Package org.apache.helix.PropertyKey

Examples of org.apache.helix.PropertyKey.Builder.currentState()


    CurrentState stateWithDeadSession = new CurrentState(record2);
    stateWithDeadSession.setSessionId(SessionId.from("session_dead"));
    stateWithDeadSession.setStateModelDefRef("MasterSlave");
    stateWithDeadSession.setState(PartitionId.from("testResourceName_1"), State.from("MASTER"));

    accessor.setProperty(keyBuilder.currentState("localhost_3", "session_3", "testResourceName"),
        stateWithLiveSession);
    accessor.setProperty(
        keyBuilder.currentState("localhost_3", "session_dead", "testResourceName"),
        stateWithDeadSession);
    runStage(event, new ReadClusterDataStage());
View Full Code Here


    stateWithDeadSession.setState(PartitionId.from("testResourceName_1"), State.from("MASTER"));

    accessor.setProperty(keyBuilder.currentState("localhost_3", "session_3", "testResourceName"),
        stateWithLiveSession);
    accessor.setProperty(
        keyBuilder.currentState("localhost_3", "session_dead", "testResourceName"),
        stateWithDeadSession);
    runStage(event, new ReadClusterDataStage());
    runStage(event, stage);
    ResourceCurrentState output3 = event.getAttribute(AttributeName.CURRENT_STATE.toString());
    State currentState =
View Full Code Here

    CurrentState currentState = new CurrentState(oldResource);
    currentState.setState(PartitionId.from("testResourceOld_0"), State.from("OFFLINE"));
    currentState.setState(PartitionId.from("testResourceOld_1"), State.from("SLAVE"));
    currentState.setState(PartitionId.from("testResourceOld_2"), State.from("MASTER"));
    currentState.setStateModelDefRef("MasterSlave");
    accessor.setProperty(keyBuilder.currentState(instanceName, sessionId, oldResource),
        currentState);

    ResourceComputationStage stage = new ResourceComputationStage();
    runStage(event, new ReadClusterDataStage());
    runStage(event, stage);
View Full Code Here

          && message.getMsgType().equals(Message.MessageType.STATE_TRANSITION.toString())) {
        ResourceId resourceId = message.getResourceId();
        if (!curResourceNames.contains(resourceId.stringify())
            && !createCurStateNames.contains(resourceId.stringify())) {
          createCurStateNames.add(resourceId.stringify());
          createCurStateKeys.add(keyBuilder.currentState(instanceName, sessionId,
              resourceId.stringify()));

          CurrentState metaCurState = new CurrentState(resourceId.stringify());
          metaCurState.setBucketSize(message.getBucketSize());
          metaCurState.setStateModelDefRef(message.getStateModelDef());
View Full Code Here

    }

    try {
      // Update the ZK current state of the node
      PropertyKey key =
          keyBuilder.currentState(instanceName, sessionId.stringify(), resource.stringify(),
              bucketizer.getBucketName(partitionId.stringify()));
      if (_message.getAttribute(Attributes.PARENT_MSG_ID) == null) {
        // normal message
        accessor.updateProperty(key, _currentStateDelta);
      } else {
View Full Code Here

        // if transit from ERROR state, disable the partition
        if (_message.getTypedFromState().toString().equalsIgnoreCase(HelixDefinedState.ERROR.toString())) {
          disablePartition();
        }
        accessor.updateProperty(keyBuilder.currentState(instanceName, _message.getTypedTgtSessionId()
            .stringify(), resourceId.stringify()), currentStateDelta);
      }
    } finally {
      StateTransitionError error = new StateTransitionError(type, code, e);
      _stateModel.rollbackOnError(_message, _notificationContext, error);
View Full Code Here

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

      List<ZNRecord> instanceCurrentStateList = new ArrayList<ZNRecord>();
      for (ZNRecord idealState : idealStateList) {
        String resourceName = idealState.getId();

        HelixProperty property =
            accessor.getProperty(keyBuilder.currentState(host, sessionId, resourceName));
        ZNRecord currentState = null;
        if (property == null) {
          _logger.warn("Resource " + resourceName + " has null currentState");
          currentState = new ZNRecord(resourceName);
        } else {
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
Copyright © 2018 www.massapi.com. 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.