-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Remove some abstractions from TransportReplicationAction
#40706
Changes from 1 commit
85b1cdb
4302320
16350a6
efdab0c
e1fef41
4844f9a
2135ff9
240edcf
a076dec
83c6c67
3d7e753
df7437c
9f89af7
a5bfc84
7182fd6
fb06813
ffc7256
c4d9c40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,21 +144,21 @@ protected TransportReplicationAction(Settings settings, String actionName, Trans | |
|
||
this.transportPrimaryAction = actionName + "[p]"; | ||
this.transportReplicaAction = actionName + "[r]"; | ||
registerRequestHandlers(actionName, transportService, request, replicaRequest, executor); | ||
|
||
transportService.registerRequestHandler(actionName, request, ThreadPool.Names.SAME, this::handleOperationRequest); | ||
transportService.registerRequestHandler(transportPrimaryAction, () -> new ConcreteShardRequest<>(request), executor, true, | ||
forcePrimaryActionExecution(), this::handlePrimaryRequest); | ||
// we must never reject on because of thread pool capacity on replicas | ||
transportService.registerRequestHandler( | ||
transportReplicaAction, () -> new ConcreteReplicaRequest<>(replicaRequest), executor, true, true, this::handleReplicaRequest); | ||
|
||
this.transportOptions = transportOptions(settings); | ||
|
||
this.syncGlobalCheckpointAfterOperation = syncGlobalCheckpointAfterOperation; | ||
} | ||
|
||
protected void registerRequestHandlers(String actionName, TransportService transportService, Supplier<Request> request, | ||
Supplier<ReplicaRequest> replicaRequest, String executor) { | ||
transportService.registerRequestHandler(actionName, request, ThreadPool.Names.SAME, this::handleOperationRequest); | ||
transportService.registerRequestHandler(transportPrimaryAction, () -> new ConcreteShardRequest<>(request), executor, | ||
this::handlePrimaryRequest); | ||
// we must never reject on because of thread pool capacity on replicas | ||
transportService.registerRequestHandler( | ||
transportReplicaAction, () -> new ConcreteReplicaRequest<>(replicaRequest), executor, true, true, this::handleReplicaRequest); | ||
protected boolean forcePrimaryActionExecution() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally this would be a constructor parameter instead to avoid the dreaded relying on subclass uninitialized state problem. However, the old registerRequestHandlers had the same issue, so this is still a good improvement. I would like to add a javadoc comment to it that overriding methods should only return either true and not rely on state. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh darn it I didn't mean to commit that, it doesn't work. At least, I committed it, then reverted it (it doesn't work) but then reverted the reversion to investigate why. I have now reverted the reverted reversion. 🤣 |
||
return false; | ||
} | ||
|
||
@Override | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result of
forcePrimaryActionExecution()
is passed to the wrong parameter (canTripCircuitBreaker
). Swap this and the previoustrue
and I think it will work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, well spotted. I opened #40762.