Package org.apache.helix.model

Examples of org.apache.helix.model.CurrentState


  }
 
  public int getBucketSize(String resource)
  {
    int bucketSize = 0;
    CurrentState curStateMeta = _curStateMetaMap.get(resource);
    if (curStateMeta != null)
    {
      bucketSize = curStateMeta.getBucketSize()
    }
   
    return bucketSize;
  }
View Full Code Here


    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);
    _stateModel.rollbackOnError(_message, _notificationContext, error);
    // if the transition is not canceled, it should go into error state
    if (code == ErrorCode.ERROR)
    {
      currentStateDelta.setState(partition, "ERROR");
      _stateModel.updateState("ERROR");

      accessor.updateProperty(keyBuilder.currentState(instanceName,
                                                      _message.getTgtSessionId(),
                                                      resourceName),
View Full Code Here

      }
    }

    // check partition is in ERROR state
    String sessionId = liveInstance.getSessionId();
    CurrentState curState =
        accessor.getProperty(keyBuilder.currentState(instanceName,
                                                     sessionId,
                                                     resourceName));
    for (String partitionName : resetPartitionNames)
    {
      if (!curState.getState(partitionName).equals("ERROR"))
      {
        throw new HelixException("Can't reset state for " + resourceName + "/"
            + partitionNames + " on " + instanceName + ", because not all "
            + partitionNames + " are in ERROR state");
      }
View Full Code Here

    NotificationContext context;
    executor.registerMessageHandlerFactory(MessageType.TASK_REPLY.toString(),
                                           new AsyncCallbackService());
    // String clusterName =" testcluster";
    context = new NotificationContext(manager);
    CurrentState currentStateDelta = new CurrentState("TestDB");
    currentStateDelta.setState("TestDB_0", "OFFLINE");
    HelixStateTransitionHandler handler =
        new HelixStateTransitionHandler(stateModel,
                                        message,
                                        context,
                                        currentStateDelta,
View Full Code Here

        List<String> sessionIds =
            accessor.getChildNames(keyBuilder.sessions(instanceName));

        for (String sessionId : sessionIds)
        {
          CurrentState curState =
              accessor.getProperty(keyBuilder.currentState(instanceName,
                                                           sessionId,
                                                           resourceName));

          if (curState != null && curState.getRecord().getMapFields().size() != 0)
          {
            return false;
          }
        }
View Full Code Here

        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;
        }
      }
View Full Code Here

    return _resourceStateModelMap.get(resourceName);
  }

  public void setBucketSize(String resource, int bucketSize)
  {
    CurrentState curStateMeta = _curStateMetaMap.get(resource);
    if (curStateMeta == null)
    {
      curStateMeta = new CurrentState(resource);
      _curStateMetaMap.put(resource, curStateMeta);
    }
    curStateMeta.setBucketSize(bucketSize);
  }
View Full Code Here

        generator.generateConfigForMasterSlave());
    Builder keyBuilder = accessor.keyBuilder();
    accessor.setProperty(keyBuilder.stateModelDef("MasterSlave"), stateModelDef);

    context = new NotificationContext(manager);
    CurrentState currentStateDelta = new CurrentState("TestDB");
    currentStateDelta.setState("TestDB_0", "OFFLINE");

    HelixStateTransitionHandler stHandler = new HelixStateTransitionHandler(stateModel, message,
        context, currentStateDelta, executor);
    HelixTask handler;
    handler = new HelixTask(message, context, stHandler, executor);
View Full Code Here

    accessor.setProperty(keyBuilder.stateModelDef("MasterSlave"), stateModelDef);


    context = new NotificationContext(manager);
   
    CurrentState currentStateDelta = new CurrentState("TestDB");
    currentStateDelta.setState("TestDB_0", "OFFLINE");

    HelixStateTransitionHandler stHandler = new HelixStateTransitionHandler(stateModel, message,
        context, currentStateDelta, executor);

    HelixTask handler = new HelixTask(message, context, stHandler, executor);
View Full Code Here

    Set<String> orphanedPartitions = new HashSet<String>();
    orphanedPartitions.addAll(idealState.getPartitionSet());
    // Go through all current states and fill the assignments
    for (String liveInstanceName : liveInstances)
    {
      CurrentState currentState =
          cache.getCurrentState(liveInstanceName,
                                cache.getLiveInstances()
                                     .get(liveInstanceName)
                                     .getSessionId()).get(idealState.getId());
      if (currentState != null)
      {
        Map<String, String> partitionStates = currentState.getPartitionStateMap();
        for (String partitionName : partitionStates.keySet())
        {
          String state = partitionStates.get(partitionName);
          if (state.equals(topStateValue))
          {
View Full Code Here

TOP

Related Classes of org.apache.helix.model.CurrentState

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.