Package org.apache.helix.api

Examples of org.apache.helix.api.TransitionHandler


   */
  static void checkStateModelMap(StateTransitionHandlerFactory<? extends TransitionHandler> fty,
      Map<PartitionId, String> expectStateModelMap) {
    Assert.assertEquals(fty.getPartitionSet().size(), expectStateModelMap.size());
    for (PartitionId partition : fty.getPartitionSet()) {
      TransitionHandler stateModel = fty.getTransitionHandler(partition);
      String actualState = stateModel.getCurrentState();
      String expectState = expectStateModelMap.get(partition);
      LOG.debug(partition + " actual state: " + actualState + ", expect state: " + expectState);
      Assert.assertEquals(actualState, expectState, "partition: " + partition
          + " should be in state: " + expectState + " but was " + actualState);
    }
View Full Code Here


  public void reset() {
    for (Map<String, StateTransitionHandlerFactory<? extends TransitionHandler>> ftyMap : _stateModelFactoryMap
        .values()) {
      for (StateTransitionHandlerFactory<? extends TransitionHandler> stateModelFactory : ftyMap.values()) {
        for (PartitionId partition : stateModelFactory.getPartitionSet()) {
          TransitionHandler stateModel = stateModelFactory.getTransitionHandler(partition);
          stateModel.reset();
          String initialState = _stateModelParser.getInitialState(stateModel.getClass());
          stateModel.updateState(initialState);
          // TODO probably should update the state on ZK. Shi confirm what needs
          // to be done here.
        }
      }
    }
View Full Code Here

    }

    if (message.getBatchMessageMode() == false) {
      // create currentStateDelta for this partition
      String initState = _stateModelDefs.get(message.getStateModelDefId()).getInitialState();
      TransitionHandler stateModel = stateModelFactory.getTransitionHandler(partitionKey);
      if (stateModel == null) {
        stateModel = stateModelFactory.createAndAddSTransitionHandler(partitionKey);
        stateModel.updateState(initState);
      }

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

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

      return new HelixStateTransitionHandler(stateModelFactory, stateModel, message, context,
          currentStateDelta);
    } else {
View Full Code Here

    if (ftyMap.isEmpty()) {
      _stateModelFactoryMap.remove(stateModelDefId);
    }

    for (PartitionId partition : fty.getPartitionSet()) {
      TransitionHandler stateModel = fty.getTransitionHandler(partition);
      stateModel.reset();
      // TODO probably should remove the state from zookeeper
    }

    return true;
  }
View Full Code Here

TOP

Related Classes of org.apache.helix.api.TransitionHandler

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.