com.sun.sgs.impl.protocol.simple
Class SimpleSgsProtocolAcceptor

java.lang.Object
  extended by com.sun.sgs.impl.util.AbstractService
      extended by com.sun.sgs.impl.protocol.simple.SimpleSgsProtocolAcceptor
All Implemented Interfaces:
ProtocolAcceptor, Service

public class SimpleSgsProtocolAcceptor
extends AbstractService
implements ProtocolAcceptor

A protocol acceptor for connections that speak the SimpleSgsProtocol. The constructors support the following properties:

Property: "com.sun.sgs.impl.protocol.simple.transport"
Default: "com.sun.sgs.impl.transport.tcp.TcpTransport"
Specifies the transport. The specified transport must support Delivery.RELIABLE.

Property: "com.sun.sgs.impl.protocol.simple.protocol.version"
Default: 5
Specifies the SimpleSgsProtocol version for this acceptor's connections. Valid values for the protocol version are 0x05 which supports client session relocation, and 0x04, which does not support client session relocation but is compatible with clients using the older protocol version. Protocol version 0x05 is incompatible with clients using protocol version 0x04.

Property: "com.sun.sgs.impl.protocol.simple.read.buffer.size"
Default: 131072
Minimum: 8192
Specifies the read buffer size.

Property: "com.sun.sgs.impl.protocol.simple.disconnect.delay"
Default: 1000L
Minimum: 1000L
Specifies the disconnect delay (in milliseconds) for disconnecting sessions.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.sun.sgs.impl.util.AbstractService
AbstractService.State, AbstractService.Version
 
Field Summary
static long DEFAULT_DISCONNECT_DELAY
          The time (in milliseconds) that a disconnecting connection is allowed before this service forcibly disconnects it.
static int DEFAULT_PROTOCOL_VERSION
          The default protocol version: 5.
static int DEFAULT_READ_BUFFER_SIZE
          The default read buffer size: 131072.
static String DEFAULT_TRANSPORT
          The default transport.
static String DISCONNECT_DELAY_PROPERTY
          The name of the disconnect delay property.
static long MIN_DISCONNECT_DELAY
          The minimum disconnect delay value.
static int MIN_READ_BUFFER_SIZE
          The minimum read buffer size value.
static String PROTOCOL_VERSION_PROPERTY
          The protocol version property.
static int PROTOCOL4
          The protocol version 4.
static String READ_BUFFER_SIZE_PROPERTY
          The name of the read buffer size property.
protected  int readBufferSize
          The read buffer size for new connections.
protected  Transport transport
          The transport.
static String TRANSPORT_PROPERTY
          The transport 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, logger, maxIoAttempts, retryWaitTime, taskOwner, taskScheduler, transactionScheduler, txnProxy
 
Constructor Summary
  SimpleSgsProtocolAcceptor(Properties properties, ComponentRegistry systemRegistry, TransactionProxy txnProxy)
          Constructs an instance with the specified properties, systemRegistry, and txnProxy.
protected SimpleSgsProtocolAcceptor(Properties properties, ComponentRegistry systemRegistry, TransactionProxy txnProxy, LoggerWrapper logger)
          Constructs an instance with the specified properties, systemRegistry, txnProxy, and logger.
 
Method Summary
 void accept(ProtocolListener protocolListener)
          Starts accepting connections, and notifies the specified listener of new connections.
 Identity authenticate(String name, String password)
          Returns the authenticated identity for the specified name and password.
 void close()
          Shuts down any pending accept operation as well as the acceptor itself.
 void doReady()
          Performs ready operations.
 void doShutdown()
          Performs shutdown operations.
 ProtocolDescriptor getDescriptor()
          Returns the descriptor for this protocol.
protected  void handleServiceVersionMismatch(AbstractService.Version oldVersion, AbstractService.Version currentVersion)
          Handles conversion from the oldVersion to the currentVersion.
 void monitorDisconnection(SessionProtocol protocol)
          Adds the specified protocol to the map containing SessionProtocols that are disconnecting.
 void scheduleNonTransactionalTask(KernelRunnable task)
          Schedules a non-durable, non-transactional task.
 
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

READ_BUFFER_SIZE_PROPERTY

public static final String READ_BUFFER_SIZE_PROPERTY
The name of the read buffer size property.

See Also:
Constant Field Values

DEFAULT_READ_BUFFER_SIZE

public static final int DEFAULT_READ_BUFFER_SIZE
The default read buffer size: 131072.

See Also:
Constant Field Values

MIN_READ_BUFFER_SIZE

public static final int MIN_READ_BUFFER_SIZE
The minimum read buffer size value.

See Also:
Constant Field Values

TRANSPORT_PROPERTY

public static final String TRANSPORT_PROPERTY
The transport property. The specified transport must support RELIABLE delivery.

See Also:
Constant Field Values

DEFAULT_TRANSPORT

public static final String DEFAULT_TRANSPORT
The default transport.

See Also:
Constant Field Values

PROTOCOL_VERSION_PROPERTY

public static final String PROTOCOL_VERSION_PROPERTY
The protocol version property. Valid values are 4 and 5.

See Also:
Constant Field Values

PROTOCOL4

public static final int PROTOCOL4
The protocol version 4.

See Also:
Constant Field Values

DEFAULT_PROTOCOL_VERSION

public static final int DEFAULT_PROTOCOL_VERSION
The default protocol version: 5.

See Also:
Constant Field Values

DISCONNECT_DELAY_PROPERTY

public static final String DISCONNECT_DELAY_PROPERTY
The name of the disconnect delay property.

See Also:
Constant Field Values

DEFAULT_DISCONNECT_DELAY

public static final long DEFAULT_DISCONNECT_DELAY
The time (in milliseconds) that a disconnecting connection is allowed before this service forcibly disconnects it.

See Also:
Constant Field Values

MIN_DISCONNECT_DELAY

public static final long MIN_DISCONNECT_DELAY
The minimum disconnect delay value.

See Also:
Constant Field Values

readBufferSize

protected final int readBufferSize
The read buffer size for new connections.


transport

protected final Transport transport
The transport.

Constructor Detail

SimpleSgsProtocolAcceptor

public SimpleSgsProtocolAcceptor(Properties properties,
                                 ComponentRegistry systemRegistry,
                                 TransactionProxy txnProxy)
                          throws Exception
Constructs an instance with the specified properties, systemRegistry, and txnProxy.

Parameters:
properties - the configuration properties
systemRegistry - the system registry
txnProxy - a transaction proxy
Throws:
Exception - if a problem occurs

SimpleSgsProtocolAcceptor

protected SimpleSgsProtocolAcceptor(Properties properties,
                                    ComponentRegistry systemRegistry,
                                    TransactionProxy txnProxy,
                                    LoggerWrapper logger)
                             throws Exception
Constructs an instance with the specified properties, systemRegistry, txnProxy, and logger.

Parameters:
properties - the configuration properties
systemRegistry - the system registry
txnProxy - a transaction proxy
logger - a logger for this instance
Throws:
Exception - if a problem occurs
Method Detail

handleServiceVersionMismatch

protected void handleServiceVersionMismatch(AbstractService.Version oldVersion,
                                            AbstractService.Version currentVersion)
Handles conversion from the oldVersion to the currentVersion. This method is invoked by checkServiceVersion if a version mismatch is detected and is invoked from within a transaction.

Specified by:
handleServiceVersionMismatch in class AbstractService
Parameters:
oldVersion - the old version
currentVersion - the current version

doReady

public void doReady()
Performs ready operations. This method is invoked by the ready method only once so that the subclass can perform any operations necessary during the "ready" phase.

Specified by:
doReady in class AbstractService

doShutdown

public void doShutdown()
Performs shutdown operations. This method is invoked by the shutdown method only once so that the subclass can perform any operations necessary to shutdown the service.

Specified by:
doShutdown in class AbstractService

getDescriptor

public ProtocolDescriptor getDescriptor()
Returns the descriptor for this protocol. Multiple calls to this method may return the same object.

Specified by:
getDescriptor in interface ProtocolAcceptor
Returns:
the descriptor for this protocol

accept

public void accept(ProtocolListener protocolListener)
            throws IOException
Starts accepting connections, and notifies the specified listener of new connections.

When an incoming connection with a given identity is established with this protocol acceptor, the protocol acceptor should invoke the provided listener's newLogin method with the identity and the protocol connection.

Specified by:
accept in interface ProtocolAcceptor
Parameters:
protocolListener - a protocol listener
Throws:
IOException - if an IO problem occurs

close

public void close()
Shuts down any pending accept operation as well as the acceptor itself.

Specified by:
close in interface ProtocolAcceptor

authenticate

public Identity authenticate(String name,
                             String password)
                      throws LoginException
Returns the authenticated identity for the specified name and password.

Parameters:
name - a name
password - a password
Returns:
the authenticated identity
Throws:
LoginException - if a problem occurs authenticating the name and password

monitorDisconnection

public void monitorDisconnection(SessionProtocol protocol)
Adds the specified protocol to the map containing SessionProtocols that are disconnecting. The map is keyed by connection expiration time. The connection will expire after a fixed delay and will be forcibly terminated if the client hasn't already closed the connection.

Parameters:
protocol - a SessionProtocol that is disconnecting

scheduleNonTransactionalTask

public void scheduleNonTransactionalTask(KernelRunnable task)
Schedules a non-durable, non-transactional task.

Parameters:
task - a non-durable, non-transactional task

RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved