Repository: drill
Updated Branches:
refs/heads/master 9620e3482 -> 44d5cc8eb
DRILL-5745: Corrected 'location' information in Drill web server
closes #948
Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/61c48a9c
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/61c48a9c
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/61c48a9c
Branch: refs/heads/master
Commit: 61c48a9cf935c43de4cfca28fe11fbe6fdb1a36f
Parents: 9620e34
Author: Prasad Subramanya <prasadsubramanya@psubram-1010.local>
Authored: Tue Sep 19 18:32:49 2017 -0700
Committer: Paul Rogers <progers@maprtech.com>
Committed: Mon Sep 25 09:35:34 2017 -0700
----------------------------------------------------------------------
.../server/rest/profile/ProfileResources.java | 42 ++++++++++++++++----
1 file changed, 34 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/drill/blob/61c48a9c/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 468ec56..af47ee1 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
@@ -37,6 +37,7 @@ import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.core.UriInfo;
import javax.xml.bind.annotation.XmlRootElement;
+import org.apache.drill.common.config.DrillConfig;
import org.apache.drill.common.exceptions.DrillRuntimeException;
import org.apache.drill.common.exceptions.UserException;
import org.apache.drill.exec.ExecConstants;
@@ -55,7 +56,6 @@ import org.apache.drill.exec.store.sys.PersistentStore;
import org.apache.drill.exec.store.sys.PersistentStoreProvider;
import org.apache.drill.exec.work.WorkManager;
import org.apache.drill.exec.work.foreman.Foreman;
-import org.apache.drill.exec.work.foreman.QueryManager;
import org.glassfish.jersey.server.mvc.Viewable;
import com.google.common.collect.Lists;
@@ -77,19 +77,19 @@ public class ProfileResources {
private long startTime;
private long endTime;
private Date time;
- private String location;
+ private String link;
private String foreman;
private String query;
private String state;
private String user;
- public ProfileInfo(String queryId, long startTime, long endTime, String foreman, String
query, String state, String user) {
+ public ProfileInfo(DrillConfig drillConfig, String queryId, long startTime, long endTime,
String foreman, String query, String state, String user) {
this.queryId = queryId;
this.startTime = startTime;
this.endTime = endTime;
this.time = new Date(startTime);
this.foreman = foreman;
- this.location = "http://localhost:8047/profile/" + queryId + ".json";
+ this.link = generateLink(drillConfig, foreman, queryId);
this.query = query.substring(0, Math.min(query.length(), 150));
this.state = state;
this.user = user;
@@ -127,8 +127,8 @@ public class ProfileResources {
return state;
}
- public String getLocation() {
- return location;
+ public String getLink() {
+ return link;
}
@Override
@@ -140,6 +140,30 @@ public class ProfileResources {
return foreman;
}
+ /**
+ * Generates link which will return query profile in json representation.
+ *
+ * @param drillConfig drill configuration
+ * @param foreman foreman hostname
+ * @param queryId query id
+ * @return link
+ */
+ private String generateLink(DrillConfig drillConfig, String foreman, String queryId)
{
+ StringBuilder sb = new StringBuilder();
+ if (drillConfig.getBoolean(ExecConstants.HTTP_ENABLE_SSL)) {
+ sb.append("https://");
+ } else {
+ sb.append("http://");
+ }
+ sb.append(foreman);
+ sb.append(":");
+ sb.append(drillConfig.getInt(ExecConstants.HTTP_PORT));
+ sb.append("/profiles/");
+ sb.append(queryId);
+ sb.append(".json");
+ return sb.toString();
+ }
+
}
protected PersistentStoreProvider getProvider() {
@@ -195,7 +219,8 @@ public class ProfileResources {
final Map.Entry<String, QueryInfo> runningEntry = runningEntries.next();
final QueryInfo profile = runningEntry.getValue();
if (principal.canManageProfileOf(profile.getUser())) {
- runningQueries.add(new ProfileInfo(runningEntry.getKey(), profile.getStart(),
System.currentTimeMillis(), profile.getForeman().getAddress(), profile.getQuery(), profile.getState().name(),
profile.getUser()));
+ runningQueries.add(new ProfileInfo(work.getContext().getConfig(), runningEntry.getKey(),
profile.getStart(), System.currentTimeMillis(), profile.getForeman()
+ .getAddress(), profile.getQuery(), profile.getState().name(), profile.getUser()));
}
} catch (Exception e) {
errors.add(e.getMessage());
@@ -221,7 +246,8 @@ public class ProfileResources {
final Map.Entry<String, QueryProfile> profileEntry = range.next();
final QueryProfile profile = profileEntry.getValue();
if (principal.canManageProfileOf(profile.getUser())) {
- finishedQueries.add(new ProfileInfo(profileEntry.getKey(), profile.getStart(),
profile.getEnd(), profile.getForeman().getAddress(), profile.getQuery(), profile.getState().name(),
profile.getUser()));
+ finishedQueries.add(new ProfileInfo(work.getContext().getConfig(), profileEntry.getKey(),
profile.getStart(), profile.getEnd(), profile.getForeman().getAddress(),
+ profile.getQuery(), profile.getState().name(), profile.getUser()));
}
} catch (Exception e) {
errors.add(e.getMessage());
|