|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.sgs.impl.util.AbstractService
com.sun.sgs.impl.service.session.ClientSessionServiceImpl
public final class ClientSessionServiceImpl
Manages client sessions.
The constructor requires the
com.sun.sgs.app.name configuration
property and supports these
public configuration
properties. It also supports the following additional properties:
"com.sun.sgs.impl.service.session.server.port"
ClientSessionService's internal server.
"com.sun.sgs.impl.service.session.buffer.write.max"
"com.sun.sgs.impl.service.session.events.per.txn"
"com.sun.sgs.impl.service.session.allow.new.login"
false
false, any connecting client with
the same username as an already connected client will not be permitted
to login. If true, the user's existing session will be
disconnected and the new login is allowed to proceed.
"com.sun.sgs.impl.service.session.login.high.water"
Integer.MAX_VALUE / 2
Node.Health.YELLOW. If the number of logins exceeds 10% above the high water
the service's health is set to Node.Health.ORANGE. Legal values are between 0 and
Integer.MAX_VALUE.
"com.sun.sgs.impl.service.session.protocol.acceptor"
SimpleSgsProtocol. Other values should
specify the fully qualified name of a non-abstract class that implements
ProtocolAcceptor.
"com.sun.sgs.impl.service.session.relocation.key.length"
"com.sun.sgs.impl.service.session.relocation.timeout"
| Nested Class Summary | |
|---|---|
(package private) static interface |
ClientSessionServiceImpl.Action
An action to perform during commit. |
(package private) class |
ClientSessionServiceImpl.Context
|
| Nested classes/interfaces inherited from class com.sun.sgs.impl.util.AbstractService |
|---|
AbstractService.State, AbstractService.Version |
| Field Summary | |
|---|---|
(package private) static String |
ALLOW_NEW_LOGIN_PROPERTY
The name of the allow new login property. |
(package private) boolean |
allowNewLogin
The flag that indicates how to handle same user logins. |
(package private) static int |
DEFAULT_EVENTS_PER_TXN
The default events per transaction. |
(package private) static String |
DEFAULT_PROTOCOL_ACCEPTOR
The default protocol acceptor class. |
(package private) static int |
DEFAULT_RELOCATION_KEY_LENGTH
The default length of a relocation key, in bytes. |
(package private) static int |
DEFAULT_SERVER_PORT
The default server port. |
(package private) static int |
DEFAULT_WRITE_BUFFER_SIZE
The default write buffer size: 131072 |
(package private) static String |
EVENTS_PER_TXN_PROPERTY
The events per transaction property. |
(package private) int |
eventsPerTxn
The maximum number of session events to service per transaction. |
(package private) static String |
LOGIN_HIGH_WATER_PROPERTY
The name of the login high water property. |
(package private) NodeMappingService |
nodeMapService
The node mapping service. |
(package private) static String |
PROTOCOL_ACCEPTOR_PROPERTY
The protocol acceptor property name. |
(package private) static String |
RELOCATION_KEY_LENGTH_PROPERTY
The relocation key length property. |
(package private) int |
relocationKeyLength
The session relocation key length. |
(package private) long |
relocationTimeout
The session relocation timeout. |
(package private) static String |
SERVER_PORT_PROPERTY
The name of the server port property. |
(package private) ClientSessionServiceStats |
serviceStats
Our JMX exposed statistics. |
(package private) TaskService |
taskService
The task service. |
(package private) WatchdogService |
watchdogService
The watchdog service. |
(package private) static String |
WRITE_BUFFER_SIZE_PROPERTY
The name of the write buffer size property. |
| Fields inherited from class com.sun.sgs.impl.util.AbstractService |
|---|
appName, dataService, IO_TASK_PROPERTY_PREFIX, IO_TASK_RETRIES_PROPERTY, IO_TASK_WAIT_TIME_PROPERTY, maxIoAttempts, retryWaitTime, taskOwner, taskScheduler, transactionScheduler, txnProxy |
| Constructor Summary | |
|---|---|
ClientSessionServiceImpl(Properties properties,
ComponentRegistry systemRegistry,
TransactionProxy txnProxy)
Constructs an instance of this class with the specified properties. |
|
| Method Summary | |
|---|---|
(package private) void |
addHandler(BigInteger sessionRefId,
ClientSessionHandler handler,
Identity identity)
Adds the handler for the specified session to the internal session handler map. |
(package private) void |
addServiceEventQueueTask(byte[] sessionId)
Schedules a transactional task to service the event queue for the session with the specified sessionId. |
void |
addSessionStatusListener(ClientSessionStatusListener listener)
Adds the specified status listener to be notified when a local session disconnects or is being prepared to relocate. |
(package private) ClientSessionServiceImpl.Context |
checkContext()
Obtains information associated with the current transaction, throwing TransactionNotActiveException if there is no current transaction, and throwing IllegalStateException if there is a problem with the state of the transaction or if this service has not been initialized with a transaction proxy. |
void |
doReady()
Performs ready operations. |
void |
doShutdown()
Performs shutdown operations. |
(package private) ChannelServiceImpl |
getChannelService()
Returns the channel service. |
(package private) ClientSessionServer |
getClientSessionServer(long nodeId)
Returns the proxy for the client session server on the specified nodeId, or null if no server exists. |
(package private) ClientSessionHandler |
getHandler(BigInteger sessionRefId)
Returns the ClientSessionHandler for the specified client
session ID. |
(package private) Node.Health |
getHealth()
Get the service's health. |
(package private) static ClientSessionServiceImpl |
getInstance()
Returns the client session service relevant to the current context. |
(package private) long |
getLocalNodeId()
Returns the local node's ID. |
(package private) int |
getLoginHighWater()
Get the login high water. |
(package private) int |
getNumSessions()
Get the number of connected sessions. |
(package private) Set<ProtocolDescriptor> |
getProtocolDescriptors(long nodeId)
Returns a set of protocol descriptors for the specified nodeId, or null if there are no descriptors
for the node. |
SessionProtocol |
getSessionProtocol(BigInteger sessionRefId)
Returns a protocol for the local client session with the specified sessionRefId or null if the specified
client session is not connected to the local node. |
(package private) TaskScheduler |
getTaskScheduler()
Returns the task scheduler. |
(package private) static TaskService |
getTaskService()
Returns the task service. |
(package private) TransactionProxy |
getTransactionProxy()
Returns the transaction proxy. |
(package private) int |
getWriteBufferSize()
Returns the size of the write buffer to use for new connections. |
protected void |
handleServiceVersionMismatch(AbstractService.Version oldVersion,
AbstractService.Version currentVersion)
Handles conversion from the oldVersion to the currentVersion. |
boolean |
isRelocatingToLocalNode(BigInteger sessionRefId)
Returns true if the session with the specified sessionRefId is known to be relocating to the local node, and
returns false otherwise. |
(package private) void |
notifyPrepareToRelocate(BigInteger sessionRefId,
long newNodeId)
Notifies each registered ClientSessionStatusListener that
the session with the specified sessionRefId is moving to a
new node (specified by newNodeId). |
(package private) void |
removeHandler(BigInteger sessionRefId,
boolean isRelocating)
Removes the specified session from the internal session handler map, cleans up other session-related transient data, and if isDisconnecting is true notifies all ClientSessionStatusListeners of the session's disconnection. |
(package private) boolean |
removeUserLogin(Identity identity,
ClientSessionHandler handler)
Notifies this service that the specified identity is no
longer logged in using the specified handler so that
internal bookkeeping can be adjusted accordingly. |
(package private) void |
runTransactionalTask(KernelRunnable task,
Identity ownerIdentity)
Runs the specified task immediately, in a transaction. |
(package private) void |
scheduleTask(KernelRunnable task,
Identity ownerIdentity)
Schedules a non-durable, transactional task using the given Identity as the owner. |
(package private) void |
scheduleTaskOnCommit(KernelRunnable task)
Schedules a non-durable, transactional task using the task service. |
(package private) void |
setLoginHighWater(int highWater)
Set the login high water. |
(package private) boolean |
validateUserLogin(Identity identity,
ClientSessionHandler handler,
boolean loggingIn)
Validates the identity of the user logging in and returns
true if the login is allowed to proceed, and false
if the login is denied. |
| Methods inherited from class com.sun.sgs.impl.util.AbstractService |
|---|
callFinished, callStarted, checkNonTransactionalContext, checkServiceVersion, createTaskQueue, getDataService, getName, getState, isAlive, isInInitializedState, isRetryableException, ready, runIoTask, shutdown, shuttingDown |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.sun.sgs.service.Service |
|---|
getName, ready, shutdown |
| Field Detail |
|---|
static final String SERVER_PORT_PROPERTY
static final int DEFAULT_SERVER_PORT
static final String WRITE_BUFFER_SIZE_PROPERTY
static final int DEFAULT_WRITE_BUFFER_SIZE
static final String EVENTS_PER_TXN_PROPERTY
static final int DEFAULT_EVENTS_PER_TXN
static final String ALLOW_NEW_LOGIN_PROPERTY
static final String LOGIN_HIGH_WATER_PROPERTY
static final String PROTOCOL_ACCEPTOR_PROPERTY
static final String DEFAULT_PROTOCOL_ACCEPTOR
static final String RELOCATION_KEY_LENGTH_PROPERTY
static final int DEFAULT_RELOCATION_KEY_LENGTH
final WatchdogService watchdogService
final NodeMappingService nodeMapService
final TaskService taskService
final int eventsPerTxn
final boolean allowNewLogin
true, then if the same user logs in, the existing session will be
disconnected, and the new login is allowed to proceed. If false, then if the same user logs in, the new login will be denied.
final int relocationKeyLength
final long relocationTimeout
final ClientSessionServiceStats serviceStats
| Constructor Detail |
|---|
public ClientSessionServiceImpl(Properties properties,
ComponentRegistry systemRegistry,
TransactionProxy txnProxy)
throws Exception
properties - service propertiessystemRegistry - system registrytxnProxy - transaction proxy
Exception - if a problem occurs when creating the service| Method Detail |
|---|
protected void handleServiceVersionMismatch(AbstractService.Version oldVersion,
AbstractService.Version currentVersion)
oldVersion to the currentVersion. This method is invoked by checkServiceVersion if a version mismatch is detected and is invoked
from within a transaction.
handleServiceVersionMismatch in class AbstractServiceoldVersion - the old versioncurrentVersion - the current version
public void doReady()
throws Exception
ready method only once so that the subclass can
perform any operations necessary during the "ready" phase.
doReady in class AbstractServiceException - if a problem occurspublic void doShutdown()
shutdown method only once so that the
subclass can perform any operations necessary to shutdown the
service.
doShutdown in class AbstractServiceClientSessionServer getClientSessionServer(long nodeId)
nodeId, or null if no server exists.
nodeId - a node ID
nodeId, or nullpublic void addSessionStatusListener(ClientSessionStatusListener listener)
addSessionStatusListener in interface ClientSessionServicelistener - a listener to notify when a session disconnects or
is being prepared to relocatepublic SessionProtocol getSessionProtocol(BigInteger sessionRefId)
sessionRefId or null if the specified
client session is not connected to the local node.
The sessionRefId is the ID obtained by invoking getId on a ManagedReference to the
associated ClientSession.
This method is non-transactional. However, the method may be
invoked inside or outside of a transaction. The SessionProtocol returned from this method is used to communicate
with a client, so it should only be used outside of a transaction.
getSessionProtocol in interface ClientSessionServicesessionRefId - a client session ID, as a BigInteger
nullpublic boolean isRelocatingToLocalNode(BigInteger sessionRefId)
true if the session with the specified sessionRefId is known to be relocating to the local node, and
returns false otherwise.
isRelocatingToLocalNode in interface ClientSessionServicesessionRefId - a client session ID, as a BigInteger
true if the session with the specified sessionRefId is known to be relocating to the local node,
and returns false otherwiseTransactionProxy getTransactionProxy()
long getLocalNodeId()
int getWriteBufferSize()
ClientSessionHandler getHandler(BigInteger sessionRefId)
ClientSessionHandler for the specified client
session ID.
sessionRefId - a client session ID
int getNumSessions()
int getLoginHighWater()
void setLoginHighWater(int highWater)
highWater - the login high waterNode.Health getHealth()
ClientSessionServiceImpl.Context checkContext()
static ClientSessionServiceImpl getInstance()
boolean validateUserLogin(Identity identity,
ClientSessionHandler handler,
boolean loggingIn)
identity of the user logging in and returns
true if the login is allowed to proceed, and false
if the login is denied.
A user with the specified identity is allowed to log in
if one of the following conditions holds:
identity is not currently logged in and is not
relocating to the current node, or
identity is logged in, and the com.sun.sgs.impl.service.session.allow.new.login property is
set to true.
identity is forcibly disconnected.
If this method returns true, the removeUserLogin(com.sun.sgs.auth.Identity, com.sun.sgs.impl.service.session.ClientSessionHandler)
method must be invoked when the user with the specified identity is disconnected.
identity - the user identityhandler - the client session handlerloggingIn - if true session with specified
identity is loggingIn; otherwise it is relocating
true if the user is allowed to log in with the
specified identity, otherwise returns false
boolean removeUserLogin(Identity identity,
ClientSessionHandler handler)
identity is no
longer logged in using the specified handler so that
internal bookkeeping can be adjusted accordingly.
identity - the user identityhandler - the client session handler
void addHandler(BigInteger sessionRefId,
ClientSessionHandler handler,
Identity identity)
identity should be non-null, otherwise, the identity
should be null.
sessionRefId - the session ID, as a BigIntegerhandler - the client session handler to cacheidentity - if the session has been relocated, a non-null
identity to be removed from the
incomingRelocatingIdentities cache
void removeHandler(BigInteger sessionRefId,
boolean isRelocating)
isDisconnecting is true notifies all ClientSessionStatusListeners of the session's disconnection. This
method is invoked by the handler (in order to clean up the session's
transient data structures) when the session is disconnecting
its connection due to session termination or session relocation. If
a session is disconnecting because the session relocating to another
node, then isDisconnecting will be false.
void addServiceEventQueueTask(byte[] sessionId)
sessionId. If there is no
locally-connected session with the specified sessionId, then
no action is taken. This method should be invoked outside of a transaction.
sessionId - a session ID
void notifyPrepareToRelocate(BigInteger sessionRefId,
long newNodeId)
ClientSessionStatusListener that
the session with the specified sessionRefId is moving to a
new node (specified by newNodeId). The specified completion
handler should be notified (via its completed
method), when all listeners are finished preparing for relocation.
sessionRefId - the ID for the relocating client sessionnewNodeId - the ID of the new node for the client session
void scheduleTask(KernelRunnable task,
Identity ownerIdentity)
Identity as the owner.
void scheduleTaskOnCommit(KernelRunnable task)
void runTransactionalTask(KernelRunnable task,
Identity ownerIdentity)
throws Exception
task immediately, in a transaction.
Exceptionstatic TaskService getTaskService()
TaskScheduler getTaskScheduler()
ChannelServiceImpl getChannelService()
Set<ProtocolDescriptor> getProtocolDescriptors(long nodeId)
nodeId, or null if there are no descriptors
for the node. This method must be run outside a transaction.
|
RedDwarf, Version 0.10.1 2010-03-14 10:56:12 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||