Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Use string-based version parsing to improve portability #1068

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
- Update template for alert summary with new log pattern tools ([#1021](https://github.com/opensearch-project/flow-framework/pull/1021))
### 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
Loading