HDFS-12863. Ozone: Avoid configuration.get() call for each container report. Contributed by Akira Ajisaka.

This commit is contained in:
Anu Engineer 2017-12-20 11:18:37 -08:00 committed by Owen O'Malley
parent 0380dbb928
commit 79432ee6cf

View File

@ -33,10 +33,10 @@
* // TODO: support incremental/delta container report * // TODO: support incremental/delta container report
*/ */
public class ContainerReportManagerImpl implements ContainerReportManager { public class ContainerReportManagerImpl implements ContainerReportManager {
private Configuration config;
// Last non-empty container report time // Last non-empty container report time
private long lastContainerReportTime; private long lastContainerReportTime;
private final long containerReportInterval; private final long containerReportInterval;
private final long heartbeatInterval;
private AtomicLong reportCount; private AtomicLong reportCount;
private static final ReportState NO_CONTAINER_REPORTSTATE = private static final ReportState NO_CONTAINER_REPORTSTATE =
ReportState.newBuilder() ReportState.newBuilder()
@ -44,13 +44,13 @@ public class ContainerReportManagerImpl implements ContainerReportManager {
.setCount(0).build(); .setCount(0).build();
public ContainerReportManagerImpl(Configuration config) { public ContainerReportManagerImpl(Configuration config) {
this.config = config;
this.lastContainerReportTime = -1; this.lastContainerReportTime = -1;
this.reportCount = new AtomicLong(0L); this.reportCount = new AtomicLong(0L);
this.containerReportInterval = config.getTimeDuration( this.containerReportInterval = config.getTimeDuration(
OzoneConfigKeys.OZONE_CONTAINER_REPORT_INTERVAL, OzoneConfigKeys.OZONE_CONTAINER_REPORT_INTERVAL,
OzoneConfigKeys.OZONE_CONTAINER_REPORT_INTERVAL_DEFAULT, OzoneConfigKeys.OZONE_CONTAINER_REPORT_INTERVAL_DEFAULT,
TimeUnit.MILLISECONDS); TimeUnit.MILLISECONDS);
this.heartbeatInterval = OzoneClientUtils.getScmHeartbeatInterval(config);
} }
public ReportState getContainerReportState() { public ReportState getContainerReportState() {
@ -82,7 +82,6 @@ private ReportState getNoContainerReportState() {
} }
private long getRandomReportDelay() { private long getRandomReportDelay() {
return RandomUtils.nextLong(0, return RandomUtils.nextLong(0, heartbeatInterval);
OzoneClientUtils.getScmHeartbeatInterval(config));
} }
} }