avijayanhwx commented on a change in pull request #353: HDDS-2623. Expose 
SCMDatanodeProtocolServer RPC endpoint through Recon.
URL: https://github.com/apache/hadoop-ozone/pull/353#discussion_r358426226
 
 

 ##########
 File path: 
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/scm/ReconStorageContainerManager.java
 ##########
 @@ -0,0 +1,114 @@
+/**
+ * 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.recon.scm;
+
+import static 
org.apache.hadoop.hdds.scm.server.StorageContainerManager.buildRpcServerStartMessage;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.scm.block.BlockManager;
+import org.apache.hadoop.hdds.scm.node.NodeManager;
+import org.apache.hadoop.hdds.scm.server.SCMStorageConfig;
+import org.apache.hadoop.hdds.scm.server.StorageContainerManagerInterface;
+import org.apache.hadoop.hdds.server.events.EventQueue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Recon's 'lite' version of SCM.
+ */
+public class ReconStorageContainerManager
+    implements StorageContainerManagerInterface {
+
+  private static final Logger LOG = LoggerFactory
+      .getLogger(ReconStorageContainerManager.class);
+
+  private final OzoneConfiguration ozoneConfiguration;
+  private final ReconDatanodeProtocolServer datanodeProtocolServer;
+  private final EventQueue eventQueue;
+  private final SCMStorageConfig scmStorageConfig;
+  private static final String RECON_SCM_CONFIG_PREFIX = "recon.";
+
+  @Inject
+  public ReconStorageContainerManager(OzoneConfiguration conf)
+      throws IOException {
+    this.eventQueue = new EventQueue();
+    this.ozoneConfiguration = getReconScmConfiguration(conf);
+    this.scmStorageConfig = new SCMStorageConfig(conf);
+    this.datanodeProtocolServer = new ReconDatanodeProtocolServer(
+        conf, this, eventQueue);
+  }
+
+  /**
+   *  For every config key which is prefixed by 'recon.scm', create a new
+   *  config key without the prefix keeping the same value.
+   *  For example, if recon.scm.a.b. = xyz, we add a new config like
+   *  a.b.c = xyz. This is done to override Recon's passive SCM configs if
+   *  needed.
+   * @param configuration configuration object.
+   * @return same configuration object with possible added elements.
+   */
+  private OzoneConfiguration getReconScmConfiguration(
+      OzoneConfiguration configuration) {
+    Map<String, String> reconScmConfigs =
+        configuration.getPropsWithPrefix(RECON_SCM_CONFIG_PREFIX);
+    for (Map.Entry<String, String> entry : reconScmConfigs.entrySet()) {
+      configuration.set(entry.getKey(), entry.getValue());
 
 Review comment:
   1. I did see some other examples of setting subsets of configuration in 
HDDS. I also wanted to create a new configuration object from properties, but 
the Hadoop configuration does not seem to provide a straightforward way to do 
that. I will look again.
   2. configuration.getPropsWithPrefix() removes the prefix.

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


With regards,
Apache Git Services

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