DRILL-237: Add local mode to QuerySubmitter
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/5883d152 Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/5883d152 Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/5883d152 Branch: refs/heads/master Commit: 5883d152d4750d987cf2c2154fd25c9276bdc0c4 Parents: b5a3b55 Author: Steven Phillips <[email protected]> Authored: Thu Sep 5 20:01:56 2013 -0700 Committer: Steven Phillips <[email protected]> Committed: Fri Sep 20 12:10:40 2013 -0700 ---------------------------------------------------------------------- .../apache/drill/exec/client/QuerySubmitter.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/5883d152/exec/java-exec/src/main/java/org/apache/drill/exec/client/QuerySubmitter.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/client/QuerySubmitter.java b/exec/java-exec/src/main/java/org/apache/drill/exec/client/QuerySubmitter.java index 4beaa53..2d5c105 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/client/QuerySubmitter.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/client/QuerySubmitter.java @@ -23,6 +23,7 @@ import com.google.common.base.Stopwatch; import com.google.common.io.Resources; import org.apache.commons.lang.StringUtils; import org.apache.drill.common.config.DrillConfig; +import org.apache.drill.exec.coord.ClusterCoordinator; import org.apache.drill.exec.coord.ZKClusterCoordinator; import org.apache.drill.exec.exception.SchemaChangeException; import org.apache.drill.exec.proto.UserProtos; @@ -33,6 +34,8 @@ import org.apache.drill.exec.rpc.RpcException; import org.apache.drill.exec.rpc.user.QueryResultBatch; import org.apache.drill.exec.rpc.user.UserResultsListener; import org.apache.drill.exec.server.BootStrapContext; +import org.apache.drill.exec.server.Drillbit; +import org.apache.drill.exec.server.RemoteServiceSet; import org.apache.drill.exec.vector.ValueVector; import java.io.IOException; @@ -54,9 +57,17 @@ public class QuerySubmitter { public int submitQuery(String planLocation, String type, String zkQuorum) throws Exception { DrillConfig config = DrillConfig.create(); - ZKClusterCoordinator clusterCoordinator = new ZKClusterCoordinator(config, zkQuorum); - clusterCoordinator.start(10000); - DrillClient client = new DrillClient(config, clusterCoordinator); + DrillClient client; + if (zkQuorum.equals("local")) { + RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); + Drillbit bit = new Drillbit(config, serviceSet); + bit.run(); + client = new DrillClient(config, serviceSet.getCoordinator()); + } else { + ZKClusterCoordinator clusterCoordinator = new ZKClusterCoordinator(config, zkQuorum); + clusterCoordinator.start(10000); + client = new DrillClient(config, clusterCoordinator); + } client.connect(); QueryResultsListener listener = new QueryResultsListener(); String plan = Charsets.UTF_8.decode(ByteBuffer.wrap(Files.readAllBytes(Paths.get(planLocation)))).toString();
