use of javax.management.remote.rmi.RMIConnectorServer in project jdk8u_jdk by JetBrains.
the class JMXConnectorServerProviderImpl method newJMXConnectorServer.
public JMXConnectorServer newJMXConnectorServer(JMXServiceURL url, Map<String, ?> map, MBeanServer mbeanServer) throws IOException {
final String protocol = url.getProtocol();
called = true;
System.out.println("JMXConnectorServerProviderImpl called");
if (protocol.equals("rmi"))
return new RMIConnectorServer(url, map, mbeanServer);
if (protocol.equals("throw-provider-exception"))
throw new JMXProviderException("I have been asked to throw");
throw new IllegalArgumentException("UNKNOWN PROTOCOL");
}
use of javax.management.remote.rmi.RMIConnectorServer in project Payara by payara.
the class RMIConnectorStarter method start.
/**
* The start method which configures the SSLSockets needed and then starts the
* JMXConnecterServer.
*
* @return
* @throws MalformedURLException
* @throws IOException
*/
@Override
public JMXConnectorServer start() throws MalformedURLException, IOException, UnknownHostException {
final String name = "jmxrmi";
final String hostname = hostname();
final Map<String, Object> env = new HashMap<>();
env.put("jmx.remote.jndi.rebind", "true");
// Provide SSL-based RMI socket factories.
env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, sslCsf);
env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, sslServerSocketFactory);
// For binding the JMXConnectorServer with the Registry
env.put("com.sun.jndi.rmi.factory.socket", sslCsf);
JMXAuthenticator authenticator = getAccessController();
if (authenticator != null) {
env.put("jmx.remote.authenticator", authenticator);
}
// env.put("jmx.remote.protocol.provider.pkgs", "com.sun.jmx.remote.protocol");
// env.put("jmx.remote.protocol.provider.class.loader", this.getClass().getClassLoader());
final String jmxHostPort = hostname + ":" + mPort;
final String registryHostPort = hostname + ":" + mPort;
// !!!
// extended JMXServiceURL uses the same port for both the RMIRegistry and the client port
// see: http://blogs.sun.com/jmxetc/entry/connecting_through_firewall_using_jmx
// the first hostPort value is the host/port to be used for the client connections; this makes it a fixed
// port number and we're making it the same as the RMI registry port.
// final String urlStr = "service:jmx:rmi:///jndi/rmi://" + hostPort + "/" + name;
final String urlStr = "service:jmx:rmi://" + jmxHostPort + "/jndi/rmi://" + registryHostPort + "/" + name;
mJMXServiceURL = new JMXServiceURL(urlStr);
if (mBindToSingleIP) {
RMIServerSocketFactory rmiSSF = isSecurityEnabled() ? sslServerSocketFactory : mServerSocketFactory;
mMyServer = new MyRMIJRMPServerImpl(mPort, env, rmiSSF, hostname);
mConnectorServer = new RMIConnectorServer(mJMXServiceURL, env, mMyServer, mMBeanServer);
} else {
mConnectorServer = JMXConnectorServerFactory.newJMXConnectorServer(mJMXServiceURL, env, mMBeanServer);
}
if (mBootListener != null) {
mConnectorServer.addNotificationListener(mBootListener, null, mJMXServiceURL.toString());
}
mConnectorServer.start();
return mConnectorServer;
}
use of javax.management.remote.rmi.RMIConnectorServer in project cassandra by apache.
the class CQLTester method tearDownClass.
@AfterClass
public static void tearDownClass() {
for (Session sess : sessions.values()) sess.close();
for (Cluster cl : clusters.values()) cl.close();
if (server != null)
server.stop();
// statements are not cached but re-prepared every time). So we clear the cache between test files to avoid accumulating too much.
if (reusePrepared)
QueryProcessor.clearInternalStatementsCache();
TokenMetadata metadata = StorageService.instance.getTokenMetadata();
metadata.clearUnsafe();
if (jmxServer != null && jmxServer instanceof RMIConnectorServer) {
try {
((RMIConnectorServer) jmxServer).stop();
} catch (IOException e) {
logger.warn("Error shutting down jmx", e);
}
}
}
use of javax.management.remote.rmi.RMIConnectorServer in project flink by apache.
the class JMXServer method internalStart.
private void internalStart(int port) throws IOException {
rmiServerReference.set(null);
// this allows clients to lookup the JMX service
rmiRegistry = new JmxRegistry(port, "jmxrmi", rmiServerReference);
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);
}
final RMIJRMPServerImpl rmiServer = new RMIJRMPServerImpl(port, null, null, null);
connector = new RMIConnectorServer(url, null, rmiServer, ManagementFactory.getPlatformMBeanServer());
connector.start();
// we can't pass the created stub directly to the registry since this would form a cyclic
// dependency:
// - you can only start the connector after the registry was started
// - you can only create the stub after the connector was started
// - you can only start the registry after the stub was created
rmiServerReference.set(rmiServer.toStub());
}
use of javax.management.remote.rmi.RMIConnectorServer in project tomcat by apache.
the class JmxRemoteLifecycleListener method createServer.
private JMXConnectorServer createServer(String serverName, String bindAddress, int theRmiRegistryPort, int theRmiServerPort, HashMap<String, Object> theEnv, RMIClientSocketFactory registryCsf, RMIServerSocketFactory registrySsf, RMIClientSocketFactory serverCsf, RMIServerSocketFactory serverSsf) {
// Create the RMI registry
Registry registry;
try {
registry = LocateRegistry.createRegistry(theRmiRegistryPort, registryCsf, registrySsf);
} catch (RemoteException e) {
log.error(sm.getString("jmxRemoteLifecycleListener.createRegistryFailed", serverName, Integer.toString(theRmiRegistryPort)), e);
return null;
}
if (bindAddress == null) {
bindAddress = "localhost";
}
String url = "service:jmx:rmi://" + bindAddress;
JMXServiceURL serviceUrl;
try {
serviceUrl = new JMXServiceURL(url);
} catch (MalformedURLException e) {
log.error(sm.getString("jmxRemoteLifecycleListener.invalidURL", serverName, url), e);
return null;
}
RMIConnectorServer cs = null;
try {
RMIJRMPServerImpl server = new RMIJRMPServerImpl(rmiServerPortPlatform, serverCsf, serverSsf, theEnv);
cs = new RMIConnectorServer(serviceUrl, theEnv, server, ManagementFactory.getPlatformMBeanServer());
cs.start();
registry.bind("jmxrmi", server.toStub());
log.info(sm.getString("jmxRemoteLifecycleListener.start", Integer.toString(theRmiRegistryPort), Integer.toString(theRmiServerPort), serverName));
} catch (IOException | AlreadyBoundException e) {
log.error(sm.getString("jmxRemoteLifecycleListener.createServerFailed", serverName), e);
}
return cs;
}
Aggregations