当前位置: 首页>>代码示例>>Java>>正文


Java HelixManager.getClusterName方法代码示例

本文整理汇总了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;
}
 
开发者ID:uber,项目名称:uReplicator,代码行数:26,代码来源:HelixUtils.java

示例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;
}
 
开发者ID:uber,项目名称:uReplicator,代码行数:17,代码来源:HelixUtils.java

示例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;
}
 
开发者ID:uber,项目名称:chaperone,代码行数:26,代码来源:HelixUtils.java

示例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;
}
 
开发者ID:apache,项目名称:helix,代码行数:19,代码来源:ParticipantManager.java

示例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());
    }
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:22,代码来源:GenericLeaderStandbyModel.java

示例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);
}
 
开发者ID:apache,项目名称:helix,代码行数:17,代码来源:DefaultMessagingService.java

示例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);
  }
}
 
开发者ID:uber,项目名称:uReplicator,代码行数:10,代码来源:AutoRebalanceLiveInstanceChangeListener.java

示例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.");
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:29,代码来源:HelixTask.java

示例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++;
    }
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:29,代码来源:TestEnablePartitionDuringDisable.java

示例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;
}
 
开发者ID:apache,项目名称:helix,代码行数:14,代码来源:FileStoreStateModel.java

示例11: GobblinHelixTaskDriver

import org.apache.helix.HelixManager; //导入方法依赖的package包/类
public GobblinHelixTaskDriver(HelixManager manager) {
  this(manager.getClusterManagmentTool(), manager.getHelixDataAccessor(), manager
      .getConfigAccessor(), manager.getHelixPropertyStore(), manager.getClusterName());
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:5,代码来源:GobblinHelixTaskDriver.java

示例12: ControllerLeaderLocator

import org.apache.helix.HelixManager; //导入方法依赖的package包/类
ControllerLeaderLocator(HelixManager helixManager) {
  _helixManager = helixManager;
  _clusterName = helixManager.getClusterName();
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:5,代码来源:ControllerLeaderLocator.java


注:本文中的org.apache.helix.HelixManager.getClusterName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。