KNOX-998 - Merge from 0.14.0 master

Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/92e2ec59
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/92e2ec59
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/92e2ec59

Branch: refs/heads/master
Commit: 92e2ec59a5940a9e7c67ec5cd29044f811dee40a
Parents: e5fd062
Author: Sandeep More <m...@apache.org>
Authored: Tue Jan 9 14:51:08 2018 -0500
Committer: Sandeep More <m...@apache.org>
Committed: Tue Jan 9 14:51:08 2018 -0500

----------------------------------------------------------------------
 .../discovery/ambari/ServiceURLCreator.java     | 32 --------
 .../discovery/ambari/ServiceURLFactory.java     | 75 -----------------
 .../discovery/ambari/WebHdfsUrlCreator.java     | 84 --------------------
 .../discovery/ambari/ServiceURLCreator.java     | 32 ++++++++
 .../discovery/ambari/ServiceURLFactory.java     | 75 +++++++++++++++++
 .../discovery/ambari/WebHdfsUrlCreator.java     | 84 ++++++++++++++++++++
 6 files changed, 191 insertions(+), 191 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/92e2ec59/gateway-discovery-ambari/src/main/java/org/apache/hadoop/gateway/topology/discovery/ambari/ServiceURLCreator.java
----------------------------------------------------------------------
diff --git 
a/gateway-discovery-ambari/src/main/java/org/apache/hadoop/gateway/topology/discovery/ambari/ServiceURLCreator.java
 
b/gateway-discovery-ambari/src/main/java/org/apache/hadoop/gateway/topology/discovery/ambari/ServiceURLCreator.java
deleted file mode 100644
index 8295155..0000000
--- 
a/gateway-discovery-ambari/src/main/java/org/apache/hadoop/gateway/topology/discovery/ambari/ServiceURLCreator.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * 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.gateway.topology.discovery.ambari;
-
-import java.util.List;
-
-public interface ServiceURLCreator {
-
-  /**
-   * Creates one or more cluster-specific URLs for the specified service.
-   *
-   * @param service The service identifier.
-   *
-   * @return A List of created URL strings; the list may be empty.
-   */
-  List<String> create(String service);
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/92e2ec59/gateway-discovery-ambari/src/main/java/org/apache/hadoop/gateway/topology/discovery/ambari/ServiceURLFactory.java
----------------------------------------------------------------------
diff --git 
a/gateway-discovery-ambari/src/main/java/org/apache/hadoop/gateway/topology/discovery/ambari/ServiceURLFactory.java
 
b/gateway-discovery-ambari/src/main/java/org/apache/hadoop/gateway/topology/discovery/ambari/ServiceURLFactory.java
deleted file mode 100644
index fa9f89a..0000000
--- 
a/gateway-discovery-ambari/src/main/java/org/apache/hadoop/gateway/topology/discovery/ambari/ServiceURLFactory.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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.gateway.topology.discovery.ambari;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Factory for creating cluster-specific service URLs.
- */
-public class ServiceURLFactory {
-
-  private Map<String, ServiceURLCreator> urlCreators = new HashMap<>();
-
-  private ServiceURLCreator defaultURLCreator = null;
-
-
-  private ServiceURLFactory(AmbariCluster cluster) {
-    // Default URL creator
-    defaultURLCreator = new AmbariDynamicServiceURLCreator(cluster);
-
-    // Custom (internal) URL creators
-    urlCreators.put("WEBHDFS", new WebHdfsUrlCreator(cluster));
-  }
-
-
-  /**
-   * Create a new factory for the specified cluster.
-   *
-   * @param cluster The cluster.
-   *
-   * @return A ServiceURLFactory instance.
-   */
-  public static ServiceURLFactory newInstance(AmbariCluster cluster) {
-    return new ServiceURLFactory(cluster);
-  }
-
-
-  /**
-   * Create one or more cluster-specific URLs for the specified service.
-   *
-   * @param service The service.
-   *
-   * @return A List of service URL strings; the list may be empty.
-   */
-  public List<String> create(String service) {
-    List<String> urls = new ArrayList<>();
-
-    ServiceURLCreator creator = urlCreators.get(service);
-    if (creator == null) {
-      creator = defaultURLCreator;
-    }
-
-    urls.addAll(creator.create(service));
-
-    return urls;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/92e2ec59/gateway-discovery-ambari/src/main/java/org/apache/hadoop/gateway/topology/discovery/ambari/WebHdfsUrlCreator.java
----------------------------------------------------------------------
diff --git 
a/gateway-discovery-ambari/src/main/java/org/apache/hadoop/gateway/topology/discovery/ambari/WebHdfsUrlCreator.java
 
b/gateway-discovery-ambari/src/main/java/org/apache/hadoop/gateway/topology/discovery/ambari/WebHdfsUrlCreator.java
deleted file mode 100644
index 1d11c66..0000000
--- 
a/gateway-discovery-ambari/src/main/java/org/apache/hadoop/gateway/topology/discovery/ambari/WebHdfsUrlCreator.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * 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.gateway.topology.discovery.ambari;
-
-import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * A ServiceURLCreator implementation for WEBHDFS.
- */
-public class WebHdfsUrlCreator implements ServiceURLCreator {
-
-  private static final String SERVICE = "WEBHDFS";
-
-  private AmbariServiceDiscoveryMessages log = 
MessagesFactory.get(AmbariServiceDiscoveryMessages.class);
-
-  private AmbariCluster cluster = null;
-
-  WebHdfsUrlCreator(AmbariCluster cluster) {
-    this.cluster = cluster;
-  }
-
-  @Override
-  public List<String> create(String service) {
-    List<String> urls = new ArrayList<>();
-
-    if (SERVICE.equals(service)) {
-      AmbariCluster.ServiceConfiguration sc = 
cluster.getServiceConfiguration("HDFS", "hdfs-site");
-
-      // First, check if it's HA config
-      String nameServices = null;
-      AmbariComponent nameNodeComp = cluster.getComponent("NAMENODE");
-      if (nameNodeComp != null) {
-        nameServices = nameNodeComp.getConfigProperty("dfs.nameservices");
-      }
-
-      if (nameServices != null && !nameServices.isEmpty()) {
-        // If it is an HA configuration
-        Map<String, String> props = sc.getProperties();
-
-        // Name node HTTP addresses are defined as properties of the form:
-        //      dfs.namenode.http-address.<NAMESERVICES>.nn<INDEX>
-        // So, this iterates over the nn<INDEX> properties until there is no 
such property (since it cannot be known how
-        // many are defined by any other means).
-        int i = 1;
-        String propertyValue = getHANameNodeHttpAddress(props, nameServices, 
i++);
-        while (propertyValue != null) {
-          urls.add(createURL(propertyValue));
-          propertyValue = getHANameNodeHttpAddress(props, nameServices, i++);
-        }
-      } else { // If it's not an HA configuration, get the single name node 
HTTP address
-        
urls.add(createURL(sc.getProperties().get("dfs.namenode.http-address")));
-      }
-    }
-
-    return urls;
-  }
-
-  private static String getHANameNodeHttpAddress(Map<String, String> props, 
String nameServices, int index) {
-    return props.get("dfs.namenode.http-address." + nameServices + ".nn" + 
index);
-  }
-
-  private static String createURL(String address) {
-    return "http://"; + address + "/webhdfs";
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/92e2ec59/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/ServiceURLCreator.java
----------------------------------------------------------------------
diff --git 
a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/ServiceURLCreator.java
 
b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/ServiceURLCreator.java
new file mode 100644
index 0000000..c2a2d22
--- /dev/null
+++ 
b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/ServiceURLCreator.java
@@ -0,0 +1,32 @@
+/**
+ * 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.knox.gateway.topology.discovery.ambari;
+
+import java.util.List;
+
+public interface ServiceURLCreator {
+
+  /**
+   * Creates one or more cluster-specific URLs for the specified service.
+   *
+   * @param service The service identifier.
+   *
+   * @return A List of created URL strings; the list may be empty.
+   */
+  List<String> create(String service);
+
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/92e2ec59/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/ServiceURLFactory.java
----------------------------------------------------------------------
diff --git 
a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/ServiceURLFactory.java
 
b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/ServiceURLFactory.java
new file mode 100644
index 0000000..e009585
--- /dev/null
+++ 
b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/ServiceURLFactory.java
@@ -0,0 +1,75 @@
+/**
+ * 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.knox.gateway.topology.discovery.ambari;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Factory for creating cluster-specific service URLs.
+ */
+public class ServiceURLFactory {
+
+  private Map<String, ServiceURLCreator> urlCreators = new HashMap<>();
+
+  private ServiceURLCreator defaultURLCreator = null;
+
+
+  private ServiceURLFactory(AmbariCluster cluster) {
+    // Default URL creator
+    defaultURLCreator = new AmbariDynamicServiceURLCreator(cluster);
+
+    // Custom (internal) URL creators
+    urlCreators.put("WEBHDFS", new WebHdfsUrlCreator(cluster));
+  }
+
+
+  /**
+   * Create a new factory for the specified cluster.
+   *
+   * @param cluster The cluster.
+   *
+   * @return A ServiceURLFactory instance.
+   */
+  public static ServiceURLFactory newInstance(AmbariCluster cluster) {
+    return new ServiceURLFactory(cluster);
+  }
+
+
+  /**
+   * Create one or more cluster-specific URLs for the specified service.
+   *
+   * @param service The service.
+   *
+   * @return A List of service URL strings; the list may be empty.
+   */
+  public List<String> create(String service) {
+    List<String> urls = new ArrayList<>();
+
+    ServiceURLCreator creator = urlCreators.get(service);
+    if (creator == null) {
+      creator = defaultURLCreator;
+    }
+
+    urls.addAll(creator.create(service));
+
+    return urls;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/92e2ec59/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/WebHdfsUrlCreator.java
----------------------------------------------------------------------
diff --git 
a/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/WebHdfsUrlCreator.java
 
b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/WebHdfsUrlCreator.java
new file mode 100644
index 0000000..1c65982
--- /dev/null
+++ 
b/gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/WebHdfsUrlCreator.java
@@ -0,0 +1,84 @@
+/**
+ * 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.knox.gateway.topology.discovery.ambari;
+
+import org.apache.knox.gateway.i18n.messages.MessagesFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A ServiceURLCreator implementation for WEBHDFS.
+ */
+public class WebHdfsUrlCreator implements ServiceURLCreator {
+
+  private static final String SERVICE = "WEBHDFS";
+
+  private AmbariServiceDiscoveryMessages log = 
MessagesFactory.get(AmbariServiceDiscoveryMessages.class);
+
+  private AmbariCluster cluster = null;
+
+  WebHdfsUrlCreator(AmbariCluster cluster) {
+    this.cluster = cluster;
+  }
+
+  @Override
+  public List<String> create(String service) {
+    List<String> urls = new ArrayList<>();
+
+    if (SERVICE.equals(service)) {
+      AmbariCluster.ServiceConfiguration sc = 
cluster.getServiceConfiguration("HDFS", "hdfs-site");
+
+      // First, check if it's HA config
+      String nameServices = null;
+      AmbariComponent nameNodeComp = cluster.getComponent("NAMENODE");
+      if (nameNodeComp != null) {
+        nameServices = nameNodeComp.getConfigProperty("dfs.nameservices");
+      }
+
+      if (nameServices != null && !nameServices.isEmpty()) {
+        // If it is an HA configuration
+        Map<String, String> props = sc.getProperties();
+
+        // Name node HTTP addresses are defined as properties of the form:
+        //      dfs.namenode.http-address.<NAMESERVICES>.nn<INDEX>
+        // So, this iterates over the nn<INDEX> properties until there is no 
such property (since it cannot be known how
+        // many are defined by any other means).
+        int i = 1;
+        String propertyValue = getHANameNodeHttpAddress(props, nameServices, 
i++);
+        while (propertyValue != null) {
+          urls.add(createURL(propertyValue));
+          propertyValue = getHANameNodeHttpAddress(props, nameServices, i++);
+        }
+      } else { // If it's not an HA configuration, get the single name node 
HTTP address
+        
urls.add(createURL(sc.getProperties().get("dfs.namenode.http-address")));
+      }
+    }
+
+    return urls;
+  }
+
+  private static String getHANameNodeHttpAddress(Map<String, String> props, 
String nameServices, int index) {
+    return props.get("dfs.namenode.http-address." + nameServices + ".nn" + 
index);
+  }
+
+  private static String createURL(String address) {
+    return "http://"; + address + "/webhdfs";
+  }
+
+}

Reply via email to