logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1501364 - /logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/FailoverAppender.java
Date Tue, 09 Jul 2013 16:19:45 GMT
Author: ggregory
Date: Tue Jul  9 16:19:45 2013
New Revision: 1501364

URL: http://svn.apache.org/r1501364
Log:
Better var names (add scale).

Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/FailoverAppender.java

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/FailoverAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/FailoverAppender.java?rev=1501364&r1=1501363&r2=1501364&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/FailoverAppender.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/FailoverAppender.java
Tue Jul  9 16:19:45 2013
@@ -45,7 +45,7 @@ import org.apache.logging.log4j.core.hel
 @Plugin(name = "Failover", category = "Core", elementType = "appender", printObject = true)
 public final class FailoverAppender<T extends Serializable> extends AbstractAppender<T>
{
 
-    private static final int DEFAULT_INTERVAL = 60 * Constants.MILLIS_IN_SECONDS;
+    private static final int DEFAULT_INTERVAL_MILLIS = 60 * Constants.MILLIS_IN_SECONDS;
 
     private final String primaryRef;
 
@@ -57,19 +57,19 @@ public final class FailoverAppender<T ex
 
     private final List<AppenderControl<?>> failoverAppenders = new ArrayList<AppenderControl<?>>();
 
-    private final long interval;
+    private final long intervalMillis;
 
-    private long nextCheck = 0;
+    private long nextCheckMillis = 0;
 
     private volatile boolean failure = false;
 
     private FailoverAppender(final String name, final Filter filter, final String primary,
final String[] failovers,
-                             final int interval, final Configuration config, final boolean
handleExceptions) {
+                             final int intervalMillis, final Configuration config, final
boolean handleExceptions) {
         super(name, filter, null, handleExceptions);
         this.primaryRef = primary;
         this.failovers = failovers;
         this.config = config;
-        this.interval = interval;
+        this.intervalMillis = intervalMillis;
     }
 
 
@@ -113,8 +113,8 @@ public final class FailoverAppender<T ex
         if (!failure) {
             callAppender(event);
         } else {
-            final long current = System.currentTimeMillis();
-            if (current >= nextCheck) {
+            final long currentMillis = System.currentTimeMillis();
+            if (currentMillis >= nextCheckMillis) {
                 callAppender(event);
             } else {
                 failover(event, null);
@@ -126,7 +126,7 @@ public final class FailoverAppender<T ex
         try {
             primary.callAppender(event);
         } catch (final Exception ex) {
-            nextCheck = System.currentTimeMillis() + interval;
+            nextCheckMillis = System.currentTimeMillis() + intervalMillis;
             failure = true;
             failover(event, ex);
         }
@@ -177,7 +177,7 @@ public final class FailoverAppender<T ex
      * @param name The name of the Appender (required).
      * @param primary The name of the primary Appender (required).
      * @param failovers The name of one or more Appenders to fail over to (at least one is
required).
-     * @param interval The retry interval.
+     * @param intervalSeconds The retry intervalMillis.
      * @param config The current Configuration (passed by the Configuration when the appender
is created).
      * @param filter A Filter (optional).
      * @param suppress "true" if exceptions should be hidden from the application, "false"
otherwise.
@@ -189,7 +189,7 @@ public final class FailoverAppender<T ex
     public static <S extends Serializable> FailoverAppender<S> createAppender(@PluginAttr("name")
final String name,
                                                   @PluginAttr("primary") final String primary,
                                                   @PluginElement("failovers") final String[]
failovers,
-                                                  @PluginAttr("retryInterval") final String
interval,
+                                                  @PluginAttr("retryInterval") final String
intervalSeconds,
                                                   @PluginConfiguration final Configuration
config,
                                                   @PluginElement("filters") final Filter
filter,
                                                   @PluginAttr("suppressExceptions") final
String suppress) {
@@ -206,26 +206,26 @@ public final class FailoverAppender<T ex
             return null;
         }
 
-        int retryInterval;
-        if (Strings.isEmpty(interval)) {
-            retryInterval = DEFAULT_INTERVAL;
+        int retryIntervalMillis;
+        if (Strings.isEmpty(intervalSeconds)) {
+            retryIntervalMillis = DEFAULT_INTERVAL_MILLIS;
         } else {
             try {
-                final int value = Integer.parseInt(interval);
-                if (value >= 0) {
-                    retryInterval = value * Constants.MILLIS_IN_SECONDS;
+                final int seconds = Integer.parseInt(intervalSeconds);
+                if (seconds >= 0) {
+                    retryIntervalMillis = seconds * Constants.MILLIS_IN_SECONDS;
                 } else {
-                    LOGGER.warn("Interval " + interval + " is less than zero. Using default");
-                    retryInterval = DEFAULT_INTERVAL;
+                    LOGGER.warn("Interval " + intervalSeconds + " is less than zero. Using
default");
+                    retryIntervalMillis = DEFAULT_INTERVAL_MILLIS;
                 }
             } catch (final NumberFormatException nfe) {
-                LOGGER.error("Interval " + interval + " is non-numeric. Using default");
-                retryInterval = DEFAULT_INTERVAL;
+                LOGGER.error("Interval " + intervalSeconds + " is non-numeric. Using default");
+                retryIntervalMillis = DEFAULT_INTERVAL_MILLIS;
             }
         }
 
         final boolean handleExceptions = suppress == null ? true : Boolean.valueOf(suppress);
 
-        return new FailoverAppender<S>(name, filter, primary, failovers, retryInterval,
config, handleExceptions);
+        return new FailoverAppender<S>(name, filter, primary, failovers, retryIntervalMillis,
config, handleExceptions);
     }
 }



Mime
View raw message