Skip to content

Commit

Permalink
Merge pull request #2535 from atlanhq/scrub_optimisation
Browse files Browse the repository at this point in the history
add log lines
  • Loading branch information
ektavarma10 authored Nov 29, 2023
2 parents 1f12ac1 + 3f64c95 commit f533128
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,8 @@ public void filterTypesDef(AtlasTypesDefFilterRequest request) throws AtlasAutho

private void checkAccessAndScrubAsync(List<AtlasEntityHeader> entitiesToCheck, AtlasSearchResultScrubRequest request, boolean isScrubAuditEnabled) throws AtlasAuthorizationException {
LOG.info("Creating futures to check access and scrub " + entitiesToCheck.size() + " entities");
long startTime = System.currentTimeMillis();
LOG.info("Started checkAccessAndScrubAsync: " + System.currentTimeMillis());
List<CompletableFuture<AtlasAuthorizationException>> completableFutures = entitiesToCheck
.stream()
.map(entity -> CompletableFuture.supplyAsync(() -> {
Expand All @@ -654,18 +656,18 @@ private void checkAccessAndScrubAsync(List<AtlasEntityHeader> entitiesToCheck, A
}
}, entityAccessThreadpool))
.collect(Collectors.toList());

LOG.info("Completed async submission " + (System.currentTimeMillis()-startTime));
// wait for all threads to complete their execution
CompletableFuture.allOf(completableFutures.toArray(new CompletableFuture[0])).join();

LOG.info("Completed waiting for completion of threads: " + (System.currentTimeMillis()-startTime));
// get the first exception from any checkAccessAndScrub calls
Optional<AtlasAuthorizationException> maybeAuthException = completableFutures
.stream()
.map(CompletableFuture::join)
.filter(Objects::nonNull)
.findFirst();

LOG.info("Async check access and scrub is complete");
LOG.info("Async check access and scrub is complete: "+ (System.currentTimeMillis()-startTime));
if (maybeAuthException.isPresent()) {
throw maybeAuthException.get();
}
Expand Down

0 comments on commit f533128

Please sign in to comment.