mirror of https://github.com/apache/lucene.git
Try all MBeanServers before giving up
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@681613 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b7bdc34715
commit
e25d09c798
|
@ -60,7 +60,7 @@ public class TestJmxIntegration extends AbstractSolrTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testJmxRegistration() throws Exception {
|
public void testJmxRegistration() throws Exception {
|
||||||
List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
|
List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
|
||||||
System.out.println("Servers: " + servers);
|
System.out.println("Servers in testJmxRegistration: " + servers);
|
||||||
assertNotNull("MBeanServers were null", servers);
|
assertNotNull("MBeanServers were null", servers);
|
||||||
assertFalse("No MBeanServer was found", servers.isEmpty());
|
assertFalse("No MBeanServer was found", servers.isEmpty());
|
||||||
|
|
||||||
|
@ -82,12 +82,24 @@ public class TestJmxIntegration extends AbstractSolrTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testJmxUpdate() throws Exception {
|
public void testJmxUpdate() throws Exception {
|
||||||
List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
|
List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
|
||||||
MBeanServer mbeanServer = servers.get(0);
|
System.out.println("Servers in testJmxUpdate: " + servers);
|
||||||
|
boolean found = false;
|
||||||
|
Set<ObjectInstance> objects = null;
|
||||||
|
MBeanServer mbeanServer = null;
|
||||||
|
|
||||||
Set<ObjectInstance> objects = mbeanServer.queryMBeans(null, Query.match(
|
for (MBeanServer server : servers) {
|
||||||
Query.attr("numDocs"), Query.value("[0-9]")));
|
objects = server.queryMBeans(null, Query.match(
|
||||||
assertFalse("No MBean for SolrIndexSearcher found in MBeanServer", objects
|
Query.attr("numDocs"), Query.value("*")));
|
||||||
.isEmpty());
|
if (!objects.isEmpty()) {
|
||||||
|
found = true;
|
||||||
|
mbeanServer = server;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
assertFalse("No MBean for SolrIndexSearcher found in MBeanServer", objects.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
int oldNumDocs = Integer.valueOf((String) mbeanServer.getAttribute(objects
|
int oldNumDocs = Integer.valueOf((String) mbeanServer.getAttribute(objects
|
||||||
.iterator().next().getObjectName(), "numDocs"));
|
.iterator().next().getObjectName(), "numDocs"));
|
||||||
|
@ -96,7 +108,7 @@ public class TestJmxIntegration extends AbstractSolrTestCase {
|
||||||
assertU(commit());
|
assertU(commit());
|
||||||
|
|
||||||
objects = mbeanServer.queryMBeans(null, Query.match(Query.attr("numDocs"),
|
objects = mbeanServer.queryMBeans(null, Query.match(Query.attr("numDocs"),
|
||||||
Query.value("[0-9]")));
|
Query.value("*")));
|
||||||
assertFalse("No MBean for SolrIndexSearcher found in MBeanServer", objects
|
assertFalse("No MBean for SolrIndexSearcher found in MBeanServer", objects
|
||||||
.isEmpty());
|
.isEmpty());
|
||||||
|
|
||||||
|
@ -106,3 +118,4 @@ public class TestJmxIntegration extends AbstractSolrTestCase {
|
||||||
numDocs > oldNumDocs);
|
numDocs > oldNumDocs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue