Search in sources :

Example 1 with EntityResult

use of io.cdap.cdap.internal.entity.EntityResult in project cdap by caskdata.

the class CapabilityApplier method getApplications.

@VisibleForTesting
EntityResult<ApplicationId> getApplications(NamespaceId namespace, String capability, @Nullable String cursor, int offset, int limit) throws IOException, UnauthorizedException {
    String capabilityTag = String.format(CAPABILITY, capability);
    SearchRequest searchRequest = SearchRequest.of(capabilityTag).addNamespace(namespace.getNamespace()).addType(APPLICATION).setScope(MetadataScope.SYSTEM).setCursor(cursor).setOffset(offset).setLimit(limit).build();
    MetadataSearchResponse searchResponse = metadataSearchClient.search(searchRequest);
    Set<ApplicationId> applicationIds = searchResponse.getResults().stream().map(MetadataSearchResultRecord::getMetadataEntity).map(this::getApplicationId).collect(Collectors.toSet());
    return new EntityResult<>(applicationIds, getCursorResponse(searchResponse), searchResponse.getOffset(), searchResponse.getLimit(), searchResponse.getTotal());
}
Also used : SearchRequest(io.cdap.cdap.spi.metadata.SearchRequest) MetadataSearchResultRecord(io.cdap.cdap.proto.metadata.MetadataSearchResultRecord) MetadataSearchResponse(io.cdap.cdap.proto.metadata.MetadataSearchResponse) ApplicationId(io.cdap.cdap.proto.id.ApplicationId) EntityResult(io.cdap.cdap.internal.entity.EntityResult) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with EntityResult

use of io.cdap.cdap.internal.entity.EntityResult in project cdap by cdapio.

the class CapabilityApplier method getApplications.

@VisibleForTesting
EntityResult<ApplicationId> getApplications(NamespaceId namespace, String capability, @Nullable String cursor, int offset, int limit) throws IOException, UnauthorizedException {
    String capabilityTag = String.format(CAPABILITY, capability);
    SearchRequest searchRequest = SearchRequest.of(capabilityTag).addNamespace(namespace.getNamespace()).addType(APPLICATION).setScope(MetadataScope.SYSTEM).setCursor(cursor).setOffset(offset).setLimit(limit).build();
    MetadataSearchResponse searchResponse = metadataSearchClient.search(searchRequest);
    Set<ApplicationId> applicationIds = searchResponse.getResults().stream().map(MetadataSearchResultRecord::getMetadataEntity).map(this::getApplicationId).collect(Collectors.toSet());
    return new EntityResult<>(applicationIds, getCursorResponse(searchResponse), searchResponse.getOffset(), searchResponse.getLimit(), searchResponse.getTotal());
}
Also used : SearchRequest(io.cdap.cdap.spi.metadata.SearchRequest) MetadataSearchResultRecord(io.cdap.cdap.proto.metadata.MetadataSearchResultRecord) MetadataSearchResponse(io.cdap.cdap.proto.metadata.MetadataSearchResponse) ApplicationId(io.cdap.cdap.proto.id.ApplicationId) EntityResult(io.cdap.cdap.internal.entity.EntityResult) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 EntityResult (io.cdap.cdap.internal.entity.EntityResult)2 ApplicationId (io.cdap.cdap.proto.id.ApplicationId)2 MetadataSearchResponse (io.cdap.cdap.proto.metadata.MetadataSearchResponse)2 MetadataSearchResultRecord (io.cdap.cdap.proto.metadata.MetadataSearchResultRecord)2 SearchRequest (io.cdap.cdap.spi.metadata.SearchRequest)2