Search in sources :

Example 1 with DeleteBlockGroupResult

use of org.apache.hadoop.ozone.common.DeleteBlockGroupResult 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 DeleteBlockGroupResult

use of org.apache.hadoop.ozone.common.DeleteBlockGroupResult in project ozone by apache.

the class SCMBlockProtocolServer method deleteKeyBlocks.

/**
 * Delete blocks for a set of object keys.
 *
 * @param keyBlocksInfoList list of block keys with object keys to delete.
 * @return deletion results.
 */
@Override
public List<DeleteBlockGroupResult> deleteKeyBlocks(List<BlockGroup> keyBlocksInfoList) throws IOException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("SCM is informed by OM to delete {} blocks", keyBlocksInfoList.size());
    }
    List<DeleteBlockGroupResult> results = new ArrayList<>();
    Map<String, String> auditMap = Maps.newHashMap();
    ScmBlockLocationProtocolProtos.DeleteScmBlockResult.Result resultCode;
    Exception e = null;
    try {
        scm.getScmBlockManager().deleteBlocks(keyBlocksInfoList);
        resultCode = ScmBlockLocationProtocolProtos.DeleteScmBlockResult.Result.success;
    } catch (IOException ioe) {
        e = ioe;
        LOG.warn("Fail to delete {} keys", keyBlocksInfoList.size(), ioe);
        switch(ioe instanceof SCMException ? ((SCMException) ioe).getResult() : IO_EXCEPTION) {
            case SAFE_MODE_EXCEPTION:
                resultCode = ScmBlockLocationProtocolProtos.DeleteScmBlockResult.Result.safeMode;
                break;
            case FAILED_TO_FIND_BLOCK:
                resultCode = ScmBlockLocationProtocolProtos.DeleteScmBlockResult.Result.errorNotFound;
                break;
            default:
                resultCode = ScmBlockLocationProtocolProtos.DeleteScmBlockResult.Result.unknownFailure;
        }
    }
    for (BlockGroup bg : keyBlocksInfoList) {
        auditMap.put("KeyBlockToDelete", bg.toString());
        List<DeleteBlockResult> blockResult = new ArrayList<>();
        for (BlockID b : bg.getBlockIDList()) {
            blockResult.add(new DeleteBlockResult(b, resultCode));
        }
        results.add(new DeleteBlockGroupResult(bg.getGroupID(), blockResult));
    }
    if (e == null) {
        AUDIT.logWriteSuccess(buildAuditMessageForSuccess(SCMAction.DELETE_KEY_BLOCK, auditMap));
    } else {
        AUDIT.logWriteFailure(buildAuditMessageForFailure(SCMAction.DELETE_KEY_BLOCK, auditMap, e));
    }
    return results;
}
Also used : ArrayList(java.util.ArrayList) IOException(java.io.IOException) IOException(java.io.IOException) SCMException(org.apache.hadoop.hdds.scm.exceptions.SCMException) DeleteBlockResult(org.apache.hadoop.hdds.scm.container.common.helpers.DeleteBlockResult) DeleteBlockGroupResult(org.apache.hadoop.ozone.common.DeleteBlockGroupResult) BlockID(org.apache.hadoop.hdds.client.BlockID) SCMException(org.apache.hadoop.hdds.scm.exceptions.SCMException) BlockGroup(org.apache.hadoop.ozone.common.BlockGroup)

Example 3 with DeleteBlockGroupResult

use of org.apache.hadoop.ozone.common.DeleteBlockGroupResult 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)

Example 4 with DeleteBlockGroupResult

use of org.apache.hadoop.ozone.common.DeleteBlockGroupResult in project ozone by apache.

the class ScmBlockLocationTestingClient method deleteKeyBlocks.

@Override
public List<DeleteBlockGroupResult> deleteKeyBlocks(List<BlockGroup> keyBlocksInfoList) throws IOException {
    List<DeleteBlockGroupResult> results = new ArrayList<>();
    List<DeleteBlockResult> blockResultList = new ArrayList<>();
    Result result;
    for (BlockGroup keyBlocks : keyBlocksInfoList) {
        for (BlockID blockKey : keyBlocks.getBlockIDList()) {
            currentCall++;
            switch(this.failCallsFrequency) {
                case 0:
                    result = success;
                    break;
                case 1:
                    result = unknownFailure;
                    break;
                default:
                    if (currentCall % this.failCallsFrequency == 0) {
                        result = unknownFailure;
                    } else {
                        result = success;
                    }
            }
            blockResultList.add(new DeleteBlockResult(blockKey, result));
        }
        results.add(new DeleteBlockGroupResult(keyBlocks.getGroupID(), blockResultList));
    }
    return results;
}
Also used : DeleteBlockGroupResult(org.apache.hadoop.ozone.common.DeleteBlockGroupResult) ArrayList(java.util.ArrayList) BlockID(org.apache.hadoop.hdds.client.BlockID) ContainerBlockID(org.apache.hadoop.hdds.client.ContainerBlockID) DeleteBlockResult(org.apache.hadoop.hdds.scm.container.common.helpers.DeleteBlockResult) DeleteBlockResult(org.apache.hadoop.hdds.scm.container.common.helpers.DeleteBlockResult) DeleteBlockGroupResult(org.apache.hadoop.ozone.common.DeleteBlockGroupResult) Result(org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.DeleteScmBlockResult.Result) BlockGroup(org.apache.hadoop.ozone.common.BlockGroup)

Aggregations

DeleteBlockGroupResult (org.apache.hadoop.ozone.common.DeleteBlockGroupResult)4 ArrayList (java.util.ArrayList)3 BlockGroup (org.apache.hadoop.ozone.common.BlockGroup)3 BlockID (org.apache.hadoop.hdds.client.BlockID)2 DeleteScmKeyBlocksResponseProto (org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.DeleteScmKeyBlocksResponseProto)2 DeleteBlockResult (org.apache.hadoop.hdds.scm.container.common.helpers.DeleteBlockResult)2 IOException (java.io.IOException)1 ContainerBlockID (org.apache.hadoop.hdds.client.ContainerBlockID)1 DeleteKeyBlocksResultProto (org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.DeleteKeyBlocksResultProto)1 Result (org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.DeleteScmBlockResult.Result)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 SCMException (org.apache.hadoop.hdds.scm.exceptions.SCMException)1