Skip to content

Commit

Permalink
Use string-based version parsing to improve portability
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed Feb 24, 2025
1 parent f9a878e commit 0734971
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)

### Maintenance
### Refactoring
- Use string-based version parsing to improve portability ([#1067](https://github.com/opensearch-project/flow-framework/pull/1067))
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
*/
package org.opensearch.flowframework.transport;

import org.opensearch.Version;
import org.opensearch.action.ActionRequest;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.flowframework.common.CommonValue;
import org.opensearch.flowframework.model.Template;

import java.io.IOException;
Expand Down Expand Up @@ -70,7 +70,7 @@ public ReprovisionWorkflowRequest(StreamInput in) throws IOException {
this.workflowId = in.readString();
this.originalTemplate = Template.parse(in.readString());
this.updatedTemplate = Template.parse(in.readString());
if (in.getVersion().onOrAfter(Version.V_2_19_0)) {
if (in.getVersion().onOrAfter(CommonValue.VERSION_2_19_0)) {
this.waitForCompletionTimeout = in.readTimeValue();
}

Expand All @@ -82,7 +82,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeString(workflowId);
out.writeString(originalTemplate.toJson());
out.writeString(updatedTemplate.toJson());
if (out.getVersion().onOrAfter(Version.V_2_19_0)) {
if (out.getVersion().onOrAfter(CommonValue.VERSION_2_19_0)) {
out.writeTimeValue(waitForCompletionTimeout);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
*/
package org.opensearch.flowframework.transport;

import org.opensearch.Version;
import org.opensearch.action.ActionRequest;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.common.Nullable;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.flowframework.common.CommonValue;
import org.opensearch.flowframework.model.Template;

import java.io.IOException;
Expand Down Expand Up @@ -187,7 +187,7 @@ public WorkflowRequest(StreamInput in) throws IOException {
this.params = Collections.emptyMap();
}
this.reprovision = !provision && Boolean.parseBoolean(params.get(REPROVISION_WORKFLOW));
if (in.getVersion().onOrAfter(Version.V_2_19_0)) {
if (in.getVersion().onOrAfter(CommonValue.VERSION_2_19_0)) {
this.waitForCompletionTimeout = in.readOptionalTimeValue();
}

Expand Down Expand Up @@ -274,7 +274,7 @@ public void writeTo(StreamOutput out) throws IOException {
} else if (reprovision) {
out.writeMap(Map.of(REPROVISION_WORKFLOW, "true"), StreamOutput::writeString, StreamOutput::writeString);
}
if (out.getVersion().onOrAfter(Version.V_2_19_0)) {
if (out.getVersion().onOrAfter(CommonValue.VERSION_2_19_0)) {
out.writeOptionalTimeValue(waitForCompletionTimeout);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
*/
package org.opensearch.flowframework.transport;

import org.opensearch.Version;
import org.opensearch.common.Nullable;
import org.opensearch.core.action.ActionResponse;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.xcontent.ToXContentObject;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.flowframework.common.CommonValue;
import org.opensearch.flowframework.model.WorkflowState;

import java.io.IOException;
Expand Down Expand Up @@ -49,7 +49,7 @@ public WorkflowResponse(String workflowId) {
public WorkflowResponse(StreamInput in) throws IOException {
super(in);
this.workflowId = in.readString();
if (in.getVersion().onOrAfter(Version.V_2_19_0)) {
if (in.getVersion().onOrAfter(CommonValue.VERSION_2_19_0)) {
this.workflowState = in.readOptionalWriteable(WorkflowState::new);
}

Expand Down Expand Up @@ -94,7 +94,7 @@ public WorkflowResponse(String workflowId, WorkflowState workflowState) {
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(workflowId);
if (out.getVersion().onOrAfter(Version.V_2_19_0)) {
if (out.getVersion().onOrAfter(CommonValue.VERSION_2_19_0)) {
out.writeOptionalWriteable(workflowState);
}
}
Expand Down

0 comments on commit 0734971

Please sign in to comment.