Package org.apache.helix.api.id

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


      InstanceConfig instanceConfig = instanceConfigMap.get(participantName);
      UserConfig userConfig = instanceConfig.getUserConfig();
      LiveInstance liveInstance = liveInstanceMap.get(participantName);
      Map<String, Message> instanceMsgMap = messageMap.get(participantName);

      ParticipantId participantId = ParticipantId.from(participantName);

      participantMap.put(
          participantId,
          createParticipant(participantId, instanceConfig, userConfig, liveInstance,
              instanceMsgMap, currentStateMap.get(participantName)));
View Full Code Here


    if (!isClusterStructureValid()) {
      LOG.error("Cluster: " + _clusterId + " structure is not valid");
      return false;
    }

    ParticipantId participantId = participant.getId();
    InstanceConfig existConfig =
        _accessor.getProperty(_keyBuilder.instanceConfig(participantId.stringify()));
    if (existConfig != null && isParticipantStructureValid(participantId)) {
      LOG.error("Config for participant: " + participantId + " already exists in cluster: "
          + _clusterId);
      return false;
    }

    // clear and rebuild the participant structure
    clearParticipantStructure(participantId);
    initParticipantStructure(participantId);

    // add the config
    _accessor.setProperty(_keyBuilder.instanceConfig(participantId.stringify()),
        participant.getInstanceConfig());
    return true;
  }
View Full Code Here

    for (Map.Entry<String, List<String>> e : preferenceLists.entrySet()) {
      String partitionName = e.getKey();
      partitionName = String.valueOf(pId(partitionName));
      List<String> preferenceList = e.getValue();
      for (String participantName : preferenceList) {
        ParticipantId participantId = ParticipantId.from(participantName);
        if (!taskAssignment.containsKey(participantId)) {
          taskAssignment.put(participantId, new TreeSet<Integer>());
        }
        taskAssignment.get(participantId).add(Integer.valueOf(partitionName));
      }
View Full Code Here

              PartitionId.from(partition));
      Map<ParticipantId, State> pendingStateMap =
          currStateOutput.getPendingStateMap(ResourceId.from(targetResource),
              PartitionId.from(partition));
      for (Map.Entry<ParticipantId, State> e : stateMap.entrySet()) {
        ParticipantId instanceName = e.getKey();
        State state = e.getValue();
        State pending = pendingStateMap.get(instanceName);
        if (pending != null) {
          continue;
        }
View Full Code Here

      }

      // Move partitions
      Map<ParticipantId, SortedSet<Integer>> newAssignment = Maps.newHashMap();
      for (Map.Entry<ParticipantId, SortedSet<Integer>> e : origAssignment.entrySet()) {
        ParticipantId instance = e.getKey();
        SortedSet<Integer> partitions = e.getValue();
        Integer instanceId = instanceMap.get(instance);
        if (instanceId != null) {
          for (int p : partitions) {
            // Determine for each partition if there have been failures with the current assignment
            // strategy, and if so, force a shift in assignment for that partition only
            int shiftValue = getNumInstancesToShift(jobCfg, jobCtx, instances, p);
            int newInstanceId = (instanceId + shiftValue) % instances.size();
            ParticipantId newInstance = instanceMap.inverse().get(newInstanceId);
            if (newInstance == null) {
              newInstance = instance;
            }
            if (!newAssignment.containsKey(newInstance)) {
              newAssignment.put(newInstance, new TreeSet<Integer>());
View Full Code Here

        }
      }
      if (stateCount > -1) {
        int count = 0;
        for (int i = 0; i < participantPreferenceList.size(); i++) {
          ParticipantId participantId = participantPreferenceList.get(i);

          boolean notInErrorState =
              currentStateMap == null
                  || currentStateMap.get(participantId) == null
                  || !currentStateMap.get(participantId)
View Full Code Here

      CommandLine cliParser = new GnuParser().parse(opts, args);
      String zkAddress = cliParser.getOptionValue("zkAddress");
      final HelixConnection connection = new ZkHelixConnection(zkAddress);
      connection.connect();
      ClusterId clusterId = ClusterId.from(cliParser.getOptionValue("cluster"));
      ParticipantId participantId = ParticipantId.from(cliParser.getOptionValue("participantId"));
      String participantClass = cliParser.getOptionValue("participantClass");
      @SuppressWarnings("unchecked")
      Class<? extends AbstractParticipantService> clazz =
          (Class<? extends AbstractParticipantService>) Class.forName(participantClass);
      final AbstractParticipantService containerParticipant =
View Full Code Here

    int numReplicas = countStateReplicas();
    int count = countStateReplicas();
    for (PartitionId partition : _partitions) {
      for (int replicaId = 0; replicaId < count; replicaId++) {
        Replica replica = new Replica(partition, replicaId);
        ParticipantId nodeName =
            ParticipantId.from(_placementScheme.getLocation(partitionId, replicaId,
                _partitions.size(), numReplicas, nodeNames));
        preferredMapping.put(replica, _nodeMap.get(nodeName));
      }
      partitionId = partitionId + 1;
View Full Code Here

    accessor.createCluster(cluster);
  }

  private static ParticipantConfig getParticipant() {
    // identify the participant
    ParticipantId participantId = ParticipantId.from("localhost_0");

    // create (optional) participant user config properties
    UserConfig userConfig = new UserConfig(Scope.participant(participantId));
    List<String> sampleList = Lists.newArrayList("elem1", "elem2");
    userConfig.setListField("sampleList", sampleList);
View Full Code Here

    int i = 0;
    for (PartitionId partition : idealState.getPartitionIdSet()) {
      Map<ParticipantId, State> replicaMap = new HashMap<ParticipantId, State>();
      for (int j = i; j < i + lockHolders; j++) {
        int participantIndex = j % liveParticipants.size();
        ParticipantId participant = liveParticipants.get(participantIndex);
        // enforce that a participant can only have one instance of a given lock
        if (!replicaMap.containsKey(participant)) {
          replicaMap.put(participant, lockState);
        }
      }
View Full Code Here

TOP

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

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.