private double parseRangeArg(String rangeArg, Graph g) { if(rangeArg == null) return Double.NaN; Matcher m = rangePattern.matcher(rangeArg); jrds.GraphNode node = g.getNode(); if(m.matches() && node != null) { String valueString = m.group(1); Number value = jrds.Util.parseStringNumber(valueString, Double.NaN); String suffixString = m.group(3); if(!"".equals(suffixString)) { try { SiPrefix suffix = SiPrefix.valueOf(suffixString); return suffix.evaluate(value.doubleValue(), node.getGraphDesc().isSiUnit()); } catch (java.lang.IllegalArgumentException e) { logger.info("Illegal SI suffix " + suffixString); } } else return value.doubleValue(); } return Double.NaN; }
protected void addlegend(RrdGraphDef graphDef) { Date lastUpdate = node.getProbe().getLastUpdate(); graphDef.comment("\\l"); graphDef.comment("\\l"); graphDef.comment("Last update: " + lastUpdateFormat.get().format(lastUpdate) + "\\L"); String unit = "SI"; if(!getGraphDesc().isSiUnit()) unit = "binary"; graphDef.comment("Unit type: " + unit + "\\r"); graphDef.comment("Period from " + lastUpdateFormat.get().format(start) + " to " + lastUpdateFormat.get().format(end) + "\\L"); graphDef.comment("Source type: " + node.getProbe().getSourceType() + "\\r"); }
Assert.assertEquals("graph name failed", "graphdesctest", gd.getName()); Assert.assertEquals("legend count failed", 5, gd.getLegendLines()); Assert.assertFalse("Graph unit should be binary", gd.isSiUnit()); Assert.assertEquals("Graph unit scale should be fixed", 0, gd.getUnitExponent().intValue());
@Test public void loadGraphDesc() throws Exception { JrdsDocument d = Tools.parseRessource("graphdesc2.xml"); GraphDescBuilder builder = new GraphDescBuilder(); builder.setPm(new PropertiesManager()); GraphDesc gd = (GraphDesc) builder.build(d); Assert.assertEquals("mokegraph", gd.getName()); Assert.assertEquals("mokegraphname", gd.getGraphName()); Assert.assertEquals("mokegraphtitle", gd.getGraphTitle()); Assert.assertTrue(gd.isSiUnit()); Assert.assertEquals("verticallabel", gd.getVerticalLabel()); GraphNode gn = new GraphNode(GetMoke.getProbe(), gd); logger.debug(gd.getHostTree(gn)); logger.debug(gd.getViewTree(gn)); }
@Test public void loadGraph() throws Exception { JrdsDocument d = Tools.parseRessource("customgraph.xml"); GraphDescBuilder builder = new GraphDescBuilder(); builder.setPm(new PropertiesManager()); GraphDesc gd = (GraphDesc) builder.build(d); Assert.assertEquals("name", gd.getName()); Assert.assertEquals("graphName", gd.getGraphName()); Assert.assertEquals("", gd.getGraphTitle()); Assert.assertTrue(gd.isSiUnit()); Assert.assertEquals("verticalLabel", gd.getVerticalLabel()); GraphNode gn = new GraphNode(GetMoke.getProbe(), gd); logger.debug(gd.getHostTree(gn)); logger.debug(gd.getViewTree(gn)); }