mirror of
https://github.com/apache/lucene.git
synced 2025-02-28 05:19:17 +00:00
Added debug output and changed the failing test to use SolrIndexSearcher's ObjectName directly.
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@681640 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
670174c87b
commit
1d92c29bf0
@ -26,6 +26,7 @@ import javax.management.*;
|
|||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for JMX Integration
|
* Test for JMX Integration
|
||||||
@ -83,39 +84,27 @@ public class TestJmxIntegration extends AbstractSolrTestCase {
|
|||||||
public void testJmxUpdate() throws Exception {
|
public void testJmxUpdate() throws Exception {
|
||||||
List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
|
List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
|
||||||
System.out.println("Servers in testJmxUpdate: " + servers);
|
System.out.println("Servers in testJmxUpdate: " + servers);
|
||||||
boolean found = false;
|
|
||||||
Set<ObjectInstance> objects = null;
|
|
||||||
MBeanServer mbeanServer = null;
|
|
||||||
|
|
||||||
for (MBeanServer server : servers) {
|
ObjectName searcher = getObjectName("searcher", h.getCore().getInfoRegistry().get("searcher"));
|
||||||
objects = server.queryMBeans(null, Query.match(
|
MBeanServer mbeanServer = servers.get(0);
|
||||||
Query.attr("numDocs"), Query.value("*")));
|
System.out.println("Mbeans in server: " + mbeanServer.queryNames(null, null));
|
||||||
if (!objects.isEmpty()) {
|
|
||||||
found = true;
|
|
||||||
mbeanServer = server;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found) {
|
assertFalse("No mbean found for SolrIndexSearcher", mbeanServer.queryMBeans(searcher, null).isEmpty());
|
||||||
assertFalse("No MBean for SolrIndexSearcher found in MBeanServer", objects.isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
int oldNumDocs = Integer.valueOf((String) mbeanServer.getAttribute(objects
|
|
||||||
.iterator().next().getObjectName(), "numDocs"));
|
|
||||||
|
|
||||||
|
int oldNumDocs = Integer.valueOf((String) mbeanServer.getAttribute(searcher, "numDocs"));
|
||||||
assertU(adoc("id", "1"));
|
assertU(adoc("id", "1"));
|
||||||
assertU(commit());
|
assertU("commit", commit());
|
||||||
|
int numDocs = Integer.valueOf((String) mbeanServer.getAttribute(searcher, "numDocs"));
|
||||||
objects = mbeanServer.queryMBeans(null, Query.match(Query.attr("numDocs"),
|
|
||||||
Query.value("*")));
|
|
||||||
assertFalse("No MBean for SolrIndexSearcher found in MBeanServer", objects
|
|
||||||
.isEmpty());
|
|
||||||
|
|
||||||
int numDocs = Integer.valueOf((String) mbeanServer.getAttribute(objects
|
|
||||||
.iterator().next().getObjectName(), "numDocs"));
|
|
||||||
assertTrue("New numDocs is same as old numDocs as reported by JMX",
|
assertTrue("New numDocs is same as old numDocs as reported by JMX",
|
||||||
numDocs > oldNumDocs);
|
numDocs > oldNumDocs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ObjectName getObjectName(String key, SolrInfoMBean infoBean)
|
||||||
|
throws MalformedObjectNameException {
|
||||||
|
Hashtable<String, String> map = new Hashtable<String, String>();
|
||||||
|
map.put("type", key);
|
||||||
|
map.put("id", infoBean.getName());
|
||||||
|
return ObjectName.getInstance("solr", map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user