Package org.apache.helix.monitoring.mbeans

Examples of org.apache.helix.monitoring.mbeans.ClusterStatusMonitor


    ClusterAccessor clusterAccessor = new ClusterAccessor(clusterId, accessor, _cache);

    Cluster cluster = clusterAccessor.readCluster();

    // Update the cluster status gauges
    ClusterStatusMonitor clusterStatusMonitor =
        (ClusterStatusMonitor) event.getAttribute("clusterStatusMonitor");
    if (clusterStatusMonitor != null) {
      Set<String> instanceSet = Sets.newHashSet();
      Set<String> liveInstanceSet = Sets.newHashSet();
      Set<String> disabledInstanceSet = Sets.newHashSet();
      Map<String, Set<String>> disabledPartitions = Maps.newHashMap();
      Map<String, Set<String>> tags = Maps.newHashMap();
      for (Participant participant : cluster.getParticipantMap().values()) {
        instanceSet.add(participant.getId().toString());
        if (participant.isAlive()) {
          liveInstanceSet.add(participant.getId().toString());
        }
        if (!participant.isEnabled()) {
          disabledInstanceSet.add(participant.getId().toString());
        }
        Set<String> partitionNames = Sets.newHashSet();
        for (PartitionId partitionId : participant.getDisabledPartitionIds()) {
          partitionNames.add(partitionId.toString());
        }
        disabledPartitions.put(participant.getId().toString(), partitionNames);
        tags.put(participant.getId().toString(), participant.getTags());
      }
      clusterStatusMonitor.setClusterInstanceStatus(liveInstanceSet, instanceSet,
          disabledInstanceSet, disabledPartitions, tags);
    }

    event.addAttribute("Cluster", cluster);
    event.addAttribute("ClusterDataCache", _cache);
View Full Code Here


          }
        }
      }

      // Update cluster status monitor mbean
      ClusterStatusMonitor clusterStatusMonitor =
          (ClusterStatusMonitor) event.getAttribute("clusterStatusMonitor");
      IdealState idealState = cache._idealStateMap.get(view.getResourceName());
      if (idealState != null) {
        if (clusterStatusMonitor != null
            && !idealState.getStateModelDefRef().equalsIgnoreCase(
                DefaultSchedulerMessageHandlerFactory.SCHEDULER_TASK_QUEUE)) {
          StateModelDefinition stateModelDef =
              cache.getStateModelDef(idealState.getStateModelDefRef());
          clusterStatusMonitor.setResourceStatus(view,
              cache._idealStateMap.get(view.getResourceName()), stateModelDef);
        }
      } else {
        // Drop the metrics for the dropped resource
        clusterStatusMonitor.unregisterResource(view.getResourceName());
      }

      // compare the new external view with current one, set only on different
      ExternalView curExtView = curExtViews.get(resourceId.stringify());
      if (curExtView == null || !curExtView.getRecord().equals(view.getRecord())) {
View Full Code Here

        stopRebalancingTimer();
        logger.info("Get FINALIZE notification, skip the pipeline. Event :" + event.getName());
        return;
      } else {
        if (_clusterStatusMonitor == null) {
          _clusterStatusMonitor = new ClusterStatusMonitor(manager.getClusterName());
        }

        event.addAttribute("clusterStatusMonitor", _clusterStatusMonitor);
      }
    }
View Full Code Here

    ClusterId clusterId = ClusterId.from(manager.getClusterName());
    ClusterAccessor clusterAccessor = new ClusterAccessor(clusterId, accessor);

    Cluster cluster = clusterAccessor.readCluster();

    ClusterStatusMonitor clusterStatusMonitor =
        (ClusterStatusMonitor) event.getAttribute("clusterStatusMonitor");
    if (clusterStatusMonitor != null) {
      // TODO fix it
      // int disabledInstances = 0;
      // int disabledPartitions = 0;
View Full Code Here

        stopRebalancingTimer();
        logger.info("Get FINALIZE notification, skip the pipeline. Event :" + event.getName());
        return;
      } else {
        if (_clusterStatusMonitor == null) {
          _clusterStatusMonitor = new ClusterStatusMonitor(manager.getClusterName());
        }

        event.addAttribute("clusterStatusMonitor", _clusterStatusMonitor);
      }
    }
View Full Code Here

    BestPossibleStateOutput bestPossibleStateOutput =
        compute(event, resourceMap, currentStateOutput);
    event.addAttribute(AttributeName.BEST_POSSIBLE_STATE.name(), bestPossibleStateOutput);

    try {
      ClusterStatusMonitor clusterStatusMonitor =
          (ClusterStatusMonitor) event.getAttribute("clusterStatusMonitor");
      if (clusterStatusMonitor != null) {
        clusterStatusMonitor.setPerInstanceResourceStatus(bestPossibleStateOutput,
            cache.getInstanceConfigMap(), resourceMap, cache.getStateModelDefMap());
      }
    } catch (Exception e) {
      logger.error("Could not update cluster status metrics!", e);
    }
View Full Code Here

            // }
          }
        }
      }
      // Update cluster status monitor mbean
      ClusterStatusMonitor clusterStatusMonitor =
          (ClusterStatusMonitor) event.getAttribute("clusterStatusMonitor");
      IdealState idealState = cache._idealStateMap.get(view.getResourceName());
      if (idealState != null) {
        if (clusterStatusMonitor != null
            && !idealState.getStateModelDefRef().equalsIgnoreCase(
                DefaultSchedulerMessageHandlerFactory.SCHEDULER_TASK_QUEUE)) {
          StateModelDefinition stateModelDef =
              cache.getStateModelDef(idealState.getStateModelDefRef());
          clusterStatusMonitor.setResourceStatus(view,
              cache._idealStateMap.get(view.getResourceName()), stateModelDef);
        }
      } else {
        // Drop the metrics for the dropped resource
        clusterStatusMonitor.unregisterResource(view.getResourceName());
      }

      // compare the new external view with current one, set only on different
      ExternalView curExtView = curExtViews.get(resourceName);
      if (curExtView == null || !curExtView.getRecord().equals(view.getRecord())) {
View Full Code Here

            // }
          }
        }
      }
      // Update cluster status monitor mbean
      ClusterStatusMonitor clusterStatusMonitor =
          (ClusterStatusMonitor) event.getAttribute("clusterStatusMonitor");
      IdealState idealState = cache._idealStateMap.get(view.getResourceName());
      if(idealState != null)
      {
        if (clusterStatusMonitor != null && !idealState.getStateModelDefRef().equalsIgnoreCase(DefaultSchedulerMessageHandlerFactory.SCHEDULER_TASK_QUEUE))
        {
          clusterStatusMonitor.onExternalViewChange(view,
                                                  cache._idealStateMap.get(view.getResourceName()));
        }
      }

      // compare the new external view with current one, set only on different
View Full Code Here

      throw new StageException("HelixManager attribute value is null");
    }
    HelixDataAccessor dataAccessor = manager.getHelixDataAccessor();
    _cache.refresh(dataAccessor);
   
    ClusterStatusMonitor clusterStatusMonitor = (ClusterStatusMonitor) event.getAttribute("clusterStatusMonitor");
    if(clusterStatusMonitor != null)
    {
      int disabledInstances = 0;
      int disabledPartitions = 0;
      for(InstanceConfig  config : _cache._instanceConfigMap.values())
      {
        if(config.getInstanceEnabled() == false)
        {
          disabledInstances++;
        }
        if(config.getDisabledPartitions() != null)
        {
          disabledPartitions += config.getDisabledPartitions().size();
        }
      }
      clusterStatusMonitor.setClusterStatusCounters(_cache._liveInstanceMap.size(), _cache._instanceConfigMap.size(),
          disabledInstances, disabledPartitions);
    }

    event.addAttribute("ClusterDataCache", _cache);
   
View Full Code Here

      }
      else
      {
        if (_clusterStatusMonitor == null)
        {
          _clusterStatusMonitor = new ClusterStatusMonitor(manager.getClusterName());
        }
       
        event.addAttribute("clusterStatusMonitor", _clusterStatusMonitor);
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.helix.monitoring.mbeans.ClusterStatusMonitor

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.