Package zmq.io
Class StreamEngine
- java.lang.Object
-
- zmq.io.StreamEngine
-
- All Implemented Interfaces:
IEngine
,IPollEvents
public class StreamEngine extends java.lang.Object implements IEngine, IPollEvents
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StreamEngine.ErrorReason
private class
StreamEngine.ProducePongMessage
private static class
StreamEngine.Protocol
-
Field Summary
Fields Modifier and Type Field Description private Function<Msg,java.lang.Boolean>
decodeAndPush
private IDecoder
decoder
private IEncoder
encoder
private java.lang.String
endpoint
private Errno
errno
private java.nio.channels.SocketChannel
fd
private java.nio.ByteBuffer
greetingRecv
private java.nio.ByteBuffer
greetingSend
private int
greetingSize
private Poller.Handle
handle
private static int
HANDSHAKE_TIMER_ID
private boolean
handshaking
private boolean
hasHandshakeTimer
private boolean
hasHeartbeatTimer
private boolean
hasTimeoutTimer
private boolean
hasTtlTimer
private static int
HEARTBEAT_IVL_TIMER_ID
private static int
HEARTBEAT_TIMEOUT_TIMER_ID
private static int
HEARTBEAT_TTL_TIMER_ID
private byte[]
heartbeatContext
private int
heartbeatTimeout
private java.nio.ByteBuffer
inpos
private boolean
inputStopped
private int
insize
private boolean
ioError
private IOObject
ioObject
private Mechanism
mechanism
private Metadata
metadata
private Supplier<Msg>
nextHandshakeCommand
private Supplier<Msg>
nextIdentity
private Supplier<Msg>
nextMsg
private Options
options
private ValueReference<java.nio.ByteBuffer>
outpos
private boolean
outputStopped
private int
outsize
private Address
peerAddress
private boolean
plugged
private Function<Msg,java.lang.Boolean>
processHandshakeCommand
private Function<Msg,java.lang.Boolean>
processIdentity
private Function<Msg,java.lang.Boolean>
processMsg
private Supplier<Msg>
producePingMessage
private Supplier<Msg>
pullAndEncode
private Supplier<Msg>
pullMsgFromSession
private Function<Msg,java.lang.Boolean>
pushMsgToSession
private Function<Msg,java.lang.Boolean>
pushOneThenDecodeAndPush
private Function<Msg,java.lang.Boolean>
pushRawMsgToSession
private SessionBase
session
private static int
SIGNATURE_SIZE
private SocketBase
socket
private boolean
subscriptionRequired
private static int
V2_GREETING_SIZE
private static int
V3_GREETING_SIZE
private Function<Msg,java.lang.Boolean>
writeCredential
private StreamEngine.Protocol
zmtpVersion
-
Constructor Summary
Constructors Constructor Description StreamEngine(java.nio.channels.SocketChannel fd, Options options, java.lang.String endpoint)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
decodeAndPush(Msg msg)
private boolean
decodeCurrentInputs()
private void
decodeDataAfterHandshake(int greetingSize)
void
destroy()
private void
error(StreamEngine.ErrorReason error)
private boolean
handshake()
private int
heartbeatTimeout()
private Msg
identityMsg()
void
inEvent()
Called by I/O thread when file descriptor is ready for reading.private <T> T
instantiate(java.lang.Class<T> clazz, int size, long max)
private void
mechanismReady()
private Msg
nextHandshakeCommand()
void
outEvent()
Called by I/O thread when file descriptor is ready for writing.void
plug(IOThread ioThread, SessionBase session)
private boolean
processCommand(Msg msg)
private boolean
processHandshakeCommand(Msg msg)
private boolean
processHeartbeatMessage(Msg msg)
private boolean
processIdentityMsg(Msg msg)
private Msg
producePingMessage()
private Msg
producePongMessage(byte[] pingContext)
private Msg
pullAndEncode()
private Msg
pullMsgFromSession()
private boolean
pushMsgToSession(Msg msg)
private boolean
pushOneThenDecodeAndPush(Msg msg)
private boolean
pushRawMsgToSession(Msg msg)
private int
read(java.nio.ByteBuffer buf)
void
restartInput()
void
restartOutput()
private void
setHandshakeTimer()
void
terminate()
void
timerEvent(int id)
Called when timer expires.java.lang.String
toString()
private void
unplug()
private int
write(java.nio.ByteBuffer outbuf)
private boolean
writeCredential(Msg msg)
void
zapMsgAvailable()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface zmq.poll.IPollEvents
acceptEvent, connectEvent
-
-
-
-
Field Detail
-
ioObject
private IOObject ioObject
-
fd
private java.nio.channels.SocketChannel fd
-
handle
private Poller.Handle handle
-
inpos
private java.nio.ByteBuffer inpos
-
insize
private int insize
-
decoder
private IDecoder decoder
-
outpos
private final ValueReference<java.nio.ByteBuffer> outpos
-
outsize
private int outsize
-
encoder
private IEncoder encoder
-
metadata
private Metadata metadata
-
handshaking
private boolean handshaking
-
SIGNATURE_SIZE
private static final int SIGNATURE_SIZE
- See Also:
- Constant Field Values
-
V2_GREETING_SIZE
private static final int V2_GREETING_SIZE
- See Also:
- Constant Field Values
-
V3_GREETING_SIZE
private static final int V3_GREETING_SIZE
- See Also:
- Constant Field Values
-
greetingSize
private int greetingSize
-
greetingRecv
private final java.nio.ByteBuffer greetingRecv
-
greetingSend
private final java.nio.ByteBuffer greetingSend
-
zmtpVersion
private StreamEngine.Protocol zmtpVersion
-
session
private SessionBase session
-
options
private final Options options
-
endpoint
private final java.lang.String endpoint
-
plugged
private boolean plugged
-
ioError
private boolean ioError
-
subscriptionRequired
private boolean subscriptionRequired
-
mechanism
private Mechanism mechanism
-
inputStopped
private boolean inputStopped
-
outputStopped
private boolean outputStopped
-
HANDSHAKE_TIMER_ID
private static final int HANDSHAKE_TIMER_ID
- See Also:
- Constant Field Values
-
HEARTBEAT_TTL_TIMER_ID
private static final int HEARTBEAT_TTL_TIMER_ID
- See Also:
- Constant Field Values
-
HEARTBEAT_IVL_TIMER_ID
private static final int HEARTBEAT_IVL_TIMER_ID
- See Also:
- Constant Field Values
-
HEARTBEAT_TIMEOUT_TIMER_ID
private static final int HEARTBEAT_TIMEOUT_TIMER_ID
- See Also:
- Constant Field Values
-
hasHandshakeTimer
private boolean hasHandshakeTimer
-
hasTtlTimer
private boolean hasTtlTimer
-
hasTimeoutTimer
private boolean hasTimeoutTimer
-
hasHeartbeatTimer
private boolean hasHeartbeatTimer
-
heartbeatTimeout
private final int heartbeatTimeout
-
heartbeatContext
private final byte[] heartbeatContext
-
socket
private SocketBase socket
-
peerAddress
private final Address peerAddress
-
errno
private final Errno errno
-
-
Constructor Detail
-
StreamEngine
public StreamEngine(java.nio.channels.SocketChannel fd, Options options, java.lang.String endpoint)
-
-
Method Detail
-
heartbeatTimeout
private int heartbeatTimeout()
-
destroy
public void destroy()
-
plug
public void plug(IOThread ioThread, SessionBase session)
-
instantiate
private <T> T instantiate(java.lang.Class<T> clazz, int size, long max)
-
unplug
private void unplug()
-
inEvent
public void inEvent()
Description copied from interface:IPollEvents
Called by I/O thread when file descriptor is ready for reading.- Specified by:
inEvent
in interfaceIPollEvents
-
outEvent
public void outEvent()
Description copied from interface:IPollEvents
Called by I/O thread when file descriptor is ready for writing.- Specified by:
outEvent
in interfaceIPollEvents
-
restartOutput
public void restartOutput()
- Specified by:
restartOutput
in interfaceIEngine
-
restartInput
public void restartInput()
- Specified by:
restartInput
in interfaceIEngine
-
decodeCurrentInputs
private boolean decodeCurrentInputs()
-
handshake
private boolean handshake()
-
decodeDataAfterHandshake
private void decodeDataAfterHandshake(int greetingSize)
-
identityMsg
private Msg identityMsg()
-
processIdentityMsg
private boolean processIdentityMsg(Msg msg)
-
nextHandshakeCommand
private Msg nextHandshakeCommand()
-
processHandshakeCommand
private boolean processHandshakeCommand(Msg msg)
-
zapMsgAvailable
public void zapMsgAvailable()
- Specified by:
zapMsgAvailable
in interfaceIEngine
-
mechanismReady
private void mechanismReady()
-
pullMsgFromSession
private Msg pullMsgFromSession()
-
pushMsgToSession
private boolean pushMsgToSession(Msg msg)
-
pushRawMsgToSession
private boolean pushRawMsgToSession(Msg msg)
-
writeCredential
private boolean writeCredential(Msg msg)
-
pullAndEncode
private Msg pullAndEncode()
-
decodeAndPush
private boolean decodeAndPush(Msg msg)
-
pushOneThenDecodeAndPush
private boolean pushOneThenDecodeAndPush(Msg msg)
-
error
private void error(StreamEngine.ErrorReason error)
-
setHandshakeTimer
private void setHandshakeTimer()
-
timerEvent
public void timerEvent(int id)
Description copied from interface:IPollEvents
Called when timer expires.- Specified by:
timerEvent
in interfaceIPollEvents
- Parameters:
id
- the ID of the expired timer.
-
producePingMessage
private Msg producePingMessage()
-
producePongMessage
private Msg producePongMessage(byte[] pingContext)
-
processCommand
private boolean processCommand(Msg msg)
-
processHeartbeatMessage
private boolean processHeartbeatMessage(Msg msg)
-
write
private int write(java.nio.ByteBuffer outbuf)
-
read
private int read(java.nio.ByteBuffer buf)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-