Skip to content

Commit

Permalink
Fix deserilization error
Browse files Browse the repository at this point in the history
Signed-off-by: Anshu Agarwal <[email protected]>
  • Loading branch information
Anshu Agarwal committed Aug 6, 2024
1 parent 9142a25 commit d9bbc65
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
11 changes: 5 additions & 6 deletions server/src/main/java/org/opensearch/snapshots/SnapshotInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public static final class SnapshotInfoBuilder {
private Boolean includeGlobalState = null;

private Boolean remoteStoreIndexShallowCopy = null;
private long pinnedTimestamp;
private long pinnedTimestamp = 0L;
private Map<String, Object> userMetadata = null;
private int version = -1;
private List<SnapshotShardFailure> shardFailures = null;
Expand Down Expand Up @@ -351,7 +351,7 @@ public SnapshotInfo(SnapshotsInProgress.Entry entry) {
entry.includeGlobalState(),
entry.userMetadata(),
entry.remoteStoreIndexShallowCopy(),
0
0L
);
}

Expand Down Expand Up @@ -443,7 +443,7 @@ public SnapshotInfo(final StreamInput in) throws IOException {
remoteStoreIndexShallowCopy = in.readOptionalBoolean();
}
if (in.getVersion().onOrAfter(Version.V_2_16_0)) {
pinnedTimestamp = in.readLong();
pinnedTimestamp = in.readVLong();
}
}

Expand Down Expand Up @@ -667,9 +667,8 @@ public XContentBuilder toXContent(final XContentBuilder builder, final Params pa
if (remoteStoreIndexShallowCopy != null) {
builder.field(REMOTE_STORE_INDEX_SHALLOW_COPY, remoteStoreIndexShallowCopy);
}
if (pinnedTimestamp != 0) {
builder.field(PINNED_TIMESTAMP);
}
builder.field(PINNED_TIMESTAMP);

builder.startArray(INDICES);
for (String index : indices) {
builder.value(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ public void startCreateSnapshot(final CreateSnapshotRequest request, final Actio
* @param listener snapshot creation listener
*/
public void createSnapshot(final CreateSnapshotRequest request, final ActionListener<Snapshot> listener) {

final String repositoryName = request.repository();
final String snapshotName = indexNameExpressionResolver.resolveDateMathExpression(request.snapshot());
validate(repositoryName, snapshotName);
Expand Down Expand Up @@ -518,7 +517,7 @@ public void createShallowSnapshotV2(final CreateSnapshotRequest request, final A
shardGenerations.indices().stream().map(IndexId::getName).collect(Collectors.toList()),
dataStreams,
pinnedTimestamp,
"",
null,
System.currentTimeMillis(),
shardGenerations.totalShards(),
Collections.emptyList(),
Expand All @@ -532,10 +531,14 @@ public void createShallowSnapshotV2(final CreateSnapshotRequest request, final A
}
final StepListener<RepositoryData> pinnedTimestampListener = new StepListener<>();
pinnedTimestampListener.whenComplete(
repoData -> completeListenersIgnoringException(

repoData -> {completeListenersIgnoringException(
endAndGetListenersToResolve(snapshot),
Tuple.tuple(repoData, snapshotInfo)
),
);
listener.onResponse(snapshot);
},

e -> failSnapshotCompletionListeners(snapshot, new SnapshotException(snapshot, e.toString()))
);

Expand All @@ -545,7 +548,7 @@ public void createShallowSnapshotV2(final CreateSnapshotRequest request, final A
metadataForSnapshot(currentState.metadata(), request.includeGlobalState(), false, dataStreams, indexIds),
snapshotInfo,
version,
(Function<ClusterState, ClusterState>) currentState,
state -> stateWithoutSnapshot(clusterService.state(), snapshot),
new ActionListener<RepositoryData>() {
@Override
public void onResponse(RepositoryData repositoryData) {
Expand Down Expand Up @@ -583,6 +586,7 @@ private void updateSnapshotPinnedTimestamp(
long timestampToPin,
ActionListener<RepositoryData> listener
) {
listener.onResponse(repositoryData);
// remoteStorePinnedTimestampService.pinTimestamp(
// timestampToPin,
// snapshot.getRepository() + "__" + snapshot.getSnapshotId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ protected SnapshotInfo mutateInstance(SnapshotInfo instance) {
instance.includeGlobalState(),
instance.userMetadata(),
instance.isRemoteStoreIndexShallowCopyEnabled(),
0
123456
);
case 9:
return new SnapshotInfo(
Expand All @@ -271,7 +271,7 @@ protected SnapshotInfo mutateInstance(SnapshotInfo instance) {
instance.includeGlobalState(),
instance.userMetadata(),
Boolean.FALSE.equals(instance.isRemoteStoreIndexShallowCopyEnabled()),
0
123456
);
default:
throw new IllegalArgumentException("invalid randomization case");
Expand Down

0 comments on commit d9bbc65

Please sign in to comment.