Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrates weighted loadbalance strategy to user new RequestInterceptors for Stats tracking #946

Merged
merged 2 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Specify extra profilers:
Prominent profilers (for full list call `jmhProfilers` task):
- comp - JitCompilations, tune your iterations
- stack - which methods used most time
- gc - print garbage collection stats
- gc - print garbage collection defaultWeightedStats
- hs_thr - thread usage

Change report format from JSON to one of [CSV, JSON, NONE, SCSV, TEXT]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void subscribe(CoreSubscriber<? super Void> actual) {
p.release();

if (interceptor != null) {
interceptor.onCancel(streamId);
interceptor.onCancel(streamId, FrameType.REQUEST_FNF);
}

return;
Expand All @@ -153,7 +153,7 @@ public void subscribe(CoreSubscriber<? super Void> actual) {
lazyTerminate(STATE, this);

if (interceptor != null) {
interceptor.onTerminate(streamId, e);
interceptor.onTerminate(streamId, FrameType.REQUEST_FNF, e);
}

actual.onError(e);
Expand All @@ -163,7 +163,7 @@ public void subscribe(CoreSubscriber<? super Void> actual) {
lazyTerminate(STATE, this);

if (interceptor != null) {
interceptor.onTerminate(streamId, null);
interceptor.onTerminate(streamId, FrameType.REQUEST_FNF, null);
}

actual.onComplete();
Expand Down Expand Up @@ -262,7 +262,7 @@ public Void block() {
lazyTerminate(STATE, this);

if (interceptor != null) {
interceptor.onTerminate(streamId, e);
interceptor.onTerminate(streamId, FrameType.REQUEST_FNF, e);
}

throw Exceptions.propagate(e);
Expand All @@ -271,7 +271,7 @@ public Void block() {
lazyTerminate(STATE, this);

if (interceptor != null) {
interceptor.onTerminate(streamId, null);
interceptor.onTerminate(streamId, FrameType.REQUEST_FNF, null);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.netty.util.ReferenceCountUtil;
import io.rsocket.Payload;
import io.rsocket.RSocket;
import io.rsocket.frame.FrameType;
import io.rsocket.frame.decoder.PayloadDecoder;
import io.rsocket.plugins.RequestInterceptor;
import org.reactivestreams.Subscription;
Expand Down Expand Up @@ -101,7 +102,7 @@ public void onNext(Void voidVal) {}
public void onError(Throwable t) {
final RequestInterceptor requestInterceptor = this.requestInterceptor;
if (requestInterceptor != null) {
requestInterceptor.onTerminate(this.streamId, t);
requestInterceptor.onTerminate(this.streamId, FrameType.REQUEST_FNF, t);
}

logger.debug("Dropped Outbound error", t);
Expand All @@ -111,7 +112,7 @@ public void onError(Throwable t) {
public void onComplete() {
final RequestInterceptor requestInterceptor = this.requestInterceptor;
if (requestInterceptor != null) {
requestInterceptor.onTerminate(this.streamId, null);
requestInterceptor.onTerminate(this.streamId, FrameType.REQUEST_FNF, null);
}
}

Expand All @@ -131,7 +132,7 @@ public void handleNext(ByteBuf followingFrame, boolean hasFollows, boolean isLas

final RequestInterceptor requestInterceptor = this.requestInterceptor;
if (requestInterceptor != null) {
requestInterceptor.onTerminate(streamId, t);
requestInterceptor.onTerminate(streamId, FrameType.REQUEST_FNF, t);
}

logger.debug("Reassembly has failed", t);
Expand All @@ -151,7 +152,7 @@ public void handleNext(ByteBuf followingFrame, boolean hasFollows, boolean isLas

final RequestInterceptor requestInterceptor = this.requestInterceptor;
if (requestInterceptor != null) {
requestInterceptor.onTerminate(this.streamId, t);
requestInterceptor.onTerminate(this.streamId, FrameType.REQUEST_FNF, t);
}

logger.debug("Reassembly has failed", t);
Expand All @@ -175,7 +176,7 @@ public final void handleCancel() {

final RequestInterceptor requestInterceptor = this.requestInterceptor;
if (requestInterceptor != null) {
requestInterceptor.onCancel(streamId);
requestInterceptor.onCancel(streamId, FrameType.REQUEST_FNF);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ void sendFirstPayload(Payload firstPayload, long initialRequestN) {
this.inboundDone = true;

if (requestInterceptor != null) {
requestInterceptor.onTerminate(streamId, t);
requestInterceptor.onTerminate(streamId, FrameType.REQUEST_CHANNEL, t);
}

this.inboundSubscriber.onError(t);
Expand All @@ -281,7 +281,7 @@ void sendFirstPayload(Payload firstPayload, long initialRequestN) {
connection.sendFrame(streamId, cancelFrame);

if (requestInterceptor != null) {
requestInterceptor.onCancel(streamId);
requestInterceptor.onCancel(streamId, FrameType.REQUEST_CHANNEL);
}
return;
}
Expand Down Expand Up @@ -364,7 +364,7 @@ void propagateErrorSafely(Throwable t) {
if (!this.inboundDone) {
final RequestInterceptor interceptor = requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(this.streamId, t);
interceptor.onTerminate(this.streamId, FrameType.REQUEST_CHANNEL, t);
}

this.inboundDone = true;
Expand All @@ -386,7 +386,7 @@ public final void cancel() {

final RequestInterceptor requestInterceptor = this.requestInterceptor;
if (requestInterceptor != null) {
requestInterceptor.onCancel(this.streamId);
requestInterceptor.onCancel(this.streamId, FrameType.REQUEST_CHANNEL);
}
}

Expand Down Expand Up @@ -449,7 +449,7 @@ public void onError(Throwable t) {
synchronized (this) {
final RequestInterceptor interceptor = requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(streamId, t);
interceptor.onTerminate(streamId, FrameType.REQUEST_CHANNEL, t);
}

this.inboundDone = true;
Expand Down Expand Up @@ -492,7 +492,7 @@ public void onComplete() {
if (isInboundTerminated) {
final RequestInterceptor interceptor = requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(streamId, null);
interceptor.onTerminate(streamId, FrameType.REQUEST_CHANNEL, null);
}
}
}
Expand All @@ -515,7 +515,7 @@ public final void handleComplete() {

final RequestInterceptor interceptor = requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(streamId, null);
interceptor.onTerminate(streamId, FrameType.REQUEST_CHANNEL, null);
}
}

Expand All @@ -538,7 +538,7 @@ public final void handleError(Throwable cause) {
} else if (isInboundTerminated(previousState)) {
final RequestInterceptor interceptor = this.requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(this.streamId, cause);
interceptor.onTerminate(this.streamId, FrameType.REQUEST_CHANNEL, cause);
}

Operators.onErrorDropped(cause, this.inboundSubscriber.currentContext());
Expand All @@ -555,7 +555,7 @@ public final void handleError(Throwable cause) {

final RequestInterceptor interceptor = requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(streamId, cause);
interceptor.onTerminate(streamId, FrameType.REQUEST_CHANNEL, cause);
}

this.inboundSubscriber.onError(cause);
Expand Down Expand Up @@ -599,7 +599,7 @@ public void handleCancel() {
if (inboundTerminated) {
final RequestInterceptor interceptor = requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(this.streamId, null);
interceptor.onTerminate(this.streamId, FrameType.REQUEST_CHANNEL, null);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public void cancel() {
if (isOutboundTerminated) {
final RequestInterceptor interceptor = requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(streamId, null);
interceptor.onTerminate(streamId, FrameType.REQUEST_CHANNEL, null);
}
}
}
Expand All @@ -337,7 +337,7 @@ public final void handleCancel() {

final RequestInterceptor interceptor = this.requestInterceptor;
if (interceptor != null) {
interceptor.onCancel(this.streamId);
interceptor.onCancel(this.streamId, FrameType.REQUEST_CHANNEL);
}
return;
}
Expand All @@ -349,7 +349,7 @@ public final void handleCancel() {

final RequestInterceptor interceptor = this.requestInterceptor;
if (interceptor != null) {
interceptor.onCancel(this.streamId);
interceptor.onCancel(this.streamId, FrameType.REQUEST_CHANNEL);
}
}

Expand Down Expand Up @@ -464,7 +464,7 @@ public final void handleError(Throwable t) {

final RequestInterceptor interceptor = requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(this.streamId, t);
interceptor.onTerminate(this.streamId, FrameType.REQUEST_CHANNEL, t);
}
}

Expand All @@ -490,7 +490,7 @@ public void handleComplete() {
if (isOutboundTerminated) {
final RequestInterceptor interceptor = this.requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(this.streamId, null);
interceptor.onTerminate(this.streamId, FrameType.REQUEST_CHANNEL, null);
}
}
}
Expand All @@ -514,7 +514,7 @@ public void handleNext(ByteBuf frame, boolean hasFollows, boolean isLastPayload)
} else if (isOutboundTerminated(previousState)) {
final RequestInterceptor interceptor = this.requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(this.streamId, t);
interceptor.onTerminate(this.streamId, FrameType.REQUEST_CHANNEL, t);
}

Operators.onErrorDropped(t, this.inboundSubscriber.currentContext());
Expand All @@ -530,7 +530,7 @@ public void handleNext(ByteBuf frame, boolean hasFollows, boolean isLastPayload)

final RequestInterceptor interceptor = requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(streamId, t);
interceptor.onTerminate(streamId, FrameType.REQUEST_CHANNEL, t);
}
return;
}
Expand Down Expand Up @@ -572,7 +572,7 @@ public void handleNext(ByteBuf frame, boolean hasFollows, boolean isLastPayload)
} else if (isOutboundTerminated(previousState)) {
final RequestInterceptor interceptor = this.requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(this.streamId, e);
interceptor.onTerminate(this.streamId, FrameType.REQUEST_CHANNEL, e);
}

Operators.onErrorDropped(e, this.inboundSubscriber.currentContext());
Expand All @@ -591,7 +591,7 @@ public void handleNext(ByteBuf frame, boolean hasFollows, boolean isLastPayload)

final RequestInterceptor interceptor = this.requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(streamId, e);
interceptor.onTerminate(streamId, FrameType.REQUEST_CHANNEL, e);
}

return;
Expand Down Expand Up @@ -620,7 +620,7 @@ public void handleNext(ByteBuf frame, boolean hasFollows, boolean isLastPayload)
} else if (isOutboundTerminated(previousState)) {
final RequestInterceptor interceptor = this.requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(this.streamId, t);
interceptor.onTerminate(this.streamId, FrameType.REQUEST_CHANNEL, t);
}

Operators.onErrorDropped(t, this.inboundSubscriber.currentContext());
Expand All @@ -638,7 +638,7 @@ public void handleNext(ByteBuf frame, boolean hasFollows, boolean isLastPayload)

final RequestInterceptor interceptor = requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(streamId, t);
interceptor.onTerminate(streamId, FrameType.REQUEST_CHANNEL, t);
}

return;
Expand Down Expand Up @@ -690,7 +690,7 @@ public void onNext(Payload p) {

final RequestInterceptor interceptor = this.requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(streamId, e);
interceptor.onTerminate(streamId, FrameType.REQUEST_CHANNEL, e);
}

Operators.onErrorDropped(e, this.inboundSubscriber.currentContext());
Expand All @@ -705,7 +705,7 @@ public void onNext(Payload p) {

final RequestInterceptor interceptor = this.requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(streamId, e);
interceptor.onTerminate(streamId, FrameType.REQUEST_CHANNEL, e);
}
return;
}
Expand All @@ -720,7 +720,7 @@ public void onNext(Payload p) {
} else if (isOutboundTerminated(previousState)) {
final RequestInterceptor interceptor = this.requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(streamId, e);
interceptor.onTerminate(streamId, FrameType.REQUEST_CHANNEL, e);
}

Operators.onErrorDropped(e, this.inboundSubscriber.currentContext());
Expand All @@ -736,7 +736,7 @@ public void onNext(Payload p) {

final RequestInterceptor interceptor = requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(streamId, e);
interceptor.onTerminate(streamId, FrameType.REQUEST_CHANNEL, e);
}
return;
}
Expand All @@ -749,7 +749,7 @@ public void onNext(Payload p) {
long previousState = this.tryTerminate(false);
final RequestInterceptor interceptor = requestInterceptor;
if (interceptor != null && !isTerminated(previousState)) {
interceptor.onTerminate(streamId, t);
interceptor.onTerminate(streamId, FrameType.REQUEST_CHANNEL, t);
}
}
}
Expand Down Expand Up @@ -810,7 +810,7 @@ && isFirstFrameSent(previousState)

final RequestInterceptor interceptor = this.requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(streamId, t);
interceptor.onTerminate(streamId, FrameType.REQUEST_CHANNEL, t);
}
}

Expand Down Expand Up @@ -840,7 +840,7 @@ public void onComplete() {
if (isInboundTerminated) {
final RequestInterceptor interceptor = this.requestInterceptor;
if (interceptor != null) {
interceptor.onTerminate(streamId, null);
interceptor.onTerminate(streamId, FrameType.REQUEST_CHANNEL, null);
}
}
}
Expand Down
Loading