final class LeafSessionManager extends SessionManager
SessionManager
which have behavior specific to a leaf node. Essentially, this is just
differences in initialization and the ability to request direct session
establishment with a remote network node.
This class is not instantiated directly. A singleton instance is created
using the SessionManagerFactory.createLeafNode(BootstrapConfig)
factory method. This instance is later retrieved with SessionManager.get()
.
It is possible to create multiple direct sessions or multiple virtual sessions to a router node. But, current implementation does not allow establishing at the same time direct and virtual sessions to the same router. Once all sessions to that router are terminated, the mode is reset and the next session can be of either type: direct or virtual.
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.net.InetSocketAddress,java.lang.Integer> |
connectionModes
Map containg the type of sessions which are allowed to be created for
the specific address.
|
private static int |
DIRECT_MODE
Identifier indicating that a direct session was establies to that
specific remote address and all subsequent sessions must be of the same
type (i.e.
|
private static int |
NOT_ESTABLISHED
Identifier indicating no session was established to that specific remote
address.
|
private static int |
VIRTUAL_MODE
Identifier indicating that a virtual session was establies to that
specific remote address and all subsequent sessions must be of the same
type (i.e.
|
activeSession, addressUseCount, appServers, config, identityByQueue, lock, LOG, secMgr, sessionsByQueue, shutdownDone, topology, virtualControlByContext, virtualLocksByQueue, virtualSessionsByContext
Constructor and Description |
---|
LeafSessionManager()
Constructor which enforces the singleton pattern.
|
Modifier and Type | Method and Description |
---|---|
Session |
connectDirect(BootstrapConfig config,
InterruptHandler interruptHandler,
SessionListener notify)
Establish a direct connection to a network node using the bootstrap
configuration stored during construction.
|
Session |
connectVirtual(BootstrapConfig config,
SessionListener notify)
Establish a virtual (multiplexed) connection to a network node at the
given address.
|
protected boolean |
deregisterSession(BaseSession session)
Deregister a session with the session manager.
|
protected void |
init()
Perform any special initialization which is not handled by the default
(common) logic.
|
boolean |
isLeaf()
Convenience method to detect whether this session manager operates on a
leaf node.
|
authenticateRemote, callAuthenticateRemote, config, connectDirect, connectVirtual, connectVirtual, createDirectSession, createQueue, deregisterAsyncThread, dropInitialContext, endSession, executeInContext, get, getAppServer, getInterruptHandler, getNodeAddress, getRemoteAddress, getSecurityPlugin, getSession, getSessionContexts, initialize, isAsyncThread, isLocalNode, isRouter, isVirtualSession, listen, nextContextID, notifyTermination, processEcho, queueStopped, registerAsyncThread, registerSession, restoreContext, setContext, setContext, setContext, setInitialContext, setInterruptHandler, shutdown, terminateInput, terminateRemote, terminateSessions, terminateVirtual, toString, waitForShutdown, waitUntilReady
private static final int NOT_ESTABLISHED
private static final int DIRECT_MODE
private static final int VIRTUAL_MODE
private final java.util.Map<java.net.InetSocketAddress,java.lang.Integer> connectionModes
LeafSessionManager()
java.lang.IllegalStateException
- if called more than once per JVM instance.java.lang.NullPointerException
- if config
is null
.public boolean isLeaf()
isLeaf
in class SessionManager
true
if network node for this session manager is a
leaf node; else false
.public Session connectDirect(BootstrapConfig config, InterruptHandler interruptHandler, SessionListener notify) throws java.lang.Exception
connectDirect
in class SessionManager
config
- Bootstrap configuration information which contains at least
enough information (host and port) to make a direct connection
from this node to another.interruptHandler
- An object that is notified when the current thread is
interrupted.notify
- Session listener to be notified of session events.java.lang.Exception
- if there are any errors reading configuration or creating a
queue.protected boolean deregisterSession(BaseSession session)
If the session being deregistered is the last session to use its queue, this fact is indicated by the method's return value.
The parent's implementation is overridden here to permit additional cleanup necessary for this implementation. However, this implementation first invokes the parent's.
deregisterSession
in class SessionManager
session
- Session being deregistered.true
if the session's underlying queue is still
needed by other sessions; false
if this was the
last session using its queue, and the queue can now be stopped.public Session connectVirtual(BootstrapConfig config, SessionListener notify) throws java.lang.Exception
This method is called by the requester side to establish a virtual session. The first time it must connect to a particular destination, a message transport queue is established. This requires authentication between the leaf node and the router node Thereafter, requests for additional sessions with that endpoint use the existing queue, and communications are multiplexed by context ID.
Once a transport is available, the current user's account identifier is
used to authenticate at the remote node. On the remote side, if
authentication is successful the other "half" of the virtual session is
established on the remote side. A unique context ID is assigned to that
session and is returned to the requester. This context ID is used to
establish a virtual session (RequesterSession
) on this side.
This ID is later used in outbound messages to multiplex communications
over the shared queue.
This method is synchronized so, if multiple clients are calling this method, only one of them will create the connection.
connectVirtual
in class SessionManager
config
- Bootstrap configuration information which contains at least
enough information to make a virtual connection from this node
to another.notify
- Session listener to be notified of session events.java.lang.Exception
- if there are any errors reading configuration, creating a
queue, or authenticating the user session remotely.protected void init() throws ConfigurationException
init
in class SessionManager
ConfigurationException
- if any configuration error occurs during initialization.