Examples of Heatmap


Examples of org.apache.hadoop.chukwa.hicc.bean.Heatmap

      @QueryParam("end") String end,
      @QueryParam("max") @DefaultValue("1.0") double max,
      @QueryParam("scale") @DefaultValue("100") double scale,
      @QueryParam("height") @DefaultValue("400") int height) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
    Heatmap heatmap = null;
    long startTime = 0;
      long endTime = 0;
      TimeHandler time = new TimeHandler(request);
      try {
        if(start!=null) {
View Full Code Here

Examples of org.apache.hadoop.chukwa.hicc.bean.Heatmap

  }
 
  public static Heatmap getHeatmap(String tableName, String family, String column,
      long startTime, long endTime, double max, double scale, int height) {
  final long MINUTE = TimeUnit.MINUTES.toMillis(1);
  Heatmap heatmap = new Heatmap();
    HTableInterface table = pool.getTable(tableName);
    try {
        Scan scan = new Scan();
        ColumnPrefixFilter cpf = new ColumnPrefixFilter(column.getBytes());
        scan.addFamily(family.getBytes());
        scan.setFilter(cpf);
      scan.setTimeRange(startTime, endTime);
      scan.setBatch(10000);
        ResultScanner results = table.getScanner(scan);
      Iterator<Result> it = results.iterator();
    int index = 0;
    // Series display in y axis
    int y = 0;
    HashMap<String, Integer> keyMap = new HashMap<String, Integer>();
      while(it.hasNext()) {
      Result result = it.next();
      List<KeyValue> kvList = result.list();
        for(KeyValue kv : kvList) {
      String key = parseRowKey(result.getRow());
      StringBuilder tmp = new StringBuilder();
      tmp.append(key);
      tmp.append(":");
      tmp.append(new String(kv.getQualifier()));
      String seriesName = tmp.toString();
      long time = parseTime(result.getRow());
      // Time display in x axis
      int x = (int) ((time - startTime) / MINUTE);
      if(keyMap.containsKey(seriesName)) {
        y = keyMap.get(seriesName);
        } else {
        keyMap.put(seriesName, new Integer(index));
          y = index;
          index++;
      }
      double v = Double.parseDouble(new String(kv.getValue()));
      heatmap.put(x, y, v);
      if(v > max) {
        max = v;
      }
        }
      }
      results.close();
      table.close();
      int radius = height / index;
      // Usually scale max from 0 to 100 for visualization
      heatmap.putMax(scale);
      for(HeatMapPoint point : heatmap.getHeatmap()) {
        double round = point.count / max * scale;
        round = Math.round(round * 100.0) / 100.0;
        point.put(point.x, point.y * radius, round);
      }
      heatmap.putRadius(radius);
      heatmap.putSeries(index);
  } catch (IOException e) {
      log.error(ExceptionUtil.getStackTrace(e));
  }
  return heatmap;
  }
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.