use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListBucketsRequest in project ozone by apache.
the class OzoneManagerProtocolClientSideTranslatorPB method listBuckets.
/**
* List buckets in a volume.
*
* @param volumeName
* @param startKey
* @param prefix
* @param count
* @return
* @throws IOException
*/
@Override
public List<OmBucketInfo> listBuckets(String volumeName, String startKey, String prefix, int count) throws IOException {
List<OmBucketInfo> buckets = new ArrayList<>();
ListBucketsRequest.Builder reqBuilder = ListBucketsRequest.newBuilder();
reqBuilder.setVolumeName(volumeName);
reqBuilder.setCount(count);
if (startKey != null) {
reqBuilder.setStartKey(startKey);
}
if (prefix != null) {
reqBuilder.setPrefix(prefix);
}
ListBucketsRequest request = reqBuilder.build();
OMRequest omRequest = createOMRequest(Type.ListBuckets).setListBucketsRequest(request).build();
ListBucketsResponse resp = handleError(submitRequest(omRequest)).getListBucketsResponse();
buckets.addAll(resp.getBucketInfoList().stream().map(OmBucketInfo::getFromProtobuf).collect(Collectors.toList()));
return buckets;
}
Aggregations