|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.sgs.impl.service.session.ClientSessionImpl
public class ClientSessionImpl
Implements a client session. The non-static, non-transient fields of an instance of this class are the persistent state of a client session and are only accessed transactionally.
| Nested Class Summary | |
|---|---|
(package private) static class |
ClientSessionImpl.HandleNextDisconnectedSessionTask
A persistent task to schedule tasks to notify (in succession) the client session listener of each disconnected session on a given failed node and to clean up the persistent data and bindings of those client sessions. |
(package private) static class |
ClientSessionImpl.SendEvent
A client session 'send' event, enqueued by a ClientSession.send invocation. |
| Constructor Summary | |
|---|---|
ClientSessionImpl(ClientSessionServiceImpl sessionService,
Identity identity,
Set<Delivery> deliveries,
int maxMessageLength)
Constructs an instance of this class with the specified sessionService, identity, and supported deliveries,
and stores this instance with the following bindings: |
|
| Method Summary | |
|---|---|
(package private) void |
addMoveEvent(long newNodeId)
Initiates a relocation of this client session from the current node to newNodeId. |
(package private) void |
disconnect()
If the session is connected, enqueues a disconnect event to this client session's event queue, and marks this session as disconnected. |
boolean |
equals(Object obj)
|
(package private) ClientSessionListener |
getClientSessionListener(DataService dataService)
Returns the client session listener, obtained from the specified dataService, for this session. |
(package private) BigInteger |
getId()
Returns the ID of this instance as a BigInteger. |
int |
getMaxMessageLength()
Return the maximum message length supported by this session. |
String |
getName()
Returns the login name used to authenticate this session. |
long |
getNodeId()
Returns the node ID for this instance. |
long |
getRelocatingToNodeId()
Returns the ID of the new node that the client session is relocating to, or -1 if the associated client session
is not relocating. |
(package private) static ClientSessionImpl |
getSession(DataService dataService,
BigInteger id)
Returns the ClientSession instance for the given id, retrieved from the specified dataService, or
null if the client session isn't bound in the data
service. |
ClientSessionWrapper |
getWrappedClientSession()
Returns the wrapped client session for this instance. |
(package private) int |
getWriteBufferCapacity()
Returns the write buffer capacity for this session. |
int |
hashCode()
|
boolean |
isConnected()
Returns true if the client is connected,
otherwise returns false. |
boolean |
isRelocating()
Returns true if the session is relocating, and false otherwise. |
(package private) void |
move(long newNodeId)
Updates this client session's node ID and bindings to the client session to reflect its reassignment to newNodeId. |
(package private) void |
notifyListenerAndRemoveSession(DataService dataService,
boolean graceful,
boolean notify)
Invokes the disconnected callback on this session's ClientSessionListener (if present and notify is
true), removes the listener and its binding (if present),
and then removes this session and its bindings from the specified
dataService. |
(package private) void |
putClientSessionListener(DataService dataService,
ClientSessionListener listener)
Stores the specified client session listener in the specified dataService with following binding: |
(package private) void |
relocationComplete()
Marks this client session as having completed relocation, and then services this session's event queue. |
ClientSession |
send(ByteBuffer message)
Sends a message contained in the specified ByteBuffer to
this session's client with the delivery guarantee of Delivery.RELIABLE. |
ClientSession |
send(ByteBuffer message,
Delivery delivery)
Sends a message contained in the specified ByteBuffer to
this session's client in a manner that satisfies the specified
delivery guarantee. |
(package private) static void |
serviceEventQueue(byte[] sessionId)
Services the event queue for the session with the specified sessionId. |
Set<Delivery> |
supportedDeliveries()
Returns a set containing the delivery guarantees supported by this session. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
ClientSessionImpl(ClientSessionServiceImpl sessionService,
Identity identity,
Set<Delivery> deliveries,
int maxMessageLength)
sessionService, identity, and supported deliveries,
and stores this instance with the following bindings:
com.sun.sgs.impl.service.session.impl.<idBytes> com.sun.sgs.impl.service.session.node.<nodeId>.impl.<idBytes>This method should only be called within a transaction.
sessionService - a client session serviceidentity - the session's identitydeliveries - the session's supported delivery requirementsmaxMessageLength - the maximum session message length
TransactionException - if there is a problem with the
current transaction| Method Detail |
|---|
public String getName()
getName in interface ClientSessionpublic Set<Delivery> supportedDeliveries()
supportedDeliveries in interface ClientSessionpublic int getMaxMessageLength()
getMaxMessageLength in interface ClientSessionpublic boolean isConnected()
true if the client is connected,
otherwise returns false.
isConnected in interface ClientSessiontrue if the client is connected,
otherwise returns falsepublic ClientSession send(ByteBuffer message)
ByteBuffer to
this session's client with the delivery guarantee of Delivery.RELIABLE. The message starts at the buffer's current
position and ends at the buffer's limit. The buffer's position is
not modified by this operation.
The ByteBuffer may be reused immediately after this method
returns. Changes made to the buffer after this method returns will
have no effect on the message sent to the client by this invocation.
This method is equivalent to invoking send with the specified message
and Delivery.RELIABLE.
Enqueues a send event to this client session's event queue for servicing.
send in interface ClientSessionmessage - a message
public ClientSession send(ByteBuffer message,
Delivery delivery)
ByteBuffer to
this session's client in a manner that satisfies the specified
delivery guarantee. The message starts at the buffer's
current position and ends at the buffer's limit. The buffer's
position is not modified by this operation.
When possible, the message should be delivered using the most
efficient means to satisfy the delivery guarantee. However, a
stronger delivery guarantee may be used to deliver the message if
the underlying protocol only supports stronger delivery guarantees.
If the protocol is not able to satisfy the specified delivery
guarantee (e.g., only supports weaker delivery guarantees than the
one specified), then a DeliveryNotSupportedException will be
thrown.
The ByteBuffer may be reused immediately after this method
returns. Changes made to the buffer after this method returns will
have no effect on the message sent to the client by this invocation.
Enqueues a send event to this client session's event queue for servicing.
send in interface ClientSessionmessage - a messagedelivery - a delivery guarantee
void addMoveEvent(long newNodeId)
newNodeId. If the client session is no longer connected
or the session is already relocating then this request is ignored.
newNodeId - the ID of the node this session is relocating tovoid relocationComplete()
IllegalStateException - if this method is invoked from a node
other than the session's local nodepublic boolean isRelocating()
true if the session is relocating, and false otherwise.
true if the session is relocating, and false otherwisevoid move(long newNodeId)
newNodeId.
newNodeId - the node this session is relocating to
IllegalArgumentException - if newNodeId does not match
the local node IDvoid disconnect()
public long getNodeId()
getNodeId in interface NodeAssignmentpublic long getRelocatingToNodeId()
-1 if the associated client session
is not relocating.
getRelocatingToNodeId in interface NodeAssignment-1 if the
session is not relocatingpublic boolean equals(Object obj)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class ObjectBigInteger getId()
BigInteger.
BigInteger
static ClientSessionImpl getSession(DataService dataService,
BigInteger id)
ClientSession instance for the given id, retrieved from the specified dataService, or
null if the client session isn't bound in the data
service. This method should only be called within a
transaction.
dataService - a data serviceid - a session ID
id,
or null
TransactionException - if there is a problem with the
current transactionpublic ClientSessionWrapper getWrappedClientSession()
void notifyListenerAndRemoveSession(DataService dataService,
boolean graceful,
boolean notify)
disconnected callback on this session's ClientSessionListener (if present and notify is
true), removes the listener and its binding (if present),
and then removes this session and its bindings from the specified
dataService. If the bindings have already been removed from
the dataService this method takes no action. This method
should only be called within a transaction.
dataService - a data servicegraceful - true if disconnection is graceful,
and false otherwisenotify - true if the disconnected
callback should be invoked
TransactionException - if there is a problem with the
current transaction
void putClientSessionListener(DataService dataService,
ClientSessionListener listener)
dataService with following binding:
com.sun.sgs.impl.service.session.listener.<idBytes>This method should only be called within a transaction.
dataService - a data servicelistener - a client session listener
TransactionException - if there is a problem with the
current transactionClientSessionListener getClientSessionListener(DataService dataService)
dataService, for this session. This method
should only be called within a transaction.
dataService - a data service
TransactionException - if there is a problem with the
current transactionstatic void serviceEventQueue(byte[] sessionId)
sessionId.
int getWriteBufferCapacity()
|
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 | |||||||||