コード例 #1
0
ファイル: TestHostBuilder.java プロジェクト: p-maks/jrds
  @Test
  public void testNewProbe()
      throws InvocationTargetException, IllegalArgumentException, IllegalAccessException,
          IOException {
    PropertiesManager localpm = Tools.makePm();

    HostBuilder hb = new HostBuilder();
    // Generate a probe with a bean hostInfo with a default value of ${host}
    hb.setProbeFactory(
        new MokeProbeFactory() {
          @Override
          public Probe<?, ?> makeProbe(String type) {
            logger.trace(type);
            ProbeDesc pd = generateProbeDesc(type);
            try {
              pd.setProbeClass(MokeProbeBean.class);
            } catch (InvocationTargetException e1) {
              throw new RuntimeException(e1);
            }
            Probe<?, ?> p = new MokeProbeBean(pd);
            try {
              pd.addDefaultArg("hostInfo", "${host}");
            } catch (Exception e) {
              throw new RuntimeException(e.getMessage(), e);
            }
            return p;
          }
        });
    hb.setPm(localpm);
    hb.setTimers(Tools.getSimpleTimerMap());

    HostInfo host = new HostInfo("localhost");
    host.setHostDir(testFolder.getRoot());

    JrdsDocument probeNode = new JrdsDocument(Tools.dbuilder.newDocument());
    probeNode.doRootElement("probe", "type=probetype");

    Probe<?, ?> p = hb.makeProbe(probeNode.getRootElement(), host, null);
    Assert.assertEquals(
        "localhost", p.getPd().getBeanMap().get("hostInfo").getReadMethod().invoke(p));
    logger.trace(p.getName());
  }
コード例 #2
0
ファイル: JSonGraph.java プロジェクト: is00hcw/Mycat-Web
  private void doGraph(GraphNode gn, Renderer r, ParamsBean params, JrdsJSONWriter w)
      throws IOException, JSONException {
    jrds.Graph graph = gn.getGraph();
    params.configureGraph(graph);

    Map<String, Object> imgProps = new HashMap<String, Object>();
    r.render(graph);
    Probe<?, ?> p = gn.getProbe();
    imgProps.put("probename", p.getName());
    imgProps.put("qualifiedname", graph.getQualifiedName());

    imgProps.put("qualifiedname", graph.getQualifiedName());
    GraphDesc gd = gn.getGraphDesc();
    if (gd != null && gd.getDimension() != null) {
      imgProps.put("height", gd.getDimension().height);
      imgProps.put("width", gd.getDimension().width);
    }
    imgProps.put("graph", params.doArgsMap(graph, true));
    imgProps.put("history", params.doArgsMap(graph, false));
    imgProps.put("probe", params.doArgsMap(p, true));
    imgProps.put("graphnode", params.doArgsMap(gn, true));
    doTree(w, graph.getQualifiedName(), gn.hashCode(), "graph", null, imgProps);
  }