use of javax.management.ObjectInstance in project geode by apache.
the class MBeanSecurityJUnitTest method testQueryBean.
/**
* looks like everyone can query for beans, but the AccessControlMXBean is filtered from the
* result
*/
@Test
@ConnectionConfiguration(user = "stranger", password = "1234567")
public void testQueryBean() throws MalformedObjectNameException, IOException {
MBeanServerConnection con = connectionRule.getMBeanServerConnection();
Set<ObjectInstance> objects = con.queryMBeans(ObjectName.getInstance(ResourceConstants.OBJECT_NAME_ACCESSCONTROL), null);
// no AccessControlMBean in the query result
assertThat(objects.size()).isEqualTo(0);
objects = con.queryMBeans(ObjectName.getInstance("GemFire:service=CacheServer,*"), null);
assertThat(objects.size()).isEqualTo(1);
}
use of javax.management.ObjectInstance in project lucene-solr by apache.
the class TestJmxIntegration method testJmxUpdate.
@Test
public void testJmxUpdate() throws Exception {
SolrInfoBean bean = null;
// wait until searcher is registered
for (int i = 0; i < 100; i++) {
bean = h.getCore().getInfoRegistry().get("searcher");
if (bean != null)
break;
Thread.sleep(250);
}
if (bean == null)
throw new RuntimeException("searcher was never registered");
ObjectName searcher = nameFactory.createName("gauge", registryName, "SEARCHER.searcher.*");
log.info("Mbeans in server: " + mbeanServer.queryNames(null, null));
Set<ObjectInstance> objects = mbeanServer.queryMBeans(searcher, null);
assertFalse("No mbean found for SolrIndexSearcher", mbeanServer.queryMBeans(searcher, null).isEmpty());
ObjectName name = nameFactory.createName("gauge", registryName, "SEARCHER.searcher.numDocs");
int oldNumDocs = (Integer) mbeanServer.getAttribute(name, "Value");
assertU(adoc("id", "1"));
assertU("commit", commit());
int numDocs = (Integer) mbeanServer.getAttribute(name, "Value");
assertTrue("New numDocs is same as old numDocs as reported by JMX", numDocs > oldNumDocs);
}
use of javax.management.ObjectInstance in project lucene-solr by apache.
the class SolrJmxReporterTest method testReportMetrics.
@Test
public void testReportMetrics() throws Exception {
Random random = random();
Map<String, Counter> registered = new HashMap<>();
String scope = SolrMetricTestUtils.getRandomScope(random, true);
SolrInfoBean.Category category = SolrMetricTestUtils.getRandomCategory(random, true);
int iterations = TestUtil.nextInt(random, 0, MAX_ITERATIONS);
for (int i = 0; i < iterations; ++i) {
Map<String, Counter> metrics = SolrMetricTestUtils.getRandomMetricsWithReplacements(random, registered);
SolrMetricProducer producer = SolrMetricTestUtils.getProducerOf(metricManager, category, scope, metrics);
coreMetricManager.registerMetricProducer(scope, producer);
registered.putAll(metrics);
//waitForListener();
Set<ObjectInstance> objects = mBeanServer.queryMBeans(null, null);
assertEquals(registered.size(), objects.stream().filter(o -> scope.equals(o.getObjectName().getKeyProperty("scope")) && rootName.equals(o.getObjectName().getDomain())).count());
}
}
use of javax.management.ObjectInstance in project wildfly by wildfly.
the class LogStoreProbeHandler method addParticipants.
private void addParticipants(final Resource parent, Set<ObjectInstance> participants, MBeanServer mbs) throws IntrospectionException, InstanceNotFoundException, IOException, ReflectionException {
int i = 1;
for (ObjectInstance participant : participants) {
final Resource resource = new LogStoreResource.LogStoreRuntimeResource(participant.getObjectName());
final ModelNode model = resource.getModel();
Map<String, String> pAttributes = getMBeanValues(mbs, participant.getObjectName(), LogStoreConstants.PARTICIPANT_JMX_NAMES);
String pAddress = pAttributes.get(JNDI_PROPNAME);
if (pAddress == null || pAddress.length() == 0) {
pAttributes.put(JNDI_PROPNAME, String.valueOf(i++));
pAddress = pAttributes.get(JNDI_PROPNAME);
}
addAttributes(model, LogStoreConstants.MODEL_TO_JMX_PARTICIPANT_NAMES, pAttributes);
// model.get(LogStoreConstants.JMX_ON_ATTRIBUTE).set(participant.getObjectName().getCanonicalName());
final PathElement element = PathElement.pathElement(LogStoreConstants.PARTICIPANTS, pAddress);
parent.registerChild(element, resource);
}
}
use of javax.management.ObjectInstance in project wildfly by wildfly.
the class LogStoreProbeHandler method probeTransactions.
private Resource probeTransactions(MBeanServer mbs, boolean exposeAllLogs) throws OperationFailedException {
try {
ObjectName on = new ObjectName(osMBeanName);
mbs.setAttribute(on, new javax.management.Attribute("ExposeAllRecordsAsMBeans", Boolean.valueOf(exposeAllLogs)));
mbs.invoke(on, "probe", null, null);
Set<ObjectInstance> transactions = mbs.queryMBeans(new ObjectName(osMBeanName + ",*"), null);
final Resource resource = Resource.Factory.create();
addTransactions(resource, transactions, mbs);
return resource;
} catch (JMException e) {
throw new OperationFailedException("Transaction discovery error: ", e);
} catch (IOException e) {
throw new OperationFailedException("Transaction discovery error: ", e);
}
}
Aggregations