@Override public StarterNode getLevel() { return parent.getLevel(); }
private JMXConnection getCnx(String proto, int port) { JMXConnection cnx = new JMXConnection() { @Override public String getHostName() { return "localhost"; } }; cnx.setPort(port); cnx.setProtocol(proto); return cnx; }
@SuppressWarnings("unused") private void doTest(String proto, int port) throws Exception { mbi = new JrdsMBeanInfo(proto, "localhost", port); HostStarter host = new HostStarter(new HostInfo("localhost")) { public boolean isCollectRunning() { return true; } }; host.setTimeout(1); JMXConnection cnx = getCnx(proto, port); host.registerStarter(new SocketFactory()); host.registerStarter(new JmxSocketFactory()); host.registerStarter(cnx); host.configureStarters(new PropertiesManager()); host.startCollect(); Assert.assertTrue("JMX Connection failed to start", cnx.isStarted()); Assert.assertNotNull("Failed to read uptime", cnx.setUptime()); if(false) enumerate((NativeJmxSource)cnx.getConnection()); }
@Override public Map<String, Double> getNewSampleValuesConnected(JMXConnection cnx) { JmxAbstractDataSource<?> mbean = cnx.getConnection(); try { Set<String> collectKeys = getCollectMapping().keySet();
@Test public void testConnectionInfo() throws Exception { PropertiesManager pm = Tools.makePm(testFolder); HostBuilder hb = new HostBuilder(); hb.setPm(pm); hb.setClassLoader(this.getClass().getClassLoader()); JrdsDocument cnxdoc = new JrdsDocument(Tools.dbuilder.newDocument()); cnxdoc.doRootElement("host").addElement("connection", "type=jrds.probe.JMXConnection").addElement("attr", "name=port").setTextContent("8999"); for(ConnectionInfo ci: hb.makeConnexion(cnxdoc.getRootElement(), new HostInfo("localhost"), new HashMap<String, String>(0))) { logger.trace(ci.getName()); StarterNode sn = new StarterNode() {}; ci.register(sn); JMXConnection cnx = sn.find(JMXConnection.class); Assert.assertEquals("Attributed not setted", new Integer(8999), cnx.getPort()); } }