Top Fields Constructors Methods
org.apache.hc.client5.http.impl.async

pack-priv Class LoggingIOSession

extends Object
implements IOSession
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.reactor.IOSession, org.apache.hc.core5.util.Identifiable, org.apache.hc.core5.http.SocketModalCloseable, org.apache.hc.core5.io.ModalCloseable, java.io.Closeable, java.lang.AutoCloseable, java.nio.channels.ByteChannel, java.nio.channels.WritableByteChannel, java.nio.channels.Channel, java.nio.channels.ReadableByteChannel
Imports
java.io.IOException, java.net.SocketAddress, java.nio.ByteBuffer, java.nio.channels.ByteChannel, .SelectionKey, java.util.concurrent.locks.Lock, org.apache.hc.core5.http.Chars, org.apache.hc.core5.io.CloseMode, org.apache.hc.core5.reactor.Command, .IOEventHandler, .IOSession, org.apache.hc.core5.util.Args, .Timeout, org.slf4j.Logger

Field Summary

Modifier and TypeField and Description
private final Logger
private final IOSession
private final Logger

Constructor Summary

AccessConstructor and Description
public
LoggingIOSession(final IOSession session, final Logger log, final Logger wireLog)

Method Summary

Modifier and TypeMethod and Description
public ByteChannel
channel()

Implements org.apache.hc.core5.reactor.IOSession.channel.

Returns the underlying I/O channel associated with this session.
public void
clearEvent(final int
I/O event type.
op
)

Implements org.apache.hc.core5.reactor.IOSession.clearEvent.

Clears interest in a particular I/O event type by updating the event mask associated with the session.
public void
close()

Implements org.apache.hc.core5.reactor.IOSession.close.

Terminates the session gracefully and closes the underlying I/O channel.
public void
close(final CloseMode
How to close the receiver.
closeMode
)

Implements org.apache.hc.core5.io.ModalCloseable.close.

Closes this process or endpoint and releases any system resources associated with it.
public void
enqueue(final Command command, final Command.Priority priority)

Implements org.apache.hc.core5.reactor.IOSession.enqueue.

Inserts Command at the end of the command queue.
private static String
formatOps(final int ops)

public int
getEventMask()

Implements org.apache.hc.core5.reactor.IOSession.getEventMask.

Returns mask of I/O evens this session declared interest in.
public IOEventHandler
getHandler()

Implements org.apache.hc.core5.reactor.IOSession.getHandler.

Returns event handler associated with the session.
public String
public long
getLastEventTime()

Implements org.apache.hc.core5.reactor.IOSession.getLastEventTime.

Returns timestamp of the last I/O event including socket timeout reset.
public long
getLastReadTime()

Implements org.apache.hc.core5.reactor.IOSession.getLastReadTime.

Returns timestamp of the last read event.
public long
getLastWriteTime()

Implements org.apache.hc.core5.reactor.IOSession.getLastWriteTime.

Returns timestamp of the last write event.
public SocketAddress
public Lock
getLock()

Implements org.apache.hc.core5.reactor.IOSession.getLock.

Returns session lock that should be used by I/O event handlers to synchronize access to the session.
public SocketAddress
getRemoteAddress()

Implements org.apache.hc.core5.reactor.IOSession.getRemoteAddress.

Returns address of the remote peer.
public Timeout
getSocketTimeout()

Implements org.apache.hc.core5.reactor.IOSession.getSocketTimeout.

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

Implements org.apache.hc.core5.reactor.IOSession.getStatus.

Returns status of the session:

Status#ACTIVE: session is active.

public boolean
hasCommands()

Implements org.apache.hc.core5.reactor.IOSession.hasCommands.

Tests if there enqueued commands pending execution.
public boolean
isOpen()

Implements java.nio.channels.Channel.isOpen.

Tells whether or not this channel is open.
private void
logData(final ByteBuffer data, final String prefix)

public Command
poll()

Implements org.apache.hc.core5.reactor.IOSession.poll.

Removes first Command from the command queue if available.
public int
read(final ByteBuffer
The buffer into which bytes are to be transferred
dst
)

Implements java.nio.channels.ReadableByteChannel.read.

Reads a sequence of bytes from this channel into the given buffer.
public void
setEvent(final int
I/O event type.
op
)

Implements org.apache.hc.core5.reactor.IOSession.setEvent.

Declares interest in a particular I/O event type by updating the event mask associated with the session.
public void
setEventMask(final int
new I/O event mask.
ops
)

Implements org.apache.hc.core5.reactor.IOSession.setEventMask.

Declares interest in I/O event notifications by setting the event mask associated with the session
public void
setSocketTimeout(final Timeout
socket timeout.
timeout
)

Implements org.apache.hc.core5.reactor.IOSession.setSocketTimeout.

Sets value of the socket timeout in milliseconds.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
updateReadTime()

Implements org.apache.hc.core5.reactor.IOSession.updateReadTime.

Updates the timestamp of the last read event
public void
updateWriteTime()

Implements org.apache.hc.core5.reactor.IOSession.updateWriteTime.

Updates the timestamp of the last write event
public void
upgrade(final IOEventHandler handler)

Implements org.apache.hc.core5.reactor.IOSession.upgrade.

Upgrades event handler associated with the session.
public int
write(final ByteBuffer
The buffer from which bytes are to be retrieved
src
)

Implements java.nio.channels.WritableByteChannel.write.

Writes a sequence of bytes to this channel from the given buffer.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

logback to summary
private final Logger log
sessionback to summary
private final IOSession session
wireLogback to summary
private final Logger wireLog

Constructor Detail

LoggingIOSessionback to summary
public LoggingIOSession(final IOSession session, final Logger log, final Logger wireLog)

Method Detail

channelback to summary
public ByteChannel channel()

Implements org.apache.hc.core5.reactor.IOSession.channel.

Doc from org.apache.hc.core5.reactor.IOSession.channel.

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

Returns:ByteChannel

the I/O channel.

Annotations
@Override
clearEventback to summary
public void clearEvent(final int op)

Implements org.apache.hc.core5.reactor.IOSession.clearEvent.

Doc from org.apache.hc.core5.reactor.IOSession.clearEvent.

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.

Annotations
@Override
closeback to summary
public void close()

Implements org.apache.hc.core5.reactor.IOSession.close.

Doc from org.apache.hc.core5.reactor.IOSession.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
closeback to summary
public void close(final CloseMode closeMode)

Implements org.apache.hc.core5.io.ModalCloseable.close.

Doc from org.apache.hc.core5.io.ModalCloseable.close.

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

Parameters
closeMode:CloseMode

How to close the receiver.

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

Implements org.apache.hc.core5.reactor.IOSession.enqueue.

Doc from org.apache.hc.core5.reactor.IOSession.enqueue.

Inserts Command at the end of the command queue.

Annotations
@Override
formatOpsback to summary
private static String formatOps(final int ops)
getEventMaskback to summary
public int getEventMask()

Implements org.apache.hc.core5.reactor.IOSession.getEventMask.

Doc from org.apache.hc.core5.reactor.IOSession.getEventMask.

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

Returns:int

I/O event mask.

Annotations
@Override
getHandlerback to summary
public IOEventHandler getHandler()

Implements org.apache.hc.core5.reactor.IOSession.getHandler.

Doc from org.apache.hc.core5.reactor.IOSession.getHandler.

Returns event handler associated with the session.

Annotations
@Override
getIdback to summary
public String getId()

Implements org.apache.hc.core5.util.Identifiable.getId.

Annotations
@Override
getLastEventTimeback to summary
public long getLastEventTime()

Implements org.apache.hc.core5.reactor.IOSession.getLastEventTime.

Doc from org.apache.hc.core5.reactor.IOSession.getLastEventTime.

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

Returns:long

timestamp.

Annotations
@Override
getLastReadTimeback to summary
public long getLastReadTime()

Implements org.apache.hc.core5.reactor.IOSession.getLastReadTime.

Doc from org.apache.hc.core5.reactor.IOSession.getLastReadTime.

Returns timestamp of the last read event.

Returns:long

timestamp.

Annotations
@Override
getLastWriteTimeback to summary
public long getLastWriteTime()

Implements org.apache.hc.core5.reactor.IOSession.getLastWriteTime.

Doc from org.apache.hc.core5.reactor.IOSession.getLastWriteTime.

Returns timestamp of the last write event.

Returns:long

timestamp.

Annotations
@Override
getLocalAddressback to summary
public SocketAddress getLocalAddress()

Implements org.apache.hc.core5.reactor.IOSession.getLocalAddress.

Doc from org.apache.hc.core5.reactor.IOSession.getLocalAddress.

Returns local address.

Returns:SocketAddress

socket address.

Annotations
@Override
getLockback to summary
public Lock getLock()

Implements org.apache.hc.core5.reactor.IOSession.getLock.

Doc from org.apache.hc.core5.reactor.IOSession.getLock.

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

Annotations
@Override
getRemoteAddressback to summary
public SocketAddress getRemoteAddress()

Implements org.apache.hc.core5.reactor.IOSession.getRemoteAddress.

Doc from org.apache.hc.core5.reactor.IOSession.getRemoteAddress.

Returns address of the remote peer.

Returns:SocketAddress

socket address.

Annotations
@Override
getSocketTimeoutback to summary
public Timeout getSocketTimeout()

Implements org.apache.hc.core5.reactor.IOSession.getSocketTimeout.

Doc from org.apache.hc.core5.reactor.IOSession.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()

Implements org.apache.hc.core5.reactor.IOSession.getStatus.

Doc from org.apache.hc.core5.reactor.IOSession.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.

Annotations
@Override
hasCommandsback to summary
public boolean hasCommands()

Implements org.apache.hc.core5.reactor.IOSession.hasCommands.

Doc from org.apache.hc.core5.reactor.IOSession.hasCommands.

Tests if there enqueued commands pending execution.

Annotations
@Override
isOpenback to summary
public boolean isOpen()

Implements java.nio.channels.Channel.isOpen.

Doc from java.nio.channels.Channel.isOpen.

Tells whether or not this channel is open.

Returns:boolean

true if, and only if, this channel is open

Annotations
@Override
logDataback to summary
private void logData(final ByteBuffer data, final String prefix) throws IOException
pollback to summary
public Command poll()

Implements org.apache.hc.core5.reactor.IOSession.poll.

Doc from org.apache.hc.core5.reactor.IOSession.poll.

Removes first Command from the command queue if available.

Annotations
@Override
readback to summary
public int read(final ByteBuffer dst) throws IOException

Implements java.nio.channels.ReadableByteChannel.read.

Doc from java.nio.channels.ReadableByteChannel.read.

Reads a sequence of bytes from this channel into the given buffer.

An attempt is made to read up to r bytes from the channel, where r is the number of bytes remaining in the buffer, that is, dst.remaining(), at the moment this method is invoked.

Suppose that a byte sequence of length n is read, where 0 <= n <= r. This byte sequence will be transferred into the buffer so that the first byte in the sequence is at index p and the last byte is at index p + n - 1, where p is the buffer's position at the moment this method is invoked. Upon return the buffer's position will be equal to p + n; its limit will not have changed.

A read operation might not fill the buffer, and in fact it might not read any bytes at all. Whether or not it does so depends upon the nature and state of the channel. A socket channel in non-blocking mode, for example, cannot read any more bytes than are immediately available from the socket's input buffer; similarly, a file channel cannot read any more bytes than remain in the file. It is guaranteed, however, that if a channel is in blocking mode and there is at least one byte remaining in the buffer then this method will block until at least one byte is read.

This method may be invoked at any time. If another thread has already initiated a read operation upon this channel, however, then an invocation of this method will block until the first operation is complete.

Parameters
dst:ByteBuffer

The buffer into which bytes are to be transferred

Returns:int

The number of bytes read, possibly zero, or -1 if the channel has reached end-of-stream

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
setEventback to summary
public void setEvent(final int op)

Implements org.apache.hc.core5.reactor.IOSession.setEvent.

Doc from org.apache.hc.core5.reactor.IOSession.setEvent.

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.

Annotations
@Override
setEventMaskback to summary
public void setEventMask(final int ops)

Implements org.apache.hc.core5.reactor.IOSession.setEventMask.

Doc from org.apache.hc.core5.reactor.IOSession.setEventMask.

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

Parameters
ops:int

new I/O event mask.

Annotations
@Override
setSocketTimeoutback to summary
public void setSocketTimeout(final Timeout timeout)

Implements org.apache.hc.core5.reactor.IOSession.setSocketTimeout.

Doc from org.apache.hc.core5.reactor.IOSession.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
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
updateReadTimeback to summary
public void updateReadTime()

Implements org.apache.hc.core5.reactor.IOSession.updateReadTime.

Doc from org.apache.hc.core5.reactor.IOSession.updateReadTime.

Updates the timestamp of the last read event

Annotations
@Override
updateWriteTimeback to summary
public void updateWriteTime()

Implements org.apache.hc.core5.reactor.IOSession.updateWriteTime.

Doc from org.apache.hc.core5.reactor.IOSession.updateWriteTime.

Updates the timestamp of the last write event

Annotations
@Override
upgradeback to summary
public void upgrade(final IOEventHandler handler)

Implements org.apache.hc.core5.reactor.IOSession.upgrade.

Doc from org.apache.hc.core5.reactor.IOSession.upgrade.

Upgrades event handler associated with the session.

Annotations
@Override
writeback to summary
public int write(final ByteBuffer src) throws IOException

Implements java.nio.channels.WritableByteChannel.write.

Doc from java.nio.channels.WritableByteChannel.write.

Writes a sequence of bytes to this channel from the given buffer.

An attempt is made to write up to r bytes to the channel, where r is the number of bytes remaining in the buffer, that is, src.remaining(), at the moment this method is invoked.

Suppose that a byte sequence of length n is written, where 0 <= n <= r. This byte sequence will be transferred from the buffer starting at index p, where p is the buffer's position at the moment this method is invoked; the index of the last byte written will be p + n - 1. Upon return the buffer's position will be equal to p + n; its limit will not have changed.

Unless otherwise specified, a write operation will return only after writing all of the r requested bytes. Some types of channels, depending upon their state, may write only some of the bytes or possibly none at all. A socket channel in non-blocking mode, for example, cannot write any more bytes than are free in the socket's output buffer.

This method may be invoked at any time. If another thread has already initiated a write operation upon this channel, however, then an invocation of this method will block until the first operation is complete.

Parameters
src:ByteBuffer

The buffer from which bytes are to be retrieved

Returns:int

The number of bytes written, possibly zero

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs