Package com.alibaba.jstorm.daemon.worker

Examples of com.alibaba.jstorm.daemon.worker.WorkerMetricInfo


  public void buildWorkerJsonMsg(String topologyId, Set<Integer> workerSet, boolean metricPerf) {
    String workerId = null;
    for (Integer port: workerSet) {
      try {
        workerId = hostName + ":" + port;
        WorkerMetricInfo workerMetric = cluster.get_worker_metric(topologyId, workerId);
        if (workerMetric == null) continue;
       
        Map<String, Object> workerKV = new HashMap<String, Object>();
               
        workerKV.put("Topology_Name", topologyId);
        workerKV.put("Port", String.valueOf(port));
        workerKV.put(MetricDef.MEMORY_USED, workerMetric.getUsedMem());
        workerKV.put(MetricDef.CPU_USED_RATIO, workerMetric.getUsedCpu());
       
        workerKV.putAll(workerMetric.getGaugeData());
        workerKV.putAll(workerMetric.getCounterData());
        workerKV.putAll(workerMetric.getMeterData());
       
        if (metricPerf == true)
        {
                    workerKV.putAll(workerMetric.getTimerData());
                    workerKV.putAll(workerMetric.getHistogramData());
        }
       
        jsonMsgWorkers.add(workerKV);
      } catch (Exception e) {
        LOG.error("Failed to buildWorkerJsonMsg, workerId=" + workerId + ", e=" + e);
View Full Code Here


      String hostName;

      hostName = JStormServerUtils.getHostName(workerData.getConf());
      String workerId = hostName + ":" + workerData.getPort();
     
      WorkerMetricInfo workerMetricInfo = new WorkerMetricInfo(hostName, workerData.getPort());
      try {
        //Set metrics data
          for(MetricInfo metricInfo : metricList) {   
          workerMetricInfo.updateMetricData(metricInfo)
        }
         
          //Set cpu & memory usage
          Runtime rt=Runtime.getRuntime();
          long usedMem = rt.totalMemory() - rt.freeMemory();
          workerMetricInfo.setUsedMem(usedMem);  
         
          workerMetricInfo.setUsedCpu(getCpuUsage());
             
          clusterState.update_worker_metric(topologyId, workerId, workerMetricInfo);
      } catch(Exception e) {
        logger.error(marker, "Failed to update metrics data in ZK for topo-{} idStr-{}.",
                topologyId, workerId, e);
View Full Code Here

    List<String> workerList = cluster_state.get_children(monitorWorkerDirPath, false);
   
    for(String workerId : workerList) {
      byte[] byteArray = cluster_state.get_data(Cluster.monitor_worker_path(topologyId, workerId), false);
      if(byteArray != null) {
        WorkerMetricInfo workerMetric = (WorkerMetricInfo)Cluster.maybe_deserialize(byteArray);
          if(workerMetric != null) {
            workerMetricList.add(workerMetric);
          }
      } else {
        LOG.warn("get_worker_metric_list failed, workerMetric is null, topoId: " + topologyId + " workerId:" + workerId);
View Full Code Here

    return taskMetric;
  }
 
  @Override
  public WorkerMetricInfo get_worker_metric(String topologyId, String workerId) throws Exception {
    WorkerMetricInfo workerMetric = null;
   
    String monitorWorkerPath = Cluster.monitor_worker_path(topologyId, workerId)
    workerMetric = (WorkerMetricInfo)(Cluster.maybe_deserialize(
        cluster_state.get_data(monitorWorkerPath, false)));
   
View Full Code Here

TOP

Related Classes of com.alibaba.jstorm.daemon.worker.WorkerMetricInfo

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.