Package org.apache.helix.api.id

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


        }
      }
    }

    for (int i = 0; i < targetNumContainers; i++) {
      ParticipantId participantId = ParticipantId.from(resourceId + "_container_" + (i));
      excessActiveContainers.remove(participantId); // don't stop this container if active
      if (excessHaltedContainers.containsKey(participantId)) {
        // Halted containers can be restarted if necessary
        // Participant participant = excessHaltedContainers.get(participantId);
        // containersToStart.add(participant);
View Full Code Here


  public void stopContainer(String appName, String participantName) throws Exception {
    ClusterId clusterId = ClusterId.from(appName);
    ClusterAccessor clusterAccessor = _connection.createClusterAccessor(clusterId);
    HelixDataAccessor dataAccessor = _connection.createDataAccessor(clusterId);
    ParticipantId participantId = ParticipantId.from(participantName);
    Participant participant = clusterAccessor.readParticipant(participantId);
    if (participant != null && participant.isAlive()) {
      Message message = new Message(MessageType.SHUTDOWN, UUID.randomUUID().toString());
      message.setTgtName(participant.getId().toString());
      message.setTgtSessionId(participant.getLiveInstance().getSessionId());
View Full Code Here

    System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));

    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");
View Full Code Here

    while (iter.hasNext()) {
      Message message = iter.next();
      ResourceId resourceId = message.getResourceId();
      ResourceConfig resource = resourceMap.get(resourceId);

      ParticipantId participantId = ParticipantId.from(message.getTgtName());
      Participant liveParticipant = liveParticipantMap.get(participantId);
      String participantVersion = null;
      if (liveParticipant != null) {
        participantVersion = liveParticipant.getLiveInstance().getHelixVersion();
      }
View Full Code Here

      // Get instance->[partition, ...] mappings for the target resource.
      Map<ParticipantId, SortedSet<Integer>> tgtPartitionAssignments =
          getTaskAssignment(currStateOutput, prevAssignment, liveInstances, jobCfg, jobCtx,
              workflowConfig, workflowCtx, allPartitions, cache);
      for (Map.Entry<ParticipantId, SortedSet<Integer>> entry : taskAssignments.entrySet()) {
        ParticipantId instance = entry.getKey();
        if (!tgtPartitionAssignments.containsKey(instance)) {
          continue;
        }
        // Contains the set of task partitions currently assigned to the instance.
        Set<Integer> pSet = entry.getValue();
        int numToAssign = jobCfg.getNumConcurrentTasksPerInstance() - pSet.size();
        if (numToAssign > 0) {
          List<Integer> nextPartitions =
              getNextPartitions(tgtPartitionAssignments.get(instance), excludeSet, numToAssign);
          for (Integer pId : nextPartitions) {
            String pName = pName(jobResource, pId);
            paMap.put(pId,
                new PartitionAssignment(instance.toString(), TaskPartitionState.RUNNING.name()));
            excludeSet.add(pId);
            jobCtx.setAssignedParticipant(pId, instance.toString());
            jobCtx.setPartitionState(pId, TaskPartitionState.INIT);
            LOG.debug(String.format("Setting task partition %s state to %s on instance %s.", pName,
                TaskPartitionState.RUNNING, instance));
          }
        }
View Full Code Here

    }

    ResourceCurrentState currentStateOutput = new ResourceCurrentState();

    for (Participant liveParticipant : cluster.getLiveParticipantMap().values()) {
      ParticipantId participantId = liveParticipant.getId();

      // add pending messages
      Map<MessageId, Message> instanceMsgs = liveParticipant.getMessageMap();
      for (Message message : instanceMsgs.values()) {
        if (!MessageType.STATE_TRANSITION.toString().equalsIgnoreCase(message.getMsgType())) {
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

          }

          for (String partitionName : partErrStates.keySet()) {
            String instanceName = partErrStates.get(partitionName);
            PartitionId partitionId = PartitionId.from(partitionName);
            ParticipantId participantId = ParticipantId.from(instanceName);
            raBuilder.addAssignment(partitionId, participantId,
                State.from(HelixDefinedState.ERROR.toString()));
          }
          bestPossOutput.setResourceAssignment(resourceId, raBuilder.build());
View Full Code Here

    int i = 0;
    for (PartitionId partition : context.getPartitionSet()) {
      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

    final String testSimpleValue = "testValue";
    final List<String> testListValue = ImmutableList.of("testValue");
    final Map<String, String> testMapValue = ImmutableMap.of("testInnerKey", "testValue");

    // first, add Helix configuration to an InstanceConfig
    ParticipantId participantId = ParticipantId.from("testParticipant");
    InstanceConfig instanceConfig = new InstanceConfig(participantId);
    instanceConfig.setHostName("localhost");

    // now, add user configuration
    UserConfig userConfig = new UserConfig(Scope.participant(participantId));
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.