You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by bh...@apache.org on 2020/09/30 23:42:31 UTC

[hadoop-ozone] branch master updated: HDDS-4292. Ozone Client not working with Hadoop Version < 3.2 (#1463)

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

bharat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new be25991  HDDS-4292. Ozone Client not working with Hadoop Version < 3.2 (#1463)
be25991 is described below

commit be25991b2b69689b03578549a3b0433de0bece4d
Author: Bharat Viswanadham <bh...@apache.org>
AuthorDate: Wed Sep 30 16:39:01 2020 -0700

    HDDS-4292. Ozone Client not working with Hadoop Version < 3.2 (#1463)
---
 .../ozone/om/ha/OMFailoverProxyProvider.java       | 54 +++++++++++-----------
 .../hadoop/ozone/om/failover/TestOMFailovers.java  | 13 +++---
 2 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/ha/OMFailoverProxyProvider.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/ha/OMFailoverProxyProvider.java
index acafa7c..65eb139 100644
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/ha/OMFailoverProxyProvider.java
+++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/ha/OMFailoverProxyProvider.java
@@ -141,15 +141,14 @@ public class OMFailoverProxyProvider implements
 
         if (omProxyInfo.getAddress() != null) {
 
-          ProxyInfo<OzoneManagerProtocolPB> proxyInfo =
-              new ProxyInfo(null, omProxyInfo.toString());
 
           // For a non-HA OM setup, nodeId might be null. If so, we assign it
           // a dummy value
           if (nodeId == null) {
             nodeId = OzoneConsts.OM_NODE_ID_DUMMY;
           }
-          omProxies.put(nodeId, proxyInfo);
+          // ProxyInfo will be set during first time call to server.
+          omProxies.put(nodeId, null);
           omProxyInfos.put(nodeId, omProxyInfo);
           omNodeIDList.add(nodeId);
         } else {
@@ -199,31 +198,30 @@ public class OMFailoverProxyProvider implements
   @Override
   public synchronized ProxyInfo getProxy() {
     ProxyInfo currentProxyInfo = omProxies.get(currentProxyOMNodeId);
-    createOMProxyIfNeeded(currentProxyInfo, currentProxyOMNodeId);
+    if (currentProxyInfo == null) {
+      currentProxyInfo = createOMProxy(currentProxyOMNodeId);
+    }
     return currentProxyInfo;
   }
 
   /**
-   * Creates proxy object if it does not already exist.
+   * Creates proxy object.
    */
-  protected void createOMProxyIfNeeded(ProxyInfo proxyInfo,
-      String nodeId) {
-    if (proxyInfo.proxy == null) {
-      InetSocketAddress address = omProxyInfos.get(nodeId).getAddress();
-      try {
-        OzoneManagerProtocolPB proxy = createOMProxy(address);
-        try {
-          proxyInfo.proxy = proxy;
-        } catch (IllegalAccessError iae) {
-          omProxies.put(nodeId,
-              new ProxyInfo<>(proxy, proxyInfo.proxyInfo));
-        }
-      } catch (IOException ioe) {
-        LOG.error("{} Failed to create RPC proxy to OM at {}",
-            this.getClass().getSimpleName(), address, ioe);
-        throw new RuntimeException(ioe);
-      }
+  protected ProxyInfo createOMProxy(String nodeId) {
+    OMProxyInfo omProxyInfo = omProxyInfos.get(nodeId);
+    InetSocketAddress address = omProxyInfo.getAddress();
+    ProxyInfo proxyInfo;
+    try {
+      OzoneManagerProtocolPB proxy = createOMProxy(address);
+      // Create proxyInfo here, to make it work with all Hadoop versions.
+      proxyInfo = new ProxyInfo<>(proxy, omProxyInfos.toString());
+      omProxies.put(nodeId, proxyInfo);
+    } catch (IOException ioe) {
+      LOG.error("{} Failed to create RPC proxy to OM at {}",
+          this.getClass().getSimpleName(), address, ioe);
+      throw new RuntimeException(ioe);
     }
+    return proxyInfo;
   }
 
   @VisibleForTesting
@@ -480,10 +478,9 @@ public class OMFailoverProxyProvider implements
    */
   @Override
   public synchronized void close() throws IOException {
-    for (ProxyInfo<OzoneManagerProtocolPB> proxy : omProxies.values()) {
-      OzoneManagerProtocolPB omProxy = proxy.proxy;
-      if (omProxy != null) {
-        RPC.stopProxy(omProxy);
+    for (ProxyInfo<OzoneManagerProtocolPB> proxyInfo : omProxies.values()) {
+      if (proxyInfo != null) {
+        RPC.stopProxy(proxyInfo.proxy);
       }
     }
   }
@@ -494,6 +491,11 @@ public class OMFailoverProxyProvider implements
   }
 
   @VisibleForTesting
+  public Map<String, ProxyInfo<OzoneManagerProtocolPB>> getOMProxyMap() {
+    return omProxies;
+  }
+
+  @VisibleForTesting
   public List<OMProxyInfo> getOMProxyInfos() {
     return new ArrayList<OMProxyInfo>(omProxyInfos.values());
   }
diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/failover/TestOMFailovers.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/failover/TestOMFailovers.java
index 860f3ed..310d42c 100644
--- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/failover/TestOMFailovers.java
+++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/failover/TestOMFailovers.java
@@ -119,12 +119,11 @@ public class TestOMFailovers {
     }
 
     @Override
-    protected void createOMProxyIfNeeded(ProxyInfo proxyInfo,
-        String nodeId) {
-      if (proxyInfo.proxy == null) {
-        proxyInfo.proxy = new MockOzoneManagerProtocol(nodeId,
-            testException);
-      }
+    protected ProxyInfo createOMProxy(String nodeId) {
+      ProxyInfo proxyInfo = new ProxyInfo<>(new MockOzoneManagerProtocol(nodeId,
+          testException), nodeId);
+      getOMProxyMap().put(nodeId, proxyInfo);
+      return proxyInfo;
     }
 
     @Override
@@ -137,7 +136,7 @@ public class TestOMFailovers {
 
       for (int i = 1; i <= 3; i++) {
         String nodeId = "om" + i;
-        omProxies.put(nodeId, new ProxyInfo<>(null, nodeId));
+        omProxies.put(nodeId, null);
         omProxyInfos.put(nodeId, null);
         omNodeIDList.add(nodeId);
       }


---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-commits-help@hadoop.apache.org