Class ClientToServerConnection

java.lang.Object
host.anzo.simon.ClientToServerConnection

public class ClientToServerConnection extends Object
This class is used to store the relation between:
  • Dispatcher
  • IoSession
  • IoConnector
  • a String of format "HOST:PORT" that identifies the server
  • and the ExecutorService used 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 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 of ClientToServerConnection
      Parameters:
      serverString - the used server string
      dispatcher - the used dispatcher
      session - the underlying session
      connector - the used ioconnector
      filterchainWorkerPool - the executorservice for the filter chain
  • Method Details

    • getConnector

      protected org.apache.mina.core.service.IoConnector getConnector()
      Returns the IoConnector related 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

      protected ExecutorService getFilterchainWorkerPool()
    • setFilterchainWorkerPool

      protected void setFilterchainWorkerPool(ExecutorService filterchainWorkerPool)
    • 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

      protected Dispatcher getDispatcher()
      Gets the Dispatcher the client uses to communicate with the network
      Returns:
      the stored dispatcher
    • setDispatcher

      protected void setDispatcher(Dispatcher dispatcher)
      Sets the Dispatcher the 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 via Dispatcher
      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 via Dispatcher
      Parameters:
      session - the session to store
    • getServerString

      protected String getServerString()
      Gets the server string
      Returns:
      the stored server string
    • setServerString

      protected void setServerString(String serverString)
      Sets the server string
      Parameters:
      serverString - the server string to store