Search in sources :

Example 1 with SlowPeerReports

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

the class BPServiceActor method sendHeartBeat.

HeartbeatResponse sendHeartBeat(boolean requestBlockReportLease) throws IOException {
    scheduler.scheduleNextHeartbeat();
    StorageReport[] reports = dn.getFSDataset().getStorageReports(bpos.getBlockPoolId());
    if (LOG.isDebugEnabled()) {
        LOG.debug("Sending heartbeat with " + reports.length + " storage reports from service actor: " + this);
    }
    final long now = monotonicNow();
    scheduler.updateLastHeartbeatTime(now);
    VolumeFailureSummary volumeFailureSummary = dn.getFSDataset().getVolumeFailureSummary();
    int numFailedVolumes = volumeFailureSummary != null ? volumeFailureSummary.getFailedStorageLocations().length : 0;
    final boolean slowPeersReportDue = scheduler.isSlowPeersReportDue(now);
    final SlowPeerReports slowPeers = slowPeersReportDue && dn.getPeerMetrics() != null ? SlowPeerReports.create(dn.getPeerMetrics().getOutliers()) : SlowPeerReports.EMPTY_REPORT;
    HeartbeatResponse response = bpNamenode.sendHeartbeat(bpRegistration, reports, dn.getFSDataset().getCacheCapacity(), dn.getFSDataset().getCacheUsed(), dn.getXmitsInProgress(), dn.getXceiverCount(), numFailedVolumes, volumeFailureSummary, requestBlockReportLease, slowPeers);
    if (slowPeersReportDue) {
        // If the report was due and successfully sent, schedule the next one.
        scheduler.scheduleNextSlowPeerReport();
    }
    return response;
}
Also used : HeartbeatResponse(org.apache.hadoop.hdfs.server.protocol.HeartbeatResponse) StorageReport(org.apache.hadoop.hdfs.server.protocol.StorageReport) SlowPeerReports(org.apache.hadoop.hdfs.server.protocol.SlowPeerReports) VolumeFailureSummary(org.apache.hadoop.hdfs.server.protocol.VolumeFailureSummary)

Example 2 with SlowPeerReports

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

the class TestPBHelper method testSlowPeerInfoPBHelper.

@Test
public void testSlowPeerInfoPBHelper() {
    // Test with a map that has a few slow peer entries.
    final SlowPeerReports slowPeers = SlowPeerReports.create(ImmutableMap.of("peer1", 0.0, "peer2", 1.0, "peer3", 2.0));
    SlowPeerReports slowPeersConverted1 = PBHelper.convertSlowPeerInfo(PBHelper.convertSlowPeerInfo(slowPeers));
    assertTrue("Expected map:" + slowPeers + ", got map:" + slowPeersConverted1.getSlowPeers(), slowPeersConverted1.equals(slowPeers));
    // Test with an empty map.
    SlowPeerReports slowPeersConverted2 = PBHelper.convertSlowPeerInfo(PBHelper.convertSlowPeerInfo(SlowPeerReports.EMPTY_REPORT));
    assertTrue("Expected empty map:" + ", got map:" + slowPeersConverted2, slowPeersConverted2.equals(SlowPeerReports.EMPTY_REPORT));
}
Also used : SlowPeerReports(org.apache.hadoop.hdfs.server.protocol.SlowPeerReports) Test(org.junit.Test)

Aggregations

SlowPeerReports (org.apache.hadoop.hdfs.server.protocol.SlowPeerReports)2 HeartbeatResponse (org.apache.hadoop.hdfs.server.protocol.HeartbeatResponse)1 StorageReport (org.apache.hadoop.hdfs.server.protocol.StorageReport)1 VolumeFailureSummary (org.apache.hadoop.hdfs.server.protocol.VolumeFailureSummary)1 Test (org.junit.Test)1