edu.berkeley.psi.seda.generic
Class genericServer

java.lang.Object
  extended by edu.berkeley.psi.seda.generic.genericServer
All Implemented Interfaces:
genericConst, EventHandlerIF

public class genericServer
extends java.lang.Object
implements EventHandlerIF, genericConst

A genericServer is an EventHandlerIF for a SandStorm stage which accepts incoming service connections. The server has a client sink associated with it, onto which genericConnection and genericRequest events are pushed. When a connection is closed, a SinkClosedEvent is pushed, with the sink pointer set to the genericConnection that closed.

See Also:
genericConnection, genericRequest

Field Summary
private static boolean DEBUG
           
protected  int listenPort
           
protected  ManagerIF mgr
           
protected  SinkIF mySink
           
private static int num_svrs
           
protected  ATcpServerSocket servsock
           
protected  StageIF stage
           
 
Fields inherited from interface edu.berkeley.psi.seda.generic.genericConst
CRLF, DEFAULT_PORT, WRITE_CLOG_THRESHOLD
 
Constructor Summary
genericServer()
          Create a generic server listening for incoming connections on the default port.
 
Method Summary
 void destroy()
          Called when an event handler is destroyed.
 ATcpServerSocket getServerSocket()
          Return the server socket being used by this genericServer.
(package private)  SinkIF getSink()
           
 void handleEvent(QueueElementIF qel)
          The main event handler.
 void handleEvents(QueueElementIF[] qelarr)
          Handle the events corresponding to the given QueueElementIF array.
 void init(ConfigDataIF config)
          The Sandstorm stage initialization method.
 void resumeAccept()
          Resume acceptance of new connections on this server.
 void suspendAccept()
          Suspend acceptance of new connections on this server.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

num_svrs

private static int num_svrs

listenPort

protected int listenPort

servsock

protected ATcpServerSocket servsock

mgr

protected ManagerIF mgr

stage

protected StageIF stage

mySink

protected SinkIF mySink
Constructor Detail

genericServer

public genericServer()
Create a generic server listening for incoming connections on the default port.

Method Detail

init

public void init(ConfigDataIF config)
          throws java.lang.Exception
The Sandstorm stage initialization method.

Specified by:
init in interface EventHandlerIF
Parameters:
config - The set of configuration parameters for the stage.
Throws:
java.lang.Exception - The EventHandler can indicate an error to the runtime during initialization by throwing an Exception.

destroy

public void destroy()
Description copied from interface: EventHandlerIF
Called when an event handler is destroyed. This method should perform any cleanup or shutdown operations as required by the application before the event handler is removed from the system.

Specified by:
destroy in interface EventHandlerIF

handleEvent

public void handleEvent(QueueElementIF qel)
The main event handler.

Specified by:
handleEvent in interface EventHandlerIF

handleEvents

public void handleEvents(QueueElementIF[] qelarr)
Description copied from interface: EventHandlerIF
Handle the events corresponding to the given QueueElementIF array. This method is invoked when multiple events are pending for the event handler. The application may reorder, filter, or drop these events if it wishes to do so.

Specified by:
handleEvents in interface EventHandlerIF

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

suspendAccept

public void suspendAccept()
Suspend acceptance of new connections on this server. This request will not be effective immediately.


resumeAccept

public void resumeAccept()
Resume acceptance of new connections on this server. This request will not be effective immediately.


getSink

SinkIF getSink()

getServerSocket

public ATcpServerSocket getServerSocket()
Return the server socket being used by this genericServer.