Examples of ResourceID


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

  @Test
  public void testMissingStateModel() throws Exception {
    Mocks.MockAccessor accessor = new Mocks.MockAccessor();

    // create an ideal state and no spec
    ResourceId masterSlaveCustomResource = ResourceId.from("masterSlaveCustomResource");
    ResourceId leaderStandbyCustomResource = ResourceId.from("leaderStandbyCustomResource");
    createIS(accessor, masterSlaveCustomResource, "MasterSlave", RebalanceMode.CUSTOMIZED);
    createIS(accessor, leaderStandbyCustomResource, "LeaderStandby", RebalanceMode.CUSTOMIZED);

    // add some state models (but not leader standby)
    addStateModels(accessor);
View Full Code Here

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

   */
  private void mapDroppedAndDisabledPartitions(Cluster cluster,
      ResourceAssignment resourceAssignment, ResourceCurrentState currentStateOutput,
      StateModelDefinition stateModelDef) {
    // get the total partition set: mapped and current state
    ResourceId resourceId = resourceAssignment.getResourceId();
    Set<PartitionId> mappedPartitions = Sets.newHashSet();
    mappedPartitions.addAll(currentStateOutput.getCurrentStateMappedPartitions(resourceId));
    mappedPartitions.addAll(resourceAssignment.getMappedPartitionIds());
    for (PartitionId partitionId : mappedPartitions) {
      // for each partition, get the dropped and disabled mappings
View Full Code Here

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

    _connection = new ZkHelixConnection(zkAddress);
    _connection.connect();
  }

  public void setNumContainers(String appName, String serviceName, int numContainers) {
    ResourceId resourceId = ResourceId.from(serviceName);

    ClusterAccessor clusterAccessor = _connection.createClusterAccessor(ClusterId.from(appName));
    Resource resource = clusterAccessor.readResource(resourceId);
    LOG.info("Current provisioner config:" + resource.getProvisionerConfig());
View Full Code Here

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

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

    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

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

    }
  }

  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

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

        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

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

    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

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

        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

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

     * @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
TOP
Copyright © 2018 www.massapi.com. 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.