Skip to content

Commit

Permalink
Added a log instead of Voldemort exception in Histogram and added Req…
Browse files Browse the repository at this point in the history
…uestCounterTest
  • Loading branch information
Chinmay Soman committed Mar 21, 2012
1 parent 8b53cc0 commit fd33676
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/java/voldemort/store/stats/Histogram.java
Expand Up @@ -2,7 +2,8 @@

import java.util.Arrays;

import voldemort.VoldemortException;
import org.apache.log4j.Logger;

import voldemort.annotations.concurrency.Threadsafe;

/**
Expand All @@ -20,6 +21,7 @@ public class Histogram {
private final int[] buckets;
private final int[] bounds;
private int size;
private static final Logger logger = Logger.getLogger(Histogram.class);

/**
* Initialize an empty histogram
Expand Down Expand Up @@ -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++;
Expand Down
28 changes: 28 additions & 0 deletions 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);
}

}

0 comments on commit fd33676

Please sign in to comment.