Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…uestCounterTest
  • Loading branch information...
commit fd3367629ce2d5c950a227f0723e45e5db974e7b 1 parent 8b53cc0
Chinmay Soman authored
View
6 src/java/voldemort/store/stats/Histogram.java
@@ -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++;
View
28 test/unit/voldemort/store/stats/RequestCounterTest.java
@@ -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);
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.