You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2016/03/04 15:22:48 UTC

[10/50] [abbrv] logging-log4j2 git commit: Formatting nit.

Formatting nit.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/88f04e3e
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/88f04e3e
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/88f04e3e

Branch: refs/heads/LOG4J2-1278-gc-free-logger
Commit: 88f04e3ea027d86490a96c2c0ef594a65fd565b1
Parents: 7da2fa1
Author: Matt Sicker <bo...@gmail.com>
Authored: Tue Mar 1 09:35:38 2016 -0600
Committer: Matt Sicker <bo...@gmail.com>
Committed: Tue Mar 1 09:35:38 2016 -0600

----------------------------------------------------------------------
 .../core/appender/routing/IdlePurgePolicy.java  | 98 ++++++++++----------
 1 file changed, 48 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/88f04e3e/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/IdlePurgePolicy.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/IdlePurgePolicy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/IdlePurgePolicy.java
index fc1921d..fe62783 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/IdlePurgePolicy.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/IdlePurgePolicy.java
@@ -35,9 +35,7 @@ import org.apache.logging.log4j.core.config.plugins.PluginFactory;
 import org.apache.logging.log4j.status.StatusLogger;
 
 /**
- * 
  * Policy is purging appenders that were not in use specified time in minutes
- *
  */
 @Plugin(name = "IdlePurgePolicy", category = "Core", printObject = true)
 @Scheduled
@@ -46,20 +44,20 @@ public class IdlePurgePolicy extends AbstractLifeCycle implements PurgePolicy, R
     private static final Logger LOGGER = StatusLogger.getLogger();
     private static final long serialVersionUID = 7481062062560624564L;
     private final long timeToLive;
-	private final ConcurrentMap<String, Long> appendersUsage = new ConcurrentHashMap<>();
-	private RoutingAppender routingAppender;
+    private final ConcurrentMap<String, Long> appendersUsage = new ConcurrentHashMap<>();
+    private RoutingAppender routingAppender;
     private final ConfigurationScheduler scheduler;
     private volatile ScheduledFuture<?> future = null;
-    
-	public IdlePurgePolicy(long timeToLive, ConfigurationScheduler scheduler) {
-		this.timeToLive = timeToLive;
+
+    public IdlePurgePolicy(long timeToLive, ConfigurationScheduler scheduler) {
+        this.timeToLive = timeToLive;
         this.scheduler = scheduler;
-	}	
+    }
 
     @Override
-	public void initialize(RoutingAppender routingAppender) {
-		this.routingAppender = routingAppender;
-	}
+    public void initialize(RoutingAppender routingAppender) {
+        this.routingAppender = routingAppender;
+    }
 
     @Override
     public void stop() {
@@ -67,35 +65,34 @@ public class IdlePurgePolicy extends AbstractLifeCycle implements PurgePolicy, R
         future.cancel(true);
     }
 
-	/**
-	 * Purging appenders that were not in use specified time
-	 * 
-	 */
-	@Override
-	public void purge() {
-		long createTime = System.currentTimeMillis() - timeToLive;
-    	for (Entry<String, Long> entry : appendersUsage.entrySet()) {
-			if (entry.getValue() < createTime) {
+    /**
+     * Purging appenders that were not in use specified time
+     */
+    @Override
+    public void purge() {
+        long createTime = System.currentTimeMillis() - timeToLive;
+        for (Entry<String, Long> entry : appendersUsage.entrySet()) {
+            if (entry.getValue() < createTime) {
                 LOGGER.debug("Removing appender " + entry.getKey());
-				appendersUsage.remove(entry.getKey());
-		       	routingAppender.deleteAppender(entry.getKey());
-			}
-		}
-	}
-
-	@Override
-	public void update(String key, LogEvent event) {
+                appendersUsage.remove(entry.getKey());
+                routingAppender.deleteAppender(entry.getKey());
+            }
+        }
+    }
+
+    @Override
+    public void update(String key, LogEvent event) {
         long now = System.currentTimeMillis();
-		appendersUsage.put(key, now);
+        appendersUsage.put(key, now);
         if (future == null) {
-            synchronized(this) {
+            synchronized (this) {
                 if (future == null) {
                     scheduleNext();
                 }
             }
         }
 
-	}
+    }
 
     @Override
     public void run() {
@@ -116,37 +113,38 @@ public class IdlePurgePolicy extends AbstractLifeCycle implements PurgePolicy, R
         }
     }
 
-	/**
+    /**
      * Create the PurgePolicy
+     *
      * @param timeToLive the number of increments of timeUnit before the Appender should be purged.
-     * @param timeUnit the unit of time the timeToLive is expressed in.
+     * @param timeUnit   the unit of time the timeToLive is expressed in.
      * @return The Routes container.
      */
     @PluginFactory
     public static PurgePolicy createPurgePolicy(
-            @PluginAttribute("timeToLive") final String timeToLive,
-			@PluginAttribute("timeUnit") final String timeUnit,
-            @PluginConfiguration Configuration configuration) {
-    	
+        @PluginAttribute("timeToLive") final String timeToLive,
+        @PluginAttribute("timeUnit") final String timeUnit,
+        @PluginConfiguration Configuration configuration) {
+
         if (timeToLive == null) {
             LOGGER.error("A timeToLive  value is required");
             return null;
         }
-		TimeUnit units;
-		if (timeUnit == null) {
-			units = TimeUnit.MINUTES;
-		} else {
-			try {
-				units = TimeUnit.valueOf(timeUnit.toUpperCase());
-			} catch(Exception ex) {
-				LOGGER.error("Invalid time unit {}", timeUnit);
-				units = TimeUnit.MINUTES;
-			}
-		}
-        
+        TimeUnit units;
+        if (timeUnit == null) {
+            units = TimeUnit.MINUTES;
+        } else {
+            try {
+                units = TimeUnit.valueOf(timeUnit.toUpperCase());
+            } catch (Exception ex) {
+                LOGGER.error("Invalid time unit {}", timeUnit);
+                units = TimeUnit.MINUTES;
+            }
+        }
+
         final long ttl = units.toMillis(Long.parseLong(timeToLive));
 
-        
+
         return new IdlePurgePolicy(ttl, configuration.getScheduler());
     }