Class AckFilterLayer
- java.lang.Object
-
- org.jenkinsci.remoting.protocol.FilterLayer
-
- org.jenkinsci.remoting.protocol.impl.AckFilterLayer
-
- All Implemented Interfaces:
ProtocolLayer
,ProtocolLayer.Recv
,ProtocolLayer.Send
public class AckFilterLayer extends FilterLayer
AFilterLayer
that ensures both sides will not proceed unless the acknowledgement has been sent and received by both sides.- 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
Constructors Constructor Description AckFilterLayer()
Default constructor.AckFilterLayer(String ack)
Constructor using a custom acknowledgement string.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doSend(ByteBuffer data)
SPI: Sends data to the lower layer.boolean
isRecvOpen()
Tracks if this layer is accepting received data viaProtocolLayer.Recv.onRecv(ByteBuffer)
.void
onRecv(ByteBuffer data)
SPI: Callback on data being received from the lower layer.void
onRecvClosed(IOException cause)
Callback on the lower layer's source of data being closed.void
start()
Starts this layer.-
Methods inherited from class org.jenkinsci.remoting.protocol.FilterLayer
abort, completed, doCloseSend, flushRecv, flushSend, init, isSendOpen, next, stack
-
-
-
-
Constructor Detail
-
AckFilterLayer
public AckFilterLayer()
Default constructor.
-
AckFilterLayer
public AckFilterLayer(String ack)
Constructor using a custom acknowledgement string.- Parameters:
ack
- the acknowledgement string.
-
-
Method Detail
-
start
public void start() throws IOException
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 classFilterLayer
- Throws:
IOException
- if something goes wrong.
-
onRecv
public void onRecv(@NonNull ByteBuffer data) throws IOException
SPI: Callback on data being received from the lower layer.- Specified by:
onRecv
in interfaceProtocolLayer.Recv
- Specified by:
onRecv
in classFilterLayer
- 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 there was an error during processing of the received data.
-
onRecvClosed
public void onRecvClosed(IOException cause) throws IOException
Callback on the lower layer's source of data being closed.- Specified by:
onRecvClosed
in interfaceProtocolLayer.Recv
- Overrides:
onRecvClosed
in classFilterLayer
- Parameters:
cause
- the cause of the lower layer being closed ornull
.- Throws:
IOException
- if there was an error during the processing of the close notification.
-
isRecvOpen
public boolean isRecvOpen()
Tracks if this layer is accepting received data viaProtocolLayer.Recv.onRecv(ByteBuffer)
. Once this method returnsfalse
it must always returnfalse
and can be assumed to behave in this way.- Specified by:
isRecvOpen
in interfaceProtocolLayer.Recv
- Overrides:
isRecvOpen
in classFilterLayer
- Returns:
true
if accepting received data viaProtocolLayer.Recv.onRecv(ByteBuffer)
.
-
doSend
public void doSend(@NonNull ByteBuffer data) throws IOException
SPI: Sends data to the lower layer.- Specified by:
doSend
in interfaceProtocolLayer.Send
- Specified by:
doSend
in classFilterLayer
- Parameters:
data
- the data to send. 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 there was an error during processing of the data.
-
-