drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From par...@apache.org
Subject [1/3] drill git commit: DRILL-3034: Apply UserException to port-binding; handle in embedded-Drill case.
Date Tue, 02 Jun 2015 20:53:23 GMT
Repository: drill
Updated Branches:
  refs/heads/master bca206552 -> acf5566e8


DRILL-3034: Apply UserException to port-binding; handle in embedded-Drill case.

Applied UserException to can't-bind-to-port error.  [BasicServer]
Added specific handling of UserException (above case or other) in SQLException
wrapping.  [DrillConnectionImpl]


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/71199edd
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/71199edd
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/71199edd

Branch: refs/heads/master
Commit: 71199edd54e1b9c4ede58c99eb7b6721878b4449
Parents: bca2065
Author: dbarclay <dbarclay@maprtech.com>
Authored: Mon May 11 20:55:19 2015 -0700
Committer: Parth Chandra <parthc@apache.org>
Committed: Tue Jun 2 12:25:48 2015 -0700

----------------------------------------------------------------------
 .../java/org/apache/drill/exec/rpc/BasicServer.java   | 14 ++++++++++++--
 .../org/apache/drill/jdbc/DrillConnectionImpl.java    |  5 +++++
 2 files changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/71199edd/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicServer.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicServer.java b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicServer.java
index 5c04264..2ebd353 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicServer.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicServer.java
@@ -32,6 +32,7 @@ import java.io.IOException;
 import java.net.BindException;
 import java.util.concurrent.ExecutionException;
 
+import org.apache.drill.common.exceptions.UserException;
 import org.apache.drill.exec.exception.DrillbitStartupException;
 import org.apache.drill.exec.memory.BufferAllocator;
 import org.apache.drill.exec.proto.GeneralRPCProtos.RpcMode;
@@ -190,15 +191,24 @@ public abstract class BasicServer<T extends EnumLite, C extends RemoteConnection
         b.bind(++port).sync();
         break;
       } catch (Exception e) {
+        // TODO(DRILL-3026):  Revisit:  Exception is not (always) BindException.
+        // One case is "java.io.IOException: bind() failed: Address already in
+        // use".
         if (e instanceof BindException && allowPortHunting) {
           continue;
         }
-        throw new DrillbitStartupException("Could not bind Drillbit", e);
+        final UserException bindException =
+            UserException
+              .resourceError( e )
+              .addContext( "Server type", getClass().getSimpleName() )
+              .message( "Drillbit could not bind to port %s.", port )
+              .build();
+        throw bindException;
       }
     }
 
     connect = !connect;
-    logger.debug("Server started on port {} of type {} ", port, this.getClass().getSimpleName());
+    logger.debug("Server of type {} started on port {}.", getClass().getSimpleName(), port);
     return port;
   }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/71199edd/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnectionImpl.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnectionImpl.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnectionImpl.java
index 7c6ef7e..5f82054 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnectionImpl.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnectionImpl.java
@@ -35,6 +35,7 @@ import net.hydromatic.avatica.UnregisteredDriver;
 
 import org.apache.drill.common.config.DrillConfig;
 import org.apache.drill.common.exceptions.DrillRuntimeException;
+import org.apache.drill.common.exceptions.UserException;
 import org.apache.drill.exec.client.DrillClient;
 import org.apache.drill.exec.memory.BufferAllocator;
 import org.apache.drill.exec.memory.TopLevelAllocator;
@@ -95,6 +96,10 @@ public abstract class DrillConnectionImpl extends AvaticaConnection
           try {
             bit = new Drillbit(dConfig, serviceSet);
             bit.run();
+          } catch (final UserException e) {
+            throw new SQLException(
+                "Failure in starting embedded Drillbit: " + e.getMessage(),
+                e);
           } catch (Exception e) {
             // (Include cause exception's text in wrapping exception's text so
             // it's more likely to get to user (e.g., via SQLLine), and use


Mime
View raw message