[강운덕] [PINPOINT-258] timestamp를 Range객체로 묶어서 다니도록 수정함.

git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-web/trunk@3302 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
Woonduk Kang
2014-02-10 07:46:59 +00:00
parent 8ae0b0d089
commit 5bda613ae4
5 changed files with 59 additions and 7 deletions
@@ -53,21 +53,20 @@ public class HbaseAgentStatDao implements AgentStatDao {
if (agentId == null) {
throw new NullPointerException("agentId must not be null");
}
if (range == null) {
throw new NullPointerException("range must not be null");
}
if (logger.isDebugEnabled()) {
logger.debug("scanAgentStat : agentId={}, {}", agentId, range);
}
if (range.getTo() < range.getFrom()) {
logger.error("invalid parameter : agentId={}, {}", agentId, range);
return Collections.emptyList();
}
Scan scan = createScan(agentId, range);
List<List<TAgentStat>> intermediate = hbaseOperations2.find(HBaseTables.AGENT_STAT, scan, rowKeyDistributor, agentStatMapper);
int expectedSize = (int)((range.getTo() - range.getFrom()) / 5000); // 5초간 데이터
int expectedSize = (int)(range.getRange() / 5000); // 5초간 데이터
List<TAgentStat> merged = new ArrayList<TAgentStat>(expectedSize);
for(List<TAgentStat> each : intermediate) {
@@ -48,7 +48,13 @@ public class HbaseApplicationMapStatisticsCallerDao implements ApplicationMapSta
@Override
public List<TransactionFlowStatistics> selectCaller(Application calleeApplication, Range range) {
Scan scan = createScan(calleeApplication, range);
if (calleeApplication == null) {
throw new NullPointerException("calleeApplication must not be null");
}
if (range == null) {
throw new NullPointerException("range must not be null");
}
Scan scan = createScan(calleeApplication, range);
final List<List<TransactionFlowStatistics>> foundListList = hbaseOperations2.find(HBaseTables.APPLICATION_MAP_STATISTICS_CALLER, scan, applicationMapStatisticsCallerMapper);
if (foundListList.isEmpty()) {
@@ -63,6 +63,9 @@ public class HbaseApplicationTraceIndexDao implements ApplicationTraceIndexDao {
if (applicationName == null) {
throw new NullPointerException("applicationName must not be null");
}
if (range == null) {
throw new NullPointerException("range must not be null");
}
if (limit < 0) {
throw new IllegalArgumentException("negative limit:" + limit);
}
@@ -149,6 +152,9 @@ public class HbaseApplicationTraceIndexDao implements ApplicationTraceIndexDao {
if (applicationName == null) {
throw new NullPointerException("applicationName must not be null");
}
if (range == null) {
throw new NullPointerException("range must not be null");
}
if (limit < 0) {
throw new IllegalArgumentException("negative limit:" + limit);
}
@@ -10,6 +10,7 @@ public final class Range {
public Range(long from, long to) {
this.from = from;
this.to = to;
isValidate();
}
public long getFrom() {
@@ -20,6 +21,15 @@ public final class Range {
return to;
}
public long getRange() {
return to - from;
}
private void isValidate() {
if (this.to < this.from) {
throw new IllegalArgumentException("invalid range:" + this);
}
}
@Override
public boolean equals(Object o) {
@@ -0,0 +1,31 @@
package com.nhn.pinpoint.web.vo;
import junit.framework.Assert;
import org.junit.Test;
/**
* @author emeroad
*/
public class RangeTest {
@Test
public void testCreate() {
Range range1 = new Range(0, 0);
Range range2 = new Range(0, 1);
try {
Range range3 = new Range(0, -1);
Assert.fail();
} catch (Exception e) {
}
}
@Test
public void testRange() {
Range range1 = new Range(0, 0);
Assert.assertEquals(range1.getRange(), 0);
Range range2 = new Range(0, 1);
Assert.assertEquals(range2.getRange(), 1);
}
}