Skip to content

Commit

Permalink
Added logging for skipping index rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
todvora committed Aug 20, 2024
1 parent e644002 commit 6e48d4d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ public void doRun() {


private boolean isCurrentlyMigrated(IndexSet indexSet) {
return migrationService.isMigrationRunning(indexSet);
final boolean migrationIsRunning = migrationService.isMigrationRunning(indexSet);
if (migrationIsRunning) {
LOG.info("Index set {} is being migrated, skipping index rotation", indexSet.getConfig().title());
}
return migrationIsRunning;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import jakarta.inject.Provider;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;

import static org.mockito.Mockito.never;
Expand Down Expand Up @@ -129,8 +128,8 @@ public void testDoNotPerformRotation() throws NoTargetIndexException {
@Test
public void testSkipRotationDuringMigration() throws NoTargetIndexException {
TestableRotationStrategy testableRotationStrategy = new TestableRotationStrategy();
final IndexSet indexSetFinished = mockIndexSet(true, testableRotationStrategy);
final IndexSet indexSetMigrated = mockIndexSet(true, testableRotationStrategy);
final IndexSet indexSetFinished = mockIndexSet("finished_index_set", true, testableRotationStrategy);
final IndexSet indexSetMigrated = mockIndexSet("migrating_index_set", true, testableRotationStrategy);

final IndexRotationThread rotationThread = new IndexRotationThread(
Mockito.mock(NotificationService.class),
Expand All @@ -157,11 +156,12 @@ private RemoteReindexingMigrationAdapter mockMigrationAdapter(IndexSet migration
return migrationAdapter;
}

private IndexSet mockIndexSet(boolean writable, RotationStrategy testableRotationStrategy) {
private IndexSet mockIndexSet(String indexSetTitle, boolean writable, RotationStrategy testableRotationStrategy) {
final IndexSet indexSet = Mockito.mock(IndexSet.class);
final IndexSetConfig config = Mockito.mock(IndexSetConfig.class);
Mockito.when(config.isWritable()).thenReturn(writable);
Mockito.when(config.rotationStrategyClass()).thenReturn(testableRotationStrategy.getStrategyName());
Mockito.when(config.title()).thenReturn(indexSetTitle);
Mockito.when(indexSet.getConfig()).thenReturn(config);
return indexSet;
}
Expand Down

0 comments on commit 6e48d4d

Please sign in to comment.