Package org.apache.helix.api.id

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


   * lists should prefer nodes in the current mapping at all times, but when all nodes are in the
   * current mapping, then it should distribute states as evenly as possible.
   */
  @Test
  public void testOrphansNotPreferred() {
    final ResourceId RESOURCE = ResourceId.from("resource");
    final PartitionId[] PARTITIONS =
        {
            PartitionId.from("resource_0"), PartitionId.from("resource_1"),
            PartitionId.from("resource_2")
        };
View Full Code Here


    String zkAddr = ZK_ADDR;
    ClusterId clusterId = ClusterId.from(clusterName);
    ControllerId controllerId = ControllerId.from("controller");
    final ParticipantId participantId = ParticipantId.from("participant1");

    ResourceId resourceId = ResourceId.from("testDB");
    State master = State.from("MASTER");
    State slave = State.from("SLAVE");
    State offline = State.from("OFFLINE");
    State dropped = State.from("DROPPED");
    StateModelDefId stateModelDefId = StateModelDefId.from("MasterSlave");
View Full Code Here

  public boolean setResource(ResourceConfig resourceConfig) {
    if (resourceConfig == null || resourceConfig.getRebalancerConfig() == null) {
      LOG.error("Resource not fully defined with a rebalancer context");
      return false;
    }
    ResourceId resourceId = resourceConfig.getId();
    ResourceConfiguration config = new ResourceConfiguration(resourceId);
    config.addNamespacedConfig(resourceConfig.getUserConfig());
    config.addNamespacedConfig(resourceConfig.getRebalancerConfig().toNamespacedConfig());
    config.setBucketSize(resourceConfig.getBucketSize());
    config.setBatchMessageMode(resourceConfig.getBatchMessageMode());
View Full Code Here

        if (!liveParticipant.getRunningInstance().getSessionId()
            .equals(message.getTypedTgtSessionId())) {
          continue;
        }

        ResourceId resourceId = message.getResourceId();
        ResourceConfig resource = resourceMap.get(resourceId);
        if (resource == null) {
          continue;
        }

        if (!message.getBatchMessageMode()) {
          PartitionId partitionId = message.getPartitionId();
          Partition partition = resource.getSubUnit(partitionId);
          if (partition != null) {
            currentStateOutput.setPendingState(resourceId, partitionId, participantId,
                message.getTypedToState());
          } else {
            // log
          }
        } else {
          List<PartitionId> partitionNames = message.getPartitionIds();
          if (!partitionNames.isEmpty()) {
            for (PartitionId partitionId : partitionNames) {
              Partition partition = resource.getSubUnit(partitionId);
              if (partition != null) {
                currentStateOutput.setPendingState(resourceId, partitionId, participantId,
                    message.getTypedToState());
              } else {
                // log
              }
            }
          }
        }
      }

      // add current state
      SessionId sessionId = liveParticipant.getRunningInstance().getSessionId();
      Map<ResourceId, CurrentState> curStateMap = liveParticipant.getCurrentStateMap();
      for (CurrentState curState : curStateMap.values()) {
        if (!sessionId.equals(curState.getTypedSessionId())) {
          continue;
        }

        ResourceId resourceId = curState.getResourceId();
        StateModelDefId stateModelDefId = curState.getStateModelDefId();
        ResourceConfig resource = resourceMap.get(resourceId);
        if (resource == null) {
          continue;
        }
View Full Code Here

    int bucketSize = bucketSizeValues == null ? 0 : Integer.parseInt(bucketSizeValues[0]);

    int maxPartitionsPerNode =
        maxPartitionsPerNodeValues == null ? -1 : Integer.parseInt(maxPartitionsPerNodeValues[0]);

    ResourceId resourceId = ResourceId.from(resourceName);
    StateModelDefId stateModelDefId = StateModelDefId.from(stateModelDefName);

    IdealState idealState = new IdealState(resourceName);
    idealState.setRebalanceMode(rebalancerMode);
    idealState.setNumPartitions(partitionNumber);
View Full Code Here

  void listPartitionInfo(String[] optValues) {
    String clusterName = optValues[0];
    String resourceName = optValues[1];
    String partitionName = optValues[2];

    ResourceId resourceId = ResourceId.from(resourceName);
    PartitionId partitionId = PartitionId.from(partitionName);
    ResourceAccessor accessor = resourceAccessor(clusterName);
    Resource resource = accessor.readResource(resourceId);

    StringBuilder sb = new StringBuilder();
View Full Code Here

  void enablePartition(String[] optValues) {
    boolean enabled = Boolean.parseBoolean(optValues[0].toLowerCase());
    String clusterName = optValues[1];
    ParticipantId participantId = ParticipantId.from(optValues[2]);
    ResourceId resourceId = ResourceId.from(optValues[3]);

    Set<PartitionId> partitionIdSet = new HashSet<PartitionId>();
    for (int i = 4; i < optValues.length; i++) {
      partitionIdSet.add(PartitionId.from(optValues[i]));
    }
View Full Code Here

      ParticipantAccessor accessor = participantAccessor(clusterName);
      results = keyValueMap(accessor.readUserConfig(participantId), null, keys);
      break;
    }
    case RESOURCE: {
      ResourceId resourceId = ResourceId.from(scopeArgs[1]);
      ResourceAccessor accessor = resourceAccessor(clusterName);
      results = keyValueMap(accessor.readUserConfig(resourceId), null, keys);
      break;
    }
    case PARTITION: {
      ResourceId resourceId = ResourceId.from(scopeArgs[1]);
      String partitionId = scopeArgs[2];
      ResourceAccessor accessor = resourceAccessor(clusterName);
      results = keyValueMap(accessor.readUserConfig(resourceId), partitionId, keys);
      break;
    }
View Full Code Here

      UserConfig userConfig = userConfig(scope, null, keyValues);
      accessor.setUserConfig(participantId, userConfig);
      break;
    }
    case RESOURCE: {
      ResourceId resourceId = ResourceId.from(scopeArgs[1]);
      ResourceAccessor accessor = resourceAccessor(clusterName);
      Scope<ResourceId> scope = Scope.resource(resourceId);
      UserConfig userConfig = userConfig(scope, null, keyValues);
      accessor.setUserConfig(resourceId, userConfig);
      break;
    }
    case PARTITION: {
      ResourceId resourceId = ResourceId.from(scopeArgs[1]);
      String partitionId = scopeArgs[2];
      ResourceAccessor accessor = resourceAccessor(clusterName);
      Scope<ResourceId> scope = Scope.resource(resourceId);
      UserConfig userConfig = userConfig(scope, partitionId, keyValues);
      accessor.setUserConfig(resourceId, userConfig);
View Full Code Here

  void listResourceInfo(String[] optValues) {
    String clusterName = optValues[0];
    String resourceName = optValues[1];
    ResourceAccessor accessor = resourceAccessor(clusterName);
    ResourceId resourceId = ResourceId.from(resourceName);
    Resource resource = accessor.readResource(resourceId);
    StringBuilder sb =
        new StringBuilder("Resource ").append(resourceName).append(" in cluster ")
            .append(clusterName).append(":\n").append("externalView: ")
            .append(resource.getExternalView()).append(", userConfig: ")
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.