Search in sources :

Example 6 with ReceivedDeletedBlockInfo

use of org.apache.hadoop.hdfs.server.protocol.ReceivedDeletedBlockInfo in project hadoop by apache.

the class TestIncrementalBlockReports method injectBlockDeleted.

/**
   * Inject a fake 'deleted' block into the BPServiceActor state.
   */
private void injectBlockDeleted() {
    ReceivedDeletedBlockInfo rdbi = new ReceivedDeletedBlockInfo(getDummyBlock(), BlockStatus.DELETED_BLOCK, null);
    actor.getIbrManager().addRDBI(rdbi, singletonDn.getFSDataset().getStorage(storageUuid));
}
Also used : ReceivedDeletedBlockInfo(org.apache.hadoop.hdfs.server.protocol.ReceivedDeletedBlockInfo)

Example 7 with ReceivedDeletedBlockInfo

use of org.apache.hadoop.hdfs.server.protocol.ReceivedDeletedBlockInfo in project hadoop by apache.

the class TestIncrementalBlockReports method injectBlockReceived.

/**
   * Inject a fake 'received' block into the BPServiceActor state.
   */
private void injectBlockReceived() {
    ReceivedDeletedBlockInfo rdbi = new ReceivedDeletedBlockInfo(getDummyBlock(), BlockStatus.RECEIVED_BLOCK, null);
    DatanodeStorage s = singletonDn.getFSDataset().getStorage(storageUuid);
    actor.getIbrManager().notifyNamenodeBlock(rdbi, s, false);
}
Also used : DatanodeStorage(org.apache.hadoop.hdfs.server.protocol.DatanodeStorage) ReceivedDeletedBlockInfo(org.apache.hadoop.hdfs.server.protocol.ReceivedDeletedBlockInfo)

Example 8 with ReceivedDeletedBlockInfo

use of org.apache.hadoop.hdfs.server.protocol.ReceivedDeletedBlockInfo in project hadoop by apache.

the class DatanodeProtocolClientSideTranslatorPB method blockReceivedAndDeleted.

@Override
public void blockReceivedAndDeleted(DatanodeRegistration registration, String poolId, StorageReceivedDeletedBlocks[] receivedAndDeletedBlocks) throws IOException {
    BlockReceivedAndDeletedRequestProto.Builder builder = BlockReceivedAndDeletedRequestProto.newBuilder().setRegistration(PBHelper.convert(registration)).setBlockPoolId(poolId);
    for (StorageReceivedDeletedBlocks storageBlock : receivedAndDeletedBlocks) {
        StorageReceivedDeletedBlocksProto.Builder repBuilder = StorageReceivedDeletedBlocksProto.newBuilder();
        // Set for wire compatibility.
        repBuilder.setStorageUuid(storageBlock.getStorage().getStorageID());
        repBuilder.setStorage(PBHelperClient.convert(storageBlock.getStorage()));
        for (ReceivedDeletedBlockInfo rdBlock : storageBlock.getBlocks()) {
            repBuilder.addBlocks(PBHelper.convert(rdBlock));
        }
        builder.addBlocks(repBuilder.build());
    }
    try {
        rpcProxy.blockReceivedAndDeleted(NULL_CONTROLLER, builder.build());
    } catch (ServiceException se) {
        throw ProtobufHelper.getRemoteException(se);
    }
}
Also used : BlockReceivedAndDeletedRequestProto(org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReceivedAndDeletedRequestProto) ServiceException(com.google.protobuf.ServiceException) StorageReceivedDeletedBlocksProto(org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.StorageReceivedDeletedBlocksProto) StorageReceivedDeletedBlocks(org.apache.hadoop.hdfs.server.protocol.StorageReceivedDeletedBlocks) ReceivedDeletedBlockInfo(org.apache.hadoop.hdfs.server.protocol.ReceivedDeletedBlockInfo)

Example 9 with ReceivedDeletedBlockInfo

use of org.apache.hadoop.hdfs.server.protocol.ReceivedDeletedBlockInfo in project hadoop by apache.

the class DatanodeProtocolServerSideTranslatorPB method blockReceivedAndDeleted.

@Override
public BlockReceivedAndDeletedResponseProto blockReceivedAndDeleted(RpcController controller, BlockReceivedAndDeletedRequestProto request) throws ServiceException {
    List<StorageReceivedDeletedBlocksProto> sBlocks = request.getBlocksList();
    StorageReceivedDeletedBlocks[] info = new StorageReceivedDeletedBlocks[sBlocks.size()];
    for (int i = 0; i < sBlocks.size(); i++) {
        StorageReceivedDeletedBlocksProto sBlock = sBlocks.get(i);
        List<ReceivedDeletedBlockInfoProto> list = sBlock.getBlocksList();
        ReceivedDeletedBlockInfo[] rdBlocks = new ReceivedDeletedBlockInfo[list.size()];
        for (int j = 0; j < list.size(); j++) {
            rdBlocks[j] = PBHelper.convert(list.get(j));
        }
        if (sBlock.hasStorage()) {
            info[i] = new StorageReceivedDeletedBlocks(PBHelperClient.convert(sBlock.getStorage()), rdBlocks);
        } else {
            info[i] = new StorageReceivedDeletedBlocks(new DatanodeStorage(sBlock.getStorageUuid()), rdBlocks);
        }
    }
    try {
        impl.blockReceivedAndDeleted(PBHelper.convert(request.getRegistration()), request.getBlockPoolId(), info);
    } catch (IOException e) {
        throw new ServiceException(e);
    }
    return VOID_BLOCK_RECEIVED_AND_DELETE_RESPONSE;
}
Also used : ReceivedDeletedBlockInfoProto(org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.ReceivedDeletedBlockInfoProto) ServiceException(com.google.protobuf.ServiceException) StorageReceivedDeletedBlocksProto(org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.StorageReceivedDeletedBlocksProto) DatanodeStorage(org.apache.hadoop.hdfs.server.protocol.DatanodeStorage) StorageReceivedDeletedBlocks(org.apache.hadoop.hdfs.server.protocol.StorageReceivedDeletedBlocks) IOException(java.io.IOException) ReceivedDeletedBlockInfo(org.apache.hadoop.hdfs.server.protocol.ReceivedDeletedBlockInfo)

Example 10 with ReceivedDeletedBlockInfo

use of org.apache.hadoop.hdfs.server.protocol.ReceivedDeletedBlockInfo in project hadoop by apache.

the class BlockManager method processIncrementalBlockReport.

private void processIncrementalBlockReport(final DatanodeDescriptor node, final StorageReceivedDeletedBlocks srdb) throws IOException {
    DatanodeStorageInfo storageInfo = node.getStorageInfo(srdb.getStorage().getStorageID());
    if (storageInfo == null) {
        // The DataNode is reporting an unknown storage. Usually the NN learns
        // about new storages from heartbeats but during NN restart we may
        // receive a block report or incremental report before the heartbeat.
        // We must handle this for protocol compatibility. This issue was
        // uncovered by HDFS-6094.
        storageInfo = node.updateStorage(srdb.getStorage());
    }
    int received = 0;
    int deleted = 0;
    int receiving = 0;
    for (ReceivedDeletedBlockInfo rdbi : srdb.getBlocks()) {
        switch(rdbi.getStatus()) {
            case DELETED_BLOCK:
                removeStoredBlock(storageInfo, rdbi.getBlock(), node);
                deleted++;
                break;
            case RECEIVED_BLOCK:
                addBlock(storageInfo, rdbi.getBlock(), rdbi.getDelHints());
                received++;
                break;
            case RECEIVING_BLOCK:
                receiving++;
                processAndHandleReportedBlock(storageInfo, rdbi.getBlock(), ReplicaState.RBW, null);
                break;
            default:
                String msg = "Unknown block status code reported by " + node + ": " + rdbi;
                blockLog.warn(msg);
                // if assertions are enabled, throw.
                assert false : msg;
                break;
        }
        blockLog.debug("BLOCK* block {}: {} is received from {}", rdbi.getStatus(), rdbi.getBlock(), node);
    }
    blockLog.debug("*BLOCK* NameNode.processIncrementalBlockReport: from " + "{} receiving: {}, received: {}, deleted: {}", node, receiving, received, deleted);
}
Also used : ReceivedDeletedBlockInfo(org.apache.hadoop.hdfs.server.protocol.ReceivedDeletedBlockInfo)

Aggregations

ReceivedDeletedBlockInfo (org.apache.hadoop.hdfs.server.protocol.ReceivedDeletedBlockInfo)11 DatanodeStorage (org.apache.hadoop.hdfs.server.protocol.DatanodeStorage)7 StorageReceivedDeletedBlocks (org.apache.hadoop.hdfs.server.protocol.StorageReceivedDeletedBlocks)7 DatanodeRegistration (org.apache.hadoop.hdfs.server.protocol.DatanodeRegistration)4 Configuration (org.apache.hadoop.conf.Configuration)3 HdfsConfiguration (org.apache.hadoop.hdfs.HdfsConfiguration)3 Block (org.apache.hadoop.hdfs.protocol.Block)3 Test (org.junit.Test)3 ServiceException (com.google.protobuf.ServiceException)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Path (org.apache.hadoop.fs.Path)2 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)2 LocatedBlock (org.apache.hadoop.hdfs.protocol.LocatedBlock)2 StorageReceivedDeletedBlocksProto (org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.StorageReceivedDeletedBlocksProto)2 DataNode (org.apache.hadoop.hdfs.server.datanode.DataNode)2 BlockReportContext (org.apache.hadoop.hdfs.server.protocol.BlockReportContext)2 Map (java.util.Map)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)1