public final class AprSocketConnector extends AbstractPollingIoConnector<AprSession,java.lang.Long> implements SocketConnector
IoConnector for APR based socket transport (TCP/IP).AbstractPollingIoConnector.ConnectionRequestAbstractIoService.ServiceOperationFuturedisposalLock| Constructor and Description |
|---|
AprSocketConnector()
Create an
AprSocketConnector with default configuration (multiple thread model). |
AprSocketConnector(java.util.concurrent.Executor executor,
IoProcessor<AprSession> processor)
Constructor for
AprSocketConnector with a given Executor for handling
connection events and a given IoProcessor for handling I/O events, useful for sharing
the same processor and executor over multiple IoService of the same type. |
AprSocketConnector(int processorCount)
Constructor for
AprSocketConnector with default configuration, and
given number of AprIoProcessor for multithreading I/O operations |
AprSocketConnector(IoProcessor<AprSession> processor)
Constructor for
AprSocketConnector with default configuration but a
specific IoProcessor, useful for sharing the same processor over multiple
IoService of the same type. |
| Modifier and Type | Method and Description |
|---|---|
protected java.util.Iterator<java.lang.Long> |
allHandles()
Iterator for all the client sockets polled for connection. |
protected void |
close(java.lang.Long handle)
Close a client socket.
|
protected boolean |
connect(java.lang.Long handle,
java.net.SocketAddress remoteAddress)
Connect a newly created client socket handle to a remote
SocketAddress. |
protected void |
destroy()
Destroy the polling system, will be called when this
IoConnector
implementation will be disposed. |
protected boolean |
finishConnect(java.lang.Long handle)
Finish the connection process of a client socket after it was marked as ready to process
by the
AbstractPollingIoConnector.select(int) call. |
protected AbstractPollingIoConnector.ConnectionRequest |
getConnectionRequest(java.lang.Long handle)
get the
AbstractPollingIoConnector.ConnectionRequest for a given client socket handle |
java.net.InetSocketAddress |
getDefaultRemoteAddress()
Returns the default remote address to connect to when no argument
is specified in
IoConnector.connect() method. |
SocketSessionConfig |
getSessionConfig()
Returns the default configuration of the new
IoSessions
created by this service. |
TransportMetadata |
getTransportMetadata()
Returns the
TransportMetadata that this service runs on. |
protected void |
init()
Initialize the polling system, will be called at construction time.
|
protected java.lang.Long |
newHandle(java.net.SocketAddress localAddress)
Create a new client socket handle from a local
SocketAddress |
protected AprSession |
newSession(IoProcessor<AprSession> processor,
java.lang.Long handle)
Create a new
IoSession from a connected socket client handle. |
protected void |
register(java.lang.Long handle,
AbstractPollingIoConnector.ConnectionRequest request)
Register a new client socket for connection, add it to connection polling
|
protected int |
select(int timeout)
Check for connected sockets, interrupt when at least a connection is processed (connected or
failed to connect).
|
protected java.util.Iterator<java.lang.Long> |
selectedHandles()
Iterator for the set of client sockets found connected or
failed to connect during the last #select() call. |
void |
setDefaultRemoteAddress(java.net.InetSocketAddress defaultRemoteAddress)
TODO : add documentation
|
protected void |
wakeup()
Interrupt the
#select() method. |
connect0, dispose0connect, connect, connect, connect, connect, connect, finishSessionInitialization0, getConnectTimeout, getConnectTimeoutCheckInterval, getConnectTimeoutMillis, setConnectTimeout, setConnectTimeoutCheckInterval, setConnectTimeoutMillis, setDefaultRemoteAddress, toStringaddListener, broadcast, dispose, dispose, executeWorker, executeWorker, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getListeners, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, initSession, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactoryclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitconnect, connect, connect, connect, connect, connect, getConnectTimeout, getConnectTimeoutMillis, setConnectTimeout, setConnectTimeoutMillis, setDefaultRemoteAddressaddListener, broadcast, dispose, dispose, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactorypublic AprSocketConnector()
AprSocketConnector with default configuration (multiple thread model).public AprSocketConnector(int processorCount)
AprSocketConnector with default configuration, and
given number of AprIoProcessor for multithreading I/O operationsprocessorCount - the number of processor to create and place in a
SimpleIoProcessorPoolpublic AprSocketConnector(IoProcessor<AprSession> processor)
AprSocketConnector with default configuration but a
specific IoProcessor, useful for sharing the same processor over multiple
IoService of the same type.processor - the processor to use for managing I/O eventspublic AprSocketConnector(java.util.concurrent.Executor executor,
IoProcessor<AprSession> processor)
AprSocketConnector with a given Executor for handling
connection events and a given IoProcessor for handling I/O events, useful for sharing
the same processor and executor over multiple IoService of the same type.executor - the executor for connectionprocessor - the processor for I/O operationsprotected void init()
throws java.lang.Exception
init in class AbstractPollingIoConnector<AprSession,java.lang.Long>java.lang.Exception - any exception thrown by the underlying system callsprotected void destroy()
throws java.lang.Exception
IoConnector
implementation will be disposed.destroy in class AbstractPollingIoConnector<AprSession,java.lang.Long>java.lang.Exception - any exception thrown by the underlying systems callsprotected java.util.Iterator<java.lang.Long> allHandles()
Iterator for all the client sockets polled for connection.allHandles in class AbstractPollingIoConnector<AprSession,java.lang.Long>protected boolean connect(java.lang.Long handle,
java.net.SocketAddress remoteAddress)
throws java.lang.Exception
SocketAddress.
This operation is non-blocking, so at end of the call the socket can be still in connection
process.connect in class AbstractPollingIoConnector<AprSession,java.lang.Long>handle - the client socket handleremoteAddress - the remote address where to connectjava.lang.Exceptionprotected AbstractPollingIoConnector.ConnectionRequest getConnectionRequest(java.lang.Long handle)
AbstractPollingIoConnector.ConnectionRequest for a given client socket handlegetConnectionRequest in class AbstractPollingIoConnector<AprSession,java.lang.Long>handle - the socket client handlenullprotected void close(java.lang.Long handle)
throws java.lang.Exception
close in class AbstractPollingIoConnector<AprSession,java.lang.Long>handle - the client socketjava.lang.Exception - any exception thrown by the underlying systems callsprotected boolean finishConnect(java.lang.Long handle)
throws java.lang.Exception
AbstractPollingIoConnector.select(int) call. The socket will be connected or reported as connection
failed.finishConnect in class AbstractPollingIoConnector<AprSession,java.lang.Long>handle - the client socket handle to finsh to connectjava.lang.Exception - any exception thrown by the underlying systems callsprotected java.lang.Long newHandle(java.net.SocketAddress localAddress)
throws java.lang.Exception
SocketAddressnewHandle in class AbstractPollingIoConnector<AprSession,java.lang.Long>localAddress - the socket address for binding the new client socketjava.lang.Exception - any exception thrown by the underlying systems callsprotected AprSession newSession(IoProcessor<AprSession> processor, java.lang.Long handle) throws java.lang.Exception
IoSession from a connected socket client handle.
Will assign the created IoSession to the given IoProcessor for
managing future I/O events.newSession in class AbstractPollingIoConnector<AprSession,java.lang.Long>processor - the processor in charge of this sessionhandle - the newly connected client socket handleIoSessionjava.lang.Exception - any exception thrown by the underlying systems callsprotected void register(java.lang.Long handle,
AbstractPollingIoConnector.ConnectionRequest request)
throws java.lang.Exception
register in class AbstractPollingIoConnector<AprSession,java.lang.Long>handle - client socket handlerequest - the associated AbstractPollingIoConnector.ConnectionRequestjava.lang.Exception - any exception thrown by the underlying systems callsprotected int select(int timeout)
throws java.lang.Exception
AbstractPollingIoConnector.selectedHandles()select in class AbstractPollingIoConnector<AprSession,java.lang.Long>java.lang.Exception - any exception thrown by the underlying systems callsprotected java.util.Iterator<java.lang.Long> selectedHandles()
Iterator for the set of client sockets found connected or
failed to connect during the last #select() call.selectedHandles in class AbstractPollingIoConnector<AprSession,java.lang.Long>protected void wakeup()
#select() method. Used when the poll set need to be modified.wakeup in class AbstractPollingIoConnector<AprSession,java.lang.Long>public TransportMetadata getTransportMetadata()
TransportMetadata that this service runs on.getTransportMetadata in interface IoServicepublic SocketSessionConfig getSessionConfig()
IoSessions
created by this service.getSessionConfig in interface IoServicegetSessionConfig in interface SocketConnectorgetSessionConfig in class AbstractIoServicepublic java.net.InetSocketAddress getDefaultRemoteAddress()
IoConnector.connect() method.getDefaultRemoteAddress in interface IoConnectorgetDefaultRemoteAddress in interface SocketConnectorgetDefaultRemoteAddress in class AbstractIoConnectorpublic void setDefaultRemoteAddress(java.net.InetSocketAddress defaultRemoteAddress)
setDefaultRemoteAddress in interface SocketConnector