This is an automated email from the ASF dual-hosted git repository.

pifta pushed a commit to branch HDDS-3816-ec
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/HDDS-3816-ec by this push:
     new d0467ba  HDDS-6220. EC: Introduce a gRPC client implementation for EC 
with really async WriteChunk and PutBlock. (#3016)
d0467ba is described below

commit d0467bac1dd115887aef3d17f0d62e3d4b03782e
Author: Istvan Fajth <[email protected]>
AuthorDate: Tue Jan 25 17:54:35 2022 +0100

    HDDS-6220. EC: Introduce a gRPC client implementation for EC with really 
async WriteChunk and PutBlock. (#3016)
---
 .../hadoop/hdds/scm/ECXceiverClientGrpc.java       | 60 ++++++++++++++++++++++
 .../apache/hadoop/hdds/scm/XceiverClientGrpc.java  | 17 +++++-
 .../hadoop/hdds/scm/XceiverClientManager.java      |  2 +-
 3 files changed, 77 insertions(+), 2 deletions(-)

diff --git 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/ECXceiverClientGrpc.java
 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/ECXceiverClientGrpc.java
new file mode 100644
index 0000000..4873fdd
--- /dev/null
+++ 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/ECXceiverClientGrpc.java
@@ -0,0 +1,60 @@
+/*
+ * 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
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  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.hdds.scm;
+
+import org.apache.hadoop.hdds.conf.ConfigurationSource;
+import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
+import org.apache.hadoop.hdds.scm.pipeline.Pipeline;
+
+import java.security.cert.X509Certificate;
+import java.util.List;
+
+/**
+ * {@link XceiverClientSpi} implementation to work specifically with EC
+ * related requests. The only difference at the moment from the basic
+ * {@link XceiverClientGrpc} is that this implementation does async calls when
+ * a write request is posted via the sendCommandAsync method.
+ *
+ * @see https://issues.apache.org/jira/browse/HDDS-5954
+ */
+public class ECXceiverClientGrpc extends XceiverClientGrpc {
+
+  public ECXceiverClientGrpc(
+      Pipeline pipeline,
+      ConfigurationSource config,
+      List<X509Certificate> caCerts) {
+    super(pipeline, config, caCerts);
+  }
+
+  /**
+   * For EC writes, due to outside syncronization points during writes, it is
+   * not necessary to block any async requests that are
+   * arriving via the
+   * {@link #sendCommandAsync(ContainerProtos.ContainerCommandRequestProto)}
+   * method.
+   *
+   * @param request the request we need the decision about
+   * @return false always to do not block async requests.
+   */
+  @Override
+  protected boolean shouldBlockAndWaitAsyncReply(
+      ContainerProtos.ContainerCommandRequestProto request) {
+    return false;
+  }
+}
diff --git 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java
 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java
index f19853c..aa518ee 100644
--- 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java
+++ 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java
@@ -460,7 +460,7 @@ public class XceiverClientGrpc extends XceiverClientSpi {
       // served out of order over XceiverClientGrpc. This needs to be fixed
       // if this API is to be used for I/O path. Currently, this is not
       // used for Read/Write Operation but for tests.
-      if (!HddsUtils.isReadOnly(request)) {
+      if (shouldBlockAndWaitAsyncReply(request)) {
         asyncReply.getResponse().get();
       }
       return asyncReply;
@@ -470,6 +470,21 @@ public class XceiverClientGrpc extends XceiverClientSpi {
     }
   }
 
+  /**
+   * During data writes the ordering of WriteChunk and PutBlock is not ensured
+   * by any outside logic, therefore in this original implementation, all reads
+   * and writes are synchronized.
+   * This method is providing the possibility for subclasses to override this
+   * behaviour.
+   *
+   * @param request the request we need the decision about
+   * @return true if the request is a write request.
+   */
+  protected boolean shouldBlockAndWaitAsyncReply(
+      ContainerCommandRequestProto request) {
+    return !HddsUtils.isReadOnly(request);
+  }
+
   @VisibleForTesting
   public XceiverClientReply sendCommandAsync(
       ContainerCommandRequestProto request, DatanodeDetails dn)
diff --git 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientManager.java
 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientManager.java
index cb8bef1..ee4edec 100644
--- 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientManager.java
+++ 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientManager.java
@@ -232,7 +232,7 @@ public class XceiverClientManager implements Closeable, 
XceiverClientFactory {
               client = new XceiverClientGrpc(pipeline, conf, caCerts);
               break;
             case EC:
-              client = new XceiverClientGrpc(pipeline, conf, caCerts);
+              client = new ECXceiverClientGrpc(pipeline, conf, caCerts);
               break;
             case CHAINED:
             default:

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to