-
Notifications
You must be signed in to change notification settings - Fork 12
[1.x] Distinguish shard pick-up results #1505
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
Conversation
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.
Please see my comments.
server/src/main/java/io/spine/server/delivery/PickUpOutcome.java
Outdated
Show resolved
Hide resolved
server/src/main/java/io/spine/server/delivery/PickUpOutcome.java
Outdated
Show resolved
Hide resolved
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.
@nick-dolgiy please see my comments.
server/src/main/java/io/spine/server/delivery/DeliveryMonitor.java
Outdated
Show resolved
Hide resolved
server/src/main/java/io/spine/server/delivery/DeliveryMonitor.java
Outdated
Show resolved
Hide resolved
server/src/main/java/io/spine/server/delivery/DeliveryMonitor.java
Outdated
Show resolved
Hide resolved
server/src/main/java/io/spine/server/delivery/DeliveryMonitor.java
Outdated
Show resolved
Hide resolved
server/src/main/java/io/spine/server/delivery/DeliveryMonitor.java
Outdated
Show resolved
Hide resolved
…eadyPicked()` handler.
Done. |
|
@armiol PTAL. |
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.
@nick-dolgiy please see my comments.
server/src/main/java/io/spine/server/delivery/AlreadyPickedUp.java
Outdated
Show resolved
Hide resolved
server/src/main/java/io/spine/server/delivery/FailedPickUp.java
Outdated
Show resolved
Hide resolved
server/src/main/java/io/spine/server/delivery/FailedPickUp.java
Outdated
Show resolved
Hide resolved
server/src/main/java/io/spine/server/delivery/FailedPickUp.java
Outdated
Show resolved
Hide resolved
|
@armiol PTAL. |
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.
@nick-dolgiy one last thing, hopefully. Please see my comment.
Otherwise, LGTM.
server/src/main/java/io/spine/server/delivery/AlreadyPickedUp.java
Outdated
Show resolved
Hide resolved
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.
LGTM!
In this PR we start to distinguish the shard pick-up results. In particular, it is now possible to find out the reason of an unsuccessful shard pick-up. In particular, there may be some runtime issues, or the shard may already be picked-up by another worker.
Two new API endpoints were added to the
DeliveryMonitorto provide end-users with some control over such cases:FailedPickUp.Action onShardAlreadyPicked(AlreadyPickedUp failure)This method will be invoked if the shard could not be picked as it's already picked by another worker. This method receives the
ShardIndexof the shard that could not be picked, theWorkerIdof the worker who owns the delivery session, and theTimestampwhen the shard was picked. It is required to return an action to take in relation to this case. By default, it returns an action which just accepts this case (and ends the delivery session without any processing), but end-users may return a predefined action retrying the shard pick-up:FailedPickUp.Action onShardPickUpFailure(RuntimeFailure failure)This method is invoked if the shard could not be picked for some runtime technical reason, such as a runtime exception. This method receives the
ShardIndexof the shard that could not be picked, and the instance of the occurredException. It also requires to return an action to handle this case. By default, such failures are just rethrown asRuntimeException, but end-users may choose to retry the pick-up:Breaking changes
The API of the
ShardedWorkRegistryhas been changed.In particular, a new
PickUpOutcome pickUp(ShardIndex index, NodeId node)method is introduced. Note, it returns an explicit result instead ofOptional, as previously. This outcome contains either of two:ShardSessionRecord— meaning that the shard is picked successfully,ShardAlreadyPickedUp— a message that contains aWorkerIDof the worker who owns the session at the moment, and theTimestampwhen the shard was picked. This outcome means the session cannot be obtained as it's already picked.Also, there is a new
void release(ShardSessionRecord session)method that releases the passed session.Here is a summary of code changes for those using
ShardedWorkRegistry:Before:
After:
Also, the new API allows getting the
WorkerIdof the worker who owns the session in case if the shard is already picked by someone else and theTimestampwhen the shard was picked: