Package org.apache.helix.model

Examples of org.apache.helix.model.CurrentState


    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


      }
    }

    // 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(HelixDefinedState.ERROR.toString()))
      {
        throw new HelixException("Can't reset state for " + resourceName + "/"
            + partitionNames + " on " + instanceName + ", because not all "
            + partitionNames + " are in ERROR state");
      }
View Full Code Here

    _lastCurState = lastCurState;
  }
 
  @Override
  public ZNRecord update(ZNRecord currentData) {
    CurrentState curState = null;
    if (currentData == null) {
      curState = new CurrentState(_lastCurState.getId());
      // copy all simple fields settings and overwrite session-id to current session
      curState.getRecord().setSimpleFields(_lastCurState.getRecord().getSimpleFields());
      curState.setSessionId(_curSessionId);
    } else
    {
      curState = new CurrentState(currentData);
    }
   
    for (String partitionName : _lastCurState.getPartitionStateMap().keySet()) {
      // carry-over only when current-state not exist
      if (curState.getState(partitionName) == null) {
        curState.setState(partitionName, _initState);
      }
    }
    return curState.getRecord();
  }
View Full Code Here

          createCurStateNames.add(resourceName);
          createCurStateKeys.add(keyBuilder.currentState(instanceName,
                                                         sessionId,
                                                         resourceName));

          CurrentState metaCurState = new CurrentState(resourceName);
          metaCurState.setBucketSize(message.getBucketSize());
          metaCurState.setStateModelDefRef(message.getStateModelDef());
          metaCurState.setSessionId(sessionId);
          metaCurState.setBatchMessageMode(message.getBatchMessageMode());
          String ftyName = message.getStateModelFactoryName();
          if (ftyName != null)
          {
            metaCurState.setStateModelFactoryName(ftyName);
          }
          else
          {
            metaCurState.setStateModelFactoryName(HelixConstants.DEFAULT_STATE_MODEL_FACTORY);
          }

          metaCurStates.add(metaCurState);
        }
      }
View Full Code Here

    try {
      // set current state to ERROR for the partition
      // if the transition is not canceled, it should go into error state
      if (code == ErrorCode.ERROR) {
        CurrentState currentStateDelta = new CurrentState(resourceName);
        currentStateDelta.setState(partition, HelixDefinedState.ERROR.toString());
        _stateModel.updateState(HelixDefinedState.ERROR.toString());
 
        // if transit from ERROR state, disable the partition
        if (_message.getFromState().equalsIgnoreCase(HelixDefinedState.ERROR.toString())) {
          disablePartition();
View Full Code Here

          stateModel = stateModelFactory.createAndAddStateModel(partitionKey);
          stateModel.updateState(initState);
        }

        // TODO: move currentStateDelta to StateTransitionMsgHandler
        CurrentState currentStateDelta = new CurrentState(resourceName);
        currentStateDelta.setSessionId(sessionId);
        currentStateDelta.setStateModelDefRef(stateModelName);
        currentStateDelta.setStateModelFactoryName(factoryName);
        currentStateDelta.setBucketSize(bucketSize);

        currentStateDelta.setState(partitionKey, (stateModel.getCurrentState() == null)
            ? initState : stateModel.getCurrentState());

        return new HelixStateTransitionHandler(stateModel,
                                               message,
                                               context,
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.