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


Java HelixManager.getInstanceName方法代码示例

本文整理汇总了Java中org.apache.helix.HelixManager.getInstanceName方法的典型用法代码示例。如果您正苦于以下问题:Java HelixManager.getInstanceName方法的具体用法?Java HelixManager.getInstanceName怎么用?Java HelixManager.getInstanceName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.helix.HelixManager的用法示例。


在下文中一共展示了HelixManager.getInstanceName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: process

import org.apache.helix.HelixManager; //导入方法依赖的package包/类
@Override
public void process(ClusterEvent event) throws Exception {
  HelixManager manager = event.getAttribute(AttributeName.helixmanager.name());
  ClusterDataCache cache = event.getAttribute(AttributeName.ClusterDataCache.name());
  if (manager == null || cache == null) {
    throw new StageException("Missing attributes in event:" + event
        + ". Requires HelixManager | DataCache");
  }

  HelixManagerProperties properties = manager.getProperties();
  Map<String, LiveInstance> liveInstanceMap = cache.getLiveInstances();
  for (LiveInstance liveInstance : liveInstanceMap.values()) {
    String participantVersion = liveInstance.getHelixVersion();
    if (!properties.isParticipantCompatible(participantVersion)) {
      String errorMsg =
          "incompatible participant. pipeline will not continue. " + "controller: "
              + manager.getInstanceName() + ", controllerVersion: " + properties.getVersion()
              + ", minimumSupportedParticipantVersion: "
              + properties.getProperty("miminum_supported_version.participant")
              + ", participant: " + liveInstance.getInstanceName() + ", participantVersion: "
              + participantVersion;
      LOG.error(errorMsg);
      throw new StageException(errorMsg);
    }
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:27,代码来源:CompatibilityCheckStage.java

示例3: 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

示例4: tryUpdateController

import org.apache.helix.HelixManager; //导入方法依赖的package包/类
private boolean tryUpdateController(HelixManager manager) {
  HelixDataAccessor accessor = manager.getHelixDataAccessor();
  Builder keyBuilder = accessor.keyBuilder();

  LiveInstance leader = new LiveInstance(manager.getInstanceName());
  try {
    leader.setLiveInstance(ManagementFactory.getRuntimeMXBean().getName());
    leader.setSessionId(manager.getSessionId());
    leader.setHelixVersion(manager.getVersion());
    boolean success = accessor.createControllerLeader(leader);
    if (success) {
      return true;
    } else {
      LOG.info("Unable to become leader probably because some other controller becames the leader");
    }
  } catch (Exception e) {
    LOG.error(
        "Exception when trying to updating leader record in cluster:" + manager.getClusterName()
            + ". Need to check again whether leader node has been created or not", e);
  }

  leader = accessor.getProperty(keyBuilder.controllerLeader());
  if (leader != null) {
    String leaderSessionId = leader.getSessionId();
    LOG.info("Leader exists for cluster: " + manager.getClusterName() + ", currentLeader: "
        + leader.getInstanceName() + ", leaderSessionId: " + leaderSessionId);

    if (leaderSessionId != null && leaderSessionId.equals(manager.getSessionId())) {
      return true;
    }
  }
  return false;
}
 
开发者ID:apache,项目名称:helix,代码行数:34,代码来源:DistributedLeaderElection.java

示例5: callParticipantCode

import org.apache.helix.HelixManager; //导入方法依赖的package包/类
private void callParticipantCode(NotificationContext context) {
  // since ZkClient.unsubscribe() does not immediately remove listeners
  // from zk, it is possible that two listeners exist when leadership transfers
  // therefore, double check to make sure only one participant invokes the code
  if (context.getType() == Type.CALLBACK) {
    HelixManager manager = context.getManager();
    // DataAccessor accessor = manager.getDataAccessor();
    HelixDataAccessor accessor = manager.getHelixDataAccessor();
    Builder keyBuilder = accessor.keyBuilder();

    String instance = manager.getInstanceName();
    String sessionId = manager.getSessionId();

    // get resource name from partition key: "PARTICIPANT_LEADER_XXX_0"
    String resourceName = _partitionKey.substring(0, _partitionKey.lastIndexOf('_'));

    CurrentState curState =
        accessor.getProperty(keyBuilder.currentState(instance, sessionId, resourceName));
    if (curState == null) {
      return;
    }

    String state = curState.getState(_partitionKey);
    if (state == null || !state.equalsIgnoreCase("LEADER")) {
      return;
    }
  }

  try {
    _callback.onCallback(context);
  } catch (Exception e) {
    LOG.error("Error invoking callback:" + _callback, e);
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:35,代码来源:CustomCodeInvoker.java

示例6: 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

示例7: 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


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