private String getPort() throws MalformedURLException { if (port == null && url != null) { port = String.valueOf(new JMXServiceURL(getUrl()).getPort()); } return port; }
private String getPort() throws MalformedURLException { if (port == null && url != null) { port = String.valueOf(new JMXServiceURL(getUrl()).getPort()); } return port; }
public InetAddress getIpAddress() throws MalformedURLException { if (ipAddress == null && url != null) { ipAddress = InetAddressUtils.getInetAddress(new JMXServiceURL(getUrl()).getHost()); } return ipAddress; }
public InetAddress getIpAddress() throws MalformedURLException { if (ipAddress == null && url != null) { ipAddress = InetAddressUtils.getInetAddress(new JMXServiceURL(getUrl()).getHost()); } return ipAddress; }
public static JmxServerConnectionWrapper getMBeanServerConnection(Map<String,String> propertiesMap, InetAddress address) throws IOException { final long timeout = DEFAULT_TIMEOUT; propertiesMap.putIfAbsent("factory", "STANDARD"); propertiesMap.putIfAbsent("port", "1099"); propertiesMap.putIfAbsent("protocol", "rmi"); propertiesMap.putIfAbsent("urlPath", "/jmxrmi"); propertiesMap.putIfAbsent("timeout", Long.toString(timeout)); final Callable<JmxServerConnectionWrapper> task = new Callable<JmxServerConnectionWrapper>() { @Override public JmxServerConnectionWrapper call() throws Exception { return new DefaultJmxConnector().createConnection(address, propertiesMap); } }; final Future<JmxServerConnectionWrapper> future = executor.submit(task); try { final JmxServerConnectionWrapper connectionWrapper = future.get(timeout, TimeUnit.MILLISECONDS); return connectionWrapper; } catch (InterruptedException | ExecutionException | TimeoutException e) { final String url = JmxConnectionConfigBuilder.buildFrom(address, propertiesMap).build().getUrl(); LOG.info("Exception connecting JMXConnectorFactory url {} , Error: {}", url, e.getMessage()); if (!future.isDone()) { future.cancel(true); LOG.info(" the task {}", future.isCancelled() ? "was cancelled" : "could not be cancelled"); } throw new ConnectException("Error connecting JMXConnectionFactory " + url); } } }
public static JmxServerConnectionWrapper getMBeanServerConnection(Map<String,String> propertiesMap, InetAddress address) throws IOException { final long timeout = DEFAULT_TIMEOUT; propertiesMap.putIfAbsent("factory", "STANDARD"); propertiesMap.putIfAbsent("port", "1099"); propertiesMap.putIfAbsent("protocol", "rmi"); propertiesMap.putIfAbsent("urlPath", "/jmxrmi"); propertiesMap.putIfAbsent("timeout", Long.toString(timeout)); final Callable<JmxServerConnectionWrapper> task = new Callable<JmxServerConnectionWrapper>() { @Override public JmxServerConnectionWrapper call() throws Exception { return new DefaultJmxConnector().createConnection(address, propertiesMap); } }; final Future<JmxServerConnectionWrapper> future = executor.submit(task); try { final JmxServerConnectionWrapper connectionWrapper = future.get(timeout, TimeUnit.MILLISECONDS); return connectionWrapper; } catch (InterruptedException | ExecutionException | TimeoutException e) { final String url = JmxConnectionConfigBuilder.buildFrom(address, propertiesMap).build().getUrl(); LOG.info("Exception connecting JMXConnectorFactory url {} , Error: {}", url, e.getMessage()); if (!future.isDone()) { future.cancel(true); LOG.info(" the task {}", future.isCancelled() ? "was cancelled" : "could not be cancelled"); } throw new ConnectException("Error connecting JMXConnectionFactory " + url); } } }
public static MBeanServer getMBeanServer(JmxConfigDao jmxConfigDao, String address, Map<String, String> parameters) { Objects.requireNonNull(address); Objects.requireNonNull(parameters); if (jmxConfigDao != null && jmxConfigDao.getConfig() != null) { try { final JmxConnectionConfig config = JmxConnectionConfigBuilder.buildFrom(address, parameters).build(); final int port = new JMXServiceURL(config.getUrl()).getPort(); final MBeanServer mBeanServer = jmxConfigDao.getConfig().lookupMBeanServer(address, port); return mBeanServer; } catch (MalformedURLException e) { LOG.warn("Unexpected exception: {}", e.getMessage(), e); } } return null; // not found or exception }
@Override public DetectRequest buildRequest(String location, InetAddress address, Integer port, Map<String, String> attributes) { // in case port is null, but url is provided, the port is extracted from the url if (port == null && attributes.containsKey("url")) { try { final JmxConnectionConfig config = JmxConnectionConfigBuilder.buildFrom(address, attributes).build(); port = new JMXServiceURL(config.getUrl()).getPort(); } catch (MalformedURLException e) { throw new IllegalArgumentException("url is not valid", e); } } return new DetectRequestImpl(address, port, getRuntimeAttributes(address, port)); }
public static MBeanServer getMBeanServer(JmxConfigDao jmxConfigDao, String address, Map<String, String> parameters) { Objects.requireNonNull(address); Objects.requireNonNull(parameters); if (jmxConfigDao != null && jmxConfigDao.getConfig() != null) { try { final JmxConnectionConfig config = JmxConnectionConfigBuilder.buildFrom(address, parameters).build(); final int port = new JMXServiceURL(config.getUrl()).getPort(); final MBeanServer mBeanServer = jmxConfigDao.getConfig().lookupMBeanServer(address, port); return mBeanServer; } catch (MalformedURLException e) { LOG.warn("Unexpected exception: {}", e.getMessage(), e); } } return null; // not found or exception }
final String urlString = config.getUrl(); final JMXServiceURL url = new JMXServiceURL(urlString); LOG.debug("JMX: {} - {}", config.getFactory(), url);
final String urlString = config.getUrl(); final JMXServiceURL url = new JMXServiceURL(urlString); LOG.debug("JMX: {} - {}", config.getFactory(), url);