You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by ja...@apache.org on 2013/04/23 08:09:17 UTC

[3/3] git commit: addressed jacques comments

addressed jacques comments


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

Branch: refs/heads/execwork
Commit: 0d2428fdea1d4135db129538333871ce8affa1b9
Parents: 31fb6eb
Author: David Ribeiro Alves <da...@gmail.com>
Authored: Fri Apr 19 18:16:47 2013 -0500
Committer: David Ribeiro Alves <da...@gmail.com>
Committed: Fri Apr 19 18:16:47 2013 -0500

----------------------------------------------------------------------
 .../apache/drill/common/config/DrillConfig.java    |    1 -
 .../org/apache/drill/exec/client/DrillClient.java  |   32 ++++++++------
 .../org/apache/drill/exec/rpc/BasicServer.java     |   22 +++++-----
 .../java-exec/src/main/resources/drill-module.conf |    1 -
 .../org/apache/drill/exec/DrillSystemTestBase.java |   14 ------
 5 files changed, 28 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0d2428fd/sandbox/prototype/common/src/main/java/org/apache/drill/common/config/DrillConfig.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/config/DrillConfig.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/config/DrillConfig.java
index dc9327e..5750aaf 100644
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/config/DrillConfig.java
+++ b/sandbox/prototype/common/src/main/java/org/apache/drill/common/config/DrillConfig.java
@@ -24,7 +24,6 @@ import java.util.Queue;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.sun.media.jfxmedia.events.VideoTrackSizeListener;
 import org.apache.drill.common.exceptions.DrillConfigurationException;
 import org.apache.drill.common.expression.LogicalExpression;
 import org.apache.drill.common.logical.StorageEngineConfigBase;

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0d2428fd/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillClient.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillClient.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillClient.java
index e0f3347..74474a4 100644
--- a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillClient.java
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillClient.java
@@ -1,3 +1,20 @@
+/*******************************************************************************
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.drill.exec.client;
 
 import io.netty.buffer.ByteBufAllocator;
@@ -16,9 +33,6 @@ import java.util.Collection;
 
 import static com.google.common.base.Preconditions.checkState;
 import static com.google.common.collect.Iterables.get;
-import static io.netty.buffer.Unpooled.EMPTY_BUFFER;
-import static io.netty.buffer.Unpooled.copiedBuffer;
-import static java.nio.charset.Charset.forName;
 import static org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;
 import static org.apache.drill.exec.proto.UserProtos.QueryHandle;
 import static org.apache.drill.exec.proto.UserProtos.QueryResultsMode.STREAM_FULL;
@@ -84,17 +98,7 @@ public class DrillClient {
    * @throws RpcException
    */
   public DrillRpcFuture<QueryHandle> submitPlan(String plan) throws RpcException {
-    return this.client.submitQuery(newBuilder().setMode(STREAM_FULL).setPlan(plan).build(), EMPTY_BUFFER);
+    return this.client.submitQuery(newBuilder().setMode(STREAM_FULL).setPlan(plan).build(), null);
   }
 
-  /**
-   * Submits a Query for parsing and execution
-   *
-   * @param query the query to execute
-   * @return a handle for the query result
-   * @throws RpcException
-   */
-  public DrillRpcFuture<QueryHandle> submitQuery(String query) throws RpcException {
-    return this.client.submitQuery(newBuilder().setMode(STREAM_FULL).build(), copiedBuffer(query, forName("UTF-8")));
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0d2428fd/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicServer.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicServer.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicServer.java
index a75dee0..bc942ac 100644
--- a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicServer.java
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicServer.java
@@ -17,6 +17,7 @@
  ******************************************************************************/
 package org.apache.drill.exec.rpc;
 
+import com.google.protobuf.Internal.EnumLite;
 import io.netty.bootstrap.ServerBootstrap;
 import io.netty.buffer.ByteBufAllocator;
 import io.netty.channel.ChannelInitializer;
@@ -26,12 +27,10 @@ import io.netty.channel.socket.SocketChannel;
 import io.netty.channel.socket.nio.NioServerSocketChannel;
 import io.netty.handler.logging.LogLevel;
 import io.netty.handler.logging.LoggingHandler;
-
-import java.io.IOException;
-
 import org.apache.drill.exec.exception.DrillbitStartupException;
 
-import com.google.protobuf.Internal.EnumLite;
+import java.io.IOException;
+import java.net.BindException;
 
 /**
  * A server is bound to a port and is responsible for responding to various type of requests. In some cases, the inbound
@@ -79,18 +78,17 @@ public abstract class BasicServer<T extends EnumLite> extends RpcBus<T>{
 
 
   public int bind(final int initialPort) throws InterruptedException, DrillbitStartupException{
-    boolean ok = false;
     int port = initialPort;
-    for(; port < Character.MAX_VALUE; port++){
-      if(b.bind(port).sync().isSuccess()){
-        ok = true;
+    while (true) {
+      try {
+        b.bind(port++).sync();
         break;
+      } catch (Exception e) {
+        if (e instanceof BindException)
+          continue;
+        throw new DrillbitStartupException("Could not bind Drillbit", e);
       }
     }
-    if(!ok){
-      throw new DrillbitStartupException(String.format("Unable to find available port for Drillbit server starting at port %d.", initialPort));
-    }
-    
     connect = !connect;
     return port;    
   }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0d2428fd/sandbox/prototype/exec/java-exec/src/main/resources/drill-module.conf
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/resources/drill-module.conf b/sandbox/prototype/exec/java-exec/src/main/resources/drill-module.conf
index c516dda..ad18d6e 100644
--- a/sandbox/prototype/exec/java-exec/src/main/resources/drill-module.conf
+++ b/sandbox/prototype/exec/java-exec/src/main/resources/drill-module.conf
@@ -4,7 +4,6 @@
 drill.exec: {
   cluster-id: "drillbits1"
   rpc: {
-    user.address : localhost
   	user.port : 31010,
   	bit.port : 31011
   },

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0d2428fd/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/DrillSystemTestBase.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/DrillSystemTestBase.java b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/DrillSystemTestBase.java
index 645c4d5..37ba12b 100644
--- a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/DrillSystemTestBase.java
+++ b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/DrillSystemTestBase.java
@@ -18,7 +18,6 @@
 package org.apache.drill.exec;
 
 import com.google.common.collect.ImmutableList;
-import com.typesafe.config.ConfigValueFactory;
 import org.apache.drill.common.config.DrillConfig;
 import org.apache.drill.exec.exception.DrillbitStartupException;
 import org.apache.drill.exec.server.Drillbit;
@@ -43,8 +42,6 @@ public class DrillSystemTestBase {
   private static File testDir = new File("target/test-data");
   private static DrillConfig config;
   private static String zkUrl;
-  private static int bitPort;
-  private static int userPort;
 
   private List<Drillbit> servers;
   private MiniZooKeeperCluster zkCluster;
@@ -52,8 +49,6 @@ public class DrillSystemTestBase {
   @BeforeClass
   public static void setUp() throws Exception {
     config = DrillConfig.create();
-    bitPort = config.getInt(ExecConstants.INITIAL_BIT_PORT);
-    userPort = config.getInt(ExecConstants.INITIAL_USER_PORT);
     zkUrl = config.getString(ExecConstants.ZK_CONNECTION);
     setupTestDir();
   }
@@ -64,19 +59,10 @@ public class DrillSystemTestBase {
     }
   }
 
-  private DrillConfig newConfigWithDifferentPorts() {
-    return new DrillConfig(config
-      .withValue(ExecConstants.INITIAL_BIT_PORT, ConfigValueFactory.fromAnyRef(bitPort++))
-      .withValue(ExecConstants.INITIAL_USER_PORT, ConfigValueFactory.fromAnyRef(userPort++)));
-  }
-
   public void startCluster(int numServers) {
     try {
       ImmutableList.Builder<Drillbit> servers = ImmutableList.builder();
       for (int i = 0; i < numServers; i++) {
-        DrillConfig config = newConfigWithDifferentPorts();
-//        System.out.println("NEW CONFIG");
-//        System.out.println(config);
         servers.add(Drillbit.start(config));
       }
       this.servers = servers.build();