本文整理汇总了Java中org.apache.helix.HelixManager.getClusterName方法的典型用法代码示例。如果您正苦于以下问题:Java HelixManager.getClusterName方法的具体用法?Java HelixManager.getClusterName怎么用?Java HelixManager.getClusterName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.helix.HelixManager
的用法示例。
在下文中一共展示了HelixManager.getClusterName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInstanceToTopicPartitionsMap
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
/**
* From IdealStates.
*
* @return InstanceToNumTopicPartitionMap
*/
public static Map<String, Set<TopicPartition>> getInstanceToTopicPartitionsMap(
HelixManager helixManager) {
Map<String, Set<TopicPartition>> instanceToNumTopicPartitionMap =
new HashMap<String, Set<TopicPartition>>();
HelixAdmin helixAdmin = helixManager.getClusterManagmentTool();
String helixClusterName = helixManager.getClusterName();
for (String topic : helixAdmin.getResourcesInCluster(helixClusterName)) {
IdealState is = helixAdmin.getResourceIdealState(helixClusterName, topic);
for (String partition : is.getPartitionSet()) {
TopicPartition tpi = new TopicPartition(topic, Integer.parseInt(partition));
for (String instance : is.getInstanceSet(partition)) {
if (!instanceToNumTopicPartitionMap.containsKey(instance)) {
instanceToNumTopicPartitionMap.put(instance, new HashSet<TopicPartition>());
}
instanceToNumTopicPartitionMap.get(instance).add(tpi);
}
}
}
return instanceToNumTopicPartitionMap;
}
示例2: getUnassignedPartitions
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
public static Set<TopicPartition> getUnassignedPartitions(HelixManager helixManager) {
Set<TopicPartition> unassignedPartitions = new HashSet<TopicPartition>();
HelixAdmin helixAdmin = helixManager.getClusterManagmentTool();
String helixClusterName = helixManager.getClusterName();
for (String topic : helixAdmin.getResourcesInCluster(helixClusterName)) {
IdealState is = helixAdmin.getResourceIdealState(helixClusterName, topic);
int numPartitions = is.getNumPartitions();
for (int partition = 0; partition < numPartitions; ++partition) {
if (is.getInstanceSet(Integer.toString(partition)).isEmpty()) {
TopicPartition tpi = new TopicPartition(topic, partition);
unassignedPartitions.add(tpi);
}
}
}
return unassignedPartitions;
}
示例3: getInstanceToTopicPartitionsMap
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
/**
* From IdealStates.
* @param helixManager
* @return InstanceToNumTopicPartitionMap
*/
public static Map<String, Set<TopicPartition>> getInstanceToTopicPartitionsMap(
HelixManager helixManager) {
Map<String, Set<TopicPartition>> instanceToNumTopicPartitionMap =
new HashMap<String, Set<TopicPartition>>();
HelixAdmin helixAdmin = helixManager.getClusterManagmentTool();
String helixClusterName = helixManager.getClusterName();
for (String topic : helixAdmin.getResourcesInCluster(helixClusterName)) {
IdealState is = helixAdmin.getResourceIdealState(helixClusterName, topic);
for (String partition : is.getPartitionSet()) {
TopicPartition tpi = new TopicPartition(topic, Integer.parseInt(partition));
for (String instance : is.getInstanceSet(partition)) {
if (!instanceToNumTopicPartitionMap.containsKey(instance)) {
instanceToNumTopicPartitionMap.put(instance, new HashSet<TopicPartition>());
}
instanceToNumTopicPartitionMap.get(instance).add(tpi);
}
}
}
return instanceToNumTopicPartitionMap;
}
示例4: ParticipantManager
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
public ParticipantManager(HelixManager manager, ZkClient zkclient, int sessionTimeout,
LiveInstanceInfoProvider liveInstanceInfoProvider, List<PreConnectCallback> preConnectCallbacks) {
_zkclient = zkclient;
_manager = manager;
_clusterName = manager.getClusterName();
_instanceName = manager.getInstanceName();
_keyBuilder = new PropertyKey.Builder(_clusterName);
_sessionId = manager.getSessionId();
_sessionTimeout = sessionTimeout;
_configAccessor = manager.getConfigAccessor();
_instanceType = manager.getInstanceType();
_helixAdmin = manager.getClusterManagmentTool();
_dataAccessor = (ZKHelixDataAccessor) manager.getHelixDataAccessor();
_messagingService = (DefaultMessagingService) manager.getMessagingService();
_stateMachineEngine = manager.getStateMachineEngine();
_liveInstanceInfoProvider = liveInstanceInfoProvider;
_preConnectCallbacks = preConnectCallbacks;
}
示例5: onBecomeStandbyFromLeader
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
@Transition(to = "STANDBY", from = "LEADER")
public void onBecomeStandbyFromLeader(Message message, NotificationContext context) {
LOG.info("Become STANDBY from LEADER");
HelixManager manager = context.getManager();
if (manager == null) {
throw new IllegalArgumentException("Require HelixManager in notification conext");
}
Builder keyBuilder = new Builder(manager.getClusterName());
for (ChangeType notificationType : _notificationTypes) {
if (notificationType == ChangeType.LIVE_INSTANCE) {
manager.removeListener(keyBuilder.liveInstances(), _particHolder);
} else if (notificationType == ChangeType.CONFIG) {
manager.removeListener(keyBuilder.instanceConfigs(), _particHolder);
} else if (notificationType == ChangeType.EXTERNAL_VIEW) {
manager.removeListener(keyBuilder.externalViews(), _particHolder);
} else {
LOG.error("Unsupport notificationType:" + notificationType.toString());
}
}
}
示例6: DefaultMessagingService
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
public DefaultMessagingService(HelixManager manager) {
_manager = manager;
_evaluator = new CriteriaEvaluator();
boolean isParticipant = false;
if (manager.getInstanceType() == InstanceType.PARTICIPANT || manager.getInstanceType() == InstanceType.CONTROLLER_PARTICIPANT) {
isParticipant = true;
}
_taskExecutor = new HelixTaskExecutor(
new ParticipantStatusMonitor(isParticipant, manager.getInstanceName()),
new MessageQueueMonitor(manager.getClusterName(), manager.getInstanceName()));
_asyncCallbackService = new AsyncCallbackService();
_taskExecutor.registerMessageHandlerFactory(MessageType.TASK_REPLY.name(),
_asyncCallbackService);
}
示例7: assignIdealStates
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
private static void assignIdealStates(HelixManager helixManager,
Map<String, IdealState> idealStatesFromAssignment) {
HelixAdmin helixAdmin = helixManager.getClusterManagmentTool();
String helixClusterName = helixManager.getClusterName();
for (String topic : idealStatesFromAssignment.keySet()) {
IdealState idealState = idealStatesFromAssignment.get(topic);
helixAdmin.setResourceIdealState(helixClusterName, topic, idealState);
}
}
示例8: reportMessageStat
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
private void reportMessageStat(HelixManager manager, Message message, HelixTaskResult taskResult) {
// report stat
if (!message.getMsgType().equals(MessageType.STATE_TRANSITION.name())) {
return;
}
long now = new Date().getTime();
long msgReadTime = message.getReadTimeStamp();
long msgExecutionStartTime = message.getExecuteStartTimeStamp();
if (msgReadTime != 0 && msgExecutionStartTime != 0) {
long totalDelay = now - msgReadTime;
long executionDelay = now - msgExecutionStartTime;
if (totalDelay > 0 && executionDelay > 0) {
String fromState = message.getFromState();
String toState = message.getToState();
String transition = fromState + "--" + toState;
StateTransitionContext cxt =
new StateTransitionContext(manager.getClusterName(), manager.getInstanceName(),
message.getResourceName(), transition);
StateTransitionDataPoint data =
new StateTransitionDataPoint(totalDelay, executionDelay, taskResult.isSuccess());
_executor.getParticipantMonitor().reportTransitionStat(cxt, data);
}
} else {
logger.warn("message read time and start execution time not recorded.");
}
}
示例9: doTransition
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
@Override
public void doTransition(Message message, NotificationContext context) {
HelixManager manager = context.getManager();
String clusterName = manager.getClusterName();
String instance = message.getTgtName();
String partitionName = message.getPartitionName();
String fromState = message.getFromState();
String toState = message.getToState();
if (instance.equals("localhost_12919") && partitionName.equals("TestDB0_0")) {
if (fromState.equals("SLAVE") && toState.equals("OFFLINE")) {
slaveToOfflineCnt++;
try {
String command =
"--zkSvr " + ZK_ADDR + " --enablePartition true " + clusterName
+ " localhost_12919 TestDB0 TestDB0_0";
ClusterSetup.processCommandLineArgs(command.split("\\s+"));
} catch (Exception e) {
LOG.error("Exception in cluster setup", e);
}
} else if (slaveToOfflineCnt > 0 && fromState.equals("OFFLINE") && toState.equals("SLAVE")) {
offlineToSlave++;
}
}
}
示例10: FileStoreStateModel
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
public FileStoreStateModel(HelixManager manager, String resource, String partition) {
String clusterName = manager.getClusterName();
String instanceName = manager.getInstanceName();
instanceConfig = manager.getClusterManagmentTool().getInstanceConfig(clusterName, instanceName);
replicator = new Replicator(instanceConfig, resource, partition);
try {
manager.addExternalViewChangeListener(replicator);
} catch (Exception e) {
e.printStackTrace();
}
_partition = partition;
_serverId = instanceName;
}
示例11: GobblinHelixTaskDriver
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
public GobblinHelixTaskDriver(HelixManager manager) {
this(manager.getClusterManagmentTool(), manager.getHelixDataAccessor(), manager
.getConfigAccessor(), manager.getHelixPropertyStore(), manager.getClusterName());
}
示例12: ControllerLeaderLocator
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
ControllerLeaderLocator(HelixManager helixManager) {
_helixManager = helixManager;
_clusterName = helixManager.getClusterName();
}