vldpyatkov commented on code in PR #1765:
URL: https://github.com/apache/ignite-3/pull/1765#discussion_r1146430084
##########
modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java:
##########
@@ -1005,4 +1006,50 @@ public static <T> Optional<T> findAny(Collection<T>
collection, @Nullable Predic
return Optional.empty();
}
+
+ /**
+ * Retries operation until it succeeds or fails with exception that is
different than the given.
+ *
+ * @param operation Operation.
+ * @param exClass Exception.
+ * @return Future that is completed when operation is successful or failed
with other exception than the given.
+ */
+ public static <T> CompletableFuture<T> retryOperationUntilSuccess(
+ Supplier<CompletableFuture<T>> operation,
+ Class<? extends Exception> exClass,
Review Comment:
Why do you think that the only exception class is enough?
##########
modules/placement-driver-api/src/main/java/org/apache/ignite/internal/placementdriver/message/PlacementDriverMessageGroup.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.placementdriver.message;
+
+import static
org.apache.ignite.internal.placementdriver.message.PlacementDriverMessageGroup.GROUP_NAME;
+import static
org.apache.ignite.internal.placementdriver.message.PlacementDriverMessageGroup.GROUP_TYPE;
+
+import org.apache.ignite.network.annotations.MessageGroup;
+
+/**
+ * Message group for placement driver messages.
+ */
+@MessageGroup(groupType = GROUP_TYPE, groupName = GROUP_NAME)
+public interface PlacementDriverMessageGroup {
+ /** Placement driver message group type. */
+ short GROUP_TYPE = 11;
+
+ String GROUP_NAME = "PlacementDriverMessages";
+
+ short LEASE_GRANTED_MESSAGE = 0;
Review Comment:
It is a usual approach in our code.
Look at here ReplicaMessageGroup or here RaftMessageGroup
If we have a direct message and reverse, we determine constants with
Request* and Response prefixes.
##########
modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java:
##########
@@ -1005,4 +1006,50 @@ public static <T> Optional<T> findAny(Collection<T>
collection, @Nullable Predic
return Optional.empty();
}
+
+ /**
+ * Retries operation until it succeeds or fails with exception that is
different than the given.
+ *
+ * @param operation Operation.
+ * @param exClass Exception.
+ * @return Future that is completed when operation is successful or failed
with other exception than the given.
+ */
+ public static <T> CompletableFuture<T> retryOperationUntilSuccess(
+ Supplier<CompletableFuture<T>> operation,
+ Class<? extends Exception> exClass,
+ Executor executor
+ ) {
+ CompletableFuture<T> fut = new CompletableFuture<>();
+
+ retryOperationUntilSuccess(operation, exClass, fut, executor);
+
+ return fut;
+ }
+
+ /**
+ * Retries operation until it succeeds or fails with exception that is
different than the given.
+ *
+ * @param operation Operation.
+ * @param exClass Exception.
+ * @param fut Future that is completed when operation is successful or
failed with other exception than the given.
+ */
+ public static <T> void retryOperationUntilSuccess(
+ Supplier<CompletableFuture<T>> operation,
+ Class<? extends Exception> exClass,
+ CompletableFuture<T> fut,
+ Executor executor
Review Comment:
Add the parameter to javadoc
--
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]