Package org.apache.helix

Examples of org.apache.helix.HelixManager


  @Transition(to="LEADER",from="STANDBY")
  public void onBecomeLeaderFromStandby(Message message, NotificationContext context)
      throws Exception
  {
    LOG.info("Become LEADER from STANDBY");
    HelixManager manager = context.getManager();
    if (manager == null)
    {
      throw new IllegalArgumentException("Require HelixManager in notification conext");
    }
    for (ChangeType notificationType : _notificationTypes)
    {
      if (notificationType == ChangeType.LIVE_INSTANCE)
      {
        manager.addLiveInstanceChangeListener(_particHolder);
      }
      else if (notificationType == ChangeType.CONFIG)
      {
        manager.addConfigChangeListener(_particHolder);
      }
      else if (notificationType == ChangeType.EXTERNAL_VIEW)
      {
        manager.addExternalViewChangeListener(_particHolder);
      }
      else
      {
        LOG.error("Unsupport notificationType:" + notificationType.toString());
      }
View Full Code Here


  @Transition(to="STANDBY",from="LEADER")
  public void onBecomeStandbyFromLeader(Message message, NotificationContext context)
  {
    LOG.info("Become STANDBY from LEADER");
    HelixManager manager = context.getManager();
    manager.removeListener(_particHolder);   
  }
View Full Code Here

            break;
          }
          else if (_command._commandType == CommandType.STOP)
          {
            // TODO add data trigger for STOP command
            HelixManager manager = _command._nodeOpArg._manager;
            manager.disconnect();
            Thread thread = _command._nodeOpArg._thread;
            thread.interrupt();

            // System.err.println("stop " +
            // _command._nodeOpArg._manager.getInstanceName());
View Full Code Here

                                               NotificationContext context)
  {
    synchronized (_stateModel)
    {
      HelixTaskResult taskResult = new HelixTaskResult();
      HelixManager manager = context.getManager();
      HelixDataAccessor accessor = manager.getHelixDataAccessor();

      _statusUpdateUtil.logInfo(message,
                                HelixStateTransitionHandler.class,
                                "Message handling task begin execute",
                                accessor);
View Full Code Here

    if (type == ErrorType.INTERNAL)
    {
      logger.error("Skip internal error " + e.getMessage() + " " + code);
      return;
    }
    HelixManager manager = _notificationContext.getManager();
    HelixDataAccessor accessor = manager.getHelixDataAccessor();
    Builder keyBuilder = accessor.keyBuilder();

    String instanceName = manager.getInstanceName();
    String partition = _message.getPartitionName();
    String resourceName = _message.getResourceName();
    CurrentState currentStateDelta = new CurrentState(resourceName);

    StateTransitionError error = new StateTransitionError(type, code, e);
View Full Code Here

  @Override
  public void process(ClusterEvent event) throws Exception
  {
    long startTime = System.currentTimeMillis();

    HelixManager manager = event.getAttribute("helixmanager");
    if (manager == null)
    {
      throw new StageException("HelixManager attribute value is null");
    }
    // DataAccessor dataAccessor = manager.getDataAccessor();
    HelixDataAccessor accessor = manager.getHelixDataAccessor();
    _cache.refresh(accessor);

    event.addAttribute("HealthDataCache", _cache);

    long processLatency = System.currentTimeMillis() - startTime;
View Full Code Here

    String zkAddr = args[0];
    String clusterName = args[1];
    String instanceName = args[2];

    HelixManager manager = null;
    try
    {
      manager = HelixManagerFactory.getZKHelixManager(clusterName, instanceName,
          InstanceType.PARTICIPANT, zkAddr);

      StateMachineEngine stateMach = manager.getStateMachineEngine();
      DummyMSModelFactory msModelFactory = new DummyMSModelFactory();
      stateMach.registerStateModelFactory("MasterSlave", msModelFactory);

      manager.connect();

      Thread.currentThread().join();
    } catch (Exception e)
    {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } finally
    {
      if (manager != null)
      {
        manager.disconnect();
      }
    }
  }
View Full Code Here

   *
   * @param event
   */
  protected synchronized void handleEvent(ClusterEvent event)
  {
    HelixManager manager = event.getAttribute("helixmanager");
    if (manager == null)
    {
      logger.error("No cluster manager in event:" + event.getName());
      return;
    }

    if (!manager.isLeader())
    {
      logger.error("Cluster manager: " + manager.getInstanceName()
          + " is not leader. Pipeline will not be invoked");
      return;
    }

    if (_paused)
    {
      logger.info("Cluster is paused. Ignoring the event:" + event.getName());
      return;
    }

    NotificationContext context = null;
    if (event.getAttribute("changeContext") != null)
    {
      context = (NotificationContext) (event.getAttribute("changeContext"));
    }

    // Initialize _clusterStatusMonitor
    if (context != null)
    {
      if (context.getType() == Type.FINALIZE)
      {
        if (_clusterStatusMonitor != null)
        {
          _clusterStatusMonitor.reset();
          _clusterStatusMonitor = null;
        }
       
        stopRebalancingTimer();
        logger.info("Get FINALIZE notification, skip the pipeline. Event :" + event.getName());
        return;
      }
      else
      {
        if (_clusterStatusMonitor == null)
        {
          _clusterStatusMonitor = new ClusterStatusMonitor(manager.getClusterName());
        }
       
        event.addAttribute("clusterStatusMonitor", _clusterStatusMonitor);
      }
    }
View Full Code Here

  {
    for (LiveInstance instance : liveInstances)
    {
      String instanceName = instance.getId();
      String clientSessionId = instance.getSessionId();
      HelixManager manager = changeContext.getManager();

      // _instanceCurrentStateChangeSubscriptionSessionIds contains all the sessionIds
      // that we've added a currentState listener
      if (!_instanceCurrentStateChangeSubscriptionSessionIds.contains(clientSessionId))
      {
        try
        {
          manager.addCurrentStateChangeListener(this, instanceName, clientSessionId);
          _instanceCurrentStateChangeSubscriptionSessionIds.add(clientSessionId);
          logger.info("Observing client session id: " + clientSessionId);
        }
        catch (Exception e)
        {
          logger.error("Exception adding current state and message listener for instance:"
                           + instanceName,
                       e);
        }
      }

      // _instanceSubscriptionNames contains all the instanceNames that we've added a
      // message listener
      if (!_instanceSubscriptionNames.contains(instanceName))
      {
        try
        {
          logger.info("Adding message listener for " + instanceName);
          manager.addMessageListener(this, instanceName);
          _instanceSubscriptionNames.add(instanceName);
        }
        catch (Exception e)
        {
          logger.error("Exception adding message listener for instance:" + instanceName,
View Full Code Here

  @BeforeClass()
  public synchronized void setup()
  {

    final String[] array = new String[] { "localhost_8900", "localhost_8901" };
    HelixManager manager = new Mocks.MockManager() {
      private MockAccessor _mockAccessor;

      @Override
//      public DataAccessor getDataAccessor()
      public HelixDataAccessor getHelixDataAccessor()
View Full Code Here

TOP

Related Classes of org.apache.helix.HelixManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.