Skip to content

Commit 73f0188

Browse files
[Backport 2.x] Use string-based version parsing to improve portability (#1068)
Use string-based version parsing to improve portability (#1067) (cherry picked from commit 88fe98e) Signed-off-by: Daniel Widdis <widdis@gmail.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent c5450fb commit 73f0188

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
2626
- Update template for alert summary with new log pattern tools ([#1021](https://github.com/opensearch-project/flow-framework/pull/1021))
2727
### Maintenance
2828
### Refactoring
29+
- Use string-based version parsing to improve portability ([#1067](https://github.com/opensearch-project/flow-framework/pull/1067))

src/main/java/org/opensearch/flowframework/transport/ReprovisionWorkflowRequest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
*/
99
package org.opensearch.flowframework.transport;
1010

11-
import org.opensearch.Version;
1211
import org.opensearch.action.ActionRequest;
1312
import org.opensearch.action.ActionRequestValidationException;
1413
import org.opensearch.common.unit.TimeValue;
1514
import org.opensearch.core.common.io.stream.StreamInput;
1615
import org.opensearch.core.common.io.stream.StreamOutput;
16+
import org.opensearch.flowframework.common.CommonValue;
1717
import org.opensearch.flowframework.model.Template;
1818

1919
import java.io.IOException;
@@ -70,7 +70,7 @@ public ReprovisionWorkflowRequest(StreamInput in) throws IOException {
7070
this.workflowId = in.readString();
7171
this.originalTemplate = Template.parse(in.readString());
7272
this.updatedTemplate = Template.parse(in.readString());
73-
if (in.getVersion().onOrAfter(Version.V_2_19_0)) {
73+
if (in.getVersion().onOrAfter(CommonValue.VERSION_2_19_0)) {
7474
this.waitForCompletionTimeout = in.readTimeValue();
7575
}
7676

@@ -82,7 +82,7 @@ public void writeTo(StreamOutput out) throws IOException {
8282
out.writeString(workflowId);
8383
out.writeString(originalTemplate.toJson());
8484
out.writeString(updatedTemplate.toJson());
85-
if (out.getVersion().onOrAfter(Version.V_2_19_0)) {
85+
if (out.getVersion().onOrAfter(CommonValue.VERSION_2_19_0)) {
8686
out.writeTimeValue(waitForCompletionTimeout);
8787
}
8888
}

src/main/java/org/opensearch/flowframework/transport/WorkflowRequest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
*/
99
package org.opensearch.flowframework.transport;
1010

11-
import org.opensearch.Version;
1211
import org.opensearch.action.ActionRequest;
1312
import org.opensearch.action.ActionRequestValidationException;
1413
import org.opensearch.common.Nullable;
1514
import org.opensearch.common.unit.TimeValue;
1615
import org.opensearch.core.common.io.stream.StreamInput;
1716
import org.opensearch.core.common.io.stream.StreamOutput;
17+
import org.opensearch.flowframework.common.CommonValue;
1818
import org.opensearch.flowframework.model.Template;
1919

2020
import java.io.IOException;
@@ -187,7 +187,7 @@ public WorkflowRequest(StreamInput in) throws IOException {
187187
this.params = Collections.emptyMap();
188188
}
189189
this.reprovision = !provision && Boolean.parseBoolean(params.get(REPROVISION_WORKFLOW));
190-
if (in.getVersion().onOrAfter(Version.V_2_19_0)) {
190+
if (in.getVersion().onOrAfter(CommonValue.VERSION_2_19_0)) {
191191
this.waitForCompletionTimeout = in.readOptionalTimeValue();
192192
}
193193

@@ -274,7 +274,7 @@ public void writeTo(StreamOutput out) throws IOException {
274274
} else if (reprovision) {
275275
out.writeMap(Map.of(REPROVISION_WORKFLOW, "true"), StreamOutput::writeString, StreamOutput::writeString);
276276
}
277-
if (out.getVersion().onOrAfter(Version.V_2_19_0)) {
277+
if (out.getVersion().onOrAfter(CommonValue.VERSION_2_19_0)) {
278278
out.writeOptionalTimeValue(waitForCompletionTimeout);
279279
}
280280
}

src/main/java/org/opensearch/flowframework/transport/WorkflowResponse.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
*/
99
package org.opensearch.flowframework.transport;
1010

11-
import org.opensearch.Version;
1211
import org.opensearch.common.Nullable;
1312
import org.opensearch.core.action.ActionResponse;
1413
import org.opensearch.core.common.io.stream.StreamInput;
1514
import org.opensearch.core.common.io.stream.StreamOutput;
1615
import org.opensearch.core.xcontent.ToXContentObject;
1716
import org.opensearch.core.xcontent.XContentBuilder;
17+
import org.opensearch.flowframework.common.CommonValue;
1818
import org.opensearch.flowframework.model.WorkflowState;
1919

2020
import java.io.IOException;
@@ -49,7 +49,7 @@ public WorkflowResponse(String workflowId) {
4949
public WorkflowResponse(StreamInput in) throws IOException {
5050
super(in);
5151
this.workflowId = in.readString();
52-
if (in.getVersion().onOrAfter(Version.V_2_19_0)) {
52+
if (in.getVersion().onOrAfter(CommonValue.VERSION_2_19_0)) {
5353
this.workflowState = in.readOptionalWriteable(WorkflowState::new);
5454
}
5555

@@ -94,7 +94,7 @@ public WorkflowResponse(String workflowId, WorkflowState workflowState) {
9494
@Override
9595
public void writeTo(StreamOutput out) throws IOException {
9696
out.writeString(workflowId);
97-
if (out.getVersion().onOrAfter(Version.V_2_19_0)) {
97+
if (out.getVersion().onOrAfter(CommonValue.VERSION_2_19_0)) {
9898
out.writeOptionalWriteable(workflowState);
9999
}
100100
}

0 commit comments

Comments
 (0)