logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1187195 - /logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java
Date Fri, 21 Oct 2011 07:47:21 GMT
Author: rgoers
Date: Fri Oct 21 07:47:21 2011
New Revision: 1187195

URL: http://svn.apache.org/viewvc?rev=1187195&view=rev
Log:
Use floating point for rate

Modified:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java?rev=1187195&r1=1187194&r2=1187195&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/BurstFilter.java
Fri Oct 21 07:47:21 2011
@@ -77,10 +77,10 @@ public class BurstFilter extends FilterB
 
     private final Queue<LogDelay> available = new ConcurrentLinkedQueue<LogDelay>();
 
-    private BurstFilter(Level level, long rate, long maxBurst, Result onMatch, Result onMismatch)
{
+    private BurstFilter(Level level, float rate, long maxBurst, Result onMatch, Result onMismatch)
{
         super(onMatch, onMismatch);
         this.level = level;
-        this.burstInterval = maxBurst / rate;
+        this.burstInterval = (long) (NANOS_IN_SECONDS * (maxBurst / rate));
         for (int i = 0; i < maxBurst; ++i) {
             available.add(new LogDelay());
         }
@@ -160,7 +160,7 @@ public class BurstFilter extends FilterB
         }
 
         public void setDelay(long delay) {
-            this.expireTime = (delay * NANOS_IN_SECONDS) + System.nanoTime();
+            this.expireTime = delay + System.nanoTime();
         }
 
         public long getDelay(TimeUnit timeUnit) {
@@ -218,8 +218,11 @@ public class BurstFilter extends FilterB
         Result onMatch = match == null ? null : Result.valueOf(match);
         Result onMismatch = mismatch == null ? null : Result.valueOf(mismatch);
         Level lvl = Level.toLevel(level, Level.WARN);
-        long eventRate = rate == null ? DEFAULT_RATE : Long.parseLong(rate);
-        long max = maxBurst == null ? eventRate * DEFAULT_RATE_MULTIPLE : Long.parseLong(maxBurst);
+        float eventRate = rate == null ? DEFAULT_RATE : Float.parseFloat(rate);
+        if (eventRate <= 0) {
+            eventRate = DEFAULT_RATE;
+        }
+        long max = maxBurst == null ? (long) (eventRate * DEFAULT_RATE_MULTIPLE) : Long.parseLong(maxBurst);
         if (onMatch == null) {
             onMatch = Result.NEUTRAL;
         }



Mime
View raw message