denis-chudov commented on code in PR #3401:
URL: https://github.com/apache/ignite-3/pull/3401#discussion_r1524807871
##########
modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/negotiation/LeaseNegotiator.java:
##########
@@ -88,28 +91,37 @@ public void negotiate(Lease lease, boolean force) {
if (throwable == null) {
assert msg instanceof LeaseGrantedMessageResponse :
"Message type is unexpected [type="
+ msg.getClass().getSimpleName() + ']';
- } else if (!(unwrapCause(throwable) instanceof
NodeStoppingException)) {
- LOG.warn("Lease was not negotiated due to exception
[lease={}]", throwable, lease);
- }
- LeaseGrantedMessageResponse response =
(LeaseGrantedMessageResponse) msg;
+ LeaseGrantedMessageResponse response =
(LeaseGrantedMessageResponse) msg;
- fut.complete(response);
+ fut.complete(response);
+ } else {
+ if (!(unwrapCause(throwable) instanceof
NodeStoppingException)) {
+ LOG.warn("Lease was not negotiated due to
exception [lease={}]", throwable, lease);
+ }
- triggerToRenewLeases();
+ fut.complete(NOT_ACCEPTED_RESPONSE);
+ }
});
}
/**
- * Gets a lease agreement or {@code null} if the agreement has not formed
yet.
+ * Gets a lease agreement or {@link LeaseAgreement#UNDEFINED_AGREEMENT} if
the process of agreement is not started yet. Removes
+ * the agreement from the map if it is ready.
*
* @param groupId Replication group id.
* @return Lease agreement.
*/
- public LeaseAgreement negotiated(ReplicationGroupId groupId) {
- LeaseAgreement agreement = leaseToNegotiate.getOrDefault(groupId,
UNDEFINED_AGREEMENT);
+ public LeaseAgreement getAndRemoveIfReady(ReplicationGroupId groupId) {
+ LeaseAgreement[] res = new LeaseAgreement[1];
+
+ leaseToNegotiate.compute(groupId, (k, v) -> {
Review Comment:
I wouldn't say so, this is a concurrent map which can be changed from
different threads (lease updater and `whenComplete` of MS invoke)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]