vldpyatkov commented on code in PR #4700: URL: https://github.com/apache/ignite-3/pull/4700#discussion_r1848681274
########## modules/replicator/src/main/java/org/apache/ignite/internal/replicator/message/ReplicaMessageGroup.java: ########## @@ -49,6 +49,9 @@ public interface ReplicaMessageGroup { /** Message type for {@link AwaitReplicaResponse}. */ short AWAIT_REPLICA_RESPONSE = 7; + /** Message type for {@link org.apache.ignite.internal.replicator.CommitReplicaResponse}. */ + short COMMIT_REPLICA_RESPONSE = 8; Review Comment: It is not used. ########## modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java: ########## @@ -2735,24 +2738,20 @@ private CompletableFuture<CompletableFuture<?>> applyUpdateCommand( ); } - CompletableFuture<UUID> fut = applyCmdWithExceptionHandling(cmd, new CompletableFuture<>()) - .thenApply(res -> cmd.txId()); + CompletableFuture<UUID> repFut = applyCmdWithExceptionHandling(cmd).thenApply(res -> cmd.txId()); - return completedFuture(fut); + return completedFuture(new ApplyResult(null, repFut)); } else { - CompletableFuture<ApplyCommandResult<Object>> resultFuture = new CompletableFuture<>(); - - applyCmdWithExceptionHandling(cmd, resultFuture); - - return resultFuture.thenCompose(res -> { + return applyCmdWithExceptionHandling(cmd).thenCompose(res -> { UpdateCommandResult updateCommandResult = (UpdateCommandResult) res.getResult(); if (updateCommandResult != null && !updateCommandResult.isPrimaryReplicaMatch()) { throw new PrimaryReplicaMissException(txId, cmd.leaseStartTime(), updateCommandResult.currentLeaseStartTime()); } if (updateCommandResult != null && updateCommandResult.isPrimaryInPeersAndLearners()) { - return safeTime.waitFor(((UpdateCommand) res.getCommand()).safeTime()).thenApply(ignored -> null); + return safeTime.waitFor(((UpdateCommand) res.getCommand()).safeTime()).thenApply(ignored -> null) + .thenApply(ret -> new ApplyResult(((UpdateCommand) res.getCommand()).safeTime(), null)); Review Comment: Please replace `ret` to `ignored`. ########## modules/transactions/src/main/java/org/apache/ignite/internal/tx/HybridTimestampTracker.java: ########## @@ -19,34 +19,39 @@ import static org.apache.ignite.internal.hlc.HybridTimestamp.NULL_HYBRID_TIMESTAMP; -import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicLongFieldUpdater; import org.apache.ignite.internal.hlc.HybridTimestamp; import org.jetbrains.annotations.Nullable; /** * Hybrid timestamp tracker. */ public class HybridTimestampTracker { + private static final AtomicLongFieldUpdater<HybridTimestampTracker> TIMESTAMP = AtomicLongFieldUpdater.newUpdater( Review Comment: Why is this better than that was? ########## modules/table/src/main/java/org/apache/ignite/internal/table/distributed/storage/InternalTableImpl.java: ########## @@ -1107,7 +1116,7 @@ public CompletableFuture<Void> upsert(BinaryRowEx row, @Nullable InternalTransac .transactionId(txo.id()) .enlistmentConsistencyToken(enlistmentConsistencyToken) .requestType(RW_UPSERT) - .timestamp(clockService.now()) + .timestamp(txo.startTimestamp()) // TODO replace everythere Review Comment: It has to do in this PR, isn't it? ########## modules/core/src/test/java/org/apache/ignite/internal/hlc/HybridClockTest.java: ########## @@ -40,27 +37,19 @@ */ @ExtendWith(MockitoExtension.class) class HybridClockTest extends BaseIgniteAbstractTest { - /** - * Mock of a system clock. - */ - private static MockedStatic<HybridClockImpl> clockMock; - @Mock private ClockUpdateListener updateListener; - @AfterEach - public void afterEach() { - closeClockMock(); - } + private long mockedTime; /** * Tests a {@link HybridClock#now()}. */ @Test public void testNow() { - clockMock = mockToEpochMilli(100); + mockedTime = 100; - HybridClock clock = new HybridClockImpl(); + HybridClock clock = new TestHybridClock(() -> mockedTime); Review Comment: It makes me stressed because we test a test clock implementation. ########## modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaResult.java: ########## @@ -28,17 +27,17 @@ public class ReplicaResult { private final Object res; /** The replication future. */ - private final CompletableFuture<?> repFut; + private final ApplyResult applyResult; /** * Construct a replica result. * * @param res The result. - * @param repFut The replication future. + * @param applyResult The replication result. */ - public ReplicaResult(@Nullable Object res, @Nullable CompletableFuture<?> repFut) { + public ReplicaResult(@Nullable Object res, @Nullable ApplyResult applyResult) { this.res = res; - this.repFut = repFut; + this.applyResult = applyResult == null ? new ApplyResult(null, null) : applyResult; Review Comment: Make `new ApplyResult(null, null)` as a constant. ########## modules/table/src/main/java/org/apache/ignite/internal/table/distributed/raft/PartitionListener.java: ########## @@ -588,7 +588,7 @@ public boolean onBeforeApply(Command command) { if (maxObservableSafeTime == -1) { maxObservableSafeTime = clockService.now().addPhysicalTime(clockService.maxClockSkewMillis()).longValue(); - LOG.info("maxObservableSafeTime is initialized with [" + maxObservableSafeTime + "]."); + LOG.info("maxObservableSafeTime is initialized with [" + HybridTimestamp.hybridTimestamp(maxObservableSafeTime) + "]."); Review Comment: More usual for our code style and using of loggre: ``` LOG.info("maxObservableSafeTime is initialized with [ts={}].", HybridTimestamp.hybridTimestamp(maxObservableSafeTime)); ``` Also, fix the outout at the `onLeaderStop` method. ########## modules/core/src/test/java/org/apache/ignite/internal/hlc/HybridClockTest.java: ########## @@ -40,27 +37,19 @@ */ @ExtendWith(MockitoExtension.class) class HybridClockTest extends BaseIgniteAbstractTest { - /** - * Mock of a system clock. - */ - private static MockedStatic<HybridClockImpl> clockMock; - @Mock private ClockUpdateListener updateListener; - @AfterEach - public void afterEach() { - closeClockMock(); - } + private long mockedTime; /** * Tests a {@link HybridClock#now()}. */ @Test public void testNow() { - clockMock = mockToEpochMilli(100); + mockedTime = 100; - HybridClock clock = new HybridClockImpl(); + HybridClock clock = new TestHybridClock(() -> mockedTime); Review Comment: But I see a reason, it is just a note. ########## modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java: ########## @@ -745,7 +745,7 @@ public class IgniteImpl implements Ignite { SchemaSynchronizationConfiguration schemaSyncConfig = clusterConfigRegistry .getConfiguration(SchemaSynchronizationExtensionConfiguration.KEY).schemaSync(); - clockService = new ClockServiceImpl(clock, clockWaiter, new SameValueLongSupplier(() -> schemaSyncConfig.maxClockSkew().value())); + clockService = new ClockServiceImpl(clock, clockWaiter, () -> schemaSyncConfig.maxClockSkew().value()); Review Comment: I thought that would be replaced by the cached supplier. -- 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-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org