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
ConstructorsConstructorDescriptionBIONetworkLayer(IOHub ioHub, ReadableByteChannel in, WritableByteChannel out) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidRequest the recv side to be closed.voidNotify the lower layer that it should close.booleanTracks if this layer is submitting data to be sent viaProtocolLayer.Send.doSend(ByteBuffer).voidstart()Starts this layer.protected voidwrite(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:
writein classNetworkLayer- Parameters:
data- the data received. Any data consumed from theByteBuffercan be assumed as processed. Any data not consumed from theByteBufferwill 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:
doCloseRecvin 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:
startin interfaceProtocolLayer- Overrides:
startin 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 returnsfalseit must always returnfalseand can be assumed to behave in this way.- Returns:
trueif submitting data to be sent viaProtocolLayer.Send.doSend(ByteBuffer).
-