Skip to content

Commit

Permalink
First commit for proto test
Browse files Browse the repository at this point in the history
Signed-off-by: Sarat Vemulapalli <[email protected]>
  • Loading branch information
saratvemulapalli committed Mar 16, 2023
1 parent 497c80d commit 3c506cb
Show file tree
Hide file tree
Showing 12 changed files with 922 additions and 20 deletions.
32 changes: 16 additions & 16 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions gradle/run.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ testClusters {
testDistribution = 'archive'
if (numZones > 1) numberOfZones = numZones
if (numNodes > 1) numberOfNodes = numNodes
systemProperty 'opensearch.experimental.feature.extensions.enabled', 'true'
}
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/repository-gcs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ dependencies {
api 'com.google.api:gax:2.17.0'
api 'org.threeten:threetenbp:1.4.4'
api 'com.google.protobuf:protobuf-java-util:3.20.0'
api 'com.google.protobuf:protobuf-java:3.21.7'
//api 'com.google.protobuf:protobuf-java:3.21.7'
api 'com.google.code.gson:gson:2.9.0'
api 'com.google.api.grpc:proto-google-common-protos:2.10.0'
api 'com.google.api.grpc:proto-google-iam-v1:0.12.0'
Expand Down
2 changes: 1 addition & 1 deletion plugins/repository-hdfs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ dependencies {
api 'org.apache.avro:avro:1.11.1'
api 'com.google.code.gson:gson:2.10.1'
runtimeOnly "com.google.guava:guava:${versions.guava}"
api 'com.google.protobuf:protobuf-java:3.22.2'
//api 'com.google.protobuf:protobuf-java:3.22.2'
api "commons-logging:commons-logging:${versions.commonslogging}"
api 'commons-cli:commons-cli:1.5.0'
api "commons-codec:commons-codec:${versions.commonscodec}"
Expand Down
3 changes: 3 additions & 0 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ dependencies {
// jna
api "net.java.dev.jna:jna:${versions.jna}"

// protobuf
implementation 'com.google.protobuf:protobuf-java:3.22.2'

testImplementation(project(":test:framework")) {
// tests use the locally compiled version of server
exclude group: 'org.opensearch', module: 'server'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.extensions.DiscoveryExtensionNode;
import org.opensearch.extensions.proto.ExtensionOuterClass;
import org.opensearch.transport.TransportRequest;

import java.io.IOException;
Expand All @@ -25,23 +26,27 @@
public class InitializeExtensionRequest extends TransportRequest {
private final DiscoveryNode sourceNode;
private final DiscoveryExtensionNode extension;
private final ExtensionOuterClass.Extension extensionProto;

public InitializeExtensionRequest(DiscoveryNode sourceNode, DiscoveryExtensionNode extension) {
this.sourceNode = sourceNode;
this.extension = extension;
this.extensionProto = ExtensionOuterClass.Extension.newBuilder().setName("Sarat").setId(10).setAlias("vemsarat").build();
}

public InitializeExtensionRequest(StreamInput in) throws IOException {
super(in);
sourceNode = new DiscoveryNode(in);
extension = new DiscoveryExtensionNode(in);
this.extensionProto = ExtensionOuterClass.Extension.parseFrom(in.readByteArray());
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
sourceNode.writeTo(out);
extension.writeTo(out);
out.writeByteArray(extensionProto.toByteArray());
}

public DiscoveryNode getSourceNode() {
Expand All @@ -52,9 +57,11 @@ public DiscoveryExtensionNode getExtension() {
return extension;
}

public ExtensionOuterClass.Extension getExtensionProto() { return extensionProto; }

@Override
public String toString() {
return "InitializeExtensionsRequest{" + "sourceNode=" + sourceNode + ", extension=" + extension + '}';
return "InitializeExtensionsRequest{" + "sourceNode=" + sourceNode + ", extension=" + extension + extensionProto.toString() + '}';
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.opensearch.common.Nullable;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.extensions.proto.ExtensionOuterClass;
import org.opensearch.transport.TransportRequest;

import java.io.IOException;
Expand All @@ -29,27 +30,32 @@ public class ExtensionRequest extends TransportRequest {
private final ExtensionsManager.RequestType requestType;
private final Optional<String> uniqueId;

private final ExtensionOuterClass.Extension extension;

public ExtensionRequest(ExtensionsManager.RequestType requestType) {
this(requestType, null);
}

public ExtensionRequest(ExtensionsManager.RequestType requestType, @Nullable String uniqueId) {
this.requestType = requestType;
this.uniqueId = uniqueId == null ? Optional.empty() : Optional.of(uniqueId);
extension = ExtensionOuterClass.Extension.newBuilder().setName("Sarat").setId(10).build();
}

public ExtensionRequest(StreamInput in) throws IOException {
super(in);
this.requestType = in.readEnum(ExtensionsManager.RequestType.class);
String id = in.readOptionalString();
this.uniqueId = id == null ? Optional.empty() : Optional.of(id);
this.extension = ExtensionOuterClass.Extension.parseFrom(in.readByteArray());
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeEnum(requestType);
out.writeOptionalString(uniqueId.orElse(null));
out.writeByteArray(extension.toByteArray());
}

public ExtensionsManager.RequestType getRequestType() {
Expand All @@ -60,8 +66,12 @@ public Optional<String> getUniqueId() {
return uniqueId;
}

public void extensionToString() {
logger.info(extension.toString());
}

public String toString() {
return "ExtensionRequest{" + "requestType=" + requestType + "uniqueId=" + uniqueId + '}';
return "ExtensionRequest{" + "requestType=" + requestType + "uniqueId=" + uniqueId + extension.toString() + '}';
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.opensearch.extensions.action.ExtensionActionResponse;
import org.opensearch.extensions.action.ExtensionTransportActionsHandler;
import org.opensearch.extensions.action.TransportActionRequestFromExtension;
import org.opensearch.extensions.proto.ExtensionProtoHelloWorld;
import org.opensearch.extensions.rest.RegisterRestActionsRequest;
import org.opensearch.extensions.rest.RestActionsRequestHandler;
import org.opensearch.extensions.settings.CustomSettingsRequestHandler;
Expand Down Expand Up @@ -155,6 +156,8 @@ public ExtensionsManager(Settings settings, Path extensionsPath) throws IOExcept
this.client = null;
this.extensionTransportActionsHandler = null;

ExtensionProtoHelloWorld protoHelloWorld = new ExtensionProtoHelloWorld();

/*
* Now Discover extensions
*/
Expand Down
Loading

0 comments on commit 3c506cb

Please sign in to comment.