Skip to content

Commit

Permalink
Add version change todos and fix potential breaking changes
Browse files Browse the repository at this point in the history
Signed-off-by: Lakshya Taragi <[email protected]>
  • Loading branch information
ltaragi committed Sep 23, 2024
1 parent 77ccc5d commit 8e7af89
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void testStatusApiConsistency() {
assertEquals(snapshotStatus.getStats().getTime(), snapshotInfo.endTime() - snapshotInfo.startTime());
}

public void testStatusAPICallForShallowCopySnapshot() throws Exception {
public void testStatusAPICallForShallowCopySnapshot() {
disableRepoConsistencyCheck("Remote store repository is being used for the test");
internalCluster().startClusterManagerOnlyNode();
internalCluster().startDataOnlyNode();
Expand All @@ -136,24 +136,15 @@ public void testStatusAPICallForShallowCopySnapshot() throws Exception {
final String snapshot = "snapshot";
createFullSnapshot(snapshotRepoName, snapshot);

assertBusy(() -> {
final SnapshotStatus snapshotStatus = client().admin()
.cluster()
.prepareSnapshotStatus(snapshotRepoName)
.setSnapshots(snapshot)
.execute()
.actionGet()
.getSnapshots()
.get(0);
assertThat(snapshotStatus.getState(), is(SnapshotsInProgress.State.SUCCESS));
final SnapshotStatus snapshotStatus = getSnapshotStatus(snapshotRepoName, snapshot);
assertThat(snapshotStatus.getState(), is(SnapshotsInProgress.State.SUCCESS));

final SnapshotIndexShardStatus snapshotShardState = stateFirstShard(snapshotStatus, indexName);
assertThat(snapshotShardState.getStage(), is(SnapshotIndexShardStage.DONE));
assertThat(snapshotShardState.getStats().getTotalFileCount(), greaterThan(0));
assertThat(snapshotShardState.getStats().getTotalSize(), greaterThan(0L));
assertThat(snapshotShardState.getStats().getIncrementalFileCount(), greaterThan(0));
assertThat(snapshotShardState.getStats().getIncrementalSize(), greaterThan(0L));
}, 1, TimeUnit.MINUTES);
final SnapshotIndexShardStatus snapshotShardState = stateFirstShard(snapshotStatus, indexName);
assertThat(snapshotShardState.getStage(), is(SnapshotIndexShardStage.DONE));
assertThat(snapshotShardState.getStats().getTotalFileCount(), greaterThan(0));
assertThat(snapshotShardState.getStats().getTotalSize(), greaterThan(0L));
assertThat(snapshotShardState.getStats().getIncrementalFileCount(), greaterThan(0));
assertThat(snapshotShardState.getStats().getIncrementalSize(), greaterThan(0L));
}

public void testStatusAPICallInProgressSnapshot() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public class SnapshotStatus implements ToXContentObject, Writeable {
includeGlobalState = in.readOptionalBoolean();
final long startTime = in.readLong();
final long time = in.readLong();
// TODO: change version to 2_18_0
if (in.getVersion().onOrAfter(Version.CURRENT)) {
initialTotalSizeInBytes = in.readOptionalLong();
} else {
Expand All @@ -107,6 +108,17 @@ public class SnapshotStatus implements ToXContentObject, Writeable {
updateShardStats(startTime, time, initialTotalSizeInBytes);
}

SnapshotStatus(
Snapshot snapshot,
State state,
List<SnapshotIndexShardStatus> shards,
Boolean includeGlobalState,
long startTime,
long time
) {
this(snapshot, state, shards, includeGlobalState, startTime, time, 0L);
}

SnapshotStatus(
Snapshot snapshot,
State state,
Expand Down Expand Up @@ -217,6 +229,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalBoolean(includeGlobalState);
out.writeLong(stats.getStartTime());
out.writeLong(stats.getTime());
// TODO: change version to 2_18_0
if (out.getVersion().onOrAfter(Version.CURRENT)) {
out.writeOptionalLong(initialTotalSizeInBytes);
}
Expand Down
12 changes: 3 additions & 9 deletions server/src/main/java/org/opensearch/cluster/ClusterInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,7 @@ public ClusterInfo(
final Map<NodeAndPath, ReservedSpace> reservedSpace,
final Map<String, FileCacheStats> nodeFileCacheStats
) {
this(
leastAvailableSpaceUsage,
mostAvailableSpaceUsage,
shardSizes,
routingToDataPath,
reservedSpace,
nodeFileCacheStats,
0L
);
this(leastAvailableSpaceUsage, mostAvailableSpaceUsage, shardSizes, routingToDataPath, reservedSpace, nodeFileCacheStats, 0L);
}

/**
Expand Down Expand Up @@ -155,6 +147,7 @@ public ClusterInfo(StreamInput in) throws IOException {
} else {
this.nodeFileCacheStats = Map.of();
}
// TODO: change version to 2_18_0
if (in.getVersion().onOrAfter(Version.CURRENT)) {
this.primaryStoreSize = in.readOptionalLong();
} else {
Expand Down Expand Up @@ -205,6 +198,7 @@ public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(Version.V_2_10_0)) {
out.writeMap(this.nodeFileCacheStats, StreamOutput::writeString, (o, v) -> v.writeTo(o));
}
// TODO: change version to 2_18_0
if (out.getVersion().onOrAfter(Version.CURRENT)) {
out.writeOptionalLong(this.primaryStoreSize);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ public SnapshotInfo(final StreamInput in) throws IOException {
}
if (in.getVersion().onOrAfter(Version.V_2_17_0)) {
pinnedTimestamp = in.readVLong();
}
// TODO: change version to 2_18_0
if (in.getVersion().onOrAfter(Version.CURRENT)) {
snapshotSizeInBytes = in.readVLong();
}
}
Expand Down Expand Up @@ -1012,6 +1015,9 @@ public void writeTo(final StreamOutput out) throws IOException {
}
if (out.getVersion().onOrAfter(Version.V_2_17_0)) {
out.writeVLong(pinnedTimestamp);
}
// TODO: change version to 2_18_0
if (out.getVersion().onOrAfter(Version.CURRENT)) {
out.writeVLong(snapshotSizeInBytes);
}
}
Expand Down

0 comments on commit 8e7af89

Please sign in to comment.