brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grk...@apache.org
Subject brooklyn-server git commit: Revert semantics of prepareForMasterUse in FileBasedObjectStore
Date Wed, 22 Jun 2016 23:42:36 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master cbec083b1 -> f554e61fe


Revert semantics of prepareForMasterUse in FileBasedObjectStore


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

Branch: refs/heads/master
Commit: f554e61fe622dcb3b05197246c11393891b5f67c
Parents: cbec083
Author: Andrew Donald Kennedy <andrew.kennedy@cloudsoftcorp.com>
Authored: Wed Jun 22 16:42:28 2016 -0700
Committer: Andrew Donald Kennedy <andrew.kennedy@cloudsoftcorp.com>
Committed: Wed Jun 22 16:42:28 2016 -0700

----------------------------------------------------------------------
 .../core/mgmt/persist/FileBasedObjectStore.java | 33 ++++++++++----------
 1 file changed, 16 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f554e61f/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 e5fb831..9e6621a 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
@@ -33,18 +33,9 @@ import java.util.Date;
 import java.util.List;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
 
 import javax.annotation.Nullable;
 
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.api.mgmt.ha.HighAvailabilityMode;
-import org.apache.brooklyn.core.server.BrooklynServerConfig;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.exceptions.FatalConfigurationRuntimeException;
-import org.apache.brooklyn.util.io.FileUtil;
-import org.apache.brooklyn.util.os.Os;
-import org.apache.brooklyn.util.os.Os.DeletionResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -56,9 +47,15 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.util.concurrent.ListeningExecutorService;
 import com.google.common.util.concurrent.MoreExecutors;
 
-/**
- * @author Andrea Turli
- */
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.api.mgmt.ha.HighAvailabilityMode;
+import org.apache.brooklyn.core.server.BrooklynServerConfig;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.exceptions.FatalConfigurationRuntimeException;
+import org.apache.brooklyn.util.io.FileUtil;
+import org.apache.brooklyn.util.os.Os;
+import org.apache.brooklyn.util.os.Os.DeletionResult;
+
 public class FileBasedObjectStore implements PersistenceObjectStore {
 
     private static final Logger log = LoggerFactory.getLogger(FileBasedObjectStore.class);
@@ -72,7 +69,7 @@ public class FileBasedObjectStore implements PersistenceObjectStore {
     private ManagementContext mgmt;
     private boolean prepared = false;
     private boolean deferredBackupNeeded = false;
-    private AtomicBoolean doneFirstContentiousWrite = new AtomicBoolean(false);
+    private boolean doneFirstContentiousWrite = false;
 
     /**
      * @param basedir
@@ -92,9 +89,10 @@ public class FileBasedObjectStore implements PersistenceObjectStore {
     public File getBaseDir() {
         return basedir;
     }
-    
-    public void prepareForMasterUse() {
-        if (doneFirstContentiousWrite.getAndSet(true)) return;
+
+    @Override
+    public synchronized void prepareForMasterUse() {
+        if (doneFirstContentiousWrite) return;
         try {
             if (deferredBackupNeeded) {
                 // defer backup and path creation until first write
@@ -105,11 +103,12 @@ public class FileBasedObjectStore implements PersistenceObjectStore
{
 
                 deferredBackupNeeded = false;
             }
+            doneFirstContentiousWrite = true;
         } catch (Exception e) {
             throw Exceptions.propagate(e);
         }
     }
-    
+
     @Override
     public void createSubPath(String subPath) {
         if (!prepared) throw new IllegalStateException("Not yet prepared: "+this);


Mime
View raw message