Permalink
Browse files

Added a log instead of Voldemort exception in Histogram and added Req…

…uestCounterTest
  • Loading branch information...
1 parent 8b53cc0 commit fd3367629ce2d5c950a227f0723e45e5db974e7b Chinmay Soman committed Mar 21, 2012
@@ -2,7 +2,8 @@
import java.util.Arrays;
-import voldemort.VoldemortException;
+import org.apache.log4j.Logger;
+
import voldemort.annotations.concurrency.Threadsafe;
/**
@@ -20,6 +21,7 @@
private final int[] buckets;
private final int[] bounds;
private int size;
+ private static final Logger logger = Logger.getLogger(Histogram.class);
/**
* Initialize an empty histogram
@@ -60,7 +62,7 @@ public synchronized void reset() {
public synchronized void insert(long data) {
int index = findBucket(data);
if(index == -1) {
- throw new VoldemortException(data + " can't be bucketed, is invalid!");
+ logger.error(data + " can't be bucketed, is invalid!");
}
buckets[index]++;
size++;
@@ -0,0 +1,28 @@
+package voldemort.store.stats;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class RequestCounterTest {
+
+ private RequestCounter requestCounter;
+
+ @Before
+ public void setUp() {
+ // Initialize the RequestCounter with a histogram
+ requestCounter = new RequestCounter(10000, true);
+ }
+
+ @Test
+ public void test() {
+ long val = 234;
+ requestCounter.addRequest(val);
+ }
+
+ @Test
+ public void testLargeValues() {
+ long val = 999999992342756424l;
+ requestCounter.addRequest(val);
+ }
+
+}

0 comments on commit fd33676

Please sign in to comment.