From 8fe4062bfc20ee181106eb68635d3404c50c9238 Mon Sep 17 00:00:00 2001 From: Xiaoyu Yao Date: Mon, 10 Sep 2018 08:45:49 -0700 Subject: [PATCH] HDDS-403. Fix createdOn and modifiedOn timestamp for volume, bucket, key. Contributed by Dinesh Chitlangia. --- .../org/apache/hadoop/hdds/scm/client/HddsClientUtils.java | 4 ++-- .../main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/client/HddsClientUtils.java b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/client/HddsClientUtils.java index a6813ebf60..9c590385a4 100644 --- a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/client/HddsClientUtils.java +++ b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/client/HddsClientUtils.java @@ -74,7 +74,7 @@ private HddsClientUtils() { */ public static String formatDateTime(long millis) { ZonedDateTime dateTime = ZonedDateTime.ofInstant( - Instant.ofEpochSecond(millis), DATE_FORMAT.get().getZone()); + Instant.ofEpochMilli(millis), DATE_FORMAT.get().getZone()); return DATE_FORMAT.get().format(dateTime); } @@ -85,7 +85,7 @@ public static String formatDateTime(long millis) { public static long formatDateTime(String date) throws ParseException { Preconditions.checkNotNull(date, "Date string should not be null."); return ZonedDateTime.parse(date, DATE_FORMAT.get()) - .toInstant().getEpochSecond(); + .toInstant().toEpochMilli(); } diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java index d21e5c588b..5cf869eee2 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java @@ -250,8 +250,8 @@ public OpenKeySession openKey(OmKeyArgs args) throws IOException { .setKeyName(args.getKeyName()) .setOmKeyLocationInfos(Collections.singletonList( new OmKeyLocationInfoGroup(0, locations))) - .setCreationTime(currentTime) - .setModificationTime(currentTime) + .setCreationTime(Time.now()) + .setModificationTime(Time.now()) .setDataSize(size) .setReplicationType(type) .setReplicationFactor(factor)