Skip to content

Commit

Permalink
[#142] Tokens endpoint should provide usernames who never had a token…
Browse files Browse the repository at this point in the history
… issued
  • Loading branch information
pjeli authored Oct 23, 2018
1 parent f3d7888 commit c6baf98
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/REST_Endpoints/Token.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
`/token` is a GET only call that only CACHE users can access.

Response code is 200 and a JSON dump of mapping users to the last known timestamp when a delegation token was issued to them.
A date of `N/A` means this user has never been issued a delegation token since NNA has been observing.

Response code of 403 means you are not authorized to view this endpoint.
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@ public void reloadSuggestions(NameNodeLoader nameNodeLoader) {
final long s2 = System.currentTimeMillis();

cachedLogins.putAll(nameNodeLoader.getTokenExtractor().getTokenLastLogins());
users.forEach(u -> cachedLogins.putIfAbsent(u, -1L));
cachedLogins.keySet().removeIf(u -> !fileUsers.contains(u) && !dirUsers.contains(u));

cachedUsers.clear();
cachedUsers.addAll(users);
cachedValues.put("timeTaken", timeTaken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public Map<String, Long> getTokenLastLogins() {
return new HashMap<String, Long>() {
{
put("hdfs", System.currentTimeMillis());
put("n/a", -1L);
}
};
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/public/tokens.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ <h1>Welcome to NNAnalytics</h1>
<script type="text/javascript">getClusterName();</script>

<script>
var limit = getUrlParameter("limit");
if(limit == null || limit.length == 0) {
limit = 2000;
}
$.ajax({
type: 'GET',
url: "./token",
Expand All @@ -89,8 +85,12 @@ <h1>Welcome to NNAnalytics</h1>
console.log("success");
var tokenMap = new Object();
for (var user in users) {
var date = new Date(users[user]).toISOString().slice(0, 10);
tokenMap[user] = date;
if(users[user] > 0) {
var date = new Date(users[user]).toISOString().slice(0, 10);
tokenMap[user] = date;
} else {
tokenMap[user] = "N/A";
}
}

$("#loaderDiv").hide();
Expand Down

0 comments on commit c6baf98

Please sign in to comment.