brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [04/13] incubator-brooklyn git commit: allow explicit setting master
Date Wed, 19 Nov 2014 17:47:59 GMT
allow explicit setting master

this is in fact needed, as otherwise if a previous master has failed we have no way to force
a new master sooner than the heartbeat timeout


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

Branch: refs/heads/master
Commit: 288ffd7105808402a7f3479e709f5f85d3ea36f1
Parents: b0bb61a
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Tue Nov 18 23:43:06 2014 +0000
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Wed Nov 19 13:53:07 2014 +0000

----------------------------------------------------------------------
 .../management/ha/HighAvailabilityManagerImpl.java      | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/288ffd71/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java b/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java
index 31ec5b1..3c1196d 100644
--- a/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java
+++ b/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java
@@ -253,7 +253,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager
{
     
     @VisibleForTesting
     @Beta
-    public void changeMode(HighAvailabilityMode startMode, boolean preventElectionOnExplicitStandbyMode,
boolean failOnExplicitStandbyModeIfNoMaster) {
+    public void changeMode(HighAvailabilityMode startMode, boolean preventElectionOnExplicitStandbyMode,
boolean failOnExplicitModesIfUnusual) {
         if (!running) {
             // if was not running then start as disabled mode, then proceed as normal
             LOG.info("HA changing mode to "+startMode+" from "+getInternalNodeState()+" when
not running, forcing an intermediate start as DISABLED then will convert to "+startMode);
@@ -334,9 +334,13 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager
{
             }
             break;
         case MASTER:
-            if (existingMaster == null) {
+            if (!failOnExplicitModesIfUnusual || existingMaster==null) {
                 promoteToMaster();
-                LOG.info("Management node "+ownNodeId+" running as HA MASTER explicitly");
+                if (existingMaster!=null) {
+                    LOG.info("Management node "+ownNodeId+" running as HA MASTER explicitly");
+                } else {
+                    LOG.info("Management node "+ownNodeId+" running as HA MASTER explicitly,
stealing from "+existingMaster);
+                }
             } else if (!weAreRecognisedAsMaster) {
                 throw new IllegalStateException("Master already exists; cannot run as master
(master "+existingMaster.toVerboseString()+"); "
                     + "to trigger a promotion, set a priority and demote the current master");
@@ -362,7 +366,7 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager
{
                 if (!preventElectionOnExplicitStandbyMode) {
                     publishAndCheck(true);
                 }
-                if (failOnExplicitStandbyModeIfNoMaster && existingMaster==null)
{
+                if (failOnExplicitModesIfUnusual && existingMaster==null) {
                     LOG.error("Management node "+ownNodeId+" detected no master when "+startMode+"
requested and existing master required; failing.");
                     throw new IllegalStateException("No existing master; cannot start as
"+startMode);
                 }


Mime
View raw message