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

Integrating Protobuf with OpenSearch Transport #7131

Closed
wants to merge 11 commits into from
  •  
  •  
  •  
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 8 additions & 1 deletion server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,13 @@ tasks.named("missingJavadoc").configure {
javadocMissingIgnore = [
"org.opensearch.extensions.proto.ExtensionRequestProto",
"org.opensearch.extensions.proto.ExtensionRequestProto.ExtensionRequestOrBuilder",
"org.opensearch.extensions.proto"
"org.opensearch.extensions.proto",
"org.opensearch.tasks.proto.TaskResourceStatsProto",
"org.opensearch.tasks.proto.TaskResourceStatsProto.TaskResourceStatsOrBuilder",
"org.opensearch.tasks.proto.TaskResourceStatsProto.TaskResourceStats.TaskResourceUsageOrBuilder",
"org.opensearch.tasks.proto.TaskIdProto",
"org.opensearch.tasks.proto.TaskIdProto.TaskIdOrBuilder",
"org.opensearch.tasks.proto"
]
}

Expand All @@ -373,6 +379,7 @@ tasks.named("licenseHeaders").configure {
excludes << 'org/opensearch/client/documentation/placeholder.txt'
// Ignore for protobuf generated code
excludes << 'org/opensearch/extensions/proto/*'
excludes << 'org/opensearch/tasks/proto/*'
}

tasks.test {
Expand Down
26 changes: 26 additions & 0 deletions server/src/main/java/org/opensearch/Build.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

package org.opensearch;

import com.google.protobuf.CodedInputStream;
import com.google.protobuf.CodedOutputStream;
import org.opensearch.common.Booleans;
import org.opensearch.common.io.FileSystemUtils;
import org.opensearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -218,6 +220,18 @@ public static Build readBuild(StreamInput in) throws IOException {
return new Build(type, hash, date, snapshot, version, distribution);
}

public static Build readBuildProtobuf(CodedInputStream in) throws IOException {
// the following is new for opensearch: we write the distribution to support any "forks"
final String distribution = in.readString();
// be lenient when reading on the wire, the enumeration values from other versions might be different than what we know
final Type type = Type.fromDisplayName(in.readString(), false);
String hash = in.readString();
String date = in.readString();
boolean snapshot = in.readBool();
final String version = in.readString();
return new Build(type, hash, date, snapshot, version, distribution);
}

public static void writeBuild(Build build, StreamOutput out) throws IOException {
// the following is new for opensearch: we write the distribution name to support any "forks" of the code
out.writeString(build.distribution);
Expand All @@ -230,6 +244,18 @@ public static void writeBuild(Build build, StreamOutput out) throws IOException
out.writeString(build.getQualifiedVersion());
}

public static void writeBuildProtobuf(Build build, CodedOutputStream out) throws IOException {
// the following is new for opensearch: we write the distribution name to support any "forks" of the code
out.writeStringNoTag(build.distribution);

final Type buildType = build.type();
out.writeStringNoTag(buildType.displayName());
out.writeStringNoTag(build.hash());
out.writeStringNoTag(build.date());
out.writeBoolNoTag(build.isSnapshot());
out.writeStringNoTag(build.getQualifiedVersion());
}

/**
* Get the distribution name (expected to be OpenSearch; empty if legacy; something else if forked)
* @return distribution name as a string
Expand Down
Loading
Loading