rpuch commented on code in PR #1036:
URL: https://github.com/apache/ignite-3/pull/1036#discussion_r955073971
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/raft/RebalanceRaftGroupEventsListener.java:
##########
@@ -191,14 +191,19 @@ public void onReconfigurationError(Status status,
List<PeerId> peers, long term)
}
try {
- if (status == null) {
- // leader stepped down, so we are expecting
RebalanceRaftGroupEventsListener.onLeaderElected to be called on a new leader.
+ assert status != null;
+
+ RaftError raftError = status.getRaftError();
+
+ if (raftError == RaftError.EPERM && "Leader stepped
down.".equals(status.getErrorMsg())) {
Review Comment:
This looks a bit shaky. If I understand this correctly, the idea is to have
some 'leader stepped down' marker status. Can we create it (a `Status` object)
somewhere and both use it on the calling side (in `NodeImpl`) and here? So that
it be more visible that we are not just checking some string constant that is
easy to break.
This will require modifying `NodeImpl`. If this is undesirable, maybe we
should still make the modification in the listener, this will make it easier to
see that this is a special status.
Also, `Status#equals()` looks appropriate to use it for comparison instead
of this AND expression.
##########
modules/core/src/test/java/org/apache/ignite/internal/testframework/util/DirectExecutor.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * 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.testframework.util;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.jetbrains.annotations.NotNull;
+
+/** Executor service that executes tasks within the thread task was submitted
in. */
+public class DirectExecutor implements ExecutorService {
+ private final AtomicBoolean isShutdown = new AtomicBoolean();
+
+ @Override
+ public void shutdown() {
+ isShutdown.set(true);
+ }
+
+ @NotNull
Review Comment:
Should we still use `@NotNull`?
--
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]