Search in sources :

Example 36 with ObjectName

use of javax.management.ObjectName in project camel by apache.

the class TestSupportJmxCleanup method removeMBeans.

public static void removeMBeans(String domain) throws Exception {
    MBeanServer mbsc = ManagementFactory.getPlatformMBeanServer();
    Set<ObjectName> s = mbsc.queryNames(new ObjectName(getDomainName(domain) + ":*"), null);
    for (ObjectName on : s) {
        mbsc.unregisterMBean(on);
    }
}
Also used : MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 37 with ObjectName

use of javax.management.ObjectName in project camel by apache.

the class LanguageLoadScriptFromFileCachedTest method testClearCachedScriptViaJmx.

public void testClearCachedScriptViaJmx() throws Exception {
    getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", "Hello World", "Bye World");
    template.sendBody("direct:start", "World");
    // even if we update the file the content is cached
    template.sendBodyAndHeader("file:target/script", "Bye ${body}", Exchange.FILE_NAME, "myscript.txt");
    template.sendBody("direct:start", "World");
    // now clear the cache via the mbean server
    MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
    Set<ObjectName> objNameSet = mbeanServer.queryNames(new ObjectName("org.apache.camel:type=endpoints,name=\"language://simple:*contentCache=true*\",*"), null);
    ObjectName managedObjName = new ArrayList<ObjectName>(objNameSet).get(0);
    mbeanServer.invoke(managedObjName, "clearContentCache", null, null);
    template.sendBody("direct:start", "World");
    assertMockEndpointsSatisfied();
}
Also used : MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 38 with ObjectName

use of javax.management.ObjectName in project camel by apache.

the class DualManagedThreadPoolWithIdTest method testManagedThreadPool.

public void testManagedThreadPool() throws Exception {
    // JMX tests dont work well on AIX CI servers (hangs them)
    if (isPlatform("aix")) {
        return;
    }
    MBeanServer mbeanServer = getMBeanServer();
    ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=threadpools,name=\"myThreads(threads)\"");
    Integer corePoolSize = (Integer) mbeanServer.getAttribute(on, "CorePoolSize");
    assertEquals(15, corePoolSize.intValue());
    Integer maxPoolSize = (Integer) mbeanServer.getAttribute(on, "MaximumPoolSize");
    assertEquals(30, maxPoolSize.intValue());
    String id = (String) mbeanServer.getAttribute(on, "Id");
    assertEquals("myThreads", id);
    String source = (String) mbeanServer.getAttribute(on, "SourceId");
    assertEquals("threads", source);
    String route = (String) mbeanServer.getAttribute(on, "RouteId");
    assertEquals("route1", route);
    on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=threadpools,name=\"myOtherThreads(threads)\"");
    corePoolSize = (Integer) mbeanServer.getAttribute(on, "CorePoolSize");
    assertEquals(1, corePoolSize.intValue());
    maxPoolSize = (Integer) mbeanServer.getAttribute(on, "MaximumPoolSize");
    assertEquals(2, maxPoolSize.intValue());
    id = (String) mbeanServer.getAttribute(on, "Id");
    assertEquals("myOtherThreads", id);
    source = (String) mbeanServer.getAttribute(on, "SourceId");
    assertEquals("threads", source);
    route = (String) mbeanServer.getAttribute(on, "RouteId");
    assertEquals("route2", route);
}
Also used : MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 39 with ObjectName

use of javax.management.ObjectName in project camel by apache.

the class EndpointCompletionTest method testEndpointConfigurationJson.

public void testEndpointConfigurationJson() throws Exception {
    // JMX tests dont work well on AIX CI servers (hangs them)
    if (isPlatform("aix")) {
        return;
    }
    MBeanServer mbeanServer = getMBeanServer();
    ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=context,name=\"camel-1\"");
    assertNotNull(on);
    mbeanServer.isRegistered(on);
    assertParameterJsonSchema(mbeanServer, on, "bean");
    assertParameterJsonSchema(mbeanServer, on, "timer");
}
Also used : MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 40 with ObjectName

use of javax.management.ObjectName in project camel by apache.

the class EndpointCompletionTest method testEndpointCompletion.

public void testEndpointCompletion() throws Exception {
    // JMX tests dont work well on AIX CI servers (hangs them)
    if (isPlatform("aix")) {
        return;
    }
    MBeanServer mbeanServer = getMBeanServer();
    ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=context,name=\"camel-1\"");
    assertNotNull(on);
    mbeanServer.isRegistered(on);
    String componentName = "file";
    Map<String, Object> properties = new HashMap<String, Object>();
    assertCompletion(mbeanServer, on, componentName, properties, "");
    assertCompletion(mbeanServer, on, componentName, properties, "po");
    assertCompletion(mbeanServer, on, componentName, properties, "/");
    assertCompletion(mbeanServer, on, componentName, properties, "/usr/local");
    assertCompletion(mbeanServer, on, componentName, properties, "/usr/local/");
    assertCompletion(mbeanServer, on, componentName, properties, "/usr/local/b");
}
Also used : HashMap(java.util.HashMap) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Aggregations

ObjectName (javax.management.ObjectName)1515 MBeanServer (javax.management.MBeanServer)691 Test (org.junit.Test)258 MalformedObjectNameException (javax.management.MalformedObjectNameException)168 IOException (java.io.IOException)101 HashMap (java.util.HashMap)99 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)97 Attribute (javax.management.Attribute)94 InstanceNotFoundException (javax.management.InstanceNotFoundException)94 ArrayList (java.util.ArrayList)91 MBeanServerConnection (javax.management.MBeanServerConnection)72 Map (java.util.Map)66 SystemManagementService (org.apache.geode.management.internal.SystemManagementService)66 MBeanInfo (javax.management.MBeanInfo)64 TabularData (javax.management.openmbean.TabularData)55 JMXServiceURL (javax.management.remote.JMXServiceURL)55 MBeanRegistrationException (javax.management.MBeanRegistrationException)53 JMXConnector (javax.management.remote.JMXConnector)53 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)48 Notification (javax.management.Notification)47