Package host.anzo.simon
Class ClientToServerConnection
java.lang.Object
host.anzo.simon.ClientToServerConnection
This class is used to store the relation between:
DispatcherIoSessionIoConnector- a String of format "HOST:PORT" that identifies the server
- and the
ExecutorServiceused on the filter chain
This information is used by Simon to establish only one connection to a server for
several Lookup.lookup(String) calls. Each lookup on the same connection increases a reference count.
The connection will be dropped by SIMON if the reference count reaches 0.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedClientToServerConnection(String serverString, Dispatcher dispatcher, org.apache.mina.core.session.IoSession session, org.apache.mina.core.service.IoConnector connector, ExecutorService filterchainWorkerPool) Creates a new Instance ofClientToServerConnection -
Method Summary
Modifier and TypeMethodDescriptionprotected intaddRef()Increases the reference count by oneprotected intdelRef()Decreases the reference count by oneprotected org.apache.mina.core.service.IoConnectorReturns theIoConnectorrelated to the connectionprotected DispatcherGets theDispatcherthe client uses to communicate with the networkprotected ExecutorServiceprotected intReturns the current valid reference countprotected StringGets the server stringprotected org.apache.mina.core.session.IoSessionGets the session which is used by the client to communicate with the server viaDispatcherprotected voidsetConnector(org.apache.mina.transport.socket.nio.NioSocketConnector connector) Sets the socket connector used by SIMON to connect to serverprotected voidsetDispatcher(Dispatcher dispatcher) Sets theDispatcherthe client uses to communicate with the networkprotected voidsetFilterchainWorkerPool(ExecutorService filterchainWorkerPool) protected voidsetServerString(String serverString) Sets the server stringprotected voidsetSession(org.apache.mina.core.session.IoSession session) Sets the session which is used by the client to communicate with the server viaDispatcher
-
Constructor Details
-
ClientToServerConnection
protected ClientToServerConnection(String serverString, Dispatcher dispatcher, org.apache.mina.core.session.IoSession session, org.apache.mina.core.service.IoConnector connector, ExecutorService filterchainWorkerPool) Creates a new Instance ofClientToServerConnection- Parameters:
serverString- the used server stringdispatcher- the used dispatchersession- the underlying sessionconnector- the used ioconnectorfilterchainWorkerPool- the executorservice for the filter chain
-
-
Method Details
-
getConnector
protected org.apache.mina.core.service.IoConnector getConnector()Returns theIoConnectorrelated to the connection- Returns:
- the related
IoConnector
-
setConnector
protected void setConnector(org.apache.mina.transport.socket.nio.NioSocketConnector connector) Sets the socket connector used by SIMON to connect to server- Parameters:
connector- nio socket connector
-
getFilterchainWorkerPool
-
setFilterchainWorkerPool
-
addRef
protected int addRef()Increases the reference count by one- Returns:
- the new reference count
-
delRef
protected int delRef()Decreases the reference count by one- Returns:
- the new reference count
-
getRefCount
protected int getRefCount()Returns the current valid reference count- Returns:
- the current reference count
-
getDispatcher
Gets theDispatcherthe client uses to communicate with the network- Returns:
- the stored dispatcher
-
setDispatcher
Sets theDispatcherthe client uses to communicate with the network- Parameters:
dispatcher- the dispatcher to store
-
getSession
protected org.apache.mina.core.session.IoSession getSession()Gets the session which is used by the client to communicate with the server viaDispatcher- Returns:
- the stored session
-
setSession
protected void setSession(org.apache.mina.core.session.IoSession session) Sets the session which is used by the client to communicate with the server viaDispatcher- Parameters:
session- the session to store
-
getServerString
Gets the server string- Returns:
- the stored server string
-
setServerString
Sets the server string- Parameters:
serverString- the server string to store
-