Skip to content

Commit 5d0ecd3

Browse files
committed
add version checks for searchTask
Signed-off-by: Ruirui Zhang <[email protected]>
1 parent b0fa30f commit 5d0ecd3

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

server/src/main/java/org/opensearch/tasks/BaseSearchTaskCancellationStats.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
19
package org.opensearch.tasks;
210

311
import org.opensearch.core.common.io.stream.StreamInput;

server/src/main/java/org/opensearch/tasks/SearchShardTaskCancellationStats.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
19
package org.opensearch.tasks;
210

311
import org.opensearch.core.common.io.stream.StreamInput;

server/src/main/java/org/opensearch/tasks/SearchTaskCancellationStats.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
19
package org.opensearch.tasks;
210

311
import org.opensearch.core.common.io.stream.StreamInput;

server/src/main/java/org/opensearch/tasks/TaskCancellationStats.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
package org.opensearch.tasks;
1010

11+
import org.opensearch.Version;
1112
import org.opensearch.core.common.io.stream.StreamInput;
1213
import org.opensearch.core.common.io.stream.StreamOutput;
1314
import org.opensearch.core.common.io.stream.Writeable;
@@ -34,7 +35,11 @@ public TaskCancellationStats(
3435
}
3536

3637
public TaskCancellationStats(StreamInput in) throws IOException {
37-
searchTaskCancellationStats = new SearchTaskCancellationStats(in);
38+
if (in.getVersion().onOrAfter(Version.V_3_0_0)) {
39+
searchTaskCancellationStats = new SearchTaskCancellationStats(in);
40+
} else {
41+
searchTaskCancellationStats = new SearchTaskCancellationStats(0, 0);
42+
}
3843
searchShardTaskCancellationStats = new SearchShardTaskCancellationStats(in);
3944
}
4045

@@ -58,7 +63,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
5863

5964
@Override
6065
public void writeTo(StreamOutput out) throws IOException {
61-
searchTaskCancellationStats.writeTo(out);
66+
if (out.getVersion().onOrAfter(Version.V_3_0_0)) {
67+
searchTaskCancellationStats.writeTo(out);
68+
}
6269
searchShardTaskCancellationStats.writeTo(out);
6370
}
6471

0 commit comments

Comments
 (0)