hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stak...@apache.org
Subject hive git commit: HIVE-17953: Metrics should move to destination atomically (Alexander Kolbasov, reviewed by Sahil Takiar, Barna Zsombor Klara)
Date Mon, 06 Nov 2017 20:51:00 GMT
Repository: hive
Updated Branches:
  refs/heads/master ddce801f2 -> d7d96658c


HIVE-17953: Metrics should move to destination atomically (Alexander Kolbasov, reviewed by
Sahil Takiar, Barna Zsombor Klara)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/d7d96658
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/d7d96658
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/d7d96658

Branch: refs/heads/master
Commit: d7d96658c233b100754884985860bf40f97264ee
Parents: ddce801
Author: Alexander Kolbasov <akolb@cloudera.com>
Authored: Mon Nov 6 12:49:47 2017 -0800
Committer: Sahil Takiar <stakiar@cloudera.com>
Committed: Mon Nov 6 12:50:46 2017 -0800

----------------------------------------------------------------------
 .../hive/common/metrics/metrics2/JsonFileMetricsReporter.java   | 4 ++--
 .../org/apache/hadoop/hive/metastore/metrics/JsonReporter.java  | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/d7d96658/common/src/java/org/apache/hadoop/hive/common/metrics/metrics2/JsonFileMetricsReporter.java
----------------------------------------------------------------------
diff --git a/common/src/java/org/apache/hadoop/hive/common/metrics/metrics2/JsonFileMetricsReporter.java
b/common/src/java/org/apache/hadoop/hive/common/metrics/metrics2/JsonFileMetricsReporter.java
index b9be8bd..2e6420c 100644
--- a/common/src/java/org/apache/hadoop/hive/common/metrics/metrics2/JsonFileMetricsReporter.java
+++ b/common/src/java/org/apache/hadoop/hive/common/metrics/metrics2/JsonFileMetricsReporter.java
@@ -170,9 +170,9 @@ public class JsonFileMetricsReporter implements CodahaleReporter, Runnable
{
         return;
       }
 
-      // Move temp file to the destination file
+      // Atomically move temp file to the destination file
       try {
-        Files.move(tmpFile, path, StandardCopyOption.REPLACE_EXISTING);
+        Files.move(tmpFile, path, StandardCopyOption.ATOMIC_MOVE);
       } catch (Exception e) {
         LOGGER.error("Unable to rename temp file {} to {}", tmpFile, path);
         LOGGER.error("Exception during rename", e);

http://git-wip-us.apache.org/repos/asf/hive/blob/d7d96658/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/metrics/JsonReporter.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/metrics/JsonReporter.java
b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/metrics/JsonReporter.java
index 04a5f02..e198fbc 100644
--- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/metrics/JsonReporter.java
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/metrics/JsonReporter.java
@@ -163,9 +163,10 @@ public class JsonReporter extends ScheduledReporter {
         return;
       }
 
+      // Atomically move temp file to the destination file
       try {
-        Files.move(tmpFile, path, StandardCopyOption.REPLACE_EXISTING);
-      } catch (IOException e) {
+        Files.move(tmpFile, path, StandardCopyOption.ATOMIC_MOVE);
+      } catch (Exception e) {
         LOG.error("Unable to rename temp file {} to {}", tmpFile, path);
         LOG.error("Exception during rename", e);
       }


Mime
View raw message