use of io.cdap.cdap.common.utils.BatchingConsumer in project cdap by caskdata.
the class ApplicationLifecycleService method scanApplications.
/**
* Scans all applications in the specified namespace, filtered to only include application details
* which satisfy the filters
*
* @param request application scan request. Must name namespace filled
* @param consumer a {@link Consumer} to consume each ApplicationDetail being scanned
* @return if limit was reached (true) or all items were scanned before reaching the limit (false)
* @throws IllegalArgumentException if scan request does not have namespace specified
*/
public boolean scanApplications(ScanApplicationsRequest request, Consumer<ApplicationDetail> consumer) {
NamespaceId namespace = request.getNamespaceId();
if (namespace == null) {
throw new IllegalStateException("Application scan request without namespace");
}
accessEnforcer.enforceOnParent(EntityType.DATASET, namespace, authenticationContext.getPrincipal(), StandardPermission.LIST);
try (BatchingConsumer<Entry<ApplicationId, ApplicationSpecification>> batchingConsumer = new BatchingConsumer<>(list -> processApplications(list, consumer), batchSize)) {
return store.scanApplications(request, batchSize, (appId, appSpec) -> {
batchingConsumer.accept(new SimpleEntry<>(appId, appSpec));
});
}
}
Aggregations