Search in sources :

Example 1 with ListBucketsRequest

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;
}
Also used : OmBucketInfo(org.apache.hadoop.ozone.om.helpers.OmBucketInfo) OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) ListBucketsResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListBucketsResponse) ListBucketsRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListBucketsRequest) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 OmBucketInfo (org.apache.hadoop.ozone.om.helpers.OmBucketInfo)1 ListBucketsRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListBucketsRequest)1 ListBucketsResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListBucketsResponse)1 OMRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest)1