diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/CacheDirectiveInfo.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/CacheDirectiveInfo.java index 0661a40bbb304..1d505647265c2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/CacheDirectiveInfo.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/CacheDirectiveInfo.java @@ -27,6 +27,7 @@ import org.apache.hadoop.util.Preconditions; import org.apache.hadoop.hdfs.DFSUtilClient; +import org.apache.hadoop.util.Time; /** * Describes a path-based cache directive. @@ -237,7 +238,7 @@ public long getAbsoluteMillis() { if (!isRelative) { return ms; } else { - return new Date().getTime() + ms; + return Time.now() + ms; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/CacheDirective.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/CacheDirective.java index d03ad3d4d7ce6..7e4cc10db5110 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/CacheDirective.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/CacheDirective.java @@ -27,6 +27,7 @@ import org.apache.hadoop.util.IntrusiveCollection.Element; import org.apache.hadoop.util.Preconditions; +import org.apache.hadoop.util.Time; /** * Namenode class that tracks state related to a cached path. @@ -118,7 +119,7 @@ public CacheDirectiveStats toStats() { setBytesCached(bytesCached). setFilesNeeded(filesNeeded). setFilesCached(filesCached). - setHasExpired(new Date().getTime() > expiryTime). + setHasExpired(Time.now() > expiryTime). build(); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/CacheReplicationMonitor.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/CacheReplicationMonitor.java index 1e5f952040d53..5507f475099f3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/CacheReplicationMonitor.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/CacheReplicationMonitor.java @@ -23,7 +23,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collection; -import java.util.Date; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -321,7 +320,7 @@ private void resetStatistics() { */ private void rescanCacheDirectives() { FSDirectory fsDir = namesystem.getFSDirectory(); - final long now = new Date().getTime(); + final long now = Time.now(); for (CacheDirective directive : cacheManager.getCacheDirectives()) { scannedDirectives++; // Skip processing this entry if it has expired diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/CacheManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/CacheManager.java index 03dab29a54a5d..754775a9f8857 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/CacheManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/CacheManager.java @@ -34,7 +34,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Date; import java.util.EnumSet; import java.util.Iterator; import java.util.List; @@ -384,7 +383,7 @@ private static long validateExpiryTime(CacheDirectiveInfo info, long maxRelativeExpiryTime) throws InvalidRequestException { LOG.trace("Validating directive {} pool maxRelativeExpiryTime {}", info, maxRelativeExpiryTime); - final long now = new Date().getTime(); + final long now = Time.now(); final long maxAbsoluteExpiryTime = now + maxRelativeExpiryTime; if (info == null || info.getExpiration() == null) { return maxAbsoluteExpiryTime;