Search in sources :

Example 66 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project alliance by codice.

the class StreamMonitorHelper method registerMbean.

private void registerMbean() {
    try {
        objectName = new ObjectName(StreamMonitorHelper.class.getName() + ":service=stream");
        mBeanServer = ManagementFactory.getPlatformMBeanServer();
    } catch (MalformedObjectNameException e) {
        LOGGER.info("Unable to create FMV Stream Monitor Helper MBean.", e);
    }
    if (mBeanServer == null) {
        return;
    }
    try {
        try {
            mBeanServer.registerMBean(this, objectName);
            LOGGER.debug("Registered FMV Stream Monitor Helper MBean under object name: {}", objectName);
        } catch (InstanceAlreadyExistsException e) {
            mBeanServer.unregisterMBean(objectName);
            mBeanServer.registerMBean(this, objectName);
            LOGGER.debug("Re-registered FMV Stream Monitor Helper MBean", e);
        }
    } catch (MBeanRegistrationException | InstanceNotFoundException | InstanceAlreadyExistsException | NotCompliantMBeanException e) {
        LOGGER.info("Could not register MBean [{}].", objectName.toString(), e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 67 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project core by weld.

the class ProbeExtension method afterDeploymentValidation.

public void afterDeploymentValidation(@Observes AfterDeploymentValidation event, BeanManager beanManager) {
    BeanManagerImpl manager = BeanManagerProxy.unwrap(beanManager);
    probe.init(manager);
    if (isJMXSupportEnabled(manager)) {
        try {
            MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
            mbs.registerMBean(new ProbeDynamicMBean(jsonDataProvider, JsonDataProvider.class), constructProbeJsonDataMBeanName(manager, probe));
        } catch (MalformedObjectNameException | InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) {
            event.addDeploymentProblem(ProbeLogger.LOG.unableToRegisterMBean(JsonDataProvider.class, manager.getContextId(), e));
        }
    }
    addContainerLifecycleEvent(event, null, beanManager);
    exportDataIfNeeded(manager);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) BeanManagerImpl(org.jboss.weld.manager.BeanManagerImpl) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) MBeanServer(javax.management.MBeanServer)

Example 68 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project narayana by jbosstm.

the class BTAdmin method main.

public static void main(String[] args) throws IOException {
    int exitStatus = -1;
    if (System.getProperty("log4j.configuration") == null && !new File("log4cxx.properties").exists() && !new File("log4j.xml").exists()) {
        BasicConfigurator.configure();
        log.info("BasicConfigurator ran");
    }
    boolean interactive = args.length == 0;
    boolean done = false;
    try {
        CommandHandler commandHandler = new CommandHandler();
        do {
            if (interactive) {
                System.out.print("> ");
                // split on white space
                args = br.readLine().split("\\s+");
            }
            try {
                exitStatus = commandHandler.handleCommand(args);
                if (exitStatus == 0) {
                    log.trace("Command was successful");
                } else {
                    log.trace("Command failed");
                }
                if (args.length > 0 && args[0].equals("quit")) {
                    done = true;
                }
            } catch (Exception e) {
                log.error("Could not invoke command: " + e.getMessage(), e);
            }
        } while (interactive && !done);
    } catch (MalformedObjectNameException e) {
        log.error("MBean name was badly structured: " + e.getMessage(), e);
    } catch (ConfigurationException e) {
        log.error("BlackTie Configuration invalid: " + e.getMessage(), e);
    }
    if (!interactive) {
        // Exit the launcher with the value of the command
        // This must be a halt so that any executed servers are not reaped
        // by the JVM. If spawned servers die when launcher does we will
        // need to investigate using setppid or something to set the
        // spawned process as daemons
        Runtime.getRuntime().halt(exitStatus);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) ConfigurationException(org.jboss.narayana.blacktie.jatmibroker.core.conf.ConfigurationException) File(java.io.File) MalformedObjectNameException(javax.management.MalformedObjectNameException) ConfigurationException(org.jboss.narayana.blacktie.jatmibroker.core.conf.ConfigurationException) IOException(java.io.IOException)

Example 69 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project zalenium by zalando.

the class SauceLabsRemoteProxyTest method setUp.

@Before
public void setUp() {
    try {
        ObjectName objectName = new ObjectName("org.seleniumhq.grid:type=Hub");
        ManagementFactory.getPlatformMBeanServer().getObjectInstance(objectName);
        new JMXHelper().unregister(objectName);
    } catch (MalformedObjectNameException | InstanceNotFoundException e) {
    // Might be that the object does not exist, it is ok. Nothing to do, this is just a cleanup task.
    }
    registry = ZaleniumRegistry.newInstance(new Hub(new GridHubConfiguration()));
    // Creating the configuration and the registration request of the proxy (node)
    RegistrationRequest request = TestUtils.getRegistrationRequestForTesting(30001, SauceLabsRemoteProxy.class.getCanonicalName());
    CommonProxyUtilities commonProxyUtilities = mock(CommonProxyUtilities.class);
    when(commonProxyUtilities.readJSONFromUrl(anyString(), anyString(), anyString())).thenReturn(null);
    SauceLabsRemoteProxy.setCommonProxyUtilities(commonProxyUtilities);
    sauceLabsProxy = SauceLabsRemoteProxy.getNewInstance(request, registry);
    // we need to register a DockerSeleniumStarter proxy to have a proper functioning SauceLabsProxy
    request = TestUtils.getRegistrationRequestForTesting(30000, DockerSeleniumStarterRemoteProxy.class.getCanonicalName());
    DockerSeleniumStarterRemoteProxy dsStarterProxy = DockerSeleniumStarterRemoteProxy.getNewInstance(request, registry);
    // We add both nodes to the registry
    registry.add(sauceLabsProxy);
    registry.add(dsStarterProxy);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) CommonProxyUtilities(de.zalando.ep.zalenium.util.CommonProxyUtilities) Hub(org.openqa.grid.web.Hub) JMXHelper(org.openqa.selenium.remote.server.jmx.JMXHelper) InstanceNotFoundException(javax.management.InstanceNotFoundException) GridHubConfiguration(org.openqa.grid.internal.utils.configuration.GridHubConfiguration) RegistrationRequest(org.openqa.grid.common.RegistrationRequest) ObjectName(javax.management.ObjectName) Before(org.junit.Before)

Example 70 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project zalenium by zalando.

the class TestingBotRemoteProxyTest method setUp.

@SuppressWarnings("ConstantConditions")
@Before
public void setUp() throws IOException {
    try {
        ObjectName objectName = new ObjectName("org.seleniumhq.grid:type=Hub");
        ManagementFactory.getPlatformMBeanServer().getObjectInstance(objectName);
        new JMXHelper().unregister(objectName);
    } catch (MalformedObjectNameException | InstanceNotFoundException e) {
    // Might be that the object does not exist, it is ok. Nothing to do, this is just a cleanup task.
    }
    registry = ZaleniumRegistry.newInstance(new Hub(new GridHubConfiguration()));
    // Creating the configuration and the registration request of the proxy (node)
    RegistrationRequest request = TestUtils.getRegistrationRequestForTesting(30002, TestingBotRemoteProxy.class.getCanonicalName());
    JsonElement informationSample = TestUtils.getTestInformationSample("testingbot_testinformation.json");
    String userInfoUrl = "https://api.testingbot.com/v1/user";
    Environment env = new Environment();
    CommonProxyUtilities commonProxyUtilities = mock(CommonProxyUtilities.class);
    when(commonProxyUtilities.readJSONFromUrl(userInfoUrl, env.getStringEnvVariable("TESTINGBOT_KEY", ""), env.getStringEnvVariable("TESTINGBOT_SECRET", ""))).thenReturn(null);
    String mockTestInfoUrl = "https://api.testingbot.com/v1/tests/2cf5d115-ca6f-4bc4-bc06-a4fca00836ce";
    when(commonProxyUtilities.readJSONFromUrl(mockTestInfoUrl, env.getStringEnvVariable("TESTINGBOT_KEY", ""), env.getStringEnvVariable("TESTINGBOT_SECRET", ""))).thenReturn(informationSample);
    TestingBotRemoteProxy.setCommonProxyUtilities(commonProxyUtilities);
    testingBotProxy = TestingBotRemoteProxy.getNewInstance(request, registry);
    // we need to register a DockerSeleniumStarter proxy to have a proper functioning testingBotProxy
    request = TestUtils.getRegistrationRequestForTesting(30000, DockerSeleniumStarterRemoteProxy.class.getCanonicalName());
    DockerSeleniumStarterRemoteProxy dsStarterProxy = DockerSeleniumStarterRemoteProxy.getNewInstance(request, registry);
    // Temporal folder for dashboard files
    TestUtils.ensureRequiredInputFilesExist(temporaryFolder);
    // We add both nodes to the registry
    registry.add(testingBotProxy);
    registry.add(dsStarterProxy);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) CommonProxyUtilities(de.zalando.ep.zalenium.util.CommonProxyUtilities) JMXHelper(org.openqa.selenium.remote.server.jmx.JMXHelper) InstanceNotFoundException(javax.management.InstanceNotFoundException) RegistrationRequest(org.openqa.grid.common.RegistrationRequest) ObjectName(javax.management.ObjectName) Hub(org.openqa.grid.web.Hub) JsonElement(com.google.gson.JsonElement) Environment(de.zalando.ep.zalenium.util.Environment) GridHubConfiguration(org.openqa.grid.internal.utils.configuration.GridHubConfiguration) Before(org.junit.Before)

Aggregations

MalformedObjectNameException (javax.management.MalformedObjectNameException)309 ObjectName (javax.management.ObjectName)285 InstanceNotFoundException (javax.management.InstanceNotFoundException)88 MBeanServer (javax.management.MBeanServer)80 MBeanRegistrationException (javax.management.MBeanRegistrationException)75 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)63 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)59 IOException (java.io.IOException)53 ArrayList (java.util.ArrayList)45 ReflectionException (javax.management.ReflectionException)30 MBeanException (javax.management.MBeanException)23 Test (org.testng.annotations.Test)23 CompositeData (javax.management.openmbean.CompositeData)18 Notification (javax.management.Notification)15 MBeanInfo (javax.management.MBeanInfo)14 AttributeNotFoundException (javax.management.AttributeNotFoundException)13 HashMap (java.util.HashMap)11 Map (java.util.Map)11 IntrospectionException (javax.management.IntrospectionException)11 MalformedURLException (java.net.MalformedURLException)10