public GraphNode getGraphNode(JrdsServlet caller) { GraphNode gn = null; if(id != null) gn = hostlist.getGraphById(id); if(gn != null) { logger.debug(jrds.Util.delayedFormatString("Graph found: %s", gn)); } else if(pid != null && pid != 0 && dsName != null) { if(!caller.allowed(this, hostlist.getDefaultRoles())) return null; Probe<?, ?> p = getProbe(); if(p == null) { logger.error("Looking for unknown probe"); return null; } logger.debug(jrds.Util.delayedFormatString("Probe found: %s", p)); Graphics2D g2d = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB).createGraphics(); String graphDescName = p.getName() + "." + dsName; GraphDesc gd = new GraphDesc(); gd.setName(graphDescName); gd.setGraphName(p.getHost().getName() + "." + p.getName() + "." + dsName); gd.setGraphTitle(p.getName() + "." + dsName + " on ${host}"); gd.add(dsName, GraphDesc.LINE); gd.initializeLimits(g2d); gn = new GraphNode(p, gd); gn.addACL(Configuration.get().getPropertiesManager().defaultACL); } return gn; }
@Test public void create() throws Exception { @SuppressWarnings("unchecked") Probe<String, Number> p = GenerateProbe.quickProbe(testFolder); p.setPd(Full.getPd()); File rrdFile = new File(p.getMainStore().getPath()); Assert.assertTrue("Failed to create probe " + rrdFile.getAbsolutePath(), p.checkStore()); logger.debug("Created " + p + " stored in " + p.getMainStore().getStoreObject()); long endSec = Full.fill(p); logger.debug("fill time: " + endSec); logger.debug(p.getLastUpdate()); Period pr = Full.getPeriod(p, endSec); Graphics2D g2d = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB).createGraphics(); GraphDesc gd = Full.getGd(); gd.initializeLimits(g2d); GraphNode gn = new GraphNode(p, gd); Graph g = new Graph(gn); g.setPeriod(pr); int h = g.getDimension().height; int w = g.getDimension().width; File outputFile = testFolder.newFile(); OutputStream out = new FileOutputStream(outputFile); g.writePng(out); BufferedImage img = ImageIO.read(outputFile); Assert.assertEquals(h, img.getHeight()); Assert.assertEquals(w, img.getWidth()); Assert.assertTrue(rrdFile.exists()); Assert.assertTrue(rrdFile.length() > 0); }