Java Code Examples for javax.management.Query#eq()
The following examples show how to use
javax.management.Query#eq() .
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: Solr4X509ServletFilter.java From SearchServices with GNU Lesser General Public License v3.0 | 6 votes |
Optional<ObjectName> connectorMBeanName() { try { final QueryExp query = Query.eq(Query.attr("Scheme"), Query.value("https")); final Set<ObjectName> connectors = mxServer().queryNames(null, query); return connectors .stream() .findFirst(); } catch (final Exception exception) { logger.error("Error getting the Connector MBean.", exception); return Optional.empty(); } }
Example 2
Source File: LocalProcessController.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Builds the QueryExp used to identify the target MBean. * * @param pidAttribute the name of the MBean attribute with the process id to compare against * @param attributes the names of additional MBean attributes to compare with expected values * @param values the expected values of the specified MBean attributes * * @return the main QueryExp for matching the target MBean */ private QueryExp buildQueryExp(final String pidAttribute, final String[] attributes, final Object[] values) { final QueryExp optionalAttributes = buildOptionalQueryExp(attributes, values); QueryExp constraint; if (optionalAttributes != null) { constraint = Query.and(optionalAttributes, Query.eq( Query.attr(pidAttribute), Query.value(this.pid))); } else { constraint = Query.eq( Query.attr(pidAttribute), Query.value(this.pid)); } return constraint; }
Example 3
Source File: LocalProcessController.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Builds an optional QueryExp to aid in matching the correct MBean using * additional attributes with the specified values. Returns null if no * attributes and values were specified during construction. * * @param attributes the names of additional MBean attributes to compare with expected values * @param values the expected values of the specified MBean attributes * * @return optional QueryExp to aid in matching the correct MBean */ private QueryExp buildOptionalQueryExp(final String[] attributes, final Object[] values) { QueryExp queryExp = null; for (int i = 0; i < attributes.length; i++) { if (values[i] instanceof Boolean) { if (queryExp == null) { queryExp = Query.eq( Query.attr(attributes[i]), Query.value(((Boolean) values[i]))); } else { queryExp = Query.and(queryExp, Query.eq(Query.attr(attributes[i]), Query.value(((Boolean) values[i])))); } } else if (values[i] instanceof Number) { if (queryExp == null) { queryExp = Query.eq( Query.attr(attributes[i]), Query.value((Number)values[i])); } else { queryExp = Query.and(queryExp, Query.eq(Query.attr(attributes[i]), Query.value((Number)values[i]))); } } else if (values[i] instanceof String) { if (queryExp == null) { queryExp = Query.eq( Query.attr(attributes[i]), Query.value((String)values[i])); } else { queryExp = Query.and(queryExp, Query.eq(Query.attr(attributes[i]), Query.value((String)values[i]))); } } } return queryExp; }
Example 4
Source File: MBeanProcessController.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Builds the QueryExp used to identify the target MBean. * * @param pidAttribute the name of the MBean attribute with the process id to compare against * @param attributes the names of additional MBean attributes to compare with expected values * @param values the expected values of the specified MBean attributes * * @return the main QueryExp for matching the target MBean */ private QueryExp buildQueryExp(final String pidAttribute, final String[] attributes, final Object[] values) { final QueryExp optionalAttributes = buildOptionalQueryExp(attributes, values); QueryExp constraint; if (optionalAttributes != null) { constraint = Query.and(optionalAttributes, Query.eq( Query.attr(pidAttribute), Query.value(this.pid))); } else { constraint = Query.eq( Query.attr(pidAttribute), Query.value(this.pid)); } return constraint; }
Example 5
Source File: MBeanProcessController.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Builds an optional QueryExp to aid in matching the correct MBean using * additional attributes with the specified values. Returns null if no * attributes and values were specified during construction. * * @param attributes the names of additional MBean attributes to compare with expected values * @param values the expected values of the specified MBean attributes * * @return optional QueryExp to aid in matching the correct MBean */ private QueryExp buildOptionalQueryExp(final String[] attributes, final Object[] values) { QueryExp queryExp = null; for (int i = 0; i < attributes.length; i++) { if (values[i] instanceof Boolean) { if (queryExp == null) { queryExp = Query.eq( Query.attr(attributes[i]), Query.value(((Boolean) values[i]))); } else { queryExp = Query.and(queryExp, Query.eq(Query.attr(attributes[i]), Query.value(((Boolean) values[i])))); } } else if (values[i] instanceof Number) { if (queryExp == null) { queryExp = Query.eq( Query.attr(attributes[i]), Query.value((Number)values[i])); } else { queryExp = Query.and(queryExp, Query.eq(Query.attr(attributes[i]), Query.value((Number)values[i]))); } } else if (values[i] instanceof String) { if (queryExp == null) { queryExp = Query.eq( Query.attr(attributes[i]), Query.value((String)values[i])); } else { queryExp = Query.and(queryExp, Query.eq(Query.attr(attributes[i]), Query.value((String)values[i]))); } } } return queryExp; }
Example 6
Source File: QueryParameterSourceJUnitTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
@Test public void testCreateQueryParameterSource() throws MalformedObjectNameException { final ObjectName expectedObjectName = ObjectName.getInstance("GemFire:type=Member,*"); final QueryExp expectedQueryExpression = Query.eq(Query.attr("id"), Query.value("12345")); final QueryParameterSource query = new QueryParameterSource(expectedObjectName, expectedQueryExpression); assertNotNull(query); assertSame(expectedObjectName, query.getObjectName()); assertSame(expectedQueryExpression, query.getQueryExpression()); }
Example 7
Source File: LauncherLifecycleCommandsDUnitTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
protected static String getMemberId(final String jmxManagerHost, final int jmxManagerPort, final String memberName) throws Exception { JMXConnector connector = null; try { connector = JMXConnectorFactory.connect(new JMXServiceURL(String.format( "service:jmx:rmi://%1$s/jndi/rmi://%1$s:%2$d/jmxrmi", jmxManagerHost, jmxManagerPort))); final MBeanServerConnection connection = connector.getMBeanServerConnection(); final ObjectName objectNamePattern = ObjectName.getInstance("GemFire:type=Member,*"); final QueryExp query = Query.eq(Query.attr("Name"), Query.value(memberName)); final Set<ObjectName> objectNames = connection.queryNames(objectNamePattern, query); assertNotNull(objectNames); assertEquals(1, objectNames.size()); //final ObjectName objectName = ObjectName.getInstance("GemFire:type=Member,Name=" + memberName); final ObjectName objectName = objectNames.iterator().next(); //System.err.printf("ObjectName for Member with Name (%1$s) is %2$s%n", memberName, objectName); return ObjectUtils.toString(connection.getAttribute(objectName, "Id")); } finally { IOUtils.close(connector); } }
Example 8
Source File: ServerManagement.java From micro-integrator with Apache License 2.0 | 5 votes |
/** * Wait till all service requests have been serviced. This method will only wait for a maximum * of {@link ServerManagement#TIMEOUT} * * @throws Exception If an error occurs while trying to connect to the Tomcat MBean */ public void waitForRequestCompletion() throws Exception { SecurityManager secMan = System.getSecurityManager(); if (secMan != null) { secMan.checkPermission(new ManagementPermission("control")); } log.info("Waiting for request service completion..."); /** * Get all MBeans with names such as Catalina:type=RequestProcessor,worker=http-9762,name=HttpRequest<n> * & Catalina:type=RequestProcessor,worker=http-9762,name=HttpsRequest<n> */ MBeanServer mbs = MbeanManagementFactory.getMBeanServer(); boolean areRequestsInService; long start = System.currentTimeMillis(); do { // Check whether there are any processors which are currently in the SERVICE stage (3) QueryExp query = Query.eq(Query.attr("stage"), Query.value(3)); // 3 = org.apache.coyote.Constants.STAGE_SERVICE Set set = mbs.queryNames(new ObjectName("Catalina:type=RequestProcessor,*"), query); if (set.size() > 0) { areRequestsInService = true; if (System.currentTimeMillis() - start > TIMEOUT) { log.warn("Timeout occurred even though there are active connections."); break; } Thread.sleep(2000); } else { areRequestsInService = false; } } while (areRequestsInService); log.info("All requests have been served."); }
Example 9
Source File: JmxMetricsReporter.java From lucene-solr with Apache License 2.0 | 5 votes |
private JmxListener(MBeanServer mBeanServer, String name, MetricFilter filter, TimeUnit rateUnit, TimeUnit durationUnit, ObjectNameFactory objectNameFactory, String tag) { this.mBeanServer = mBeanServer; this.name = name; this.filter = filter; this.rateUnit = rateUnit; this.durationUnit = durationUnit; this.registered = new ConcurrentHashMap<>(); this.objectNameFactory = objectNameFactory; this.tag = tag; this.exp = Query.eq(Query.attr(INSTANCE_TAG), Query.value(tag)); }
Example 10
Source File: LocalProcessController.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Builds the QueryExp used to identify the target MBean. * * @param pidAttribute the name of the MBean attribute with the process id to compare against * @param attributes the names of additional MBean attributes to compare with expected values * @param values the expected values of the specified MBean attributes * * @return the main QueryExp for matching the target MBean */ private QueryExp buildQueryExp(final String pidAttribute, final String[] attributes, final Object[] values) { final QueryExp optionalAttributes = buildOptionalQueryExp(attributes, values); QueryExp constraint; if (optionalAttributes != null) { constraint = Query.and(optionalAttributes, Query.eq( Query.attr(pidAttribute), Query.value(this.pid))); } else { constraint = Query.eq( Query.attr(pidAttribute), Query.value(this.pid)); } return constraint; }
Example 11
Source File: LocalProcessController.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Builds an optional QueryExp to aid in matching the correct MBean using * additional attributes with the specified values. Returns null if no * attributes and values were specified during construction. * * @param attributes the names of additional MBean attributes to compare with expected values * @param values the expected values of the specified MBean attributes * * @return optional QueryExp to aid in matching the correct MBean */ private QueryExp buildOptionalQueryExp(final String[] attributes, final Object[] values) { QueryExp queryExp = null; for (int i = 0; i < attributes.length; i++) { if (values[i] instanceof Boolean) { if (queryExp == null) { queryExp = Query.eq( Query.attr(attributes[i]), Query.value(((Boolean) values[i]))); } else { queryExp = Query.and(queryExp, Query.eq(Query.attr(attributes[i]), Query.value(((Boolean) values[i])))); } } else if (values[i] instanceof Number) { if (queryExp == null) { queryExp = Query.eq( Query.attr(attributes[i]), Query.value((Number)values[i])); } else { queryExp = Query.and(queryExp, Query.eq(Query.attr(attributes[i]), Query.value((Number)values[i]))); } } else if (values[i] instanceof String) { if (queryExp == null) { queryExp = Query.eq( Query.attr(attributes[i]), Query.value((String)values[i])); } else { queryExp = Query.and(queryExp, Query.eq(Query.attr(attributes[i]), Query.value((String)values[i]))); } } } return queryExp; }
Example 12
Source File: MBeanProcessController.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Builds the QueryExp used to identify the target MBean. * * @param pidAttribute the name of the MBean attribute with the process id to compare against * @param attributes the names of additional MBean attributes to compare with expected values * @param values the expected values of the specified MBean attributes * * @return the main QueryExp for matching the target MBean */ private QueryExp buildQueryExp(final String pidAttribute, final String[] attributes, final Object[] values) { final QueryExp optionalAttributes = buildOptionalQueryExp(attributes, values); QueryExp constraint; if (optionalAttributes != null) { constraint = Query.and(optionalAttributes, Query.eq( Query.attr(pidAttribute), Query.value(this.pid))); } else { constraint = Query.eq( Query.attr(pidAttribute), Query.value(this.pid)); } return constraint; }
Example 13
Source File: MBeanProcessController.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Builds an optional QueryExp to aid in matching the correct MBean using * additional attributes with the specified values. Returns null if no * attributes and values were specified during construction. * * @param attributes the names of additional MBean attributes to compare with expected values * @param values the expected values of the specified MBean attributes * * @return optional QueryExp to aid in matching the correct MBean */ private QueryExp buildOptionalQueryExp(final String[] attributes, final Object[] values) { QueryExp queryExp = null; for (int i = 0; i < attributes.length; i++) { if (values[i] instanceof Boolean) { if (queryExp == null) { queryExp = Query.eq( Query.attr(attributes[i]), Query.value(((Boolean) values[i]))); } else { queryExp = Query.and(queryExp, Query.eq(Query.attr(attributes[i]), Query.value(((Boolean) values[i])))); } } else if (values[i] instanceof Number) { if (queryExp == null) { queryExp = Query.eq( Query.attr(attributes[i]), Query.value((Number)values[i])); } else { queryExp = Query.and(queryExp, Query.eq(Query.attr(attributes[i]), Query.value((Number)values[i]))); } } else if (values[i] instanceof String) { if (queryExp == null) { queryExp = Query.eq( Query.attr(attributes[i]), Query.value((String)values[i])); } else { queryExp = Query.and(queryExp, Query.eq(Query.attr(attributes[i]), Query.value((String)values[i]))); } } } return queryExp; }
Example 14
Source File: QueryParameterSourceJUnitTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
@Test public void testCreateQueryParameterSource() throws MalformedObjectNameException { final ObjectName expectedObjectName = ObjectName.getInstance("GemFire:type=Member,*"); final QueryExp expectedQueryExpression = Query.eq(Query.attr("id"), Query.value("12345")); final QueryParameterSource query = new QueryParameterSource(expectedObjectName, expectedQueryExpression); assertNotNull(query); assertSame(expectedObjectName, query.getObjectName()); assertSame(expectedQueryExpression, query.getQueryExpression()); }
Example 15
Source File: LauncherLifecycleCommandsDUnitTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
protected static String getMemberId(final String jmxManagerHost, final int jmxManagerPort, final String memberName) throws Exception { JMXConnector connector = null; try { connector = JMXConnectorFactory.connect(new JMXServiceURL(String.format( "service:jmx:rmi://%1$s/jndi/rmi://%1$s:%2$d/jmxrmi", jmxManagerHost, jmxManagerPort))); final MBeanServerConnection connection = connector.getMBeanServerConnection(); final ObjectName objectNamePattern = ObjectName.getInstance("GemFire:type=Member,*"); final QueryExp query = Query.eq(Query.attr("Name"), Query.value(memberName)); final Set<ObjectName> objectNames = connection.queryNames(objectNamePattern, query); assertNotNull(objectNames); assertEquals(1, objectNames.size()); //final ObjectName objectName = ObjectName.getInstance("GemFire:type=Member,Name=" + memberName); final ObjectName objectName = objectNames.iterator().next(); //System.err.printf("ObjectName for Member with Name (%1$s) is %2$s%n", memberName, objectName); return ObjectUtils.toString(connection.getAttribute(objectName, "Id")); } finally { IOUtils.close(connector); } }
Example 16
Source File: LocalProcessControllerJUnitTest.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
public void testProcessMBean() throws Exception { final String testName = "testProcessMBean"; final int pid = ProcessUtils.identifyPid(); final Process process = new Process(pid, true); final ObjectName objectName = ObjectName.getInstance( getClass().getSimpleName() + ":testName=" + testName); final MBeanServer server = ManagementFactory.getPlatformMBeanServer(); final ObjectInstance instance = server.registerMBean(process, objectName); assertNotNull(instance); try { // validate basics of the ProcessMBean Set<ObjectName> mbeanNames = server.queryNames(objectName, null); assertFalse("Zero matching mbeans", mbeanNames.isEmpty()); assertEquals(1, mbeanNames.size()); final ObjectName name = mbeanNames.iterator().next(); final MBeanInfo info = server.getMBeanInfo(name); final MBeanOperationInfo[] operInfo = info.getOperations(); assertEquals(1, operInfo.length); assertEquals("stop", operInfo[0].getName()); final MBeanAttributeInfo[] attrInfo = info.getAttributes(); assertEquals(2, attrInfo.length); // The order of these attributes is indeterminate // assertEquals("Pid", attrInfo[0].getName()); // assertEquals("Process", attrInfo[1].getName()); assertNotNull(server.getAttribute(name, "Pid")); assertNotNull(server.getAttribute(name, "Process")); assertEquals(pid, server.getAttribute(name, "Pid")); assertEquals(true, server.getAttribute(name, "Process")); // validate query using only Pid attribute QueryExp constraint = Query.eq( Query.attr("Pid"), Query.value(pid)); mbeanNames = server.queryNames(objectName, constraint); assertFalse("Zero matching mbeans", mbeanNames.isEmpty()); // validate query with wrong Pid finds nothing constraint = Query.eq( Query.attr("Pid"), Query.value(pid+1)); mbeanNames = server.queryNames(objectName, constraint); assertTrue("Found matching mbeans", mbeanNames.isEmpty()); // validate query using both attributes constraint = Query.and( Query.eq(Query.attr("Process"),Query.value(true)), Query.eq(Query.attr("Pid"),Query.value(pid))); mbeanNames = server.queryNames(objectName, constraint); assertFalse("Zero matching mbeans", mbeanNames.isEmpty()); // validate query with wrong attribute finds nothing constraint = Query.and( Query.eq(Query.attr("Process"),Query.value(false)), Query.eq(Query.attr("Pid"),Query.value(pid))); mbeanNames = server.queryNames(objectName, constraint); assertTrue("Found matching mbeans", mbeanNames.isEmpty()); } finally { try { server.unregisterMBean(objectName); } catch (Throwable t) { t.printStackTrace(); } } }
Example 17
Source File: LocalProcessControllerJUnitTest.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
public void testProcessMBean() throws Exception { final String testName = "testProcessMBean"; final int pid = ProcessUtils.identifyPid(); final Process process = new Process(pid, true); final ObjectName objectName = ObjectName.getInstance( getClass().getSimpleName() + ":testName=" + testName); final MBeanServer server = ManagementFactory.getPlatformMBeanServer(); final ObjectInstance instance = server.registerMBean(process, objectName); assertNotNull(instance); try { // validate basics of the ProcessMBean Set<ObjectName> mbeanNames = server.queryNames(objectName, null); assertFalse("Zero matching mbeans", mbeanNames.isEmpty()); assertEquals(1, mbeanNames.size()); final ObjectName name = mbeanNames.iterator().next(); final MBeanInfo info = server.getMBeanInfo(name); final MBeanOperationInfo[] operInfo = info.getOperations(); assertEquals(1, operInfo.length); assertEquals("stop", operInfo[0].getName()); final MBeanAttributeInfo[] attrInfo = info.getAttributes(); assertEquals(2, attrInfo.length); // The order of these attributes is indeterminate // assertEquals("Pid", attrInfo[0].getName()); // assertEquals("Process", attrInfo[1].getName()); assertNotNull(server.getAttribute(name, "Pid")); assertNotNull(server.getAttribute(name, "Process")); assertEquals(pid, server.getAttribute(name, "Pid")); assertEquals(true, server.getAttribute(name, "Process")); // validate query using only Pid attribute QueryExp constraint = Query.eq( Query.attr("Pid"), Query.value(pid)); mbeanNames = server.queryNames(objectName, constraint); assertFalse("Zero matching mbeans", mbeanNames.isEmpty()); // validate query with wrong Pid finds nothing constraint = Query.eq( Query.attr("Pid"), Query.value(pid+1)); mbeanNames = server.queryNames(objectName, constraint); assertTrue("Found matching mbeans", mbeanNames.isEmpty()); // validate query using both attributes constraint = Query.and( Query.eq(Query.attr("Process"),Query.value(true)), Query.eq(Query.attr("Pid"),Query.value(pid))); mbeanNames = server.queryNames(objectName, constraint); assertFalse("Zero matching mbeans", mbeanNames.isEmpty()); // validate query with wrong attribute finds nothing constraint = Query.and( Query.eq(Query.attr("Process"),Query.value(false)), Query.eq(Query.attr("Pid"),Query.value(pid))); mbeanNames = server.queryNames(objectName, constraint); assertTrue("Found matching mbeans", mbeanNames.isEmpty()); } finally { try { server.unregisterMBean(objectName); } catch (Throwable t) { t.printStackTrace(); } } }