brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [15/21] incubator-brooklyn git commit: correct description and tidied code for determining backup location spec v non-backup location spec, fixing NPE's
Date Sat, 15 Nov 2014 00:05:24 GMT
correct description and tidied code for determining backup location spec v non-backup location
spec, fixing NPE's


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

Branch: refs/heads/master
Commit: a6891c691a3ead9ef0dac4e978527e034a83e576
Parents: 9edd58d
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Thu Nov 13 21:42:04 2014 +0000
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Thu Nov 13 23:38:55 2014 +0000

----------------------------------------------------------------------
 .../java/brooklyn/config/BrooklynServerConfig.java    |  2 +-
 .../java/brooklyn/config/BrooklynServerPaths.java     | 14 +++++++++-----
 .../rebind/persister/BrooklynPersistenceUtils.java    | 13 ++++++++-----
 3 files changed, 18 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a6891c69/core/src/main/java/brooklyn/config/BrooklynServerConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/config/BrooklynServerConfig.java b/core/src/main/java/brooklyn/config/BrooklynServerConfig.java
index c240d7c..4fdf4c4 100644
--- a/core/src/main/java/brooklyn/config/BrooklynServerConfig.java
+++ b/core/src/main/java/brooklyn/config/BrooklynServerConfig.java
@@ -76,7 +76,7 @@ public class BrooklynServerConfig {
     public static final ConfigKey<String> PERSISTENCE_BACKUPS_LOCATION_SPEC = newStringConfigKey(
         "brooklyn.persistence.backups.location.spec", 
         "Location spec string for an object store (e.g. jclouds:swift:URL) where backups
of persisted state should be kept; "
-        + "defaults to the same location spec as regular persisted state, failing back to
local file system");
+        + "defaults to the local file system");
     
     public static final ConfigKey<Boolean> PERSISTENCE_BACKUPS_REQUIRED_ON_PROMOTION
=
         ConfigKeys.newBooleanConfigKey("brooklyn.persistence.backups.required.promotion",

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a6891c69/core/src/main/java/brooklyn/config/BrooklynServerPaths.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/config/BrooklynServerPaths.java b/core/src/main/java/brooklyn/config/BrooklynServerPaths.java
index ee294e9..06c8033 100644
--- a/core/src/main/java/brooklyn/config/BrooklynServerPaths.java
+++ b/core/src/main/java/brooklyn/config/BrooklynServerPaths.java
@@ -162,13 +162,12 @@ public class BrooklynServerPaths {
      * It also includes conveniences for resolving further subpaths, cf {@link PersistenceBackupPathResolver#resolveWithSubpathFor(ManagementContextInternal,
String)}.
      */
     public static class PersistenceBackupPathResolver extends PersistencePathResolver {
-        protected String nonBackuplocationSpec;
+        private String nonBackupLocationSpec;
         private PersistenceBackupPathResolver(StringConfigMap brooklynProperties) {
             super(brooklynProperties);
         }
-        @Override
-        public PersistenceBackupPathResolver location(@Nullable String locationSpec) {
-            this.nonBackuplocationSpec = locationSpec;
+        public PersistenceBackupPathResolver nonBackupLocation(@Nullable String locationSpec)
{
+            this.nonBackupLocationSpec = locationSpec;
             return this;
         }
         @Override
@@ -176,8 +175,13 @@ public class BrooklynServerPaths {
             super.dir(dirOrContainer);
             return this;
         }
+        @Override
+        public PersistenceBackupPathResolver location(String backupLocationSpec) {
+            super.location(backupLocationSpec);
+            return this;
+        }
         protected boolean isBackupSameLocation() {
-            return Objects.equal(locationSpec, nonBackuplocationSpec);
+            return Objects.equal(locationSpec, nonBackupLocationSpec);
         }
         /** Appends a sub-path to the path returned by {@link #resolve()} */
         public String resolveWithSubpath(String subpath) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a6891c69/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynPersistenceUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynPersistenceUtils.java
b/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynPersistenceUtils.java
index ea52f36..9d2721d 100644
--- a/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynPersistenceUtils.java
+++ b/core/src/main/java/brooklyn/entity/rebind/persister/BrooklynPersistenceUtils.java
@@ -230,9 +230,10 @@ public class BrooklynPersistenceUtils {
         
             PersistenceObjectStore destinationObjectStore = null;
             String backupSpec = managementContext.getConfig().getConfig(BrooklynServerConfig.PERSISTENCE_BACKUPS_LOCATION_SPEC);
+            String nonBackupSpec = managementContext.getConfig().getConfig(BrooklynServerConfig.PERSISTENCE_LOCATION_SPEC);
             try {
-                String backupContainer = BrooklynServerPaths.newBackupPersistencePathResolver(managementContext).location(backupSpec)
-                    .resolveWithSubpathFor(managementContext, mode.toString());
+                String backupContainer = BrooklynServerPaths.newBackupPersistencePathResolver(managementContext)
+                    .location(backupSpec).nonBackupLocation(nonBackupSpec).resolveWithSubpathFor(managementContext,
mode.toString());
                 destinationObjectStore = BrooklynPersistenceUtils.newPersistenceObjectStore(managementContext,
backupSpec, backupContainer);
                 log.debug("Backing up persisted state on "+mode+", to "+destinationObjectStore.getSummaryName());
                 BrooklynPersistenceUtils.writeMemento(managementContext, memento, destinationObjectStore);
@@ -243,11 +244,13 @@ public class BrooklynPersistenceUtils {
                 Exceptions.propagateIfFatal(e);
                 PersistenceObjectStore failedStore = destinationObjectStore;
                 if (!Strings.isBlank(backupSpec) && !"localhost".equals(backupSpec))
{
+                    String failedSpec = backupSpec;
                     backupSpec = "localhost";
-                    String backupContainer = BrooklynServerPaths.newBackupPersistencePathResolver(managementContext).location(backupSpec)
-                        .resolveWithSubpathFor(managementContext, mode.toString());
+                    String backupContainer = BrooklynServerPaths.newBackupPersistencePathResolver(managementContext)
+                        .location(backupSpec).nonBackupLocation(nonBackupSpec).resolveWithSubpathFor(managementContext,
mode.toString());
                     destinationObjectStore = BrooklynPersistenceUtils.newPersistenceObjectStore(managementContext,
backupSpec, backupContainer);
-                    log.warn("Persisted state back-up to "+failedStore.getSummaryName()+"
failed with "+e, e);
+                    log.warn("Persisted state back-up to "+(failedStore!=null ? failedStore.getSummaryName()
: failedSpec)
+                        +" failed with "+e, e);
                     
                     log.debug("Backing up persisted state on "+mode+", locally because remote
failed, to "+destinationObjectStore.getSummaryName());
                     BrooklynPersistenceUtils.writeMemento(managementContext, memento, destinationObjectStore);


Mime
View raw message