You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "ibessonov (via GitHub)" <gi...@apache.org> on 2023/11/07 16:18:24 UTC
[PR] IGNITE-20803 Split ActionRequest into 2 interfaces [ignite-3]
ibessonov opened a new pull request, #2814:
URL: https://github.com/apache/ignite-3/pull/2814
https://issues.apache.org/jira/browse/IGNITE-20803
Thank you for submitting the pull request.
To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:
### The Review Checklist
- [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:
\- There is a single JIRA ticket related to the pull request.
\- The web-link to the pull request is attached to the JIRA ticket.
\- The JIRA ticket has the Patch Available state.
\- The description of the JIRA ticket explains WHAT was made, WHY and HOW.
\- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
- [ ] **Design:** new code conforms with the design principles of the components it is added to.
- [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
- [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
- [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
### Notes
- [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20803 Split ActionRequest into 2 interfaces [ignite-3]
Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2814:
URL: https://github.com/apache/ignite-3/pull/2814#discussion_r1386201931
##########
modules/raft/src/test/java/org/apache/ignite/internal/raft/RaftGroupServiceTest.java:
##########
@@ -617,7 +618,7 @@ private void mockUserInput(boolean delay, @Nullable Peer peer) {
argThat(new ArgumentMatcher<ActionRequest>() {
@Override
public boolean matches(ActionRequest arg) {
- return arg.command() instanceof TestWriteCommand;
+ return arg instanceof WriteActionRequest && ((WriteActionRequest) arg).command() instanceof TestWriteCommand;
Review Comment:
Next issue will change the type of `command()` property for write commands into a byte[], interfaces will become incompatible
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20803 Split ActionRequest into 2 interfaces [ignite-3]
Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill commented on code in PR #2814:
URL: https://github.com/apache/ignite-3/pull/2814#discussion_r1386199463
##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/ReadActionRequest.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.raft.jraft.rpc;
+
+import org.apache.ignite.internal.raft.ReadCommand;
+import org.apache.ignite.network.annotations.Transferable;
+import org.apache.ignite.raft.jraft.RaftMessageGroup.RpcActionMessageGroup;
+
+/**
+ * Submit an action to a replication group.
+ */
+@Transferable(RpcActionMessageGroup.READ_ACTION_REQUEST)
+public interface ReadActionRequest extends ActionRequest {
+ /**
+ * @return Action's command.
+ */
+ ReadCommand command();
+
+ /**
+ * @return {@code True} for linearizable reading.
Review Comment:
I understand, but you added a new interface, let’s improve it!
##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/ReadActionRequest.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.raft.jraft.rpc;
+
+import org.apache.ignite.internal.raft.ReadCommand;
+import org.apache.ignite.network.annotations.Transferable;
+import org.apache.ignite.raft.jraft.RaftMessageGroup.RpcActionMessageGroup;
+
+/**
+ * Submit an action to a replication group.
+ */
+@Transferable(RpcActionMessageGroup.READ_ACTION_REQUEST)
+public interface ReadActionRequest extends ActionRequest {
+ /**
+ * @return Action's command.
+ */
+ ReadCommand command();
+
+ /**
+ * @return {@code True} for linearizable reading.
Review Comment:
I understand, but you added a new interface, let’s improve it!
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20803 Split ActionRequest into 2 interfaces [ignite-3]
Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2814:
URL: https://github.com/apache/ignite-3/pull/2814#discussion_r1386198694
##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/impl/ActionRequestProcessor.java:
##########
@@ -82,25 +84,30 @@ public void handleRequest(RpcContext rpcCtx, ActionRequest request) {
JraftServerImpl.DelegatingStateMachine fsm = (JraftServerImpl.DelegatingStateMachine) node.getOptions().getFsm();
- if (request.command() instanceof WriteCommand) {
+ if (request instanceof WriteActionRequest) {
if (fsm.getListener() instanceof BeforeApplyHandler) {
synchronized (groupIdSyncMonitor(request.groupId())) {
callOnBeforeApply(request, fsm);
- applyWrite(node, request, rpcCtx);
+ applyWrite(node, (WriteActionRequest) request, rpcCtx);
}
} else {
- applyWrite(node, request, rpcCtx);
+ applyWrite(node, (WriteActionRequest) request, rpcCtx);
}
} else {
if (fsm.getListener() instanceof BeforeApplyHandler) {
callOnBeforeApply(request, fsm);
}
- applyRead(node, request, rpcCtx);
+ applyRead(node, (ReadActionRequest) request, rpcCtx);
}
}
+
private static void callOnBeforeApply(ActionRequest request, DelegatingStateMachine fsm) {
- ((BeforeApplyHandler) fsm.getListener()).onBeforeApply(request.command());
+ Command command = request instanceof WriteActionRequest
+ ? ((WriteActionRequest) request).command()
+ : ((ReadActionRequest) request).command();
Review Comment:
No, this is deliberate
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20803 Split ActionRequest into 2 interfaces [ignite-3]
Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill commented on code in PR #2814:
URL: https://github.com/apache/ignite-3/pull/2814#discussion_r1386204854
##########
modules/raft/src/test/java/org/apache/ignite/internal/raft/RaftGroupServiceTest.java:
##########
@@ -617,7 +618,7 @@ private void mockUserInput(boolean delay, @Nullable Peer peer) {
argThat(new ArgumentMatcher<ActionRequest>() {
@Override
public boolean matches(ActionRequest arg) {
- return arg.command() instanceof TestWriteCommand;
+ return arg instanceof WriteActionRequest && ((WriteActionRequest) arg).command() instanceof TestWriteCommand;
Review Comment:
Ok
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20803 Split ActionRequest into 2 interfaces [ignite-3]
Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill commented on code in PR #2814:
URL: https://github.com/apache/ignite-3/pull/2814#discussion_r1386172458
##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/ReadActionRequest.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.raft.jraft.rpc;
+
+import org.apache.ignite.internal.raft.ReadCommand;
+import org.apache.ignite.network.annotations.Transferable;
+import org.apache.ignite.raft.jraft.RaftMessageGroup.RpcActionMessageGroup;
+
+/**
+ * Submit an action to a replication group.
+ */
+@Transferable(RpcActionMessageGroup.READ_ACTION_REQUEST)
+public interface ReadActionRequest extends ActionRequest {
+ /**
+ * @return Action's command.
+ */
+ ReadCommand command();
+
+ /**
+ * @return {@code True} for linearizable reading.
Review Comment:
I don't quite understand this description, could you expand on it? I see that there is a command for reading, can they be not only for reading? How can they **not** be safe reading?
##########
modules/raft/src/main/java/org/apache/ignite/internal/raft/RaftGroupServiceImpl.java:
##########
@@ -449,11 +449,20 @@ public <R> CompletableFuture<R> run(Command cmd) {
return refreshLeader().thenCompose(res -> run(cmd));
}
- Function<Peer, ActionRequest> requestFactory = targetPeer -> factory.actionRequest()
- .command(cmd)
- .groupId(groupId)
- .readOnlySafe(true)
- .build();
+ Function<Peer, ActionRequest> requestFactory;
Review Comment:
Suggestion: How about creating a separate, understandable functional interface with a description? Even with implementations to make it clearer why this is.
##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/ReadActionRequest.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.raft.jraft.rpc;
+
+import org.apache.ignite.internal.raft.ReadCommand;
+import org.apache.ignite.network.annotations.Transferable;
+import org.apache.ignite.raft.jraft.RaftMessageGroup.RpcActionMessageGroup;
+
+/**
+ * Submit an action to a replication group.
+ */
+@Transferable(RpcActionMessageGroup.READ_ACTION_REQUEST)
+public interface ReadActionRequest extends ActionRequest {
+ /**
+ * @return Action's command.
+ */
Review Comment:
```suggestion
/** Returns read command. */
```
##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/ReadActionRequest.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.raft.jraft.rpc;
+
+import org.apache.ignite.internal.raft.ReadCommand;
+import org.apache.ignite.network.annotations.Transferable;
+import org.apache.ignite.raft.jraft.RaftMessageGroup.RpcActionMessageGroup;
+
+/**
+ * Submit an action to a replication group.
+ */
+@Transferable(RpcActionMessageGroup.READ_ACTION_REQUEST)
+public interface ReadActionRequest extends ActionRequest {
+ /**
+ * @return Action's command.
+ */
+ ReadCommand command();
+
+ /**
+ * @return {@code True} for linearizable reading.
+ */
Review Comment:
```suggestion
/** Returns {@code True} for linearizable reading. */
```
##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/ReadActionRequest.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.raft.jraft.rpc;
+
+import org.apache.ignite.internal.raft.ReadCommand;
+import org.apache.ignite.network.annotations.Transferable;
+import org.apache.ignite.raft.jraft.RaftMessageGroup.RpcActionMessageGroup;
+
+/**
+ * Submit an action to a replication group.
+ */
Review Comment:
```suggestion
/** Submit a read action to a replication group. */
```
##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/WriteActionRequest.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * 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.raft.jraft.rpc;
+
+import org.apache.ignite.internal.raft.WriteCommand;
+import org.apache.ignite.network.annotations.Transferable;
+import org.apache.ignite.raft.jraft.RaftMessageGroup.RpcActionMessageGroup;
+
+/**
+ * Submit an action to a replication group.
+ */
Review Comment:
```suggestion
/** Submit a write action to a replication group. */
```
##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/impl/ActionRequestProcessor.java:
##########
@@ -82,25 +84,30 @@ public void handleRequest(RpcContext rpcCtx, ActionRequest request) {
JraftServerImpl.DelegatingStateMachine fsm = (JraftServerImpl.DelegatingStateMachine) node.getOptions().getFsm();
- if (request.command() instanceof WriteCommand) {
+ if (request instanceof WriteActionRequest) {
if (fsm.getListener() instanceof BeforeApplyHandler) {
synchronized (groupIdSyncMonitor(request.groupId())) {
callOnBeforeApply(request, fsm);
- applyWrite(node, request, rpcCtx);
+ applyWrite(node, (WriteActionRequest) request, rpcCtx);
}
} else {
- applyWrite(node, request, rpcCtx);
+ applyWrite(node, (WriteActionRequest) request, rpcCtx);
}
} else {
if (fsm.getListener() instanceof BeforeApplyHandler) {
callOnBeforeApply(request, fsm);
}
- applyRead(node, request, rpcCtx);
+ applyRead(node, (ReadActionRequest) request, rpcCtx);
}
}
+
private static void callOnBeforeApply(ActionRequest request, DelegatingStateMachine fsm) {
- ((BeforeApplyHandler) fsm.getListener()).onBeforeApply(request.command());
+ Command command = request instanceof WriteActionRequest
+ ? ((WriteActionRequest) request).command()
+ : ((ReadActionRequest) request).command();
Review Comment:
Can we create one common interface that will return a command so as not to use `instanceof`?
##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/WriteActionRequest.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * 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.raft.jraft.rpc;
+
+import org.apache.ignite.internal.raft.WriteCommand;
+import org.apache.ignite.network.annotations.Transferable;
+import org.apache.ignite.raft.jraft.RaftMessageGroup.RpcActionMessageGroup;
+
+/**
+ * Submit an action to a replication group.
+ */
+@Transferable(RpcActionMessageGroup.WRITE_ACTION_REQUEST)
+public interface WriteActionRequest extends ActionRequest {
+ /**
+ * @return Action's command.
+ */
Review Comment:
```suggestion
/** Returns write action' command. */
```
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/raftsnapshot/ItTableRaftSnapshotsTest.java:
##########
@@ -667,8 +667,8 @@ void snapshotInstallTimeoutDoesNotBreakSubsequentInstallsWhenSecondAttemptIsIden
try {
prepareClusterForInstallingSnapshotToNode2(DEFAULT_STORAGE_ENGINE, theCluster -> {
BiPredicate<String, NetworkMessage> dropSafeTimeUntilSecondInstallSnapshotRequestIsProcessed = (recipientId, message) ->
- message instanceof ActionRequest
- && ((ActionRequest) message).command() instanceof SafeTimeSyncCommand
+ message instanceof WriteActionRequest
Review Comment:
Same about common interface.
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItBuildIndexTest.java:
##########
@@ -241,8 +241,8 @@ private static BiPredicate<String, NetworkMessage> waitSendBuildIndexCommand(
boolean dropBuildIndexCommand
) {
return (nodeConsistentId, networkMessage) -> {
- if (networkMessage instanceof ActionRequest) {
- Command command = ((ActionRequest) networkMessage).command();
+ if (networkMessage instanceof WriteActionRequest) {
Review Comment:
Same
##########
modules/raft/src/test/java/org/apache/ignite/internal/raft/RaftGroupServiceTest.java:
##########
@@ -617,7 +618,7 @@ private void mockUserInput(boolean delay, @Nullable Peer peer) {
argThat(new ArgumentMatcher<ActionRequest>() {
@Override
public boolean matches(ActionRequest arg) {
- return arg.command() instanceof TestWriteCommand;
+ return arg instanceof WriteActionRequest && ((WriteActionRequest) arg).command() instanceof TestWriteCommand;
Review Comment:
It would be more convenient with a common interface that returns a command.
##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/impl/IgniteRpcServer.java:
##########
@@ -197,6 +191,26 @@ else if (prc.executor() != null) {
LOG.warn("A request execution was rejected [sender={} req={} reason={}]", sender, S.toString(message), e.getMessage());
}
}
+
+ private @Nullable RpcProcessor<NetworkMessage> getProcessor(Class<?> cls) {
+ RpcProcessor<NetworkMessage> prc = processors.get(cls.getName());
+
+ if (prc != null) {
+ processors.putIfAbsent(cls.getName(), prc);
Review Comment:
Why `putIfAbsent` if it already exists above?
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20803 Split ActionRequest into 2 interfaces [ignite-3]
Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2814:
URL: https://github.com/apache/ignite-3/pull/2814#discussion_r1386199910
##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/impl/IgniteRpcServer.java:
##########
@@ -197,6 +191,26 @@ else if (prc.executor() != null) {
LOG.warn("A request execution was rejected [sender={} req={} reason={}]", sender, S.toString(message), e.getMessage());
}
}
+
+ private @Nullable RpcProcessor<NetworkMessage> getProcessor(Class<?> cls) {
+ RpcProcessor<NetworkMessage> prc = processors.get(cls.getName());
+
+ if (prc != null) {
+ processors.putIfAbsent(cls.getName(), prc);
Review Comment:
Good catch, I messed up
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20803 Split ActionRequest into 2 interfaces [ignite-3]
Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2814:
URL: https://github.com/apache/ignite-3/pull/2814#discussion_r1386206506
##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/ReadActionRequest.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.raft.jraft.rpc;
+
+import org.apache.ignite.internal.raft.ReadCommand;
+import org.apache.ignite.network.annotations.Transferable;
+import org.apache.ignite.raft.jraft.RaftMessageGroup.RpcActionMessageGroup;
+
+/**
+ * Submit an action to a replication group.
+ */
+@Transferable(RpcActionMessageGroup.READ_ACTION_REQUEST)
+public interface ReadActionRequest extends ActionRequest {
+ /**
+ * @return Action's command.
+ */
Review Comment:
Looks good to me already
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20803 Split ActionRequest into 2 interfaces [ignite-3]
Posted by "tkalkirill (via GitHub)" <gi...@apache.org>.
tkalkirill commented on code in PR #2814:
URL: https://github.com/apache/ignite-3/pull/2814#discussion_r1386205076
##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/impl/ActionRequestProcessor.java:
##########
@@ -82,25 +84,30 @@ public void handleRequest(RpcContext rpcCtx, ActionRequest request) {
JraftServerImpl.DelegatingStateMachine fsm = (JraftServerImpl.DelegatingStateMachine) node.getOptions().getFsm();
- if (request.command() instanceof WriteCommand) {
+ if (request instanceof WriteActionRequest) {
if (fsm.getListener() instanceof BeforeApplyHandler) {
synchronized (groupIdSyncMonitor(request.groupId())) {
callOnBeforeApply(request, fsm);
- applyWrite(node, request, rpcCtx);
+ applyWrite(node, (WriteActionRequest) request, rpcCtx);
}
} else {
- applyWrite(node, request, rpcCtx);
+ applyWrite(node, (WriteActionRequest) request, rpcCtx);
}
} else {
if (fsm.getListener() instanceof BeforeApplyHandler) {
callOnBeforeApply(request, fsm);
}
- applyRead(node, request, rpcCtx);
+ applyRead(node, (ReadActionRequest) request, rpcCtx);
}
}
+
private static void callOnBeforeApply(ActionRequest request, DelegatingStateMachine fsm) {
- ((BeforeApplyHandler) fsm.getListener()).onBeforeApply(request.command());
+ Command command = request instanceof WriteActionRequest
+ ? ((WriteActionRequest) request).command()
+ : ((ReadActionRequest) request).command();
Review Comment:
ok
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20803 Split ActionRequest into 2 interfaces [ignite-3]
Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2814:
URL: https://github.com/apache/ignite-3/pull/2814#discussion_r1386198219
##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/rpc/ReadActionRequest.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.raft.jraft.rpc;
+
+import org.apache.ignite.internal.raft.ReadCommand;
+import org.apache.ignite.network.annotations.Transferable;
+import org.apache.ignite.raft.jraft.RaftMessageGroup.RpcActionMessageGroup;
+
+/**
+ * Submit an action to a replication group.
+ */
+@Transferable(RpcActionMessageGroup.READ_ACTION_REQUEST)
+public interface ReadActionRequest extends ActionRequest {
+ /**
+ * @return Action's command.
+ */
+ ReadCommand command();
+
+ /**
+ * @return {@code True} for linearizable reading.
Review Comment:
I copied the description from the old interface
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20803 Split ActionRequest into 2 interfaces [ignite-3]
Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2814:
URL: https://github.com/apache/ignite-3/pull/2814#discussion_r1386204958
##########
modules/raft/src/main/java/org/apache/ignite/internal/raft/RaftGroupServiceImpl.java:
##########
@@ -449,11 +449,20 @@ public <R> CompletableFuture<R> run(Command cmd) {
return refreshLeader().thenCompose(res -> run(cmd));
}
- Function<Peer, ActionRequest> requestFactory = targetPeer -> factory.actionRequest()
- .command(cmd)
- .groupId(groupId)
- .readOnlySafe(true)
- .build();
+ Function<Peer, ActionRequest> requestFactory;
Review Comment:
Not here, it's not relevant to my changes
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20803 Split ActionRequest into 2 interfaces [ignite-3]
Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov merged PR #2814:
URL: https://github.com/apache/ignite-3/pull/2814
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org