DRILL-964: Allow enabling/disabling storage plugin instance from UI + Creating a client per request (to avoid issues with multiple connections). + Correcting the links. + Searchable result table. + Minor UI tweaks.
Squashed commits: [461182d] [99a678a] [2c16c3a] Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/0879f830 Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/0879f830 Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/0879f830 Branch: refs/heads/master Commit: 0879f830068e0282884b55812f4a4fba0311a63f Parents: 2903ed3 Author: Sudheesh Katkam <[email protected]> Authored: Tue Jun 10 12:13:56 2014 -0700 Committer: Jacques Nadeau <[email protected]> Committed: Wed Jun 11 16:08:16 2014 -0700 ---------------------------------------------------------------------- .../drill/exec/server/rest/DrillRestServer.java | 5 --- .../drill/exec/server/rest/QueryResources.java | 10 ++++- .../drill/exec/server/rest/StatusResources.java | 2 +- .../exec/server/rest/StorageResources.java | 29 ++++++++++++-- .../src/main/resources/rest/generic.ftl | 6 +-- .../src/main/resources/rest/profile/list.ftl | 4 +- .../src/main/resources/rest/profile/profile.ftl | 4 -- .../src/main/resources/rest/query/result.ftl | 33 +++++++++++++--- .../src/main/resources/rest/storage/list.ftl | 22 ++++------- .../src/main/resources/rest/storage/update.ftl | 41 ++++++++++---------- 10 files changed, 95 insertions(+), 61 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0879f830/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 c3c7b04..11bb776 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 @@ -64,10 +64,6 @@ 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() { @@ -75,7 +71,6 @@ 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(client).to(DrillClient.class); } }); } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0879f830/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 f444a02..9c1dce1 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 @@ -31,8 +31,11 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +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.exception.SchemaChangeException; +import org.apache.drill.exec.memory.BufferAllocator; import org.apache.drill.exec.proto.UserBitShared; import org.apache.drill.exec.record.RecordBatchLoader; import org.apache.drill.exec.record.VectorWrapper; @@ -50,8 +53,6 @@ public class QueryResources { @Inject WorkManager work; - @Inject - DrillClient client; @GET @Produces(MediaType.TEXT_HTML) @@ -63,6 +64,11 @@ public class QueryResources { @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces(MediaType.TEXT_HTML) public Viewable submitQuery(@FormParam("query") String query, @FormParam("queryType") String queryType) throws Exception { + final DrillConfig config = work.getContext().getConfig(); + final ClusterCoordinator coordinator = work.getContext().getClusterCoordinator(); + final BufferAllocator allocator = work.getContext().getAllocator(); + DrillClient client = new DrillClient(config, coordinator, allocator); + UserBitShared.QueryType type = UserBitShared.QueryType.SQL; switch (queryType){ case "SQL" : type = UserBitShared.QueryType.SQL; break; http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0879f830/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 index c98c8e6..4ec4182 100644 --- 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 @@ -32,7 +32,7 @@ public class StatusResources { @Produces(MediaType.TEXT_HTML) public Viewable getStatus() { String status = "Running!"; - return new Viewable("/rest/status/status.ftl", status); + return new Viewable("/rest/status.ftl", status); } } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0879f830/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java index 244d8a8..aa090cf 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java @@ -19,6 +19,8 @@ package org.apache.drill.exec.server.rest; import java.io.IOException; import java.io.StringReader; +import java.net.URI; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -30,7 +32,10 @@ import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; import org.apache.drill.common.exceptions.ExecutionSetupException; import org.apache.drill.common.logical.StoragePluginConfig; @@ -59,12 +64,15 @@ public class StorageResources { @Produces(MediaType.TEXT_HTML) public Viewable getQueries() { - List<String> names = Lists.newArrayList(); + List<SimpleHash> list = Lists.newArrayList(); for (Map.Entry<String, StoragePluginConfig> config : storage.getStore()) { - names.add(config.getKey()); + SimpleHash map = new SimpleHash(); + map.put("name", config.getKey()); + map.put("enabled", config.getValue().isEnabled()); + list.add(map); } - return new Viewable("/rest/storage/list.ftl", names); + return new Viewable("/rest/storage/list.ftl", list); } @GET @@ -78,10 +86,25 @@ public class StorageResources { map.put("config", conf); map.put("name", name); map.put("exists", config != null); + map.put("enabled", config.isEnabled()); return new Viewable("/rest/storage/update.ftl", map); } @GET + @Path("/{name}/enable/{val}") + @Produces(MediaType.TEXT_HTML) + public Response setEnable(@Context UriInfo uriInfo, @PathParam("name") String name, @PathParam("val") Boolean enable) throws ExecutionSetupException { + StoragePluginConfig config = findConfig(name); + if (config != null) { + config.setEnabled(enable); + storage.createOrUpdate(name, config, true); + } + + URI uri = uriInfo.getBaseUriBuilder().path("/storage").build(); + return Response.seeOther(uri).build(); + } + + @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{name}/config") public StoragePluginConfig getConfig(@PathParam("name") String name) { http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0879f830/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 aad0794..1a47915 100644 --- a/exec/java-exec/src/main/resources/rest/generic.ftl +++ b/exec/java-exec/src/main/resources/rest/generic.ftl @@ -25,9 +25,9 @@ <title>Apache Drill</title> <link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"> - <link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css" rel="stylesheet"> - <link href="theme.css" rel="stylesheet"> + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> + <script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script> <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> @@ -67,8 +67,6 @@ <div class="container theme-showcase" role="main"> <@page_body/> </div> - <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> - <script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script> </body> </html> </#macro> http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0879f830/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 ebd9f7a..61d3466 100644 --- a/exec/java-exec/src/main/resources/rest/profile/list.ftl +++ b/exec/java-exec/src/main/resources/rest/profile/list.ftl @@ -29,7 +29,7 @@ <tr> <td>${query.getValue()}</td> <td> - <a href="/query/${query.getKey()}"> + <a href="/profiles/${query.getKey()}"> <div style="height:100%;width:100%"> ${query.getKey()} </div> @@ -52,7 +52,7 @@ <tr> <td>${query.getValue()}</td> <td> - <a href="/profile/${query.getKey()}"> + <a href="/profiles/${query.getKey()}"> <div style="height:100%;width:100%"> ${query.getKey()} </div> http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0879f830/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 d4035ae..ffd22db 100644 --- a/exec/java-exec/src/main/resources/rest/profile/profile.ftl +++ b/exec/java-exec/src/main/resources/rest/profile/profile.ftl @@ -47,15 +47,11 @@ <div class="page-header"> <h2>Physical Plan</h2> </div> - <div class="well"> <p><pre>${model.plan}</pre></p> - </div> <div class="page-header"> <h2>Complete Profile</h2> </div> - <div class="well"> <p><pre>${model.toString()}</pre></p> - </div> </#macro> <@page_html/> http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0879f830/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 e608650..bedbf9f 100644 --- a/exec/java-exec/src/main/resources/rest/query/result.ftl +++ b/exec/java-exec/src/main/resources/rest/query/result.ftl @@ -11,6 +11,12 @@ <#include "*/generic.ftl"> <#macro page_head> + <link rel="stylesheet" type="text/css" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"> + <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/plug-ins/be7019ee387/integration/jqueryui/dataTables.jqueryui.css"> + + <script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.10.2.min.js"></script> + <script type="text/javascript" language="javascript" src="//cdn.datatables.net/1.10.0/js/jquery.dataTables.min.js"></script> + <script type="text/javascript" language="javascript" src="//cdn.datatables.net/plug-ins/be7019ee387/integration/jqueryui/dataTables.jqueryui.js"></script> </#macro> <#macro page_body> @@ -18,19 +24,34 @@ <div class="page-header"> </div> <h2>Result</h2> - <div class="table-responsive"> - <table class="table"> - <tbody> - <#list model as rows> + <div style="width=100%; overflow: auto;"> + <table id="relation" class="table table-striped table-bordered table-condensed" style="display: table; table-layout: fized; width=100%;"> + <#assign rows = model[0]> + <thead style="overflow: auto;"> <tr> <#list rows as row> - <td style="border:none;"><pre>${row}</pre></td> + <th>${row}</th> </#list> </tr> - </#list> + </thead> + <tbody style="overflow: auto;"> + <#list model as rows> + <#if (rows_index > 0)> + <tr> + <#list rows as row> + <td>${row}</td> + </#list> + </tr> + </#if> + </#list> </tbody> </table> </div> + <script charset="utf-8"> + $(document).ready(function() { + $('#relation').dataTable( { "scrollX" : true } ); + } ); + </script> </#macro> <@page_html/> http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0879f830/exec/java-exec/src/main/resources/rest/storage/list.ftl ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/resources/rest/storage/list.ftl b/exec/java-exec/src/main/resources/rest/storage/list.ftl index 6afe4b5..5e50616 100644 --- a/exec/java-exec/src/main/resources/rest/storage/list.ftl +++ b/exec/java-exec/src/main/resources/rest/storage/list.ftl @@ -24,17 +24,15 @@ <#list model as plugin> <tr> <td style="border:none;"> - ${plugin} + ${plugin.name} </td> <td style="border:none;"> - <form action="/storage/${plugin}/config"> - <button class="btn btn-default" type="submit">View</button> - </form> - </td> - <td style="border:none;"> - <form action="/storage/${plugin}/config/update"> - <button class="btn btn-primary" type="submit">Update</button> - </form> + <a class="btn btn-primary" href="/storage/${plugin.name}/config/update">Update</a> + <#if plugin.enabled> + <a class="btn btn-default" href="/storage/${plugin.name}/enable/false">Disable</a> + <#else> + <a class="btn btn-primary" href="/storage/${plugin.name}/enable/true">Enable</a> + </#if> </td> </tr> </#list> @@ -55,13 +53,9 @@ form.submit(); } </script> - <button type="submit" class="btn btn-default" onclick="javascript:doSubmit();">Submit</button> + <button type="submit" class="btn btn-default" onclick="javascript:doSubmit();">Create</button> </form> </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/0879f830/exec/java-exec/src/main/resources/rest/storage/update.ftl ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/resources/rest/storage/update.ftl b/exec/java-exec/src/main/resources/rest/storage/update.ftl index a76d750..ae60852 100644 --- a/exec/java-exec/src/main/resources/rest/storage/update.ftl +++ b/exec/java-exec/src/main/resources/rest/storage/update.ftl @@ -19,27 +19,28 @@ </div> <h3>Configuration</h3> <form role="form" action="/storage/config/update" method="POST"> - <input type="hidden" name="name" value="${model.name}" /> - <div class="form-group"> - <textarea class="form-control" id="config" rows="20" cols="50" name="config">${model.config}</textarea> - </div> - <button class="btn btn-default" type="submit"> - <#if model.exists >Update<#else>Create</#if> - </button> + <input type="hidden" name="name" value="${model.name}" /> + <div class="form-group"> + <textarea class="form-control" id="config" rows="20" cols="50" name="config" style="font-family: Courier;">${model.config}</textarea> + </div> + <a class="btn btn-default" href="/storage">Back</a> + <button class="btn btn-default" type="submit"> + <#if model.exists >Update<#else>Create</#if> + </button> + <#if model.enabled> + <a class="btn btn-default" href="/storage/${model.name}/enable/false">Disable</a> + <#else> + <a class="btn btn-primary" href="/storage/${model.name}/enable/true">Enable</a> + </#if> + <#if model.exists > + <form role="form" action="/storage/config/delete" method="POST"> + <input type="hidden" name="name" value="${model.name}" /> + <button type="submit" class="btn btn-default" onclick="return confirm('Are you sure?')"> + Delete + </button> + </form> + </#if> </form> - <br/> - <#if model.exists > - <form role="form" action="/storage/config/delete" method="POST"> - <input type="hidden" name="name" value="${model.name}" /> - <button type="submit" class="btn btn-default" onclick="return confirm('Are you sure?')"> - Delete - </button> - </form> - </#if> - <script> - var elem = document.getElementById("statusFontColor"); - elem.style.color = "green"; - </script> </#macro> <@page_html/> \ No newline at end of file
