Package org.apache.helix.model

Examples of org.apache.helix.model.CurrentState


    _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(SessionId.from(_curSessionId));
    } else {
      curState = new CurrentState(currentData);
    }

    for (PartitionId partitionId : _lastCurState.getTypedPartitionStateMap().keySet()) {
      // carry-over only when current-state not exist
      if (curState.getState(partitionId) == null) {
        curState.setState(partitionId, State.from(_initState));
      }
    }
    return curState.getRecord();
  }
View Full Code Here


      for (String instanceName : instanceNames) {
        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;
          }
        }

        ExternalView extView = accessor.getProperty(keyBuilder.externalView(resourceName));
View Full Code Here

    accessor.setProperty(keyBuilder.externalView("db-12345"), extView);
    Thread.sleep(100);
    AssertJUnit.assertTrue(testListener.externalViewChangeReceived);
    testListener.Reset();

    CurrentState curState = new CurrentState("db-12345");
    curState.setSessionId(SessionId.from("sessionId"));
    curState.setStateModelDefRef("StateModelDef");
    accessor.setProperty(keyBuilder.currentState("localhost_8900", testHelixManager.getSessionId(),
        curState.getId()), curState);
    Thread.sleep(100);
    AssertJUnit.assertTrue(testListener.currentStateChangeReceived);
    testListener.Reset();

    IdealState idealState = new IdealState("db-1234");
View Full Code Here

    MockStateModel stateModel = new MockStateModel();
    executor.registerMessageHandlerFactory(MessageType.TASK_REPLY.toString(),
        new AsyncCallbackService());

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

    StateModelFactory<MockStateModel> stateModelFactory = new StateModelFactory<MockStateModel>() {

      @Override
      public MockStateModel createNewStateModel(String partitionName) {
View Full Code Here

        stateModel = stateModelFactory.createAndAddStateModel(partitionKey.stringify());
        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,
View Full Code Here

    record.setSimpleField(CurrentStateProperty.SESSION_ID.toString(), _sessionId.toString());
    record.setSimpleField(CurrentStateProperty.STATE_MODEL_DEF.toString(),
        _stateModelDefId.toString());
    record.setSimpleField(CurrentStateProperty.STATE_MODEL_FACTORY_NAME.toString(),
        _stateModelFactoryId.toString());
    return new CurrentState(record);
  }
View Full Code Here

      Map<ResourceId, CurrentState> curStateMap = participant.getCurrentStateMap();
      Assert.assertEquals(curStateMap.size(), 1);

      ResourceId resourceId = ResourceId.from("TestDB0");
      Assert.assertTrue(curStateMap.containsKey(resourceId));
      CurrentState curState = curStateMap.get(resourceId);
      Map<PartitionId, State> partitionStateMap = curState.getTypedPartitionStateMap();
      Assert.assertEquals(partitionStateMap.size(), p);
    }

    Map<ResourceId, Resource> resourceMap = cluster.getResourceMap();
    Assert.assertEquals(resourceMap.size(), 1);
View Full Code Here

        new StateModelDefinition(StateModelConfigGenerator.generateConfigForMasterSlave());
    Builder keyBuilder = accessor.keyBuilder();
    accessor.setProperty(keyBuilder.stateModelDef("MasterSlave"), stateModelDef);

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

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

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

    context = new NotificationContext(manager);

    CurrentState currentStateDelta = new CurrentState("TestDB");
    currentStateDelta.setState(PartitionId.from("TestDB_0"), State.from("OFFLINE"));

    StateModelFactory<MockStateModelAnnotated> stateModelFactory =
        new StateModelFactory<MockStateModelAnnotated>() {

          @Override
View Full Code Here

      }
    }

    // check partition is in ERROR state
    SessionId sessionId = liveInstance.getTypedSessionId();
    CurrentState curState =
        accessor.getProperty(keyBuilder.currentState(instanceName, sessionId.stringify(),
            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

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.