brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [1/2] git commit: suppress publishing of health if poll period is disabled, fixing race causing intermittent failure in split-brain test
Date Wed, 02 Jul 2014 14:22:46 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 9bb861bf9 -> 1c04ec92d


suppress publishing of health if poll period is disabled, fixing race causing intermittent
failure in split-brain test


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

Branch: refs/heads/master
Commit: 0695ba2bad743d4829e61fcc22d000a5dbd3c79b
Parents: 9bb861b
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Wed Jul 2 14:45:57 2014 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Wed Jul 2 14:45:57 2014 +0100

----------------------------------------------------------------------
 .../management/ha/HighAvailabilityManagerImpl.java       | 11 +++++++++--
 .../ha/HighAvailabilityManagerSplitBrainTest.java        |  9 ++++++++-
 2 files changed, 17 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0695ba2b/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 7e44714..fc5f66c 100644
--- a/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java
+++ b/core/src/main/java/brooklyn/management/ha/HighAvailabilityManagerImpl.java
@@ -273,8 +273,15 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager
{
             }
         };
         
-        ScheduledTask task = new ScheduledTask(MutableMap.of("period", pollPeriod), taskFactory);
-        pollingTask = managementContext.getExecutionManager().submit(task);
+        if (pollPeriod==null || pollPeriod.equals(Duration.PRACTICALLY_FOREVER)) {
+            // don't schedule - used for tests
+            // (scheduling fires off one initial task in the background before the delay,

+            // which affects tests that want to know exactly when publishing happens;
+            // TODO would be nice if scheduled task had a "no initial submission" flag )
+        } else {
+            ScheduledTask task = new ScheduledTask(MutableMap.of("period", pollPeriod), taskFactory);
+            pollingTask = managementContext.getExecutionManager().submit(task);
+        }
     }
     
     /** invoked manually when initializing, and periodically thereafter */

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0695ba2b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java
b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java
index e9eb855..c66fb38 100644
--- a/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java
+++ b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java
@@ -162,6 +162,8 @@ public class HighAvailabilityManagerSplitBrainTest {
     @Test
     public void testIfNodeStopsBeingAbleToWrite() throws Exception {
         useSharedTime();
+        log.info("time at start "+sharedTickerCurrentMillis());
+        
         HaMgmtNode n1 = newNode();
         HaMgmtNode n2 = newNode();
         
@@ -195,16 +197,19 @@ public class HighAvailabilityManagerSplitBrainTest {
         
         assertEquals(n1.mgmt.getApplications().size(), 1);
         assertEquals(n2.mgmt.getApplications().size(), 0);
+        log.info("persisting "+n1.ownNodeId);
         n1.mgmt.getRebindManager().forcePersistNow();
         
         n1.objectStore.setWritesFailSilently(true);
         log.info(n1+" writes off");
         sharedTickerAdvance(Duration.ONE_MINUTE);
+        log.info("time now "+sharedTickerCurrentMillis());
+        Long time1 = sharedTickerCurrentMillis();
         
+        log.info("publish "+n2.ownNodeId);
         n2.ha.publishAndCheck(false);
         ManagementPlaneSyncRecord memento2b = n2.ha.getManagementPlaneSyncState();
         log.info(n2+" HA now: "+memento2b);
-        Long time1 = sharedTickerCurrentMillis();
         
         // n2 infers n1 as failed 
         assertEquals(memento2b.getManagementNodes().get(n1.ownNodeId).getStatus(), ManagementNodeState.FAILED);
@@ -221,8 +226,10 @@ public class HighAvailabilityManagerSplitBrainTest {
         log.info(n1+" writes on");
         
         sharedTickerAdvance(Duration.ONE_SECOND);
+        log.info("time now "+sharedTickerCurrentMillis());
         Long time2 = sharedTickerCurrentMillis();
         
+        log.info("publish "+n1.ownNodeId);
         n1.ha.publishAndCheck(false);
         ManagementPlaneSyncRecord memento1b = n1.ha.getManagementPlaneSyncState();
         log.info(n1+" HA now: "+memento1b);


Mime
View raw message