protected HostsList getHostsList() { return Configuration.get().getHostsList(); }
protected PropertiesManager getPropertiesManager() { return Configuration.get().getPropertiesManager(); }
public static final synchronized Configuration switchConf(Properties p) { Configuration oldConfig = conf; Configuration newConfig = new Configuration(p); oldConfig.stop(); newConfig.start(); conf = newConfig; // Avoid a memory leak in perm gen java.beans.Introspector.flushCaches(); logger.info("Configuration rescaned"); return conf; }
public static final synchronized Configuration configure(Properties p) { conf = new Configuration(p); conf.start(); return conf; }
@Override public void start(String[] args) throws Exception { System.setProperty("java.awt.headless", "true"); jrds.JrdsLoggerConfiguration.initLog4J(); Properties pm = new Properties(); File propFile = new File(propFileName); if(propFile.isFile()) pm.load(new FileReader(propFile)); pm.setProperty("withjmx", "yes"); jrds.Configuration.configure(pm); jrds.JrdsLoggerConfiguration.configure(jrds.Configuration.get().getPropertiesManager()); if(jrds.Configuration.get().getPropertiesManager().withjmx) { doJmx(jrds.Configuration.get().getPropertiesManager()); Management.register(propFile); } // Make it wait on himself to wait forever try { Thread.currentThread().join(); System.out.print("joined"); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }
ctxt.setAttribute(StartListener.class.getName(), this); Properties p = readProperties(ctxt); Configuration conf = jrds.Configuration.configure(p); PropertiesManager pm = conf.getPropertiesManager(); if(pm.security) { FilterRegistration filter = ctxt.addFilter("jrdssecurity", SecurityFilter.class);
@Override public void run() { StartListener sl = (StartListener) ctxt.getAttribute(StartListener.class.getName()); Properties p = sl.readProperties(ctxt); Configuration.switchConf(p); ReloadHostList.reloading.release(); logger.info("Configuration rescaned"); } };
public static final synchronized void stopConf() { conf.stop(); }
public void contextDestroyed(ServletContextEvent arg0) { if(started) { logger.info("Application jrds will stop"); started = false; jrds.Configuration.stopConf(); StoreOpener.stop(); if(MBeanServerFactory.findMBeanServer(null).size() > 0) { Management.unregister(); } logger.info("Application jrds stopped"); } }
@Override public void run() { StartListener sl = (StartListener) ctxt.getAttribute(StartListener.class.getName()); Properties p = sl.readProperties(ctxt); Configuration.switchConf(p); reloading.release(); } };
@Override public int getGeneration() { return Configuration.get().getHostsList().getGeneration(); }
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; }
@Override public void reload() { PropertiesManager pm = new PropertiesManager(); if(configfile != null && configfile.isFile()) pm.join(configfile); else if(ctxt != null) { StartListener sl = (StartListener) ctxt.getAttribute(StartListener.class.getName()); Properties p = sl.readProperties(ctxt); pm.join(p); } pm.importSystemProps(); Configuration.switchConf(pm); }
@Override public int getHostsCount() { HostsList hl = Configuration.get().getHostsList(); Collection<HostInfo> hosts = hl.getHosts(); return hosts.size(); }
@Override public Map<String, Number> getLastValues(String host, String probeName) { Probe<?, ?> p = Configuration.get().getHostsList().getProbeByPath(host, probeName); return p.getLastValues(); }
@Override public int getProbesCount() { Configuration c = Configuration.get(); HostsList hl = c.getHostsList(); Collection<HostInfo> hosts = hl.getHosts(); int numProbes = 0; for(HostInfo h: hosts) { numProbes += h.getNumProbes(); } return numProbes; }
@Override public void run() { HostsList hl = Configuration.get().getHostsList(); try { for(Timer t: hl.getTimers()) { t.lockCollect(); } Thread.sleep(jrds.Util.parseStringNumber(arg, 1) * 1000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } for(Timer t: hl.getTimers()) { t.releaseCollect(); } logger.info("collect restarted"); } };