JKonSir commented on code in PR #7680:
URL: https://github.com/apache/ignite-3/pull/7680#discussion_r3044325581


##########
modules/core/src/main/java/org/apache/ignite/internal/util/retry/SharedRetryContext.java:
##########
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.retry;
+
+import static java.util.Optional.ofNullable;
+import static org.apache.ignite.internal.util.retry.TimeoutState.attempt;
+import static org.apache.ignite.internal.util.retry.TimeoutState.timeout;
+
+import java.util.Optional;
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * A retry context that tracks a single shared timeout state across all 
callers.
+ *
+ * <p>Unlike {@link KeyBasedRetryContext}, this context does not distinguish 
between
+ * retry targets — all callers advance and observe the same {@link 
TimeoutState}.
+ * This is appropriate when a single backoff sequence should govern all retries
+ * regardless of which operation is being retried.
+ *
+ * <p>The state is initialized lazily on the first call to {@link 
#updateAndGetState()},
+ * and can be reset to {@code null} via {@link #resetState()}, allowing the 
progression
+ * to restart from scratch. {@link #getState()} returns an empty {@link 
Optional} before
+ * the first call and after a reset.
+ *
+ * <p>Concurrent calls to {@link #updateAndGetState()} and {@link 
#resetState()} are safe.
+ * The {@link AtomicReference} handles structural transitions ({@code null ↔ 
initialized}),
+ * while the {@link TimeoutState}'s internal {@link AtomicLong} CAS handles 
concurrent
+ * value updates without allocating new objects on the hot path.
+ *
+ * <p>This class is thread-safe.
+ */
+public class SharedRetryContext {

Review Comment:
   I removed it, as I've revised the implementation and concluded that it 
doesn't make sense in this way.



-- 
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]

Reply via email to