elek commented on a change in pull request #861: HDDS-1596. Create service 
endpoint to download configuration from SCM
URL: https://github.com/apache/hadoop/pull/861#discussion_r289036738
 
 

 ##########
 File path: 
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/discovery/DiscoveryUtil.java
 ##########
 @@ -0,0 +1,90 @@
+/**
+ * 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.hdds.discovery;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.net.URL;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
+
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Utility to download ozone configuration from SCM.
+ */
+public final class DiscoveryUtil {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(DiscoveryUtil.class);
+
+  public static final String OZONE_GLOBAL_XML = "ozone-global.xml";
+
+  private DiscoveryUtil() {
+  }
+
+  /**
+   * Download ozone-global.conf from SCM to the local HADOOP_CONF_DIR.
+   */
+  public static boolean loadGlobalConfig(OzoneConfiguration conf) {
+    String hadoopConfDir = System.getenv("HADOOP_CONF_DIR");
+    if (hadoopConfDir == null || hadoopConfDir.isEmpty()) {
+      LOG.warn(
+          "HADOOP_CONF_DIR is not set, can't download ozone-global.xml from "
+              + "SCM.");
+      return false;
+    }
+    if (conf.get("ozone.scm.names") == null) {
+      LOG.warn("ozone.scm.names is not set. Can't download config from scm.");
+      return false;
+    }
+    for (int i = 0; i < 60; i++) {
 
 Review comment:
   I totally understand you.
   
   What about using a never ending loop? It can be a more obvious choice.
   
   In kubernetes there are liveness and readyness probes. You can define a port 
which is checked by the kubernetes and if it's not available, after a while the 
container will be restarted. Together with an unlimited retry it can provide 
full flexibility for the user but we don't need to introduce additional 
configuration (but it doesn't solve the problem for on-prem clusters)

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

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

Reply via email to