DRILL-5887: Display process user/groups info in Drill UI closes #998
Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/5a215144 Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/5a215144 Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/5a215144 Branch: refs/heads/master Commit: 5a215144d2542c81c3053df9effe5cdd2ed118e5 Parents: a26fbec Author: Prasad Nagaraj Subramanya <prasadn...@gmail.com> Authored: Wed Oct 25 17:03:26 2017 -0700 Committer: Paul Rogers <prog...@maprtech.com> Committed: Mon Oct 30 11:43:19 2017 -0700 ---------------------------------------------------------------------- .../drill/exec/server/rest/DrillRoot.java | 35 ++++++++++---------- .../java-exec/src/main/resources/rest/index.ftl | 22 ++++++++++-- 2 files changed, 37 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/5a215144/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 fc3395c..55bfca4 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 @@ -38,6 +38,7 @@ import org.apache.drill.exec.server.DrillbitContext; import org.apache.drill.exec.server.rest.DrillRestServer.UserAuthEnabled; import org.apache.drill.exec.server.rest.auth.AuthDynamicFeature; import org.apache.drill.exec.server.rest.auth.DrillUserPrincipal; +import org.apache.drill.exec.util.ImpersonationUtil; import org.apache.drill.exec.work.WorkManager; import org.apache.drill.exec.work.foreman.rm.DistributedQueryQueue; import org.apache.drill.exec.work.foreman.rm.DistributedQueryQueue.ZKQueueInfo; @@ -85,22 +86,10 @@ public class DrillRoot { // For all other cases the user info need-not or should-not be displayed OptionManager optionManager = work.getContext().getOptionManager(); final boolean isUserLoggedIn = AuthDynamicFeature.isUserLoggedIn(sc); - String adminUsers = isUserLoggedIn ? - ExecConstants.ADMIN_USERS_VALIDATOR.getAdminUsers(optionManager) : null; - String adminUserGroups = isUserLoggedIn ? - ExecConstants.ADMIN_USER_GROUPS_VALIDATOR.getAdminUserGroups(optionManager) : null; - - // separate groups by comma + space - if (adminUsers != null) { - String[] groups = adminUsers.split(","); - adminUsers = Joiner.on(", ").join(groups); - } - - // separate groups by comma + space - if (adminUserGroups != null) { - String[] groups = adminUserGroups.split(","); - adminUserGroups = Joiner.on(", ").join(groups); - } + final String processUser = ImpersonationUtil.getProcessUserName(); + final String processUserGroups = Joiner.on(", ").join(ImpersonationUtil.getProcessUserGroupNames()); + String adminUsers = ExecConstants.ADMIN_USERS_VALIDATOR.getAdminUsers(optionManager); + String adminUserGroups = ExecConstants.ADMIN_USER_GROUPS_VALIDATOR.getAdminUserGroups(optionManager); final boolean shouldShowUserInfo = isUserLoggedIn && ((DrillUserPrincipal)sc.getUserPrincipal()).isAdminUser(); @@ -118,8 +107,8 @@ public class DrillRoot { " userLoggedIn " + isUserLoggedIn + " shouldShowUserInfo: " + shouldShowUserInfo ); return new ClusterInfo(drillbits, currentVersion, mismatchedVersions, - userEncryptionEnabled, bitEncryptionEnabled, adminUsers, adminUserGroups, shouldShowUserInfo, - QueueInfo.build(dbContext.getResourceManager())); + userEncryptionEnabled, bitEncryptionEnabled, processUser, processUserGroups, adminUsers, + adminUserGroups, shouldShowUserInfo, QueueInfo.build(dbContext.getResourceManager())); } /** @@ -212,6 +201,8 @@ public class DrillRoot { private final boolean bitEncryptionEnabled; private final String adminUsers; private final String adminUserGroups; + private final String processUser; + private final String processUserGroups; private final boolean shouldShowUserInfo; private final QueueInfo queueInfo; @@ -221,6 +212,8 @@ public class DrillRoot { Collection<String> mismatchedVersions, boolean userEncryption, boolean bitEncryption, + String processUser, + String processUserGroups, String adminUsers, String adminUserGroups, boolean shouldShowUserInfo, @@ -230,6 +223,8 @@ public class DrillRoot { this.mismatchedVersions = Sets.newTreeSet(mismatchedVersions); this.userEncryptionEnabled = userEncryption; this.bitEncryptionEnabled = bitEncryption; + this.processUser = processUser; + this.processUserGroups = processUserGroups; this.adminUsers = adminUsers; this.adminUserGroups = adminUserGroups; this.shouldShowUserInfo = shouldShowUserInfo; @@ -252,6 +247,10 @@ public class DrillRoot { public boolean isBitEncryptionEnabled() { return bitEncryptionEnabled; } + public String getProcessUser() { return processUser; } + + public String getProcessUserGroups() { return processUserGroups; } + public String getAdminUsers() { return adminUsers; } public String getAdminUserGroups() { return adminUserGroups; } http://git-wip-us.apache.org/repos/asf/drill/blob/5a215144/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 38ce6ba..45dc1c9 100644 --- a/exec/java-exec/src/main/resources/rest/index.ftl +++ b/exec/java-exec/src/main/resources/rest/index.ftl @@ -10,6 +10,16 @@ language governing permissions and limitations under the License. --> <#include "*/generic.ftl"> + +<#-- Format comma-delimited string--> +<#macro format_string str> + <#if str?has_content> + ${(str?split(","))?join(", ")} + <#else> + ${"<empty>"} + </#if> +</#macro> + <#macro page_head> <style> .list-value { @@ -106,11 +116,19 @@ <tbody> <tr> <td>Admin Users</td> - <td class="list-value">${model.getAdminUsers()}</td> + <td class="list-value"><@format_string str=model.getAdminUsers()/></td> </tr> <tr> <td>Admin User Groups</td> - <td class="list-value">${model.getAdminUserGroups()}</td> + <td class="list-value"><@format_string str=model.getAdminUserGroups()/></td> + </tr> + <tr> + <td>Process User</td> + <td class="list-value">${model.getProcessUser()}</td> + </tr> + <tr> + <td>Process User Groups</td> + <td class="list-value">${model.getProcessUserGroups()}</td> </tr> </tbody> </table>