List of usage examples for java.lang.management ManagementFactory getPlatformMBeanServer
public static synchronized MBeanServer getPlatformMBeanServer()
From source file:org.opencastproject.userdirectory.ldap.LdapUserProviderFactory.java
/** * {@inheritDoc}/*from ww w . j a v a 2 s . com*/ * * @see org.osgi.service.cm.ManagedServiceFactory#deleted(java.lang.String) */ @Override public void deleted(String pid) { ServiceRegistration registration = providerRegistrations.remove(pid); if (registration != null) { registration.unregister(); try { ManagementFactory.getPlatformMBeanServer() .unregisterMBean(LdapUserProviderFactory.getObjectName(pid)); } catch (Exception e) { logger.warn("Unable to unregister mbean for pid='{}': {}", pid, e.getMessage()); } } }
From source file:com.stratio.cassandra.lucene.IndexService.java
void init() { // Initialize index List<SortField> keySortFields = keySortFields(); Sort keySort = new Sort(keySortFields.toArray(new SortField[keySortFields.size()])); try {//from w ww.jav a 2 s . c o m lucene.init(keySort, fieldsToLoad()); } catch (Exception e) { logger.error(String.format("Initialization of Lucene FS directory for index '%s' has failed, " + "this could be caused by on-disk data corruption, " + "or by an upgrade to an incompatible version, " + "try to drop the failing index and create it again:", name), e); } // Register JMX MBean try { mbean = new ObjectName(mbeanName); ManagementFactory.getPlatformMBeanServer().registerMBean(this, this.mbean); } catch (JMException e) { logger.error("Error while registering Lucene index JMX MBean", e); } }
From source file:org.opencastproject.kernel.security.TrustedHttpClientImpl.java
public void activate(ComponentContext cc) { logger.debug("activate"); user = cc.getBundleContext().getProperty(DIGEST_AUTH_USER_KEY); pass = cc.getBundleContext().getProperty(DIGEST_AUTH_PASS_KEY); if (user == null || pass == null) throw new IllegalStateException("trusted communication is not properly configured"); getRetryNumber(cc);/*from w w w . j a va 2 s.c o m*/ getRetryBaseTime(cc); getRetryMaximumVariableTime(cc); // register with jmx try { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName name; name = new ObjectName("org.opencastproject.security.api.TrustedHttpClient:type=HttpConnections"); Object mbean = this; mbs.registerMBean(mbean, name); } catch (Exception e) { logger.warn("Unable to register {} as an mbean: {}", this, e); } }
From source file:com.tesora.dve.server.bootstrap.BootstrapHost.java
@Override protected void unregisterMBeans() { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); try {/*from w w w. j a v a2 s. co m*/ server.unregisterMBean(new ObjectName(MBEAN_BOOTSTRAP_HOST)); } catch (Exception e) { logger.error("Unable to unregister " + MBEAN_BOOTSTRAP_HOST + " mBean", e); } try { server.unregisterMBean(new ObjectName(MBEAN_LOG4J_HIERARCHY)); } catch (Exception e) { logger.error("Unable to unregister " + MBEAN_LOG4J_HIERARCHY + " mBean", e); } super.unregisterMBeans(); }
From source file:org.jahia.tools.jvm.ThreadMonitor.java
/** * Constructs a ThreadMonitor object to get thread information in the local JVM. */ private ThreadMonitor() { this(ManagementFactory.getPlatformMBeanServer()); }
From source file:com.thoughtworks.go.server.Jetty9Server.java
private MBeanContainer mbeans() { MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer(); return new MBeanContainer(platformMBeanServer); }
From source file:au.com.redboxresearchdata.fascinator.plugins.JsonHarvestQueueConsumer.java
public void run() { try {//from w ww . ja v a2 s . co m // Get a connection to the broker String brokerUrl = globalConfig.getString(ActiveMQConnectionFactory.DEFAULT_BROKER_BIND_URL, "messaging", "url"); ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerUrl); connection = connectionFactory.createConnection(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); consumer = session.createConsumer(session.createQueue(QUEUE_ID)); consumer.setMessageListener(this); producer = session.createProducer(session.createTopic(EVENT_TOPIC_ID)); producer.setDeliveryMode(DeliveryMode.PERSISTENT); connection.start(); toolChainEntry = globalConfig.getString(DEFAULT_TOOL_CHAIN_QUEUE, "messaging", "toolChainQueue"); failedJsonMap = new HashMap<String, HarvestItem>(); failedJsonList = new ArrayList<String>(); harvestRequests = new HashMap<String, HarvestRequest>(); // registering managed bean... MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName mxbeanName = new ObjectName( "au.com.redboxresearchdata.fascinator.plugins:type=JsonHarvestQueue"); mbs.registerMBean(this, mxbeanName); log.info("'{}' is running...", name); } catch (JMSException ex) { log.error("Error starting message thread!", ex); } catch (MalformedObjectNameException e) { log.error("Error configuring MBean, invalid name", e); } catch (InstanceAlreadyExistsException e) { log.error("Error configuring MBean, instance exists.", e); } catch (MBeanRegistrationException e) { log.error("Error registering MBean. ", e); } catch (NotCompliantMBeanException e) { log.error("Error configuring Mbean, non-compliant!", e); } }
From source file:org.helios.netty.jmx.MetricCollector.java
/** * Creates a new MetricCollector/* w w w. j ava 2 s. c o m*/ * @param period The period of collection */ private MetricCollector(long period) { super(); haveNioMXBean = ManagementFactory.getPlatformMBeanServer().isRegistered(directNio); this.period = period; try { ManagementFactory.getPlatformMBeanServer().registerMBean(this, OBJECT_NAME); scheduler = (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(2, new ThreadFactory() { public Thread newThread(Runnable r) { Thread t = new Thread(r, OBJECT_NAME.getKeyProperty("service") + "Thread#" + serial.incrementAndGet()); t.setDaemon(true); return t; } }); initMetricNames(); scheduler.schedule(this, period, TimeUnit.MILLISECONDS); log.info("Started MetricCollector with a period of " + period + " ms."); } catch (Exception e) { throw new RuntimeException("Failed to create MetricCollector", e); } }
From source file:org.rhq.plugins.agent.AgentDiscoveryComponent.java
/** * Method that gets the MBeanServer that houses the agent's management MBean interface. * * <p>This is package-scoped so other components can use this to connect to the agent's management MBeanServer.</p> * * @return agent's management MBean Server * * @throws RuntimeException if failed to get the agent management MBeanServer - this should really never occur since * that MBeanServer should always been available whenever the agent is started */// w w w .ja v a2 s. c o m static MBeanServer getAgentManagementMBeanServer() { try { return ManagementFactory.getPlatformMBeanServer(); } catch (Exception e) { throw new RuntimeException("Cannot get the agent's management MBeanServer", e); } }
From source file:org.opendaylight.controller.netconf.impl.ConcurrentClientsTest.java
@Before public void setUp() throws Exception { hashedWheelTimer = new HashedWheelTimer(); nettyGroup = new NioEventLoopGroup(nettyThreads); netconfClientDispatcher = new NetconfClientDispatcherImpl(nettyGroup, nettyGroup, hashedWheelTimer); NetconfOperationServiceFactoryListenerImpl factoriesListener = new NetconfOperationServiceFactoryListenerImpl(); testingNetconfOperation = new TestingNetconfOperation(); factoriesListener//from w w w. java 2 s.c o m .onAddNetconfOperationServiceFactory(new TestingOperationServiceFactory(testingNetconfOperation)); SessionIdProvider idProvider = new SessionIdProvider(); NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory( hashedWheelTimer, factoriesListener, idProvider, 5000, commitNot, createMockedMonitoringService(), serverCaps); commitNot = new DefaultCommitNotificationProducer(ManagementFactory.getPlatformMBeanServer()); NetconfServerDispatcher.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcher.ServerChannelInitializer( serverNegotiatorFactory); final NetconfServerDispatcher dispatch = new NetconfServerDispatcher(serverChannelInitializer, nettyGroup, nettyGroup); ChannelFuture s = dispatch.createServer(netconfAddress); s.await(); }