org.apache.catalina.ha.session
public class SimpleTcpReplicationManager extends StandardManager implements ClusterManager
Version: 1.0 for TC 4.0
Description: The InMemoryReplicationManager is a session manager that replicated
session information in memory.
The InMemoryReplicationManager extends the StandardManager hence it allows for us
to inherit all the basic session management features like expiration, session listeners etc
To communicate with other nodes in the cluster, the InMemoryReplicationManager sends out 7 different type of multicast messages
all defined in the SessionMessage class.
When a session is replicated (not an attribute added/removed) the session is serialized into
a byte array using the StandardSession.readObjectData, StandardSession.writeObjectData methods.
Field Summary | |
---|---|
protected CatalinaCluster | cluster |
protected boolean | defaultMode |
protected boolean | distributable |
protected HashMap | invalidatedSessions |
static Log | log |
protected String | mChannelConfig |
protected boolean | mChannelStarted |
protected boolean | mExpireSessionsOnShutdown Set to true if we don't want the sessions to expire on shutdown |
protected String | mGroupName |
protected boolean | mManagerRunning |
protected boolean | mPrintToScreen |
protected String | name |
protected boolean | stateTransferred
Flag to keep track if the state has been transferred or not
Assumes false. |
protected boolean | synchronousReplication Use synchronous rather than asynchronous replication. |
protected boolean | useDirtyFlag |
Constructor Summary | |
---|---|
SimpleTcpReplicationManager()
Constructor, just calls super()
|
Method Summary | |
---|---|
ClusterManager | cloneFromTemplate() |
protected Session | createSession(String sessionId, boolean notify, boolean setId)
Creates a HTTP session.
|
Session | createSession(String sessionId)
Construct and return a new session object, based on the default
settings specified by this Manager's properties. |
boolean | doDomainReplication() |
CatalinaCluster | getCluster() |
boolean | getDistributable() |
boolean | getExpireSessionsOnShutdown() |
String[] | getInvalidatedSessions() |
String | getName() |
ReplicationStream | getReplicationStream(byte[] data)
Open Stream and use correct ClassLoader (Container) Switch
ThreadClassLoader
|
ReplicationStream | getReplicationStream(byte[] data, int offset, int length) |
boolean | isDefaultMode() |
boolean | isManagerRunning() |
boolean | isNotifyListenersOnReplication() |
boolean | isStateTransferred() |
void | messageDataReceived(ClusterMessage cmsg) |
protected void | messageReceived(SessionMessage msg, Member sender)
This method is called by the received thread when a SessionMessage has
been received from one of the other nodes in the cluster. |
protected Session | readSession(byte[] data, String sessionId)
Reinstantiates a serialized session from the data passed in.
|
ClusterMessage | requestCompleted(String sessionId) |
void | sessionInvalidated(String sessionId) |
void | setCluster(CatalinaCluster cluster) |
void | setDefaultMode(boolean defaultMode) |
void | setDistributable(boolean dist) |
void | setDomainReplication(boolean sendClusterDomainOnly) |
void | setExpireSessionsOnShutdown(boolean expireSessionsOnShutdown) |
void | setName(String name) |
void | setNotifyListenersOnReplication(boolean notifyListenersOnReplication) |
void | setPrintToScreen(boolean printtoscreen) |
void | setSynchronousReplication(boolean flag) |
void | setUseDirtyFlag(boolean usedirtyflag) |
void | start()
Prepare for the beginning of active use of the public methods of this
component. |
void | stop()
Gracefully terminate the active use of the public methods of this
component. |
void | unload()
Override persistence since they don't go hand in hand with replication for now. |
protected byte[] | writeSession(Session session)
Serialize a session into a byte array This method simple calls the writeObjectData method on the session and returns the byte data from that call |
Parameters: notify - if set to true the other nodes in the cluster will be notified. This flag is needed so that we can create a session before we deserialize a replicated one
See Also: ReplicatedSession
null
.
Throws: IllegalStateException if a new session cannot be instantiated for any reason
Parameters: data
Returns: The object input stream
Throws: IOException
Returns: Returns the defaultMode.
Parameters: msg - the message received sender - the sender of the message, this is used if we receive a EVT_GET_ALL_SESSION message, so that we only reply to the requesting node
Parameters: data - a byte array containing session data
Returns: a valid Session object, null if an error occurs
Parameters: defaultMode The defaultMode to set.
Parameters: sendClusterDomainOnly The sendClusterDomainOnly to set.
configure()
,
and before any of the public methods of the component are utilized.Throws: IllegalStateException if this component has already been started LifecycleException if this component detects a fatal error that prevents this component from being used
Throws: IllegalStateException if this component has not been started LifecycleException if this component detects a fatal error that needs to be reported
Parameters: session - the session to be serialized
Returns: a byte array containing the session data, null if the serialization failed