Package org.apache.hc.core5.reactor
Class InternalDataChannel
java.lang.Object
org.apache.hc.core5.reactor.InternalChannel
org.apache.hc.core5.reactor.InternalDataChannel
- All Implemented Interfaces:
Closeable,AutoCloseable,ByteChannel,Channel,ReadableByteChannel,WritableByteChannel,SocketModalCloseable,ModalCloseable,IOSession,ProtocolIOSession,TransportSecurityLayer,Identifiable
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.hc.core5.reactor.IOSession
IOSession.Status -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicBooleanprivate final Queue<InternalDataChannel> private final AtomicReference<IOSession> private final AtomicReference<IOEventHandler> private final NamedEndpointprivate final IOSessionprivate final ConcurrentMap<String, ProtocolUpgradeHandler> private final IOSessionListenerprivate final AtomicReference<SSLIOSession> -
Constructor Summary
ConstructorsConstructorDescriptionInternalDataChannel(IOSession ioSession, NamedEndpoint initialEndpoint, Decorator<IOSession> ioSessionDecorator, IOSessionListener sessionListener, Queue<InternalDataChannel> closedSessions) -
Method Summary
Modifier and TypeMethodDescriptionchannel()Returns the underlying I/O channel associated with this session.voidclearEvent(int op) Clears interest in a particular I/O event type by updating the event mask associated with the session.voidclose()Terminates the session gracefully and closes the underlying I/O channel.voidCloses this process or endpoint and releases any system resources associated with it.(package private) voidvoidenqueue(Command command, Command.Priority priority) InsertsCommandat the end of the command queue.private IOEventHandlerensureHandler(IOSession session) intReturns mask of I/O evens this session declared interest in.Returns event handler associated with the session.getId()longReturns timestamp of the last I/O event including socket timeout reset.longReturns timestamp of the last read event.longReturns timestamp of the last write event.Returns local address.getLock()Returns session lock that should be used by I/O event handlers to synchronize access to the session.Returns address of the remote peer.Returns value of the socket timeout in milliseconds.Returns status of the session:(package private) TimeoutReturns details of a fully established TLS session.booleanTests if there enqueued commands pending execution.booleanisOpen()(package private) voidonException(Exception cause) (package private) voidonIOEvent(int readyOps) (package private) void(package private) voidonTLSSessionEnd(SSLIOSession sslSession) (package private) voidonTLSSessionStart(SSLIOSession sslSession) poll()Removes firstCommandfrom the command queue if available.intread(ByteBuffer dst) voidregisterProtocol(String protocolId, ProtocolUpgradeHandler upgradeHandler) Registers protocol upgrade handler with the given application protocol ID.voidsetEvent(int op) Declares interest in a particular I/O event type by updating the event mask associated with the session.voidsetEventMask(int ops) Declares interest in I/O event notifications by setting the event mask associated with the sessionvoidsetSocketTimeout(Timeout timeout) Sets value of the socket timeout in milliseconds.voidstartTls(SSLContext sslContext, NamedEndpoint endpoint, SSLBufferMode sslBufferMode, SSLSessionInitializer initializer, SSLSessionVerifier verifier, Timeout handshakeTimeout) Starts TLS session over an existing network connection with the given SSL context.voidstartTls(SSLContext sslContext, NamedEndpoint endpoint, SSLBufferMode sslBufferMode, SSLSessionInitializer initializer, SSLSessionVerifier verifier, Timeout handshakeTimeout, FutureCallback<TransportSecurityLayer> callback) Starts TLS session over an existing network connection with the given SSL context.voidswitchProtocol(String protocolId, FutureCallback<ProtocolIOSession> callback) Switches this I/O session to the application protocol with the given ID.toString()voidUpdates the timestamp of the last read eventvoidUpdates the timestamp of the last write eventvoidupgrade(IOEventHandler handler) Upgrades event handler associated with the session.intwrite(ByteBuffer src) Methods inherited from class org.apache.hc.core5.reactor.InternalChannel
checkTimeout, handleIOEvent
-
Field Details
-
ioSession
-
initialEndpoint
-
ioSessionDecorator
-
sessionListener
-
closedSessions
-
tlsSessionRef
-
currentSessionRef
-
eventHandlerRef
-
protocolUpgradeHandlerMap
-
closed
-
-
Constructor Details
-
InternalDataChannel
InternalDataChannel(IOSession ioSession, NamedEndpoint initialEndpoint, Decorator<IOSession> ioSessionDecorator, IOSessionListener sessionListener, Queue<InternalDataChannel> closedSessions)
-
-
Method Details
-
getId
- Specified by:
getIdin interfaceIdentifiable
-
getInitialEndpoint
- Specified by:
getInitialEndpointin interfaceProtocolIOSession
-
getHandler
Description copied from interface:IOSessionReturns event handler associated with the session.- Specified by:
getHandlerin interfaceIOSession
-
upgrade
Description copied from interface:IOSessionUpgrades event handler associated with the session. -
ensureHandler
-
onIOEvent
- Specified by:
onIOEventin classInternalChannel- Throws:
IOException
-
getTimeout
Timeout getTimeout()- Specified by:
getTimeoutin classInternalChannel
-
onTimeout
- Specified by:
onTimeoutin classInternalChannel- Throws:
IOException
-
onException
- Specified by:
onExceptionin classInternalChannel
-
onTLSSessionStart
-
onTLSSessionEnd
-
disconnected
void disconnected() -
startTls
public void startTls(SSLContext sslContext, NamedEndpoint endpoint, SSLBufferMode sslBufferMode, SSLSessionInitializer initializer, SSLSessionVerifier verifier, Timeout handshakeTimeout) Description copied from interface:TransportSecurityLayerStarts TLS session over an existing network connection with the given SSL context.NamedEndpointdetails are applicable for client side connections and are used for host name verification, when supported by the SSL engine.- Specified by:
startTlsin interfaceTransportSecurityLayer- Parameters:
sslContext- SSL context to be used for this session.endpoint- optional endpoint details for outgoing client side connections.sslBufferMode- SSL buffer management mode.initializer- SSL session initialization callback.verifier- SSL session verification callback.handshakeTimeout- the timeout to use while performing the TLS handshake; may benull.
-
startTls
public void startTls(SSLContext sslContext, NamedEndpoint endpoint, SSLBufferMode sslBufferMode, SSLSessionInitializer initializer, SSLSessionVerifier verifier, Timeout handshakeTimeout, FutureCallback<TransportSecurityLayer> callback) Description copied from interface:TransportSecurityLayerStarts TLS session over an existing network connection with the given SSL context.NamedEndpointdetails are applicable for client side connections and are used for host name verification, when supported by the SSL engine.- Specified by:
startTlsin interfaceTransportSecurityLayer- Parameters:
sslContext- SSL context to be used for this session.endpoint- optional endpoint details for outgoing client side connections.sslBufferMode- SSL buffer management mode.initializer- SSL session initialization callback.verifier- SSL session verification callback.handshakeTimeout- the timeout to use while performing the TLS handshake; may benull.
-
getTlsDetails
Description copied from interface:TransportSecurityLayerReturns details of a fully established TLS session.- Specified by:
getTlsDetailsin interfaceTransportSecurityLayer- Returns:
- TLS session details.
-
getLock
Description copied from interface:IOSessionReturns session lock that should be used by I/O event handlers to synchronize access to the session. -
close
public void close()Description copied from interface:IOSessionTerminates the session gracefully and closes the underlying I/O channel. This method ensures that session termination handshake, such as the one used by the SSL/TLS protocol, is correctly carried out. -
close
Description copied from interface:ModalCloseableCloses this process or endpoint and releases any system resources associated with it. If the endpoint or the process is already closed then invoking this method has no effect.- Specified by:
closein interfaceModalCloseable- Parameters:
closeMode- How to close the receiver.
-
getStatus
Description copied from interface:IOSessionReturns status of the session:IOSession.Status.ACTIVE: session is active.IOSession.Status.CLOSING: session is being closed.IOSession.Status.CLOSED: session has been terminated. -
isOpen
public boolean isOpen() -
enqueue
Description copied from interface:IOSessionInsertsCommandat the end of the command queue. -
hasCommands
public boolean hasCommands()Description copied from interface:IOSessionTests if there enqueued commands pending execution.- Specified by:
hasCommandsin interfaceIOSession
-
poll
Description copied from interface:IOSessionRemoves firstCommandfrom the command queue if available. -
channel
Description copied from interface:IOSessionReturns the underlying I/O channel associated with this session. -
getRemoteAddress
Description copied from interface:IOSessionReturns address of the remote peer.- Specified by:
getRemoteAddressin interfaceIOSession- Returns:
- socket address.
-
getLocalAddress
Description copied from interface:IOSessionReturns local address.- Specified by:
getLocalAddressin interfaceIOSession- Returns:
- socket address.
-
getEventMask
public int getEventMask()Description copied from interface:IOSessionReturns mask of I/O evens this session declared interest in.- Specified by:
getEventMaskin interfaceIOSession- Returns:
- I/O event mask.
-
setEventMask
public void setEventMask(int ops) Description copied from interface:IOSessionDeclares interest in I/O event notifications by setting the event mask associated with the session- Specified by:
setEventMaskin interfaceIOSession- Parameters:
ops- new I/O event mask.
-
setEvent
public void setEvent(int op) Description copied from interface:IOSessionDeclares interest in a particular I/O event type by updating the event mask associated with the session. -
clearEvent
public void clearEvent(int op) Description copied from interface:IOSessionClears interest in a particular I/O event type by updating the event mask associated with the session.- Specified by:
clearEventin interfaceIOSession- Parameters:
op- I/O event type.
-
getSocketTimeout
Description copied from interface:IOSessionReturns value of the socket timeout in milliseconds. The value of0signifies the session cannot time out.- Specified by:
getSocketTimeoutin interfaceIOSession- Specified by:
getSocketTimeoutin interfaceSocketModalCloseable- Returns:
- socket timeout.
-
setSocketTimeout
Description copied from interface:IOSessionSets value of the socket timeout in milliseconds. The value of0signifies the session cannot time out.Please note this operation may affect the last event time.
- Specified by:
setSocketTimeoutin interfaceIOSession- Specified by:
setSocketTimeoutin interfaceSocketModalCloseable- Parameters:
timeout- socket timeout.- See Also:
-
read
- Specified by:
readin interfaceReadableByteChannel- Throws:
IOException
-
write
- Specified by:
writein interfaceWritableByteChannel- Throws:
IOException
-
updateReadTime
public void updateReadTime()Description copied from interface:IOSessionUpdates the timestamp of the last read event- Specified by:
updateReadTimein interfaceIOSession
-
updateWriteTime
public void updateWriteTime()Description copied from interface:IOSessionUpdates the timestamp of the last write event- Specified by:
updateWriteTimein interfaceIOSession
-
getLastReadTime
public long getLastReadTime()Description copied from interface:IOSessionReturns timestamp of the last read event.- Specified by:
getLastReadTimein interfaceIOSession- Returns:
- timestamp.
-
getLastWriteTime
public long getLastWriteTime()Description copied from interface:IOSessionReturns timestamp of the last write event.- Specified by:
getLastWriteTimein interfaceIOSession- Returns:
- timestamp.
-
getLastEventTime
public long getLastEventTime()Description copied from interface:IOSessionReturns timestamp of the last I/O event including socket timeout reset.- Specified by:
getLastEventTimein interfaceIOSession- Specified by:
getLastEventTimein classInternalChannel- Returns:
- timestamp.
- See Also:
-
switchProtocol
Description copied from interface:ProtocolIOSessionSwitches this I/O session to the application protocol with the given ID.- Specified by:
switchProtocolin interfaceProtocolIOSession- Parameters:
protocolId- the application protocol IDcallback- the result callback
-
registerProtocol
Description copied from interface:ProtocolIOSessionRegisters protocol upgrade handler with the given application protocol ID.- Specified by:
registerProtocolin interfaceProtocolIOSession- Parameters:
protocolId- the application protocol IDupgradeHandler- the upgrade handler.
-
toString
-