@Override public void collect(JmxCollectorConfig config, MBeanServer mBeanServer, JmxSampleProcessor sampleProcessor) throws JmxServerConnectionException { Map<String, String> mergedStringMap = new HashMap<>(config.getServiceProperties()); if (mBeanServer != null) { mergedStringMap.putAll(mBeanServer.getParameterMap()); } JmxConnectionManager connectionManager = new DefaultConnectionManager(config.getRetries()); try (JmxServerConnectionWrapper connectionWrapper = connectionManager.connect(config.getConnectionName(), InetAddressUtils.addr(config.getAgentAddress()), mergedStringMap, null)) { Objects.requireNonNull(connectionWrapper, "connectionWrapper should never be null"); Objects.requireNonNull(connectionWrapper.getMBeanServerConnection(), "connectionWrapper.getMBeanServerConnection() should never be null"); final MBeanServerConnection concreteConnection = connectionWrapper.getMBeanServerConnection(); collect(concreteConnection, config.getJmxCollection(), sampleProcessor); } }
@Override public void collect(JmxCollectorConfig config, MBeanServer mBeanServer, JmxSampleProcessor sampleProcessor) throws JmxServerConnectionException { Map<String, String> mergedStringMap = new HashMap<>(config.getServiceProperties()); if (mBeanServer != null) { mergedStringMap.putAll(mBeanServer.getParameterMap()); } JmxConnectionManager connectionManager = new DefaultConnectionManager(config.getRetries()); try (JmxServerConnectionWrapper connectionWrapper = connectionManager.connect(config.getConnectionName(), InetAddressUtils.addr(config.getAgentAddress()), mergedStringMap, null)) { Objects.requireNonNull(connectionWrapper, "connectionWrapper should never be null"); Objects.requireNonNull(connectionWrapper.getMBeanServerConnection(), "connectionWrapper.getMBeanServerConnection() should never be null"); final MBeanServerConnection concreteConnection = connectionWrapper.getMBeanServerConnection(); collect(concreteConnection, config.getJmxCollection(), sampleProcessor); } }
LOG.info("isServiceDetected: {}: Attempting to connect to address: {}, port: {}, attempt: #{}", getServiceName(), ipAddr, port, attempts); if (client.getMBeanServerConnection().getMBeanCount() <= 0) { return false; client.getMBeanServerConnection().getObjectInstance(new ObjectName(m_object));
connection.getMBeanServerConnection().getMBeanCount(); ObjectNameWrapper.create(connection.getMBeanServerConnection(), definition));
@Override public JmxDatacollectionConfig execute() throws TaskRunException { final JmxConnectionConfig connectionConfig = new JmxConnectionConfigBuilder() .withUrl(config.getConnection()) .withUsername(config.getUser()) .withPassword(config.getPassword()) .build(); try (JmxServerConnectionWrapper connector = new DefaultJmxConnector().createConnection(connectionConfig)) { final JmxDatacollectionConfiggenerator jmxConfigGenerator = new JmxDatacollectionConfiggenerator(new Slf4jLogAdapter(JmxDatacollectionConfiggenerator.class)); final JmxDatacollectionConfig generatedJmxConfigModel = jmxConfigGenerator.generateJmxConfigModel( connector.getMBeanServerConnection(), "anyservice", !config.isSkipDefaultVM(), config.isSkipNonNumber(), JmxHelper.loadInternalDictionary()); applyFilters(generatedJmxConfigModel); return generatedJmxConfigModel; } catch (IOException | MBeanServerQueryException | JMException | JmxServerConnectionException e) { if (e instanceof UnknownHostException || e.getCause() instanceof UnknownHostException) { throw new TaskRunException(String.format("Unknown host: %s", config.getConnection()), e); } if (e instanceof MalformedURLException || e.getCause() instanceof MalformedURLException) { throw new TaskRunException( String.format("Cannot create valid JMX Connection URL. Connection: '%s'", config.getConnection()), e); } throw new TaskRunException("Error while retrieving MBeans from server.", e); } }
@Override public JmxDatacollectionConfig execute() throws JobManager.TaskRunException { final JmxConnectionConfig connectionConfig = new JmxConnectionConfigBuilder() .withUrl(config.getConnection()) .withUsername(config.getUser()) .withPassword(config.getPassword()) .build(); try (JmxServerConnectionWrapper connector = new DefaultJmxConnector().createConnection(connectionConfig)) { final JmxDatacollectionConfiggenerator jmxConfigGenerator = new JmxDatacollectionConfiggenerator(new Slf4jLogAdapter(JmxDatacollectionConfiggenerator.class)); final JmxDatacollectionConfig generatedJmxConfigModel = jmxConfigGenerator.generateJmxConfigModel( connector.getMBeanServerConnection(), "anyservice", !config.isSkipDefaultVM(), config.isSkipNonNumber(), JmxHelper.loadInternalDictionary()); applyFilters(generatedJmxConfigModel); return generatedJmxConfigModel; } catch (IOException | MBeanServerQueryException | JMException | JmxServerConnectionException e) { if (e instanceof UnknownHostException || e.getCause() instanceof UnknownHostException) { throw new JobManager.TaskRunException(String.format("Unknown host: %s", config.getConnection()), e); } if (e instanceof MalformedURLException || e.getCause() instanceof MalformedURLException) { throw new JobManager.TaskRunException( String.format("Cannot create valid JMX Connection URL. Connection: '%s'", config.getConnection()), e); } throw new JobManager.TaskRunException("Error while retrieving MBeans from server.", e); } }