public class EngineStreamSession extends StreamSession implements IEngineStreamSession
IEngine
interface.Constructor and Description |
---|
EngineStreamSession(IEngine engine,
IStreamHandler handler,
ILogger logger)
Constructs a stream-oriented session associated with a protocol
engine and a handler.
|
EngineStreamSession(String name,
IEngine engine,
IStreamHandler handler,
ILogger logger)
Constructs a named stream-oriented session associated with a protocol
engine and a handler.
|
Modifier and Type | Method and Description |
---|---|
ByteBuffer |
allocate(int capacity)
Allocates a byte buffer by using the allocator associated with this session.
|
void |
beginHandshake()
Initiates handshaking (initial or renegotiation) on the protocol engine
driving this session.
|
void |
beginLazyHandshake()
Initiates lazy handshaking (initial or renegotiation) on the protocol
engine driving this session.
|
void |
close()
Gently closes this session after all pending data waiting for writing are fully flushed.
|
void |
dirtyClose()
Quickly closes this session without flushing any pending data and without following
close procedure of an application layer (e.g.
|
IFuture<Void> |
getCloseFuture()
Gets the future that can be use to wait for the completion of the closing
phase.
|
ICodecPipeline |
getCodecPipeline()
Gets the codec pipeline that is associated with this session.
|
ISessionConfig |
getConfig()
Gets the configuration of this session.
|
IFuture<Void> |
getCreateFuture()
Gets the future that can be use to wait for the completion of the
creation phase.
|
long |
getCreationTime()
Gets the session's creation time in milliseconds.
|
IFuture<Void> |
getEndFuture()
Gets the future that can be use to wait for the completion of the ending
phase.
|
Object |
getEngineSession()
Returns an object representing a session in the protocol engine driving this
session.
|
Executor |
getExecutor()
Returns the executor that is used to execute delegated tasks
required by this session to complete operations that block, or may take
an extended period of time to complete.
|
IStreamHandler |
getHandler()
Gets the stream-oriented handler associated with this session
|
long |
getLastIoTime()
Gets the time in milliseconds when I/O operation occurred lastly.
|
long |
getLastReadTime()
Gets the time in milliseconds when read operation occurred lastly.
|
long |
getLastWriteTime()
Gets the time in milliseconds when write operation occurred lastly.
|
IFuture<Void> |
getOpenFuture()
Gets the future that can be use to wait for the completion of the opening
phase.
|
long |
getReadBytes()
Gets the total number of bytes which were read from this session.
|
double |
getReadBytesThroughput()
Gets the number of read bytes per second.
|
IFuture<Void> |
getReadyFuture()
Gets the future that can be use to wait for the completion of the ready
phase.
|
SessionState |
getState()
Gets the current state of this session.
|
ISessionTimer |
getTimer()
Gets the session timer associated with this session.
|
long |
getWrittenBytes()
Gets the total number of bytes which were written to this session.
|
double |
getWrittenBytesThroughput()
Gets the number of written bytes per second.
|
boolean |
isOpen()
Tells if this session is open.
|
boolean |
isReadSuspended()
Tells if read operations are suspended for this session.
|
boolean |
isWriteSuspended()
Tells if write operations are suspended for this session.
|
void |
quickClose()
Quickly closes this session without flushing any pending data.
|
void |
release(ByteBuffer buffer)
Release given byte buffer by the allocator associated with this session.
|
void |
resumeRead()
Resumes read operations for this session.
|
void |
resumeWrite()
Resumes write operations for this session.
|
void |
setExecutor(Executor executor)
Sets the executor that will be used to execute delegated tasks required
by this session to complete operations that block, or may take an
extended period of time to complete.
|
void |
suspendRead()
Suspends read operations for this session.
|
void |
suspendWrite()
Suspends write operations for this session.
|
IFuture<Void> |
write(byte[] data)
Writes
data.length bytes from the specified byte array
to the stream-oriented channel associated with this session. |
IFuture<Void> |
write(byte[] data,
int offset,
int length)
Writes
length bytes from the specified byte array
to the stream-oriented channel associated with this session. |
IFuture<Void> |
write(ByteBuffer data)
Writes
data.remaining() bytes from the specified
byte buffer to the stream-oriented channel associated with
this session. |
IFuture<Void> |
write(ByteBuffer data,
int length)
Writes
length bytes from the specified byte buffer
to the stream-oriented channel associated with this session. |
void |
writenf(byte[] data)
Writes
data.length bytes from the specified byte array
to the stream-oriented channel associated with this session. |
void |
writenf(byte[] data,
int offset,
int length)
Writes
length bytes from the specified byte array
to the stream-oriented channel associated with this session. |
void |
writenf(ByteBuffer data)
Writes
data.remaining() bytes from the specified
byte buffer to the stream-oriented channel associated with
this session. |
void |
writenf(ByteBuffer data,
int length)
Writes
length bytes from the specified byte buffer
to the stream-oriented channel associated with this session. |
getLocalAddress, getParent, getRemoteAddress, write, writenf
getAttributes
getId, getName, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getParent, write, writenf
allocate, getAttributes, getCloseFuture, getCodecPipeline, getConfig, getCreateFuture, getCreationTime, getEndFuture, getId, getLastIoTime, getLastReadTime, getLastWriteTime, getLocalAddress, getName, getOpenFuture, getReadBytes, getReadBytesThroughput, getReadyFuture, getRemoteAddress, getState, getTimer, getWrittenBytes, getWrittenBytesThroughput, isOpen, isReadSuspended, isWriteSuspended, release, resumeRead, resumeWrite, suspendRead, suspendWrite
public EngineStreamSession(String name, IEngine engine, IStreamHandler handler, ILogger logger)
name
- the name for this session, or null
if the
handler's name should be used for this session's nameengine
- the protocol engine driving this sessionhandler
- the handler that should be associated with this sessionlogger
- the logger used to log messages related with this sessionpublic EngineStreamSession(IEngine engine, IStreamHandler handler, ILogger logger)
engine
- the protocol engine driving this sessionhandler
- the handler that should be associated with this sessionlogger
- the logger used to log messages related with this sessionpublic void setExecutor(Executor executor)
IEngineSession
setExecutor
in interface IEngineSession
executor
- the new executor, or null
to use the executor
configured in the selector loop that handles this session.public Executor getExecutor()
IEngineSession
By default, this method returns the executor configured in the selector
loop that handles this session, or null
.
getExecutor
in interface IEngineSession
null
if the executor is
undefined (i.e. the session is not associated with the selector
loop and the executor is not set)public void beginHandshake()
IEngineSession
This method is not needed for the initial handshake, as the wrap
and
unwrap
methods of the protocol engine should initiate it if the
handshaking has not already begun.
The operation is asynchronous.
beginHandshake
in interface IEngineSession
public void beginLazyHandshake()
IEngineSession
write
,
writenf
, beginHandshake
.
This method is not needed for the initial handshake, as the
wrap
and unwrap
methods of the protocol engine
should initiate it if the handshaking has not already begun.
The operation is asynchronous.
beginLazyHandshake
in interface IEngineSession
public Object getEngineSession()
IEngineSession
getEngineSession
in interface IEngineSession
public IStreamHandler getHandler()
IStreamSession
getHandler
in interface ISession
getHandler
in interface IStreamSession
getHandler
in class StreamSession
public IFuture<Void> write(byte[] data)
IStreamSession
data.length
bytes from the specified byte array
to the stream-oriented channel associated with this session.
The operation is asynchronous.
write
in interface IStreamSession
write
in class StreamSession
data
- bytes to be writtenpublic void writenf(byte[] data)
IStreamSession
data.length
bytes from the specified byte array
to the stream-oriented channel associated with this session.
The operation is asynchronous.
This method should be used whenever there will be no need to synchronize on a future object. This will save some resources and may improve performance.
writenf
in interface IStreamSession
writenf
in class StreamSession
data
- bytes to be writtenpublic IFuture<Void> write(byte[] data, int offset, int length)
IStreamSession
length
bytes from the specified byte array
to the stream-oriented channel associated with this session.
The operation is asynchronous.
write
in interface IStreamSession
write
in class StreamSession
data
- bytes to be writtenoffset
- offset within the array of the first byte to be writtenlength
- number of bytes to be writtenpublic void writenf(byte[] data, int offset, int length)
IStreamSession
length
bytes from the specified byte array
to the stream-oriented channel associated with this session.
The operation is asynchronous.
This method should be used whenever there will be no need to synchronize on a future object. This will save some resources and may improve performance.
writenf
in interface IStreamSession
writenf
in class StreamSession
data
- bytes to be writtenoffset
- offset within the array of the first byte to be writtenlength
- number of bytes to be writtenpublic IFuture<Void> write(ByteBuffer data)
IStreamSession
data.remaining()
bytes from the specified
byte buffer to the stream-oriented channel associated with
this session.
The operation is asynchronous.
write
in interface IStreamSession
write
in class StreamSession
data
- bytes to be writtenpublic void writenf(ByteBuffer data)
IStreamSession
data.remaining()
bytes from the specified
byte buffer to the stream-oriented channel associated with
this session.
The operation is asynchronous.
This method should be used whenever there will be no need to synchronize on a future object. This will save some resources and may improve performance.
writenf
in interface IStreamSession
writenf
in class StreamSession
data
- bytes to be writtenpublic IFuture<Void> write(ByteBuffer data, int length)
IStreamSession
length
bytes from the specified byte buffer
to the stream-oriented channel associated with this session.
The operation is asynchronous.
write
in interface IStreamSession
write
in class StreamSession
data
- bytes to be writtenlength
- number of bytes to be writtenpublic void writenf(ByteBuffer data, int length)
IStreamSession
length
bytes from the specified byte buffer
to the stream-oriented channel associated with this session.
The operation is asynchronous.
This method should be used whenever there will be no need to synchronize on a future object. This will save some resources and may improve performance.
writenf
in interface IStreamSession
writenf
in class StreamSession
data
- bytes to be writtenlength
- number of bytes to be writtenpublic void close()
ISession
After returning from this method any consecutive writes will be simply discarded.
close
in interface ISession
close
in class StreamSession
public void quickClose()
ISession
After returning from this method any consecutive writes will be simply discarded.
quickClose
in interface ISession
public void dirtyClose()
ISession
dirtyClose
in interface ISession
public IFuture<Void> getCreateFuture()
ISession
getCreateFuture
in interface ISession
public IFuture<Void> getOpenFuture()
ISession
getOpenFuture
in interface ISession
public IFuture<Void> getReadyFuture()
ISession
getReadyFuture
in interface ISession
public IFuture<Void> getCloseFuture()
ISession
getCloseFuture
in interface ISession
public IFuture<Void> getEndFuture()
ISession
getEndFuture
in interface ISession
public ISessionConfig getConfig()
ISession
public ICodecPipeline getCodecPipeline()
ISession
getCodecPipeline
in interface ISession
null
if the session does not
support itpublic SessionState getState()
ISession
public boolean isOpen()
ISession
It is equal to:
return getState() == SessionState.OPEN
public void suspendRead()
ISession
suspendRead
in interface ISession
public void suspendWrite()
ISession
suspendWrite
in interface ISession
public void resumeRead()
ISession
resumeRead
in interface ISession
public void resumeWrite()
ISession
resumeWrite
in interface ISession
public boolean isReadSuspended()
ISession
isReadSuspended
in interface ISession
true
if suspendedpublic boolean isWriteSuspended()
ISession
isWriteSuspended
in interface ISession
true
if suspendedpublic final long getReadBytes()
ISession
getReadBytes
in interface ISession
public final long getWrittenBytes()
ISession
getWrittenBytes
in interface ISession
public final double getReadBytesThroughput()
ISession
getReadBytesThroughput
in interface ISession
public final double getWrittenBytesThroughput()
ISession
getWrittenBytesThroughput
in interface ISession
public final long getCreationTime()
ISession
getCreationTime
in interface ISession
public final long getLastIoTime()
ISession
getLastIoTime
in interface ISession
public final long getLastReadTime()
ISession
getLastReadTime
in interface ISession
public final long getLastWriteTime()
ISession
getLastWriteTime
in interface ISession
public ISessionTimer getTimer()
ISession
public ByteBuffer allocate(int capacity)
ISession
public void release(ByteBuffer buffer)
ISession
Copyright © 2017–2021 SNF4J.ORG. All rights reserved.