Package org.apache.helix.api.accessor

Examples of org.apache.helix.api.accessor.ParticipantAccessor


  }

  private static void updateParticipant(ParticipantConfig participant, ClusterId clusterId,
      HelixConnection connection) {
    // add a tag to the participant and change the hostname, then update it using a delta
    ParticipantAccessor accessor = connection.createParticipantAccessor(clusterId);
    ParticipantConfig.Delta delta =
        new ParticipantConfig.Delta(participant.getId()).addTag("newTag").setHostName("newHost");
    accessor.updateParticipant(participant.getId(), delta);
  }
View Full Code Here


    HelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, _baseAccessor);
    return new ClusterAccessor(ClusterId.from(clusterName), accessor);
  }

  ParticipantAccessor participantAccessor(String clusterName) {
    return new ParticipantAccessor(new ZKHelixDataAccessor(clusterName, _baseAccessor));
  }
View Full Code Here

  void addInstanceTag(String[] optValues) {
    String clusterName = optValues[0];
    String participantName = optValues[1];
    String tag = optValues[2];

    ParticipantAccessor accessor = participantAccessor(clusterName);
    ParticipantId participantId = ParticipantId.from(participantName);

    ParticipantConfig.Delta delta = new ParticipantConfig.Delta(participantId);
    delta.addTag(tag);
    accessor.updateParticipant(participantId, delta);
  }
View Full Code Here

  void removeInstanceTag(String[] optValues) {
    String clusterName = optValues[0];
    String participantName = optValues[1];
    String tag = optValues[2];

    ParticipantAccessor accessor = participantAccessor(clusterName);
    ParticipantId participantId = ParticipantId.from(participantName);

    ParticipantConfig.Delta delta = new ParticipantConfig.Delta(participantId);
    delta.removeTag(tag);
    accessor.updateParticipant(participantId, delta);
  }
View Full Code Here

    if (instanceId.indexOf(":") != -1) {
      instanceId = instanceId.replaceAll(":", "_");
    }
    boolean enabled = Boolean.parseBoolean(optValues[2].toLowerCase());

    ParticipantAccessor accessor = participantAccessor(clusterName);
    if (enabled) {
      accessor.enableParticipant(ParticipantId.from(instanceId));
    } else {
      accessor.disableParticipant(ParticipantId.from(instanceId));
    }
  }
View Full Code Here

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

    ParticipantAccessor accessor = participantAccessor(clusterName);
    if (enabled) {
      accessor.enablePartitionsForParticipant(participantId, resourceId, partitionIdSet);
    } else {
      accessor.disablePartitionsForParticipant(participantId, resourceId, partitionIdSet);
    }
  }
View Full Code Here

      results = keyValueMap(accessor.readUserConfig(), null, keys);
      break;
    }
    case PARTICIPANT: {
      ParticipantId participantId = ParticipantId.from(scopeArgs[1]);
      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;
    }
    default:
      System.err.println("Non-recognized scopeType: " + scopeType);
      break;
View Full Code Here

      accessor.setUserConfig(userConfig);
      break;
    }
    case PARTICIPANT: {
      ParticipantId participantId = ParticipantId.from(scopeArgs[1]);
      ParticipantAccessor accessor = participantAccessor(clusterName);
      Scope<ParticipantId> scope = Scope.participant(participantId);
      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);
      break;
    }
    default:
      System.err.println("Non-recognized scopeType: " + scopeType);
      break;
View Full Code Here

  }

  void listParticipantInfo(String[] optValues) {
    String clusterName = optValues[0];
    String participantName = optValues[1];
    ParticipantAccessor accessor = participantAccessor(clusterName);
    ParticipantId participantId = ParticipantId.from(participantName);
    Participant participant = accessor.readParticipant(participantId);
    StringBuilder sb =
        new StringBuilder("Participant ").append(participantName).append(" in cluster ")
            .append(clusterName).append(":\n").append("hostName: ")
            .append(participant.getHostName()).append(", port: ").append(participant.getPort())
            .append(", enabled: ").append(participant.isEnabled()).append(", disabledPartitions: ")
View Full Code Here

      userConfig = resourceAccessor.readUserConfig(resourceId);
      removeKeysFromUserConfig(userConfig, keys);
      resourceAccessor.setUserConfig(resourceId, userConfig);
      break;
    case PARTICIPANT:
      ParticipantAccessor participantAccessor = participantAccessor(clusterName);
      ParticipantId participantId = ParticipantId.from(scopeArgs[1]);
      userConfig = participantAccessor.readUserConfig(participantId);
      removeKeysFromUserConfig(userConfig, keys);
      participantAccessor.setUserConfig(participantId, userConfig);
      break;
    case PARTITION:
      ResourceAccessor resourcePartitionAccessor = resourceAccessor(clusterName);
      PartitionId partitionId = PartitionId.from(scopeArgs[1]);
      userConfig = resourcePartitionAccessor.readUserConfig(partitionId.getResourceId());
View Full Code Here

TOP

Related Classes of org.apache.helix.api.accessor.ParticipantAccessor

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.