com.jrockit.memleak.comm
Class ControllerRJMX

java.lang.Object
  extended by com.jrockit.memleak.comm.ControllerRJMX
All Implemented Interfaces:
Controller

public class ControllerRJMX
extends java.lang.Object
implements Controller

Class for controlling the MemLeakServer remotely using RJMX.

This class will fail to initialize in pre-JDK 5.0 VMs (unless RJMX classes are present). Instead, an ExceptionInInitializerError is thrown. RemoteMLSController catches this (or actually all LinkageErrors) along with ClassNotFoundException when it is determining which protocols are available.

This way, it can differentiate between a protocol not being available at all (class does not initialize) and not available for a certain host/port (constructor fails). In the former case the protocol is marked as unavailable, and in the latter case not. When obtaining a controller, both kinds of failing protocols are skipped and the first controller that can be instantiated is used.

Some connectors (like this) do not ever fail in the constructor, because the protocols have no quick and reliable way of detecting if the server is actually talking the same protocol. (Merely checking if the server is listening to the port could be done if a protocol specific default port is requested by giving 0 as the port. But otherwise, this does not help to determine if a protocol is usable.)

Author:
Marcus Hirt, Markus Persson

Field Summary
static int DEFAULT_PORT
          The default port for this protocol.
static java.lang.String PROTOCOL
          The protocol identifier for this protocol.
 
Fields inherited from interface com.jrockit.memleak.comm.Controller
CONSTRUCTOR_SIGNATURE
 
Constructor Summary
ControllerRJMX(java.lang.String hostName, int port, java.lang.String userName, java.lang.String password)
          Constructor.
 
Method Summary
 int getMLSPort()
          Check if the server is started, will return 0 if not started, otherwise returns the port it is listening to
 void printAvailableProtocolVersions()
          For debugging, print all available protocol versions to stdout.
 void shutDownMLS()
          Shutdown the memleak server.
 int startMLS()
          Start the memory leak server on the default port.
 int startMLS(int port)
          Start the memory leak server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROTOCOL

public static final java.lang.String PROTOCOL
The protocol identifier for this protocol.

See Also:
Constant Field Values

DEFAULT_PORT

public static final int DEFAULT_PORT
The default port for this protocol.

See Also:
Constant Field Values
Constructor Detail

ControllerRJMX

public ControllerRJMX(java.lang.String hostName,
                      int port,
                      java.lang.String userName,
                      java.lang.String password)
Constructor.

Parameters:
hostName - the host running the management server.
port - the port on which the manegement server is listening.
userName - the user name, if authentication is needed to connect to the server. May be null.
password - the password used to authenticate to the server, if needed. May be null.
Method Detail

startMLS

public int startMLS()
             throws MemLeakControllerException
Description copied from interface: Controller
Start the memory leak server on the default port.

Specified by:
startMLS in interface Controller
Returns:
the port that the server is listening to.
Throws:
MemLeakControllerException
See Also:
Controller.startMLS()

startMLS

public int startMLS(int port)
             throws MemLeakControllerException
Description copied from interface: Controller
Start the memory leak server.

Specified by:
startMLS in interface Controller
Parameters:
port - - the port the server should listen to, or 0 to let the OS choose
Returns:
the port that we are actually listening to.
Throws:
MemLeakControllerException
See Also:
Controller.startMLS(int)

shutDownMLS

public void shutDownMLS()
                 throws MemLeakControllerException
Description copied from interface: Controller
Shutdown the memleak server.

Specified by:
shutDownMLS in interface Controller
Throws:
MemLeakControllerException
See Also:
Controller.shutDownMLS()

getMLSPort

public int getMLSPort()
               throws MemLeakControllerException
Description copied from interface: Controller
Check if the server is started, will return 0 if not started, otherwise returns the port it is listening to

Specified by:
getMLSPort in interface Controller
Returns:
the port it is listening to, or 0 if not started.
Throws:
MemLeakControllerException
See Also:
Controller.getMLSPort()

printAvailableProtocolVersions

public void printAvailableProtocolVersions()
                                    throws MemLeakControllerException
Description copied from interface: Controller
For debugging, print all available protocol versions to stdout.

Specified by:
printAvailableProtocolVersions in interface Controller
Throws:
MemLeakControllerException
See Also:
Controller.printAvailableProtocolVersions()


Copyright © 1999, 2011, Oracle and/or its affiliates. All rights reserved.