You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by ja...@apache.org on 2014/06/11 05:52:38 UTC
[53/61] [abbrv] git commit: Split UI endpoints into multiple
resources.
Split UI endpoints into multiple resources.
+ Corrected the allocator object and injecting the client.
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/359eccb3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/359eccb3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/359eccb3
Branch: refs/heads/master
Commit: 359eccb328171436d25da181946024410cdc4afc
Parents: ab9b2fe
Author: Sudheesh Katkam <sk...@maprtech.com>
Authored: Mon Jun 9 11:32:58 2014 -0700
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Tue Jun 10 18:59:40 2014 -0700
----------------------------------------------------------------------
.../drill/exec/server/rest/DrillRestServer.java | 11 +++-
.../drill/exec/server/rest/DrillRoot.java | 10 ----
.../exec/server/rest/MetricsResources.java | 24 ++++++++
.../exec/server/rest/ProfileResources.java | 17 ++++++
.../drill/exec/server/rest/QueryResources.java | 59 +++++++++++---------
.../drill/exec/server/rest/StatusResources.java | 38 +++++++++++++
.../src/main/resources/rest/generic.ftl | 2 +-
.../java-exec/src/main/resources/rest/index.ftl | 4 --
.../src/main/resources/rest/profile/list.ftl | 6 +-
.../src/main/resources/rest/profile/profile.ftl | 10 +---
.../src/main/resources/rest/query/list.ftl | 23 ++++++++
.../src/main/resources/rest/query/query.ftl | 4 --
.../src/main/resources/rest/query/result.ftl | 8 +--
.../src/main/resources/rest/status.ftl | 4 --
14 files changed, 152 insertions(+), 68 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/359eccb3/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRestServer.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRestServer.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRestServer.java
index 2a94e1c..c3c7b04 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRestServer.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRestServer.java
@@ -17,7 +17,10 @@
*/
package org.apache.drill.exec.server.rest;
+import org.apache.drill.common.config.DrillConfig;
import org.apache.drill.exec.client.DrillClient;
+import org.apache.drill.exec.coord.ClusterCoordinator;
+import org.apache.drill.exec.memory.BufferAllocator;
import org.apache.drill.exec.store.StoragePluginRegistry;
import org.apache.drill.exec.store.sys.PStoreProvider;
import org.apache.drill.exec.work.WorkManager;
@@ -39,6 +42,7 @@ public class DrillRestServer extends ResourceConfig {
public DrillRestServer(final WorkManager workManager) {
register(DrillRoot.class);
+ register(StatusResources.class);
register(StorageResources.class);
register(ProfileResources.class);
register(QueryResources.class);
@@ -60,7 +64,10 @@ public class DrillRestServer extends ResourceConfig {
register(provider);
}
-
+ final DrillConfig config = workManager.getContext().getConfig();
+ final BufferAllocator allocator = workManager.getContext().getAllocator();
+ final ClusterCoordinator coordinator = workManager.getContext().getClusterCoordinator();
+ final DrillClient client = new DrillClient(config, coordinator, allocator);
register(new AbstractBinder() {
@Override
protected void configure() {
@@ -68,7 +75,7 @@ public class DrillRestServer extends ResourceConfig {
bind(workManager.getContext().getConfig().getMapper()).to(ObjectMapper.class);
bind(workManager.getContext().getPersistentStoreProvider()).to(PStoreProvider.class);
bind(workManager.getContext().getStorage()).to(StoragePluginRegistry.class);
- bind(new DrillClient()).to(DrillClient.class);
+ bind(client).to(DrillClient.class);
}
});
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/359eccb3/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRoot.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRoot.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRoot.java
index b1cb18b..c2fabcb 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRoot.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRoot.java
@@ -21,7 +21,6 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
-
import org.glassfish.jersey.server.mvc.Viewable;
@Path("/")
@@ -35,13 +34,4 @@ public class DrillRoot {
return new Viewable("/rest/index.ftl", status);
}
- @GET
- @Path("/status")
- @Produces(MediaType.TEXT_HTML)
- public Viewable getStatus() {
- String status = "Running!";
- return new Viewable("/rest/status.ftl", status);
- }
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/359eccb3/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/MetricsResources.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/MetricsResources.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/MetricsResources.java
new file mode 100644
index 0000000..f7b6b7f
--- /dev/null
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/MetricsResources.java
@@ -0,0 +1,24 @@
+/**
+ * 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.server.rest;
+
+import javax.ws.rs.Path;
+
+@Path("/metrics")
+public class MetricsResources {
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/359eccb3/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/ProfileResources.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/ProfileResources.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/ProfileResources.java
index d66cdbc..386db46 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/ProfileResources.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/ProfileResources.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.server.rest;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/359eccb3/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/QueryResources.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/QueryResources.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/QueryResources.java
index 84fc581..f444a02 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/QueryResources.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/QueryResources.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.server.rest;
import java.util.LinkedList;
@@ -33,6 +50,8 @@ public class QueryResources {
@Inject
WorkManager work;
+ @Inject
+ DrillClient client;
@GET
@Produces(MediaType.TEXT_HTML)
@@ -43,31 +62,21 @@ public class QueryResources {
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.TEXT_HTML)
- public Viewable submitQuery(@FormParam("query") String query, @FormParam("queryType") String queryType)
- throws Exception {
- try (DrillClient client = new DrillClient(work.getContext().getConfig(), work.getContext().getClusterCoordinator())) {
-
- client.connect();
-
- UserBitShared.QueryType type = UserBitShared.QueryType.SQL;
- switch (queryType) {
- case "SQL":
- type = UserBitShared.QueryType.SQL;
- break;
- case "LOGICAL":
- type = UserBitShared.QueryType.LOGICAL;
- break;
- case "PHYSICAL":
- type = UserBitShared.QueryType.PHYSICAL;
- break;
- }
+ public Viewable submitQuery(@FormParam("query") String query, @FormParam("queryType") String queryType) throws Exception {
+ UserBitShared.QueryType type = UserBitShared.QueryType.SQL;
+ switch (queryType){
+ case "SQL" : type = UserBitShared.QueryType.SQL; break;
+ case "LOGICAL" : type = UserBitShared.QueryType.LOGICAL; break;
+ case "PHYSICAL" : type = UserBitShared.QueryType.PHYSICAL; break;
+ }
- Listener listener = new Listener(new RecordBatchLoader(work.getContext().getAllocator()));
- client.runQuery(type, query, listener);
- List<LinkedList<String>> result = listener.waitForCompletion();
+ client.connect();
+ Listener listener = new Listener(new RecordBatchLoader(work.getContext().getAllocator()));
+ client.runQuery(type, query, listener);
+ List<LinkedList<String>> result = listener.waitForCompletion();
+ client.close();
- return new Viewable("/rest/query/result.ftl", result);
- }
+ return new Viewable("/rest/query/result.ftl", result);
}
private static class Listener implements UserResultsListener {
@@ -122,9 +131,9 @@ public class QueryResources {
public List<LinkedList<String>> waitForCompletion() throws Exception {
latch.await();
- if (exception != null)
+ if (exception != null) {
throw exception;
- System.out.println();
+ }
return output;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/359eccb3/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StatusResources.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StatusResources.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StatusResources.java
new file mode 100644
index 0000000..c98c8e6
--- /dev/null
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StatusResources.java
@@ -0,0 +1,38 @@
+/**
+ * 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.server.rest;
+
+import org.glassfish.jersey.server.mvc.Viewable;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+@Path("/status")
+public class StatusResources {
+ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(StatusResources.class);
+
+ @GET
+ @Produces(MediaType.TEXT_HTML)
+ public Viewable getStatus() {
+ String status = "Running!";
+ return new Viewable("/rest/status/status.ftl", status);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/359eccb3/exec/java-exec/src/main/resources/rest/generic.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/generic.ftl b/exec/java-exec/src/main/resources/rest/generic.ftl
index 41700d0..aad0794 100644
--- a/exec/java-exec/src/main/resources/rest/generic.ftl
+++ b/exec/java-exec/src/main/resources/rest/generic.ftl
@@ -53,7 +53,7 @@
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
- <li><a href="/"><font color="red" id="statusFontColor">Status</font></a></li>
+ <li><a href="/status">Status</a></li>
<li><a href="/query">Query</a></li>
<li><a href="/profiles">Profiles</a></li>
<li><a href="/storage">Storage</a></li>
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/359eccb3/exec/java-exec/src/main/resources/rest/index.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/index.ftl b/exec/java-exec/src/main/resources/rest/index.ftl
index a6b3075..c6e4a4e 100644
--- a/exec/java-exec/src/main/resources/rest/index.ftl
+++ b/exec/java-exec/src/main/resources/rest/index.ftl
@@ -18,10 +18,6 @@
<div class="page-header">
</div>
<p class="lead"> Read about Apache Drill <a href="http://incubator.apache.org/drill/drill_overview.html" rel="nofollow">here</a>.</p>
- <script>
- var elem = document.getElementById("statusFontColor");
- elem.style.color = "green";
- </script>
</#macro>
<@page_html/>
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/359eccb3/exec/java-exec/src/main/resources/rest/profile/list.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/profile/list.ftl b/exec/java-exec/src/main/resources/rest/profile/list.ftl
index 613a0e9..ebd9f7a 100644
--- a/exec/java-exec/src/main/resources/rest/profile/list.ftl
+++ b/exec/java-exec/src/main/resources/rest/profile/list.ftl
@@ -52,7 +52,7 @@
<tr>
<td>${query.getValue()}</td>
<td>
- <a href="/query/${query.getKey()}">
+ <a href="/profile/${query.getKey()}">
<div style="height:100%;width:100%">
${query.getKey()}
</div>
@@ -63,10 +63,6 @@
</tbody>
</table>
</div>
- <script>
- var elem = document.getElementById("statusFontColor");
- elem.style.color = "green";
- </script>
</#macro>
<@page_html/>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/359eccb3/exec/java-exec/src/main/resources/rest/profile/profile.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/profile/profile.ftl b/exec/java-exec/src/main/resources/rest/profile/profile.ftl
index 470f7ab..d4035ae 100644
--- a/exec/java-exec/src/main/resources/rest/profile/profile.ftl
+++ b/exec/java-exec/src/main/resources/rest/profile/profile.ftl
@@ -45,21 +45,17 @@
<button type="submit" class="btn btn-default">Re-run query</button>
</form>
<div class="page-header">
- <h2>Physical plan</h2>
+ <h2>Physical Plan</h2>
</div>
<div class="well">
- <p><font face="courier">${model.plan}</font></p>
+ <p><pre>${model.plan}</pre></p>
</div>
<div class="page-header">
<h2>Complete Profile</h2>
</div>
<div class="well">
- <p><font face="courier">${model.toString()}</font></p>
+ <p><pre>${model.toString()}</pre></p>
</div>
- <script>
- var elem = document.getElementById("statusFontColor");
- elem.style.color = "green";
- </script>
</#macro>
<@page_html/>
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/359eccb3/exec/java-exec/src/main/resources/rest/query/list.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/query/list.ftl b/exec/java-exec/src/main/resources/rest/query/list.ftl
new file mode 100644
index 0000000..9b64d18
--- /dev/null
+++ b/exec/java-exec/src/main/resources/rest/query/list.ftl
@@ -0,0 +1,23 @@
+<#-- 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. -->
+
+<#include "*/generic.ftl">
+<#macro page_head>
+</#macro>
+
+<#macro page_body>
+ <a href="/queries">back</a><br/>
+ <div class="page-header">
+ </div>
+ <h3>Under Construction.</h3>
+</#macro>
+
+<@page_html/>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/359eccb3/exec/java-exec/src/main/resources/rest/query/query.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/query/query.ftl b/exec/java-exec/src/main/resources/rest/query/query.ftl
index a92696b..32e18de 100644
--- a/exec/java-exec/src/main/resources/rest/query/query.ftl
+++ b/exec/java-exec/src/main/resources/rest/query/query.ftl
@@ -45,10 +45,6 @@
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
- <script>
- var elem = document.getElementById("statusFontColor");
- elem.style.color = "green";
- </script>
</#macro>
<@page_html/>
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/359eccb3/exec/java-exec/src/main/resources/rest/query/result.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/query/result.ftl b/exec/java-exec/src/main/resources/rest/query/result.ftl
index a44be9c..e608650 100644
--- a/exec/java-exec/src/main/resources/rest/query/result.ftl
+++ b/exec/java-exec/src/main/resources/rest/query/result.ftl
@@ -16,25 +16,21 @@
<#macro page_body>
<a href="/queries">back</a><br/>
<div class="page-header">
- <h2>Result</h2>
</div>
+ <h2>Result</h2>
<div class="table-responsive">
<table class="table">
<tbody>
<#list model as rows>
<tr>
<#list rows as row>
- <td>${row}</td>
+ <td style="border:none;"><pre>${row}</pre></td>
</#list>
</tr>
</#list>
</tbody>
</table>
</div>
- <!-- <script>
- var elem = document.getElementById("statusFontColor");
- elem.style.color = "green";
- </script> -->
</#macro>
<@page_html/>
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/359eccb3/exec/java-exec/src/main/resources/rest/status.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/status.ftl b/exec/java-exec/src/main/resources/rest/status.ftl
index 1d4e3d3..bda01ec 100644
--- a/exec/java-exec/src/main/resources/rest/status.ftl
+++ b/exec/java-exec/src/main/resources/rest/status.ftl
@@ -20,10 +20,6 @@
<strong>${model}</strong>
</div>
</div>
- <script>
- var elem = document.getElementById("statusFontColor");
- elem.style.color = "green";
- </script>
</#macro>
<@page_html/>