Examples of ClusterEvent


Examples of org.apache.helix.controller.stages.ClusterEvent

    @Override
    public void run() {
      _cache.requireFullRefresh();
      NotificationContext changeContext = new NotificationContext(_manager);
      changeContext.setType(NotificationContext.Type.CALLBACK);
      ClusterEvent event = new ClusterEvent("periodicalRebalance");
      event.addAttribute("helixmanager", changeContext.getManager());
      event.addAttribute("changeContext", changeContext);
      List<ZNRecord> dummy = new ArrayList<ZNRecord>();
      event.addAttribute("eventData", dummy);
      // Should be able to process
      _eventQueue.put(event);
    }
View Full Code Here

Examples of org.apache.helix.controller.stages.ClusterEvent

    @Override
    public void run() {
      logger.info("START ClusterEventProcessor thread");
      while (!isInterrupted()) {
        try {
          ClusterEvent event = _eventQueue.take();
          handleEvent(event);
        } catch (InterruptedException e) {
          logger.warn("ClusterEventProcessor interrupted", e);
          interrupt();
        } catch (ZkInterruptedException e) {
View Full Code Here

Examples of org.apache.helix.controller.stages.ClusterEvent

    stage.process(event);
    stage.postProcess();
  }

  BestPossibleStateOutput calculateBestPossibleState(ClusterDataCache cache) throws Exception {
    ClusterEvent event = new ClusterEvent("event");
    event.addAttribute("ClusterDataCache", cache);

    List<Stage> stages = new ArrayList<Stage>();
    stages.add(new ResourceComputationStage());
    stages.add(new CurrentStateComputationStage());
    stages.add(new BestPossibleStateCalcStage());

    for (Stage stage : stages) {
      runStage(event, stage);
    }

    return event.getAttribute(AttributeName.BEST_POSSIBLE_STATE.toString());
  }
View Full Code Here

Examples of org.apache.helix.controller.stages.ClusterEvent

          + " is not leader. Pipeline will not be invoked");
      return;
    }

    try {
      ClusterEvent event = new ClusterEvent("healthChange");
      event.addAttribute("helixmanager", _manager);
      event.addAttribute("HelixStageLatencyMonitorMap", _stageLatencyMonitorMap);

      _healthStatsAggregationPipeline.handle(event);
      _healthStatsAggregationPipeline.finish();
    } catch (Exception e) {
      LOG.error("Exception while executing pipeline: " + _healthStatsAggregationPipeline, e);
View Full Code Here

Examples of org.apache.helix.controller.stages.ClusterEvent

   * @return
   * @throws Exception
   */

  static BestPossibleStateOutput calcBestPossState(ClusterDataCache cache) throws Exception {
    ClusterEvent event = new ClusterEvent("sampleEvent");
    event.addAttribute("ClusterDataCache", cache);

    ResourceComputationStage rcState = new ResourceComputationStage();
    CurrentStateComputationStage csStage = new CurrentStateComputationStage();
    BestPossibleStateCalcStage bpStage = new BestPossibleStateCalcStage();

    runStage(event, rcState);
    runStage(event, csStage);
    runStage(event, bpStage);

    BestPossibleStateOutput output =
        event.getAttribute(AttributeName.BEST_POSSIBLE_STATE.toString());

    // System.out.println("output:" + output);
    return output;
  }
View Full Code Here

Examples of org.apache.helix.controller.stages.ClusterEvent

    stage.process(event);
    stage.postProcess();
  }

  BestPossibleStateOutput calculateBestPossibleState(Cluster cluster) throws Exception {
    ClusterEvent event = new ClusterEvent("event");
    event.addAttribute("Cluster", cluster);

    List<Stage> stages = new ArrayList<Stage>();
    stages.add(new ResourceComputationStage());
    stages.add(new CurrentStateComputationStage());
    stages.add(new BestPossibleStateCalcStage());

    for (Stage stage : stages) {
      runStage(event, stage);
    }

    return event.getAttribute(AttributeName.BEST_POSSIBLE_STATE.toString());
  }
View Full Code Here

Examples of org.apache.helix.controller.stages.ClusterEvent

    @Override
    public void run() {
      _cache.requireFullRefresh();
      NotificationContext changeContext = new NotificationContext(_manager);
      changeContext.setType(NotificationContext.Type.CALLBACK);
      ClusterEvent event = new ClusterEvent("periodicalRebalance");
      event.addAttribute("helixmanager", changeContext.getManager());
      event.addAttribute("changeContext", changeContext);
      List<ZNRecord> dummy = new ArrayList<ZNRecord>();
      event.addAttribute("eventData", dummy);
      // Should be able to process
      _eventQueue.put(event);
    }
View Full Code Here

Examples of org.apache.helix.controller.stages.ClusterEvent

    @Override
    public void run() {
      logger.info("START ClusterEventProcessor thread");
      while (!isInterrupted()) {
        try {
          ClusterEvent event = _eventQueue.take();
          handleEvent(event);
        } catch (InterruptedException e) {
          logger.warn("ClusterEventProcessor interrupted", e);
          interrupt();
        } catch (ZkInterruptedException e) {
View Full Code Here

Examples of org.apache.helix.controller.stages.ClusterEvent

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

    // Set up the event
    ClusterAccessor clusterAccessor = new ClusterAccessor(_clusterId, _dataAccessor);
    Cluster cluster = clusterAccessor.readCluster();
    ClusterEvent event = new ClusterEvent(testName);
    event.addAttribute(AttributeName.CURRENT_STATE.toString(), new ResourceCurrentState());
    Map<ResourceId, ResourceConfig> resourceConfigMap =
        Maps.transformValues(cluster.getResourceMap(), new Function<Resource, ResourceConfig>() {
          @Override
          public ResourceConfig apply(Resource resource) {
            return resource.getConfig();
          }
        });
    event.addAttribute(AttributeName.RESOURCES.toString(), resourceConfigMap);
    event.addAttribute("Cluster", cluster);

    // Run the stage
    try {
      new BestPossibleStateCalcStage().process(event);
    } catch (Exception e) {
      Assert.fail(e.toString());
    }

    // Verify the result
    BestPossibleStateOutput bestPossibleStateOutput =
        event.getAttribute(AttributeName.BEST_POSSIBLE_STATE.toString());
    Assert.assertNotNull(bestPossibleStateOutput);
    ResourceId resourceId = ResourceId.from("TestDB0");
    ResourceAssignment assignment = bestPossibleStateOutput.getResourceAssignment(resourceId);
    Assert.assertNotNull(assignment);
    Resource resource = cluster.getResource(resourceId);
View Full Code Here

Examples of org.apache.helix.controller.stages.ClusterEvent

    return calcBestPossState(cluster, null);
  }

  static BestPossibleStateOutput calcBestPossState(Cluster cluster, Set<String> resources)
      throws Exception {
    ClusterEvent event = new ClusterEvent("sampleEvent");
    event.addAttribute("Cluster", cluster);

    ResourceComputationStage rcState = new ResourceComputationStage();
    CurrentStateComputationStage csStage = new CurrentStateComputationStage();
    BestPossibleStateCalcStage bpStage = new BestPossibleStateCalcStage();

    runStage(event, rcState);

    // Filter resources if specified
    if (resources != null) {
      Map<ResourceId, ResourceConfig> resourceMap =
          event.getAttribute(AttributeName.RESOURCES.toString());
      Iterator<ResourceId> it = resourceMap.keySet().iterator();
      while (it.hasNext()) {
        ResourceId resourceId = it.next();
        if (!resources.contains(resourceId.toString())) {
          it.remove();
        }
      }
    }

    runStage(event, csStage);
    runStage(event, bpStage);

    BestPossibleStateOutput output =
        event.getAttribute(AttributeName.BEST_POSSIBLE_STATE.toString());

    return output;
  }
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.