Top Description Fields Constructors Methods
io.rsocket.loadbalance

public Class WeightedStatsRequestInterceptor

extends BaseWeightedStats
implements RequestInterceptor
Class Inheritance
All Implemented Interfaces
io.rsocket.plugins.RequestInterceptor, reactor.core.Disposable
Imports
io.netty.buffer.ByteBuf, io.rsocket.frame.FrameType, io.rsocket.plugins.RequestInterceptor, reactor.util.annotation.Nullable

RequestInterceptor that hooks into request lifecycle and calls methods of the parent class to manage tracking state and expose WeightedStats.

This interceptor the default mechanism for gathering stats when WeightedLoadbalanceStrategy is used with LoadbalanceRSocketClient.

Since
1.1
See Also
LoadbalanceRSocketClient, WeightedLoadbalanceStrategy

Field Summary

Modifier and TypeField and Description
pack-priv final Int2LongHashMap

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

Implements reactor.core.Disposable.dispose.

Cancel or dispose the underlying task or resource.
public final void
onCancel(int
used by this request
streamId
,
FrameType requestType)

Implements io.rsocket.plugins.RequestInterceptor.onCancel.

Method which is being invoked once a successfully accepted request is cancelled.
public final void
onReject(Throwable
exception which causes rejection of a particular request
rejectionReason
,
FrameType requestType, ByteBuf
taken from the initial frame
metadata
)

Implements io.rsocket.plugins.RequestInterceptor.onReject.

Method which is being invoked on the request rejection.
public final void
onStart(int
used for the request
streamId
,
FrameType requestType, ByteBuf
taken from the initial frame
metadata
)

Implements io.rsocket.plugins.RequestInterceptor.onStart.

Method which is being invoked on successful acceptance and start of a request.
public final void
onTerminate(int
used by this request
streamId
,
FrameType requestType, Throwable
with which this finished has terminated. Must be one of the following signals
t
)

Implements io.rsocket.plugins.RequestInterceptor.onTerminate.

Method which is being invoked once a successfully accepted request is terminated.
Inherited from io.rsocket.loadbalance.BaseWeightedStats:
higherQuantileLatencyinstantaneouslowerQuantileLatencypendingpredictedLatencyrecordstartRequeststartStreamstopRequeststopStreamtoStringupdateAvailabilityweightedAvailability

Field Detail

requestsStartTimeback to summary
pack-priv final Int2LongHashMap requestsStartTime

Constructor Detail

WeightedStatsRequestInterceptorback to summary
public WeightedStatsRequestInterceptor()

Method Detail

disposeback to summary
public void dispose()

Implements reactor.core.Disposable.dispose.

Doc from reactor.core.Disposable.dispose.

Cancel or dispose the underlying task or resource.

Implementations are required to make this method idempotent.

Annotations
@Override
onCancelback to summary
public final void onCancel(int streamId, FrameType requestType)

Implements io.rsocket.plugins.RequestInterceptor.onCancel.

Doc from io.rsocket.plugins.RequestInterceptor.onCancel.

Method which is being invoked once a successfully accepted request is cancelled. This method can be invoked only after the onStart(int, FrameType, ByteBuf) method. This method is exclusive with onTerminate(int, FrameType, Throwable).

Parameters
streamId:int

used by this request

requestType:FrameType

of the request. Must be one of the following types FrameType#REQUEST_FNF, FrameType#REQUEST_RESPONSE, FrameType#REQUEST_STREAM or FrameType#REQUEST_CHANNEL

Annotations
@Override
onRejectback to summary
public final void onReject(Throwable rejectionReason, FrameType requestType, ByteBuf metadata)

Implements io.rsocket.plugins.RequestInterceptor.onReject.

Doc from io.rsocket.plugins.RequestInterceptor.onReject.

Method which is being invoked on the request rejection. This method is being called only if the actual request can not be started and is called instead of the onStart(int, FrameType, ByteBuf) method. The reason for rejection can be one of the following:

  • No available io.rsocket.lease.Lease on the requester or the responder sides
  • Invalid io.rsocket.Payload size or format on the Requester side, so the request is being rejected before the actual streamId is generated
  • A second subscription on the ongoing Request
Parameters
rejectionReason:Throwable

exception which causes rejection of a particular request

requestType:FrameType

of the request. Must be one of the following types FrameType#REQUEST_FNF, FrameType#REQUEST_RESPONSE, FrameType#REQUEST_STREAM or FrameType#REQUEST_CHANNEL

metadata:ByteBuf

taken from the initial frame

Annotations
@Override
onStartback to summary
public final void onStart(int streamId, FrameType requestType, ByteBuf metadata)

Implements io.rsocket.plugins.RequestInterceptor.onStart.

Doc from io.rsocket.plugins.RequestInterceptor.onStart.

Method which is being invoked on successful acceptance and start of a request.

Parameters
streamId:int

used for the request

requestType:FrameType

of the request. Must be one of the following types FrameType#REQUEST_FNF, FrameType#REQUEST_RESPONSE, FrameType#REQUEST_STREAM or FrameType#REQUEST_CHANNEL

metadata:ByteBuf

taken from the initial frame

Annotations
@Override
onTerminateback to summary
public final void onTerminate(int streamId, FrameType requestType, Throwable t)

Implements io.rsocket.plugins.RequestInterceptor.onTerminate.

Doc from io.rsocket.plugins.RequestInterceptor.onTerminate.

Method which is being invoked once a successfully accepted request is terminated. This method can be invoked only after the onStart(int, FrameType, ByteBuf) method. This method is exclusive with onCancel(int, FrameType).

Parameters
streamId:int

used by this request

requestType:FrameType

of the request. Must be one of the following types FrameType#REQUEST_FNF, FrameType#REQUEST_RESPONSE, FrameType#REQUEST_STREAM or FrameType#REQUEST_CHANNEL

t:Throwable

with which this finished has terminated. Must be one of the following signals

Annotations
@Override