Java Code Examples for org.apache.helix.HelixManager#getInstanceType()

The following examples show how to use org.apache.helix.HelixManager#getInstanceType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ParticipantManager.java    From helix with Apache License 2.0 6 votes vote down vote up
public ParticipantManager(HelixManager manager, RealmAwareZkClient zkclient, int sessionTimeout,
    LiveInstanceInfoProvider liveInstanceInfoProvider,
    List<PreConnectCallback> preConnectCallbacks, final String sessionId,
    HelixManagerProperty helixManagerProperty) {
  _zkclient = zkclient;
  _manager = manager;
  _clusterName = manager.getClusterName();
  _instanceName = manager.getInstanceName();
  _keyBuilder = new PropertyKey.Builder(_clusterName);
  _sessionId = sessionId;
  _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;
  _helixManagerProperty = helixManagerProperty;
}
 
Example 2
Source File: DefaultMessagingService.java    From helix with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 3
Source File: TestP2PNoDuplicatedMessage.java    From helix with Apache License 2.0 5 votes vote down vote up
public MockMessagingService(HelixManager manager) {
  super(manager);
  _manager = manager;

  boolean isParticipant = false;
  if (manager.getInstanceType() == InstanceType.PARTICIPANT
      || manager.getInstanceType() == InstanceType.CONTROLLER_PARTICIPANT) {
    isParticipant = true;
  }

  _taskExecutor = new MockHelixTaskExecutor(
      new ParticipantStatusMonitor(isParticipant, manager.getInstanceName()),
      new MessageQueueMonitor(manager.getClusterName(), manager.getInstanceName()));
}
 
Example 4
Source File: ControllerStarter.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
private ServiceStatus.ServiceStatusCallback generateServiceStatusCallback(HelixManager helixManager) {
  return new ServiceStatus.ServiceStatusCallback() {
    private boolean _isStarted = false;
    private String _statusDescription = "Helix ZK Not connected as " + helixManager.getInstanceType();

    @Override
    public ServiceStatus.Status getServiceStatus() {
      if (_isStarted) {
        // If we've connected to Helix at some point, the instance status depends on being connected to ZK
        if (helixManager.isConnected()) {
          return ServiceStatus.Status.GOOD;
        } else {
          return ServiceStatus.Status.BAD;
        }
      }

      // Return starting until zk is connected
      if (!helixManager.isConnected()) {
        return ServiceStatus.Status.STARTING;
      } else {
        _isStarted = true;
        _statusDescription = ServiceStatus.STATUS_DESCRIPTION_NONE;
        return ServiceStatus.Status.GOOD;
      }
    }

    @Override
    public String getStatusDescription() {
      return _statusDescription;
    }
  };
}