Skip to content

Commit

Permalink
KYLO-3224 fix profiler cache. Fix IT tests
Browse files Browse the repository at this point in the history
  • Loading branch information
scottreisdorf committed Dec 14, 2018
1 parent b112695 commit 31fff73
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ protected String getProcessingDttm(String feedId) {
}

protected int getProfileSummary(String feedId, String profileType) {
return Integer.parseInt(getJsonPathOfProfileSummary(feedId, "find {entry ->entry.metrictype == '" + profileType + "'}.metricvalue"));
return Integer.parseInt(getJsonPathOfProfileSummary(feedId, "content.find {entry ->entry.metrictype == '" + profileType + "'}.metricvalue"));
}

protected String getJsonPathOfProfileSummary(String feedId, String path) {
Expand All @@ -619,7 +619,7 @@ protected String getProfileStatsForColumn(String feedId, String processingDttm,

response.then().statusCode(HTTP_OK);

String path = String.format("find {entry ->entry.metrictype == '%s' && entry.columnname == '%s'}.metricvalue", profileType, column);
String path = String.format("content.find {entry ->entry.metrictype == '%s' && entry.columnname == '%s'}.metricvalue", profileType, column);
return JsonPath.from(response.asString()).getString(path);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,20 +256,30 @@ public int update(@Nonnull final String query) {


public boolean isTableAccessibleByImpersonatedUser(String table) {
return isTableAccessibleByImpersonatedUser(table,true);
}

private boolean isTableAccessibleByImpersonatedUser(String table, boolean refreshCache) {
String currentUser = SecurityContextHolder.getContext().getAuthentication().getName();
String schemaName = table.substring(0, table.indexOf("."));
try {
UserHiveAccessCache cache = this.perUserAccessCache.get(currentUser);
List<String> tables = cache.getTables(schemaName);
return tables != null && tables.contains(table);
boolean hasAccess = tables != null && tables.contains(table);
if(!hasAccess && refreshCache && cache.getSchemas().contains(schemaName)){
//attempt to refresh it
refreshHiveAccessCacheForImpersonatedUser();
hasAccess = isTableAccessibleByImpersonatedUser(table,false);
}
return hasAccess;
} catch (ExecutionException e) {
throw new RuntimeException(String.format("Failed to determine if Hive table %s is accessible by user %s", table, currentUser));
}
}

public void refreshHiveAccessCacheForImpersonatedUser() {
String currentUser = SecurityContextHolder.getContext().getAuthentication().getName();
this.perUserAccessCache.refresh(currentUser);
this.perUserAccessCache.invalidate(currentUser);
}

public QueryResult getTablePartitions(String tableName) {
Expand Down

0 comments on commit 31fff73

Please sign in to comment.