javax.management.StringValueExp Java Examples
The following examples show how to use
javax.management.StringValueExp.
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: SessionExpireTestRun.java From twill with Apache License 2.0 | 5 votes |
private boolean expireAppMasterZKSession(TwillController controller, long timeout, TimeUnit timeoutUnit) { MBeanServer mbeanServer = MBeanRegistry.getInstance().getPlatformMBeanServer(); QueryExp query = Query.isInstanceOf(new StringValueExp(ConnectionMXBean.class.getName())); Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); do { // Find the AM session and expire it Set<ObjectName> connectionBeans = mbeanServer.queryNames(ObjectName.WILDCARD, query); for (ObjectName objectName : connectionBeans) { ConnectionMXBean connectionBean = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName, ConnectionMXBean.class, false); for (String node : connectionBean.getEphemeralNodes()) { if (node.endsWith("/instances/" + controller.getRunId().getId())) { // This is the AM, expire the session. LOG.info("Kill AM session {}", connectionBean.getSessionId()); connectionBean.terminateSession(); return true; } } } Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS); } while (stopwatch.elapsedTime(timeoutUnit) < timeout); return false; }