Package org.apache.helix.api

Examples of org.apache.helix.api.Cluster


public class ResourceComputationStage extends AbstractBaseStage {
  private static Logger LOG = Logger.getLogger(ResourceComputationStage.class);

  @Override
  public void process(ClusterEvent event) throws StageException {
    Cluster cluster = event.getAttribute("ClusterDataCache");
    if (cluster == null) {
      throw new StageException("Missing attributes in event: " + event + ". Requires Cluster");
    }

    Map<ResourceId, ResourceConfig> resCfgMap = new HashMap<ResourceId, ResourceConfig>();
    Map<ResourceId, ResourceConfig> csResCfgMap = getCurStateResourceCfgMap(cluster);

    // ideal-state may be removed, add all resource config in current-state but not in ideal-state
    for (ResourceId resourceId : csResCfgMap.keySet()) {
      if (!cluster.getResourceMap().keySet().contains(resourceId)) {
        resCfgMap.put(resourceId, csResCfgMap.get(resourceId));
      }
    }

    for (ResourceId resourceId : cluster.getResourceMap().keySet()) {
      Resource resource = cluster.getResource(resourceId);
      RebalancerConfig rebalancerCfg = resource.getRebalancerConfig();

      ResourceConfig.Builder resCfgBuilder = new ResourceConfig.Builder(resourceId);
      resCfgBuilder.bucketSize(resource.getBucketSize());
      resCfgBuilder.batchMessageMode(resource.getBatchMessageMode());
View Full Code Here


  }

  @Override
  public boolean verify() throws Exception {
    ClusterAccessor clusterAccessor = new ClusterAccessor(ClusterId.from(_clusterName), _accessor);
    Cluster cluster = clusterAccessor.readCluster();

    List<ParticipantId> liveInstances = new ArrayList<ParticipantId>();
    liveInstances.addAll(cluster.getLiveParticipantMap().keySet());
    boolean success = verifyLiveNodes(liveInstances);
    if (!success) {
      LOG.info("liveNodes not match, expect: " + _expectSortedLiveNodes + ", actual: "
          + liveInstances);
      return false;
View Full Code Here

    return new HashSet<ConstraintItem>(selectedItems.values());
  }

  @Override
  public void process(ClusterEvent event) throws Exception {
    Cluster cluster = event.getAttribute("ClusterDataCache");
    MessageOutput msgSelectionOutput =
        event.getAttribute(AttributeName.MESSAGES_SELECTED.toString());
    Map<ResourceId, ResourceConfig> resourceMap =
        event.getAttribute(AttributeName.RESOURCES.toString());
    BestPossibleStateOutput bestPossibleStateOutput =
        event.getAttribute(AttributeName.BEST_POSSIBLE_STATE.toString());

    if (cluster == null || resourceMap == null || msgSelectionOutput == null
        || bestPossibleStateOutput == null) {
      throw new StageException("Missing attributes in event: " + event
          + ". Requires ClusterDataCache|RESOURCES|BEST_POSSIBLE_STATE|MESSAGES_SELECTED");
    }

    MessageOutput output = new MessageOutput();

    // TODO fix it
    ClusterConstraints constraint = cluster.getConstraint(ConstraintType.MESSAGE_CONSTRAINT);
    Map<String, Integer> throttleCounterMap = new HashMap<String, Integer>();

    if (constraint != null) {
      // go through all pending messages, they should be counted but not throttled
      for (ParticipantId participantId : cluster.getLiveParticipantMap().keySet()) {
        Participant liveParticipant = cluster.getLiveParticipantMap().get(participantId);
        throttle(throttleCounterMap, constraint, new ArrayList<Message>(liveParticipant
            .getMessageMap().values()), false);
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.helix.api.Cluster

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.