Class GridNioSessionImpl
- java.lang.Object
-
- org.apache.ignite.internal.util.nio.GridNioSessionImpl
-
- All Implemented Interfaces:
GridNioSession
- Direct Known Subclasses:
GridSelectorNioSessionImpl
public class GridNioSessionImpl extends Object implements GridNioSession
-
-
Constructor Summary
Constructors Constructor Description GridNioSessionImpl(GridNioFilterChain filterChain, @Nullable InetSocketAddress locAddr, @Nullable InetSocketAddress rmtAddr, boolean accepted)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccepted()<T> TaddMeta(int key, T val)Adds metadata associated with specified key.longbytesReceived()Gets the total count of bytes received since the session was created.voidbytesReceived(int cnt)Adds given amount ob bytes to the received bytes counter.longbytesReceived0()longbytesSent()Gets the total count of bytes sent since the session was created.voidbytesSent(int cnt)Adds given amount of bytes to the sent bytes counter.longbytesSent0()Certificate[]certificates()protected <T> GridNioFilterChain<T>chain()GridNioFuture<Boolean>close()Performs a request for asynchronous session close.booleanclosed()longcloseTime()If session is closed, this method will return session close time returned bySystem.currentTimeMillis().longcreateTime()Gets the time when the session was created.@Nullable GridNioRecoveryDescriptorinRecoveryDescriptor()voidinRecoveryDescriptor(GridNioRecoveryDescriptor recoveryDesc)longlastReceiveTime()Returns the time when last read activity was performed on this session.longlastSendScheduleTime()Returns time when last send was scheduled on this session.longlastSendTime()Returns time when last send activity was performed on this session.@Nullable InetSocketAddresslocalAddress()Gets local address of this session.<T> Tmeta(int key)Gets metadata associated with specified key.@Nullable GridNioRecoveryDescriptoroutRecoveryDescriptor()voidoutRecoveryDescriptor(GridNioRecoveryDescriptor recoveryDesc)GridNioFuture<?>pauseReads()Pauses reads.booleanreadsPaused()Checks whether reads are paused.voidreadsPaused(boolean readsPaused)@Nullable InetSocketAddressremoteAddress()Gets address of remote peer on this session.<T> TremoveMeta(int key)Removes metadata with the specified key.voidreset0()voidresetSendScheduleTime()Resets send schedule time to avoid multiple idle notifications.GridNioFuture<?>resumeReads()Resumes session reads.GridNioFuture<?>send(Object msg)Performs a request for asynchronous data send.voidsendNoFuture(Object msg, IgniteInClosure<IgniteException> ackC)booleansetClosed()Atomically moves this session into a closed state.voidsystemMessage(Object msg)StringtoString()
-
-
-
Constructor Detail
-
GridNioSessionImpl
public GridNioSessionImpl(GridNioFilterChain filterChain, @Nullable @Nullable InetSocketAddress locAddr, @Nullable @Nullable InetSocketAddress rmtAddr, boolean accepted)
- Parameters:
filterChain- Chain.locAddr- Local address.rmtAddr- Remote address.accepted-Trueif this session was initiated from remote host.
-
-
Method Detail
-
send
public GridNioFuture<?> send(Object msg)
Performs a request for asynchronous data send.- Specified by:
sendin interfaceGridNioSession- Parameters:
msg- Message to be sent. This message will be eventually passed in to a parser plugged to the nio server.- Returns:
- Future representing result.
-
sendNoFuture
public void sendNoFuture(Object msg, IgniteInClosure<IgniteException> ackC) throws IgniteCheckedException
- Specified by:
sendNoFuturein interfaceGridNioSession- Parameters:
msg- Message to be sent.ackC- Optional closure invoked when ack for message is received.- Throws:
IgniteCheckedException- If failed.
-
resumeReads
public GridNioFuture<?> resumeReads()
Resumes session reads.- Specified by:
resumeReadsin interfaceGridNioSession- Returns:
- Future representing result.
-
pauseReads
public GridNioFuture<?> pauseReads()
Pauses reads.- Specified by:
pauseReadsin interfaceGridNioSession- Returns:
- Future representing result.
-
close
public GridNioFuture<Boolean> close()
Performs a request for asynchronous session close.- Specified by:
closein interfaceGridNioSession- Returns:
- Future representing result.
-
localAddress
@Nullable public @Nullable InetSocketAddress localAddress()
Gets local address of this session.- Specified by:
localAddressin interfaceGridNioSession- Returns:
- Local network address or
nullif non-socket communication is used.
-
remoteAddress
@Nullable public @Nullable InetSocketAddress remoteAddress()
Gets address of remote peer on this session.- Specified by:
remoteAddressin interfaceGridNioSession- Returns:
- Address of remote peer or
nullif non-socket communication is used.
-
bytesSent
public long bytesSent()
Gets the total count of bytes sent since the session was created.- Specified by:
bytesSentin interfaceGridNioSession- Returns:
- Total count of bytes sent.
-
bytesReceived
public long bytesReceived()
Gets the total count of bytes received since the session was created.- Specified by:
bytesReceivedin interfaceGridNioSession- Returns:
- Total count of bytes received.
-
bytesSent0
public long bytesSent0()
- Returns:
- Sent bytes since last NIO sessions balancing.
-
bytesReceived0
public long bytesReceived0()
- Returns:
- Received bytes since last NIO sessions balancing.
-
reset0
public void reset0()
-
createTime
public long createTime()
Gets the time when the session was created.- Specified by:
createTimein interfaceGridNioSession- Returns:
- Time when this session was created returned by
System.currentTimeMillis().
-
closeTime
public long closeTime()
If session is closed, this method will return session close time returned bySystem.currentTimeMillis(). If session is not closed, this method will return0.- Specified by:
closeTimein interfaceGridNioSession- Returns:
- Session close time.
-
lastReceiveTime
public long lastReceiveTime()
Returns the time when last read activity was performed on this session.- Specified by:
lastReceiveTimein interfaceGridNioSession- Returns:
- Lats receive time.
-
lastSendTime
public long lastSendTime()
Returns time when last send activity was performed on this session.- Specified by:
lastSendTimein interfaceGridNioSession- Returns:
- Last send time.
-
lastSendScheduleTime
public long lastSendScheduleTime()
Returns time when last send was scheduled on this session.- Specified by:
lastSendScheduleTimein interfaceGridNioSession- Returns:
- Last send schedule time.
-
meta
public <T> T meta(int key)
Gets metadata associated with specified key.- Specified by:
metain interfaceGridNioSession- Parameters:
key- Key to look up.- Returns:
- Associated meta object or
nullif meta was not found.
-
addMeta
public <T> T addMeta(int key, @Nullable T val)Adds metadata associated with specified key.- Specified by:
addMetain interfaceGridNioSession- Parameters:
key- Metadata Key.val- Metadata value.- Returns:
- Previously associated object or
nullif no objects were associated.
-
removeMeta
public <T> T removeMeta(int key)
Removes metadata with the specified key.- Specified by:
removeMetain interfaceGridNioSession- Parameters:
key- Metadata key.- Returns:
- Object that was associated with the key or
null.
-
accepted
public boolean accepted()
- Specified by:
acceptedin interfaceGridNioSession- Returns:
Trueif this connection was initiated from remote node.
-
certificates
public Certificate[] certificates()
- Specified by:
certificatesin interfaceGridNioSession- Returns:
- Client SSL certificates
-
chain
protected <T> GridNioFilterChain<T> chain()
- Type Parameters:
T- Chain type.- Returns:
- Filter chain.
-
bytesSent
public void bytesSent(int cnt)
Adds given amount of bytes to the sent bytes counter.Note that this method is designed to be called in one thread only.
- Parameters:
cnt- Number of bytes sent.
-
bytesReceived
public void bytesReceived(int cnt)
Adds given amount ob bytes to the received bytes counter.Note that this method is designed to be called in one thread only.
- Parameters:
cnt- Number of bytes received.
-
resetSendScheduleTime
public void resetSendScheduleTime()
Resets send schedule time to avoid multiple idle notifications.
-
setClosed
public boolean setClosed()
Atomically moves this session into a closed state.- Returns:
Trueif session was moved to a closed state,falseif session was already closed.
-
closed
public boolean closed()
- Returns:
Trueif this session was closed.
-
readsPaused
public void readsPaused(boolean readsPaused)
- Parameters:
readsPaused- New reads paused flag.
-
readsPaused
public boolean readsPaused()
Description copied from interface:GridNioSessionChecks whether reads are paused.- Specified by:
readsPausedin interfaceGridNioSession- Returns:
- Reads paused flag.
-
outRecoveryDescriptor
public void outRecoveryDescriptor(GridNioRecoveryDescriptor recoveryDesc)
- Specified by:
outRecoveryDescriptorin interfaceGridNioSession- Parameters:
recoveryDesc- Recovery descriptor.
-
outRecoveryDescriptor
@Nullable public @Nullable GridNioRecoveryDescriptor outRecoveryDescriptor()
- Specified by:
outRecoveryDescriptorin interfaceGridNioSession- Returns:
- Recovery descriptor if recovery is supported,
null otherwise.
-
inRecoveryDescriptor
public void inRecoveryDescriptor(GridNioRecoveryDescriptor recoveryDesc)
- Specified by:
inRecoveryDescriptorin interfaceGridNioSession- Parameters:
recoveryDesc- Recovery descriptor.
-
inRecoveryDescriptor
@Nullable public @Nullable GridNioRecoveryDescriptor inRecoveryDescriptor()
- Specified by:
inRecoveryDescriptorin interfaceGridNioSession- Returns:
- Recovery descriptor if recovery is supported,
null otherwise.
-
systemMessage
public void systemMessage(Object msg)
- Specified by:
systemMessagein interfaceGridNioSession- Parameters:
msg- System message to send.
-
-