|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface NodeMappingService
The Node Mapping Service has the following responsibilities:
On initial client login, the ClientSessionService will get a
node assignment via assignNode. If the assigned node
is the current node (as determined by the nodeId), the client will proceed
with the login protocol.
Otherwise, the client will get a login response indicating a redirection,
and the client code should attempt to log in at the redirected node.
Mappings will be removed when the system believes an identity has become
quiescent, for example when a client logs out and there are no more durable
tasks to be run for that client's identity. In order to determine whether an
identity is quiescent, services which manage resources being used on an
identity's behalf inform this mapping service when the identity is active
or inactive on a node by calling setStatus. The node
mapping service will use this information for a simple reference counting
garbage collection scheme within the map. Status is tracked per node, so
services should consider only their local node state when calling setStatus.
TODO We might want a transactional method that returns true if an identity is both assigned to the local node and the local node is alive, as a convenience to other services.
TODO A variation of "assignNode" which adds hints for identities the input might want to colocate with will probably be added later.
| Method Summary | |
|---|---|
void |
addIdentityRelocationListener(IdentityRelocationListener listener)
Adds a listener to be notified when an identity has been selected
to be relocated off the local node. |
void |
addNodeMappingListener(NodeMappingListener listener)
Adds a listener to be notified when the identity
mapping for this node is modified. |
long |
assignNode(Class service,
Identity identity)
Assigns the identity to a node and adds the assignment to the map. |
Iterator<Identity> |
getIdentities(long nodeId)
Returns an Iterator for the set of identities assigned to a node. |
Node |
getNode(Identity identity)
Returns the live node to which the identity is assigned. |
void |
setStatus(Class service,
Identity identity,
boolean active)
Inform the NodeMappingService that a service instance has
observed a change in status of an identity on this node. |
| Methods inherited from interface com.sun.sgs.service.Service |
|---|
getName, ready, shutdown |
| Method Detail |
|---|
long assignNode(Class service,
Identity identity)
Additionally (and atomically), notes that the service considers the
identity to be active, as though
setStatus(service, identity, true) had
been called on the assigned node.
This method should not be called while in a transaction, as this method call could entail remote communication.
The returned node ID might not match the ID of the node returned from an
immediate call to getNode in a transaction because an
identity's node assignment may change at any time.
service - the class of the calleridentity - the identity to assign to a node
IllegalStateException - if this method is called while in a
transaction
void setStatus(Class service,
Identity identity,
boolean active)
throws UnknownIdentityException
NodeMappingService that a service instance has
observed a change in status of an identity on this node. When all
services which have previously noted an identity as active set the
status to false, the identity can be removed from the map. If a node
fails or the node mapping service initiates a mapping change (for
load balancing), all status votes for the failing or old node are
implicitly set to inactive.
This method should not be called while in a transaction, as this method call could entail remote communication.
service - the class of the calling serviceidentity - the identity for which service has observed a
state changeactive - true if the identity is active,
false if the identity is inactive
UnknownIdentityException - if the identity is not in the map
IllegalStateException - if this method is called while in a
transaction
Node getNode(Identity identity)
throws UnknownIdentityException
This method must be called from within a transaction.
identity - the identity
identity
UnknownIdentityException - if the identity is not in the map
TransactionException - if the operation failed because of
a problem with the current transaction
Iterator<Identity> getIdentities(long nodeId)
throws UnknownNodeException
Iterator for the set of identities assigned to a node.
The set will be empty if no identities are assigned to the node.
The remove operation of the returned iterator is not supported
and will throw UnsupportedOperationException if invoked.
This method should only be called within a transaction, and the returned iterator should only be used within that transaction.
nodeId - a node ID
UnknownNodeException - if the nodeId is unknown
IllegalArgumentException - if the specified nodeId
is not within the range of valid IDs
TransactionException - if the operation failed because of
a problem with the current transactionvoid addIdentityRelocationListener(IdentityRelocationListener listener)
listener to be notified when an identity has been selected
to be relocated off the local node. The listener will be invoked
outside of a transaction.
If a Service needs to take actions before an identity is moved,
it should register one (or more) listener objects when
constructed. The order of callbacks to listener objects is not
specified, and the callbacks will occur asynchronously.
The identity will be moved, and the mapping modified, when all
listener objects have completed their work, or after a time
delay in case a listener does not respond that it is finished.
listener - a listener to be notified prior to an identity moving
from the local nodevoid addNodeMappingListener(NodeMappingListener listener)
listener to be notified when the identity
mapping for this node is modified. This method is not performed
under a transaction; listeners are held locally on nodes.
If a Service needs to take actions when identities are added to
or removed from a local node, it should register one (or more)
listener objects when it is constructed. The order of callbacks
to listener objects is not specified, and the callbacks will occur
asynchronously.
listener - a listener to be notified of local changes to the map
|
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 | |||||||||