asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buyin...@apache.org
Subject asterixdb git commit: Change name resolution order to Node name -> DNS
Date Thu, 09 Feb 2017 16:24:44 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 7648b480c -> 19e0c22a8


Change name resolution order to Node name -> DNS

Change-Id: I2bbfc8d9d8469c444f6c70bd3a77654892aeb42f
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1491
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
BAD: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/19e0c22a
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/19e0c22a
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/19e0c22a

Branch: refs/heads/master
Commit: 19e0c22a86fa8d91e62b570cb9f8702533ed6ed2
Parents: 7648b48
Author: Abdullah Alamoudi <bamousaa@gmail.com>
Authored: Wed Feb 8 15:07:05 2017 -0800
Committer: Yingyi Bu <buyingyi@gmail.com>
Committed: Thu Feb 9 08:23:21 2017 -0800

----------------------------------------------------------------------
 .../asterix/common/exceptions/ErrorCode.java    |  1 -
 .../main/resources/asx_errormsg/en.properties   |  1 -
 .../asterix/external/util/NodeResolver.java     | 36 +++++++-------------
 3 files changed, 12 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/19e0c22a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
index 22c080a..5ae313d 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
@@ -108,7 +108,6 @@ public class ErrorCode {
     public static final int UNKNOWN_RECORD_FORMAT_FOR_META_PARSER = 3027;
     public static final int LIBRARY_JAVA_JOBJECTS_FIELD_ALREADY_DEFINED = 3028;
     public static final int LIBRARY_JAVA_JOBJECTS_UNKNOWN_FIELD = 3029;
-    public static final int NODE_RESOLVER_COULDNT_RESOLVE_ADDRESS = 3030;
     public static final int NODE_RESOLVER_NO_NODE_CONTROLLERS = 3031;
     public static final int NODE_RESOLVER_UNABLE_RESOLVE_HOST = 3032;
     public static final int INPUT_RECORD_CONVERTER_DCP_MSG_TO_RECORD_CONVERTER_UNKNOWN_DCP_REQUEST
= 3033;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/19e0c22a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
index f1e9836..440e2d3 100644
--- a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
+++ b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
@@ -93,7 +93,6 @@
 3027 = Unknown record format for a record with meta parser. Did you specify the parameter
%1$s
 3028 = Field already defined in %1$s part
 3029 = Unknown field: %1$s
-3030 = Address passed: '%1$s' couldn't be resolved to an ip address and is not an NC id.
Existing NCs are %2$s
 3031 = No node controllers found at the address: %1$s
 3032 = Unable to resolve hostname '%1$s' to an IP address
 3033 = Unknown DCP request: %1$s

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/19e0c22a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/NodeResolver.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/NodeResolver.java
b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/NodeResolver.java
index 9970f27..84346c4 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/NodeResolver.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/NodeResolver.java
@@ -38,46 +38,34 @@ import org.apache.asterix.runtime.utils.RuntimeUtils;
 public class NodeResolver implements INodeResolver {
     //TODO: change this call and replace by calling AsterixClusterProperties
     private static final Random random = new Random();
-    private static final Map<InetAddress, Set<String>> ncMap = new HashMap<InetAddress,
Set<String>>();
-    private static final Set<String> ncs = new HashSet<String>();
+    private static final Map<InetAddress, Set<String>> ncMap = new HashMap<>();
+    private static final Set<String> ncs = new HashSet<>();
 
     @Override
     public String resolveNode(String value) throws AsterixException {
-        UnknownHostException uhe = null;
         try {
             if (ncMap.isEmpty()) {
                 NodeResolver.updateNCs();
             }
+            if (ncs.contains(value)) {
+                return value;
+            } else {
+                NodeResolver.updateNCs();
+                if (ncs.contains(value)) {
+                    return value;
+                }
+            }
             InetAddress ipAddress = null;
             try {
                 ipAddress = InetAddress.getByName(value);
             } catch (UnknownHostException e) {
-                uhe = e;
-            }
-            if (ipAddress == null) {
-                if (ncs.contains(value)) {
-                    return value;
-                } else {
-                    NodeResolver.updateNCs();
-                    if (ncs.contains(value)) {
-                        return value;
-                    } else {
-                        throw new AsterixException(ErrorCode.NODE_RESOLVER_COULDNT_RESOLVE_ADDRESS,
uhe, value,
-                                ncs.toString());
-                    }
-                }
-
+                throw new AsterixException(ErrorCode.NODE_RESOLVER_UNABLE_RESOLVE_HOST, e,
value);
             }
             Set<String> nodeControllers = ncMap.get(ipAddress);
             if (nodeControllers == null || nodeControllers.isEmpty()) {
                 throw new AsterixException(ErrorCode.NODE_RESOLVER_NO_NODE_CONTROLLERS, value);
             }
-            String chosenNCId = nodeControllers.toArray(new String[] {})[random.nextInt(nodeControllers.size())];
-            return chosenNCId;
-        } catch (UnknownHostException e) {
-            throw new AsterixException(ErrorCode.NODE_RESOLVER_UNABLE_RESOLVE_HOST, value);
-        } catch (AsterixException ae) {
-            throw ae;
+            return nodeControllers.toArray(new String[] {})[random.nextInt(nodeControllers.size())];
         } catch (Exception e) {
             throw new AsterixException(e);
         }


Mime
View raw message