[강운덕] [LUCYSUS-1744] null체크 로직 강화.

git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-web/trunk@2815 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
Woonduk Kang
2013-11-06 09:29:49 +00:00
parent 2a9829854d
commit 9ddcb340af
9 changed files with 41 additions and 11 deletions
@@ -33,9 +33,13 @@ public class SpanAligner2 {
this.rootSpanId = findRootSpanId(spans, collectorAcceptTime);
}
private long findRootSpanId(List<SpanBo> spans, long collectorAcceptTime) {
private long findRootSpanId(List<SpanBo> spanList, long collectorAcceptTime) {
if (spanList == null) {
throw new NullPointerException("spanList must not be null");
}
final List<SpanBo> root = new ArrayList<SpanBo>();
for (SpanBo span : spans) {
for (SpanBo span : spanList) {
if (span.getParentSpanId() == ROOT) {
root.add(span);
}
@@ -51,7 +55,7 @@ public class SpanAligner2 {
}
// 버그 rootspan이 2개 이상인 경우는 로직 버그이다. 아무거나 잡아서 데이터를 뿌려줘야 되나?
if (rootSpanBoSize > 1) {
logger.warn("parentSpanId(-1) collision. size:{} root span:{} allSpan:{}", rootSpanBoSize, root, spans);
logger.warn("parentSpanId(-1) collision. size:{} root span:{} allSpan:{}", rootSpanBoSize, root, spanList);
throw new IllegalStateException("parentSpanId(-1) collision. size:" + rootSpanBoSize);
}
@@ -59,7 +63,7 @@ public class SpanAligner2 {
// 차선책으로 자신이 조회한 span의 시작 시간을 기준으로 span을 조회한다.
// span에서 데이터를 추출하는 것이기 때문에, 왠간하면 데이터는 존재함. hbase insert시 data insert를 실패할 경우 없을수 있음.
final List<SpanBo> collectorAcceptTimeMatcher = new ArrayList<SpanBo>();
for(SpanBo span : spans) {
for(SpanBo span : spanList) {
// collectorTime이 힌트로 들어온다.
if (span.getCollectorAcceptTime() == collectorAcceptTime) {
collectorAcceptTimeMatcher.add(span);
@@ -81,11 +85,11 @@ public class SpanAligner2 {
return spanBo.getSpanId();
}
if (startMatchSize > 1) {
logger.warn("collectorAcceptTime match collision. size:{} collectorAcceptTime:{} allSpan:{}", startMatchSize, collectorAcceptTime, spans);
logger.warn("collectorAcceptTime match collision. size:{} collectorAcceptTime:{} allSpan:{}", startMatchSize, collectorAcceptTime, spanList);
throw new IllegalStateException("startTime match collision size:" + startMatchSize + " collectorAcceptTime:" + collectorAcceptTime);
}
// 여기서 다음상황으로 더 정확하게 매치가 가능한가? 마땅히 call stack을 랜더링 할수 있는 방법 없음
logger.warn("collectorAcceptTime match not found. size:{} collectorAcceptTime:{} allSpan:{}", startMatchSize, collectorAcceptTime, spans);
logger.warn("collectorAcceptTime match not found. size:{} collectorAcceptTime:{} allSpan:{}", startMatchSize, collectorAcceptTime, spanList);
throw new IllegalStateException("startTime match not found startTime size:" + startMatchSize + " collectorAcceptTime:" + collectorAcceptTime);
}
@@ -62,9 +62,10 @@ public class FilteredApplicationMapController {
@RequestParam("to") long to,
@RequestParam(value = "filter", required = false) String filterText,
@RequestParam(value = "limit", required = false, defaultValue = "10000") int limit) {
limit = LimitUtils.checkRange(limit);
LimitedScanResult<List<TransactionId>> limitedScanResult = filteredApplicationMapService.selectTraceIdsFromApplicationTraceIndex(applicationName, from, to, limit);
Filter filter = filterBuilder.build(filterText);
final LimitedScanResult<List<TransactionId>> limitedScanResult = filteredApplicationMapService.selectTraceIdsFromApplicationTraceIndex(applicationName, from, to, limit);
final Filter filter = filterBuilder.build(filterText);
ApplicationMap map = filteredApplicationMapService.selectApplicationMap(limitedScanResult.getScanData(), from, to, filter);
@@ -104,6 +105,7 @@ public class FilteredApplicationMapController {
@RequestParam("period") long period,
@RequestParam(value = "filter", required = false) String filterText,
@RequestParam(value = "limit", required = false, defaultValue = "1000000") int limit) {
limit = LimitUtils.checkRange(limit);
long to = TimeUtils.getDelayLastTime();
long from = to - period;
@@ -128,6 +128,10 @@ public class HbaseAgentInfoDao implements AgentInfoDao {
@Override
@Deprecated
public AgentInfoBo findAgentInfoBeforeStartTime(final String agentId, final long currentTime) {
if (agentId == null) {
throw new NullPointerException("agentId must not be null");
}
// TODO cache를 걸어야 될듯 하다.
Scan scan = createScan(agentId, currentTime);
AgentInfoBo agentInfoBo = hbaseOperations2.find(HBaseTables.AGENTINFO, scan, new ResultsExtractor<AgentInfoBo>() {
@@ -26,6 +26,7 @@ import com.nhn.pinpoint.common.util.TimeSlot;
/**
*
* @author netspider
* @author emeroad
*
*/
@Repository
@@ -79,7 +80,7 @@ public class HbaseApplicationMapStatisticsCalleeDao implements ApplicationMapSta
@Override
public List<Map<Long, Map<Short, Long>>> selectCalleeStatistics(String callerApplicationName, short callerServiceType, String calleeApplicationName, short calleeServiceType, long from, long to) {
if (logger.isDebugEnabled()) {
logger.debug("selectCalleeStatistics. " + callerApplicationName + ", " + callerServiceType + ", " + calleeApplicationName + ", " + calleeServiceType + ", " + from + ", " + to);
logger.debug("selectCalleeStatistics. {}, {}, {}, {}, {}, {}", callerApplicationName, callerServiceType, calleeApplicationName, calleeServiceType, from, to);
}
Scan scan = createScan(callerApplicationName, callerServiceType, from, to);
RowMapper<Map<Long, Map<Short, Long>>> mapper = new ApplicationMapLinkStatisticsMapper(callerApplicationName, callerServiceType, calleeApplicationName, calleeServiceType);
@@ -26,6 +26,7 @@ import com.nhn.pinpoint.common.util.TimeSlot;
/**
*
* @author netspider
* @author emeroad
*
*/
@Repository
@@ -79,7 +80,7 @@ public class HbaseApplicationMapStatisticsCallerDao implements ApplicationMapSta
@Override
public List<Map<Long, Map<Short, Long>>> selectCallerStatistics(String callerApplicationName, short callerServiceType, String calleeApplicationName, short calleeServiceType, long from, long to) {
if (logger.isDebugEnabled()) {
logger.debug("selectCallerStatistics. " + callerApplicationName + ", " + callerServiceType + ", " + calleeApplicationName + ", " + calleeServiceType + ", " + from + ", " + to);
logger.debug("selectCallerStatistics. {}, {}, {}, {}, {}, {}", callerApplicationName, callerServiceType, calleeApplicationName, calleeServiceType, from, to);
}
Scan scan = createScan(calleeApplicationName, calleeServiceType, from, to);
RowMapper<Map<Long, Map<Short, Long>>> mapper = new ApplicationMapLinkStatisticsMapper(callerApplicationName, callerServiceType, calleeApplicationName, calleeServiceType);
@@ -59,6 +59,9 @@ public class HbaseApplicationTraceIndexDao implements ApplicationTraceIndexDao {
@Override
public LimitedScanResult<List<TransactionId>> scanTraceIndex(final String applicationName, long start, long end, int limit) {
if (applicationName == null) {
throw new NullPointerException("applicationName must not be null");
}
if (limit < 0) {
throw new IllegalArgumentException("negative limit:" + limit);
}
@@ -142,6 +145,9 @@ public class HbaseApplicationTraceIndexDao implements ApplicationTraceIndexDao {
@Override
public List<Dot> scanTraceScatter(String applicationName, long start, long end, final int limit) {
if (applicationName == null) {
throw new NullPointerException("applicationName must not be null");
}
if (limit < 0) {
throw new IllegalArgumentException("negative limit:" + limit);
}
@@ -23,6 +23,7 @@ import com.nhn.pinpoint.common.util.TimeUtils;
/**
*
* @author netspider
* @author emeroad
*
*/
@Repository
@@ -40,6 +41,9 @@ public class HbaseHostApplicationMapDao implements HostApplicationMapDao {
@Override
public Application findApplicationName(String host, long from, long to) {
if (host == null) {
throw new NullPointerException("host must not be null");
}
Scan scan = createScan(host, from, to);
List<Application> result = hbaseOperations2.find(HBaseTables.HOST_APPLICATION_MAP, scan, hostApplicationMapper);
if (result != null && result.size() > 0) {
@@ -50,7 +54,7 @@ public class HbaseHostApplicationMapDao implements HostApplicationMapDao {
}
private Scan createScan(String host, long from, long to) {
long startTime = TimeUtils.reverseCurrentTimeMillis(TimeSlot.getStatisticsRowSlot(from));
long startTime = TimeUtils.reverseCurrentTimeMillis(TimeSlot.getStatisticsRowSlot(from));
long endTime = TimeUtils.reverseCurrentTimeMillis(TimeSlot.getStatisticsRowSlot(to) + 1);
if (logger.isDebugEnabled()) {
@@ -33,6 +33,10 @@ public class HbaseSqlMetaDataDao implements SqlMetaDataDao {
@Override
public List<SqlMetaDataBo> getSqlMetaData(String agentId, long time, int hashCode) {
if (agentId == null) {
throw new NullPointerException("agentId must not be null");
}
SqlMetaDataBo sqlMetaData = new SqlMetaDataBo(agentId, time, hashCode);
byte[] sqlId = getDistributedKey(sqlMetaData.toRowKey());
@@ -32,6 +32,10 @@ public class HbaseStringMetaDataDao implements StringMetaDataDao {
@Override
public List<StringMetaDataBo> getStringMetaData(String agentId, long time, int stringId) {
if (agentId == null) {
throw new NullPointerException("agentId must not be null");
}
StringMetaDataBo stringMetaData = new StringMetaDataBo(agentId, time, stringId);
byte[] rowKey = getDistributedKey(stringMetaData.toRowKey());