Top Description Inners Methods
org.apache.hc.core5.reactor

public Interface IOSession

extends ByteChannel, SocketModalCloseable, Identifiable
Known Direct Subinterfaces
org.apache.hc.core5.reactor.ProtocolIOSession
Known Direct Implementers
org.apache.hc.core5.reactor.IOSessionImpl, org.apache.hc.core5.reactor.ssl.SSLIOSession
Annotations
@Internal
Imports
java.net.SocketAddress, java.nio.channels.ByteChannel, java.util.concurrent.locks.Lock, org.apache.hc.core5.annotation.Internal, org.apache.hc.core5.http.SocketModalCloseable, org.apache.hc.core5.util.Identifiable, .Timeout

IOSession interface represents a sequence of logically related data exchanges between two end points.

The channel associated with implementations of this interface can be used to read data from and write data to the session.

I/O sessions are not bound to an execution thread, therefore one cannot use the context of the thread to store a session's state. All details about a particular session must be stored within the session itself, usually using execution context associated with it.

Implementations of this interface are expected to be threading safe.

Since
4.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
IOSession.Status

This enum represents a set of states I/O session transitions through during its life-span.

Method Summary

Modifier and TypeMethod and Description
public ByteChannel

Returns:

the I/O channel.
channel
()

Returns the underlying I/O channel associated with this session.

public void
clearEvent(int
I/O event type.
op
)

Clears interest in a particular I/O event type by updating the event mask associated with the session.

public void
close()

Redeclares java.nio.channels.Channel.close, java.io.Closeable.close.

Terminates the session gracefully and closes the underlying I/O channel.
public void
enqueue(Command command, Command.Priority priority)

Inserts Command at the end of the command queue.

public int

Returns:

I/O event mask.
getEventMask
()

Returns mask of I/O evens this session declared interest in.

public IOEventHandler
getHandler()

Returns event handler associated with the session.

public long

Returns:

timestamp.
getLastEventTime
()

Returns timestamp of the last I/O event including socket timeout reset.

public long

Returns:

timestamp.
getLastReadTime
()

Returns timestamp of the last read event.

public long

Returns:

timestamp.
getLastWriteTime
()

Returns timestamp of the last write event.

public SocketAddress

Returns:

socket address.
getLocalAddress
()

Returns local address.

public Lock
getLock()

Returns session lock that should be used by I/O event handlers to synchronize access to the session.

public SocketAddress

Returns:

socket address.
getRemoteAddress
()

Returns address of the remote peer.

public Timeout

Returns:

socket timeout.
getSocketTimeout
()

Redeclares org.apache.hc.core5.http.SocketModalCloseable.getSocketTimeout.

Returns value of the socket timeout in milliseconds.
public IOSession.Status

Returns:

session status.
getStatus
()

Returns status of the session:

Status#ACTIVE: session is active.

public boolean
hasCommands()

Tests if there enqueued commands pending execution.

public Command
poll()

Removes first Command from the command queue if available.

public void
setEvent(int
I/O event type.
op
)

Declares interest in a particular I/O event type by updating the event mask associated with the session.

public void
setEventMask(int
new I/O event mask.
ops
)

Declares interest in I/O event notifications by setting the event mask associated with the session

public void
setSocketTimeout(Timeout
socket timeout.
timeout
)

Redeclares org.apache.hc.core5.http.SocketModalCloseable.setSocketTimeout.

Sets value of the socket timeout in milliseconds.
public void
updateReadTime()

Updates the timestamp of the last read event

public void
updateWriteTime()

Updates the timestamp of the last write event

public void
upgrade(IOEventHandler handler)

Upgrades event handler associated with the session.

Inherited from org.apache.hc.core5.util.Identifiable:
getId

Method Detail

channelback to summary
public ByteChannel channel()

Returns the underlying I/O channel associated with this session.

Returns:ByteChannel

the I/O channel.

clearEventback to summary
public void clearEvent(int op)

Clears interest in a particular I/O event type by updating the event mask associated with the session.

Parameters
op:int

I/O event type.

closeback to summary
public void close()

Redeclares java.nio.channels.Channel.close, java.io.Closeable.close.

Terminates 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.

Annotations
@Override
enqueueback to summary
public void enqueue(Command command, Command.Priority priority)

Inserts Command at the end of the command queue.

Since
5.0
getEventMaskback to summary
public int getEventMask()

Returns mask of I/O evens this session declared interest in.

Returns:int

I/O event mask.

getHandlerback to summary
public IOEventHandler getHandler()

Returns event handler associated with the session.

Since
5.0
getLastEventTimeback to summary
public long getLastEventTime()

Returns timestamp of the last I/O event including socket timeout reset.

Returns:long

timestamp.

See Also
getSocketTimeout()
getLastReadTimeback to summary
public long getLastReadTime()

Returns timestamp of the last read event.

Returns:long

timestamp.

getLastWriteTimeback to summary
public long getLastWriteTime()

Returns timestamp of the last write event.

Returns:long

timestamp.

getLocalAddressback to summary
public SocketAddress getLocalAddress()

Returns local address.

Returns:SocketAddress

socket address.

getLockback to summary
public Lock getLock()

Returns session lock that should be used by I/O event handlers to synchronize access to the session.

Since
5.0
getRemoteAddressback to summary
public SocketAddress getRemoteAddress()

Returns address of the remote peer.

Returns:SocketAddress

socket address.

getSocketTimeoutback to summary
public Timeout getSocketTimeout()

Redeclares org.apache.hc.core5.http.SocketModalCloseable.getSocketTimeout.

Returns value of the socket timeout in milliseconds. The value of 0 signifies the session cannot time out.

Returns:Timeout

socket timeout.

Annotations
@Override
getStatusback to summary
public IOSession.Status getStatus()

Returns status of the session:

Status#ACTIVE: session is active.

Status#CLOSING: session is being closed.

Status#CLOSED: session has been terminated.

Returns:IOSession.Status

session status.

hasCommandsback to summary
public boolean hasCommands()

Tests if there enqueued commands pending execution.

Since
5.0
pollback to summary
public Command poll()

Removes first Command from the command queue if available.

Since
5.0
setEventback to summary
public void setEvent(int op)

Declares interest in a particular I/O event type by updating the event mask associated with the session.

Parameters
op:int

I/O event type.

setEventMaskback to summary
public void setEventMask(int ops)

Declares interest in I/O event notifications by setting the event mask associated with the session

Parameters
ops:int

new I/O event mask.

setSocketTimeoutback to summary
public void setSocketTimeout(Timeout timeout)

Redeclares org.apache.hc.core5.http.SocketModalCloseable.setSocketTimeout.

Sets value of the socket timeout in milliseconds. The value of 0 signifies the session cannot time out.

Please note this operation may affect the last event time.

Parameters
timeout:Timeout

socket timeout.

Annotations
@Override
See Also
getLastEventTime()
updateReadTimeback to summary
public void updateReadTime()

Updates the timestamp of the last read event

updateWriteTimeback to summary
public void updateWriteTime()

Updates the timestamp of the last write event

upgradeback to summary
public void upgrade(IOEventHandler handler)

Upgrades event handler associated with the session.

Since
5.0
org.apache.hc.core5.reactor back to summary

public final Enum IOSession.Status

extends Enum<IOSession.Status>
Class Inheritance

This enum represents a set of states I/O session transitions through during its life-span.

Field Summary

Modifier and TypeField and Description
public static final IOSession.Status
public static final IOSession.Status
public static final IOSession.Status

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static IOSession.Status
public static IOSession.Status[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ACTIVEback to summary
public static final IOSession.Status ACTIVE
CLOSEDback to summary
public static final IOSession.Status CLOSED
CLOSINGback to summary
public static final IOSession.Status CLOSING

Constructor Detail

Statusback to summary
private Status()

Method Detail

valueOfback to summary
public static IOSession.Status valueOf(String name)
valuesback to summary
public static IOSession.Status[] values()