Class BIONetworkLayer
java.lang.Object
org.jenkinsci.remoting.protocol.NetworkLayer
org.jenkinsci.remoting.protocol.impl.BIONetworkLayer
- All Implemented Interfaces:
ProtocolLayer
,ProtocolLayer.Send
A
NetworkLayer
that uses a dedicated reader thread and runs on demand writer thread to manage I/O.- Since:
- 3.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jenkinsci.remoting.protocol.ProtocolLayer
ProtocolLayer.Recv, ProtocolLayer.Send
-
Field Summary
Fields inherited from interface org.jenkinsci.remoting.protocol.ProtocolLayer
EMPTY_BUFFER
-
Constructor Summary
ConstructorDescriptionBIONetworkLayer
(IOHub ioHub, ReadableByteChannel in, WritableByteChannel out) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Request the recv side to be closed.void
Notify the lower layer that it should close.boolean
Tracks if this layer is submitting data to be sent viaProtocolLayer.Send.doSend(ByteBuffer)
.void
start()
Starts this layer.protected void
write
(ByteBuffer data) SPI: Perform the actual write to the recipient.Methods inherited from class org.jenkinsci.remoting.protocol.NetworkLayer
acquire, doSend, getIoHub, init, isRecvOpen, newByteBufferQueue, onRead, onRecvClosed, release, stack
-
Constructor Details
-
BIONetworkLayer
Constructor.- Parameters:
ioHub
- our hub.in
- the source of data.out
- the sink for data.
-
-
Method Details
-
write
SPI: Perform the actual write to the recipient. This method should be non-blocking. The data should be enqueued and written in the order of calls to write()}.- Specified by:
write
in classNetworkLayer
- Parameters:
data
- the data received. Any data consumed from theByteBuffer
can be assumed as processed. Any data not consumed from theByteBuffer
will be the responsibility of the caller to resubmit in subsequent calls.- Throws:
IOException
- if something goes wrong
-
doCloseRecv
public void doCloseRecv()Request the recv side to be closed.- Specified by:
doCloseRecv
in classNetworkLayer
-
start
Starts this layer. All layers in the stack will be initialized before a call to this method. All lower layers in the stack will have been started before this layer is started.- Specified by:
start
in interfaceProtocolLayer
- Overrides:
start
in classNetworkLayer
- Throws:
IOException
- if something goes wrong.
-
doCloseSend
Notify the lower layer that it should close. Callers to this method are assumed to have already calledProtocolLayer.Recv.onRecvClosed(IOException)
for any upper layers.- Throws:
IOException
- if there was an error closing the lower layer.
-
isSendOpen
public boolean isSendOpen()Tracks if this layer is submitting data to be sent viaProtocolLayer.Send.doSend(ByteBuffer)
. Once this method returnsfalse
it must always returnfalse
and can be assumed to behave in this way.- Returns:
true
if submitting data to be sent viaProtocolLayer.Send.doSend(ByteBuffer)
.
-