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(); 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; } } } } while (stopwatch.elapsedTime(timeoutUnit) < timeout); return false; }
@Override protected void registerJMX() { // register with JMX try { jmxDataTreeBean = new DataTreeBean(getZKDatabase().getDataTree()); MBeanRegistry.getInstance().register(jmxDataTreeBean, jmxServerBean); } catch (Exception e) { LOG.warn("Failed to register with JMX", e); jmxDataTreeBean = null; } }
@Override protected void unregisterJMX() { // unregister from JMX try { if (jmxDataTreeBean != null) { MBeanRegistry.getInstance().unregister(jmxDataTreeBean); } } catch (Exception e) { LOG.warn("Failed to unregister with JMX", e); } jmxDataTreeBean = null; }
protected void unregisterJMX(Learner peer) { // unregister from JMX try { if (jmxServerBean != null) { MBeanRegistry.getInstance().unregister(jmxServerBean); } } catch (Exception e) { LOG.warn("Failed to unregister with JMX", e); } jmxServerBean = null; }
protected void unregisterJMX(Leader leader) { // unregister from JMX try { if (jmxServerBean != null) { MBeanRegistry.getInstance().unregister(jmxServerBean); } } catch (Exception e) { LOG.warn("Failed to unregister with JMX", e); } jmxServerBean = null; }
public void registerJMX(ZooKeeperServerBean serverBean, LocalPeerBean localPeerBean) { // register with JMX try { jmxServerBean = serverBean; MBeanRegistry.getInstance().register(serverBean, localPeerBean); } catch (Exception e) { LOG.warn("Failed to register with JMX", e); jmxServerBean = null; } }
protected void unregisterJMX(ZooKeeperServer zks) { // unregister from JMX try { if (jmxServerBean != null) { MBeanRegistry.getInstance().unregister(jmxServerBean); } } catch (Exception e) { LOG.warn("Failed to unregister with JMX", e); } jmxServerBean = null; }
public void registerConnection(ServerCnxn serverCnxn) { if (zkServer != null) { ConnectionBean jmxConnectionBean = new ConnectionBean(serverCnxn, zkServer); try { MBeanRegistry.getInstance().register(jmxConnectionBean, zkServer.jmxServerBean); connectionBeans.put(serverCnxn, jmxConnectionBean); } catch (JMException e) { LOG.warn("Could not register connection", e); } } }
public static void setUp() throws IOException { MBeanServer mbs = MBeanRegistry.getInstance().getPlatformMBeanServer(); JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://"); cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs); cs.start(); JMXServiceURL addr = cs.getAddress(); cc = JMXConnectorFactory.connect(addr); }
public static void setUp() throws IOException { MBeanServer mbs = MBeanRegistry.getInstance().getPlatformMBeanServer(); JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://127.0.0.1"); cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs); cs.start(); JMXServiceURL addr = cs.getAddress(); cc = JMXConnectorFactory.connect(addr); }