Package org.apache.helix.api.id

Examples of org.apache.helix.api.id.ResourceId


          ClusterStateVerifier.calcBestPossState(cluster, resources);

      // set error states
      if (errStates != null) {
        for (String resourceName : errStates.keySet()) {
          ResourceId resourceId = ResourceId.from(resourceName);
          Map<String, String> partErrStates = errStates.get(resourceName);
          ResourceAssignment resourceAssignment = bestPossOutput.getResourceAssignment(resourceId);

          ResourceAssignmentBuilder raBuilder = new ResourceAssignmentBuilder(resourceId);
          List<? extends PartitionId> mappedPartitions = resourceAssignment.getMappedPartitionIds();
View Full Code Here


    if (resources != null) {
      Map<ResourceId, ResourceConfig> resourceMap =
          event.getAttribute(AttributeName.RESOURCES.toString());
      Iterator<ResourceId> it = resourceMap.keySet().iterator();
      while (it.hasNext()) {
        ResourceId resourceId = it.next();
        if (!resources.contains(resourceId.toString())) {
          it.remove();
        }
      }
    }
View Full Code Here

        event.getAttribute(AttributeName.RESOURCES.toString());
    AssertJUnit.assertEquals(resources.length, 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());
View Full Code Here

    // +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
View Full Code Here

  }

  private BestPossibleStateOutput getEmptyBestPossibleStateOutput(List<IdealState> idealStates) {
    BestPossibleStateOutput output = new BestPossibleStateOutput();
    for (IdealState idealState : idealStates) {
      ResourceId resourceId = idealState.getResourceId();
      ResourceAssignment assignment = new ResourceAssignment(resourceId);
      for (PartitionId partitionId : idealState.getPartitionIdSet()) {
        Map<ParticipantId, State> emptyMap = Collections.emptyMap();
        assignment.addReplicaMap(partitionId, emptyMap);
      }
View Full Code Here

  @Test
  public void testIdealStateValidity() throws Exception {
    Mocks.MockAccessor accessor = new Mocks.MockAccessor();

    // create some ideal states
    ResourceId masterSlaveCustomResource = ResourceId.from("masterSlaveCustomResource");
    ResourceId onlineOfflineFullAutoResource = ResourceId.from("onlineOfflineFullAutoResource");
    ResourceId masterSlaveSemiAutoInvalidResource =
        ResourceId.from("masterSlaveSemiAutoInvalidResource");
    createIS(accessor, masterSlaveCustomResource, "MasterSlave", RebalanceMode.CUSTOMIZED);
    createIS(accessor, onlineOfflineFullAutoResource, "OnlineOffline", RebalanceMode.FULL_AUTO);
    createIS(accessor, masterSlaveSemiAutoInvalidResource, "MasterSlave", RebalanceMode.SEMI_AUTO);
View Full Code Here

  @Test
  public void testNoSpec() throws Exception {
    Mocks.MockAccessor accessor = new Mocks.MockAccessor();

    // create an ideal state and no spec
    ResourceId masterSlaveCustomResource = ResourceId.from("masterSlaveCustomResource");
    createIS(accessor, masterSlaveCustomResource, "MasterSlave", RebalanceMode.CUSTOMIZED);

    // add some state models
    addStateModels(accessor);
View Full Code Here

  @Test
  public void testMissingStateModel() throws Exception {
    Mocks.MockAccessor accessor = new Mocks.MockAccessor();

    // create an ideal state and no spec
    ResourceId masterSlaveCustomResource = ResourceId.from("masterSlaveCustomResource");
    ResourceId leaderStandbyCustomResource = ResourceId.from("leaderStandbyCustomResource");
    createIS(accessor, masterSlaveCustomResource, "MasterSlave", RebalanceMode.CUSTOMIZED);
    createIS(accessor, leaderStandbyCustomResource, "LeaderStandby", RebalanceMode.CUSTOMIZED);

    // add some state models (but not leader standby)
    addStateModels(accessor);
View Full Code Here

   */
  private void mapDroppedAndDisabledPartitions(Cluster cluster,
      ResourceAssignment resourceAssignment, ResourceCurrentState currentStateOutput,
      StateModelDefinition stateModelDef) {
    // get the total partition set: mapped and current state
    ResourceId resourceId = resourceAssignment.getResourceId();
    Set<PartitionId> mappedPartitions = Sets.newHashSet();
    mappedPartitions.addAll(currentStateOutput.getCurrentStateMappedPartitions(resourceId));
    mappedPartitions.addAll(resourceAssignment.getMappedPartitionIds());
    for (PartitionId partitionId : mappedPartitions) {
      // for each partition, get the dropped and disabled mappings
View Full Code Here

    _connection = new ZkHelixConnection(zkAddress);
    _connection.connect();
  }

  public void setNumContainers(String appName, String serviceName, int numContainers) {
    ResourceId resourceId = ResourceId.from(serviceName);

    ClusterAccessor clusterAccessor = _connection.createClusterAccessor(ClusterId.from(appName));
    Resource resource = clusterAccessor.readResource(resourceId);
    LOG.info("Current provisioner config:" + resource.getProvisionerConfig());
View Full Code Here

TOP

Related Classes of org.apache.helix.api.id.ResourceId

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.