Package org.apache.helix.api.id

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


    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


    List<Message> outputMessages = new ArrayList<Message>();

    Iterator<Message> iter = messages.iterator();
    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;
View Full Code Here

    }
  }

  private static ResourceAssignment emptyAssignment(String name,
      ResourceCurrentState currStateOutput) {
    ResourceId resourceId = ResourceId.from(name);
    ResourceAssignment assignment = new ResourceAssignment(resourceId);
    Set<PartitionId> partitions = currStateOutput.getCurrentStateMappedPartitions(resourceId);
    for (PartitionId partition : partitions) {
      Map<ParticipantId, State> currentStateMap =
          currStateOutput.getCurrentStateMap(resourceId, partition);
View Full Code Here

        if (!liveParticipant.getLiveInstance().getSessionId().equals(message.getTgtSessionId())) {
          continue;
        }

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

        if (!message.getBatchMessageMode()) {
          PartitionId partitionId = message.getPartitionId();
          if (idealState.getPartitionIdSet().contains(partitionId)) {
            currentStateOutput.setPendingState(resourceId, partitionId, participantId,
                message.getTypedToState());
          } else {
            // log
          }
        } else {
          List<PartitionId> partitionNames = message.getPartitionIds();
          if (!partitionNames.isEmpty()) {
            for (PartitionId partitionId : partitionNames) {
              if (idealState.getPartitionIdSet().contains(partitionId)) {
                currentStateOutput.setPendingState(resourceId, partitionId, participantId,
                    message.getTypedToState());
              } else {
                // log
              }
            }
          }
        }
      }

      // add current state
      SessionId sessionId = SessionId.from(liveParticipant.getLiveInstance().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

    clusterAccessor.createCluster(new ClusterConfig.Builder(clusterId)
        .addStateModelDefinition(statelessService).addStateModelDefinition(taskStateModel).build());
    for (String service : applicationSpec.getServices()) {
      String resourceName = service;
      // add the resource with the local provisioner
      ResourceId resourceId = ResourceId.from(resourceName);

      ServiceConfig serviceConfig = applicationSpec.getServiceConfig(resourceName);
      serviceConfig.setSimpleField("service_name", service);
      int numContainers = serviceConfig.getIntField("num_containers", 1);
View Full Code Here

        new StateModelDefinition(StateModelConfigGenerator.generateConfigForMasterSlave());
    clusterAccessor.createCluster(new ClusterConfig.Builder(clusterId).addStateModelDefinition(
        masterSlave).build());

    // add the resource with the local provisioner
    ResourceId resourceId = ResourceId.from(resourceName);
    ProvisionerConfig provisionerConfig = new LocalProvisionerConfig(resourceId);
    AutoRebalanceModeISBuilder idealStateBuilder = new AutoRebalanceModeISBuilder(resourceId);
    for (int i = 0; i < NUM_PARTITIONS; i++) {
      idealStateBuilder.add(PartitionId.from(resourceId, String.valueOf(i)));
    }
View Full Code Here

     * @param accessor the physical accessor
     */
    public void merge(HelixDataAccessor accessor) {
      // Construct the logical delta
      ResourceConfig deltaConfig = _builder.build();
      ResourceId resourceId = deltaConfig.getId();

      // Update the ideal state if set
      IdealState updatedIdealState = deltaConfig.getIdealState();
      if (updatedIdealState != null) {
        accessor.updateProperty(accessor.keyBuilder().idealStates(resourceId.toString()),
            updatedIdealState);
      }

      // Update the resource config if any of its inner configs is set
      boolean addedAnything = false;
      ResourceConfiguration updatedResourceConfig = new ResourceConfiguration(resourceId);
      ProvisionerConfig provisionerConfig = deltaConfig.getProvisionerConfig();
      if (provisionerConfig != null) {
        updatedResourceConfig.addNamespacedConfig(new ProvisionerConfigHolder(provisionerConfig)
            .toNamespacedConfig());
        addedAnything = true;
      }
      RebalancerConfig rebalancerConfig = deltaConfig.getRebalancerConfig();
      if (rebalancerConfig != null) {
        updatedResourceConfig.addNamespacedConfig(new RebalancerConfigHolder(rebalancerConfig)
            .toNamespacedConfig());
        addedAnything = true;
      }
      UserConfig userConfig = deltaConfig.getUserConfig();
      if (userConfig != null) {
        updatedResourceConfig.addNamespacedConfig(userConfig);
        addedAnything = true;
      }
      if (addedAnything) {
        accessor.updateProperty(accessor.keyBuilder().resourceConfig(resourceId.toString()),
            updatedResourceConfig);
      }
    }
View Full Code Here

    return participantBuilder.build();
  }

  private static ResourceConfig getResource(StateModelDefinition stateModelDef) {
    // identify the resource
    ResourceId resourceId = ResourceId.from("exampleResource");

    // create a partition
    Partition partition1 = new Partition(PartitionId.from(resourceId, "1"));

    // create a second partition
View Full Code Here

        new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(
            manager.getClusterName()).build();
    String json = clusterConfig.get(clusterScope, message.getResourceId().stringify());
    Dag.Node node = Dag.Node.fromJson(json);
    Set<String> parentIds = node.getParentIds();
    ResourceId resourceId = message.getResourceId();
    int numPartitions = node.getNumPartitions();
    Task task =
        _taskFactory.createTask(resourceId.stringify(), parentIds, manager, _taskResultStore);
    manager.addExternalViewChangeListener(task);

    LOG.debug("Starting task for " + _partition + "...");
    int partitionNum = Integer.parseInt(_partition.split("_")[1]);
    task.execute(resourceId.stringify(), numPartitions, partitionNum);
    LOG.debug("Task for " + _partition + " done");
  }
View Full Code Here

  }

  protected Map<ResourceId, ResourceConfig> getResourceMap(List<IdealState> idealStates) {
    Map<ResourceId, ResourceConfig> resourceMap = new HashMap<ResourceId, ResourceConfig>();
    for (IdealState idealState : idealStates) {
      ResourceId resourceId = idealState.getResourceId();
      RebalancerContext context = PartitionedRebalancerContext.from(idealState);
      Resource resource =
          new Resource(resourceId, ResourceType.DATA, idealState, null, null, context,
              new UserConfig(Scope.resource(resourceId)), idealState.getBucketSize(),
              idealState.getBatchMessageMode());
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.