You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ma...@apache.org on 2015/11/23 21:49:12 UTC
[42/50] [abbrv] incubator-geode git commit: GEODE-416: Fix test issue
where messages are arriving out of order
GEODE-416: Fix test issue where messages are arriving out of order
- Updating the alert level is changed from a pooled message to a serial
message. This ensures that consecutive alert level changes are
processed in the correct order.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/85524619
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/85524619
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/85524619
Branch: refs/heads/feature/GEODE-53
Commit: 855246198f26f16d3a115760860f69f2c8674445
Parents: 59ab8cf
Author: Jens Deppe <jd...@pivotal.io>
Authored: Mon Nov 16 13:43:00 2015 -0800
Committer: Jens Deppe <jd...@pivotal.io>
Committed: Fri Nov 20 06:16:20 2015 -0800
----------------------------------------------------------------------
.../admin/remote/AlertLevelChangeMessage.java | 5 +-
.../internal/logging/log4j/AlertAppender.java | 15 +++++-
.../management/DistributedSystemDUnitTest.java | 51 ++++++++++----------
3 files changed, 40 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/85524619/gemfire-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/AlertLevelChangeMessage.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/AlertLevelChangeMessage.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/AlertLevelChangeMessage.java
index 7e6c0a4..d7b6fc9 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/AlertLevelChangeMessage.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/AlertLevelChangeMessage.java
@@ -20,11 +20,11 @@ import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
+import com.gemstone.gemfire.distributed.internal.SerialDistributionMessage;
import org.apache.logging.log4j.Logger;
import com.gemstone.gemfire.admin.AlertLevel;
import com.gemstone.gemfire.distributed.internal.DistributionManager;
-import com.gemstone.gemfire.distributed.internal.PooledDistributionMessage;
import com.gemstone.gemfire.internal.admin.Alert;
import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
import com.gemstone.gemfire.internal.logging.LogService;
@@ -40,8 +40,7 @@ import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
* @author David Whitlock
* @since 3.5
*/
-public final class AlertLevelChangeMessage
- extends PooledDistributionMessage {
+public final class AlertLevelChangeMessage extends SerialDistributionMessage {
private static final Logger logger = LogService.getLogger();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/85524619/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/AlertAppender.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/AlertAppender.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/AlertAppender.java
index bd1ad92..e071511 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/AlertAppender.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/AlertAppender.java
@@ -199,11 +199,22 @@ public final class AlertAppender extends AbstractAppender implements PropertyCha
final Level level = LogService.toLevel(alertLevelToLogLevel(alertLevel));
for (Listener listener: this.listeners) {
- if(listener.getMember().equals(member) && listener.getLevel().equals(level)) {
+ if (listener.getMember().equals(member) && listener.getLevel().equals(level)) {
return true;
}
}
-
+
+ // Special case for alert level Alert.OFF (NONE_LEVEL), because we can never have an actual listener with
+ // this level (see AlertLevelChangeMessage.process()).
+ if (alertLevel == Alert.OFF) {
+ for (Listener listener: this.listeners) {
+ if (listener.getMember().equals(member)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
return false;
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/85524619/gemfire-core/src/test/java/com/gemstone/gemfire/management/DistributedSystemDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/management/DistributedSystemDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/management/DistributedSystemDUnitTest.java
index 193dd12..005ed1c 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/management/DistributedSystemDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/DistributedSystemDUnitTest.java
@@ -17,7 +17,6 @@
package com.gemstone.gemfire.management;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -149,7 +148,6 @@ public class DistributedSystemDUnitTest extends ManagementTestBase {
* @throws Exception
*/
public void testAlertManagedNodeFirst() throws Exception {
-
for (VM vm : getManagedNodeList()) {
createCache(vm);
@@ -158,39 +156,46 @@ public class DistributedSystemDUnitTest extends ManagementTestBase {
}
VM managingNode = getManagingNode();
+
createManagementCache(managingNode);
startManagingNode(managingNode);
-
addAlertListener(managingNode);
-
checkAlertCount(managingNode, 0, 0);
-
+
final DistributedMember managingMember = getMember(managingNode);
-
+
+ // Before we start we need to ensure that the initial (implicit) SEVERE alert has propagated everywhere.
for (VM vm : getManagedNodeList()) {
ensureLoggerState(vm, managingMember, Alert.SEVERE);
- warnLevelAlert(vm);
- severeLevelAlert(vm);
}
- checkAlertCount(managingNode, 3, 0);
- resetAlertCounts(managingNode);
+
setAlertLevel(managingNode, AlertDetails.getAlertLevelAsString(Alert.WARNING));
-
+
for (VM vm : getManagedNodeList()) {
ensureLoggerState(vm, managingMember, Alert.WARNING);
warnLevelAlert(vm);
severeLevelAlert(vm);
}
-
+
checkAlertCount(managingNode, 3, 3);
resetAlertCounts(managingNode);
+
+ setAlertLevel(managingNode, AlertDetails.getAlertLevelAsString(Alert.SEVERE));
+
+ for (VM vm : getManagedNodeList()) {
+ ensureLoggerState(vm, managingMember, Alert.SEVERE);
+ warnLevelAlert(vm);
+ severeLevelAlert(vm);
+ }
+
+ checkAlertCount(managingNode, 3, 0);
+ resetAlertCounts(managingNode);
for (VM vm : getManagedNodeList()) {
closeCache(vm);
}
closeCache(managingNode);
-
}
@SuppressWarnings("serial")
@@ -223,7 +228,6 @@ public class DistributedSystemDUnitTest extends ManagementTestBase {
}
}
-
/**
* Tests each and every operations that is defined on the MemberMXBean
*
@@ -268,6 +272,7 @@ public class DistributedSystemDUnitTest extends ManagementTestBase {
class NotificationHubTestListener implements NotificationListener {
@Override
public synchronized void handleNotification(Notification notification, Object handback) {
+ logger.info("Notification received {}", notification);
notifList.add(notification);
}
}
@@ -329,7 +334,6 @@ public class DistributedSystemDUnitTest extends ManagementTestBase {
* added for each member mbean by distributed system mbean One for the
* added listener in test
*/
-
assertEquals(2, listener.getNumCounter());
// Raise some notifications
@@ -410,11 +414,9 @@ public class DistributedSystemDUnitTest extends ManagementTestBase {
.get(memberMBeanName);
/*
- * Counter of listener should be 2 . One for default Listener which is
- * added for each member mbean by distributed system mbean One for the
- * added listener in test
+ * Counter of listener should be 1 for the default Listener which is
+ * added for each member mbean by distributed system mbean.
*/
-
assertEquals(1, listener.getNumCounter());
}
@@ -484,7 +486,6 @@ public class DistributedSystemDUnitTest extends ManagementTestBase {
}
});
}
-
}
/**
@@ -539,7 +540,7 @@ public class DistributedSystemDUnitTest extends ManagementTestBase {
setAlertLevel(managingNode, AlertDetails.getAlertLevelAsString(Alert.OFF));
for (VM vm : getManagedNodeList()) {
- // ensureLoggerState(vm, managingMember, Alert.OFF);
+ ensureLoggerState(vm, managingMember, Alert.OFF);
warnLevelAlert(vm);
severeLevelAlert(vm);
}
@@ -605,9 +606,6 @@ public class DistributedSystemDUnitTest extends ManagementTestBase {
});
}
- // Two Seconds for each member
- //sleeps to avoid false failures
- pause(1000 *10);
}
@SuppressWarnings("serial")
@@ -630,7 +628,7 @@ public class DistributedSystemDUnitTest extends ManagementTestBase {
@SuppressWarnings("serial")
public void resetAlertCounts(VM vm1) throws Exception {
{
- vm1.invoke(new SerializableCallable("Reset Alert Ccount") {
+ vm1.invoke(new SerializableCallable("Reset Alert Count") {
public Object call() throws Exception {
AlertNotifListener nt = AlertNotifListener.getInstance();
@@ -864,8 +862,9 @@ public class DistributedSystemDUnitTest extends ManagementTestBase {
private int severAlertCount = 0;
@Override
- public void handleNotification(Notification notification, Object handback) {
+ public synchronized void handleNotification(Notification notification, Object handback) {
assertNotNull(notification);
+ logger.info("Notification received {}", notification);
Map<String,String> notifUserData = (Map<String,String>)notification.getUserData();
if (notifUserData.get(JMXNotificationUserData.ALERT_LEVEL).equalsIgnoreCase("warning")) {
assertEquals(WARNING_LEVEL_MESSAGE,notification.getMessage());