|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.abstracthorizon.danube.service.Service
org.abstracthorizon.danube.service.server.ServerService
org.abstracthorizon.danube.service.server.MultiThreadServerService
public abstract class MultiThreadServerService
This class models multi-threaded model of connection service. Each new connection is
spawned in a separate, possibly new, thread obtained from given executor. Connections
passed to the thread must be of ServerConnection type in order for close method
to be called at the end of processing.
| Nested Class Summary | |
|---|---|
protected class |
MultiThreadServerService.ConnectionHandlerThread
This class is executed in under the given executor. |
| Field Summary | |
|---|---|
protected Set<MultiThreadServerService.ConnectionHandlerThread> |
activeConnections
Set of active connections |
protected Executor |
executor
Executor (thread pool) to be used |
protected int |
graceFinishPeriod
Grace period for connections to finish after service state changes to STOPPING |
| Fields inherited from class org.abstracthorizon.danube.service.server.ServerService |
|---|
connectionHandler, socketAddress |
| Fields inherited from class org.abstracthorizon.danube.service.Service |
|---|
DESTROYED, INITIALIZED, listeners, logger, name, NOT_INITIALIZED, RUNNING, SERVICE_STATE_NAMES, STARTED, STOPPED, STOPPING, stopService |
| Constructor Summary | |
|---|---|
MultiThreadServerService()
Default constructor |
|
| Method Summary | |
|---|---|
Set<MultiThreadServerService.ConnectionHandlerThread> |
getActiveConnections()
Returns active connections |
Executor |
getExecutor()
Return the executor which is used or connections to be handled with |
int |
getGraceFinishPeriod()
Returns grace finish period |
int |
getNumberOfActiveConnections()
Returns number of active connections |
protected abstract void |
processConnections()
This method processes connections |
void |
run()
Accepts connections from processes them |
void |
setExecutor(Executor executor)
Sets the executor for connections to be handled with |
void |
setGraceFinishPeriod(int graceFinishPeriod)
Sets grace finish period |
void |
start()
Starts the service |
void |
stop()
Stops the service. |
| Methods inherited from class org.abstracthorizon.danube.service.server.ServerService |
|---|
getAddress, getConnectionHandler, getPort, getSocketAddress, setAddress, setConnectionHandler, setPort, setSocketAddress |
| Methods inherited from class org.abstracthorizon.danube.service.Service |
|---|
addListener, changeState, create, destroy, getName, getState, getStateName, removeListener, setName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int graceFinishPeriod
protected Executor executor
protected Set<MultiThreadServerService.ConnectionHandlerThread> activeConnections
| Constructor Detail |
|---|
public MultiThreadServerService()
| Method Detail |
|---|
public int getGraceFinishPeriod()
public void setGraceFinishPeriod(int graceFinishPeriod)
graceFinishPeriod - grace finish periodpublic Executor getExecutor()
public void setExecutor(Executor executor)
executor - public Set<MultiThreadServerService.ConnectionHandlerThread> getActiveConnections()
public int getNumberOfActiveConnections()
public void start()
throws ServiceException
start in class ServiceServiceException
public void stop()
throws ServiceException
stop in class ServiceServiceExceptionpublic void run()
protected abstract void processConnections()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||