Examples of CurrentState


Examples of org.apache.helix.model.CurrentState

  private void setCurrentState(String clusterName, String instance, String resourceGroupName,
      String resourceKey, String sessionId, String state) {
    ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, _baseAccessor);
    Builder keyBuilder = accessor.keyBuilder();

    CurrentState curState = new CurrentState(resourceGroupName);
    curState.setState(PartitionId.from(resourceKey), State.from(state));
    curState.setSessionId(SessionId.from(sessionId));
    curState.setStateModelDefRef("MasterSlave");
    accessor.setProperty(keyBuilder.currentState(instance, sessionId, resourceGroupName), curState);
  }
View Full Code Here

Examples of org.apache.helix.model.CurrentState

    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

Examples of org.apache.helix.model.CurrentState

    Builder keyBuilder = accessor.keyBuilder();
    accessor.setProperty(keyBuilder.liveInstance(instanceName), liveInstance);
    accessor.setProperty(keyBuilder.instanceConfig(instanceName), instanceConfig);

    String oldResource = "testResourceOld";
    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);

    Map<ResourceId, ResourceConfig> resourceMap =
        event.getAttribute(AttributeName.RESOURCES.toString());
    // +1 because it will have one for current state
    AssertJUnit.assertEquals(resources.length + 1, resourceMap.size());

    for (int i = 0; i < resources.length; i++) {
      String resourceName = resources[i];
      ResourceId resourceId = ResourceId.from(resourceName);
      IdealState idealState = idealStates.get(i);
      AssertJUnit.assertTrue(resourceMap.containsKey(resourceId));
      AssertJUnit.assertEquals(resourceMap.get(resourceId).getId(), resourceId);
      AssertJUnit.assertEquals(resourceMap.get(resourceId).getIdealState().getStateModelDefId(),
          idealState.getStateModelDefId());
      AssertJUnit.assertEquals(resourceMap.get(resourceId).getSubUnitSet().size(),
          idealState.getNumPartitions());
    }
    // Test the data derived from CurrentState
    ResourceId oldResourceId = ResourceId.from(oldResource);
    AssertJUnit.assertTrue(resourceMap.containsKey(oldResourceId));
    AssertJUnit.assertEquals(resourceMap.get(oldResourceId).getId(), oldResourceId);
    AssertJUnit.assertEquals(resourceMap.get(oldResourceId).getIdealState().getStateModelDefId(),
        currentState.getStateModelDefId());
    AssertJUnit.assertEquals(resourceMap.get(oldResourceId).getSubUnitSet().size(), currentState
        .getTypedPartitionStateMap().size());

  }
View Full Code Here

Examples of org.nimbustools.messaging.gt4_0.generated.types.CurrentState

    }

    private static boolean isState(OneReport_Type report,
                                   CurrentState_Enumeration target) {

        final CurrentState state = report.getCurrentState();
        if (state == null) {
            return false;
        }
        return CurrentState_Enumeration.Running.equals(state.getState());
    }
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.