Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Brooks committed May 26, 2023
1 parent 1e96859 commit 4de3058
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3621,7 +3621,7 @@ public final void sync(Translog.Location location, Consumer<Exception> syncListe
* will not ensure that the request global checkpoint is available to be synced. It is the caller's duty to only call this
* method with a valid processed global checkpoint that is available to sync.
*/
public final void syncGlobalCheckpoint(long globalCheckpoint, Consumer<Exception> syncListener) {
public void syncGlobalCheckpoint(long globalCheckpoint, Consumer<Exception> syncListener) {
verifyNotClosed();
getEngine().asyncEnsureGlobalCheckpointSynced(globalCheckpoint, syncListener);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@
import org.elasticsearch.transport.TransportService;

import java.util.Collections;
import java.util.function.Consumer;

import static org.elasticsearch.test.ClusterServiceUtils.createClusterService;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
Expand Down Expand Up @@ -100,6 +105,11 @@ public void testTranslogSyncAfterGlobalCheckpointSync() throws Exception {

when(indexShard.getLastKnownGlobalCheckpoint()).thenReturn(globalCheckpoint);
when(indexShard.getLastSyncedGlobalCheckpoint()).thenReturn(lastSyncedGlobalCheckpoint);
doAnswer(invocation -> {
Consumer<Exception> argument = invocation.getArgument(1);
argument.accept(null);
return null;
}).when(indexShard).syncGlobalCheckpoint(anyLong(), any());

final GlobalCheckpointSyncAction action = new GlobalCheckpointSyncAction(
Settings.EMPTY,
Expand All @@ -122,10 +132,9 @@ public void testTranslogSyncAfterGlobalCheckpointSync() throws Exception {
}

if (durability == Translog.Durability.ASYNC || lastSyncedGlobalCheckpoint == globalCheckpoint) {
verify(indexShard, never()).sync();
verify(indexShard, never()).syncGlobalCheckpoint(anyLong(), any());
} else {
verify(indexShard).sync();
verify(indexShard).syncGlobalCheckpoint(eq(globalCheckpoint), any());
}
}

}

0 comments on commit 4de3058

Please sign in to comment.