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;
}
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));
}
Aggregations