本文整理了Java中org.apache.helix.manager.zk.ZKHelixDataAccessor
类的一些代码示例,展示了ZKHelixDataAccessor
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKHelixDataAccessor
类的具体详情如下:
包路径:org.apache.helix.manager.zk.ZKHelixDataAccessor
类名称:ZKHelixDataAccessor
暂无
代码示例来源:origin: apache/incubator-pinot
zkClient.waitUntilConnected(CommonConstants.Helix.ZkClient.DEFAULT_CONNECT_TIMEOUT_SEC, TimeUnit.SECONDS);
ZkBaseDataAccessor<ZNRecord> baseDataAccessor = new ZkBaseDataAccessor<>(zkClient);
ZKHelixDataAccessor zkHelixDataAccessor = new ZKHelixDataAccessor(_clusterName, baseDataAccessor);
PropertyKey property = zkHelixDataAccessor.keyBuilder().liveInstances();
List<String> liveInstances = zkHelixDataAccessor.getChildNames(property);
PropertyKey controllerLeaderKey = zkHelixDataAccessor.keyBuilder().controllerLeader();
LiveInstance controllerLeaderLiveInstance = zkHelixDataAccessor.getProperty(controllerLeaderKey);
ControllerInfo controllerInfo = new ControllerInfo();
controllerInfo.leaderName = controllerLeaderLiveInstance.getId();
代码示例来源:origin: org.apache.helix/helix-core
@Deprecated
@Override
public <T extends HelixProperty> List<T> getChildValues(PropertyKey key) {
return getChildValues(key, false);
}
代码示例来源:origin: apache/helix
@Deprecated
@Override
public <T extends HelixProperty> Map<String, T> getChildValuesMap(PropertyKey key) {
return getChildValuesMap(key, false);
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public void removeInstanceTag(String clusterName, String instanceName, String tag) {
logger.info("Remove instance tag {} for instance {} in cluster {}.", tag, instanceName,
clusterName);
if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
throw new HelixException("cluster " + clusterName + " is not setup yet");
}
if (!ZKUtil.isInstanceSetup(_zkClient, clusterName, instanceName, InstanceType.PARTICIPANT)) {
throw new HelixException(
"cluster " + clusterName + " instance " + instanceName + " is not setup yet");
}
ZKHelixDataAccessor accessor =
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient));
Builder keyBuilder = accessor.keyBuilder();
InstanceConfig config = accessor.getProperty(keyBuilder.instanceConfig(instanceName));
config.removeTag(tag);
accessor.setProperty(keyBuilder.instanceConfig(instanceName), config);
}
代码示例来源:origin: apache/helix
public static String getInstanceSessionId(ZkClient zkClient, String clusterName,
String instanceName) {
ZKHelixDataAccessor accessor =
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
Builder keyBuilder = accessor.keyBuilder();
ZNRecord liveInstance = accessor.getProperty(keyBuilder.liveInstance(instanceName)).getRecord();
return liveInstance.getSimpleField(LiveInstanceProperty.SESSION_ID.toString());
}
代码示例来源:origin: apache/helix
public void createExternalView(List<String> instanceNames, int partitions, int replicas,
String dbName, long randomSeed) {
ZKHelixDataAccessor accessor =
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor(client));
Builder keyBuilder = accessor.keyBuilder();
ExternalView externalView =
new ExternalView(computeRoutingTable(instanceNames, partitions, replicas, dbName,
randomSeed));
accessor.setProperty(keyBuilder.externalView(dbName), externalView);
}
代码示例来源:origin: apache/incubator-pinot
zkClient.setZkSerializer(new ZNRecordSerializer());
HelixDataAccessor accessor =
new ZKHelixDataAccessor(helixClusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
PropertyKey.Builder keyBuilder = accessor.keyBuilder();
accessor.setProperty(keyBuilder.stateModelDef(segmentStateModelName), newStateModelDef);
代码示例来源:origin: apache/helix
private void clearStatusUpdate(String clusterName, String instance, String resource,
String partition) {
// clear status update for error partition so verify() will not fail on old
// errors
ZKHelixDataAccessor accessor =
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
Builder keyBuilder = accessor.keyBuilder();
LiveInstance liveInstance = accessor.getProperty(keyBuilder.liveInstance(instance));
accessor.removeProperty(keyBuilder.stateTransitionStatus(instance, liveInstance.getSessionId(),
resource, partition));
}
// TODO: throw exception in reset()
代码示例来源:origin: apache/helix
public static String getPropertyAsString(ZkClient zkClient, String clusterName,
PropertyKey propertyKey, MediaType mediaType) throws JsonGenerationException,
JsonMappingException, IOException {
ZKHelixDataAccessor accessor =
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
ZNRecord record = EMPTY_ZNRECORD;
HelixProperty property = accessor.getProperty(propertyKey);
if (property != null) {
record = property.getRecord();
}
return ObjectToJson(record);
}
代码示例来源:origin: org.apache.helix/helix-core
List<String> sessions = _dataAccessor.getChildNames(_keyBuilder.sessions(_instanceName));
_dataAccessor.getChildValues(_keyBuilder.currentStates(_instanceName, session));
_dataAccessor.getProperty(_keyBuilder.stateModelDef(stateModelDefRef));
BaseDataAccessor<ZNRecord> baseAccessor = _dataAccessor.getBaseDataAccessor();
String curStatePath =
_keyBuilder.currentState(_instanceName, _sessionId, lastCurState.getResourceName())
_dataAccessor.getBaseDataAccessor().update(curStatePath,
new CurStateCarryOverUpdater(_sessionId, initState, lastCurState),
AccessOption.PERSISTENT);
代码示例来源:origin: apache/helix
private void cleanupRebalanceError() {
ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(CLUSTER_NAME, _baseAccessor);
PropertyKey errorNodeKey =
accessor.keyBuilder().controllerTaskError(RebalanceResourceFailure.name());
accessor.removeProperty(errorNodeKey);
}
代码示例来源:origin: apache/helix
public void testParticipantStatusUpdates() throws Exception {
ZKHelixDataAccessor accessor =
new ZKHelixDataAccessor(CLUSTER_NAME, new ZkBaseDataAccessor(_gZkClient));
Builder keyBuilder = accessor.keyBuilder();
List<ExternalView> extViews = accessor.getChildValues(keyBuilder.externalViews());
Assert.assertNotNull(extViews);
代码示例来源:origin: apache/helix
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
Builder keyBuilder = new Builder(clusterName);
LiveInstance liveInstance = new LiveInstance("localhost_12918");
liveInstance.setSessionId("session_0");
liveInstance.setHelixVersion("version_0");
accessor.setProperty(keyBuilder.liveInstance("localhost_12918"), liveInstance);
accessor.removeProperty(keyBuilder.liveInstance("localhost_12918"));
});
Assert.assertNull(accessor.getProperty(keyBuilder.instanceConfig("localhost_12918")),
"Instance config should be dropped");
Assert.assertFalse(
代码示例来源:origin: org.apache.helix/helix-core
@Deprecated
@Override
public <T extends HelixProperty> List<T> getProperty(List<PropertyKey> keys) {
return getProperty(keys, false);
}
代码示例来源:origin: apache/helix
public static String getInstancePropertiesAsString(ZkClient zkClient, String clusterName,
PropertyKey propertyKey, MediaType mediaType) throws JsonGenerationException,
JsonMappingException, IOException {
zkClient.setZkSerializer(new ZNRecordSerializer());
ZKHelixDataAccessor accessor =
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
List<ZNRecord> records = HelixProperty.convertToList(accessor.getChildValues(propertyKey));
return ObjectToJson(records);
}
代码示例来源:origin: apache/helix
@Override
@BeforeClass
public void beforeClass() throws Exception {
System.out.println("START " + CLASS_NAME + " at " + new Date(System.currentTimeMillis()));
// setup storage cluster
_gSetupTool.addCluster(CLUSTER_NAME, true);
for (int i = 0; i < NODE_NR; i++) {
String storageNodeName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
_gSetupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
}
// start controller
String controllerName = CONTROLLER_PREFIX + "_0";
_controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
_controller.syncStart();
// start dummy participants
for (int i = 0; i < NODE_NR; i++) {
String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
_instanceNames.add(instanceName);
_participants[i] = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instanceName);
_participants[i].syncStart();
}
enablePersistBestPossibleAssignment(_gZkClient, CLUSTER_NAME, true);
accessor = new ZKHelixDataAccessor(CLUSTER_NAME, _baseAccessor);
errorNodeKey = accessor.keyBuilder().controllerTaskError(RebalanceResourceFailure.name());
_clusterVerifier =
new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).build();
}
代码示例来源:origin: apache/helix
private void setupCluster(String clusterName, ZKHelixDataAccessor accessor) throws Exception {
TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant start port
"localhost", // participant name prefix
resourceNamePrefix, // resource name prefix
1, // resources
15, // partitions per resource
participantCount, // number of nodes
3, // replicas
"MasterSlave", IdealState.RebalanceMode.FULL_AUTO, true); // do rebalance
PropertyKey.Builder keyBuilder = accessor.keyBuilder();
ClusterConfig clusterConfig = accessor.getProperty(accessor.keyBuilder().clusterConfig());
clusterConfig.setResourcePriorityField("Name");
List<StateTransitionThrottleConfig> throttleConfigs = new ArrayList<>();
throttleConfigs.add(
new StateTransitionThrottleConfig(StateTransitionThrottleConfig.RebalanceType.LOAD_BALANCE,
StateTransitionThrottleConfig.ThrottleScope.CLUSTER, 100));
throttleConfigs.add(new StateTransitionThrottleConfig(
StateTransitionThrottleConfig.RebalanceType.RECOVERY_BALANCE,
StateTransitionThrottleConfig.ThrottleScope.CLUSTER, 100));
clusterConfig.setStateTransitionThrottleConfigs(throttleConfigs);
accessor.setProperty(keyBuilder.clusterConfig(), clusterConfig);
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public <T extends HelixProperty> Map<String, T> getChildValuesMap(PropertyKey key,
boolean throwException) {
PropertyType type = key.getType();
String parentPath = key.getPath();
int options = constructOptions(type);
List<T> children = getChildValues(key, throwException);
Map<String, T> childValuesMap = new HashMap<String, T>();
for (T t : children) {
childValuesMap.put(t.getRecord().getId(), t);
}
return childValuesMap;
}
代码示例来源:origin: org.apache.helix/helix-core
private void persistHistory(ParticipantHistory history) {
PropertyKey propertyKey = _keyBuilder.participantHistory(_instanceName);
if (!_dataAccessor.setProperty(propertyKey, history)) {
LOG.error("Failed to persist participant history to zk!");
}
}
代码示例来源:origin: apache/helix
@Override
public void handleChildChange(String parentPath, List<String> currentChilds)
throws Exception {
if (currentChilds != null && currentChilds.size() > 1) {
List<ZNRecord> records =
accessor.getBaseDataAccessor().getChildren(parentPath, null, 0);
int transitionMsgCount = 0;
for (ZNRecord record : records) {
Message msg = new Message(record);
if (msg.getMsgType().equals(Message.MessageType.STATE_TRANSITION.name())) {
transitionMsgCount++;
}
}
if (transitionMsgCount > 1) {
success.set(false);
Assert.fail("Should not see more than 1 message");
}
}
}
});
内容来源于网络,如有侵权,请联系作者删除!