List of usage examples for java.lang.management ManagementFactory getPlatformMBeanServer
public static synchronized MBeanServer getPlatformMBeanServer()
From source file:com.qwazr.server.GenericServer.java
private void startHttpServer(final ServerConfiguration.WebConnector connector, final ServletContextBuilder context, final AccessLogger accessLogger) throws IOException, ServletException, OperationsException, MBeanException { if (context == null || context.getServlets().isEmpty()) return;//from w w w.j a va 2s . c o m context.setIdentityManager(getIdentityManager(connector)); contextAttributes.forEach(context::addServletContextAttribute); if (context.getIdentityManager() != null && !StringUtils.isEmpty(connector.authentication)) { if (hostnamePrincipalResolver != null) HostnameAuthenticationMechanism.register(context, hostnamePrincipalResolver); final LoginConfig loginConfig = Servlets.loginConfig(connector.realm); for (String authmethod : StringUtils.split(connector.authentication, ',')) loginConfig.addLastAuthMethod(authmethod); context.setLoginConfig(loginConfig); } final DeploymentManager manager = servletContainer.addDeployment(context); manager.deploy(); LOGGER.info(() -> "Start the connector " + configuration.listenAddress + ":" + connector.port); HttpHandler httpHandler = manager.start(); final LogMetricsHandler logMetricsHandler = new LogMetricsHandler(httpHandler, configuration.listenAddress, connector.port, context.jmxName, accessLogger); deploymentManagers.add(manager); httpHandler = logMetricsHandler; final Undertow.Builder servletBuilder = Undertow.builder() .addHttpListener(connector.port, configuration.listenAddress) .setServerOption(UndertowOptions.NO_REQUEST_TIMEOUT, 10000) .setServerOption(UndertowOptions.RECORD_REQUEST_START_TIME, true) .setServerOption(UndertowOptions.ENABLE_STATISTICS, true) .setServerOption(UndertowOptions.ENABLE_HTTP2, true).setHandler(httpHandler); start(servletBuilder.build()); // Register MBeans final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); final Hashtable<String, String> props = new Hashtable<>(); props.put("type", "connector"); props.put("name", context.jmxName); final ObjectName name = new ObjectName( "com.qwazr.server." + serverCounter.incrementAndGet() + "." + context.jmxName, props); mbs.registerMBean(logMetricsHandler, name); registeredObjectNames.add(name); connectorsStatistics.add(logMetricsHandler); }
From source file:com.ngdata.sep.impl.fork.ForkedReplicationSource.java
/** * SEP change - new method./* w w w. j ava 2 s .co m*/ */ private void unregisterMBean() { try { ManagementFactory.getPlatformMBeanServer().unregisterMBean(getMBeanName()); } catch (Exception e) { LOG.warn("Error unregistering mbean", e); } }
From source file:com.web.server.WebServer.java
/** * This is the start of the all the services in web server * @param args// w ww.jav a 2s . com * @throws IOException * @throws SAXException */ public static void main(String[] args) throws IOException, SAXException { Hashtable urlClassLoaderMap = new Hashtable(); Hashtable executorServicesMap = new Hashtable(); Hashtable ataMap = new Hashtable<String, ATAConfig>(); Hashtable messagingClassMap = new Hashtable(); ConcurrentHashMap servletMapping = new ConcurrentHashMap(); DigesterLoader serverdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { // TODO Auto-generated method stub try { loadXMLRules(new InputSource(new FileInputStream("./config/serverconfig-rules.xml"))); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); Digester serverdigester = serverdigesterLoader.newDigester(); final ServerConfig serverconfig = (ServerConfig) serverdigester .parse(new InputSource(new FileInputStream("./config/serverconfig.xml"))); DigesterLoader messagingdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { // TODO Auto-generated method stub try { loadXMLRules(new InputSource(new FileInputStream("./config/messagingconfig-rules.xml"))); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); Digester messagingdigester = messagingdigesterLoader.newDigester(); MessagingElem messagingconfig = (MessagingElem) messagingdigester .parse(new InputSource(new FileInputStream("./config/messaging.xml"))); //System.out.println(messagingconfig); ////System.out.println(serverconfig.getDeploydirectory()); PropertyConfigurator.configure("log4j.properties"); /*MemcachedClient cache=new MemcachedClient( new InetSocketAddress("localhost", 1000));*/ // Store a value (async) for one hour //c.set("someKey", 36, new String("arun")); // Retrieve a value. System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory"); System.setProperty(Context.URL_PKG_PREFIXES, "org.apache.naming"); ExecutorService executor = java.util.concurrent.Executors.newCachedThreadPool(); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName name = null; try { name = new ObjectName("com.web.server:type=WarDeployer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } WarDeployer warDeployer = new WarDeployer(serverconfig.getDeploydirectory(), serverconfig.getFarmWarDir(), serverconfig.getClustergroup(), urlClassLoaderMap, executorServicesMap, messagingClassMap, servletMapping, messagingconfig, sessionObjects); warDeployer.setPriority(MIN_PRIORITY); try { mbs.registerMBean(warDeployer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //warDeployer.start(); executor.execute(warDeployer); ServerSocketChannel serverSocketChannel = ServerSocketChannel.open(); serverSocketChannel.bind(new InetSocketAddress("0.0.0.0", Integer.parseInt(serverconfig.getPort()))); serverSocketChannel.configureBlocking(false); final byte[] shutdownBt = new byte[50]; WebServerRequestProcessor webserverRequestProcessor = new WebServer().new WebServerRequestProcessor( servletMapping, urlClassLoaderMap, serverSocketChannel, serverconfig.getDeploydirectory(), Integer.parseInt(serverconfig.getShutdownport()), 1); webserverRequestProcessor.setPriority(MIN_PRIORITY); try { name = new ObjectName("com.web.server:type=WebServerRequestProcessor"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(webserverRequestProcessor, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //webserverRequestProcessor.start(); executor.execute(webserverRequestProcessor); for (int i = 0; i < 10; i++) { WebServerRequestProcessor webserverRequestProcessor1 = new WebServer().new WebServerRequestProcessor( servletMapping, urlClassLoaderMap, serverSocketChannel, serverconfig.getDeploydirectory(), Integer.parseInt(serverconfig.getShutdownport()), 2); webserverRequestProcessor1.setPriority(MIN_PRIORITY); try { name = new ObjectName("com.web.server:type=WebServerRequestProcessor" + (i + 1)); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(webserverRequestProcessor1, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } executor.execute(webserverRequestProcessor1); } ServerSocketChannel serverSocketChannelServices = ServerSocketChannel.open(); serverSocketChannelServices .bind(new InetSocketAddress("0.0.0.0", Integer.parseInt(serverconfig.getServicesport()))); serverSocketChannelServices.configureBlocking(false); ExecutorServiceThread executorService = new ExecutorServiceThread(serverSocketChannelServices, executorServicesMap, Integer.parseInt(serverconfig.getShutdownport()), ataMap, urlClassLoaderMap, serverconfig.getDeploydirectory(), serverconfig.getServicesdirectory(), serverconfig.getEarservicesdirectory(), serverconfig.getNodesport()); try { name = new ObjectName("com.web.services:type=ExecutorServiceThread"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(executorService, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //executorService.start(); executor.execute(executorService); for (int i = 0; i < 10; i++) { ExecutorServiceThread executorService1 = new ExecutorServiceThread(serverSocketChannelServices, executorServicesMap, Integer.parseInt(serverconfig.getShutdownport()), ataMap, urlClassLoaderMap, serverconfig.getDeploydirectory(), serverconfig.getServicesdirectory(), serverconfig.getEarservicesdirectory(), serverconfig.getNodesport()); try { name = new ObjectName("com.web.services:type=ExecutorServiceThread" + (i + 1)); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(executorService1, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } executor.execute(executorService1); } WebServerHttpsRequestProcessor webserverHttpsRequestProcessor = new WebServer().new WebServerHttpsRequestProcessor( servletMapping, urlClassLoaderMap, Integer.parseInt(serverconfig.getHttpsport()), serverconfig.getDeploydirectory(), Integer.parseInt(serverconfig.getShutdownport()), serverconfig.getHttpscertificatepath(), serverconfig.getHttpscertificatepasscode(), 1); try { name = new ObjectName("com.web.server:type=WebServerHttpsRequestProcessor"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(webserverHttpsRequestProcessor, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } webserverHttpsRequestProcessor.setPriority(MAX_PRIORITY); //webserverRequestProcessor.start(); executor.execute(webserverHttpsRequestProcessor); /* for(int i=0;i<2;i++){ webserverHttpsRequestProcessor=new WebServer().new WebServerHttpsRequestProcessor(urlClassLoaderMap,Integer.parseInt(serverconfig.getHttpsport())+(i+1),serverconfig.getDeploydirectory(),Integer.parseInt(serverconfig.getShutdownport()),serverconfig.getHttpscertificatepath(),serverconfig.getHttpscertificatepasscode(),1); try { name = new ObjectName("com.web.server:type=WebServerHttpsRequestProcessor"+(i+1)); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(webserverHttpsRequestProcessor, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } executor.execute(webserverHttpsRequestProcessor); }*/ /*ATAServer ataServer=new ATAServer(serverconfig.getAtaaddress(),serverconfig.getAtaport(),ataMap); try { name = new ObjectName("com.web.services:type=ATAServer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(ataServer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ataServer.start();*/ /*ATAConfigClient ataClient=new ATAConfigClient(serverconfig.getAtaaddress(),serverconfig.getAtaport(),serverconfig.getServicesport(),executorServicesMap); try { name = new ObjectName("com.web.services:type=ATAConfigClient"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(ataClient, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ataClient.start();*/ MessagingServer messageServer = new MessagingServer(serverconfig.getMessageport(), messagingClassMap); try { name = new ObjectName("com.web.messaging:type=MessagingServer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(messageServer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //messageServer.start(); executor.execute(messageServer); RandomQueueMessagePicker randomqueuemessagepicker = new RandomQueueMessagePicker(messagingClassMap); try { name = new ObjectName("com.web.messaging:type=RandomQueueMessagePicker"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(randomqueuemessagepicker, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //randomqueuemessagepicker.start(); executor.execute(randomqueuemessagepicker); RoundRobinQueueMessagePicker roundrobinqueuemessagepicker = new RoundRobinQueueMessagePicker( messagingClassMap); try { name = new ObjectName("com.web.messaging:type=RoundRobinQueueMessagePicker"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(roundrobinqueuemessagepicker, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //roundrobinqueuemessagepicker.start(); executor.execute(roundrobinqueuemessagepicker); TopicMessagePicker topicpicker = new TopicMessagePicker(messagingClassMap); try { name = new ObjectName("com.web.messaging:type=TopicMessagePicker"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(topicpicker, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //topicpicker.start(); executor.execute(topicpicker); try { name = new ObjectName("com.web.server:type=SARDeployer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } SARDeployer sarDeployer = SARDeployer.newInstance(serverconfig.getDeploydirectory()); try { mbs.registerMBean(sarDeployer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } executor.execute(sarDeployer); /*try { mbs.invoke(name, "startDeployer", null, null); } catch (InstanceNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (ReflectionException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (MBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } */ System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory"); System.setProperty(Context.PROVIDER_URL, "rmi://localhost:" + serverconfig.getServicesregistryport()); ; Registry registry = LocateRegistry.createRegistry(Integer.parseInt(serverconfig.getServicesregistryport())); /*JarDeployer jarDeployer=new JarDeployer(registry,serverconfig.getServicesdirectory(), serverconfig.getServiceslibdirectory(),serverconfig.getCachedir(),executorServicesMap, urlClassLoaderMap); try { name = new ObjectName("com.web.server:type=JarDeployer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(jarDeployer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //jarDeployer.start(); executor.execute(jarDeployer);*/ EARDeployer earDeployer = new EARDeployer(registry, serverconfig.getEarservicesdirectory(), serverconfig.getDeploydirectory(), executorServicesMap, urlClassLoaderMap, serverconfig.getCachedir(), warDeployer); try { name = new ObjectName("com.web.server:type=EARDeployer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(earDeployer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //earDeployer.start(); executor.execute(earDeployer); JVMConsole jvmConsole = new JVMConsole(Integer.parseInt(serverconfig.getJvmConsolePort())); try { name = new ObjectName("com.web.server:type=JVMConsole"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(jvmConsole, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } executor.execute(jvmConsole); ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor(); XMLDeploymentScanner xmlDeploymentScanner = new XMLDeploymentScanner(serverconfig.getDeploydirectory(), serverconfig.getServiceslibdirectory()); exec.scheduleAtFixedRate(xmlDeploymentScanner, 0, 1000, TimeUnit.MILLISECONDS); EmbeddedJMS embeddedJMS = null; try { embeddedJMS = new EmbeddedJMS(); embeddedJMS.start(); } catch (Exception ex) { // TODO Auto-generated catch block ex.printStackTrace(); } EJBDeployer ejbDeployer = new EJBDeployer(serverconfig.getServicesdirectory(), registry, Integer.parseInt(serverconfig.getServicesregistryport()), embeddedJMS); try { name = new ObjectName("com.web.server:type=EJBDeployer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(ejbDeployer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //jarDeployer.start(); executor.execute(ejbDeployer); new Thread() { public void run() { try { ServerSocket serverSocket = new ServerSocket(Integer.parseInt(serverconfig.getShutdownport())); while (true) { Socket sock = serverSocket.accept(); InputStream istream = sock.getInputStream(); istream.read(shutdownBt); String shutdownStr = new String(shutdownBt); String[] shutdownToken = shutdownStr.split("\r\n\r\n"); //System.out.println(shutdownStr); if (shutdownToken[0].startsWith("shutdown WebServer")) { synchronized (shutDownObject) { shutDownObject.notifyAll(); } } } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }.start(); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { public void run() { System.out.println("IN shutdown Hook"); synchronized (shutDownObject) { shutDownObject.notifyAll(); } } })); try { synchronized (shutDownObject) { shutDownObject.wait(); } executor.shutdownNow(); serverSocketChannel.close(); serverSocketChannelServices.close(); embeddedJMS.stop(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } System.out.println("IN shutdown Hook1"); /*try{ Thread.sleep(10000); } catch(Exception ex){ }*/ //webserverRequestProcessor.stop(); //webserverRequestProcessor1.stop(); /*warDeployer.stop(); executorService.stop(); //ataServer.stop(); //ataClient.stop(); messageServer.stop(); randomqueuemessagepicker.stop(); roundrobinqueuemessagepicker.stop(); topicpicker.stop();*/ /*try { mbs.invoke(new ObjectName("com.web.server:type=SARDeployer"), "destroyDeployer", null, null); } catch (InstanceNotFoundException | MalformedObjectNameException | ReflectionException | MBeanException e) { // TODO Auto-generated catch block e.printStackTrace(); }*/ //earDeployer.stop(); System.exit(0); }
From source file:org.apache.hadoop.hdfs.server.namenode.TestNameNodeMXBean.java
@Test(timeout = 120000) @SuppressWarnings("unchecked") public void testTopUsers() throws Exception { final Configuration conf = new Configuration(); MiniDFSCluster cluster = null;//from www . jav a 2s. co m try { cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build(); cluster.waitActive(); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName mxbeanNameFsns = new ObjectName("Hadoop:service=NameNode,name=FSNamesystemState"); FileSystem fs = cluster.getFileSystem(); final Path path = new Path("/"); final int NUM_OPS = 10; for (int i = 0; i < NUM_OPS; i++) { fs.listStatus(path); fs.setTimes(path, 0, 1); } String topUsers = (String) (mbs.getAttribute(mxbeanNameFsns, "TopUserOpCounts")); ObjectMapper mapper = new ObjectMapper(); Map<String, Object> map = mapper.readValue(topUsers, Map.class); assertTrue("Could not find map key timestamp", map.containsKey("timestamp")); assertTrue("Could not find map key windows", map.containsKey("windows")); List<Map<String, List<Map<String, Object>>>> windows = (List<Map<String, List<Map<String, Object>>>>) map .get("windows"); assertEquals("Unexpected num windows", 3, windows.size()); for (Map<String, List<Map<String, Object>>> window : windows) { final List<Map<String, Object>> ops = window.get("ops"); assertEquals("Unexpected num ops", 3, ops.size()); for (Map<String, Object> op : ops) { final long count = Long.parseLong(op.get("totalCount").toString()); final String opType = op.get("opType").toString(); final int expected; if (opType.equals(TopConf.ALL_CMDS)) { expected = 2 * NUM_OPS; } else { expected = NUM_OPS; } assertEquals("Unexpected total count", expected, count); } } } finally { if (cluster != null) { cluster.shutdown(); } } }
From source file:com.googlecode.jmxtrans.model.Server.java
@Override @JsonIgnore//from w w w . j av a2s.c o m public MBeanServer getLocalMBeanServer() { // Getting the platform MBean server is cheap (expect for th first call) no need to cache it. return ManagementFactory.getPlatformMBeanServer(); }
From source file:org.lilyproject.hadooptestfw.HBaseProxy.java
public void stop() throws Exception { if (mode == Mode.EMBED) { // Since HBase mini cluster shutdown has a tendency of sometimes failing (hanging waiting on master // to end), add a protection for this so that we do not run indefinitely. Especially important not to // annoy the other projects on our Hudson server. Thread stopHBaseThread = new Thread() { @Override//from w ww. java 2 s . c om public void run() { try { hbaseTestUtil.shutdownMiniCluster(); hbaseTestUtil = null; } catch (Exception e) { System.out.println("Error shutting down mini cluster."); e.printStackTrace(); } } }; stopHBaseThread.start(); stopHBaseThread.join(60000); if (stopHBaseThread.isAlive()) { System.err.println("Unable to stop embedded mini cluster within predetermined timeout."); System.err.println("Dumping stack for future investigation."); ReflectionUtils.printThreadInfo(new PrintWriter(System.out), "Thread dump"); System.out.println( "Will now try to interrupt the mini-cluster-stop-thread and give it some more time to end."); stopHBaseThread.interrupt(); stopHBaseThread.join(20000); throw new Exception("Failed to stop the mini cluster within the predetermined timeout."); } } // Close connections with HBase and HBase's ZooKeeper handles //HConnectionManager.deleteConnectionInfo(CONF, true); HConnectionManager.deleteAllConnections(true); // Close all HDFS connections FileSystem.closeAll(); conf = null; if (clearData && testHome != null) { TestHomeUtil.cleanupTestHome(testHome); } ManagementFactory.getPlatformMBeanServer() .unregisterMBean(new ObjectName("LilyHBaseProxy:name=ReplicationPeer")); }
From source file:org.codice.ddf.ui.admin.api.impl.SystemPropertiesAdmin.java
private void configureMBean() { mbeanServer = ManagementFactory.getPlatformMBeanServer(); try {/* w w w.j a v a2s .c o m*/ objectName = new ObjectName(SystemPropertiesAdminMBean.OBJECT_NAME); } catch (MalformedObjectNameException e) { LOGGER.debug("Exception while creating object name: " + SystemPropertiesAdminMBean.OBJECT_NAME, e); } try { try { mbeanServer.registerMBean(new StandardMBean(this, SystemPropertiesAdminMBean.class), objectName); } catch (InstanceAlreadyExistsException e) { mbeanServer.unregisterMBean(objectName); mbeanServer.registerMBean(new StandardMBean(this, SystemPropertiesAdminMBean.class), objectName); } } catch (Exception e) { LOGGER.info("Could not register mbean.", e); } }
From source file:com.obergner.hzserver.ServerInfo.java
@PreDestroy public void unregister() throws MBeanRegistrationException, InstanceNotFoundException { ManagementFactory.getPlatformMBeanServer().unregisterMBean(this.objectName); }
From source file:com.enioka.jqm.tools.JqmEngine.java
synchronized void checkEngineEnd() { jqmlogger.trace("Checking if engine should end with the latest poller"); for (QueuePoller poller : pollers.values()) { if (poller.isRunning()) { jqmlogger.trace("At least the poller on queue " + poller.getQueue().getName() + " is still running and prevents shutdown"); return; }//w w w .ja v a 2 s . co m } if (hasEnded) { return; } jqmlogger.trace("The engine should end with the latest poller"); hasEnded = true; // If here, all pollers are down. Stop Jetty too this.server.stop(); // Also stop the internal poller this.intPoller.stop(); // Reset the stop counter - we may want to restart one day EntityManager em = null; try { em = Helpers.getNewEm(); em.getTransaction().begin(); this.node = em.find(Node.class, this.node.getId(), LockModeType.PESSIMISTIC_WRITE); this.node.setStop(false); this.node.setLastSeenAlive(null); em.getTransaction().commit(); } catch (Exception e) { // Shutdown exception is ignored (happens during tests) } finally { Helpers.closeQuietly(em); } // JMX if (loadJmxBeans) { try { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); mbs.unregisterMBean(name); jqmlogger.trace("unregistered bean " + name); } catch (Exception e) { jqmlogger.error("Could not unregister engine JMX bean", e); } } // Note: if present, the JMX listener is not stopped as it is JVM-global, like the JNDI context // Done this.ended.release(); jqmlogger.info("JQM engine has stopped"); }