You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2021/09/08 19:51:43 UTC

[GitHub] [ozone] neils-dev commented on a change in pull request #2601: HDDS-5211. Start OM Grpc server as part of the OM bootstrap

neils-dev commented on a change in pull request #2601:
URL: https://github.com/apache/ozone/pull/2601#discussion_r704725662



##########
File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManagerServiceGrpc.java
##########
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.ozone.om;
+
+import com.google.protobuf.RpcController;
+import com.google.protobuf.ServiceException;
+import org.apache.hadoop.ipc.ClientId;
+import org.apache.hadoop.ipc.RPC;
+import org.apache.hadoop.ipc.Server;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerServiceGrpc.OzoneManagerServiceImplBase;
+import org.apache.hadoop.ozone.protocolPB.OzoneManagerProtocolServerSideTranslatorPB;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Grpc Service for handling S3 gateway OzoneManagerProtocol client requests.
+ */
+public class OzoneManagerServiceGrpc extends OzoneManagerServiceImplBase {
+  private static final Logger LOG =
+      LoggerFactory.getLogger(OzoneManagerServiceGrpc.class);
+  /**
+   * RpcController is not used and hence is set to null.
+   */
+  private static final RpcController NULL_RPC_CONTROLLER = null;
+  private OzoneManagerProtocolServerSideTranslatorPB omTranslator;
+
+  OzoneManagerServiceGrpc(
+      OzoneManagerProtocolServerSideTranslatorPB omTranslator) {
+    this.omTranslator = omTranslator;
+  }
+
+  @Override
+  public void submitRequest(org.apache.hadoop.ozone.protocol.proto.
+                                OzoneManagerProtocolProtos.
+                                OMRequest request,
+                            io.grpc.stub.StreamObserver<org.apache.
+                                hadoop.ozone.protocol.proto.
+                                OzoneManagerProtocolProtos.OMResponse>
+                                responseObserver) {
+    LOG.debug("GrpcOzoneManagerServer: OzoneManagerServiceImplBase " +
+        "processing s3g client submit request");
+    AtomicInteger callCount = new AtomicInteger(0);
+    try {
+      // need to look into handling the error path, trapping exception
+      // will be generating OmResponse with status fail & OmException shortly
+      org.apache.hadoop.ipc.Server.getCurCall().set(new Server.Call(1,

Review comment:
       Thanks @kerneltime.  The Server.Call is necessary for processing each `OMRequest` through the ratis transactions and holds caller thread info such as context, callerid.  We don't rely on this for processing requests however the ratis `OzoneManagerRatisServer` requires a `Server` class with the thread context when creating a ratisclientrequest, `createWriteRaftClientRequest`  (Server.getClientId, Server.getCallId).  To satisfy this we use Server.Call to create the instance needed to process requests through ratis/Raft.  Here in creating the thread caller Server.Call, we set the retry count with the atomic integer variable, and importantly the ClientId with a random number.  




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org