diff --git a/.gitignore b/.gitignore
index cd18466bd9b5..be16a76388cd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,6 +16,7 @@
.project
.settings
*.factorypath
+*.class
target
build
dependency-reduced-pom.xml
diff --git a/hadoop-hdds/client/pom.xml b/hadoop-hdds/client/pom.xml
index 99b7664cdd55..b697f7088116 100644
--- a/hadoop-hdds/client/pom.xml
+++ b/hadoop-hdds/client/pom.xml
@@ -52,6 +52,10 @@
org.apache.ozone
hdds-config
+
+ org.apache.ozone
+ hdds-datanode-grpc-client
+
org.apache.ozone
hdds-erasurecode
@@ -101,6 +105,21 @@
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ analyze
+
+
+
+ com.google.protobuf:protobuf-java
+
+
+
+
+
com.github.spotbugs
spotbugs-maven-plugin
diff --git a/hadoop-hdds/common/pom.xml b/hadoop-hdds/common/pom.xml
index daf7008fa83b..5d91b1cb43eb 100644
--- a/hadoop-hdds/common/pom.xml
+++ b/hadoop-hdds/common/pom.xml
@@ -248,6 +248,7 @@
org.apache.maven.plugins
maven-compiler-plugin
+ false
org.apache.ozone
@@ -263,6 +264,26 @@
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ analyze
+
+
+
+ org.apache.ozone:hdds-config
+ org.apache.ratis:ratis-thirdparty-misc
+
+
+
+
+
org.apache.maven.plugins
maven-enforcer-plugin
diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsUtils.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsUtils.java
index fce0f295e33d..c6d1c64169f3 100644
--- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsUtils.java
+++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsUtils.java
@@ -34,8 +34,6 @@
import com.google.common.base.Preconditions;
import com.google.common.net.HostAndPort;
-import com.google.protobuf.InvalidProtocolBufferException;
-import com.google.protobuf.ServiceException;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
import java.io.File;
@@ -87,6 +85,8 @@
import org.apache.hadoop.security.AccessControlException;
import org.apache.hadoop.security.token.SecretManager;
import org.apache.ratis.thirdparty.com.google.protobuf.ByteString;
+import org.apache.ratis.thirdparty.com.google.protobuf.InvalidProtocolBufferException;
+import org.apache.ratis.thirdparty.com.google.protobuf.ServiceException;
import org.apache.ratis.thirdparty.com.google.protobuf.TextFormat;
import org.apache.ratis.util.SizeInBytes;
import org.slf4j.Logger;
diff --git a/hadoop-hdds/container-service/pom.xml b/hadoop-hdds/container-service/pom.xml
index a0034eb78f4f..9d225466cafa 100644
--- a/hadoop-hdds/container-service/pom.xml
+++ b/hadoop-hdds/container-service/pom.xml
@@ -138,6 +138,10 @@
org.apache.ozone
hdds-config
+
+ org.apache.ozone
+ hdds-datanode-grpc-client
+
org.apache.ozone
hdds-interface-client
@@ -336,6 +340,24 @@
true
+
+ analyze
+
+
+
+ org.apache.hadoop:hadoop-auth
+
+ org.apache.ratis:ratis-netty
+
+
+
diff --git a/hadoop-hdds/datanode-grpc-client/pom.xml b/hadoop-hdds/datanode-grpc-client/pom.xml
new file mode 100644
index 000000000000..543be0eae63b
--- /dev/null
+++ b/hadoop-hdds/datanode-grpc-client/pom.xml
@@ -0,0 +1,195 @@
+
+
+
+ 4.0.0
+
+ org.apache.ozone
+ hdds
+ 2.2.0-SNAPSHOT
+
+ hdds-datanode-grpc-client
+ 2.2.0-SNAPSHOT
+ jar
+ Apache Ozone HDDS DataNode gRPC Client
+ DataNode XCeiver and IntraDatanode gRPC stubs generated from DatanodeClientProtocol.proto.
+ The proto file lives in hdds-interface-client (which also generates the shaded ContainerProtos
+ message classes); this module generates only the gRPC service stubs. Package names in generated
+ sources are rewritten by maven-antrun-plugin (Ant replace task, pure Java) from vanilla
+ com.google.protobuf / io.grpc / com.google.common to their ratis-thirdparty counterparts
+ before compilation.
+
+
+
+ yyyyMMddHHmmss
+
+ true
+ true
+ true
+
+
+
+
+
+ org.apache.ozone
+ hdds-interface-client
+
+
+
+ org.apache.ratis
+ ratis-thirdparty-misc
+
+
+
+ javax.annotation
+ javax.annotation-api
+ provided
+
+
+
+
+
+
+
+ com.gradle
+ develocity-maven-extension
+
+
+
+
+ maven-compiler-plugin
+
+ compiles generated + rewritten sources
+
+
+
+ maven-antrun-plugin
+
+ rewrites generated source files
+
+
+
+ protobuf-maven-plugin
+
+ generates sources
+
+
+
+
+
+
+
+
+
+
+ com.salesforce.servicelibs
+ proto-backwards-compatibility
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ none
+ false
+
+
+
+ org.xolstice.maven.plugins
+ protobuf-maven-plugin
+
+
+ compile-proto-datanode
+
+
+ compile-custom
+
+ generate-sources
+
+
+ com.google.protobuf:protoc:${ratis-thirdparty.protobuf.version}:exe:${os.detected.classifier}
+ ${project.build.directory}/generated-sources/proto-java-ratis
+ ${java.io.tmpdir}/ozone-protoc-dependencies/${project.artifactId}/${maven.build.timestamp}
+ false
+ grpc-java
+ io.grpc:protoc-gen-grpc-java:${ratis-thirdparty.grpc.version}:exe:${os.detected.classifier}
+ ${project.basedir}/../interface-client/src/main/proto
+
+ DatanodeClientProtocol.proto
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+
+
+
+ pre-verify-refresh-classes-from-jar
+ none
+
+
+
+ rewrite-generated-sources-to-ratis-ns
+
+ run
+
+ process-sources
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/hadoop-hdds/datanode-grpc-client/src/main/resources/proto.lock b/hadoop-hdds/datanode-grpc-client/src/main/resources/proto.lock
new file mode 100644
index 000000000000..338eb7a3db19
--- /dev/null
+++ b/hadoop-hdds/datanode-grpc-client/src/main/resources/proto.lock
@@ -0,0 +1,3 @@
+{
+ "definitions": []
+}
\ No newline at end of file
diff --git a/hadoop-hdds/framework/pom.xml b/hadoop-hdds/framework/pom.xml
index 34dcdde921fc..b81fa9484ecd 100644
--- a/hadoop-hdds/framework/pom.xml
+++ b/hadoop-hdds/framework/pom.xml
@@ -86,16 +86,6 @@
io.dropwizard.metrics
metrics-core
-
- io.grpc
- grpc-api
-
-
- com.google.code.findbugs
- jsr305
-
-
-
io.opentelemetry
opentelemetry-api
@@ -322,6 +312,11 @@
test-jar
test
+
+ org.apache.ozone
+ hdds-datanode-grpc-client
+ test
+
org.apache.ozone
hdds-managed-rocksdb
@@ -415,6 +410,26 @@
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ analyze
+
+
+
+ org.eclipse.jetty:jetty-http
+
+
+
+
+
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/grpc/metrics/GrpcMetricsServerRequestInterceptor.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/grpc/metrics/GrpcMetricsServerRequestInterceptor.java
index 45041fec5045..874136f5b1b1 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/grpc/metrics/GrpcMetricsServerRequestInterceptor.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/grpc/metrics/GrpcMetricsServerRequestInterceptor.java
@@ -17,12 +17,12 @@
package org.apache.hadoop.ozone.grpc.metrics;
-import com.google.protobuf.AbstractMessage;
-import io.grpc.ForwardingServerCallListener.SimpleForwardingServerCallListener;
-import io.grpc.Metadata;
-import io.grpc.ServerCall;
-import io.grpc.ServerCallHandler;
-import io.grpc.ServerInterceptor;
+import org.apache.ratis.thirdparty.com.google.protobuf.AbstractMessage;
+import org.apache.ratis.thirdparty.io.grpc.ForwardingServerCallListener.SimpleForwardingServerCallListener;
+import org.apache.ratis.thirdparty.io.grpc.Metadata;
+import org.apache.ratis.thirdparty.io.grpc.ServerCall;
+import org.apache.ratis.thirdparty.io.grpc.ServerCallHandler;
+import org.apache.ratis.thirdparty.io.grpc.ServerInterceptor;
/**
* Interceptor to gather metrics based on grpc server request.
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/grpc/metrics/GrpcMetricsServerResponseInterceptor.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/grpc/metrics/GrpcMetricsServerResponseInterceptor.java
index f8c8ad6027e8..58dedb4af0de 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/grpc/metrics/GrpcMetricsServerResponseInterceptor.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/grpc/metrics/GrpcMetricsServerResponseInterceptor.java
@@ -17,12 +17,12 @@
package org.apache.hadoop.ozone.grpc.metrics;
-import com.google.protobuf.AbstractMessage;
-import io.grpc.ForwardingServerCall;
-import io.grpc.Metadata;
-import io.grpc.ServerCall;
-import io.grpc.ServerCallHandler;
-import io.grpc.ServerInterceptor;
+import org.apache.ratis.thirdparty.com.google.protobuf.AbstractMessage;
+import org.apache.ratis.thirdparty.io.grpc.ForwardingServerCall;
+import org.apache.ratis.thirdparty.io.grpc.Metadata;
+import org.apache.ratis.thirdparty.io.grpc.ServerCall;
+import org.apache.ratis.thirdparty.io.grpc.ServerCallHandler;
+import org.apache.ratis.thirdparty.io.grpc.ServerInterceptor;
/**
* Interceptor to gather metrics based on grpc server response.
diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/grpc/metrics/GrpcMetricsServerTransportFilter.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/grpc/metrics/GrpcMetricsServerTransportFilter.java
index 434dd9017b26..2f4fac78a58b 100644
--- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/grpc/metrics/GrpcMetricsServerTransportFilter.java
+++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/grpc/metrics/GrpcMetricsServerTransportFilter.java
@@ -17,8 +17,8 @@
package org.apache.hadoop.ozone.grpc.metrics;
-import io.grpc.Attributes;
-import io.grpc.ServerTransportFilter;
+import org.apache.ratis.thirdparty.io.grpc.Attributes;
+import org.apache.ratis.thirdparty.io.grpc.ServerTransportFilter;
/**
* Transport filter class for tracking active client connections.
diff --git a/hadoop-hdds/interface-client/pom.xml b/hadoop-hdds/interface-client/pom.xml
index ca9a6aa95bcd..ead525a2529c 100644
--- a/hadoop-hdds/interface-client/pom.xml
+++ b/hadoop-hdds/interface-client/pom.xml
@@ -23,11 +23,17 @@
2.2.0-SNAPSHOT
jar
Apache Ozone HDDS Client Interface
- Apache Ozone Distributed Data Store Client interface
+ Apache Ozone Distributed Data Store Client interface.
+ Also contains the ContainerProtos message classes generated from DatanodeClientProtocol.proto
+ and rewritten to the ratis-thirdparty shaded namespace so that hdds-common and other
+ foundational modules can depend on the shaded types without pulling in the gRPC stubs.
+
+ yyyyMMddHHmmss
true
+ true
true
@@ -38,6 +44,12 @@
protobuf-java
+
org.apache.ratis
ratis-thirdparty-misc
@@ -49,6 +61,39 @@
+
+
+
+ com.gradle
+ develocity-maven-extension
+
+
+
+
+
+ maven-compiler-plugin
+
+ compiles generated sources
+
+
+
+ maven-antrun-plugin
+
+ rewrites generated source files
+
+
+
+ protobuf-maven-plugin
+
+ generates sources
+
+
+
+
+
+
+
+
com.salesforce.servicelibs
@@ -59,6 +104,7 @@
maven-compiler-plugin
none
+ false
@@ -66,37 +112,43 @@
protobuf-maven-plugin
- compile-proto-for-ratis
+ compile-proto-${protobuf.version}
compile
test-compile
- compile-custom
- test-compile-custom
- com.google.protobuf:protoc:${ratis-thirdparty.protobuf.version}:exe:${os.detected.classifier}
-
- DatanodeClientProtocol.proto
-
- target/generated-sources/proto-java-for-ratis
+ com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}
+ target/generated-sources/proto-java-for-protobuf-${protobuf.version}
+ ${java.io.tmpdir}/ozone-protoc-dependencies/${project.artifactId}/protobuf-${protobuf.version}-${maven.build.timestamp}
false
- grpc-java
- io.grpc:protoc-gen-grpc-java:${ratis-thirdparty.grpc.version}:exe:${os.detected.classifier}
+
+
+ DatanodeClientProtocol.proto
+
- compile-proto-${protobuf.version}
+
+ compile-proto-datanode-ratis
compile
- test-compile
+ generate-sources
- com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}
-
- DatanodeClientProtocol.proto
-
- target/generated-sources/proto-java-for-protobuf-${protobuf.version}
+ com.google.protobuf:protoc:${ratis-thirdparty.protobuf.version}:exe:${os.detected.classifier}
+ ${project.build.directory}/generated-sources/proto-java-ratis
+ ${java.io.tmpdir}/ozone-protoc-dependencies/${project.artifactId}/ratis-${maven.build.timestamp}
false
+
+ DatanodeClientProtocol.proto
+
@@ -106,16 +158,21 @@
maven-antrun-plugin
+
+ rewrite-generated-sources-to-ratis-ns
run
- generate-sources
+ process-sources
-
-
-
-
+
+
diff --git a/hadoop-hdds/interface-server/pom.xml b/hadoop-hdds/interface-server/pom.xml
index b914a3d4ab4c..b795917a79cd 100644
--- a/hadoop-hdds/interface-server/pom.xml
+++ b/hadoop-hdds/interface-server/pom.xml
@@ -26,6 +26,8 @@
Apache Ozone Distributed Data Store Server interface
+
+ yyyyMMddHHmmss
true
@@ -42,10 +44,6 @@
org.apache.ozone
hdds-interface-client
-
- org.apache.ratis
- ratis-thirdparty-misc
-
javax.annotation
@@ -54,6 +52,33 @@
+
+
+
+ com.gradle
+ develocity-maven-extension
+
+
+
+
+
+ maven-compiler-plugin
+
+ compiles generated sources
+
+
+
+ protobuf-maven-plugin
+
+ generates sources
+
+
+
+
+
+
+
+
com.salesforce.servicelibs
@@ -70,27 +95,6 @@
org.xolstice.maven.plugins
protobuf-maven-plugin
-
- compile-proto-for-ratis
-
- compile
- test-compile
- compile-custom
- test-compile-custom
-
-
- com.google.protobuf:protoc:${ratis-thirdparty.protobuf.version}:exe:${os.detected.classifier}
-
- InterSCMProtocol.proto
- SCMUpdateProtocol.proto
- SCMRatisProtocol.proto
-
- target/generated-sources/proto-java-for-ratis
- false
- grpc-java
- io.grpc:protoc-gen-grpc-java:${ratis-thirdparty.grpc.version}:exe:${os.detected.classifier}
-
-
compile-proto-${protobuf.version}
@@ -99,37 +103,13 @@
com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}
-
- InterSCMProtocol.proto
- SCMUpdateProtocol.proto
- SCMRatisProtocol.proto
-
target/generated-sources/proto-java-for-protobuf-${protobuf.version}
+ ${java.io.tmpdir}/ozone-protoc-dependencies/${project.artifactId}/protobuf-${protobuf.version}-${maven.build.timestamp}
false
-
- org.apache.maven.plugins
- maven-antrun-plugin
-
-
-
- run
-
- generate-sources
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hadoop-hdds/interface-server/src/main/resources/proto.lock b/hadoop-hdds/interface-server/src/main/resources/proto.lock
index 822a2f88ebe8..67a2b8f24b19 100644
--- a/hadoop-hdds/interface-server/src/main/resources/proto.lock
+++ b/hadoop-hdds/interface-server/src/main/resources/proto.lock
@@ -1,473 +1,5 @@
{
"definitions": [
- {
- "protopath": "InterSCMProtocol.proto",
- "def": {
- "messages": [
- {
- "name": "CopyDBCheckpointRequestProto",
- "fields": [
- {
- "id": 1,
- "name": "flush",
- "type": "bool",
- "required": true
- }
- ]
- },
- {
- "name": "CopyDBCheckpointResponseProto",
- "fields": [
- {
- "id": 1,
- "name": "clusterId",
- "type": "string",
- "required": true
- },
- {
- "id": 2,
- "name": "len",
- "type": "uint64",
- "required": true
- },
- {
- "id": 3,
- "name": "eof",
- "type": "bool",
- "required": true
- },
- {
- "id": 4,
- "name": "data",
- "type": "bytes",
- "required": true
- },
- {
- "id": 6,
- "name": "readOffset",
- "type": "uint64",
- "required": true
- },
- {
- "id": 7,
- "name": "checksum",
- "type": "int64",
- "optional": true
- }
- ]
- }
- ],
- "services": [
- {
- "name": "InterSCMProtocolService",
- "rpcs": [
- {
- "name": "download",
- "in_type": "CopyDBCheckpointRequestProto",
- "out_type": "CopyDBCheckpointResponseProto",
- "out_streamed": true
- }
- ]
- }
- ],
- "package": {
- "name": "hadoop.hdds.security"
- },
- "options": [
- {
- "name": "java_package",
- "value": "org.apache.hadoop.hdds.protocol.scm.proto"
- },
- {
- "name": "java_outer_classname",
- "value": "InterSCMProtocolProtos"
- },
- {
- "name": "java_generate_equals_and_hash",
- "value": "true"
- }
- ]
- }
- },
- {
- "protopath": "SCMRatisProtocol.proto",
- "def": {
- "enums": [
- {
- "name": "RequestType",
- "enum_fields": [
- {
- "name": "PIPELINE",
- "integer": 1
- },
- {
- "name": "CONTAINER",
- "integer": 2
- },
- {
- "name": "BLOCK",
- "integer": 3
- },
- {
- "name": "SEQUENCE_ID",
- "integer": 4
- },
- {
- "name": "CERT_STORE",
- "integer": 5
- },
- {
- "name": "MOVE",
- "integer": 6
- },
- {
- "name": "STATEFUL_SERVICE_CONFIG",
- "integer": 7
- },
- {
- "name": "FINALIZE",
- "integer": 8
- },
- {
- "name": "SECRET_KEY",
- "integer": 9
- },
- {
- "name": "CERT_ROTATE",
- "integer": 10
- }
- ]
- }
- ],
- "messages": [
- {
- "name": "Method",
- "fields": [
- {
- "id": 1,
- "name": "name",
- "type": "string",
- "required": true
- },
- {
- "id": 2,
- "name": "args",
- "type": "MethodArgument",
- "is_repeated": true
- }
- ]
- },
- {
- "name": "MethodArgument",
- "fields": [
- {
- "id": 1,
- "name": "type",
- "type": "string",
- "required": true
- },
- {
- "id": 2,
- "name": "value",
- "type": "bytes",
- "required": true
- }
- ]
- },
- {
- "name": "ListArgument",
- "fields": [
- {
- "id": 1,
- "name": "type",
- "type": "string",
- "required": true
- },
- {
- "id": 2,
- "name": "value",
- "type": "bytes",
- "is_repeated": true
- }
- ]
- },
- {
- "name": "SCMRatisRequestProto",
- "fields": [
- {
- "id": 1,
- "name": "type",
- "type": "RequestType",
- "required": true
- },
- {
- "id": 2,
- "name": "method",
- "type": "Method",
- "required": true
- }
- ]
- },
- {
- "name": "SCMRatisResponseProto",
- "fields": [
- {
- "id": 2,
- "name": "type",
- "type": "string",
- "required": true
- },
- {
- "id": 3,
- "name": "value",
- "type": "bytes",
- "required": true
- }
- ]
- }
- ],
- "package": {
- "name": "hadoop.hdds.security"
- },
- "options": [
- {
- "name": "java_package",
- "value": "org.apache.hadoop.hdds.protocol.proto"
- },
- {
- "name": "java_outer_classname",
- "value": "SCMRatisProtocol"
- },
- {
- "name": "java_generate_equals_and_hash",
- "value": "true"
- }
- ]
- }
- },
- {
- "protopath": "SCMUpdateProtocol.proto",
- "def": {
- "enums": [
- {
- "name": "Type",
- "enum_fields": [
- {
- "name": "CRLUpdate",
- "integer": 1
- },
- {
- "name": "PipelineUpdate",
- "integer": 2
- }
- ]
- }
- ],
- "messages": [
- {
- "name": "CRLInfoProto",
- "fields": [
- {
- "id": 1,
- "name": "x509CRL",
- "type": "string",
- "required": true
- },
- {
- "id": 2,
- "name": "creationTimestamp",
- "type": "uint64",
- "required": true
- },
- {
- "id": 3,
- "name": "crlSequenceID",
- "type": "int64",
- "required": true
- }
- ]
- },
- {
- "name": "ClientId",
- "fields": [
- {
- "id": 1,
- "name": "msb",
- "type": "int64",
- "required": true
- },
- {
- "id": 2,
- "name": "lsb",
- "type": "int64",
- "required": true
- }
- ]
- },
- {
- "name": "SubscribeRequest",
- "fields": [
- {
- "id": 1,
- "name": "hostname",
- "type": "string",
- "optional": true
- }
- ]
- },
- {
- "name": "SubscribeResponse",
- "fields": [
- {
- "id": 1,
- "name": "clientId",
- "type": "ClientId",
- "required": true
- }
- ]
- },
- {
- "name": "UpdateRequest",
- "fields": [
- {
- "id": 1,
- "name": "updateType",
- "type": "Type",
- "required": true
- },
- {
- "id": 2,
- "name": "traceID",
- "type": "string",
- "optional": true
- },
- {
- "id": 3,
- "name": "clientId",
- "type": "ClientId",
- "required": true
- },
- {
- "id": 4,
- "name": "crlUpdateRequest",
- "type": "CRLUpdateRequest",
- "optional": true
- }
- ]
- },
- {
- "name": "UpdateResponse",
- "fields": [
- {
- "id": 1,
- "name": "updateType",
- "type": "Type",
- "required": true
- },
- {
- "id": 2,
- "name": "traceID",
- "type": "string",
- "optional": true
- },
- {
- "id": 3,
- "name": "crlUpdateResponse",
- "type": "CRLUpdateResponse",
- "optional": true
- }
- ]
- },
- {
- "name": "CRLUpdateRequest",
- "fields": [
- {
- "id": 1,
- "name": "receivedCrlId",
- "type": "int64",
- "required": true
- },
- {
- "id": 2,
- "name": "pendingCrlIds",
- "type": "int64",
- "is_repeated": true
- }
- ]
- },
- {
- "name": "CRLUpdateResponse",
- "fields": [
- {
- "id": 1,
- "name": "crlInfo",
- "type": "CRLInfoProto",
- "optional": true
- }
- ]
- },
- {
- "name": "UnsubscribeRequest",
- "fields": [
- {
- "id": 1,
- "name": "clientId",
- "type": "ClientId",
- "required": true
- }
- ]
- },
- {
- "name": "UnsubscribeResponse"
- }
- ],
- "services": [
- {
- "name": "SCMUpdateService",
- "rpcs": [
- {
- "name": "subscribe",
- "in_type": "SubscribeRequest",
- "out_type": "SubscribeResponse"
- },
- {
- "name": "updateStatus",
- "in_type": "UpdateRequest",
- "out_type": "UpdateResponse",
- "in_streamed": true,
- "out_streamed": true
- },
- {
- "name": "unsubscribe",
- "in_type": "UnsubscribeRequest",
- "out_type": "UnsubscribeResponse"
- }
- ]
- }
- ],
- "package": {
- "name": "hadoop.hdds.scm"
- },
- "options": [
- {
- "name": "java_package",
- "value": "org.apache.hadoop.hdds.protocol.scm.proto"
- },
- {
- "name": "java_outer_classname",
- "value": "SCMUpdateServiceProtos"
- },
- {
- "name": "java_generate_equals_and_hash",
- "value": "true"
- },
- {
- "name": "java_generic_services",
- "value": "true"
- }
- ]
- }
- },
{
"protopath": "ScmSecretKeyProtocol.proto",
"def": {
@@ -3762,4 +3294,4 @@
}
}
]
-}
\ No newline at end of file
+}
diff --git a/hadoop-hdds/pom.xml b/hadoop-hdds/pom.xml
index cfd22b1bfc7a..2bf317f33110 100644
--- a/hadoop-hdds/pom.xml
+++ b/hadoop-hdds/pom.xml
@@ -35,6 +35,7 @@
container-service
crypto-api
crypto-default
+ datanode-grpc-client
docs
erasurecode
framework
@@ -45,6 +46,7 @@
managed-rocksdb
rocks-native
rocksdb-checkpoint-differ
+ scm-grpc-client
server-scm
test-utils
diff --git a/hadoop-hdds/scm-grpc-client/pom.xml b/hadoop-hdds/scm-grpc-client/pom.xml
new file mode 100644
index 000000000000..31c5476660e8
--- /dev/null
+++ b/hadoop-hdds/scm-grpc-client/pom.xml
@@ -0,0 +1,175 @@
+
+
+
+ 4.0.0
+
+ org.apache.ozone
+ hdds
+ 2.2.0-SNAPSHOT
+
+ hdds-scm-grpc-client
+ 2.2.0-SNAPSHOT
+ jar
+ Apache Ozone HDDS SCM gRPC Client
+ SCM internal gRPC stubs generated from InterSCMProtocol.proto, SCMUpdateProtocol.proto, and
+ SCMRatisProtocol.proto. Package names in generated sources are rewritten by maven-antrun-plugin (Ant
+ replace task, pure Java) from vanilla com.google.protobuf / io.grpc / com.google.common to their
+ ratis-thirdparty counterparts before compilation. Replaces the antrun source-rewriting approach
+ previously in hdds-interface-server.
+
+
+
+ yyyyMMddHHmmss
+
+ true
+ true
+ true
+
+
+
+
+
+ org.apache.ratis
+ ratis-thirdparty-misc
+
+
+
+ javax.annotation
+ javax.annotation-api
+ provided
+
+
+
+
+
+
+
+ com.gradle
+ develocity-maven-extension
+
+
+
+
+ maven-compiler-plugin
+
+ compiles generated + rewritten sources
+
+
+
+ maven-antrun-plugin
+
+ rewrites generated source files
+
+
+
+ protobuf-maven-plugin
+
+ generates sources
+
+
+
+
+
+
+
+
+
+
+ com.salesforce.servicelibs
+ proto-backwards-compatibility
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ none
+ false
+
+
+
+ org.xolstice.maven.plugins
+ protobuf-maven-plugin
+
+
+ compile-proto-scm
+
+ compile
+ compile-custom
+
+ generate-sources
+
+
+ com.google.protobuf:protoc:${ratis-thirdparty.protobuf.version}:exe:${os.detected.classifier}
+ ${project.build.directory}/generated-sources/proto-java-ratis
+ ${java.io.tmpdir}/ozone-protoc-dependencies/${project.artifactId}/${maven.build.timestamp}
+ false
+ grpc-java
+ io.grpc:protoc-gen-grpc-java:${ratis-thirdparty.grpc.version}:exe:${os.detected.classifier}
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+
+
+
+ pre-verify-refresh-classes-from-jar
+ none
+
+
+
+ rewrite-generated-sources-to-ratis-ns
+
+ run
+
+ process-sources
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hadoop-hdds/interface-server/src/main/proto/InterSCMProtocol.proto b/hadoop-hdds/scm-grpc-client/src/main/proto/InterSCMProtocol.proto
similarity index 100%
rename from hadoop-hdds/interface-server/src/main/proto/InterSCMProtocol.proto
rename to hadoop-hdds/scm-grpc-client/src/main/proto/InterSCMProtocol.proto
diff --git a/hadoop-hdds/interface-server/src/main/proto/SCMRatisProtocol.proto b/hadoop-hdds/scm-grpc-client/src/main/proto/SCMRatisProtocol.proto
similarity index 100%
rename from hadoop-hdds/interface-server/src/main/proto/SCMRatisProtocol.proto
rename to hadoop-hdds/scm-grpc-client/src/main/proto/SCMRatisProtocol.proto
diff --git a/hadoop-hdds/interface-server/src/main/proto/SCMUpdateProtocol.proto b/hadoop-hdds/scm-grpc-client/src/main/proto/SCMUpdateProtocol.proto
similarity index 100%
rename from hadoop-hdds/interface-server/src/main/proto/SCMUpdateProtocol.proto
rename to hadoop-hdds/scm-grpc-client/src/main/proto/SCMUpdateProtocol.proto
diff --git a/hadoop-hdds/scm-grpc-client/src/main/resources/proto.lock b/hadoop-hdds/scm-grpc-client/src/main/resources/proto.lock
new file mode 100644
index 000000000000..72c30be919da
--- /dev/null
+++ b/hadoop-hdds/scm-grpc-client/src/main/resources/proto.lock
@@ -0,0 +1,472 @@
+{
+ "definitions": [
+ {
+ "protopath": "InterSCMProtocol.proto",
+ "def": {
+ "messages": [
+ {
+ "name": "CopyDBCheckpointRequestProto",
+ "fields": [
+ {
+ "id": 1,
+ "name": "flush",
+ "type": "bool",
+ "required": true
+ }
+ ]
+ },
+ {
+ "name": "CopyDBCheckpointResponseProto",
+ "fields": [
+ {
+ "id": 1,
+ "name": "clusterId",
+ "type": "string",
+ "required": true
+ },
+ {
+ "id": 2,
+ "name": "len",
+ "type": "uint64",
+ "required": true
+ },
+ {
+ "id": 3,
+ "name": "eof",
+ "type": "bool",
+ "required": true
+ },
+ {
+ "id": 4,
+ "name": "data",
+ "type": "bytes",
+ "required": true
+ },
+ {
+ "id": 6,
+ "name": "readOffset",
+ "type": "uint64",
+ "required": true
+ },
+ {
+ "id": 7,
+ "name": "checksum",
+ "type": "int64",
+ "optional": true
+ }
+ ]
+ }
+ ],
+ "services": [
+ {
+ "name": "InterSCMProtocolService",
+ "rpcs": [
+ {
+ "name": "download",
+ "in_type": "CopyDBCheckpointRequestProto",
+ "out_type": "CopyDBCheckpointResponseProto",
+ "out_streamed": true
+ }
+ ]
+ }
+ ],
+ "package": {
+ "name": "hadoop.hdds.security"
+ },
+ "options": [
+ {
+ "name": "java_package",
+ "value": "org.apache.hadoop.hdds.protocol.scm.proto"
+ },
+ {
+ "name": "java_outer_classname",
+ "value": "InterSCMProtocolProtos"
+ },
+ {
+ "name": "java_generate_equals_and_hash",
+ "value": "true"
+ }
+ ]
+ }
+ },
+ {
+ "protopath": "SCMRatisProtocol.proto",
+ "def": {
+ "enums": [
+ {
+ "name": "RequestType",
+ "enum_fields": [
+ {
+ "name": "PIPELINE",
+ "integer": 1
+ },
+ {
+ "name": "CONTAINER",
+ "integer": 2
+ },
+ {
+ "name": "BLOCK",
+ "integer": 3
+ },
+ {
+ "name": "SEQUENCE_ID",
+ "integer": 4
+ },
+ {
+ "name": "CERT_STORE",
+ "integer": 5
+ },
+ {
+ "name": "MOVE",
+ "integer": 6
+ },
+ {
+ "name": "STATEFUL_SERVICE_CONFIG",
+ "integer": 7
+ },
+ {
+ "name": "FINALIZE",
+ "integer": 8
+ },
+ {
+ "name": "SECRET_KEY",
+ "integer": 9
+ },
+ {
+ "name": "CERT_ROTATE",
+ "integer": 10
+ }
+ ]
+ }
+ ],
+ "messages": [
+ {
+ "name": "Method",
+ "fields": [
+ {
+ "id": 1,
+ "name": "name",
+ "type": "string",
+ "required": true
+ },
+ {
+ "id": 2,
+ "name": "args",
+ "type": "MethodArgument",
+ "is_repeated": true
+ }
+ ]
+ },
+ {
+ "name": "MethodArgument",
+ "fields": [
+ {
+ "id": 1,
+ "name": "type",
+ "type": "string",
+ "required": true
+ },
+ {
+ "id": 2,
+ "name": "value",
+ "type": "bytes",
+ "required": true
+ }
+ ]
+ },
+ {
+ "name": "ListArgument",
+ "fields": [
+ {
+ "id": 1,
+ "name": "type",
+ "type": "string",
+ "required": true
+ },
+ {
+ "id": 2,
+ "name": "value",
+ "type": "bytes",
+ "is_repeated": true
+ }
+ ]
+ },
+ {
+ "name": "SCMRatisRequestProto",
+ "fields": [
+ {
+ "id": 1,
+ "name": "type",
+ "type": "RequestType",
+ "required": true
+ },
+ {
+ "id": 2,
+ "name": "method",
+ "type": "Method",
+ "required": true
+ }
+ ]
+ },
+ {
+ "name": "SCMRatisResponseProto",
+ "fields": [
+ {
+ "id": 2,
+ "name": "type",
+ "type": "string",
+ "required": true
+ },
+ {
+ "id": 3,
+ "name": "value",
+ "type": "bytes",
+ "required": true
+ }
+ ]
+ }
+ ],
+ "package": {
+ "name": "hadoop.hdds.security"
+ },
+ "options": [
+ {
+ "name": "java_package",
+ "value": "org.apache.hadoop.hdds.protocol.proto"
+ },
+ {
+ "name": "java_outer_classname",
+ "value": "SCMRatisProtocol"
+ },
+ {
+ "name": "java_generate_equals_and_hash",
+ "value": "true"
+ }
+ ]
+ }
+ },
+ {
+ "protopath": "SCMUpdateProtocol.proto",
+ "def": {
+ "enums": [
+ {
+ "name": "Type",
+ "enum_fields": [
+ {
+ "name": "CRLUpdate",
+ "integer": 1
+ },
+ {
+ "name": "PipelineUpdate",
+ "integer": 2
+ }
+ ]
+ }
+ ],
+ "messages": [
+ {
+ "name": "CRLInfoProto",
+ "fields": [
+ {
+ "id": 1,
+ "name": "x509CRL",
+ "type": "string",
+ "required": true
+ },
+ {
+ "id": 2,
+ "name": "creationTimestamp",
+ "type": "uint64",
+ "required": true
+ },
+ {
+ "id": 3,
+ "name": "crlSequenceID",
+ "type": "int64",
+ "required": true
+ }
+ ]
+ },
+ {
+ "name": "ClientId",
+ "fields": [
+ {
+ "id": 1,
+ "name": "msb",
+ "type": "int64",
+ "required": true
+ },
+ {
+ "id": 2,
+ "name": "lsb",
+ "type": "int64",
+ "required": true
+ }
+ ]
+ },
+ {
+ "name": "SubscribeRequest",
+ "fields": [
+ {
+ "id": 1,
+ "name": "hostname",
+ "type": "string",
+ "optional": true
+ }
+ ]
+ },
+ {
+ "name": "SubscribeResponse",
+ "fields": [
+ {
+ "id": 1,
+ "name": "clientId",
+ "type": "ClientId",
+ "required": true
+ }
+ ]
+ },
+ {
+ "name": "UpdateRequest",
+ "fields": [
+ {
+ "id": 1,
+ "name": "updateType",
+ "type": "Type",
+ "required": true
+ },
+ {
+ "id": 2,
+ "name": "traceID",
+ "type": "string",
+ "optional": true
+ },
+ {
+ "id": 3,
+ "name": "clientId",
+ "type": "ClientId",
+ "required": true
+ },
+ {
+ "id": 4,
+ "name": "crlUpdateRequest",
+ "type": "CRLUpdateRequest",
+ "optional": true
+ }
+ ]
+ },
+ {
+ "name": "UpdateResponse",
+ "fields": [
+ {
+ "id": 1,
+ "name": "updateType",
+ "type": "Type",
+ "required": true
+ },
+ {
+ "id": 2,
+ "name": "traceID",
+ "type": "string",
+ "optional": true
+ },
+ {
+ "id": 3,
+ "name": "crlUpdateResponse",
+ "type": "CRLUpdateResponse",
+ "optional": true
+ }
+ ]
+ },
+ {
+ "name": "CRLUpdateRequest",
+ "fields": [
+ {
+ "id": 1,
+ "name": "receivedCrlId",
+ "type": "int64",
+ "required": true
+ },
+ {
+ "id": 2,
+ "name": "pendingCrlIds",
+ "type": "int64",
+ "is_repeated": true
+ }
+ ]
+ },
+ {
+ "name": "CRLUpdateResponse",
+ "fields": [
+ {
+ "id": 1,
+ "name": "crlInfo",
+ "type": "CRLInfoProto",
+ "optional": true
+ }
+ ]
+ },
+ {
+ "name": "UnsubscribeRequest",
+ "fields": [
+ {
+ "id": 1,
+ "name": "clientId",
+ "type": "ClientId",
+ "required": true
+ }
+ ]
+ },
+ {
+ "name": "UnsubscribeResponse"
+ }
+ ],
+ "services": [
+ {
+ "name": "SCMUpdateService",
+ "rpcs": [
+ {
+ "name": "subscribe",
+ "in_type": "SubscribeRequest",
+ "out_type": "SubscribeResponse"
+ },
+ {
+ "name": "updateStatus",
+ "in_type": "UpdateRequest",
+ "out_type": "UpdateResponse",
+ "in_streamed": true,
+ "out_streamed": true
+ },
+ {
+ "name": "unsubscribe",
+ "in_type": "UnsubscribeRequest",
+ "out_type": "UnsubscribeResponse"
+ }
+ ]
+ }
+ ],
+ "package": {
+ "name": "hadoop.hdds.scm"
+ },
+ "options": [
+ {
+ "name": "java_package",
+ "value": "org.apache.hadoop.hdds.protocol.scm.proto"
+ },
+ {
+ "name": "java_outer_classname",
+ "value": "SCMUpdateServiceProtos"
+ },
+ {
+ "name": "java_generate_equals_and_hash",
+ "value": "true"
+ },
+ {
+ "name": "java_generic_services",
+ "value": "true"
+ }
+ ]
+ }
+ }
+ ]
+}
diff --git a/hadoop-hdds/server-scm/pom.xml b/hadoop-hdds/server-scm/pom.xml
index a169bea52048..cc576d103e1c 100644
--- a/hadoop-hdds/server-scm/pom.xml
+++ b/hadoop-hdds/server-scm/pom.xml
@@ -41,7 +41,8 @@
com.fasterxml.jackson.core
jackson-databind
-
+
com.google.guava
@@ -74,7 +75,8 @@
org.apache.commons
commons-compress
-
+
org.apache.commons
@@ -95,7 +97,8 @@
org.apache.ozone
hdds-client
-
+
org.apache.ozone
@@ -125,6 +128,10 @@
org.apache.ozone
hdds-managed-rocksdb
+
+ org.apache.ozone
+ hdds-scm-grpc-client
+
org.apache.ozone
hdds-server-framework
diff --git a/hadoop-ozone/cli-shell/pom.xml b/hadoop-ozone/cli-shell/pom.xml
index d824ac082bad..2a7dca1b8601 100644
--- a/hadoop-ozone/cli-shell/pom.xml
+++ b/hadoop-ozone/cli-shell/pom.xml
@@ -205,6 +205,25 @@
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ analyze
+
+
+
+ org.apache.ratis:ratis-common
+
+
+
+
+
diff --git a/hadoop-ozone/common/pom.xml b/hadoop-ozone/common/pom.xml
index 13a53cdc7a88..7de31464d4e6 100644
--- a/hadoop-ozone/common/pom.xml
+++ b/hadoop-ozone/common/pom.xml
@@ -47,24 +47,6 @@
com.google.protobuf
protobuf-java
-
- io.grpc
- grpc-api
-
-
- com.google.code.findbugs
- jsr305
-
-
-
-
- io.grpc
- grpc-netty
-
-
- io.netty
- netty-handler
-
jakarta.annotation
jakarta.annotation-api
@@ -125,12 +107,6 @@
org.slf4j
slf4j-api
-
-
- io.grpc
- grpc-stub
- provided
-
io.netty
netty-codec-http2
@@ -147,16 +123,6 @@
runtime
-
- io.grpc
- grpc-inprocess
- test
-
-
- io.grpc
- grpc-testing
- test
-
org.apache.ozone
hdds-test-utils
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/ha/GrpcOMFailoverProxyProvider.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/ha/GrpcOMFailoverProxyProvider.java
index 41cd45956547..c29d145d6d95 100644
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/ha/GrpcOMFailoverProxyProvider.java
+++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/ha/GrpcOMFailoverProxyProvider.java
@@ -20,8 +20,6 @@
import static org.apache.hadoop.hdds.HddsUtils.getHostNameFromConfigKeys;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ADDRESS_KEY;
-import io.grpc.Status;
-import io.grpc.StatusRuntimeException;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.ArrayList;
@@ -38,6 +36,8 @@
import org.apache.hadoop.ozone.om.OMConfigKeys;
import org.apache.hadoop.ozone.om.protocolPB.GrpcOmTransport;
import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.ratis.thirdparty.io.grpc.Status;
+import org.apache.ratis.thirdparty.io.grpc.StatusRuntimeException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/GrpcOmTransport.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/GrpcOmTransport.java
index e794107cd54d..a07cac451c53 100644
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/GrpcOmTransport.java
+++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/GrpcOmTransport.java
@@ -23,14 +23,11 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.net.HostAndPort;
-import io.grpc.Context;
-import io.grpc.ManagedChannel;
-import io.grpc.Status;
-import io.grpc.StatusRuntimeException;
-import io.grpc.netty.GrpcSslContexts;
-import io.grpc.netty.NettyChannelBuilder;
-import io.netty.handler.ssl.SslContextBuilder;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.UncheckedIOException;
import java.lang.reflect.Constructor;
import java.net.InetAddress;
import java.security.cert.X509Certificate;
@@ -38,6 +35,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@@ -55,12 +53,30 @@
import org.apache.hadoop.ozone.om.exceptions.OMException;
import org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes;
import org.apache.hadoop.ozone.om.ha.GrpcOMFailoverProxyProvider;
-import org.apache.hadoop.ozone.om.protocolPB.grpc.ClientAddressClientInterceptor;
-import org.apache.hadoop.ozone.om.protocolPB.grpc.GrpcClientConstants;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse;
-import org.apache.hadoop.ozone.protocol.proto.OzoneManagerServiceGrpc;
import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.ratis.thirdparty.io.grpc.CallOptions;
+import org.apache.ratis.thirdparty.io.grpc.ClientCall;
+import org.apache.ratis.thirdparty.io.grpc.ClientInterceptor;
+import org.apache.ratis.thirdparty.io.grpc.ClientInterceptors;
+import org.apache.ratis.thirdparty.io.grpc.ForwardingClientCall;
+import org.apache.ratis.thirdparty.io.grpc.ManagedChannel;
+import org.apache.ratis.thirdparty.io.grpc.Metadata;
+import org.apache.ratis.thirdparty.io.grpc.MethodDescriptor;
+import org.apache.ratis.thirdparty.io.grpc.Status;
+import org.apache.ratis.thirdparty.io.grpc.StatusRuntimeException;
+import org.apache.ratis.thirdparty.io.grpc.netty.GrpcSslContexts;
+import org.apache.ratis.thirdparty.io.grpc.netty.NettyChannelBuilder;
+import org.apache.ratis.thirdparty.io.grpc.stub.ClientCalls;
+import org.apache.ratis.thirdparty.io.netty.channel.Channel;
+import org.apache.ratis.thirdparty.io.netty.channel.EventLoopGroup;
+import org.apache.ratis.thirdparty.io.netty.channel.epoll.Epoll;
+import org.apache.ratis.thirdparty.io.netty.channel.epoll.EpollEventLoopGroup;
+import org.apache.ratis.thirdparty.io.netty.channel.epoll.EpollSocketChannel;
+import org.apache.ratis.thirdparty.io.netty.channel.nio.NioEventLoopGroup;
+import org.apache.ratis.thirdparty.io.netty.channel.socket.nio.NioSocketChannel;
+import org.apache.ratis.thirdparty.io.netty.handler.ssl.SslContextBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -72,6 +88,7 @@ public class GrpcOmTransport implements OmTransport {
LoggerFactory.getLogger(GrpcOmTransport.class);
private static final String CLIENT_NAME = "GrpcOmTransport";
+ private static final String SERVICE_NAME = "hadoop.ozone.OzoneManagerService";
private static final int SHUTDOWN_WAIT_INTERVAL = 100;
private static final int SHUTDOWN_MAX_WAIT_SECONDS = 5;
private final AtomicBoolean isRunning = new AtomicBoolean(false);
@@ -79,8 +96,20 @@ public class GrpcOmTransport implements OmTransport {
// gRPC specific
private static List caCerts = null;
- private final Map clients;
+ private static final Metadata.Key CLIENT_HOSTNAME_METADATA_KEY =
+ Metadata.Key.of("CLIENT_HOSTNAME", Metadata.ASCII_STRING_MARSHALLER);
+ private static final Metadata.Key CLIENT_IP_ADDRESS_METADATA_KEY =
+ Metadata.Key.of("CLIENT_IP_ADDRESS", Metadata.ASCII_STRING_MARSHALLER);
+
+ private static final MethodDescriptor
+ SUBMIT_REQUEST_METHOD = MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName(MethodDescriptor.generateFullMethodName(
+ SERVICE_NAME, "submitRequest"))
+ .setRequestMarshaller(new Proto2Marshaller<>(OMRequest::parseFrom))
+ .setResponseMarshaller(new Proto2Marshaller<>(OMResponse::parseFrom))
+ .build();
+
private final Map channels;
private final ConfigurationSource conf;
@@ -88,6 +117,7 @@ public class GrpcOmTransport implements OmTransport {
private AtomicInteger globalFailoverCount;
private final int maxSize;
private final SecurityConfig secConfig;
+ private EventLoopGroup eventLoopGroup;
private RetryPolicy retryPolicy;
private final GrpcOMFailoverProxyProvider
@@ -102,7 +132,6 @@ public GrpcOmTransport(ConfigurationSource conf,
throws IOException {
this.channels = new HashMap<>();
- this.clients = new HashMap<>();
this.conf = conf;
this.host = new AtomicReference<>();
this.globalFailoverCount = new AtomicInteger();
@@ -130,6 +159,21 @@ public void start() throws IOException {
return;
}
+ ThreadFactory factory = new ThreadFactoryBuilder()
+ .setDaemon(true)
+ .setNameFormat(CLIENT_NAME + "-ELG-%d")
+ .build();
+
+ final Class extends Channel> channelType;
+ if (Epoll.isAvailable()) {
+ eventLoopGroup = new EpollEventLoopGroup(0, factory);
+ channelType = EpollSocketChannel.class;
+ } else {
+ eventLoopGroup = new NioEventLoopGroup(0, factory);
+ channelType = NioSocketChannel.class;
+ }
+ LOG.info("{} channel type {}", CLIENT_NAME, channelType.getSimpleName());
+
for (String nodeId : omFailoverProxyProvider.getOMProxyMap().getNodeIds()) {
String hostaddr = omFailoverProxyProvider.getGrpcProxyAddress(nodeId);
HostAndPort hp = HostAndPort.fromString(hostaddr);
@@ -137,6 +181,8 @@ public void start() throws IOException {
NettyChannelBuilder channelBuilder =
NettyChannelBuilder.forAddress(hp.getHost(), hp.getPort())
.usePlaintext()
+ .eventLoopGroup(eventLoopGroup)
+ .channelType(channelType)
.proxyDetector(uri -> null)
.maxInboundMessageSize(maxSize);
@@ -158,11 +204,7 @@ public void start() throws IOException {
}
channels.put(hostaddr,
- channelBuilder.intercept(new ClientAddressClientInterceptor())
- .build());
- clients.put(hostaddr,
- OzoneManagerServiceGrpc
- .newBlockingStub(channels.get(hostaddr)));
+ channelBuilder.build());
}
int maxFailovers = conf.getInt(
OzoneConfigKeys.OZONE_CLIENT_FAILOVER_MAX_ATTEMPTS_KEY,
@@ -184,13 +226,12 @@ public OMResponse submitRequest(OMRequest payload) throws IOException {
expectedFailoverCount = globalFailoverCount.get();
try {
InetAddress inetAddress = InetAddress.getLocalHost();
- Context.current()
- .withValue(GrpcClientConstants.CLIENT_IP_ADDRESS_CTX_KEY,
- inetAddress.getHostAddress())
- .withValue(GrpcClientConstants.CLIENT_HOSTNAME_CTX_KEY,
- inetAddress.getHostName())
- .run(() -> resp.set(clients.get(host.get())
- .submitRequest(payload)));
+ final ManagedChannel channel = channels.get(host.get());
+ if (channel == null) {
+ throw new OMException(ResultCodes.INTERNAL_ERROR);
+ }
+ resp.set(submitRequest(channel, payload,
+ inetAddress.getHostName(), inetAddress.getHostAddress()));
} catch (StatusRuntimeException e) {
LOG.error("Failed to submit request", e);
if (e.getStatus().getCode() == Status.Code.UNAVAILABLE) {
@@ -330,6 +371,15 @@ public void shutdown() {
LOG.warn("Channels {} did not terminate within timeout.", failedChannels);
}
+ if (eventLoopGroup != null) {
+ try {
+ eventLoopGroup.shutdownGracefully().sync();
+ } catch (InterruptedException e) {
+ LOG.error("Interrupted while shutting down event loop group", e);
+ Thread.currentThread().interrupt();
+ }
+ }
+
LOG.info("{}: stopped", CLIENT_NAME);
}
@@ -338,6 +388,75 @@ public void close() throws IOException {
shutdown();
}
+ private OMResponse submitRequest(ManagedChannel channel, OMRequest request,
+ String clientHostname, String clientIpAddress) {
+ Metadata headers = new Metadata();
+ if (clientHostname != null) {
+ headers.put(CLIENT_HOSTNAME_METADATA_KEY, clientHostname);
+ }
+ if (clientIpAddress != null) {
+ headers.put(CLIENT_IP_ADDRESS_METADATA_KEY, clientIpAddress);
+ }
+
+ org.apache.ratis.thirdparty.io.grpc.Channel intercepted =
+ ClientInterceptors.intercept(channel, new FixedHeadersInterceptor(headers));
+ return ClientCalls.blockingUnaryCall(intercepted, SUBMIT_REQUEST_METHOD,
+ CallOptions.DEFAULT, request);
+ }
+
+ private static final class FixedHeadersInterceptor implements ClientInterceptor {
+ private final Metadata headers;
+
+ private FixedHeadersInterceptor(Metadata headers) {
+ this.headers = headers;
+ }
+
+ @Override
+ public ClientCall interceptCall(
+ MethodDescriptor methodDescriptor,
+ CallOptions callOptions,
+ org.apache.ratis.thirdparty.io.grpc.Channel channel) {
+ return new ForwardingClientCall.SimpleForwardingClientCall(
+ channel.newCall(methodDescriptor, callOptions)) {
+ @Override
+ public void start(Listener responseListener, Metadata metadata) {
+ metadata.merge(headers);
+ super.start(responseListener, metadata);
+ }
+ };
+ }
+ }
+
+ private static final class Proto2Marshaller implements MethodDescriptor.Marshaller {
+ private final Proto2Parser parser;
+
+ private Proto2Marshaller(Proto2Parser parser) {
+ this.parser = parser;
+ }
+
+ @Override
+ public InputStream stream(T value) {
+ if (!(value instanceof com.google.protobuf.MessageLite)) {
+ throw new IllegalArgumentException("Expected protobuf request/response");
+ }
+ return new ByteArrayInputStream(((com.google.protobuf.MessageLite) value).toByteArray());
+ }
+
+ @Override
+ public T parse(InputStream stream) {
+ try {
+ return parser.parse(stream);
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+ }
+
+ @FunctionalInterface
+ private interface Proto2Parser {
+ T parse(InputStream stream) throws IOException;
+ }
+
/**
* GrpcOmTransport configuration in Java style configuration class.
*/
@@ -364,9 +483,7 @@ public void startClient(ManagedChannel testChannel) throws IOException {
for (String nodeId : omFailoverProxyProvider.getOMProxyMap().getNodeIds()) {
String hostaddr = omFailoverProxyProvider.getGrpcProxyAddress(nodeId);
- clients.put(hostaddr,
- OzoneManagerServiceGrpc
- .newBlockingStub(testChannel));
+ channels.put(hostaddr, testChannel);
}
LOG.info("{}: started", CLIENT_NAME);
}
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/grpc/ClientAddressClientInterceptor.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/grpc/ClientAddressClientInterceptor.java
index 85190d0b93f7..1ba921af04dc 100644
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/grpc/ClientAddressClientInterceptor.java
+++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/grpc/ClientAddressClientInterceptor.java
@@ -17,13 +17,13 @@
package org.apache.hadoop.ozone.om.protocolPB.grpc;
-import io.grpc.CallOptions;
-import io.grpc.Channel;
-import io.grpc.ClientCall;
-import io.grpc.ClientInterceptor;
-import io.grpc.ForwardingClientCall;
-import io.grpc.Metadata;
-import io.grpc.MethodDescriptor;
+import org.apache.ratis.thirdparty.io.grpc.CallOptions;
+import org.apache.ratis.thirdparty.io.grpc.Channel;
+import org.apache.ratis.thirdparty.io.grpc.ClientCall;
+import org.apache.ratis.thirdparty.io.grpc.ClientInterceptor;
+import org.apache.ratis.thirdparty.io.grpc.ForwardingClientCall;
+import org.apache.ratis.thirdparty.io.grpc.Metadata;
+import org.apache.ratis.thirdparty.io.grpc.MethodDescriptor;
/**
* GRPC client side interceptor to provide client hostname and IP address.
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/grpc/ClientAddressServerInterceptor.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/grpc/ClientAddressServerInterceptor.java
index f51eb2b6dc92..753fe9ff8eac 100644
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/grpc/ClientAddressServerInterceptor.java
+++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/grpc/ClientAddressServerInterceptor.java
@@ -17,12 +17,12 @@
package org.apache.hadoop.ozone.om.protocolPB.grpc;
-import io.grpc.Context;
-import io.grpc.Contexts;
-import io.grpc.Metadata;
-import io.grpc.ServerCall;
-import io.grpc.ServerCallHandler;
-import io.grpc.ServerInterceptor;
+import org.apache.ratis.thirdparty.io.grpc.Context;
+import org.apache.ratis.thirdparty.io.grpc.Contexts;
+import org.apache.ratis.thirdparty.io.grpc.Metadata;
+import org.apache.ratis.thirdparty.io.grpc.ServerCall;
+import org.apache.ratis.thirdparty.io.grpc.ServerCallHandler;
+import org.apache.ratis.thirdparty.io.grpc.ServerInterceptor;
/**
* GRPC server side interceptor to retrieve the client IP and hostname.
diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/grpc/GrpcClientConstants.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/grpc/GrpcClientConstants.java
index e59ec98ec784..fd5331b2d8eb 100644
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/grpc/GrpcClientConstants.java
+++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/grpc/GrpcClientConstants.java
@@ -17,8 +17,8 @@
package org.apache.hadoop.ozone.om.protocolPB.grpc;
-import io.grpc.Context;
-import io.grpc.Metadata;
+import org.apache.ratis.thirdparty.io.grpc.Context;
+import org.apache.ratis.thirdparty.io.grpc.Metadata;
/**
* Constants to store grpc-client specific header values.
diff --git a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/protocolPB/TestGrpcOmTransportConcurrentFailover.java b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/protocolPB/TestGrpcOmTransportConcurrentFailover.java
index c8890eaa49c8..1f5b31b63167 100644
--- a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/protocolPB/TestGrpcOmTransportConcurrentFailover.java
+++ b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/protocolPB/TestGrpcOmTransportConcurrentFailover.java
@@ -26,12 +26,8 @@
import static org.mockito.AdditionalAnswers.delegatesTo;
import static org.mockito.Mockito.mock;
-import io.grpc.Server;
-import io.grpc.ServerBuilder;
-import io.grpc.Status;
-import io.grpc.StatusRuntimeException;
-import io.grpc.stub.StreamObserver;
import java.io.IOException;
+import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.StringJoiner;
@@ -48,8 +44,15 @@
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
-import org.apache.hadoop.ozone.protocol.proto.OzoneManagerServiceGrpc;
import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.ratis.thirdparty.io.grpc.MethodDescriptor;
+import org.apache.ratis.thirdparty.io.grpc.Server;
+import org.apache.ratis.thirdparty.io.grpc.ServerServiceDefinition;
+import org.apache.ratis.thirdparty.io.grpc.Status;
+import org.apache.ratis.thirdparty.io.grpc.StatusRuntimeException;
+import org.apache.ratis.thirdparty.io.grpc.netty.NettyServerBuilder;
+import org.apache.ratis.thirdparty.io.grpc.stub.ServerCalls;
+import org.apache.ratis.thirdparty.io.grpc.stub.StreamObserver;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -63,6 +66,17 @@ public class TestGrpcOmTransportConcurrentFailover {
private static final Logger LOG =
LoggerFactory.getLogger(TestGrpcOmTransportConcurrentFailover.class);
+ private static final String SERVICE_NAME = "hadoop.ozone.OzoneManagerService";
+
+ private static final MethodDescriptor
+ SUBMIT_REQUEST_METHOD = MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName(MethodDescriptor.generateFullMethodName(
+ SERVICE_NAME, "submitRequest"))
+ .setRequestMarshaller(new Proto2Marshaller<>(OMRequest::parseFrom))
+ .setResponseMarshaller(new Proto2Marshaller<>(OMResponse::parseFrom))
+ .build();
+
private static final String OM_SERVICE_ID = "om-service-test";
private static final String NODE_ID_BASE = "om";
private static final int NUM_OMS = 3;
@@ -237,11 +251,12 @@ private static class MockOMServer {
private final AtomicInteger successCount = new AtomicInteger(0);
private final AtomicInteger failureCount = new AtomicInteger(0);
private final AtomicBoolean isLeader = new AtomicBoolean(false);
- private final OzoneManagerServiceGrpc.OzoneManagerServiceImplBase serviceImpl =
- mock(OzoneManagerServiceGrpc.OzoneManagerServiceImplBase.class,
- delegatesTo(new OzoneManagerServiceGrpc.OzoneManagerServiceImplBase() {
+ private final ServerCalls.UnaryMethod submitRequestImpl =
+ mock(ServerCalls.UnaryMethod.class,
+ delegatesTo(new ServerCalls.UnaryMethod() {
@Override
- public void submitRequest(OMRequest request, StreamObserver responseObserver) {
+ public void invoke(OMRequest request,
+ StreamObserver responseObserver) {
requestCount.incrementAndGet();
if (!isLeader.get()) {
@@ -272,8 +287,14 @@ public void submitRequest(OMRequest request, StreamObserver response
}
public void start() throws Exception {
- server = ServerBuilder.forPort(port)
- .addService(serviceImpl)
+ ServerServiceDefinition service = ServerServiceDefinition.builder(SERVICE_NAME)
+ .addMethod(SUBMIT_REQUEST_METHOD,
+ ServerCalls.asyncUnaryCall(submitRequestImpl))
+ .build();
+
+ server = NettyServerBuilder.forPort(port)
+ .directExecutor()
+ .addService(service)
.build()
.start();
}
@@ -301,5 +322,38 @@ public int getFailureCount() {
return failureCount.get();
}
}
+
+ private static final class Proto2Marshaller implements MethodDescriptor.Marshaller {
+ private final Parser parser;
+
+ private Proto2Marshaller(Parser parser) {
+ this.parser = parser;
+ }
+
+ @Override
+ public InputStream stream(T value) {
+ if (value instanceof com.google.protobuf.Message) {
+ return ((com.google.protobuf.Message) value).toByteString().newInput();
+ }
+ if (value instanceof com.google.protobuf.MessageLite) {
+ return ((com.google.protobuf.MessageLite) value).toByteString().newInput();
+ }
+ throw new IllegalArgumentException("Unsupported protobuf type: " + value.getClass());
+ }
+
+ @Override
+ public T parse(InputStream stream) {
+ try {
+ return parser.parse(stream);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @FunctionalInterface
+ private interface Parser {
+ T parse(InputStream stream) throws IOException;
+ }
+ }
}
diff --git a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/protocolPB/TestS3GrpcOmTransport.java b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/protocolPB/TestS3GrpcOmTransport.java
index 176d9b6d03bd..ca665ef7acc6 100644
--- a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/protocolPB/TestS3GrpcOmTransport.java
+++ b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/protocolPB/TestS3GrpcOmTransport.java
@@ -18,29 +18,37 @@
package org.apache.hadoop.ozone.om.protocolPB;
import static org.apache.hadoop.ozone.ClientVersion.CURRENT_VERSION;
+import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ADDRESS_KEY;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_GRPC_MAXIMUM_RESPONSE_LENGTH;
-import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_GRPC_MAXIMUM_RESPONSE_LENGTH_DEFAULT;
+import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_GRPC_PORT_KEY;
+import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_NODES_KEY;
+import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SERVICE_IDS_KEY;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.AdditionalAnswers.delegatesTo;
import static org.mockito.Mockito.mock;
import com.google.protobuf.ServiceException;
-import io.grpc.ManagedChannel;
-import io.grpc.inprocess.InProcessChannelBuilder;
-import io.grpc.inprocess.InProcessServerBuilder;
-import io.grpc.testing.GrpcCleanupRule;
import java.io.IOException;
+import java.io.InputStream;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.ozone.OzoneConfigKeys;
+import org.apache.hadoop.ozone.ha.ConfUtils;
import org.apache.hadoop.ozone.om.exceptions.OMNotLeaderException;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ServiceListRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
-import org.apache.hadoop.ozone.protocol.proto.OzoneManagerServiceGrpc;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.ratis.protocol.RaftPeerId;
+import org.apache.ratis.thirdparty.io.grpc.MethodDescriptor;
+import org.apache.ratis.thirdparty.io.grpc.Server;
+import org.apache.ratis.thirdparty.io.grpc.ServerServiceDefinition;
+import org.apache.ratis.thirdparty.io.grpc.Status;
+import org.apache.ratis.thirdparty.io.grpc.netty.NettyServerBuilder;
+import org.apache.ratis.thirdparty.io.grpc.stub.ServerCalls;
+import org.apache.ratis.thirdparty.io.grpc.stub.StreamObserver;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
@@ -50,12 +58,23 @@
* Tests for GrpcOmTransport client.
*/
public class TestS3GrpcOmTransport {
- private final GrpcCleanupRule grpcCleanup = new GrpcCleanupRule();
-
private static final Logger LOG =
LoggerFactory.getLogger(TestS3GrpcOmTransport.class);
+ private static final String SERVICE_NAME = "hadoop.ozone.OzoneManagerService";
+
+ private static final MethodDescriptor
+ SUBMIT_REQUEST_METHOD = MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName(MethodDescriptor.generateFullMethodName(
+ SERVICE_NAME, "submitRequest"))
+ .setRequestMarshaller(new Proto2Marshaller<>(OMRequest::parseFrom))
+ .setResponseMarshaller(new Proto2Marshaller<>(OMResponse::parseFrom))
+ .build();
+
private static final String LEADER_OM_NODE_ID = "TestOM";
+ private static final String OM_SERVICE_ID = "om-service-test";
+ private static final String OM_NODE_ID = "om0";
private final OMResponse omResponse = OMResponse.newBuilder()
.setSuccess(true)
@@ -73,44 +92,33 @@ public class TestS3GrpcOmTransport {
private String omServiceId;
private UserGroupInformation ugi;
- private ManagedChannel channel;
-
- private String serverName;
-
- private final OzoneManagerServiceGrpc.OzoneManagerServiceImplBase
- serviceImpl =
- mock(OzoneManagerServiceGrpc.OzoneManagerServiceImplBase.class,
- delegatesTo(
- new OzoneManagerServiceGrpc.OzoneManagerServiceImplBase() {
- @Override
- public void submitRequest(org.apache.hadoop.ozone.protocol.proto
- .OzoneManagerProtocolProtos
- .OMRequest request,
- io.grpc.stub.StreamObserver
- responseObserver) {
- try {
- if (doFailover) {
- if (completeFailover) {
- doFailover = false;
- }
- failoverCount++;
- throw createNotLeaderException();
- } else {
- responseObserver.onNext(omResponse);
- responseObserver.onCompleted();
- }
- } catch (Throwable e) {
- IOException ex = new IOException(e.getCause());
- responseObserver.onError(io.grpc.Status
- .INTERNAL
- .withDescription(ex.getMessage())
- .asRuntimeException());
+ private Server server;
+
+ private final ServerCalls.UnaryMethod submitRequestImpl =
+ mock(ServerCalls.UnaryMethod.class,
+ delegatesTo(new ServerCalls.UnaryMethod() {
+ @Override
+ public void invoke(OMRequest request,
+ StreamObserver responseObserver) {
+ try {
+ if (doFailover) {
+ if (completeFailover) {
+ doFailover = false;
}
+ failoverCount++;
+ throw createNotLeaderException();
+ } else {
+ responseObserver.onNext(omResponse);
+ responseObserver.onCompleted();
}
- }));
+ } catch (Throwable e) {
+ IOException ex = new IOException(e.getCause());
+ responseObserver.onError(Status.INTERNAL
+ .withDescription(ex.getMessage())
+ .asRuntimeException());
+ }
+ }
+ }));
private GrpcOmTransport client;
@@ -128,28 +136,42 @@ private ServiceException createNotLeaderException() {
@BeforeEach
public void setUp() throws Exception {
failoverCount = 0;
- // Generate a unique in-process server name.
- serverName = InProcessServerBuilder.generateName();
- // Create a server, add service, start,
- // and register for automatic graceful shutdown.
- grpcCleanup.register(InProcessServerBuilder
- .forName(serverName)
+ ServerServiceDefinition service = ServerServiceDefinition.builder(SERVICE_NAME)
+ .addMethod(SUBMIT_REQUEST_METHOD,
+ ServerCalls.asyncUnaryCall(submitRequestImpl))
+ .build();
+
+ server = NettyServerBuilder.forPort(0)
.directExecutor()
- .addService(serviceImpl)
+ .addService(service)
.build()
- .start());
+ .start();
- // Create a client channel and register for automatic graceful shutdown.
- channel = grpcCleanup.register(
- InProcessChannelBuilder.forName(serverName).directExecutor().build());
-
- omServiceId = "";
+ omServiceId = OM_SERVICE_ID;
conf = new OzoneConfiguration();
+ conf.set(OZONE_OM_SERVICE_IDS_KEY, omServiceId);
+ conf.set(ConfUtils.addKeySuffixes(OZONE_OM_NODES_KEY, omServiceId), OM_NODE_ID);
+ conf.set(ConfUtils.addKeySuffixes(OZONE_OM_ADDRESS_KEY, omServiceId, OM_NODE_ID), "localhost");
+ conf.setInt(ConfUtils.addKeySuffixes(OZONE_OM_GRPC_PORT_KEY, omServiceId, OM_NODE_ID),
+ server.getPort());
ugi = UserGroupInformation.getCurrentUser();
doFailover = false;
}
+ @AfterEach
+ public void tearDown() throws Exception {
+ if (client != null) {
+ client.close();
+ client = null;
+ }
+ if (server != null) {
+ server.shutdownNow();
+ server.awaitTermination();
+ server = null;
+ }
+ }
+
@Test
public void testSubmitRequestToServer() throws Exception {
ServiceListRequest req = ServiceListRequest.newBuilder().build();
@@ -162,7 +184,6 @@ public void testSubmitRequestToServer() throws Exception {
.build();
client = new GrpcOmTransport(conf, ugi, omServiceId);
- client.startClient(channel);
final OMResponse resp = client.submitRequest(omRequest);
assertEquals(resp.getStatus(), org.apache.hadoop.ozone.protocol
@@ -182,7 +203,6 @@ public void testGrpcFailoverProxy() throws Exception {
.build();
client = new GrpcOmTransport(conf, ugi, omServiceId);
- client.startClient(channel);
doFailover = true;
// first invocation generates a NotALeaderException
@@ -208,7 +228,6 @@ public void testGrpcFailoverProxyExhaustRetry() throws Exception {
conf.setInt(OzoneConfigKeys.OZONE_CLIENT_FAILOVER_MAX_ATTEMPTS_KEY, 0);
client = new GrpcOmTransport(conf, ugi, omServiceId);
- client.startClient(channel);
doFailover = true;
// first invocation generates a NotALeaderException
@@ -229,7 +248,6 @@ public void testGrpcFailoverProxyCalculatesFailoverCountPerRequest() throws Exce
conf.setInt(OzoneConfigKeys.OZONE_CLIENT_FAILOVER_MAX_ATTEMPTS_KEY, maxFailoverAttempts);
conf.setLong(OzoneConfigKeys.OZONE_CLIENT_WAIT_BETWEEN_RETRIES_MILLIS_KEY, 50);
client = new GrpcOmTransport(conf, ugi, omServiceId);
- client.startClient(channel);
assertThrows(Exception.class, () -> client.submitRequest(arbitraryOmRequest()));
assertEquals(maxFailoverAttempts, failoverCount);
@@ -255,14 +273,6 @@ public void testGrpcFailoverExceedMaxMesgLen() throws Exception {
conf.setInt(OZONE_OM_GRPC_MAXIMUM_RESPONSE_LENGTH, 1);
client = new GrpcOmTransport(conf, ugi, omServiceId);
- int maxSize = conf.getInt(OZONE_OM_GRPC_MAXIMUM_RESPONSE_LENGTH,
- OZONE_OM_GRPC_MAXIMUM_RESPONSE_LENGTH_DEFAULT);
- channel = grpcCleanup.register(
- InProcessChannelBuilder
- .forName(serverName)
- .maxInboundMetadataSize(maxSize)
- .directExecutor().build());
- client.startClient(channel);
doFailover = true;
// GrpcOMFailoverProvider returns Fail retry due to mesg response
@@ -281,4 +291,37 @@ private static OMRequest arbitraryOmRequest() {
.setServiceListRequest(req)
.build();
}
+
+ private static final class Proto2Marshaller implements MethodDescriptor.Marshaller {
+ private final Parser parser;
+
+ private Proto2Marshaller(Parser parser) {
+ this.parser = parser;
+ }
+
+ @Override
+ public InputStream stream(T value) {
+ if (value instanceof com.google.protobuf.Message) {
+ return ((com.google.protobuf.Message) value).toByteString().newInput();
+ }
+ if (value instanceof com.google.protobuf.MessageLite) {
+ return ((com.google.protobuf.MessageLite) value).toByteString().newInput();
+ }
+ throw new IllegalArgumentException("Unsupported protobuf type: " + value.getClass());
+ }
+
+ @Override
+ public T parse(InputStream stream) {
+ try {
+ return parser.parse(stream);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @FunctionalInterface
+ private interface Parser {
+ T parse(InputStream stream) throws IOException;
+ }
+ }
}
diff --git a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/protocolPB/grpc/TestClientAddressClientInterceptor.java b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/protocolPB/grpc/TestClientAddressClientInterceptor.java
index 0a862c2eff00..8b2a9d67d064 100644
--- a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/protocolPB/grpc/TestClientAddressClientInterceptor.java
+++ b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/protocolPB/grpc/TestClientAddressClientInterceptor.java
@@ -23,13 +23,13 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import io.grpc.CallOptions;
-import io.grpc.Channel;
-import io.grpc.ClientCall;
-import io.grpc.ClientInterceptor;
-import io.grpc.Context;
-import io.grpc.Metadata;
-import io.grpc.MethodDescriptor;
+import org.apache.ratis.thirdparty.io.grpc.CallOptions;
+import org.apache.ratis.thirdparty.io.grpc.Channel;
+import org.apache.ratis.thirdparty.io.grpc.ClientCall;
+import org.apache.ratis.thirdparty.io.grpc.ClientInterceptor;
+import org.apache.ratis.thirdparty.io.grpc.Context;
+import org.apache.ratis.thirdparty.io.grpc.Metadata;
+import org.apache.ratis.thirdparty.io.grpc.MethodDescriptor;
import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
diff --git a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/protocolPB/grpc/TestClientAddressServerInterceptor.java b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/protocolPB/grpc/TestClientAddressServerInterceptor.java
index 240c1db65206..49a7e912ed5a 100644
--- a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/protocolPB/grpc/TestClientAddressServerInterceptor.java
+++ b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/protocolPB/grpc/TestClientAddressServerInterceptor.java
@@ -23,12 +23,12 @@
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;
-import io.grpc.Context;
-import io.grpc.Contexts;
-import io.grpc.Metadata;
-import io.grpc.ServerCall;
-import io.grpc.ServerCallHandler;
-import io.grpc.ServerInterceptor;
+import org.apache.ratis.thirdparty.io.grpc.Context;
+import org.apache.ratis.thirdparty.io.grpc.Contexts;
+import org.apache.ratis.thirdparty.io.grpc.Metadata;
+import org.apache.ratis.thirdparty.io.grpc.ServerCall;
+import org.apache.ratis.thirdparty.io.grpc.ServerCallHandler;
+import org.apache.ratis.thirdparty.io.grpc.ServerInterceptor;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.MockedStatic;
diff --git a/hadoop-ozone/csi/pom.xml b/hadoop-ozone/csi/pom.xml
index 045b2cae1ebf..99f3d775980a 100644
--- a/hadoop-ozone/csi/pom.xml
+++ b/hadoop-ozone/csi/pom.xml
@@ -33,15 +33,6 @@
-
- com.google.guava
- guava
-
-
- com.google.protobuf
- protobuf-java
- ${protobuf.version}
-
commons-io
commons-io
@@ -50,50 +41,6 @@
info.picocli
picocli
-
- io.grpc
- grpc-api
-
-
- com.google.code.findbugs
- jsr305
-
-
-
-
- io.grpc
- grpc-netty
-
-
- io.grpc
- grpc-protobuf
-
-
- com.google.code.findbugs
- jsr305
-
-
- com.google.protobuf
- protobuf-java
-
-
-
-
- io.grpc
- grpc-stub
-
-
- io.netty
- netty-transport
-
-
- io.netty
- netty-transport-classes-epoll
-
-
- io.netty
- netty-transport-native-unix-common
-
org.apache.ozone
hdds-cli-common
@@ -146,6 +93,10 @@
org.apache.ozone
ozone-common
+
+ org.apache.ratis
+ ratis-thirdparty-misc
+
org.slf4j
slf4j-api
@@ -156,48 +107,12 @@
3.0.2
provided
-
- com.google.protobuf
- protobuf-java-util
- ${protobuf.version}
- provided
-
-
- com.google.code.findbugs
- jsr305
-
-
- com.google.j2objc
- j2objc-annotations
-
-
- com.google.protobuf
- protobuf-java
-
-
-
javax.annotation
javax.annotation-api
provided
-
- io.netty
- netty-codec-http2
- runtime
-
-
- io.netty
- netty-handler-proxy
- runtime
-
-
- io.netty
- netty-transport-native-epoll
- linux-x86_64
- runtime
-
org.slf4j
slf4j-reload4j
@@ -227,6 +142,21 @@
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ analyze
+
+
+ org.apache.ozone:hdds-server-framework
+ org.apache.ratis:ratis-thirdparty-misc
+
+
+
+
+
org.xolstice.maven.plugins
protobuf-maven-plugin
@@ -272,6 +202,29 @@
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+
+
+ shade-proto-for-ratis
+
+ run
+
+ process-sources
+
+
+
+
+
+
+
+
+
+
+
+
+
com.github.spotbugs
spotbugs-maven-plugin
diff --git a/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/ControllerService.java b/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/ControllerService.java
index f0fa375c3fc6..aba5e38a9d8b 100644
--- a/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/ControllerService.java
+++ b/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/ControllerService.java
@@ -29,9 +29,9 @@
import csi.v1.Csi.DeleteVolumeRequest;
import csi.v1.Csi.DeleteVolumeResponse;
import csi.v1.Csi.Volume;
-import io.grpc.stub.StreamObserver;
import java.io.IOException;
import org.apache.hadoop.ozone.client.OzoneClient;
+import org.apache.ratis.thirdparty.io.grpc.stub.StreamObserver;
/**
* CSI controller service.
diff --git a/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/CsiServer.java b/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/CsiServer.java
index cf1133a53401..d9c8cc86ecb0 100644
--- a/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/CsiServer.java
+++ b/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/CsiServer.java
@@ -17,11 +17,6 @@
package org.apache.hadoop.ozone.csi;
-import io.grpc.Server;
-import io.grpc.netty.NettyServerBuilder;
-import io.netty.channel.epoll.EpollEventLoopGroup;
-import io.netty.channel.epoll.EpollServerDomainSocketChannel;
-import io.netty.channel.unix.DomainSocketAddress;
import java.util.concurrent.Callable;
import org.apache.hadoop.hdds.cli.GenericCli;
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
@@ -33,6 +28,11 @@
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientFactory;
import org.apache.hadoop.ozone.util.OzoneVersionInfo;
+import org.apache.ratis.thirdparty.io.grpc.Server;
+import org.apache.ratis.thirdparty.io.grpc.netty.NettyServerBuilder;
+import org.apache.ratis.thirdparty.io.netty.channel.epoll.EpollEventLoopGroup;
+import org.apache.ratis.thirdparty.io.netty.channel.epoll.EpollServerDomainSocketChannel;
+import org.apache.ratis.thirdparty.io.netty.channel.unix.DomainSocketAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import picocli.CommandLine.Command;
diff --git a/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/IdentityService.java b/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/IdentityService.java
index b65de8cb5f43..24085720b1ef 100644
--- a/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/IdentityService.java
+++ b/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/IdentityService.java
@@ -19,15 +19,15 @@
import static csi.v1.Csi.PluginCapability.Service.Type.CONTROLLER_SERVICE;
-import com.google.protobuf.BoolValue;
import csi.v1.Csi.GetPluginCapabilitiesResponse;
import csi.v1.Csi.GetPluginInfoResponse;
import csi.v1.Csi.PluginCapability;
import csi.v1.Csi.PluginCapability.Service;
import csi.v1.Csi.ProbeResponse;
import csi.v1.IdentityGrpc.IdentityImplBase;
-import io.grpc.stub.StreamObserver;
import org.apache.hadoop.ozone.util.OzoneVersionInfo;
+import org.apache.ratis.thirdparty.com.google.protobuf.BoolValue;
+import org.apache.ratis.thirdparty.io.grpc.stub.StreamObserver;
/**
* Implementation of the CSI identity service.
diff --git a/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/NodeService.java b/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/NodeService.java
index 7220c31137b3..283805c39082 100644
--- a/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/NodeService.java
+++ b/hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/NodeService.java
@@ -26,7 +26,6 @@
import csi.v1.Csi.NodeUnpublishVolumeRequest;
import csi.v1.Csi.NodeUnpublishVolumeResponse;
import csi.v1.NodeGrpc.NodeImplBase;
-import io.grpc.stub.StreamObserver;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -36,6 +35,7 @@
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.ozone.csi.CsiServer.CsiConfig;
+import org.apache.ratis.thirdparty.io.grpc.stub.StreamObserver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/hadoop-ozone/dist/src/main/license/bin/LICENSE.txt b/hadoop-ozone/dist/src/main/license/bin/LICENSE.txt
index a87c952ca761..b6b7165528f4 100644
--- a/hadoop-ozone/dist/src/main/license/bin/LICENSE.txt
+++ b/hadoop-ozone/dist/src/main/license/bin/LICENSE.txt
@@ -316,13 +316,9 @@ Apache License 2.0
io.airlift:aircompressor
io.dropwizard.metrics:metrics-core
io.grpc:grpc-api
- io.grpc:grpc-context
- io.grpc:grpc-core
- io.grpc:grpc-netty
io.grpc:grpc-protobuf
io.grpc:grpc-protobuf-lite
io.grpc:grpc-stub
- io.grpc:grpc-util
io.netty:netty-buffer
io.netty:netty-codec
io.netty:netty-codec-http
@@ -354,7 +350,6 @@ Apache License 2.0
io.opentelemetry:opentelemetry-sdk-logs
io.opentelemetry:opentelemetry-sdk-metrics
io.opentelemetry:opentelemetry-sdk-trace
- io.perfmark:perfmark-api
io.prometheus:simpleclient
io.prometheus:simpleclient_common
io.prometheus:simpleclient_dropwizard
diff --git a/hadoop-ozone/dist/src/main/license/jar-report.txt b/hadoop-ozone/dist/src/main/license/jar-report.txt
index 0d142d08c95c..a93054860cd9 100644
--- a/hadoop-ozone/dist/src/main/license/jar-report.txt
+++ b/hadoop-ozone/dist/src/main/license/jar-report.txt
@@ -44,13 +44,9 @@ share/ozone/lib/error_prone_annotations.jar
share/ozone/lib/failureaccess.jar
share/ozone/lib/gethostname4j.jar
share/ozone/lib/grpc-api.jar
-share/ozone/lib/grpc-context.jar
-share/ozone/lib/grpc-core.jar
-share/ozone/lib/grpc-netty.jar
share/ozone/lib/grpc-protobuf.jar
share/ozone/lib/grpc-protobuf-lite.jar
share/ozone/lib/grpc-stub.jar
-share/ozone/lib/grpc-util.jar
share/ozone/lib/gson.jar
share/ozone/lib/guava-jre.jar
share/ozone/lib/guice-assistedinject.jar
@@ -69,6 +65,7 @@ share/ozone/lib/hdds-client.jar
share/ozone/lib/hdds-common.jar
share/ozone/lib/hdds-config.jar
share/ozone/lib/hdds-container-service.jar
+share/ozone/lib/hdds-datanode-grpc-client.jar
share/ozone/lib/hdds-docs.jar
share/ozone/lib/hdds-erasurecode.jar
share/ozone/lib/hdds-interface-admin.jar
@@ -76,6 +73,7 @@ share/ozone/lib/hdds-interface-client.jar
share/ozone/lib/hdds-interface-server.jar
share/ozone/lib/hdds-rocks-native.jar
share/ozone/lib/hdds-managed-rocksdb.jar
+share/ozone/lib/hdds-scm-grpc-client.jar
share/ozone/lib/hdds-server-framework.jar
share/ozone/lib/hdds-server-scm.jar
share/ozone/lib/hk2-api.jar
@@ -189,7 +187,6 @@ share/ozone/lib/netty-tcnative-boringssl-static.Final.jar
share/ozone/lib/netty-tcnative-classes.Final.jar
share/ozone/lib/netty-transport.Final.jar
share/ozone/lib/netty-transport-classes-epoll.Final.jar
-share/ozone/lib/netty-transport-native-epoll.Final-linux-x86_64.jar
share/ozone/lib/netty-transport-native-epoll.Final.jar
share/ozone/lib/netty-transport-native-unix-common.Final.jar
share/ozone/lib/nimbus-jose-jwt.jar
@@ -234,7 +231,6 @@ share/ozone/lib/ozone-s3-secret-store.jar
share/ozone/lib/ozone-s3gateway.jar
share/ozone/lib/ozone-tools.jar
share/ozone/lib/ozone-vapor.jar
-share/ozone/lib/perfmark-api.jar
share/ozone/lib/picocli.jar
share/ozone/lib/picocli-shell-jline3.jar
share/ozone/lib/protobuf-java.jar
diff --git a/hadoop-ozone/integration-test-recon/pom.xml b/hadoop-ozone/integration-test-recon/pom.xml
index 812ee6f8667d..dff96a102161 100644
--- a/hadoop-ozone/integration-test-recon/pom.xml
+++ b/hadoop-ozone/integration-test-recon/pom.xml
@@ -217,12 +217,17 @@
org.apache.maven.plugins
maven-dependency-plugin
-
-
- org.mockito:mockito-inline:jar
- org.mockito:mockito-junit-jupiter:jar
-
-
+
+
+ analyze
+
+
+ org.mockito:mockito-inline:jar
+ org.mockito:mockito-junit-jupiter:jar
+
+
+
+
diff --git a/hadoop-ozone/interface-client/pom.xml b/hadoop-ozone/interface-client/pom.xml
index 60ddefa7cee4..4cd8352a722c 100644
--- a/hadoop-ozone/interface-client/pom.xml
+++ b/hadoop-ozone/interface-client/pom.xml
@@ -87,6 +87,34 @@
+
+
+
+ com.gradle
+ develocity-maven-extension
+
+
+
+
+
+ maven-compiler-plugin
+
+ compiles generated sources
+
+
+
+ protobuf-maven-plugin
+
+ generates sources
+
+
+
+
+
+
+
+
com.salesforce.servicelibs
diff --git a/hadoop-ozone/ozone-manager/pom.xml b/hadoop-ozone/ozone-manager/pom.xml
index fae36afa538f..9a7f2861d22f 100644
--- a/hadoop-ozone/ozone-manager/pom.xml
+++ b/hadoop-ozone/ozone-manager/pom.xml
@@ -58,36 +58,6 @@
info.picocli
picocli
-
- io.grpc
- grpc-api
-
-
- com.google.code.findbugs
- jsr305
-
-
-
-
- io.grpc
- grpc-netty
-
-
- io.grpc
- grpc-stub
-
-
- io.netty
- netty-common
-
-
- io.netty
- netty-handler
-
-
- io.netty
- netty-transport
-
jakarta.annotation
jakarta.annotation-api
@@ -238,11 +208,6 @@
hdds-docs
provided
-
- io.netty
- netty-tcnative-boringssl-static
- runtime
-
org.slf4j
slf4j-reload4j
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/GrpcOzoneManagerServer.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/GrpcOzoneManagerServer.java
index faf6d623f3ff..3855dfff7857 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/GrpcOzoneManagerServer.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/GrpcOzoneManagerServer.java
@@ -29,15 +29,6 @@
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_GRPC_WORKERGROUP_SIZE_KEY;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import io.grpc.Server;
-import io.grpc.ServerInterceptors;
-import io.grpc.netty.GrpcSslContexts;
-import io.grpc.netty.NettyServerBuilder;
-import io.netty.channel.EventLoopGroup;
-import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.nio.NioServerSocketChannel;
-import io.netty.handler.ssl.SslContextBuilder;
-import io.netty.handler.ssl.SslProvider;
import java.io.IOException;
import java.util.OptionalInt;
import java.util.concurrent.LinkedBlockingQueue;
@@ -57,6 +48,15 @@
import org.apache.hadoop.ozone.om.protocolPB.grpc.ClientAddressServerInterceptor;
import org.apache.hadoop.ozone.protocolPB.OzoneManagerProtocolServerSideTranslatorPB;
import org.apache.hadoop.ozone.security.OzoneDelegationTokenSecretManager;
+import org.apache.ratis.thirdparty.io.grpc.Server;
+import org.apache.ratis.thirdparty.io.grpc.ServerInterceptors;
+import org.apache.ratis.thirdparty.io.grpc.netty.GrpcSslContexts;
+import org.apache.ratis.thirdparty.io.grpc.netty.NettyServerBuilder;
+import org.apache.ratis.thirdparty.io.netty.channel.EventLoopGroup;
+import org.apache.ratis.thirdparty.io.netty.channel.nio.NioEventLoopGroup;
+import org.apache.ratis.thirdparty.io.netty.channel.socket.nio.NioServerSocketChannel;
+import org.apache.ratis.thirdparty.io.netty.handler.ssl.SslContextBuilder;
+import org.apache.ratis.thirdparty.io.netty.handler.ssl.SslProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManagerServiceGrpc.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManagerServiceGrpc.java
index 05abb25c376b..b3c0ac94995b 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManagerServiceGrpc.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManagerServiceGrpc.java
@@ -17,26 +17,50 @@
package org.apache.hadoop.ozone.om;
+import com.google.protobuf.MessageLite;
import com.google.protobuf.RpcController;
-import io.grpc.Status;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.UncheckedIOException;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.hadoop.ipc_.RPC;
import org.apache.hadoop.ipc_.Server;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse;
-import org.apache.hadoop.ozone.protocol.proto.OzoneManagerServiceGrpc.OzoneManagerServiceImplBase;
import org.apache.hadoop.ozone.protocolPB.OzoneManagerProtocolServerSideTranslatorPB;
import org.apache.hadoop.ozone.util.UUIDUtil;
+import org.apache.ratis.thirdparty.io.grpc.BindableService;
+import org.apache.ratis.thirdparty.io.grpc.MethodDescriptor;
+import org.apache.ratis.thirdparty.io.grpc.ServerServiceDefinition;
+import org.apache.ratis.thirdparty.io.grpc.Status;
+import org.apache.ratis.thirdparty.io.grpc.stub.ServerCalls;
+import org.apache.ratis.thirdparty.io.grpc.stub.StreamObserver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Grpc Service for handling S3 gateway OzoneManagerProtocol client requests.
+ * Implements BindableService directly using shaded gRPC with a custom byte-stream
+ * marshaller so that vanilla protobuf OMRequest/OMResponse can be used without
+ * shading OzoneManagerProtocolProtos (which imports HddsProtos vanilla types).
*/
-public class OzoneManagerServiceGrpc extends OzoneManagerServiceImplBase {
+public class OzoneManagerServiceGrpc implements BindableService {
private static final Logger LOG =
LoggerFactory.getLogger(OzoneManagerServiceGrpc.class);
+
+ static final String SERVICE_NAME = "hadoop.ozone.OzoneManagerService";
+
+ private static final MethodDescriptor
+ SUBMIT_REQUEST_DESCRIPTOR =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName(
+ MethodDescriptor.generateFullMethodName(SERVICE_NAME, "submitRequest"))
+ .setRequestMarshaller(proto2Marshaller(OMRequest::parseFrom))
+ .setResponseMarshaller(proto2Marshaller(OMResponse::parseFrom))
+ .build();
+
/**
* RpcController is not used and hence is set to null.
*/
@@ -49,9 +73,15 @@ public class OzoneManagerServiceGrpc extends OzoneManagerServiceImplBase {
}
@Override
- public void submitRequest(OMRequest request,
- io.grpc.stub.StreamObserver
- responseObserver) {
+ public ServerServiceDefinition bindService() {
+ return ServerServiceDefinition.builder(SERVICE_NAME)
+ .addMethod(SUBMIT_REQUEST_DESCRIPTOR,
+ ServerCalls.asyncUnaryCall(this::submitRequest))
+ .build();
+ }
+
+ private void submitRequest(OMRequest request,
+ StreamObserver responseObserver) {
LOG.debug("OzoneManagerServiceGrpc: OzoneManagerServiceImplBase " +
"processing s3g client submit request - for command {}",
request.getCmdType().name());
@@ -89,4 +119,27 @@ private static byte[] getClientId() {
return UUIDUtil.randomUUIDBytes();
}
+ private static MethodDescriptor.Marshaller proto2Marshaller(
+ Proto2Parser parser) {
+ return new MethodDescriptor.Marshaller() {
+ @Override
+ public InputStream stream(T value) {
+ return new ByteArrayInputStream(value.toByteArray());
+ }
+
+ @Override
+ public T parse(InputStream stream) {
+ try {
+ return parser.parse(stream);
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+ };
+ }
+
+ @FunctionalInterface
+ private interface Proto2Parser {
+ T parse(InputStream stream) throws IOException;
+ }
}
diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOMMetadataReader.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOMMetadataReader.java
index 903b0720943d..203cf7da1ff2 100644
--- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOMMetadataReader.java
+++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOMMetadataReader.java
@@ -22,8 +22,8 @@
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;
-import io.grpc.Context;
import org.apache.hadoop.ipc_.Server;
+import org.apache.ratis.thirdparty.io.grpc.Context;
import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/TestOMClientRequestWithUserInfo.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/TestOMClientRequestWithUserInfo.java
index 145ffe9854fe..3626683b897c 100644
--- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/TestOMClientRequestWithUserInfo.java
+++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/TestOMClientRequestWithUserInfo.java
@@ -27,7 +27,6 @@
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;
-import io.grpc.Context;
import java.io.IOException;
import java.net.InetAddress;
import java.nio.file.Path;
@@ -49,6 +48,7 @@
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.BucketInfo;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest;
import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.ratis.thirdparty.io.grpc.Context;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
diff --git a/hadoop-ozone/ozonefs-common/pom.xml b/hadoop-ozone/ozonefs-common/pom.xml
index aecaa66cd4c0..72ec8f089e04 100644
--- a/hadoop-ozone/ozonefs-common/pom.xml
+++ b/hadoop-ozone/ozonefs-common/pom.xml
@@ -104,6 +104,25 @@
none
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ analyze
+
+
+
+ org.apache.httpcomponents:httpclient
+
+
+
+
+
diff --git a/hadoop-ozone/ozonefs-hadoop2/pom.xml b/hadoop-ozone/ozonefs-hadoop2/pom.xml
index fc8a5c6cd8e6..c2389c56a23f 100644
--- a/hadoop-ozone/ozonefs-hadoop2/pom.xml
+++ b/hadoop-ozone/ozonefs-hadoop2/pom.xml
@@ -120,14 +120,17 @@
org.apache.maven.plugins
maven-dependency-plugin
-
-
- org.assertj:*
- org.junit.jupiter:*
- org.mockito:*
-
-
+
+ analyze
+
+
+ org.assertj:*
+ org.junit.jupiter:*
+ org.mockito:*
+
+
+
include-dependencies
diff --git a/hadoop-ozone/ozonefs-hadoop3/pom.xml b/hadoop-ozone/ozonefs-hadoop3/pom.xml
index 5a751541481d..0dc6217837ec 100644
--- a/hadoop-ozone/ozonefs-hadoop3/pom.xml
+++ b/hadoop-ozone/ozonefs-hadoop3/pom.xml
@@ -60,17 +60,20 @@
org.apache.maven.plugins
maven-dependency-plugin
-
-
- org.apache.ratis:ratis-thirdparty-misc
-
-
- org.assertj:*
- org.junit.jupiter:*
- org.mockito:*
-
-
+
+ analyze
+
+
+ org.apache.ratis:ratis-thirdparty-misc
+
+
+ org.assertj:*
+ org.junit.jupiter:*
+ org.mockito:*
+
+
+
include-dependencies
diff --git a/hadoop-ozone/recon/pom.xml b/hadoop-ozone/recon/pom.xml
index ecaf38d8de64..bdc1a876ecbf 100644
--- a/hadoop-ozone/recon/pom.xml
+++ b/hadoop-ozone/recon/pom.xml
@@ -244,7 +244,8 @@
org.springframework
spring-core
-
+
org.springframework
@@ -331,11 +332,46 @@
org.apache.maven.plugins
maven-dependency-plugin
-
-
- javax.annotation:javax.annotation-api:jar
-
-
+
+
+
+ analyze
+
+
+ aopalliance:aopalliance:jar
+ com.google.inject.extensions:guice-assistedinject:jar
+ com.jolbox:bonecp:jar
+ info.picocli:picocli:jar
+ javax.annotation:javax.annotation-api:jar
+ org.apache.derby:derby:jar
+ org.apache.ozone:ozone-reconcodegen:jar
+ org.apache.ratis:ratis-proto:jar
+ org.glassfish.hk2.external:jakarta.inject:jar
+ org.glassfish.jersey.inject:jersey-hk2:jar
+ org.glassfish.jersey.media:jersey-media-jaxb:jar
+ org.glassfish.jersey.media:jersey-media-json-jackson:jar
+ org.mockito:mockito-inline:jar
+ org.rocksdb:rocksdbjni:jar
+ org.slf4j:slf4j-reload4j:jar
+ org.springframework:spring-core:jar
+ org.springframework:spring-jdbc:jar
+ org.springframework:spring-tx:jar
+ org.xerial:sqlite-jdbc:jar
+
+
+ com.fasterxml.jackson.core:jackson-databind:jar
+ org.apache.commons:commons-collections4:jar
+ org.apache.ozone:hdds-container-service:jar
+ org.apache.ozone:hdds-managed-rocksdb:jar
+ org.springframework:spring-core:jar
+
+
+
+
org.apache.maven.plugins
diff --git a/hadoop-ozone/s3gateway/pom.xml b/hadoop-ozone/s3gateway/pom.xml
index bebe6d1d07ba..9716389055dc 100644
--- a/hadoop-ozone/s3gateway/pom.xml
+++ b/hadoop-ozone/s3gateway/pom.xml
@@ -125,7 +125,8 @@
org.apache.ozone
hdds-client
-
+
org.apache.ozone
@@ -280,6 +281,24 @@
true
+
+ analyze
+
+
+
+ org.apache.ozone:hdds-client
+ org.eclipse.jetty:jetty-servlet
+ org.eclipse.jetty:jetty-webapp
+ org.apache.ozone:ozone-interface-client
+ org.glassfish.jersey.core:jersey-common
+
+
+
diff --git a/pom.xml b/pom.xml
index df5927f60c6d..5d72e92649b0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1158,6 +1158,11 @@
${hdds.version}
test-jar
+
+ org.apache.ozone
+ hdds-datanode-grpc-client
+ ${hdds.version}
+
org.apache.ozone
hdds-docs
@@ -1210,6 +1215,11 @@
${hdds.rocks.native.version}
test-jar
+
+ org.apache.ozone
+ hdds-scm-grpc-client
+ ${hdds.version}
+
org.apache.ozone
hdds-server-framework
@@ -1725,6 +1735,37 @@
sortpom-maven-plugin
${sortpom-maven-plugin.version}
+
+ com.gradle
+ develocity-maven-extension
+
+
+
+
+
+ maven-antrun-plugin
+
+ mutates generated sources
+
+
+
+ maven-compiler-plugin
+
+ compiles generated sources
+
+
+
+ protobuf-maven-plugin
+
+ generates sources
+
+
+
+
+
+
com.google.code.maven-replacer-plugin
replacer
@@ -2246,11 +2287,50 @@
com.fasterxml.jackson.core:jackson-databind:jar
org.apache.commons:commons-compress:jar
org.apache.ozone:hdds-client:jar
+ org.apache.ozone:hdds-datanode-grpc-client:jar
+ org.apache.ozone:hdds-scm-grpc-client:jar
org.apache.ozone:ozone-interface-client:jar
org.glassfish.jersey.core:jersey-common:jar
org.rocksdb:rocksdbjni:jar
org.springframework:spring-core:jar
+
+
+ org.rocksdb:rocksdbjni:jar
+
+ org.apache.ozone:hdds-config:jar
+
+ com.fasterxml.jackson.core:jackson-databind:jar
+
+ org.apache.commons:commons-compress:jar
+
+ org.apache.ozone:hdds-client:jar
+
+
+ org.apache.ozone:hdds-datanode-grpc-client:jar
+ org.apache.ozone:hdds-scm-grpc-client:jar
+
@@ -2285,6 +2365,15 @@
org.apache.maven.plugins
maven-clean-plugin
+
+ false
${project.basedir}
@@ -2305,6 +2394,39 @@
maven-antrun-plugin
${maven-antrun-plugin.version}
+
+
+ pre-clean-force-delete-target
+
+ run
+
+ pre-clean
+
+
+
+
+
+
+
+
+
+
create-testdirs
@@ -2318,6 +2440,174 @@
+
+
+ pre-verify-delete-test-classes
+
+ run
+
+ pre-integration-test
+
+
+
+
+
+
+
+
+
+
+
+ pre-verify-refresh-classes-from-jar
+
+ run
+
+ pre-integration-test
+
+
+
+
+
+
+
+
+
+
+
+
+ pre-compile-delete-classes
+
+ run
+
+ process-resources
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ pre-test-compile-refresh-classes
+
+ run
+
+ process-test-resources
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+