Search in sources :

Example 1 with ReportedBlockInfo

use of org.apache.hadoop.hdfs.server.blockmanagement.PendingDataNodeMessages.ReportedBlockInfo in project hadoop by apache.

the class BlockManager method processQueuedMessages.

private void processQueuedMessages(Iterable<ReportedBlockInfo> rbis) throws IOException {
    for (ReportedBlockInfo rbi : rbis) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Processing previouly queued message " + rbi);
        }
        if (rbi.getReportedState() == null) {
            // This is a DELETE_BLOCK request
            DatanodeStorageInfo storageInfo = rbi.getStorageInfo();
            removeStoredBlock(getStoredBlock(rbi.getBlock()), storageInfo.getDatanodeDescriptor());
        } else {
            processAndHandleReportedBlock(rbi.getStorageInfo(), rbi.getBlock(), rbi.getReportedState(), null);
        }
    }
}
Also used : ReportedBlockInfo(org.apache.hadoop.hdfs.server.blockmanagement.PendingDataNodeMessages.ReportedBlockInfo)

Example 2 with ReportedBlockInfo

use of org.apache.hadoop.hdfs.server.blockmanagement.PendingDataNodeMessages.ReportedBlockInfo in project hadoop by apache.

the class TestPendingDataNodeMessages method testQueues.

@Test
public void testQueues() {
    DatanodeDescriptor fakeDN = DFSTestUtil.getLocalDatanodeDescriptor();
    DatanodeStorage storage = new DatanodeStorage("STORAGE_ID");
    DatanodeStorageInfo storageInfo = new DatanodeStorageInfo(fakeDN, storage);
    msgs.enqueueReportedBlock(storageInfo, block1Gs1, ReplicaState.FINALIZED);
    msgs.enqueueReportedBlock(storageInfo, block1Gs2, ReplicaState.FINALIZED);
    assertEquals(2, msgs.count());
    // Nothing queued yet for block 2
    assertNull(msgs.takeBlockQueue(block2Gs1));
    assertEquals(2, msgs.count());
    Queue<ReportedBlockInfo> q = msgs.takeBlockQueue(block1Gs2DifferentInstance);
    assertEquals("ReportedBlockInfo [block=blk_1_1, dn=127.0.0.1:9866, reportedState=FINALIZED]," + "ReportedBlockInfo [block=blk_1_2, dn=127.0.0.1:9866, reportedState=FINALIZED]", Joiner.on(",").join(q));
    assertEquals(0, msgs.count());
    // Should be null if we pull again
    assertNull(msgs.takeBlockQueue(block1Gs1));
    assertEquals(0, msgs.count());
}
Also used : ReportedBlockInfo(org.apache.hadoop.hdfs.server.blockmanagement.PendingDataNodeMessages.ReportedBlockInfo) DatanodeStorage(org.apache.hadoop.hdfs.server.protocol.DatanodeStorage) Test(org.junit.Test)

Aggregations

ReportedBlockInfo (org.apache.hadoop.hdfs.server.blockmanagement.PendingDataNodeMessages.ReportedBlockInfo)2 DatanodeStorage (org.apache.hadoop.hdfs.server.protocol.DatanodeStorage)1 Test (org.junit.Test)1