Java Code Examples for javax.management.MBeanServerConnection#getMBeanCount()
The following examples show how to use
javax.management.MBeanServerConnection#getMBeanCount() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JmxClient_remoteTest.java From monsoon with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void connect_and_server_restarts_after_we_detect_connection_death() throws Exception { jmx_server.start(); try (JmxClient jmx_client = new JmxClient(jmx_server.url)) { jmx_client.getConnection(threadpool).get().get().getMBeanServerConnection().getMBeanCount(); // Force connection to come up. /* Restart JMX server. */ jmx_server.stop(); try { /* Attempt to get data from JMX server while it is down. */ jmx_client.getConnection(threadpool).get(); } catch (ExecutionException ex) { /* expected */ } /* Complete restart of JMX server. */ jmx_server.start(); MBeanServerConnection connection = jmx_client.getConnection(threadpool).get().get().getMBeanServerConnection(); assertNotNull(connection); connection.getMBeanCount(); } }
Example 2
Source File: JmxClient.java From monsoon with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Get the connection, but don't bother with the recovery protocol if the * connection is lost. * * @return An optional with a connection, or empty optional indicating there * is no connection. */ public synchronized Optional<MBeanServerConnection> getOptionalConnection() { if (conn_ != null && conn_.isCompletedExceptionally()) conn_ = null; if (conn_ != null && conn_.isDone() && !conn_.isCompletedExceptionally()) { try { MBeanServerConnection result = conn_.get().get().getMBeanServerConnection(); result.getMBeanCount(); return Optional.of(result); } catch (Exception ex) { conn_ = null; // Connection gone bad. } } return Optional.empty(); }
Example 3
Source File: JMXRemoteNonManagementEndpointArquillianTest.java From thorntail with Apache License 2.0 | 5 votes |
@Test @RunAsClient public void testRemoteConnection() throws Exception { String urlString = "service:jmx:remote+http://localhost:8080"; JMXServiceURL serviceURL = new JMXServiceURL(urlString); JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, null); MBeanServerConnection connection = jmxConnector.getMBeanServerConnection(); int count = connection.getMBeanCount(); assertThat( count ).isGreaterThan( 1 ); jmxConnector.close(); }
Example 4
Source File: JMXRemoteManagementEndpointArquillianTest.java From thorntail with Apache License 2.0 | 5 votes |
@Test @RunAsClient public void testRemoteConnection() throws Exception { String urlString = "service:jmx:remote+http://localhost:9990"; JMXServiceURL serviceURL = new JMXServiceURL(urlString); JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, null); MBeanServerConnection connection = jmxConnector.getMBeanServerConnection(); int count = connection.getMBeanCount(); assertThat(count).isGreaterThan(1); jmxConnector.close(); }
Example 5
Source File: JMXRemoteManagementAutoEndpointArquillianTest.java From thorntail with Apache License 2.0 | 5 votes |
@Test @RunAsClient public void testRemoteConnection() throws Exception { String urlString = "service:jmx:remote+http://localhost:9990"; JMXServiceURL serviceURL = new JMXServiceURL(urlString); JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, null); MBeanServerConnection connection = jmxConnector.getMBeanServerConnection(); int count = connection.getMBeanCount(); assertThat(count).isGreaterThan(1); jmxConnector.close(); }
Example 6
Source File: JMXRemoteNonManagementEndpointArquillianTest.java From thorntail with Apache License 2.0 | 5 votes |
@Test @RunAsClient public void testRemoteConnection() throws Exception { String urlString = "service:jmx:remote://localhost:4447"; JMXServiceURL serviceURL = new JMXServiceURL(urlString); JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, null); MBeanServerConnection connection = jmxConnector.getMBeanServerConnection(); int count = connection.getMBeanCount(); assertThat(count).isGreaterThan(1); jmxConnector.close(); }
Example 7
Source File: JMXRemoteManagementAutoEndpointArquillianTest.java From thorntail with Apache License 2.0 | 5 votes |
@Test @RunAsClient public void testRemoteConnection() throws Exception { String urlString = "service:jmx:remote://localhost:4447"; JMXServiceURL serviceURL = new JMXServiceURL(urlString); JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, null); MBeanServerConnection connection = jmxConnector.getMBeanServerConnection(); int count = connection.getMBeanCount(); assertThat(count).isGreaterThan(1); jmxConnector.close(); }
Example 8
Source File: JMXRemoteNonManagementEndpointArquillianTest.java From thorntail with Apache License 2.0 | 5 votes |
@Test @RunAsClient public void testRemoteConnection() throws Exception { String urlString = "service:jmx:remote+http://localhost:8080"; JMXServiceURL serviceURL = new JMXServiceURL(urlString); JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, null); MBeanServerConnection connection = jmxConnector.getMBeanServerConnection(); int count = connection.getMBeanCount(); assertThat( count ).isGreaterThan( 1 ); jmxConnector.close(); }
Example 9
Source File: JMXRemoteManagementAutoEndpointArquillianTest.java From thorntail with Apache License 2.0 | 5 votes |
@Test @RunAsClient public void testRemoteConnection() throws Exception { String urlString = "service:jmx:remote+http://localhost:8080"; JMXServiceURL serviceURL = new JMXServiceURL(urlString); JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, null); MBeanServerConnection connection = jmxConnector.getMBeanServerConnection(); int count = connection.getMBeanCount(); assertThat(count).isGreaterThan(1); jmxConnector.close(); }
Example 10
Source File: ModelControllerMBeanTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Test public void testExposedMBeans() throws Exception { MBeanServerConnection connection = setupAndGetConnection(new BaseAdditionalInitialization(ProcessType.STANDALONE_SERVER)); int count = connection.getMBeanCount(); checkQueryMBeans(connection, count, null); checkQueryMBeans(connection, count, new ObjectName("*:*")); Set<ObjectInstance> filteredInstances = connection.queryMBeans(createObjectName(LEGACY_DOMAIN + ":socket-binding-group=*,*"), null); Set<ObjectName> filteredNames = connection.queryNames(createObjectName(LEGACY_DOMAIN + ":socket-binding-group=*,*"), null); Assert.assertEquals(2, filteredInstances.size()); Assert.assertEquals(2, filteredNames.size()); checkSameMBeans(filteredInstances, filteredNames); assertContainsNames(filteredNames, LEGACY_SOCKET_BINDING_GROUP_NAME, LEGACY_SERVER_SOCKET_BINDING_NAME); filteredInstances = connection.queryMBeans(createObjectName(EXPR_DOMAIN + ":socket-binding-group=*,*"), null); filteredNames = connection.queryNames(createObjectName(EXPR_DOMAIN + ":socket-binding-group=*,*"), null); Assert.assertEquals(2, filteredInstances.size()); Assert.assertEquals(2, filteredNames.size()); checkSameMBeans(filteredInstances, filteredNames); assertContainsNames(filteredNames, EXPR_SOCKET_BINDING_GROUP_NAME, EXPR_SERVER_SOCKET_BINDING_NAME); // WFCORE-1716 Test with a property list pattern where the non-wildcard keys are for items later in the address filteredInstances = connection.queryMBeans(createObjectName(LEGACY_DOMAIN + ":socket-binding=*,*"), null); filteredNames = connection.queryNames(createObjectName(LEGACY_DOMAIN + ":socket-binding=*,*"), null); Assert.assertEquals(1, filteredInstances.size()); Assert.assertEquals(1, filteredNames.size()); checkSameMBeans(filteredInstances, filteredNames); assertContainsNames(filteredNames, LEGACY_SERVER_SOCKET_BINDING_NAME); // WFCORE-1257 -- Test with QueryExp // First a numeric query (port) = (12345) filteredInstances = connection.queryMBeans(createObjectName(LEGACY_DOMAIN + ":socket-binding-group=*,*"), PORT_QUERY_EXP); filteredNames = connection.queryNames(createObjectName(LEGACY_DOMAIN + ":socket-binding-group=*,*"), PORT_QUERY_EXP); Assert.assertEquals(1, filteredInstances.size()); Assert.assertEquals(1, filteredNames.size()); checkSameMBeans(filteredInstances, filteredNames); assertContainsNames(filteredNames, LEGACY_SERVER_SOCKET_BINDING_NAME); // Doesn't match on jboss.as.expr as the value is a string filteredInstances = connection.queryMBeans(createObjectName(EXPR_DOMAIN + ":socket-binding-group=*,*"), PORT_QUERY_EXP); filteredNames = connection.queryNames(createObjectName(EXPR_DOMAIN + ":socket-binding-group=*,*"), PORT_QUERY_EXP); Assert.assertEquals(0, filteredInstances.size()); Assert.assertEquals(0, filteredNames.size()); // Next a port string query (port) = ("12345") // Doesn't match on jboss.as as the value is an int filteredInstances = connection.queryMBeans(createObjectName(LEGACY_DOMAIN + ":socket-binding-group=*,*"), PORT_STRING_QUERY_EXP); filteredNames = connection.queryNames(createObjectName(LEGACY_DOMAIN + ":socket-binding-group=*,*"), PORT_STRING_QUERY_EXP); Assert.assertEquals(0, filteredInstances.size()); Assert.assertEquals(0, filteredNames.size()); // Does match on jboss.as.expr as the value is a string filteredInstances = connection.queryMBeans(createObjectName(EXPR_DOMAIN + ":socket-binding-group=*,*"), PORT_STRING_QUERY_EXP); filteredNames = connection.queryNames(createObjectName(EXPR_DOMAIN + ":socket-binding-group=*,*"), PORT_STRING_QUERY_EXP); Assert.assertEquals(1, filteredInstances.size()); Assert.assertEquals(1, filteredNames.size()); checkSameMBeans(filteredInstances, filteredNames); assertContainsNames(filteredNames, EXPR_SERVER_SOCKET_BINDING_NAME); // Next a straight string query (defaultInterface) = ("test-interface") // Note this also checks a bit on the default-interface -> defaultInterface camel case handling filteredInstances = connection.queryMBeans(createObjectName(LEGACY_DOMAIN + ":socket-binding-group=*,*"), DEFAULT_INTERFACE_QUERY_EXP); filteredNames = connection.queryNames(createObjectName(LEGACY_DOMAIN + ":socket-binding-group=*,*"), DEFAULT_INTERFACE_QUERY_EXP); Assert.assertEquals(1, filteredInstances.size()); Assert.assertEquals(1, filteredNames.size()); checkSameMBeans(filteredInstances, filteredNames); assertContainsNames(filteredNames, LEGACY_SOCKET_BINDING_GROUP_NAME); filteredInstances = connection.queryMBeans(createObjectName(EXPR_DOMAIN + ":socket-binding-group=*,*"), DEFAULT_INTERFACE_QUERY_EXP); filteredNames = connection.queryNames(createObjectName(EXPR_DOMAIN + ":socket-binding-group=*,*"), DEFAULT_INTERFACE_QUERY_EXP); Assert.assertEquals(1, filteredInstances.size()); Assert.assertEquals(1, filteredNames.size()); checkSameMBeans(filteredInstances, filteredNames); assertContainsNames(filteredNames, EXPR_SOCKET_BINDING_GROUP_NAME); }
Example 11
Source File: JMXSubsystemTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Test public void testInstallIntoController() throws Exception { //Parse the subsystem xml and install into the controller String subsystemXml = "<subsystem xmlns=\"" + Namespace.CURRENT.getUriString() + "\">" + "<remoting-connector/>" + "</subsystem>"; KernelServices services = createKernelServicesBuilder(new BaseAdditionalInitialization()) .setSubsystemXml(subsystemXml) .build(); Assert.assertTrue(services.isSuccessfulBoot()); //Read the whole model and make sure it looks as expected ModelNode model = services.readWholeModel(); Assert.assertTrue(model.get(SUBSYSTEM).hasDefined(JMXExtension.SUBSYSTEM_NAME)); //Make sure that we can connect to the MBean server String urlString = System.getProperty("jmx.service.url", "service:jmx:remoting-jmx://localhost:" + JMX_PORT); JMXServiceURL serviceURL = new JMXServiceURL(urlString); JMXConnector connector = null; try { MBeanServerConnection connection = null; long end = System.currentTimeMillis() + 10000; do { try { connector = JMXConnectorFactory.connect(serviceURL, null); connection = connector.getMBeanServerConnection(); } catch (Exception e) { e.printStackTrace(); Thread.sleep(500); } } while (connection == null && System.currentTimeMillis() < end); Assert.assertNotNull(connection); connection.getMBeanCount(); } finally { IoUtils.safeClose(connector); } super.assertRemoveSubsystemResources(services); }