brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [1/3] incubator-brooklyn git commit: FileBasedObjectStore: log.warn when no atomic move
Date Wed, 16 Sep 2015 12:36:30 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master bf3d67412 -> b3ce25696


FileBasedObjectStore: log.warn when no atomic move

Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/323c7d55
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/323c7d55
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/323c7d55

Branch: refs/heads/master
Commit: 323c7d55c32df218160401052c169809ee542c53
Parents: bf3d674
Author: Aled Sage <aled.sage@gmail.com>
Authored: Wed Sep 16 13:31:03 2015 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Wed Sep 16 13:31:03 2015 +0100

----------------------------------------------------------------------
 .../brooklyn/core/mgmt/persist/FileBasedObjectStore.java    | 9 +++++++--
 .../persist/FileBasedStoreObjectAccessorWriterTest.java     | 2 --
 2 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/323c7d55/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/FileBasedObjectStore.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/FileBasedObjectStore.java
b/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/FileBasedObjectStore.java
index 40f9055..980b416 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/FileBasedObjectStore.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/FileBasedObjectStore.java
@@ -25,7 +25,6 @@ import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
 import java.nio.file.AtomicMoveNotSupportedException;
-import java.nio.file.DirectoryNotEmptyException;
 import java.nio.file.Files;
 import java.nio.file.StandardCopyOption;
 import java.text.SimpleDateFormat;
@@ -66,6 +65,8 @@ public class FileBasedObjectStore implements PersistenceObjectStore {
 
     private static final int SHUTDOWN_TIMEOUT_MS = 10*1000;
 
+    private static boolean WARNED_ON_NON_ATOMIC_FILE_UPDATES = false; 
+    
     private final File basedir;
     private final ListeningExecutorService executor;
     private ManagementContext mgmt;
@@ -357,8 +358,12 @@ public class FileBasedObjectStore implements PersistenceObjectStore {
         }
 
         try {
-            Files.move(srcFile.toPath(), destFile.toPath(), StandardCopyOption.ATOMIC_MOVE,
StandardCopyOption.REPLACE_EXISTING);
+            Files.move(srcFile.toPath(), destFile.toPath(), StandardCopyOption.ATOMIC_MOVE);
         } catch (AtomicMoveNotSupportedException e) {
+            if (!WARNED_ON_NON_ATOMIC_FILE_UPDATES) {
+                WARNED_ON_NON_ATOMIC_FILE_UPDATES = true;
+                log.warn("Unable to perform atomic file update ("+srcFile+" to "+destFile+");
file system not recommended for production HA/DR");
+            }
             Files.move(srcFile.toPath(), destFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
         }
         

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/323c7d55/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/FileBasedStoreObjectAccessorWriterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/FileBasedStoreObjectAccessorWriterTest.java
b/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/FileBasedStoreObjectAccessorWriterTest.java
index 3ee71df..29cdf36 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/FileBasedStoreObjectAccessorWriterTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/FileBasedStoreObjectAccessorWriterTest.java
@@ -23,8 +23,6 @@ import static org.testng.Assert.assertEquals;
 import java.io.File;
 import java.io.IOException;
 
-import org.apache.brooklyn.core.mgmt.persist.FileBasedStoreObjectAccessor;
-import org.apache.brooklyn.core.mgmt.persist.StoreObjectAccessorLocking;
 import org.apache.brooklyn.core.mgmt.persist.PersistenceObjectStore.StoreObjectAccessorWithLock;
 import org.apache.brooklyn.util.os.Os;
 import org.apache.brooklyn.util.time.Duration;


Mime
View raw message