xiaoyuyao commented on a change in pull request #1340:
URL: https://github.com/apache/hadoop-ozone/pull/1340#discussion_r492294434



##########
File path: 
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/proxy/SCMClientConfig.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.proxy;
+
+import org.apache.hadoop.hdds.conf.Config;
+import org.apache.hadoop.hdds.conf.ConfigGroup;
+import org.apache.hadoop.hdds.conf.ConfigType;
+
+import java.util.concurrent.TimeUnit;
+
+import static org.apache.hadoop.hdds.conf.ConfigTag.CLIENT;
+import static org.apache.hadoop.hdds.conf.ConfigTag.OZONE;
+import static org.apache.hadoop.hdds.conf.ConfigTag.SCM;
+
+/**
+ * Config for SCM Block Client.
+ */
+@ConfigGroup(prefix = "ozone.scmclient")

Review comment:
       should this configuration group prefix with hdds.scmclient to match with 
the package name?

##########
File path: 
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/proxy/SCMClientConfig.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.proxy;
+
+import org.apache.hadoop.hdds.conf.Config;
+import org.apache.hadoop.hdds.conf.ConfigGroup;
+import org.apache.hadoop.hdds.conf.ConfigType;
+
+import java.util.concurrent.TimeUnit;
+
+import static org.apache.hadoop.hdds.conf.ConfigTag.CLIENT;
+import static org.apache.hadoop.hdds.conf.ConfigTag.OZONE;
+import static org.apache.hadoop.hdds.conf.ConfigTag.SCM;
+
+/**
+ * Config for SCM Block Client.
+ */
+@ConfigGroup(prefix = "ozone.scmclient")
+public class SCMClientConfig {
+  public static final String SCM_CLIENT_RPC_TIME_OUT = "rpc.timeout";
+  public static final String SCM_CLIENT_FAILOVER_MAX_RETRY =
+      "failover.max.retry";
+  public static final String SCM_CLIENT_RETRY_INTERVAL =
+      "failover.retry.interval";
+
+  @Config(key = SCM_CLIENT_RPC_TIME_OUT,
+      defaultValue = "15m",
+      type = ConfigType.TIME,
+      tags = {OZONE, SCM, CLIENT},
+      timeUnit = TimeUnit.MILLISECONDS,
+      description = "RpcClient timeout on waiting for the response from " +
+          "OzoneManager. The default value is set to 15 minutes. " +

Review comment:
       OzoneManager=>StorageContainerManger

##########
File path: 
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/proxy/SCMClientConfig.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.proxy;
+
+import org.apache.hadoop.hdds.conf.Config;
+import org.apache.hadoop.hdds.conf.ConfigGroup;
+import org.apache.hadoop.hdds.conf.ConfigType;
+
+import java.util.concurrent.TimeUnit;
+
+import static org.apache.hadoop.hdds.conf.ConfigTag.CLIENT;
+import static org.apache.hadoop.hdds.conf.ConfigTag.OZONE;
+import static org.apache.hadoop.hdds.conf.ConfigTag.SCM;
+
+/**
+ * Config for SCM Block Client.
+ */
+@ConfigGroup(prefix = "ozone.scmclient")
+public class SCMClientConfig {
+  public static final String SCM_CLIENT_RPC_TIME_OUT = "rpc.timeout";
+  public static final String SCM_CLIENT_FAILOVER_MAX_RETRY =
+      "failover.max.retry";
+  public static final String SCM_CLIENT_RETRY_INTERVAL =
+      "failover.retry.interval";
+
+  @Config(key = SCM_CLIENT_RPC_TIME_OUT,
+      defaultValue = "15m",
+      type = ConfigType.TIME,
+      tags = {OZONE, SCM, CLIENT},
+      timeUnit = TimeUnit.MILLISECONDS,
+      description = "RpcClient timeout on waiting for the response from " +
+          "OzoneManager. The default value is set to 15 minutes. " +
+          "If ipc.client.ping is set to true and this rpc-timeout " +
+          "is greater than the value of ipc.ping.interval, the effective " +
+          "value of the rpc-timeout is rounded up to multiple of " +
+          "ipc.ping.interval."
+  )
+  private long rpcTimeOut = 15 * 60 * 1000;
+
+  @Config(key = SCM_CLIENT_FAILOVER_MAX_RETRY,
+      defaultValue = "15",
+      type = ConfigType.INT,
+      tags = {OZONE, SCM, CLIENT},
+      description = "Max retry count for SCM Client when failover happens."
+  )
+  private int retryCount = 15;
+
+  @Config(key = SCM_CLIENT_RETRY_INTERVAL,
+      defaultValue = "2s",
+      type = ConfigType.TIME,
+      tags = {OZONE, SCM, CLIENT},
+      timeUnit = TimeUnit.MILLISECONDS,
+      description = "RpcClient timeout on waiting for the response from " +
+          "OzoneManager. The default value is set to 15 minutes. " +

Review comment:
       OzoneManager=>StorageContainerManger
   
   

##########
File path: 
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/proxy/SCMClientConfig.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.proxy;
+
+import org.apache.hadoop.hdds.conf.Config;
+import org.apache.hadoop.hdds.conf.ConfigGroup;
+import org.apache.hadoop.hdds.conf.ConfigType;
+
+import java.util.concurrent.TimeUnit;
+
+import static org.apache.hadoop.hdds.conf.ConfigTag.CLIENT;
+import static org.apache.hadoop.hdds.conf.ConfigTag.OZONE;
+import static org.apache.hadoop.hdds.conf.ConfigTag.SCM;
+
+/**
+ * Config for SCM Block Client.
+ */
+@ConfigGroup(prefix = "ozone.scmclient")
+public class SCMClientConfig {
+  public static final String SCM_CLIENT_RPC_TIME_OUT = "rpc.timeout";
+  public static final String SCM_CLIENT_FAILOVER_MAX_RETRY =
+      "failover.max.retry";
+  public static final String SCM_CLIENT_RETRY_INTERVAL =
+      "failover.retry.interval";
+
+  @Config(key = SCM_CLIENT_RPC_TIME_OUT,
+      defaultValue = "15m",
+      type = ConfigType.TIME,
+      tags = {OZONE, SCM, CLIENT},
+      timeUnit = TimeUnit.MILLISECONDS,
+      description = "RpcClient timeout on waiting for the response from " +
+          "OzoneManager. The default value is set to 15 minutes. " +
+          "If ipc.client.ping is set to true and this rpc-timeout " +
+          "is greater than the value of ipc.ping.interval, the effective " +
+          "value of the rpc-timeout is rounded up to multiple of " +
+          "ipc.ping.interval."
+  )
+  private long rpcTimeOut = 15 * 60 * 1000;
+
+  @Config(key = SCM_CLIENT_FAILOVER_MAX_RETRY,
+      defaultValue = "15",
+      type = ConfigType.INT,
+      tags = {OZONE, SCM, CLIENT},
+      description = "Max retry count for SCM Client when failover happens."
+  )
+  private int retryCount = 15;
+
+  @Config(key = SCM_CLIENT_RETRY_INTERVAL,
+      defaultValue = "2s",
+      type = ConfigType.TIME,
+      tags = {OZONE, SCM, CLIENT},
+      timeUnit = TimeUnit.MILLISECONDS,
+      description = "RpcClient timeout on waiting for the response from " +
+          "OzoneManager. The default value is set to 15 minutes. " +

Review comment:
       Also the description does not match with the configuration key and needs 
to be updated. 

##########
File path: 
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/proxy/SCMProxyInfo.java
##########
@@ -0,0 +1,65 @@
+/**
+ * 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.proxy;
+
+import com.google.common.base.Preconditions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetSocketAddress;
+
+/**
+ * Class to store SCM proxy info.
+ */
+public class SCMProxyInfo {
+  private String serviceId;
+  private String nodeId;
+  private String rpcAddrStr;
+  private InetSocketAddress rpcAddr;
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(SCMProxyInfo.class);
+
+  public SCMProxyInfo(String serviceID, String nodeID,
+                      InetSocketAddress rpcAddress) {
+    Preconditions.checkNotNull(rpcAddress);
+    this.serviceId = serviceID;
+    this.nodeId = nodeID;
+    this.rpcAddrStr = rpcAddress.toString();
+    this.rpcAddr = rpcAddress;
+    if (rpcAddr.isUnresolved()) {
+      LOG.warn("SCM address {} for serviceID {} remains unresolved " +
+              "for node ID {} Check your ozone-site.xml file to ensure scm " +
+              "addresses are configured properly.",
+          rpcAddress, serviceId, nodeId);
+    }
+  }
+
+  public String toString() {
+    return new StringBuilder()
+        .append("nodeId=")
+        .append(nodeId)
+        .append(",nodeAddress=")
+        .append(rpcAddrStr).toString();
+  }
+
+  public InetSocketAddress getAddress() {

Review comment:
       missing getter for nodeid and serviceid?

##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/protocol/ScmBlockLocationProtocolServerSideTranslatorPB.java
##########
@@ -94,9 +95,26 @@ public ScmBlockLocationProtocolServerSideTranslatorPB(
         .setTraceID(traceID);
   }
 
+  private boolean isLeader() throws ServiceException {
+    if (!(impl instanceof SCMBlockProtocolServer)) {
+      throw new ServiceException("Should be SCMBlockProtocolServer");
+    } else {
+      return ((SCMBlockProtocolServer) impl).getScm().checkLeader();
+    }
+  }
+
   @Override
   public SCMBlockLocationResponse send(RpcController controller,
       SCMBlockLocationRequest request) throws ServiceException {
+    if (!isLeader()) {
+      SCMBlockLocationResponse.Builder response = createSCMBlockResponse(
+          request.getCmdType(),
+          request.getTraceID());
+      response.setSuccess(false);
+      response.setStatus(Status.SCM_NOT_LEADER);
+      response.setLeaderSCMNodeId(null);

Review comment:
       Should we send back the leader known by this SCM follower instead of 
null to avoid unnecessary client retry?




----------------------------------------------------------------
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.

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



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

Reply via email to