|
||||||||||
| 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.channel.ChannelServiceImpl
public final class ChannelServiceImpl
ChannelService implementation.
The constructor requires the
com.sun.sgs.app.name property and also supports
the following additional properties:
"com.sun.sgs.impl.service.channel.events.per.txn"
"com.sun.sgs.impl.service.channel.server.port"
ChannelServer of the local node.
"com.sun.sgs.impl.service.channel.write.buffer.size"
"com.sun.sgs.impl.service.session.relocation.timeout"
| Nested Class Summary | |
|---|---|
(package private) class |
ChannelServiceImpl.Context
This transaction context maintains a per-channel list of non-transactional tasks to perform when the transaction commits. |
(package private) static class |
ChannelServiceImpl.MembershipEventType
Channel membership event types. |
| Nested classes/interfaces inherited from class com.sun.sgs.impl.util.AbstractService |
|---|
AbstractService.State, AbstractService.Version |
| Field Summary | |
|---|---|
(package private) static int |
DEFAULT_EVENTS_PER_TXN
The default events per transaction: 1. |
(package private) static int |
DEFAULT_SERVER_PORT
The default server port: 0. |
(package private) static int |
DEFAULT_WRITE_BUFFER_SIZE
The default write buffer size: 131072. |
(package private) static String |
EVENTS_PER_TXN_PROPERTY
The property name for the maximum number of events to process in a single transaction. |
(package private) int |
eventsPerTxn
The maximum number of channel events to service per transaction. |
(package private) static String |
SERVER_PORT_PROPERTY
The name of the server port property. |
(package private) ChannelServiceStats |
serviceStats
Our JMX exposed statistics. |
(package private) long |
sessionRelocationTimeout
The timeout expiration, in milliseconds, for a client session to relocate. |
(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 | |
|---|---|
ChannelServiceImpl(Properties properties,
ComponentRegistry systemRegistry,
TransactionProxy txnProxy)
Constructs an instance of this class with the specified properties, systemRegistry, and txnProxy. |
|
| Method Summary | ||
|---|---|---|
(package private) void |
addChannelTaskOnCommit(BigInteger channelRefId,
IoRunnable ioTask,
long nodeId)
Adds the specified ioTask (in a wrapper that runs the task by
invoking runIoTask with the ioTask and nodeId) to the task list of the given channelRefId (when the current transaction commits). |
|
(package private) void |
addChannelTaskOnCommit(BigInteger channelRefId,
KernelRunnable task)
Adds the specified non-transactional task to the task list
of the given channelRefId (when the current transaction
commits). |
|
(package private) void |
addServiceEventQueueTask(BigInteger channelRefId)
Adds a task to service the event queue of the channel with the specified channelRefId. |
|
(package private) void |
addServiceEventQueueTaskOnCommit(BigInteger channelRefId)
Adds the specified channelRefId to the list of
locally-coordinated channels that need servicing after the current
transaction commits. |
|
(package private) void |
cacheMembershipEvent(ChannelServiceImpl.MembershipEventType eventType,
BigInteger channelRefId,
BigInteger sessionRefId,
long eventTimestamp,
long expirationTimestamp)
Caches the channel membership event with the specified eventType, channelRefId, sessionRefId, and eventTimestamp. |
|
(package private) static void |
checkTransaction(Transaction txn)
Checks that the specified context is currently active, throwing TransactionNotActiveException if it isn't. |
|
(package private) void |
closedChannel(BigInteger channelRefId)
Notifies this service that the channel with the specified channelRefId is closed so that this service can clean up any
per-channel data structures (relating to the channel coordinator). |
|
(package private) Set<BigInteger> |
collectChannelMembership(Transaction txn,
BigInteger channelRefId,
Set<Long> nodeIds)
Collects a snapshot of the channel membership for the channel with the specified channelRefId and set of member nodeIds and returns an unmodifiable set containing the channel
membership. |
|
Channel |
createChannel(String name,
ChannelListener listener,
Delivery delivery)
Creates a new channel with the specified listener and delivery guarantee, binds it to the specified name, and returns it. |
|
protected void |
doReady()
Performs ready operations. |
|
protected void |
doShutdown()
Performs shutdown operations. |
|
Channel |
getChannel(String name)
Returns an existing channel with the specified name. |
|
(package private) ChannelServer |
getChannelServer(long nodeId)
Returns the ChannelServer for the given nodeId,
or null if no channel server exists for the given
nodeId. |
|
(package private) static ClientSessionService |
getClientSessionService()
Returns the client session service. |
|
(package private) static BindingKeyedCollections |
getCollectionsFactory()
Returns the BindingKeyedCollections instance. |
|
(package private) static ChannelServiceImpl |
getInstance()
Returns the channel service. |
|
(package private) static long |
getLocalNodeId()
Returns the local node ID. |
|
(package private) static Object |
getObjectForId(BigInteger refId)
Returns the managed object with the specified refId, or null if there is no object with the specified refId. |
|
(package private) static TaskService |
getTaskService()
Returns the task service. |
|
(package private) static Transaction |
getTransaction()
Returns the currently active transaction, or throws TransactionNotActiveException if no transaction is active. |
|
(package private) static WatchdogService |
getWatchdogService()
Returns the watchdog service. |
|
void |
handleChannelMessage(BigInteger channelRefId,
ClientSession session,
ByteBuffer message)
Handles a channel message that the specified session
is sending on the channel with the specified channelRefId. |
|
protected void |
handleServiceVersionMismatch(AbstractService.Version oldVersion,
AbstractService.Version currentVersion)
Handles conversion from the oldVersion to the currentVersion. |
|
(package private) boolean |
isChannelMember(BigInteger channelRefId,
BigInteger sessionRefId,
boolean isChannelMember,
long timestamp)
Returns true if the session with the specified sessionRefId is a member of the channel with the specified channelRefId, and false otherwise. |
|
(package private) boolean |
isLocalChannelMember(BigInteger channelRefId,
BigInteger sessionRefId)
Returns true if the session with the specified
sessionRefId is a local member of the channel with
the specified channelRefId. |
|
(package private)
|
runTransactionalCallable(KernelCallable<R> callable)
Runs the specified non-durable, transactional callable using
this service's task owner, and returns the result. |
|
(package private) void |
runTransactionalTask(KernelRunnable task)
Runs the specified non-durable, transactional task using this
service's task owner. |
|
| 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 |
| Field Detail |
|---|
static final String SERVER_PORT_PROPERTY
static final int DEFAULT_SERVER_PORT
static final String EVENTS_PER_TXN_PROPERTY
static final int DEFAULT_EVENTS_PER_TXN
static final String WRITE_BUFFER_SIZE_PROPERTY
static final int DEFAULT_WRITE_BUFFER_SIZE
final int eventsPerTxn
final long sessionRelocationTimeout
final ChannelServiceStats serviceStats
| Constructor Detail |
|---|
public ChannelServiceImpl(Properties properties,
ComponentRegistry systemRegistry,
TransactionProxy txnProxy)
throws Exception
properties, systemRegistry, and txnProxy.
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 versionprotected void doReady()
ready method only once so that the subclass can
perform any operations necessary during the "ready" phase.
doReady in class AbstractServiceprotected void doShutdown()
shutdown method only once so that the
subclass can perform any operations necessary to shutdown the
service.
doShutdown in class AbstractService
public Channel createChannel(String name,
ChannelListener listener,
Delivery delivery)
If the specified listener is null, then any
messages sent on the returned channel by any client session will
be automatically forwarded, unfiltered, to all channel members.
If the specified listener is
non-null, then when any client session sends a
message on the returned channel, the specified listener's receivedMessage method is invoked with the channel, client
session and the message. The specified listener is not
invoked for messages that the server sends on the channel via
the channel's send method. If the specified
listener is non-null, then it must also
be Serializable.
Supplying a non-null listener (although not required) is
strongly suggested. A listener's receivedMessage
method provides an opportunity for an application to intervene when
a client sends a channel message, to perform access control,
filtering, or take other application-specific action on such channel
messages.
If a non-null listener is provided, it is strongly
suggested that a different listener instance be provided for each
channel created, in order to reduce the possible contention on
channel listeners.
Messages sent on the returned channel are delivered in a manner that satisfies the minimum requirements of the specified delivery guarantee.
createChannel in interface ChannelManagername - a namelistener - a channel listener, or nulldelivery - a delivery guarantee
public Channel getChannel(String name)
getChannel in interface ChannelManagername - a channel name
public void handleChannelMessage(BigInteger channelRefId,
ClientSession session,
ByteBuffer message)
message that the specified session
is sending on the channel with the specified channelRefId.
This method is invoked from the ClientSessionHandler of the
given session, when it receives a channel
message. This method must be called from within a transaction.
channelRefId - the channel ID, as a BigIntegersession - the client session sending the channel messagemessage - the channel message
boolean isLocalChannelMember(BigInteger channelRefId,
BigInteger sessionRefId)
true if the session with the specified
sessionRefId is a local member of the channel with
the specified channelRefId.
channelRefId - a channel IDsessionRefId - a session ID
true if the session with the specified
sessionRefId is a local member of the
channel with the specified channelRefId
Set<BigInteger> collectChannelMembership(Transaction txn,
BigInteger channelRefId,
Set<Long> nodeIds)
channelRefId and set of member nodeIds and returns an unmodifiable set containing the channel
membership.
static Transaction getTransaction()
TransactionNotActiveException if no transaction is active.
static void checkTransaction(Transaction txn)
void addChannelTaskOnCommit(BigInteger channelRefId,
IoRunnable ioTask,
long nodeId)
ioTask (in a wrapper that runs the task by
invoking runIoTask with the ioTask and nodeId) to the task list of the given channelRefId (when the current transaction commits).
void addChannelTaskOnCommit(BigInteger channelRefId,
KernelRunnable task)
task to the task list
of the given channelRefId (when the current transaction
commits).
channelRefId - a channel IDtask - a non-transactional taskvoid addServiceEventQueueTaskOnCommit(BigInteger channelRefId)
channelRefId to the list of
locally-coordinated channels that need servicing after the current
transaction commits.
channelRefId - a channel ID for a locally-coordinated channelvoid closedChannel(BigInteger channelRefId)
channelRefId is closed so that this service can clean up any
per-channel data structures (relating to the channel coordinator).
static ChannelServiceImpl getInstance()
static ClientSessionService getClientSessionService()
static TaskService getTaskService()
static WatchdogService getWatchdogService()
static BindingKeyedCollections getCollectionsFactory()
static long getLocalNodeId()
ChannelServer getChannelServer(long nodeId)
ChannelServer for the given nodeId,
or null if no channel server exists for the given
nodeId. If the specified nodeId is the local
node's ID, then this method returns a reference to the server
implementation object, rather than the proxy.
void runTransactionalTask(KernelRunnable task)
throws Exception
task using this
service's task owner.
task - a transactional task
Exception - the exception thrown while running task
<R> R runTransactionalCallable(KernelCallable<R> callable)
throws Exception
callable using
this service's task owner, and returns the result.
callable - a callable to call
Exception - the exception thrown while calliing callablestatic Object getObjectForId(BigInteger refId)
refId, or null if there is no object with the specified refId.
refId - the object's identifier as obtained by
ManagedReference.getId
TransactionException - if the operation failed because of a
problem with the current transactionvoid addServiceEventQueueTask(BigInteger channelRefId)
channelRefId. This method is only invoked on the
channel's coordinator node.
channelRefId - a channel ID
void cacheMembershipEvent(ChannelServiceImpl.MembershipEventType eventType,
BigInteger channelRefId,
BigInteger sessionRefId,
long eventTimestamp,
long expirationTimestamp)
eventType, channelRefId, sessionRefId, and eventTimestamp. This method is only invoked on the channel's
coordinator node.
eventType - an membership event typechannelRefId - a channel IDsessionRefId - a session ID, or nulleventTimestamp - the event's timestampexpirationTimestamp - the event queue's timestamp
boolean isChannelMember(BigInteger channelRefId,
BigInteger sessionRefId,
boolean isChannelMember,
long timestamp)
true if the session with the specified sessionRefId is a member of the channel with the specified channelRefId, and false otherwise. This method is only
invoked on the channel's coordinator node.
channelRefId - a channel IDsessionRefId - a session IDisChannelMember - if true, the specified session is
considered to be a member when current event was added to
the event queuetimestamp - the timestamp of the currently executing event,
beyond which join/leave requests should not be considered
in determining channel membership
true if the session with the specified sessionRefId is a member of the channel with the specified
channelRefId, and false otherwise
|
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 | |||||||||