public static ReceivedDeletedBlockInfoProto convert( ReceivedDeletedBlockInfo receivedDeletedBlockInfo) { ReceivedDeletedBlockInfoProto.Builder builder = ReceivedDeletedBlockInfoProto.newBuilder(); ReceivedDeletedBlockInfoProto.BlockStatus status; switch (receivedDeletedBlockInfo.getStatus()) { case RECEIVING_BLOCK: status = ReceivedDeletedBlockInfoProto.BlockStatus.RECEIVING; break; case RECEIVED_BLOCK: status = ReceivedDeletedBlockInfoProto.BlockStatus.RECEIVED; break; case DELETED_BLOCK: status = ReceivedDeletedBlockInfoProto.BlockStatus.DELETED; break; default: throw new IllegalArgumentException("Bad status: " + receivedDeletedBlockInfo.getStatus()); } builder.setStatus(status); if (receivedDeletedBlockInfo.getDelHints() != null) { builder.setDeleteHint(receivedDeletedBlockInfo.getDelHints()); } return builder.setBlock( PBHelperClient.convert(receivedDeletedBlockInfo.getBlock())).build(); }
private void notifyNamenodeBlock(ExtendedBlock block, BlockStatus status, String delHint, String storageUuid, boolean isOnTransientStorage) { checkBlock(block); final ReceivedDeletedBlockInfo info = new ReceivedDeletedBlockInfo( block.getLocalBlock(), status, delHint); final DatanodeStorage storage = dn.getFSDataset().getStorage(storageUuid); for (BPServiceActor actor : bpServices) { actor.getIbrManager().notifyNamenodeBlock(info, storage, isOnTransientStorage); } }
/** Put the block to this IBR. */ void put(ReceivedDeletedBlockInfo rdbi) { blocks.put(rdbi.getBlock(), rdbi); increaseBlocksCounter(rdbi); }
synchronized void notifyNamenodeBlock(ReceivedDeletedBlockInfo rdbi, DatanodeStorage storage, boolean isOnTransientStorage) { addRDBI(rdbi, storage); final BlockStatus status = rdbi.getStatus(); if (status == BlockStatus.RECEIVING_BLOCK) { // the report will be sent out in the next heartbeat. readyToSend = true; } else if (status == BlockStatus.RECEIVED_BLOCK) { // the report is sent right away. triggerIBR(isOnTransientStorage); } }
@Override public boolean equals(Object o) { if (!(o instanceof ReceivedDeletedBlockInfo)) { return false; } ReceivedDeletedBlockInfo other = (ReceivedDeletedBlockInfo) o; return this.block.equals(other.getBlock()) && this.status == other.status && this.delHints != null && this.delHints.equals(other.delHints); }
private void increaseBlocksCounter( final ReceivedDeletedBlockInfo receivedDeletedBlockInfo) { switch (receivedDeletedBlockInfo.getStatus()) { case RECEIVING_BLOCK: dnMetrics.incrBlocksReceivingInPendingIBR(); break; case RECEIVED_BLOCK: dnMetrics.incrBlocksReceivedInPendingIBR(); break; case DELETED_BLOCK: dnMetrics.incrBlocksDeletedInPendingIBR(); break; default: break; } dnMetrics.incrBlocksInPendingIBR(); }
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; rdbi.getStatus(), rdbi.getBlock(), node);
/** * Put the all blocks to this IBR unless the block already exists. * @param rdbis list of blocks to add. * @return the number of missing blocks added. */ int putMissing(ReceivedDeletedBlockInfo[] rdbis) { int count = 0; for (ReceivedDeletedBlockInfo rdbi : rdbis) { if (!blocks.containsKey(rdbi.getBlock())) { put(rdbi); count++; } } return count; } }
public static ReceivedDeletedBlockInfo convert( ReceivedDeletedBlockInfoProto proto) { ReceivedDeletedBlockInfo.BlockStatus status = null; switch (proto.getStatus()) { case RECEIVING: status = BlockStatus.RECEIVING_BLOCK; break; case RECEIVED: status = BlockStatus.RECEIVED_BLOCK; break; case DELETED: status = BlockStatus.DELETED_BLOCK; break; } return new ReceivedDeletedBlockInfo( PBHelperClient.convert(proto.getBlock()), status, proto.hasDeleteHint() ? proto.getDeleteHint() : null); }
synchronized void notifyNamenodeBlock(ReceivedDeletedBlockInfo rdbi, DatanodeStorage storage, boolean isOnTransientStorage) { addRDBI(rdbi, storage); final BlockStatus status = rdbi.getStatus(); if (status == BlockStatus.RECEIVING_BLOCK) { // the report will be sent out in the next heartbeat. readyToSend = true; } else if (status == BlockStatus.RECEIVED_BLOCK) { // the report is sent right away. triggerIBR(isOnTransientStorage); } }
public static ReceivedDeletedBlockInfoProto convert( ReceivedDeletedBlockInfo receivedDeletedBlockInfo) { ReceivedDeletedBlockInfoProto.Builder builder = ReceivedDeletedBlockInfoProto.newBuilder(); ReceivedDeletedBlockInfoProto.BlockStatus status; switch (receivedDeletedBlockInfo.getStatus()) { case RECEIVING_BLOCK: status = ReceivedDeletedBlockInfoProto.BlockStatus.RECEIVING; break; case RECEIVED_BLOCK: status = ReceivedDeletedBlockInfoProto.BlockStatus.RECEIVED; break; case DELETED_BLOCK: status = ReceivedDeletedBlockInfoProto.BlockStatus.DELETED; break; default: throw new IllegalArgumentException("Bad status: " + receivedDeletedBlockInfo.getStatus()); } builder.setStatus(status); if (receivedDeletedBlockInfo.getDelHints() != null) { builder.setDeleteHint(receivedDeletedBlockInfo.getDelHints()); } return builder.setBlock(PBHelper.convert(receivedDeletedBlockInfo.getBlock())) .build(); }
/** * Add a block for notification to NameNode. * If another entry exists for the same block it is removed. */ @VisibleForTesting synchronized void addRDBI(ReceivedDeletedBlockInfo rdbi, DatanodeStorage storage) { // Make sure another entry for the same block is first removed. // There may only be one such entry. for (PerStorageIBR perStorage : pendingIBRs.values()) { if (perStorage.remove(rdbi.getBlock()) != null) { break; } } getPerStorageIBR(storage).put(rdbi); }
public static StorageReceivedDeletedBlocks[] makeReportForReceivedBlock( Block block, BlockStatus blockStatus, DatanodeStorage storage) { ReceivedDeletedBlockInfo[] receivedBlocks = new ReceivedDeletedBlockInfo[1]; receivedBlocks[0] = new ReceivedDeletedBlockInfo(block, blockStatus, null); StorageReceivedDeletedBlocks[] reports = new StorageReceivedDeletedBlocks[1]; reports[0] = new StorageReceivedDeletedBlocks(storage, receivedBlocks); return reports; }
synchronized void notifyNamenodeBlock(ReceivedDeletedBlockInfo rdbi, DatanodeStorage storage, boolean isOnTransientStorage) { addRDBI(rdbi, storage); final BlockStatus status = rdbi.getStatus(); if (status == BlockStatus.RECEIVING_BLOCK) { // the report will be sent out in the next heartbeat. readyToSend = true; } else if (status == BlockStatus.RECEIVED_BLOCK) { // the report is sent right away. triggerIBR(isOnTransientStorage); } }
public static ReceivedDeletedBlockInfoProto convert( ReceivedDeletedBlockInfo receivedDeletedBlockInfo) { ReceivedDeletedBlockInfoProto.Builder builder = ReceivedDeletedBlockInfoProto.newBuilder(); ReceivedDeletedBlockInfoProto.BlockStatus status; switch (receivedDeletedBlockInfo.getStatus()) { case RECEIVING_BLOCK: status = ReceivedDeletedBlockInfoProto.BlockStatus.RECEIVING; break; case RECEIVED_BLOCK: status = ReceivedDeletedBlockInfoProto.BlockStatus.RECEIVED; break; case DELETED_BLOCK: status = ReceivedDeletedBlockInfoProto.BlockStatus.DELETED; break; default: throw new IllegalArgumentException("Bad status: " + receivedDeletedBlockInfo.getStatus()); } builder.setStatus(status); if (receivedDeletedBlockInfo.getDelHints() != null) { builder.setDeleteHint(receivedDeletedBlockInfo.getDelHints()); } return builder.setBlock(PBHelper.convert(receivedDeletedBlockInfo.getBlock())) .build(); }
/** Put the block to this IBR. */ void put(ReceivedDeletedBlockInfo rdbi) { blocks.put(rdbi.getBlock(), rdbi); }
private static StorageReceivedDeletedBlocks[] makeReportForReceivedBlock( Block block, DatanodeStorage storage) { ReceivedDeletedBlockInfo[] receivedBlocks = new ReceivedDeletedBlockInfo[1]; receivedBlocks[0] = new ReceivedDeletedBlockInfo(block, BlockStatus.RECEIVED_BLOCK, null); StorageReceivedDeletedBlocks[] reports = new StorageReceivedDeletedBlocks[1]; reports[0] = new StorageReceivedDeletedBlocks(storage, receivedBlocks); return reports; }
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; rdbi.getStatus(), rdbi.getBlock(), node);
/** Put the block to this IBR. */ void put(ReceivedDeletedBlockInfo rdbi) { blocks.put(rdbi.getBlock(), rdbi); }
private void notifyNamenodeBlock(ExtendedBlock block, BlockStatus status, String delHint, String storageUuid, boolean isOnTransientStorage) { checkBlock(block); final ReceivedDeletedBlockInfo info = new ReceivedDeletedBlockInfo( block.getLocalBlock(), status, delHint); final DatanodeStorage storage = dn.getFSDataset().getStorage(storageUuid); for (BPServiceActor actor : bpServices) { actor.getIbrManager().notifyNamenodeBlock(info, storage, isOnTransientStorage); } }