sashapolo commented on code in PR #5134:
URL: https://github.com/apache/ignite-3/pull/5134#discussion_r1936827588
##########
modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/ZonePartitionRaftListener.java:
##########
@@ -51,47 +70,121 @@ public void onRead(Iterator<CommandClosure<ReadCommand>>
iterator) {
@Override
public void onWrite(Iterator<CommandClosure<WriteCommand>> iterator) {
- iterator.forEachRemaining((CommandClosure<? extends WriteCommand> clo)
-> {
- Command command = clo.command();
-
- Serializable result = null;
-
+ iterator.forEachRemaining(clo -> {
try {
- if (command instanceof FinishTxCommand) {
- FinishTxCommand cmd = (FinishTxCommand) command;
-
- result = new TransactionResult(cmd.commit() ? COMMITTED :
ABORTED, cmd.commitTimestamp());
- } else {
- LOG.debug("Message type " + command.getClass() + " is not
supported by the zone partition RAFT listener yet");
- }
+ processWriteCommand(clo);
} catch (Throwable t) {
LOG.error(
"Unknown error while processing command
[commandIndex={}, commandTerm={}, command={}]",
t,
- clo.index(), clo.index(), command
+ clo.index(), clo.index(), clo.command()
);
clo.result(t);
throw t;
}
-
- clo.result(result);
});
}
+ private void processWriteCommand(CommandClosure<WriteCommand> clo) {
+ Command command = clo.command();
+
+ if (command instanceof FinishTxCommand) {
+ FinishTxCommand cmd = (FinishTxCommand) command;
+
+ clo.result(new TransactionResult(cmd.commit() ? COMMITTED :
ABORTED, cmd.commitTimestamp()));
+ } else if (command instanceof PrimaryReplicaChangeCommand) {
+ // This is a hack for tests, this command is not issued in
production because no zone-wide placement driver exists yet.
+ CommandClosure<WriteCommand> idempotentCommandClosure =
idempotentCommandClosure(clo);
+
+ tablePartitionRaftListeners.values().forEach(listener ->
listener.onWrite(singletonIterator(idempotentCommandClosure)));
+
+ clo.result(null);
+ } else if (command instanceof UpdateCommand) {
+ TablePartitionId tablePartitionId = ((UpdateCommand)
command).tablePartitionId().asTablePartitionId();
+
+ processTableSpecificCommand(tablePartitionId, clo);
+ } else if (command instanceof UpdateAllCommand) {
+ TablePartitionId tablePartitionId = ((UpdateAllCommand)
command).tablePartitionId().asTablePartitionId();
+
+ processTableSpecificCommand(tablePartitionId, clo);
+ } else {
+ LOG.info("Message type " + command.getClass() + " is not supported
by the zone partition RAFT listener yet");
Review Comment:
This is from the previous implementation and this is temporary code anyway,
this will become an assertion eventually
--
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]