ConfigObjectFactory conf = new ConfigObjectFactory(pm, pm.extensionClassLoader); conf.setGraphDescMap(); Map<String, ProbeDesc<? extends Object>> probesMap = conf.setProbeDescMap(); if(args.length == 0) { dumpAll(probesMap.values());
ConfigObjectFactory conf = new ConfigObjectFactory(pm); Document hostDom = generate(hostname, conf.getNodeMap(ConfigType.PROBEDESC), request); response.setContentType(CONTENT_TYPE); response.addHeader("Cache-Control", "no-cache");
public Map<String, Tab> setTabMap() { Map<String, JrdsDocument> nodemap = load.getRepository(ConfigType.TAB); TabBuilder ob = new TabBuilder(); Map<String, Tab> tabsMap = getObjectMap(ob, nodemap); logger.debug(jrds.Util.delayedFormatString("Tabs configured: %s", tabsMap.keySet())); return tabsMap; }
ConfigObjectFactory conf = new ConfigObjectFactory(pm); conf.setArchiveSetMap(); conf.setGraphDescMap(); Map<String, ProbeDesc<?>> allProbeDesc = conf.setProbeDescMap(); for(ProbeDesc<?> pd: allProbeDesc.values()) { for(ProbeMeta meta: ArgFactory.enumerateAnnotation(pd.getProbeClass(), ProbeMeta.class, StarterNode.class)) { conf.setMacroMap(); for(Listener<?, ?> l: conf.setListenerMap().values()) { registerStarter(l); topStarters.add(l); Map<String, HostInfo> allHosts = conf.setHostMap(timers); hostList.addAll(allHosts.values()); Set<Class<? extends Starter>> topStarterClasses = new HashSet<Class<? extends Starter>>(); doFilterTabs(conf.setFilterMap(), allTabs); doSums(conf.setSumMap(), graphMap, treeMap, allTabs); doCustomGraphs(conf.setGrapMap(), graphMap, treeMap, allTabs); Map<String, Tab> customTabMap = conf.setTabMap(); doCustomTabs(customTabMap, treeMap, allTabs);
@Test public void testFullConfigpath() throws Exception { PropertiesManager localpm = Tools.makePm(testFolder); ConfigObjectFactory conf = new ConfigObjectFactory(localpm, localpm.extensionClassLoader); conf.getNodeMap(ConfigType.PROBEDESC).put("name", Tools.parseRessource("httpxmlprobedesc.xml")); ProbeDesc<?> pd = conf.setProbeDescMap().get("name"); Assert.assertNotNull("Probedesc not build", pd); }
@Test public void testAttributesParsing() throws Exception { PropertiesManager pm = Tools.makePm(testFolder); File descpath = new File("desc"); if(descpath.exists()) pm.libspath.add(descpath.toURI()); ConfigObjectFactory conf = new ConfigObjectFactory(pm); JrdsDocument pddoc = Tools.parseRessource("beans.xml"); conf.getNodeMap(ConfigType.PROBEDESC).put("name", pddoc); Map<String, GraphDesc> graphDescMap = conf.setGraphDescMap(); Map<String, ProbeDesc<? extends Object>> probeDescMap = conf.setProbeDescMap(); ProbeFactory pf = new ProbeFactory(probeDescMap, graphDescMap); HostBuilder hb = new HostBuilder(); hb.setPm(pm); hb.setClassLoader(this.getClass().getClassLoader()); hb.setMacros(new HashMap<String, Macro>(0)); hb.setProbeFactory(pf); Map<String, Timer> timerMap = Tools.getSimpleTimerMap(); timerMap.put("another", timerMap.get(Timer.DEFAULTNAME)); hb.setTimers(timerMap); JrdsDocument fullhost = Tools.parseRessource("attrhost.xml"); HostInfo hi = hb.build(fullhost); Probe<?, ?> p = hi.getProbes().iterator().next(); Assert.assertEquals("${attr.customattr1} failed", "defaultattr1", Util.parseTemplate("${attr.customattr1}", p)); Assert.assertEquals("${attr.customattr3} failed", "defaultattr2", Util.parseTemplate("${attr.customattr2}", p)); Assert.assertEquals("${attr.customattr3} failed", "defaultattr1", Util.parseTemplate("${attr.customattr3}", p)); Assert.assertEquals("${attr.customattr4} failed", "value4", Util.parseTemplate("${attr.customattr4}", p)); }
@Test public void testFullConfigpath() throws Exception { PropertiesManager localpm = Tools.makePm(testFolder); ConfigObjectFactory conf = new ConfigObjectFactory(localpm); conf.getNodeMap(ConfigType.GRAPHDESC).put("graphdesc", Tools.parseRessource("graphdesc.xml")); Assert.assertNotNull("Graphdesc not build", conf.setGraphDescMap().get("graphdesctest")); }
@Test public void testFullConfigpath() throws Exception { PropertiesManager localpm = Tools.makePm(testFolder); ConfigObjectFactory conf = new ConfigObjectFactory(localpm); conf.getNodeMap(ConfigType.FILTER).put("filtername", Tools.parseString(goodFilterXml)); Assert.assertNotNull("Filter not build", conf.setFilterMap().get("filtername")); }
@Test public void testFullConfigpath() throws Exception { PropertiesManager localpm = Tools.makePm(testFolder); ConfigObjectFactory conf = new ConfigObjectFactory(localpm, localpm.extensionClassLoader); conf.getNodeMap(ConfigType.MACRODEF).put("macrodef", Tools.parseString(goodMacroXml)); Assert.assertNotNull("Macro not build", conf.setMacroMap().get("macrodef")); }
@Test public void testFullConfigpath() throws Exception { PropertiesManager localpm = Tools.makePm(testFolder); JrdsDocument host = new JrdsDocument(Tools.dbuilder.newDocument()); host.doRootElement("host", "name=name"); ConfigObjectFactory conf = new ConfigObjectFactory(localpm, localpm.extensionClassLoader); conf.getNodeMap(ConfigType.HOSTS).put("name", host); Assert.assertNotNull("Probedesc not build", conf.setHostMap(Tools.getSimpleTimerMap()).get("name")); }
public ConfigObjectFactory(jrds.PropertiesManager pm) { this.pm = pm; this.cl = pm.extensionClassLoader; init(); }
@Test public void testDefaultArgs() throws Exception { PropertiesManager localpm = Tools.makePm(testFolder); ConfigObjectFactory conf = new ConfigObjectFactory(localpm, localpm.extensionClassLoader); JrdsDocument pddoc = Tools.parseRessource("beans.xml"); pddoc.getRootElement().getElementbyName("probeClass").setTextContent("jrds.mockobjects.MokeProbeBean"); conf.getNodeMap(ConfigType.PROBEDESC).put("name", pddoc); ProbeDesc<?> pd = conf.setProbeDescMap().get("name"); Assert.assertEquals("bean default value not found", "defaultattr1", pd.getDefaultBeans().get("customattr1").value); Assert.assertEquals("default attribute not delayed", true, pd.getDefaultBeans().get("customattr2").delayed); }
public ConfigObjectFactory(jrds.PropertiesManager pm, ClassLoader cl) { this.pm = pm; this.cl = cl; init(); }
@Test public void testOptional() throws Exception { PropertiesManager localpm = Tools.makePm(testFolder); ConfigObjectFactory conf = new ConfigObjectFactory(localpm, localpm.extensionClassLoader); JrdsDocument pddoc = Tools.parseRessource("httpxmlprobedesc.xml"); pddoc.getRootElement().getElementbyName("probeClass").setTextContent("jrds.mockobjects.MokeProbeBean"); conf.getNodeMap(ConfigType.PROBEDESC).put("name", pddoc); @SuppressWarnings("unchecked") ProbeDesc<String> pd = (ProbeDesc<String>) conf.setProbeDescMap().get("name"); Assert.assertNotNull("Probedesc not build", pd); @SuppressWarnings("unchecked") Probe<String, String> p = (Probe<String, String>) pd.getProbeClass().getConstructor().newInstance(); p.setPd(pd); p.setLabel("goodlabel"); Assert.assertTrue("optional resolution broken", p.isOptional("goodlabel")); }
ConfigObjectFactory conf = new ConfigObjectFactory(pm); Map<String, GraphDesc> grapMap = conf.setGraphDescMap(); ConfigObjectFactory confjar = new ConfigObjectFactory(pm); Map<String, GraphDesc> grapMapjar = confjar.setGraphDescMap(); for(ProbeDesc<?> pd: confjar.setProbeDescMap().values()) { Class<?> pc = pd.getProbeClass(); while (pc != null && pc != StarterNode.class) {
@Test public void enumerateProbe() throws IOException { PropertiesManager pm = Tools.makePm(testFolder, "autocreate=false", "strictparsing=true"); pm.update(); pm.libspath.clear(); File descpath = new File("desc"); if(descpath.exists()) pm.libspath.add(descpath.toURI()); ConfigObjectFactory conf = new ConfigObjectFactory(pm); Set<String> failed = new HashSet<String>(); for(JrdsDocument n: conf.getNodeMap(ConfigType.PROBEDESC).values()) { JrdsElement root = n.getRootElement(); JrdsElement classElem = root.getElementbyName("probeClass"); ProbeDesc<String> pd = new ProbeDesc<>(); String name = ""; try { String className = classElem.getTextContent().trim(); name = root.getElementbyName("name").getTextContent(); @SuppressWarnings("unchecked") Class<? extends Probe<String, ?>> c = (Class<? extends Probe<String, ?>>) pm.extensionClassLoader.loadClass(className); pd.setProbeClass(c); } catch (Exception e) { logger.error("Failed probedesc " + name + ": " + e.getMessage()); failed.add(name); } } if(!failed.isEmpty()) { Assert.fail("Invalid class:" + failed); } }
public Map<String, Macro> setMacroMap() { Map<String, JrdsDocument> nodemap = load.getRepository(ConfigType.MACRODEF); macrosmap = getObjectMap(new MacroBuilder(), nodemap); logger.debug(jrds.Util.delayedFormatString("Macro configured: %s", macrosmap.keySet())); return macrosmap; }
@Test public void testCustomBeans() throws Exception { PropertiesManager localpm = Tools.makePm(testFolder); ConfigObjectFactory conf = new ConfigObjectFactory(localpm, localpm.extensionClassLoader); JrdsDocument pddoc = Tools.parseRessource("beans.xml"); pddoc.getRootElement().getElementbyName("probeClass").setTextContent("jrds.mockobjects.MokeProbeBean"); conf.getNodeMap(ConfigType.PROBEDESC).put("name", pddoc); @SuppressWarnings("unchecked") ProbeDesc<String> pd = (ProbeDesc<String>) conf.setProbeDescMap().get("name"); Assert.assertNotNull("custom bean customattr1 not found", pd.getBean("customattr1")); Assert.assertNotNull("custom bean customattr2 not found", pd.getBean("customattr2")); @SuppressWarnings("unchecked") Probe<String, String> p = (Probe<String, String>) pd.getProbeClass().getConstructor().newInstance(); p.setPd(pd); pd.getBean("customattr1").set(p, "value1"); pd.getBean("customattr2").set(p, "value2"); Assert.assertEquals("value1", pd.getBean("customattr1").get(p)); Assert.assertEquals("value2", pd.getBean("customattr2").get(p)); Assert.assertEquals("value1", Util.parseTemplate("${attr.customattr1}", p)); Assert.assertEquals("value2", Util.parseTemplate("${attr.customattr2}", p)); } }
ConfigObjectFactory conf = new ConfigObjectFactory(pm); Map<String, GraphDesc> graphDescMap = conf.setGraphDescMap(); Map<String, ProbeDesc<?>> probeDescMap = conf.setProbeDescMap();
public Map<String, ArchivesSet> setArchiveSetMap() { Map<String, JrdsDocument> nodemap = load.getRepository(ConfigType.ARCHIVESSET); archivessetmap = getObjectMap(new ArchivesSetBuilder(), nodemap); archivessetmap.put(ArchivesSet.DEFAULT.getName(), ArchivesSet.DEFAULT); logger.debug(jrds.Util.delayedFormatString("Archives set configured: %s", archivessetmap.keySet())); return archivessetmap; }