Refine search
public static void setUp() throws IOException { MBeanServer mbs = MBeanRegistry.getInstance().getPlatformMBeanServer(); JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://127.0.0.1"); cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs); cs.start(); JMXServiceURL addr = cs.getAddress(); cc = JMXConnectorFactory.connect(addr); }
/** * Starts a JMX connector that allows (un)registering MBeans with the MBean server and RMI invocations. * * @param port jmx port to use * @throws IOException */ private void startJmxService(int port) throws IOException { String serviceUrl = "service:jmx:rmi://localhost:" + port + "/jndi/rmi://localhost:" + port + "/jmxrmi"; JMXServiceURL url; try { url = new JMXServiceURL(serviceUrl); } catch (MalformedURLException e) { throw new IllegalArgumentException("Malformed service url created " + serviceUrl, e); } connector = JMXConnectorServerFactory.newJMXConnectorServer(url, null, ManagementFactory.getPlatformMBeanServer()); connector.start(); }
if (registry == null) { LOG.debug("Creating RMIRegistry on port {}", connectorPort); registry = LocateRegistry.createRegistry(connectorPort); JMXServiceURL url = new JMXServiceURL(serviceURL); connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, environment, mbeanServer);
String host = containerConfiguration.getHost(); if (cs != null && cs.isActive() && cs.getAddress().getPort() == port) { return; cs.stop(); Registry registry = LocateRegistry.getRegistry(port); try { registry.list(); } catch (Exception e) { LocateRegistry.createRegistry(port); JMXServiceURL jmxUrl = new JMXServiceURL(sJmxURL); .newJMXConnectorServer(jmxUrl, null, adminAttributes .getRawMBeanServer()); cs = connectorServer; + cs.getAddress().getURLPath()); } catch (Exception e) { log.error(
cs = JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs); cs.setMBeanServerForwarder(new MBeanServerWrapper(securityService)); cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs); LocateRegistry.createRegistry(jmxPort); System.out.println("RMI registry ready."); } catch (Exception e) { cs.start(); await() .until(() -> cs.isActive());
Registry registry = LocateRegistry.getRegistry(rmiPort); try { registry.list(); } catch (Exception e) { LocateRegistry.createRegistry(rmiPort); JMXServiceURL jmxUrl = new JMXServiceURL(getJmxServiceURL(rmiHost, rmiPort)); this.cs = JMXConnectorServerFactory.newJMXConnectorServer(jmxUrl, env, this.adminAttributes.getRawMBeanServer()); this.cs.start(); } catch (IOException e) { this.log.error("Failed to start JMX RMI connector service", e); + this.cs.getAddress().getURLPath());
rmiRegistry = LocateRegistry.createRegistry(rmiRegistryPort); throw new RuntimeException("Started by another thread?"); JMX_CS = JMXConnectorServerFactory.newJMXConnectorServer(serviceUrl, jmxEnv, mbs); JMX_CS.start();
JMXServiceURL url = new JMXServiceURL("service:jmx:jmxmp://localhost:" + port); JMXConnectorServer connector = JMXConnectorServerFactory.newJMXConnectorServer(url, null, getServer()); factory.setServiceUrl(url.toString()); factory.setProxyInterface(IJmxTestBean.class); factory.setObjectName(OBJECT_NAME); connector.start(); connector.stop(); connector = JMXConnectorServerFactory.newJMXConnectorServer(url, null, getServer()); connector.start();
sRMIRegistry = LocateRegistry.createRegistry(port); env.put(JMXConnectorServer.AUTHENTICATOR, new RealmJMXAuthenticator(serviceRealmContext)); JMXServiceURL serviceURL = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + uri.getHost() + ":" + port + "/jmxrmi"); connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(serviceURL, env, mbeanServer); connectorServer.setMBeanServerForwarder(MBSFInvocationHandler.newProxyInstance(requiredRoles)); filter.enableType(JMXConnectionNotification.OPENED); filter.enableType(JMXConnectionNotification.CLOSED); connectorServer.addNotificationListener(this, filter, null); connectorServer.start(); startupLogger.info(format("JMX Management service started with URI %s with service URI %s", uri, serviceURL.toString()));
JMXServiceURL url = new JMXServiceURL(this.serviceUrl); this.connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, this.environment, this.server); this.connectorServer.setMBeanServerForwarder(this.forwarder); this.connectorServer.start();
private JMXConnectorServer doLegacy(String url) throws IOException { LOG.info("Starting JMX Connector Server '{}'", url); Map<String, String> jmxEnv = new HashMap<>(); jmxEnv.put("jmx.remote.server.address.wildcard", Boolean.toString(jmxAddress == null)); JMXServiceURL jmxUrl = new JMXServiceURL(url); return JMXConnectorServerFactory.newJMXConnectorServer(jmxUrl, jmxEnv, mbs); }
registry = LocateRegistry.createRegistry(port, clientSocketFactory, serverSocketFactory); } catch (RemoteException ex) { registry = LocateRegistry.getRegistry(null, port, clientSocketFactory); connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(serviceUrl, serverEnv, mbeanServer); connectorServer.start(); JMXServiceURL connectorServerAddress = connectorServer.getAddress();
@Override public void onSetUp() throws Exception { runTests = false; Assume.group(TestGroup.JMXMP); runTests = true; super.onSetUp(); this.connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(getServiceUrl(), null, getServer()); try { this.connectorServer.start(); } catch (BindException ex) { System.out.println("Skipping remote JMX tests because binding to local port [" + SERVICE_PORT + "] failed: " + ex.getMessage()); runTests = false; } }
private JMXConnectorServer getConnectorServer() throws Exception { return JMXConnectorServerFactory.newJMXConnectorServer(getJMXServiceUrl(), null, getServer()); }
String protocol = serviceURL.getProtocol(); protocol = ConnectorFactoryUtil.normalizeProtocol(protocol); PROTOCOL_PROVIDER_PACKAGES); List providers = loadProviders(providerPackages, classLoader, protocol);
JMXConnectorServerProvider providerInstance = loadProvider(providerPackage, protocol, classLoader); providers.add(providerInstance); JMXConnectorServerProvider localProvider = loadProvider(DEFAULT_PROTOCOL_PROVIDER_PACKAGE, protocol, Thread.currentThread().getContextClassLoader());
private void initConnector(Map<String, Object> environment) throws IOException { JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + assignedPort.getNumber() + "/server"); // service:jmx:rmi:///jndi/rmi://localhost:1199/server connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, environment, mBeanServer); connectorServer.start(); }
/** * Initialize the monitor server. * * @param agentConfig agentConfig * @throws IOException IO error */ public void init(AgentConfig agentConfig) throws IOException { this.agentConfig = agentConfig; Set<String> systemDataCollector = new HashSet<String>(); systemDataCollector.add(SYSTEM); MonitorContext.getInstance().setDataCollectors(systemDataCollector); int port = agentConfig.getMonitorProperties().getPropertyInt(PROP_MONITOR_BINDING_PORT); this.rmiRegistry = LocateRegistry.createRegistry(port); MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); String hostname = agentConfig.getMonitorBindingIP(); if (StringUtils.isBlank(hostname)) { hostname = NetworkUtils.getAllPBindingAddress(); } final String jmxUrlString = String.format("service:jmx:rmi://%s:%d/jndi/rmi://%s:%d/jmxrmi", hostname, port, hostname, port); JMXServiceURL jmxUrl = new JMXServiceURL(jmxUrlString); this.jmxServer = JMXConnectorServerFactory.newJMXConnectorServer(jmxUrl, null, mBeanServer); RegisterMXBean.getInstance().addDefaultMXBean(mBeanServer); LOG.info("Service URL:{} is initiated.", jmxUrl); }
JMXServiceURL url; try { url = new JMXServiceURL("service:jmx:rmi://localhost/jndi/rmi://localhost:" + xport + "/jmxrmi"); } catch (MalformedURLException ex) { logger.warn("error creating JMX URL: {} on port: {}", ex.getMessage(), port); LocateRegistry.createRegistry(port); } catch (RemoteException ex) { logger.warn("error creating JMX Registry: {}", ex.getMessage()); adminCS = JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs); UserManagement uMgr = context.getBean(UserManagement.class); MBeanServerForwarder mbsf = BagriJAASInvocationHandler.newProxyInstance(uMgr); adminCS.setMBeanServerForwarder(mbsf); if (!adminCS.isActive()) { adminCS.start();
/** * Starts this guy listening on his specified port * * @throws IOException if the port couldn't be opened * @throws IllegalArgumentException if he's already started */ public void start() throws IOException { if (connector != null) { throw new IllegalArgumentException("already started"); } LocateRegistry.createRegistry(port); connector = JMXConnectorServerFactory.newJMXConnectorServer( url, Collections.singletonMap(PROP_SOCK, this), ManagementFactory.getPlatformMBeanServer()); connector.start(); }