geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject geode git commit: Change non-logging callers to use AlertService
Date Wed, 18 Jan 2017 01:24:01 GMT
Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-2297-2 fa3efda3e -> 66767ae2f


Change non-logging callers to use AlertService


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/66767ae2
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/66767ae2
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/66767ae2

Branch: refs/heads/feature/GEODE-2297-2
Commit: 66767ae2fd6d5c81e8481624e747e3779efc8559
Parents: fa3efda
Author: Kirk Lund <klund@apache.org>
Authored: Tue Jan 17 17:23:32 2017 -0800
Committer: Kirk Lund <klund@apache.org>
Committed: Tue Jan 17 17:23:32 2017 -0800

----------------------------------------------------------------------
 .../geode/admin/jmx/internal/AgentImpl.java     |  10 +-
 .../internal/DistributionManager.java           |   4 +-
 .../internal/InternalDistributedSystem.java     |   6 +-
 .../gms/mgr/GMSMembershipManager.java           |   7 +-
 .../remote/AdminConsoleDisconnectMessage.java   |   9 +-
 .../admin/remote/AdminConsoleMessage.java       |  17 +--
 .../admin/remote/AlertLevelChangeMessage.java   |   6 +-
 .../internal/logging/log4j/AlertAppender.java   | 126 ++++++-------------
 .../internal/logging/log4j/AlertLevel.java      |  67 ++++++++++
 .../internal/logging/log4j/AlertService.java    |  58 +++++++++
 .../internal/ManagerStartupMessage.java         |  11 +-
 .../logging/log4j/AlertAppenderJUnitTest.java   |  45 +++----
 .../management/DistributedSystemDUnitTest.java  |   6 +-
 13 files changed, 218 insertions(+), 154 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/66767ae2/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AgentImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AgentImpl.java b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AgentImpl.java
index e55c3f1..8ca8897 100644
--- a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AgentImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AgentImpl.java
@@ -66,7 +66,7 @@ import org.apache.geode.internal.logging.LogConfig;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.logging.LogWriterFactory;
 import org.apache.geode.internal.logging.LoggingThreadGroup;
-import org.apache.geode.internal.logging.log4j.AlertAppender;
+import org.apache.geode.internal.logging.log4j.AlertService;
 import org.apache.geode.internal.logging.log4j.LocalizedMessage;
 import org.apache.geode.internal.logging.log4j.LogMarker;
 import org.apache.geode.internal.logging.log4j.LogWriterAppender;
@@ -277,7 +277,7 @@ public class AgentImpl implements org.apache.geode.admin.jmx.Agent,
     try {
       startHttpAdaptor();
     } catch (StartupException e) {
-      AlertAppender.getInstance().shuttingDown();
+      AlertService.shuttingDown();
       LogWriterAppenders.stop(LogWriterAppenders.Identifier.MAIN);
       LogWriterAppenders.destroy(LogWriterAppenders.Identifier.MAIN);
       throw e;
@@ -287,7 +287,7 @@ public class AgentImpl implements org.apache.geode.admin.jmx.Agent,
       startRMIConnectorServer();
     } catch (StartupException e) {
       stopHttpAdaptor();
-      AlertAppender.getInstance().shuttingDown();
+      AlertService.shuttingDown();
       LogWriterAppenders.stop(LogWriterAppenders.Identifier.MAIN);
       LogWriterAppenders.destroy(LogWriterAppenders.Identifier.MAIN);
       throw e;
@@ -298,7 +298,7 @@ public class AgentImpl implements org.apache.geode.admin.jmx.Agent,
     } catch (StartupException e) {
       stopRMIConnectorServer();
       stopHttpAdaptor();
-      AlertAppender.getInstance().shuttingDown();
+      AlertService.shuttingDown();
       LogWriterAppenders.stop(LogWriterAppenders.Identifier.MAIN);
       LogWriterAppenders.destroy(LogWriterAppenders.Identifier.MAIN);
       throw e;
@@ -339,7 +339,7 @@ public class AgentImpl implements org.apache.geode.admin.jmx.Agent,
   public void stop() {
     try {
       logger.info(LocalizedMessage.create(LocalizedStrings.AgentImpl_STOPPING_JMX_AGENT));
-      AlertAppender.getInstance().shuttingDown();
+      AlertService.shuttingDown();
       LogWriterAppenders.stop(LogWriterAppenders.Identifier.MAIN);
 
       // stop the GemFire Distributed System

http://git-wip-us.apache.org/repos/asf/geode/blob/66767ae2/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionManager.java
b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionManager.java
index 3efbafc..201911f 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionManager.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionManager.java
@@ -31,7 +31,7 @@ import org.apache.geode.internal.cache.InitialImageOperation;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.logging.LoggingThreadGroup;
-import org.apache.geode.internal.logging.log4j.AlertAppender;
+import org.apache.geode.internal.logging.log4j.AlertService;
 import org.apache.geode.internal.logging.log4j.LocalizedMessage;
 import org.apache.geode.internal.logging.log4j.LogMarker;
 import org.apache.geode.internal.net.SocketCreator;
@@ -3225,7 +3225,7 @@ public class DistributionManager implements DM {
     boolean crashed = p_crashed;
     String reason = p_reason;
 
-    AlertAppender.getInstance().removeAlertListener(theId);
+    AlertService.removeAlertSubscriber(theId);
 
     // this fixes a race introduced in 5.0.1 by the fact that an explicit
     // shutdown will cause a member to no longer be in our DM membership

http://git-wip-us.apache.org/repos/asf/geode/blob/66767ae2/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
index fad9206..f53e887 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
@@ -89,7 +89,7 @@ import org.apache.geode.internal.logging.InternalLogWriter;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.logging.LogWriterFactory;
 import org.apache.geode.internal.logging.LoggingThreadGroup;
-import org.apache.geode.internal.logging.log4j.AlertAppender;
+import org.apache.geode.internal.logging.log4j.AlertService;
 import org.apache.geode.internal.logging.log4j.LocalizedMessage;
 import org.apache.geode.internal.logging.log4j.LogWriterAppender;
 import org.apache.geode.internal.logging.log4j.LogWriterAppenders;
@@ -1366,7 +1366,7 @@ public class InternalDistributedSystem extends DistributedSystem
           }
         }
 
-        AlertAppender.getInstance().shuttingDown();
+        AlertService.shuttingDown();
 
       } finally { // be ABSOLUTELY CERTAIN that dm closed
         try {
@@ -2951,7 +2951,7 @@ public class InternalDistributedSystem extends DistributedSystem
 
 
   public boolean hasAlertListenerFor(DistributedMember member, int severity) {
-    return AlertAppender.getInstance().hasAlertListener(member, severity);
+    return AlertService.hasAlertSubscriber(member, severity);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/geode/blob/66767ae2/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/mgr/GMSMembershipManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/mgr/GMSMembershipManager.java
b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/mgr/GMSMembershipManager.java
index cf17025..eb81141 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/mgr/GMSMembershipManager.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/mgr/GMSMembershipManager.java
@@ -27,7 +27,7 @@ import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.*;
+import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CountDownLatch;
@@ -77,7 +77,6 @@ import org.apache.geode.distributed.internal.membership.gms.SuspectMember;
 import org.apache.geode.distributed.internal.membership.gms.fd.GMSHealthMonitor;
 import org.apache.geode.distributed.internal.membership.gms.interfaces.Manager;
 import org.apache.geode.distributed.internal.membership.gms.membership.GMSJoinLeave;
-import org.apache.geode.distributed.internal.membership.gms.messenger.GMSQuorumChecker;
 import org.apache.geode.internal.Assert;
 import org.apache.geode.internal.SystemTimer;
 import org.apache.geode.internal.Version;
@@ -88,7 +87,7 @@ import org.apache.geode.internal.cache.partitioned.PartitionMessageWithDirectRep
 import org.apache.geode.internal.cache.xmlcache.CacheServerCreation;
 import org.apache.geode.internal.cache.xmlcache.CacheXmlGenerator;
 import org.apache.geode.internal.i18n.LocalizedStrings;
-import org.apache.geode.internal.logging.log4j.AlertAppender;
+import org.apache.geode.internal.logging.log4j.AlertService;
 import org.apache.geode.internal.logging.log4j.LocalizedMessage;
 import org.apache.geode.internal.logging.log4j.LogMarker;
 import org.apache.geode.internal.shared.StringPrintWriter;
@@ -2523,7 +2522,7 @@ public class GMSMembershipManager implements MembershipManager, Manager
{
     services.setShutdownCause(shutdownCause);
     services.getCancelCriterion().cancel(reason);
 
-    AlertAppender.getInstance().shuttingDown();
+    AlertService.shuttingDown();
 
     if (!inhibitForceDisconnectLogging) {
       logger.fatal(

http://git-wip-us.apache.org/repos/asf/geode/blob/66767ae2/geode-core/src/main/java/org/apache/geode/internal/admin/remote/AdminConsoleDisconnectMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/admin/remote/AdminConsoleDisconnectMessage.java
b/geode-core/src/main/java/org/apache/geode/internal/admin/remote/AdminConsoleDisconnectMessage.java
index 8452929..8554c0e 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/admin/remote/AdminConsoleDisconnectMessage.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/admin/remote/AdminConsoleDisconnectMessage.java
@@ -12,8 +12,6 @@
  * or implied. See the License for the specific language governing permissions and limitations
under
  * the License.
  */
-
-
 package org.apache.geode.internal.admin.remote;
 
 import java.io.DataInput;
@@ -29,12 +27,12 @@ import org.apache.geode.distributed.internal.PooledDistributionMessage;
 import org.apache.geode.internal.statistics.GemFireStatSampler;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.internal.logging.log4j.AlertAppender;
+import org.apache.geode.internal.logging.log4j.AlertService;
 import org.apache.geode.internal.logging.log4j.LocalizedMessage;
 
 /**
  * A message that is sent to a particular distribution manager to let it know that the sender
is an
- * administation console that just disconnected.
+ * administration console that just disconnected.
  */
 public final class AdminConsoleDisconnectMessage extends PooledDistributionMessage {
   private static final Logger logger = LogService.getLogger();
@@ -79,9 +77,8 @@ public final class AdminConsoleDisconnectMessage extends PooledDistributionMessa
   @Override
   public void process(DistributionManager dm) {
     InternalDistributedSystem sys = dm.getSystem();
-    // DistributionConfig config = sys.getConfig();
     if (alertListenerExpected) {
-      if (!AlertAppender.getInstance().removeAlertListener(this.getSender())
+      if (!AlertService.removeAlertSubscriber(getSender())
           && !this.ignoreAlertListenerRemovalFailure) {
         logger.warn(LocalizedMessage.create(
             LocalizedStrings.ManagerLogWriter_UNABLE_TO_REMOVE_CONSOLE_WITH_ID_0_FROM_ALERT_LISTENERS,

http://git-wip-us.apache.org/repos/asf/geode/blob/66767ae2/geode-core/src/main/java/org/apache/geode/internal/admin/remote/AdminConsoleMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/admin/remote/AdminConsoleMessage.java
b/geode-core/src/main/java/org/apache/geode/internal/admin/remote/AdminConsoleMessage.java
index fa07560..a43d4d0 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/admin/remote/AdminConsoleMessage.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/admin/remote/AdminConsoleMessage.java
@@ -12,31 +12,24 @@
  * or implied. See the License for the specific language governing permissions and limitations
under
  * the License.
  */
-
-
 package org.apache.geode.internal.admin.remote;
 
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 
-import org.apache.logging.log4j.Logger;
-
 import org.apache.geode.distributed.internal.DistributionManager;
 import org.apache.geode.distributed.internal.PooledDistributionMessage;
 import org.apache.geode.internal.admin.Alert;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.internal.logging.ManagerLogWriter;
-import org.apache.geode.internal.logging.log4j.AlertAppender;
-import org.apache.geode.internal.logging.log4j.LogWriterLogger;
+import org.apache.geode.internal.logging.log4j.AlertService;
 
 /**
  * A message that is sent to a particular distribution manager to let it know that the sender
is an
- * administation console that just connected.
+ * administration console that just connected.
  */
 public final class AdminConsoleMessage extends PooledDistributionMessage {
   // instance variables
-  int level;
+  private int level;
 
   public static AdminConsoleMessage create(int level) {
     AdminConsoleMessage m = new AdminConsoleMessage();
@@ -51,9 +44,9 @@ public final class AdminConsoleMessage extends PooledDistributionMessage
{
   @Override
   public void process(DistributionManager dm) {
     if (this.level != Alert.OFF) {
-      AlertAppender.getInstance().addAlertListener(this.getSender(), this.level);
+      AlertService.addAlertSubscriber(getSender(), this.level);
     }
-    dm.addAdminConsole(this.getSender());
+    dm.addAdminConsole(getSender());
   }
 
   public int getDSFID() {

http://git-wip-us.apache.org/repos/asf/geode/blob/66767ae2/geode-core/src/main/java/org/apache/geode/internal/admin/remote/AlertLevelChangeMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/admin/remote/AlertLevelChangeMessage.java
b/geode-core/src/main/java/org/apache/geode/internal/admin/remote/AlertLevelChangeMessage.java
index c3a293f..3414775 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/admin/remote/AlertLevelChangeMessage.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/admin/remote/AlertLevelChangeMessage.java
@@ -26,7 +26,7 @@ import org.apache.geode.distributed.internal.DistributionManager;
 import org.apache.geode.internal.admin.Alert;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.internal.logging.log4j.AlertAppender;
+import org.apache.geode.internal.logging.log4j.AlertService;
 import org.apache.geode.internal.logging.log4j.LogMarker;
 
 /**
@@ -59,10 +59,10 @@ public final class AlertLevelChangeMessage extends SerialDistributionMessage
{
 
   @Override
   public void process(DistributionManager dm) {
-    AlertAppender.getInstance().removeAlertListener(this.getSender());
+    AlertService.removeAlertSubscriber(this.getSender());
 
     if (this.newLevel != Alert.OFF) {
-      AlertAppender.getInstance().addAlertListener(this.getSender(), this.newLevel);
+      AlertService.addAlertSubscriber(getSender(), this.newLevel);
       if (logger.isTraceEnabled(LogMarker.DM)) {
         logger.trace(LogMarker.DM, "Added new AlertListener to application log writer");
       }

http://git-wip-us.apache.org/repos/asf/geode/blob/66767ae2/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/AlertAppender.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/AlertAppender.java
b/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/AlertAppender.java
index e44c336..26ac410 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/AlertAppender.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/AlertAppender.java
@@ -20,7 +20,6 @@ import java.util.Date;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.appender.AbstractAppender;
@@ -56,7 +55,7 @@ public final class AlertAppender extends AbstractAppender implements PropertyCha
   };
 
   // Listeners are ordered with the narrowest levels (e.g. FATAL) at the end
-  private final CopyOnWriteArrayList<Listener> listeners = new CopyOnWriteArrayList<Listener>();
+  private final CopyOnWriteArrayList<AlertSubscriber> listeners = new CopyOnWriteArrayList<AlertSubscriber>();
 
   private final AppenderContext appenderContext = LogService.getAppenderContext();
 
@@ -123,14 +122,14 @@ public final class AlertAppender extends AbstractAppender implements
PropertyCha
       }
       DistributionManager distMgr = (DistributionManager) ds.getDistributionManager();
 
-      final int intLevel = logLevelToAlertLevel(event.getLevel().intLevel());
+      final int intLevel = AlertLevel.logLevelToAlertLevel(event.getLevel().intLevel());
       final Date date = new Date(event.getTimeMillis());
       final String threadName = event.getThreadName();
       final String logMessage = event.getMessage().getFormattedMessage();
       final String stackTrace = ThreadUtils.stackTraceToString(event.getThrown(), true);
       final String connectionName = ds.getConfig().getName();
 
-      for (Listener listener : this.listeners) {
+      for (AlertSubscriber listener : this.listeners) {
         if (event.getLevel().intLevel() > listener.getLevel().intLevel()) {
           break;
         }
@@ -165,14 +164,28 @@ public final class AlertAppender extends AbstractAppender implements
PropertyCha
     }
   }
 
-  public synchronized void addAlertListener(final DistributedMember member, final int alertLevel)
{
-    final Level level = LogService.toLevel(alertLevelToLogLevel(alertLevel));
+  @Override
+  public synchronized void propertyChange(final PropertyChangeEvent evt) {
+    if (logger.isDebugEnabled()) {
+      logger.debug("Responding to a property change event. Property name is {}.",
+          evt.getPropertyName());
+    }
+    if (evt.getPropertyName().equals(LoggerContext.PROPERTY_CONFIG)) {
+      LoggerConfig loggerConfig = this.appenderContext.getLoggerConfig();
+      if (!loggerConfig.getAppenders().containsKey(APPENDER_NAME)) {
+        loggerConfig.addAppender(this, this.listeners.get(0).getLevel(), null);
+      }
+    }
+  }
+
+  synchronized void addAlertSubscriber(final DistributedMember member, final int alertLevel)
{
+    final Level level = LogService.toLevel(AlertLevel.alertLevelToLogLevel(alertLevel));
 
     if (this.listeners.size() == 0) {
       this.appenderContext.getLoggerContext().addPropertyChangeListener(this);
     }
 
-    addListenerToSortedList(new Listener(level, member));
+    addListenerToSortedList(new AlertSubscriber(level, member));
 
     LoggerConfig loggerConfig = this.appenderContext.getLoggerConfig();
     loggerConfig.addAppender(this, this.listeners.get(0).getLevel(), null);
@@ -181,8 +194,8 @@ public final class AlertAppender extends AbstractAppender implements PropertyCha
     }
   }
 
-  public synchronized boolean removeAlertListener(final DistributedMember member) {
-    final boolean memberWasFound = this.listeners.remove(new Listener(null, member));
+  synchronized boolean removeAlertSubscriber(final DistributedMember member) {
+    final boolean memberWasFound = this.listeners.remove(new AlertSubscriber(null, member));
 
     if (memberWasFound) {
       if (this.listeners.size() == 0) {
@@ -201,11 +214,10 @@ public final class AlertAppender extends AbstractAppender implements
PropertyCha
     return memberWasFound;
   }
 
-  public synchronized boolean hasAlertListener(final DistributedMember member,
-      final int alertLevel) {
-    final Level level = LogService.toLevel(alertLevelToLogLevel(alertLevel));
+  synchronized boolean hasAlertSubscriber(final DistributedMember member, final int alertLevel)
{
+    final Level level = LogService.toLevel(AlertLevel.alertLevelToLogLevel(alertLevel));
 
-    for (Listener listener : this.listeners) {
+    for (AlertSubscriber listener : this.listeners) {
       if (listener.getMember().equals(member) && listener.getLevel().equals(level))
{
         return true;
       }
@@ -215,7 +227,7 @@ public final class AlertAppender extends AbstractAppender implements PropertyCha
     // listener with
     // this level (see AlertLevelChangeMessage.process()).
     if (alertLevel == Alert.OFF) {
-      for (Listener listener : this.listeners) {
+      for (AlertSubscriber listener : this.listeners) {
         if (listener.getMember().equals(member)) {
           return false;
         }
@@ -226,27 +238,19 @@ public final class AlertAppender extends AbstractAppender implements
PropertyCha
     return false;
   }
 
-  @Override
-  public synchronized void propertyChange(final PropertyChangeEvent evt) {
-    if (logger.isDebugEnabled()) {
-      logger.debug("Responding to a property change event. Property name is {}.",
-          evt.getPropertyName());
-    }
-    if (evt.getPropertyName().equals(LoggerContext.PROPERTY_CONFIG)) {
-      LoggerConfig loggerConfig = this.appenderContext.getLoggerConfig();
-      if (!loggerConfig.getAppenders().containsKey(APPENDER_NAME)) {
-        loggerConfig.addAppender(this, this.listeners.get(0).getLevel(), null);
-      }
-    }
+  synchronized void shuttingDown() {
+    this.listeners.clear();
+    this.appenderContext.getLoggerContext().removePropertyChangeListener(this);
+    this.appenderContext.getLoggerConfig().removeAppender(APPENDER_NAME);
   }
 
   /**
    * Will add (or replace) a listener to the list of sorted listeners such that listeners
with a
    * narrower level (e.g. FATAL) will be at the end of the list.
-   * 
+   *
    * @param listener The listener to add to the list.
    */
-  private void addListenerToSortedList(final Listener listener) {
+  private void addListenerToSortedList(final AlertSubscriber listener) {
     if (this.listeners.contains(listener)) {
       this.listeners.remove(listener);
     }
@@ -262,61 +266,18 @@ public final class AlertAppender extends AbstractAppender implements
PropertyCha
   }
 
   /**
-   * Converts an int alert level to an int log level.
-   * 
-   * @param alertLevel The int value for the alert level
-   * @return The int value for the matching log level
-   * @throws java.lang.IllegalArgumentException If there is no matching log level
+   * Simple value object which holds an InteralDistributedMember and Level pair.
    */
-  public static int alertLevelToLogLevel(final int alertLevel) {
-    switch (alertLevel) {
-      case Alert.SEVERE:
-        return Level.FATAL.intLevel();
-      case Alert.ERROR:
-        return Level.ERROR.intLevel();
-      case Alert.WARNING:
-        return Level.WARN.intLevel();
-      case Alert.OFF:
-        return Level.OFF.intLevel();
-    }
-
-    throw new IllegalArgumentException("Unknown Alert level [" + alertLevel + "].");
-  }
+  static class AlertSubscriber {
+    
+    private final Level level;
+    private final DistributedMember member;
 
-  /**
-   * Converts an int log level to an int alert level.
-   * 
-   * @param logLevel The int value for the log level
-   * @return The int value for the matching alert level
-   * @throws java.lang.IllegalArgumentException If there is no matching log level
-   */
-  public static int logLevelToAlertLevel(final int logLevel) {
-    if (logLevel == Level.FATAL.intLevel()) {
-      return Alert.SEVERE;
-    } else if (logLevel == Level.ERROR.intLevel()) {
-      return Alert.ERROR;
-    } else if (logLevel == Level.WARN.intLevel()) {
-      return Alert.WARNING;
-    } else if (logLevel == Level.OFF.intLevel()) {
-      return Alert.OFF;
+    AlertSubscriber(final Level level, final DistributedMember member) {
+      this.level = level;
+      this.member = member;
     }
 
-    throw new IllegalArgumentException("Unknown Log level [" + logLevel + "].");
-  }
-
-  public synchronized void shuttingDown() {
-    this.listeners.clear();
-    this.appenderContext.getLoggerContext().removePropertyChangeListener(this);
-    this.appenderContext.getLoggerConfig().removeAppender(APPENDER_NAME);
-  }
-
-  /**
-   * Simple value object which holds an InteralDistributedMember and Level pair.
-   */
-  static class Listener {
-    private Level level;
-    private DistributedMember member;
-
     public Level getLevel() {
       return this.level;
     }
@@ -325,11 +286,6 @@ public final class AlertAppender extends AbstractAppender implements
PropertyCha
       return this.member;
     }
 
-    Listener(final Level level, final DistributedMember member) {
-      this.level = level;
-      this.member = member;
-    }
-
     /**
      * Never used, but maintain the hashCode/equals contract.
      */
@@ -343,7 +299,7 @@ public final class AlertAppender extends AbstractAppender implements PropertyCha
      */
     @Override
     public boolean equals(Object other) {
-      return (this.member.equals(((Listener) other).member)) ? true : false;
+      return (this.member.equals(((AlertSubscriber) other).member)) ? true : false;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/geode/blob/66767ae2/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/AlertLevel.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/AlertLevel.java
b/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/AlertLevel.java
new file mode 100644
index 0000000..8ad71c7
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/AlertLevel.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geode.internal.logging.log4j;
+
+import org.apache.logging.log4j.Level;
+
+import org.apache.geode.internal.admin.Alert;
+
+public class AlertLevel {
+
+  /**
+   * Converts an int alert level to an int log level.
+   *
+   * @param alertLevel The int value for the alert level
+   * @return The int value for the matching log level
+   * @throws IllegalArgumentException If there is no matching log level
+   */
+  public static int alertLevelToLogLevel(final int alertLevel) {
+    switch (alertLevel) {
+      case Alert.SEVERE:
+        return Level.FATAL.intLevel();
+      case Alert.ERROR:
+        return Level.ERROR.intLevel();
+      case Alert.WARNING:
+        return Level.WARN.intLevel();
+      case Alert.OFF:
+        return Level.OFF.intLevel();
+    }
+
+    throw new IllegalArgumentException("Unknown Alert level [" + alertLevel + "].");
+  }
+
+  /**
+   * Converts an int log level to an int alert level.
+   *
+   * @param logLevel The int value for the log level
+   * @return The int value for the matching alert level
+   * @throws IllegalArgumentException If there is no matching log level
+   */
+  public static int logLevelToAlertLevel(final int logLevel) {
+    if (logLevel == Level.FATAL.intLevel()) {
+      return Alert.SEVERE;
+    } else if (logLevel == Level.ERROR.intLevel()) {
+      return Alert.ERROR;
+    } else if (logLevel == Level.WARN.intLevel()) {
+      return Alert.WARNING;
+    } else if (logLevel == Level.OFF.intLevel()) {
+      return Alert.OFF;
+    }
+
+    throw new IllegalArgumentException("Unknown Log level [" + logLevel + "].");
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/66767ae2/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/AlertService.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/AlertService.java
b/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/AlertService.java
new file mode 100644
index 0000000..c76ba0d
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/AlertService.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geode.internal.logging.log4j;
+
+import org.apache.geode.distributed.DistributedMember;
+
+public class AlertService {
+
+  private static final AlertService instance = createAlertService();
+
+  private final AlertAppender alertAppender;
+
+  private static AlertService createAlertService() {
+    AlertService alertService = new AlertService(AlertAppender.getInstance());
+    return alertService;
+  }
+
+  public static AlertService getAlertService() {
+    return instance;
+  }
+
+  private AlertService(final AlertAppender alertAppender) {
+    this.alertAppender = alertAppender;
+  }
+
+  public static void addAlertSubscriber(final DistributedMember member, final int alertLevel)
{
+    getAlertService().alertAppender.addAlertSubscriber(member, alertLevel);
+  }
+
+  public static boolean removeAlertSubscriber(final DistributedMember member) {
+    return getAlertService().alertAppender.removeAlertSubscriber(member);
+  }
+
+  public static boolean hasAlertSubscriber(final DistributedMember member, final int alertLevel)
{
+    return getAlertService().alertAppender.hasAlertSubscriber(member, alertLevel);
+  }
+
+  /**
+   * TODO: change to be called by new geode lifecycle callbacks
+   */
+  public static void shuttingDown() {
+    getAlertService().alertAppender.shuttingDown();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/66767ae2/geode-core/src/main/java/org/apache/geode/management/internal/ManagerStartupMessage.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/ManagerStartupMessage.java
b/geode-core/src/main/java/org/apache/geode/management/internal/ManagerStartupMessage.java
index fa3b382..eb1f8b0 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/ManagerStartupMessage.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/ManagerStartupMessage.java
@@ -20,15 +20,12 @@ import java.io.IOException;
 
 import org.apache.geode.distributed.internal.DistributionManager;
 import org.apache.geode.distributed.internal.PooledDistributionMessage;
-import org.apache.geode.i18n.LogWriterI18n;
 import org.apache.geode.internal.admin.Alert;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.internal.logging.ManagerLogWriter;
-import org.apache.geode.internal.logging.log4j.AlertAppender;
+import org.apache.geode.internal.logging.log4j.AlertService;
 
 public class ManagerStartupMessage extends PooledDistributionMessage {
   // instance variables
-  int alertLevel;
+  private int alertLevel;
 
   public static ManagerStartupMessage create(int level) {
     ManagerStartupMessage m = new ManagerStartupMessage();
@@ -42,9 +39,8 @@ public class ManagerStartupMessage extends PooledDistributionMessage {
 
   @Override
   public void process(DistributionManager dm) {
-
     if (this.alertLevel != Alert.OFF) {
-      AlertAppender.getInstance().addAlertListener(this.getSender(), this.alertLevel);
+      AlertService.addAlertSubscriber(getSender(), this.alertLevel);
     }
   }
 
@@ -69,5 +65,4 @@ public class ManagerStartupMessage extends PooledDistributionMessage {
     return "ManagerStartupMessage from " + this.getSender() + " level=" + alertLevel;
   }
 
-
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/66767ae2/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/AlertAppenderJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/AlertAppenderJUnitTest.java
b/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/AlertAppenderJUnitTest.java
index 5717253..da9bf39 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/AlertAppenderJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/AlertAppenderJUnitTest.java
@@ -35,6 +35,7 @@ import org.apache.geode.distributed.DurableClientAttributes;
 import org.apache.geode.distributed.Role;
 import org.apache.geode.internal.admin.Alert;
 import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.internal.logging.log4j.AlertAppender.AlertSubscriber;
 import org.apache.geode.test.junit.categories.UnitTest;
 
 /**
@@ -56,7 +57,7 @@ public class AlertAppenderJUnitTest {
     LogService.setBaseLogLevel(this.previousLogLevel);
     if (!this.members.isEmpty()) {
       for (DistributedMember member : this.members) {
-        AlertAppender.getInstance().removeAlertListener(member);
+        AlertAppender.getInstance().removeAlertSubscriber(member);
       }
       this.members.clear();
     }
@@ -80,19 +81,19 @@ public class AlertAppenderJUnitTest {
 
     LogService.setBaseLogLevel(Level.WARN);
 
-    AlertAppender.getInstance().addAlertListener(member1, Alert.SEVERE);
-    AlertAppender.getInstance().addAlertListener(member2, Alert.WARNING);
-    AlertAppender.getInstance().addAlertListener(member3, Alert.ERROR);
-    AlertAppender.getInstance().addAlertListener(member4, Alert.ERROR);
-    AlertAppender.getInstance().addAlertListener(member5, Alert.WARNING);
-    AlertAppender.getInstance().addAlertListener(member6, Alert.SEVERE);
+    AlertAppender.getInstance().addAlertSubscriber(member1, Alert.SEVERE);
+    AlertAppender.getInstance().addAlertSubscriber(member2, Alert.WARNING);
+    AlertAppender.getInstance().addAlertSubscriber(member3, Alert.ERROR);
+    AlertAppender.getInstance().addAlertSubscriber(member4, Alert.ERROR);
+    AlertAppender.getInstance().addAlertSubscriber(member5, Alert.WARNING);
+    AlertAppender.getInstance().addAlertSubscriber(member6, Alert.SEVERE);
 
     Field listenersField = AlertAppender.getInstance().getClass().getDeclaredField("listeners");
     listenersField.setAccessible(true);
 
     @SuppressWarnings("unchecked")
-    final CopyOnWriteArrayList<AlertAppender.Listener> listeners =
-        (CopyOnWriteArrayList<AlertAppender.Listener>) listenersField
+    final CopyOnWriteArrayList<AlertSubscriber> listeners =
+        (CopyOnWriteArrayList<AlertSubscriber>) listenersField
             .get(AlertAppender.getInstance());
 
     // Verify add
@@ -105,7 +106,7 @@ public class AlertAppenderJUnitTest {
     assertSame(6, listeners.size());
 
     // Verify replace with same level
-    AlertAppender.getInstance().addAlertListener(member5, Alert.WARNING);
+    AlertAppender.getInstance().addAlertSubscriber(member5, Alert.WARNING);
     assertSame(member5, listeners.get(0).getMember());
     assertSame(member2, listeners.get(1).getMember());
     assertSame(member4, listeners.get(2).getMember());
@@ -115,7 +116,7 @@ public class AlertAppenderJUnitTest {
     assertSame(6, listeners.size());
 
     // Verify replace with difference level
-    AlertAppender.getInstance().addAlertListener(member5, Alert.SEVERE);
+    AlertAppender.getInstance().addAlertSubscriber(member5, Alert.SEVERE);
     assertSame(member2, listeners.get(0).getMember());
     assertSame(member4, listeners.get(1).getMember());
     assertSame(member3, listeners.get(2).getMember());
@@ -125,7 +126,7 @@ public class AlertAppenderJUnitTest {
     assertSame(6, listeners.size());
 
     // Verify remove
-    assertTrue(AlertAppender.getInstance().removeAlertListener(member3));
+    assertTrue(AlertAppender.getInstance().removeAlertSubscriber(member3));
     assertSame(member2, listeners.get(0).getMember());
     assertSame(member4, listeners.get(1).getMember());
     assertSame(member5, listeners.get(2).getMember());
@@ -133,12 +134,12 @@ public class AlertAppenderJUnitTest {
     assertSame(member1, listeners.get(4).getMember());
     assertSame(5, listeners.size());
 
-    assertTrue(AlertAppender.getInstance().removeAlertListener(member1));
-    assertTrue(AlertAppender.getInstance().removeAlertListener(member2));
-    assertFalse(AlertAppender.getInstance().removeAlertListener(member3));
-    assertTrue(AlertAppender.getInstance().removeAlertListener(member4));
-    assertTrue(AlertAppender.getInstance().removeAlertListener(member5));
-    assertTrue(AlertAppender.getInstance().removeAlertListener(member6));
+    assertTrue(AlertAppender.getInstance().removeAlertSubscriber(member1));
+    assertTrue(AlertAppender.getInstance().removeAlertSubscriber(member2));
+    assertFalse(AlertAppender.getInstance().removeAlertSubscriber(member3));
+    assertTrue(AlertAppender.getInstance().removeAlertSubscriber(member4));
+    assertTrue(AlertAppender.getInstance().removeAlertSubscriber(member5));
+    assertTrue(AlertAppender.getInstance().removeAlertSubscriber(member6));
   }
 
   /**
@@ -159,14 +160,14 @@ public class AlertAppenderJUnitTest {
 
     // Add a listener and verify that the appender was added to log4j
     DistributedMember member1 = createTestDistributedMember("Member1");
-    AlertAppender.getInstance().addAlertListener(member1, Alert.SEVERE);
+    AlertAppender.getInstance().addAlertSubscriber(member1, Alert.SEVERE);
     assertEquals(loggerConfig.getAppenders().values().toString(), startingSize + 1,
         loggerConfig.getAppenders().size());
     assertTrue(loggerConfig.getAppenders().containsKey(appenderName));
 
     // Add another listener and verify that there's still only 1 alert appender
     DistributedMember member2 = createTestDistributedMember("Member1");
-    AlertAppender.getInstance().addAlertListener(member2, Alert.SEVERE);
+    AlertAppender.getInstance().addAlertSubscriber(member2, Alert.SEVERE);
     assertEquals(startingSize + 1, loggerConfig.getAppenders().size());
 
     // Modify the config and verify that the appender still exists
@@ -180,8 +181,8 @@ public class AlertAppenderJUnitTest {
     assertTrue(loggerConfig.getAppenders().containsKey(appenderName));
 
     // Remove the listeners and verify that the appender was removed from log4j
-    assertTrue(AlertAppender.getInstance().removeAlertListener(member2));
-    assertFalse(AlertAppender.getInstance().removeAlertListener(member1));
+    assertTrue(AlertAppender.getInstance().removeAlertSubscriber(member2));
+    assertFalse(AlertAppender.getInstance().removeAlertSubscriber(member1));
     assertEquals(startingSize, loggerConfig.getAppenders().size());
     assertFalse(loggerConfig.getAppenders().containsKey(appenderName));
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/66767ae2/geode-core/src/test/java/org/apache/geode/management/DistributedSystemDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/DistributedSystemDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/management/DistributedSystemDUnitTest.java
index 4eaba67..2827650 100644
--- a/geode-core/src/test/java/org/apache/geode/management/DistributedSystemDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/DistributedSystemDUnitTest.java
@@ -19,8 +19,7 @@ import org.junit.Test;
 
 import static org.junit.Assert.*;
 
-import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
+import org.apache.geode.internal.logging.log4j.AlertService;
 import org.apache.geode.test.junit.categories.DistributedTest;
 
 import java.util.ArrayList;
@@ -47,7 +46,6 @@ import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.internal.admin.Alert;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.internal.logging.log4j.AlertAppender;
 import org.apache.geode.management.internal.AlertDetails;
 import org.apache.geode.management.internal.MBeanJMXAdapter;
 import org.apache.geode.management.internal.ManagementConstants;
@@ -215,7 +213,7 @@ public class DistributedSystemDUnitTest extends ManagementTestBase {
 
             public boolean done() {
 
-              if (AlertAppender.getInstance().hasAlertListener(member, alertLevel)) {
+              if (AlertService.hasAlertSubscriber(member, alertLevel)) {
                 return true;
               }
               return false;


Mime
View raw message