Package org.apache.helix.controller.rebalancer.context

Examples of org.apache.helix.controller.rebalancer.context.SemiAutoRebalancerContext


      idealState.setStateModelDefId(partitionedContext.getStateModelDefId());
      idealState.setStateModelFactoryId(partitionedContext.getStateModelFactoryId());
      idealState.setBucketSize(bucketSize);
      idealState.setBatchMessageMode(batchMessageMode);
      if (partitionedContext.getRebalanceMode() == RebalanceMode.SEMI_AUTO) {
        SemiAutoRebalancerContext semiAutoContext =
            config.getRebalancerContext(SemiAutoRebalancerContext.class);
        for (PartitionId partitionId : semiAutoContext.getPartitionSet()) {
          idealState.setPreferenceList(partitionId, semiAutoContext.getPreferenceList(partitionId));
        }
      } else if (partitionedContext.getRebalanceMode() == RebalanceMode.CUSTOMIZED) {
        CustomRebalancerContext customContext =
            config.getRebalancerContext(CustomRebalancerContext.class);
        for (PartitionId partitionId : customContext.getPartitionSet()) {
View Full Code Here


  }

  @Override
  public ResourceAssignment computeResourceMapping(RebalancerConfig rebalancerConfig,
      Cluster cluster, ResourceCurrentState currentState) {
    SemiAutoRebalancerContext config =
        rebalancerConfig.getRebalancerContext(SemiAutoRebalancerContext.class);
    StateModelDefinition stateModelDef =
        cluster.getStateModelMap().get(config.getStateModelDefId());
    if (LOG.isDebugEnabled()) {
      LOG.debug("Processing resource:" + config.getResourceId());
    }
    ResourceAssignment partitionMapping = new ResourceAssignment(config.getResourceId());

    for (PartitionId partition : config.getPartitionSet()) {
      Map<ParticipantId, State> currentStateMap =
          currentState.getCurrentStateMap(config.getResourceId(), partition);
      Set<ParticipantId> disabledInstancesForPartition =
          ConstraintBasedAssignment.getDisabledParticipants(cluster.getParticipantMap(),
              partition);
      List<ParticipantId> preferenceList =
          ConstraintBasedAssignment.getPreferenceList(cluster, partition,
              config.getPreferenceList(partition));
      Map<State, String> upperBounds =
          ConstraintBasedAssignment.stateConstraints(stateModelDef, config.getResourceId(),
              cluster.getConfig());

      Map<ParticipantId, State> bestStateForPartition =
          ConstraintBasedAssignment.computeAutoBestStateForPartition(upperBounds, cluster
              .getLiveParticipantMap().keySet(), stateModelDef, preferenceList, currentStateMap,
View Full Code Here

   * @param resource the resource to verify
   * @param assignment the assignment to verify
   */
  private void verifySemiAutoRebalance(Resource resource, ResourceAssignment assignment) {
    Assert.assertEquals(assignment.getMappedPartitionIds().size(), resource.getSubUnitSet().size());
    SemiAutoRebalancerContext context =
        resource.getRebalancerConfig().getRebalancerContext(SemiAutoRebalancerContext.class);
    for (PartitionId partitionId : assignment.getMappedPartitionIds()) {
      List<ParticipantId> preferenceList = context.getPreferenceList(partitionId);
      Map<ParticipantId, State> replicaMap = assignment.getReplicaMap(partitionId);
      Assert.assertEquals(replicaMap.size(), preferenceList.size());
      Assert.assertEquals(replicaMap.size(), r);
      boolean hasMaster = false;
      for (ParticipantId participant : preferenceList) {
View Full Code Here

    // start: add a user config, a semi auto rebalancer context, and set bucket size and batch
    // message mode
    UserConfig userConfig = new UserConfig(Scope.resource(resourceId));
    userConfig.setSimpleField("key1", "value1");
    SemiAutoRebalancerContext rebalancerContext =
        new SemiAutoRebalancerContext.Builder(resourceId).build();
    ResourceConfig config =
        new ResourceConfig.Builder(resourceId).userConfig(userConfig)
            .rebalancerContext(rebalancerContext).bucketSize(OLD_BUCKET_SIZE)
            .batchMessageMode(true).build();
View Full Code Here

    PartitionedRebalancerContext partitionedContext =
        resource.getRebalancerConfig().getRebalancerContext(PartitionedRebalancerContext.class);
    if (partitionedContext != null) {
      // for partitioned contexts, check the mode and apply mode-specific information if possible
      if (partitionedContext.getRebalanceMode() == RebalanceMode.SEMI_AUTO) {
        SemiAutoRebalancerContext semiAutoContext =
            resource.getRebalancerConfig().getRebalancerContext(SemiAutoRebalancerContext.class);
        sb.append(", preferenceList: " + semiAutoContext.getPreferenceList(partitionId));
      } else if (partitionedContext.getRebalanceMode() == RebalanceMode.CUSTOMIZED) {
        CustomRebalancerContext customContext =
            resource.getRebalancerConfig().getRebalancerContext(CustomRebalancerContext.class);
        sb.append(", preferenceMap: " + customContext.getPreferenceMap(partitionId));
      }
View Full Code Here

  }

  private void expandResource(ClusterId clusterId, ResourceId resourceId) {
    ResourceAccessor accessor = resourceAccessor(clusterId.stringify());
    Resource resource = accessor.readResource(resourceId);
    SemiAutoRebalancerContext context =
        resource.getRebalancerConfig().getRebalancerContext(SemiAutoRebalancerContext.class);
    if (context == null) {
      LOG.info("Only SEMI_AUTO mode supported for resource expansion");
      return;
    }
    if (context.anyLiveParticipant()) {
      LOG.info("Resource uses ANY_LIVE_PARTICIPANT, skipping default assignment");
      return;
    }
    if (context.getPreferenceLists().size() == 0) {
      LOG.info("No preference lists have been set yet, skipping default assignment");
      return;
    }
    accessor.generateDefaultAssignment(resourceId, -1, null);
  }
View Full Code Here

TOP

Related Classes of org.apache.helix.controller.rebalancer.context.SemiAutoRebalancerContext

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.