Skip to content

Commit

Permalink
Incorporate name change comments
Browse files Browse the repository at this point in the history
Signed-off-by: Aman Khare <amkhar@amazon.com>
  • Loading branch information
Aman Khare committed Oct 23, 2023
1 parent a099a86 commit 6606b53
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ assert verifyManifestAndClusterState(lastAcceptedManifest, lastAcceptedState) ==

@Override
public PersistedStateStats getStats() {
return remoteClusterStateService.getRemoteClusterStateStats();
return remoteClusterStateService.getStats();
}

private boolean verifyManifestAndClusterState(ClusterMetadataManifest manifest, ClusterState clusterState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ public static String encodeString(String content) {
}

public void writeMetadataFailed() {
getRemoteClusterStateStats().stateFailed();
getStats().stateFailed();
}

/**
Expand Down Expand Up @@ -1236,7 +1236,7 @@ public void deleteStaleClusterUUIDs(ClusterState clusterState, ClusterMetadataMa
});
}

public RemotePersistenceStats getRemoteClusterStateStats() {
public RemotePersistenceStats getStats() {
return remoteStateStats;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
*/
public class RemotePersistenceStats extends PersistedStateStats {
static final String CLEANUP_ATTEMPT_FAILED_COUNT = "cleanup_attempt_failed_count";
static final String REMOTE = "remote";
static final String REMOTE_UPLOAD = "remote_upload";
private AtomicLong cleanupAttemptFailedCount = new AtomicLong(0);

public RemotePersistenceStats() {
super(REMOTE);
super(REMOTE_UPLOAD);
addToExtendedFields(CLEANUP_ATTEMPT_FAILED_COUNT, cleanupAttemptFailedCount);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ public void testRemotePersistedStateFailureStats() throws IOException {
final RemoteClusterStateService remoteClusterStateService = Mockito.mock(RemoteClusterStateService.class);
final String previousClusterUUID = "prev-cluster-uuid";
Mockito.doThrow(IOException.class).when(remoteClusterStateService).writeFullMetadata(Mockito.any(), Mockito.any());
when(remoteClusterStateService.getRemoteClusterStateStats()).thenReturn(remoteStateStats);
when(remoteClusterStateService.getStats()).thenReturn(remoteStateStats);
doCallRealMethod().when(remoteClusterStateService).writeMetadataFailed();
CoordinationState.PersistedState remotePersistedState = new RemotePersistedState(remoteClusterStateService, previousClusterUUID);

Expand All @@ -797,8 +797,8 @@ public void testRemotePersistedStateFailureStats() throws IOException {
);

assertThrows(OpenSearchException.class, () -> remotePersistedState.setLastAcceptedState(clusterState));
assertEquals(1, remoteClusterStateService.getRemoteClusterStateStats().getFailedCount());
assertEquals(0, remoteClusterStateService.getRemoteClusterStateStats().getSuccessCount());
assertEquals(1, remoteClusterStateService.getStats().getFailedCount());
assertEquals(0, remoteClusterStateService.getStats().getSuccessCount());
}

public void testGatewayForRemoteState() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,15 @@ public void testWriteFullMetadataInParallelFailureForIndexMetadata() throws IOEx
RemoteClusterStateService.IndexMetadataTransferException.class,
() -> remoteClusterStateService.writeFullMetadata(clusterState, randomAlphaOfLength(10))
);
assertEquals(0, remoteClusterStateService.getRemoteClusterStateStats().getSuccessCount());
assertEquals(0, remoteClusterStateService.getStats().getSuccessCount());
}

public void testFailWriteIncrementalMetadataNonClusterManagerNode() throws IOException {
final ClusterState clusterState = generateClusterStateWithOneIndex().build();
remoteClusterStateService.start();
final ClusterMetadataManifest manifest = remoteClusterStateService.writeIncrementalMetadata(clusterState, clusterState, null);
Assert.assertThat(manifest, nullValue());
assertEquals(0, remoteClusterStateService.getRemoteClusterStateStats().getSuccessCount());
assertEquals(0, remoteClusterStateService.getStats().getSuccessCount());
}

public void testFailWriteIncrementalMetadataWhenTermChanged() {
Expand Down Expand Up @@ -997,10 +997,10 @@ public void testRemoteStateStats() throws IOException {
remoteClusterStateService.start();
final ClusterMetadataManifest manifest = remoteClusterStateService.writeFullMetadata(clusterState, "prev-cluster-uuid");

assertTrue(remoteClusterStateService.getRemoteClusterStateStats() != null);
assertEquals(1, remoteClusterStateService.getRemoteClusterStateStats().getSuccessCount());
assertEquals(0, remoteClusterStateService.getRemoteClusterStateStats().getCleanupAttemptFailedCount());
assertEquals(0, remoteClusterStateService.getRemoteClusterStateStats().getFailedCount());
assertTrue(remoteClusterStateService.getStats() != null);
assertEquals(1, remoteClusterStateService.getStats().getSuccessCount());
assertEquals(0, remoteClusterStateService.getStats().getCleanupAttemptFailedCount());
assertEquals(0, remoteClusterStateService.getStats().getFailedCount());
}

public void testRemoteStateCleanupFailureStats() throws IOException {
Expand All @@ -1014,9 +1014,9 @@ public void testRemoteStateCleanupFailureStats() throws IOException {
try {
assertBusy(() -> {
// wait for stats to get updated
assertTrue(remoteClusterStateService.getRemoteClusterStateStats() != null);
assertEquals(0, remoteClusterStateService.getRemoteClusterStateStats().getSuccessCount());
assertEquals(1, remoteClusterStateService.getRemoteClusterStateStats().getCleanupAttemptFailedCount());
assertTrue(remoteClusterStateService.getStats() != null);
assertEquals(0, remoteClusterStateService.getStats().getSuccessCount());
assertEquals(1, remoteClusterStateService.getStats().getCleanupAttemptFailedCount());
});
} catch (Exception e) {
throw new RuntimeException(e);
Expand Down

0 comments on commit 6606b53

Please sign in to comment.