Skip to content

Commit cefa0bc

Browse files
committed
Add version change todos and fix potential breaking changes
Signed-off-by: Lakshya Taragi <lakshya.taragi@gmail.com>
1 parent 77ccc5d commit cefa0bc

File tree

4 files changed

+31
-27
lines changed

4 files changed

+31
-27
lines changed

server/src/internalClusterTest/java/org/opensearch/snapshots/SnapshotStatusApisIT.java

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public void testStatusApiConsistency() {
116116
assertEquals(snapshotStatus.getStats().getTime(), snapshotInfo.endTime() - snapshotInfo.startTime());
117117
}
118118

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

139-
assertBusy(() -> {
140-
final SnapshotStatus snapshotStatus = client().admin()
141-
.cluster()
142-
.prepareSnapshotStatus(snapshotRepoName)
143-
.setSnapshots(snapshot)
144-
.execute()
145-
.actionGet()
146-
.getSnapshots()
147-
.get(0);
148-
assertThat(snapshotStatus.getState(), is(SnapshotsInProgress.State.SUCCESS));
139+
final SnapshotStatus snapshotStatus = getSnapshotStatus(snapshotRepoName, snapshot);
140+
assertThat(snapshotStatus.getState(), is(SnapshotsInProgress.State.SUCCESS));
149141

150-
final SnapshotIndexShardStatus snapshotShardState = stateFirstShard(snapshotStatus, indexName);
151-
assertThat(snapshotShardState.getStage(), is(SnapshotIndexShardStage.DONE));
152-
assertThat(snapshotShardState.getStats().getTotalFileCount(), greaterThan(0));
153-
assertThat(snapshotShardState.getStats().getTotalSize(), greaterThan(0L));
154-
assertThat(snapshotShardState.getStats().getIncrementalFileCount(), greaterThan(0));
155-
assertThat(snapshotShardState.getStats().getIncrementalSize(), greaterThan(0L));
156-
}, 1, TimeUnit.MINUTES);
142+
final SnapshotIndexShardStatus snapshotShardState = stateFirstShard(snapshotStatus, indexName);
143+
assertThat(snapshotShardState.getStage(), is(SnapshotIndexShardStage.DONE));
144+
assertThat(snapshotShardState.getStats().getTotalFileCount(), greaterThan(0));
145+
assertThat(snapshotShardState.getStats().getTotalSize(), greaterThan(0L));
146+
assertThat(snapshotShardState.getStats().getIncrementalFileCount(), greaterThan(0));
147+
assertThat(snapshotShardState.getStats().getIncrementalSize(), greaterThan(0L));
157148
}
158149

159150
public void testStatusAPICallInProgressSnapshot() throws Exception {

server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public class SnapshotStatus implements ToXContentObject, Writeable {
9999
includeGlobalState = in.readOptionalBoolean();
100100
final long startTime = in.readLong();
101101
final long time = in.readLong();
102+
// TODO: change version to 2_18_0
102103
if (in.getVersion().onOrAfter(Version.CURRENT)) {
103104
initialTotalSizeInBytes = in.readOptionalLong();
104105
} else {
@@ -107,6 +108,17 @@ public class SnapshotStatus implements ToXContentObject, Writeable {
107108
updateShardStats(startTime, time, initialTotalSizeInBytes);
108109
}
109110

111+
SnapshotStatus(
112+
Snapshot snapshot,
113+
State state,
114+
List<SnapshotIndexShardStatus> shards,
115+
Boolean includeGlobalState,
116+
long startTime,
117+
long time
118+
) {
119+
this(snapshot, state, shards, includeGlobalState, startTime, time, 0L);
120+
}
121+
110122
SnapshotStatus(
111123
Snapshot snapshot,
112124
State state,
@@ -217,6 +229,7 @@ public void writeTo(StreamOutput out) throws IOException {
217229
out.writeOptionalBoolean(includeGlobalState);
218230
out.writeLong(stats.getStartTime());
219231
out.writeLong(stats.getTime());
232+
// TODO: change version to 2_18_0
220233
if (out.getVersion().onOrAfter(Version.CURRENT)) {
221234
out.writeOptionalLong(initialTotalSizeInBytes);
222235
}

server/src/main/java/org/opensearch/cluster/ClusterInfo.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,7 @@ public ClusterInfo(
9696
final Map<NodeAndPath, ReservedSpace> reservedSpace,
9797
final Map<String, FileCacheStats> nodeFileCacheStats
9898
) {
99-
this(
100-
leastAvailableSpaceUsage,
101-
mostAvailableSpaceUsage,
102-
shardSizes,
103-
routingToDataPath,
104-
reservedSpace,
105-
nodeFileCacheStats,
106-
0L
107-
);
99+
this(leastAvailableSpaceUsage, mostAvailableSpaceUsage, shardSizes, routingToDataPath, reservedSpace, nodeFileCacheStats, 0L);
108100
}
109101

110102
/**
@@ -155,6 +147,7 @@ public ClusterInfo(StreamInput in) throws IOException {
155147
} else {
156148
this.nodeFileCacheStats = Map.of();
157149
}
150+
// TODO: change version to 2_18_0
158151
if (in.getVersion().onOrAfter(Version.CURRENT)) {
159152
this.primaryStoreSize = in.readOptionalLong();
160153
} else {
@@ -205,6 +198,7 @@ public void writeTo(StreamOutput out) throws IOException {
205198
if (out.getVersion().onOrAfter(Version.V_2_10_0)) {
206199
out.writeMap(this.nodeFileCacheStats, StreamOutput::writeString, (o, v) -> v.writeTo(o));
207200
}
201+
// TODO: change version to 2_18_0
208202
if (out.getVersion().onOrAfter(Version.CURRENT)) {
209203
out.writeOptionalLong(this.primaryStoreSize);
210204
}

server/src/main/java/org/opensearch/snapshots/SnapshotInfo.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,9 @@ public SnapshotInfo(final StreamInput in) throws IOException {
528528
}
529529
if (in.getVersion().onOrAfter(Version.V_2_17_0)) {
530530
pinnedTimestamp = in.readVLong();
531+
}
532+
// TODO: change version to 2_18_0
533+
if (in.getVersion().onOrAfter(Version.CURRENT)) {
531534
snapshotSizeInBytes = in.readVLong();
532535
}
533536
}
@@ -1012,6 +1015,9 @@ public void writeTo(final StreamOutput out) throws IOException {
10121015
}
10131016
if (out.getVersion().onOrAfter(Version.V_2_17_0)) {
10141017
out.writeVLong(pinnedTimestamp);
1018+
}
1019+
// TODO: change version to 2_18_0
1020+
if (out.getVersion().onOrAfter(Version.CURRENT)) {
10151021
out.writeVLong(snapshotSizeInBytes);
10161022
}
10171023
}

0 commit comments

Comments
 (0)