List of usage examples for javax.management ObjectName ObjectName
public ObjectName(String name) throws MalformedObjectNameException
From source file:com.twitter.hraven.hadoopJobMonitor.HadoopJobMonitorService.java
public void init() { YarnConfiguration yConf = new YarnConfiguration(); DefaultMetricsSystem.initialize("HadoopJobMonitor"); String logDir = System.getProperty("hadoopJobMonitor.log.dir"); if (logDir == null) logDir = "/tmp"; MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); try {/*from w w w. j a va 2 s . c o m*/ ObjectName name = new ObjectName( "com.twitter.hraven.hadoopJobMonitor.jmx:type=" + WhiteList.class.getSimpleName()); WhiteList.init(logDir); WhiteList mbean = WhiteList.getInstance(); mbs.registerMBean(mbean, name); LOG.error("Current whitelist is: \n" + mbean.getExpirations()); } catch (Exception e) { LOG.fatal("Error in retriving white list from dir " + logDir, e); } metrics = HadoopJobMonitorMetrics.initSingleton(conf); rmDelegate = new ResourceMgrDelegate(yConf); clientCache = new ClientCache(conf, rmDelegate); AppConfCache.init(conf); ProgressCache.init(conf); Mail.init(conf); Notifier.init(conf); clusterCheckerExecutor = Executors .newSingleThreadScheduledExecutor(new ClusterStatusChecker.SimpleThreadFactory()); int concurrentAppCheckers = conf.getInt(HadoopJobMonitorConfiguration.NEW_APP_CHECKER_CONCURRENCY, HadoopJobMonitorConfiguration.DEFAULT_NEW_APP_CHECKER_CONCURRENCY); appCheckerExecutor = new BlockingExecutor(concurrentAppCheckers, new AppStatusChecker.SimpleThreadFactory()); }
From source file:com.hellblazer.glassHouse.discovery.HubConfiguration.java
/** * Construct a hub from the receiver configuration, using the supplied * MBeanServer/*from ww w. j a v a2 s. com*/ * * @param mbs * @return the configured instance of the Hub * @throws Exception */ public Hub construct(MBeanServer mbs) throws Exception { ServiceScope scope = discovery.construct(); scope.start(); CascadingService cascadingService = new CascadingService(mbs); mbs.registerMBean(cascadingService, new ObjectName(cascadingServiceName)); AggregateServiceImpl aggregateService = new AggregateServiceImpl(mbs); Hub hub = new Hub(cascadingService, sourceMap, scope, aggregateService); for (Map.Entry<String, String> entry : services.entrySet()) { hub.listenFor(String.format("(%s=%s)", SERVICE_TYPE, entry.getKey()), entry.getValue()); } return hub; }
From source file:org.fishwife.jrugged.spring.TestCircuitBreakerBeanFactory.java
@Test public void testCreatePerformanceMonitorObjectName() throws MalformedObjectNameException, NullPointerException { mockMBeanExporter = createMock(MBeanExporter.class); ObjectName objectName = new ObjectName( "org.fishwife.jrugged.spring:type=" + "CircuitBreakerBean,name=testCreate"); mockMBeanExporter.registerManagedResource(EasyMock.<Object>anyObject(), EasyMock.eq(objectName)); replay(mockMBeanExporter);// ww w . j a va2 s. c o m factory.setMBeanExportOperations(mockMBeanExporter); factory.createCircuitBreaker("testCreate", config); EasyMock.verify(mockMBeanExporter); }
From source file:io.fabric8.cxf.endpoint.jaxws.JsonSchemaJMXTest.java
private ObjectName getEndpointObjectName() throws MalformedObjectNameException, NullPointerException { StringBuilder buffer = new StringBuilder(); String serviceName = "{http://apache.org/hello_world/services}SOAPService"; String portName = "SoapPort"; buffer.append(ManagedApi.DOMAIN_NAME + ":type=Bus.Service.Endpoint,"); buffer.append(ManagementConstants.SERVICE_NAME_PROP + "=\"" + serviceName + "\","); buffer.append(ManagementConstants.PORT_NAME_PROP + "=\"" + portName + "\",*"); return new ObjectName(buffer.toString()); }
From source file:eu.itesla_project.online.tools.RunTDSimulationsMpiTool.java
@Override public void run(CommandLine line) throws Exception { OnlineWorkflowStartParameters startconfig = OnlineWorkflowStartParameters.loadDefault(); String host = line.getOptionValue(OnlineWorkflowCommand.HOST); String port = line.getOptionValue(OnlineWorkflowCommand.PORT); String threads = line.getOptionValue(OnlineWorkflowCommand.THREADS); if (host != null) startconfig.setJmxHost(host);//from w w w . ja va 2s . c o m if (port != null) startconfig.setJmxPort(Integer.valueOf(port)); if (threads != null) startconfig.setThreads(Integer.valueOf(threads)); String urlString = "service:jmx:rmi:///jndi/rmi://" + startconfig.getJmxHost() + ":" + startconfig.getJmxPort() + "/jmxrmi"; JMXServiceURL serviceURL = new JMXServiceURL(urlString); Map<String, String> jmxEnv = new HashMap<>(); JMXConnector connector = JMXConnectorFactory.connect(serviceURL, jmxEnv); MBeanServerConnection mbsc = connector.getMBeanServerConnection(); ObjectName name = new ObjectName(LocalOnlineApplicationMBean.BEAN_NAME); LocalOnlineApplicationMBean application = MBeanServerInvocationHandler.newProxyInstance(mbsc, name, LocalOnlineApplicationMBean.class, false); boolean emptyContingency = line.hasOption("empty-contingency"); Path caseFile = Paths.get(line.getOptionValue("case-file")); application.runTDSimulations(startconfig, caseFile.toString(), line.getOptionValue("contingencies"), Boolean.toString(emptyContingency), line.getOptionValue("output-folder")); }
From source file:net.sf.ehcache.management.ManagementServiceTest.java
/** * Integration test for the registration service *///w w w . j a v a 2s . co m public void testRegistrationServiceFourTrueUsing14MBeanServer() throws Exception { mBeanServer = create14MBeanServer(); ManagementService.registerMBeans(manager, mBeanServer, true, true, true, true); assertEquals(OBJECTS_IN_TEST_EHCACHE, mBeanServer.queryNames(new ObjectName("net.sf.ehcache:*"), null).size()); }
From source file:com.funambol.pushlistener.example.DummyJMXPlugin.java
@Override public void startPlugin() { if (logger.isInfoEnabled()) { logger.info("Starting JMXDummyPlugin"); logger.info("Registering MBean " + MBEAN_NAME); }/*from w w w .j ava 2 s. co m*/ MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); try { // Construct the ObjectName for the MBean we will register ObjectName name = new ObjectName(MBEAN_NAME); mbs.registerMBean(this, name); } catch (Exception ex) { logger.error("Error registering mbean '" + MBEAN_NAME + "'", ex); } }
From source file:com.espertech.esper.example.servershell.ServerShellMain.java
public ServerShellMain() throws Exception { log.info("Loading properties"); Properties properties = new Properties(); InputStream propertiesIS = ServerShellMain.class.getClassLoader() .getResourceAsStream(ServerShellConstants.CONFIG_FILENAME); if (propertiesIS == null) { throw new RuntimeException( "Properties file '" + ServerShellConstants.CONFIG_FILENAME + "' not found in classpath"); }//w w w. j a v a2 s.c o m properties.load(propertiesIS); // Start RMI registry log.info("Starting RMI registry"); int port = Integer.parseInt(properties.getProperty(ServerShellConstants.MGMT_RMI_PORT)); LocateRegistry.createRegistry(port); // Obtain MBean servera log.info("Obtaining JMX server and connector"); MBeanServer mbs = MBeanServerFactory.createMBeanServer(); String jmxServiceURL = properties.getProperty(ServerShellConstants.MGMT_SERVICE_URL); JMXServiceURL jmxURL = new JMXServiceURL(jmxServiceURL); JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(jmxURL, null, mbs); cs.start(); // Initialize engine log.info("Getting Esper engine instance"); Configuration configuration = new Configuration(); configuration.addEventType("SampleEvent", SampleEvent.class.getName()); EPServiceProvider engine = EPServiceProviderManager.getDefaultProvider(configuration); // Initialize engine log.info("Creating sample statement"); SampleStatement.createStatement(engine.getEPAdministrator()); // Register MBean log.info("Registering MBean"); ObjectName name = new ObjectName(ServerShellConstants.MGMT_MBEAN_NAME); EPServiceProviderJMX mbean = new EPServiceProviderJMX(engine); mbs.registerMBean(mbean, name); // Connect to JMS log.info("Connecting to JMS server"); String factory = properties.getProperty(ServerShellConstants.JMS_CONTEXT_FACTORY); String jmsurl = properties.getProperty(ServerShellConstants.JMS_PROVIDER_URL); String connFactoryName = properties.getProperty(ServerShellConstants.JMS_CONNECTION_FACTORY_NAME); String user = properties.getProperty(ServerShellConstants.JMS_USERNAME); String password = properties.getProperty(ServerShellConstants.JMS_PASSWORD); String destination = properties.getProperty(ServerShellConstants.JMS_INCOMING_DESTINATION); boolean isTopic = Boolean.parseBoolean(properties.getProperty(ServerShellConstants.JMS_IS_TOPIC)); JMSContext jmsCtx = JMSContextFactory.createContext(factory, jmsurl, connFactoryName, user, password, destination, isTopic); int numListeners = Integer.parseInt(properties.getProperty(ServerShellConstants.JMS_NUM_LISTENERS)); log.info("Creating " + numListeners + " listeners to destination '" + destination + "'"); SampleJMSMessageListener listeners[] = new SampleJMSMessageListener[numListeners]; for (int i = 0; i < numListeners; i++) { listeners[i] = new SampleJMSMessageListener(engine.getEPRuntime()); MessageConsumer consumer = jmsCtx.getSession().createConsumer(jmsCtx.getDestination()); consumer.setMessageListener(listeners[i]); } // Start processing log.info("Starting JMS connection"); jmsCtx.getConnection().start(); // Register shutdown hook Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { isShutdown = true; } }); // Report statistics long startTime = System.currentTimeMillis(); long currTime; double deltaSeconds; int lastTotalEvents = 0; AccumulatingStat avgLast5 = new AccumulatingStat(5); AccumulatingStat avgLast10 = new AccumulatingStat(10); AccumulatingStat avgLast20 = new AccumulatingStat(20); do { // sleep Thread.sleep(1000); currTime = System.currentTimeMillis(); deltaSeconds = (currTime - startTime) / 1000.0; // compute stats int totalEvents = 0; for (int i = 0; i < listeners.length; i++) { totalEvents += listeners[i].getCount(); } double totalLastBatch = totalEvents - lastTotalEvents; avgLast5.add(totalLastBatch); avgLast10.add(totalLastBatch); avgLast20.add(totalLastBatch); log.info("total=" + totalEvents + " last=" + totalLastBatch + " last5Avg=" + avgLast5.getAvg() + " last10Avg=" + avgLast10.getAvg() + " last20Avg=" + avgLast20.getAvg() + " time=" + deltaSeconds); lastTotalEvents = totalEvents; } while (!isShutdown); log.info("Shutting down server"); jmsCtx.destroy(); log.info("Exiting"); System.exit(-1); }
From source file:admin.jmx.StepExecutionServiceLevelMonitor.java
public GaugeMonitor getObject() throws Exception { GaugeMonitor monitor = new GaugeMonitor(); monitor.setNotifyHigh(true);/*w w w . j a v a 2s . c o m*/ monitor.addObservedObject(new ObjectName( String.format("%s:type=JobExecution,name=%s,step=%s", defaultDomain, jobName, stepName))); monitor.setObservedAttribute(observedAttribute); if (observedAttribute.endsWith("Duration")) { monitor.setThresholds(new Double(upperThreshold), new Double(lowerThreshold)); } else { monitor.setThresholds(new Integer(upperThreshold), new Integer(lowerThreshold)); } if (autoStart) { monitor.start(); } return monitor; }
From source file:com.buschmais.maexo.test.spring.SpringTest.java
/** * Test if MBean registration is done.// w w w . j ava 2 s. c om * * @throws MalformedObjectNameException * @throws NullPointerException */ public void test_mbeanRegistrationDone() throws MalformedObjectNameException, NullPointerException { assertNotNull(this.standardMBean.isRegistrationDone()); assertTrue(this.standardMBean.isRegistrationDone().booleanValue()); assertEquals(new ObjectName(OBJECTNAME), this.standardMBean.getObjectName()); }