Search in sources :

Example 1 with DeleteScmKeyBlocksResponseProto

use of org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.DeleteScmKeyBlocksResponseProto in project ozone by apache.

the class ScmBlockLocationProtocolClientSideTranslatorPB method deleteKeyBlocks.

/**
 * Delete the set of keys specified.
 *
 * @param keyBlocksInfoList batch of block keys to delete.
 * @return list of block deletion results.
 * @throws IOException if there is any failure.
 */
@Override
public List<DeleteBlockGroupResult> deleteKeyBlocks(List<BlockGroup> keyBlocksInfoList) throws IOException {
    List<KeyBlocks> keyBlocksProto = keyBlocksInfoList.stream().map(BlockGroup::getProto).collect(Collectors.toList());
    DeleteScmKeyBlocksRequestProto request = DeleteScmKeyBlocksRequestProto.newBuilder().addAllKeyBlocks(keyBlocksProto).build();
    SCMBlockLocationRequest wrapper = createSCMBlockRequest(Type.DeleteScmKeyBlocks).setDeleteScmKeyBlocksRequest(request).build();
    final SCMBlockLocationResponse wrappedResponse = handleError(submitRequest(wrapper));
    final DeleteScmKeyBlocksResponseProto resp = wrappedResponse.getDeleteScmKeyBlocksResponse();
    List<DeleteBlockGroupResult> results = new ArrayList<>(resp.getResultsCount());
    results.addAll(resp.getResultsList().stream().map(result -> new DeleteBlockGroupResult(result.getObjectKey(), DeleteBlockGroupResult.convertBlockResultProto(result.getBlockResultsList()))).collect(Collectors.toList()));
    return results;
}
Also used : SCMBlockLocationRequest(org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.SCMBlockLocationRequest) DeleteScmKeyBlocksRequestProto(org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.DeleteScmKeyBlocksRequestProto) SCMBlockLocationResponse(org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.SCMBlockLocationResponse) DeleteBlockGroupResult(org.apache.hadoop.ozone.common.DeleteBlockGroupResult) ArrayList(java.util.ArrayList) DeleteScmKeyBlocksResponseProto(org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.DeleteScmKeyBlocksResponseProto) KeyBlocks(org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.KeyBlocks)

Example 2 with DeleteScmKeyBlocksResponseProto

use of org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.DeleteScmKeyBlocksResponseProto in project ozone by apache.

the class ScmBlockLocationProtocolServerSideTranslatorPB method deleteScmKeyBlocks.

public DeleteScmKeyBlocksResponseProto deleteScmKeyBlocks(DeleteScmKeyBlocksRequestProto req) throws IOException {
    DeleteScmKeyBlocksResponseProto.Builder resp = DeleteScmKeyBlocksResponseProto.newBuilder();
    List<BlockGroup> infoList = req.getKeyBlocksList().stream().map(BlockGroup::getFromProto).collect(Collectors.toList());
    final List<DeleteBlockGroupResult> results = impl.deleteKeyBlocks(infoList);
    for (DeleteBlockGroupResult result : results) {
        DeleteKeyBlocksResultProto.Builder deleteResult = DeleteKeyBlocksResultProto.newBuilder().setObjectKey(result.getObjectKey()).addAllBlockResults(result.getBlockResultProtoList());
        resp.addResults(deleteResult.build());
    }
    return resp.build();
}
Also used : DeleteBlockGroupResult(org.apache.hadoop.ozone.common.DeleteBlockGroupResult) DeleteScmKeyBlocksResponseProto(org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.DeleteScmKeyBlocksResponseProto) DeleteKeyBlocksResultProto(org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.DeleteKeyBlocksResultProto) BlockGroup(org.apache.hadoop.ozone.common.BlockGroup)

Aggregations

DeleteScmKeyBlocksResponseProto (org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.DeleteScmKeyBlocksResponseProto)2 DeleteBlockGroupResult (org.apache.hadoop.ozone.common.DeleteBlockGroupResult)2 ArrayList (java.util.ArrayList)1 DeleteKeyBlocksResultProto (org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.DeleteKeyBlocksResultProto)1 DeleteScmKeyBlocksRequestProto (org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.DeleteScmKeyBlocksRequestProto)1 KeyBlocks (org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.KeyBlocks)1 SCMBlockLocationRequest (org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.SCMBlockLocationRequest)1 SCMBlockLocationResponse (org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.SCMBlockLocationResponse)1 BlockGroup (org.apache.hadoop.ozone.common.BlockGroup)1