Search in sources :

Example 1 with ListTrashRequest

use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListTrashRequest in project ozone by apache.

the class OzoneManagerProtocolClientSideTranslatorPB method listTrash.

@Override
public List<RepeatedOmKeyInfo> listTrash(String volumeName, String bucketName, String startKeyName, String keyPrefix, int maxKeys) throws IOException {
    Preconditions.checkArgument(Strings.isNullOrEmpty(volumeName), "The volume name cannot be null or " + "empty.  Please enter a valid volume name or use '*' as a wild card");
    Preconditions.checkArgument(Strings.isNullOrEmpty(bucketName), "The bucket name cannot be null or " + "empty.  Please enter a valid bucket name or use '*' as a wild card");
    ListTrashRequest trashRequest = ListTrashRequest.newBuilder().setVolumeName(volumeName).setBucketName(bucketName).setStartKeyName(startKeyName).setKeyPrefix(keyPrefix).setMaxKeys(maxKeys).build();
    OMRequest omRequest = createOMRequest(Type.ListTrash).setListTrashRequest(trashRequest).build();
    ListTrashResponse trashResponse = handleError(submitRequest(omRequest)).getListTrashResponse();
    List<RepeatedOmKeyInfo> deletedKeyList = new ArrayList<>(trashResponse.getDeletedKeysCount());
    List<RepeatedOmKeyInfo> list = new ArrayList<>();
    for (OzoneManagerProtocolProtos.RepeatedKeyInfo repeatedKeyInfo : trashResponse.getDeletedKeysList()) {
        RepeatedOmKeyInfo fromProto = RepeatedOmKeyInfo.getFromProto(repeatedKeyInfo);
        list.add(fromProto);
    }
    deletedKeyList.addAll(list);
    return deletedKeyList;
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) ListTrashResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListTrashResponse) OzoneManagerProtocolProtos(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos) ListTrashRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListTrashRequest) ArrayList(java.util.ArrayList) RepeatedOmKeyInfo(org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo)

Aggregations

ArrayList (java.util.ArrayList)1 RepeatedOmKeyInfo (org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo)1 OzoneManagerProtocolProtos (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos)1 ListTrashRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListTrashRequest)1 ListTrashResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListTrashResponse)1 OMRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest)1