DRILL-5259: Allow listing a user-defined number of profiles Allow changing default number of finished queries in web UI, when starting up Drillbits. Option provided in drill-override.conf (default=100 ; defined in drill-module.conf) Alternatively, the page can be loaded dynamically for the same. e.g. https://<hostname>:8047/profiles?max=100
closes #751 Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/93bd7d0a Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/93bd7d0a Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/93bd7d0a Branch: refs/heads/master Commit: 93bd7d0a8465064ba75ffafd72d33995e4d5348c Parents: 6be287d Author: Kunal Khatua <kkha...@maprtech.com> Authored: Tue Feb 21 11:07:01 2017 -0800 Committer: Sudheesh Katkam <sudhe...@apache.org> Committed: Fri Feb 24 18:41:50 2017 -0800 ---------------------------------------------------------------------- .../org/apache/drill/exec/ExecConstants.java | 1 + .../server/rest/profile/ProfileResources.java | 24 +++++++++++++++----- .../src/main/resources/drill-module.conf | 3 ++- 3 files changed, 21 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/93bd7d0a/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java b/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java index d739f88..ce16c32 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java @@ -90,6 +90,7 @@ public interface ExecConstants { String TEXT_LINE_READER_BUFFER_SIZE = "drill.exec.storage.file.text.buffer.size"; String HAZELCAST_SUBNETS = "drill.exec.cache.hazel.subnets"; String HTTP_ENABLE = "drill.exec.http.enabled"; + String HTTP_MAX_PROFILES = "drill.exec.http.max_profiles"; String HTTP_PORT = "drill.exec.http.port"; String HTTP_ENABLE_SSL = "drill.exec.http.ssl_enabled"; String HTTP_CORS_ENABLED = "drill.exec.http.cors.enabled"; http://git-wip-us.apache.org/repos/asf/drill/blob/93bd7d0a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileResources.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileResources.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileResources.java index 9ab4f4a..e1f2099 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileResources.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileResources.java @@ -31,12 +31,15 @@ import javax.ws.rs.GET; 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.SecurityContext; +import javax.ws.rs.core.UriInfo; import javax.xml.bind.annotation.XmlRootElement; import org.apache.drill.common.exceptions.DrillRuntimeException; import org.apache.drill.common.exceptions.UserException; +import org.apache.drill.exec.ExecConstants; import org.apache.drill.exec.coord.ClusterCoordinator; import org.apache.drill.exec.coord.store.TransientStore; import org.apache.drill.exec.proto.GeneralRPCProtos.Ack; @@ -61,8 +64,6 @@ import com.google.common.collect.Lists; public class ProfileResources { static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ProfileResources.class); - public final static int MAX_PROFILES = 100; - @Inject UserAuthEnabled authEnabled; @Inject WorkManager work; @Inject DrillUserPrincipal principal; @@ -171,10 +172,13 @@ public class ProfileResources { public List<String> getErrors() { return errors; } } + //max Param to cap listing of profiles + private static final String MAX_QPROFILES_PARAM = "max"; + @GET @Path("/profiles.json") @Produces(MediaType.APPLICATION_JSON) - public QProfiles getProfilesJSON() { + public QProfiles getProfilesJSON(@Context UriInfo uriInfo) { try { final PersistentStore<QueryProfile> completed = getProvider().getOrCreateStore(QueryManager.QUERY_PROFILE); final TransientStore<QueryInfo> running = getCoordinator().getOrCreateTransientStore(QueryManager.RUNNING_QUERY_INFO); @@ -201,7 +205,15 @@ public class ProfileResources { final List<ProfileInfo> finishedQueries = Lists.newArrayList(); - final Iterator<Map.Entry<String, QueryProfile>> range = completed.getRange(0, MAX_PROFILES); + //Defining #Profiles to load + int maxProfilesToLoad = work.getContext().getConfig().getInt(ExecConstants.HTTP_MAX_PROFILES); + String maxProfilesParams = uriInfo.getQueryParameters().getFirst(MAX_QPROFILES_PARAM); + if (maxProfilesParams != null && !maxProfilesParams.isEmpty()) { + maxProfilesToLoad = Integer.valueOf(maxProfilesParams); + } + + final Iterator<Map.Entry<String, QueryProfile>> range = completed.getRange(0, maxProfilesToLoad); + while (range.hasNext()) { try { final Map.Entry<String, QueryProfile> profileEntry = range.next(); @@ -226,8 +238,8 @@ public class ProfileResources { @GET @Path("/profiles") @Produces(MediaType.TEXT_HTML) - public Viewable getProfiles() { - QProfiles profiles = getProfilesJSON(); + public Viewable getProfiles(@Context UriInfo uriInfo) { + QProfiles profiles = getProfilesJSON(uriInfo); return ViewableWithPermissions.create(authEnabled.get(), "/rest/profile/list.ftl", sc, profiles); } http://git-wip-us.apache.org/repos/asf/drill/blob/93bd7d0a/exec/java-exec/src/main/resources/drill-module.conf ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/resources/drill-module.conf b/exec/java-exec/src/main/resources/drill-module.conf index 1c702d7..0b45f52 100644 --- a/exec/java-exec/src/main/resources/drill-module.conf +++ b/exec/java-exec/src/main/resources/drill-module.conf @@ -115,7 +115,8 @@ drill.exec: { http: { enabled: true, ssl_enabled: false, - port: 8047 + port: 8047, + max_profiles: 100, session_max_idle_secs: 3600, # Default value 1hr cors: { enabled: false,