mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-25 20:55:59 +10:00
backport.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2014 NAVER Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.navercorp.pinpoint.common.hbase;
|
||||
|
||||
/**
|
||||
* @author jaehong.kim
|
||||
*/
|
||||
public interface RowReducer<T> {
|
||||
T reduce(T map) throws Exception;
|
||||
}
|
||||
+11
-19
@@ -18,7 +18,7 @@ package com.navercorp.pinpoint.web.applicationmap.rawdata;
|
||||
|
||||
import com.navercorp.pinpoint.common.ServiceType;
|
||||
import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram;
|
||||
import com.navercorp.pinpoint.web.vo.Application;
|
||||
import com.navercorp.pinpoint.web.util.TimeWindow;
|
||||
import com.navercorp.pinpoint.web.vo.LinkKey;
|
||||
|
||||
import java.util.*;
|
||||
@@ -36,8 +36,13 @@ public class LinkCallData {
|
||||
private final ServiceType targetServiceType;
|
||||
|
||||
private final Map<Long, TimeHistogram> targetHistogramTimeMap;
|
||||
private final TimeWindow timeWindow;
|
||||
|
||||
public LinkCallData(LinkKey linkKey) {
|
||||
this(linkKey, null);
|
||||
}
|
||||
|
||||
public LinkCallData(LinkKey linkKey, TimeWindow timeWindow) {
|
||||
if (linkKey == null) {
|
||||
throw new NullPointerException("linkKey must not be null");
|
||||
}
|
||||
@@ -48,23 +53,9 @@ public class LinkCallData {
|
||||
this.targetServiceType = linkKey.getToServiceType();
|
||||
|
||||
this.targetHistogramTimeMap = new HashMap<Long, TimeHistogram>();
|
||||
this.timeWindow = timeWindow;
|
||||
}
|
||||
|
||||
public LinkCallData(Application source, Application target) {
|
||||
if (source == null) {
|
||||
throw new NullPointerException("linkKey must not be null");
|
||||
}
|
||||
this.source = source.getName();
|
||||
this.sourceServiceType = source.getServiceType();
|
||||
|
||||
this.target = target.getName();
|
||||
this.targetServiceType = target.getServiceType();
|
||||
|
||||
this.targetHistogramTimeMap = new HashMap<Long, TimeHistogram>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
@@ -122,10 +113,11 @@ public class LinkCallData {
|
||||
}
|
||||
|
||||
private TimeHistogram getTimeHistogram(Long timeStamp) {
|
||||
TimeHistogram histogram = targetHistogramTimeMap.get(timeStamp);
|
||||
long key = timeWindow != null ? timeWindow.refineTimestamp(timeStamp) : timeStamp;
|
||||
TimeHistogram histogram = targetHistogramTimeMap.get(key);
|
||||
if (histogram == null) {
|
||||
histogram = new TimeHistogram(targetServiceType, timeStamp);
|
||||
targetHistogramTimeMap.put(timeStamp, histogram);
|
||||
histogram = new TimeHistogram(targetServiceType, key);
|
||||
targetHistogramTimeMap.put(key, histogram);
|
||||
}
|
||||
return histogram;
|
||||
}
|
||||
|
||||
+6
-7
@@ -18,6 +18,7 @@ package com.navercorp.pinpoint.web.applicationmap.rawdata;
|
||||
|
||||
import com.navercorp.pinpoint.common.ServiceType;
|
||||
import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram;
|
||||
import com.navercorp.pinpoint.web.util.TimeWindow;
|
||||
import com.navercorp.pinpoint.web.vo.LinkKey;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -32,18 +33,16 @@ public class LinkCallDataMap {
|
||||
// private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final Map<LinkKey, LinkCallData> linkDataMap = new HashMap<LinkKey, LinkCallData>();
|
||||
private final TimeWindow timewWindow;
|
||||
|
||||
public LinkCallDataMap() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public LinkCallDataMap(LinkCallDataMap copyLinkCallDataMap) {
|
||||
if (copyLinkCallDataMap == null) {
|
||||
throw new NullPointerException("copyLinkCallDataMap must not be null");
|
||||
}
|
||||
addLinkDataMap(copyLinkCallDataMap);
|
||||
public LinkCallDataMap(TimeWindow timeWindow) {
|
||||
this.timewWindow = timeWindow;
|
||||
}
|
||||
|
||||
|
||||
public void addCallData(String sourceAgentId, ServiceType sourceServiceType, String targetId, ServiceType targetServiceType, Collection<TimeHistogram> timeHistogramList) {
|
||||
LinkKey linkKey = createLinkKey(sourceAgentId, sourceServiceType, targetId, targetServiceType);
|
||||
LinkCallData linkCallData = getLinkCallData(linkKey);
|
||||
@@ -78,7 +77,7 @@ public class LinkCallDataMap {
|
||||
final Map<LinkKey, LinkCallData> rawCallDataMap = this.linkDataMap;
|
||||
LinkCallData linkCallData = rawCallDataMap.get(key);
|
||||
if (linkCallData == null) {
|
||||
linkCallData = new LinkCallData(key);
|
||||
linkCallData = new LinkCallData(key, timewWindow);
|
||||
rawCallDataMap.put(key, linkCallData);
|
||||
}
|
||||
return linkCallData;
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.navercorp.pinpoint.web.applicationmap.rawdata;
|
||||
|
||||
|
||||
import com.navercorp.pinpoint.common.ServiceType;
|
||||
import com.navercorp.pinpoint.web.util.TimeWindow;
|
||||
import com.navercorp.pinpoint.web.vo.Application;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@@ -36,23 +37,13 @@ public class LinkData {
|
||||
private final Application toApplication;
|
||||
|
||||
private LinkCallDataMap linkCallDataMap;
|
||||
private final TimeWindow timeWindow;
|
||||
|
||||
public LinkData(Application fromApplication, Application toApplication) {
|
||||
if (fromApplication == null) {
|
||||
throw new NullPointerException("fromApplication must not be null");
|
||||
}
|
||||
if (toApplication == null) {
|
||||
throw new NullPointerException("toApplication must not be null");
|
||||
}
|
||||
|
||||
this.fromApplication = fromApplication;
|
||||
this.toApplication = toApplication;
|
||||
|
||||
this.linkCallDataMap = new LinkCallDataMap();
|
||||
this(fromApplication, toApplication, null);
|
||||
}
|
||||
|
||||
// deliberately not implemented as a copy constructor
|
||||
public LinkData(Application fromApplication, Application toApplication, LinkCallDataMap linkCallDataMap) {
|
||||
public LinkData(Application fromApplication, Application toApplication, TimeWindow timeWindow) {
|
||||
if (fromApplication == null) {
|
||||
throw new NullPointerException("fromApplication must not be null");
|
||||
}
|
||||
@@ -61,8 +52,8 @@ public class LinkData {
|
||||
}
|
||||
this.fromApplication = fromApplication;
|
||||
this.toApplication = toApplication;
|
||||
|
||||
this.linkCallDataMap = linkCallDataMap;
|
||||
this.timeWindow = timeWindow;
|
||||
this.linkCallDataMap = new LinkCallDataMap(timeWindow);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,10 +71,9 @@ public class LinkData {
|
||||
}
|
||||
|
||||
public void resetLinkData() {
|
||||
this.linkCallDataMap = new LinkCallDataMap();
|
||||
this.linkCallDataMap = new LinkCallDataMap(timeWindow);
|
||||
}
|
||||
|
||||
|
||||
public Application getFromApplication() {
|
||||
return this.fromApplication;
|
||||
}
|
||||
@@ -97,6 +87,10 @@ public class LinkData {
|
||||
return this.linkCallDataMap;
|
||||
}
|
||||
|
||||
public void setLinkCallDataMap(LinkCallDataMap linkCallDataMap) {
|
||||
this.linkCallDataMap = linkCallDataMap;
|
||||
}
|
||||
|
||||
public AgentHistogramList getTargetList() {
|
||||
return linkCallDataMap.getTargetList();
|
||||
}
|
||||
|
||||
+14
-6
@@ -18,20 +18,20 @@ package com.navercorp.pinpoint.web.applicationmap.rawdata;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.navercorp.pinpoint.web.util.TimeWindow;
|
||||
import com.navercorp.pinpoint.web.vo.Application;
|
||||
import com.navercorp.pinpoint.web.vo.LinkKey;
|
||||
|
||||
public class LinkDataMap {
|
||||
private final Map<LinkKey, LinkData> linkDataMap = new HashMap<LinkKey, LinkData>();
|
||||
private TimeWindow timeWindow;
|
||||
|
||||
public LinkDataMap() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public LinkDataMap(LinkDataMap copyLinkDataMap) {
|
||||
if (copyLinkDataMap == null) {
|
||||
throw new NullPointerException("copyLinkDataMap must not be null");
|
||||
}
|
||||
addLinkDataMap(copyLinkDataMap);
|
||||
public LinkDataMap(TimeWindow timeWindow) {
|
||||
this.timeWindow = timeWindow;
|
||||
}
|
||||
|
||||
public Collection<LinkData> getLinkDataList() {
|
||||
@@ -72,7 +72,7 @@ public class LinkDataMap {
|
||||
final LinkKey key = new LinkKey(fromApplication, toApplication);
|
||||
LinkData findLink = linkDataMap.get(key);
|
||||
if (findLink == null) {
|
||||
findLink = new LinkData(fromApplication, toApplication);
|
||||
findLink = new LinkData(fromApplication, toApplication, timeWindow);
|
||||
linkDataMap.put(key, findLink);
|
||||
}
|
||||
return findLink;
|
||||
@@ -97,4 +97,12 @@ public class LinkDataMap {
|
||||
}
|
||||
return this.linkDataMap.get(findLinkKey);
|
||||
}
|
||||
|
||||
public TimeWindow getTimeWindow() {
|
||||
return timeWindow;
|
||||
}
|
||||
|
||||
public void setTimeWindow(TimeWindow timeWindow) {
|
||||
this.timeWindow = timeWindow;
|
||||
}
|
||||
}
|
||||
|
||||
+9
-3
@@ -24,6 +24,8 @@ import com.navercorp.pinpoint.common.util.ApplicationMapStatisticsUtils;
|
||||
import com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap;
|
||||
import com.navercorp.pinpoint.web.dao.MapStatisticsCalleeDao;
|
||||
import com.navercorp.pinpoint.web.mapper.*;
|
||||
import com.navercorp.pinpoint.web.util.TimeWindow;
|
||||
import com.navercorp.pinpoint.web.util.TimeWindowDownSampler;
|
||||
import com.navercorp.pinpoint.web.vo.Application;
|
||||
import com.navercorp.pinpoint.web.vo.Range;
|
||||
import com.navercorp.pinpoint.web.vo.RangeFactory;
|
||||
@@ -33,6 +35,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.hadoop.hbase.ResultsExtractor;
|
||||
import org.springframework.data.hadoop.hbase.RowMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -67,13 +70,16 @@ public class HbaseMapStatisticsCalleeDao implements MapStatisticsCalleeDao {
|
||||
throw new NullPointerException("range must not be null");
|
||||
}
|
||||
Scan scan = createScan(calleeApplication, range);
|
||||
List<LinkDataMap> foundListList = hbaseOperations2.find(HBaseTables.MAP_STATISTICS_CALLER, scan, mapStatisticsCalleeMapper);
|
||||
final TimeWindow timeWindow = new TimeWindow(range, TimeWindowDownSampler.SAMPLER);
|
||||
final ResultsExtractor<LinkDataMap> resultExtractor = new RowMapReduceResultExtractor<LinkDataMap>(mapStatisticsCalleeMapper, new MapStatisticsTimeWindowReducer(timeWindow));
|
||||
LinkDataMap foundListList = hbaseOperations2.find(HBaseTables.MAP_STATISTICS_CALLER, scan, resultExtractor);
|
||||
|
||||
if (foundListList.isEmpty()) {
|
||||
if (foundListList == null) {
|
||||
logger.debug("There's no caller data. {}, {}", calleeApplication, range);
|
||||
return new LinkDataMap();
|
||||
}
|
||||
|
||||
return merge(foundListList);
|
||||
return foundListList;
|
||||
}
|
||||
|
||||
private LinkDataMap merge(List<LinkDataMap> foundListList) {
|
||||
|
||||
+10
-3
@@ -24,6 +24,8 @@ import com.navercorp.pinpoint.common.util.ApplicationMapStatisticsUtils;
|
||||
import com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap;
|
||||
import com.navercorp.pinpoint.web.dao.MapStatisticsCallerDao;
|
||||
import com.navercorp.pinpoint.web.mapper.*;
|
||||
import com.navercorp.pinpoint.web.util.TimeWindow;
|
||||
import com.navercorp.pinpoint.web.util.TimeWindowDownSampler;
|
||||
import com.navercorp.pinpoint.web.vo.Application;
|
||||
import com.navercorp.pinpoint.web.vo.Range;
|
||||
import com.navercorp.pinpoint.web.vo.RangeFactory;
|
||||
@@ -33,6 +35,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.hadoop.hbase.ResultsExtractor;
|
||||
import org.springframework.data.hadoop.hbase.RowMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -61,13 +64,17 @@ public class HbaseMapStatisticsCallerDao implements MapStatisticsCallerDao {
|
||||
@Override
|
||||
public LinkDataMap selectCaller(Application callerApplication, Range range) {
|
||||
Scan scan = createScan(callerApplication, range);
|
||||
final List<LinkDataMap> foundList = hbaseOperations2.find(HBaseTables.MAP_STATISTICS_CALLEE, scan, mapStatisticsCallerMapper);
|
||||
final TimeWindow timeWindow = new TimeWindow(range, TimeWindowDownSampler.SAMPLER);
|
||||
final ResultsExtractor<LinkDataMap> resultExtractor = new RowMapReduceResultExtractor<LinkDataMap>(mapStatisticsCallerMapper, new MapStatisticsTimeWindowReducer(timeWindow));
|
||||
final LinkDataMap foundList = hbaseOperations2.find(HBaseTables.MAP_STATISTICS_CALLEE, scan, resultExtractor);
|
||||
logger.debug("Caller data. {}, {}", foundList, range);
|
||||
|
||||
if (foundList.isEmpty()) {
|
||||
if (foundList == null) {
|
||||
logger.debug("There's no caller data. {}, {}", callerApplication, range);
|
||||
return new LinkDataMap();
|
||||
}
|
||||
|
||||
return merge(foundList);
|
||||
return foundList;
|
||||
}
|
||||
|
||||
private LinkDataMap merge(List<LinkDataMap> foundList) {
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2014 NAVER Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.navercorp.pinpoint.web.mapper;
|
||||
|
||||
import com.navercorp.pinpoint.common.hbase.RowReducer;
|
||||
import com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap;
|
||||
import com.navercorp.pinpoint.web.util.TimeWindow;
|
||||
|
||||
/**
|
||||
* @author jaehong.kim
|
||||
*/
|
||||
public class MapStatisticsTimeWindowReducer implements RowReducer<LinkDataMap> {
|
||||
|
||||
private final LinkDataMap result;
|
||||
|
||||
public MapStatisticsTimeWindowReducer(TimeWindow timeWindow) {
|
||||
result = new LinkDataMap(timeWindow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkDataMap reduce(LinkDataMap map) throws Exception {
|
||||
result.addLinkDataMap(map);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2014 NAVER Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.navercorp.pinpoint.web.mapper;
|
||||
|
||||
import org.apache.hadoop.hbase.client.Result;
|
||||
import org.apache.hadoop.hbase.client.ResultScanner;
|
||||
import org.springframework.data.hadoop.hbase.ResultsExtractor;
|
||||
import org.springframework.data.hadoop.hbase.RowMapper;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.navercorp.pinpoint.common.hbase.RowReducer;
|
||||
|
||||
/**
|
||||
* @author jaehong.kim
|
||||
*/
|
||||
public class RowMapReduceResultExtractor<T> implements ResultsExtractor<T> {
|
||||
private final RowMapper<T> rowMapper;
|
||||
private final RowReducer<T> rowReducer;
|
||||
|
||||
public RowMapReduceResultExtractor(RowMapper<T> rowMapper, RowReducer<T> rowReducer) {
|
||||
Assert.notNull(rowMapper, "RowMapper is required");
|
||||
this.rowMapper = rowMapper;
|
||||
this.rowReducer = rowReducer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T extractData(ResultScanner results) throws Exception {
|
||||
int rowNum = 0;
|
||||
T r = null;
|
||||
for (Result result : results) {
|
||||
T map = this.rowMapper.mapRow(result, rowNum++);
|
||||
r = rowReducer.reduce(map);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
}
|
||||
@@ -179,7 +179,8 @@ public class BFSLinkSelector implements LinkSelector {
|
||||
logger.debug("Application info replaced. {} => {}", linkData, acceptApplicationList);
|
||||
|
||||
AcceptApplication first = acceptApplicationList.iterator().next();
|
||||
final LinkData acceptedLinkData = new LinkData(linkData.getFromApplication(), first.getApplication(), linkData.getLinkCallDataMap());
|
||||
final LinkData acceptedLinkData = new LinkData(linkData.getFromApplication(), first.getApplication());
|
||||
acceptedLinkData.setLinkCallDataMap(linkData.getLinkCallDataMap());
|
||||
return Collections.singletonList(acceptedLinkData);
|
||||
} else {
|
||||
// special case - there are more than 2 nodes grouped by a single url
|
||||
@@ -187,7 +188,8 @@ public class BFSLinkSelector implements LinkSelector {
|
||||
}
|
||||
} else {
|
||||
final Application unknown = new Application(toApplication.getName(), ServiceType.UNKNOWN);
|
||||
final LinkData unknownLinkData = new LinkData(linkData.getFromApplication(), unknown, linkData.getLinkCallDataMap());
|
||||
final LinkData unknownLinkData = new LinkData(linkData.getFromApplication(), unknown);
|
||||
unknownLinkData.setLinkCallDataMap(linkData.getLinkCallDataMap());
|
||||
return Collections.singletonList(unknownLinkData);
|
||||
}
|
||||
|
||||
@@ -199,7 +201,8 @@ public class BFSLinkSelector implements LinkSelector {
|
||||
List<LinkData> emulationLink = new ArrayList<LinkData>();
|
||||
for (AcceptApplication acceptApplication : acceptApplicationList) {
|
||||
// linkCallData needs to be modified - remove callHistogram on purpose
|
||||
final LinkData acceptedLinkData = new LinkData(linkData.getFromApplication(), acceptApplication.getApplication(), linkData.getLinkCallDataMap());
|
||||
final LinkData acceptedLinkData = new LinkData(linkData.getFromApplication(), acceptApplication.getApplication());
|
||||
acceptedLinkData.setLinkCallDataMap(linkData.getLinkCallDataMap());
|
||||
emulationLink.add(acceptedLinkData);
|
||||
traceEmulationLink(acceptedLinkData);
|
||||
}
|
||||
|
||||
@@ -192,7 +192,8 @@ public class DFSLinkSelector implements LinkSelector {
|
||||
logger.debug("Application info replaced. {} => {}", linkData, acceptApplicationList);
|
||||
|
||||
AcceptApplication first = acceptApplicationList.iterator().next();
|
||||
final LinkData acceptedLinkData = new LinkData(linkData.getFromApplication(), first.getApplication(), linkData.getLinkCallDataMap());
|
||||
final LinkData acceptedLinkData = new LinkData(linkData.getFromApplication(), first.getApplication());
|
||||
acceptedLinkData.setLinkCallDataMap(linkData.getLinkCallDataMap());
|
||||
return Collections.singletonList(acceptedLinkData);
|
||||
} else {
|
||||
// special case - there are more than 2 nodes grouped by a single url
|
||||
@@ -200,7 +201,8 @@ public class DFSLinkSelector implements LinkSelector {
|
||||
}
|
||||
} else {
|
||||
final Application unknown = new Application(toApplication.getName(), ServiceType.UNKNOWN);
|
||||
final LinkData unknownLinkData = new LinkData(linkData.getFromApplication(), unknown, linkData.getLinkCallDataMap());
|
||||
final LinkData unknownLinkData = new LinkData(linkData.getFromApplication(), unknown);
|
||||
unknownLinkData.setLinkCallDataMap(linkData.getLinkCallDataMap());
|
||||
return Collections.singletonList(unknownLinkData);
|
||||
}
|
||||
|
||||
@@ -212,7 +214,8 @@ public class DFSLinkSelector implements LinkSelector {
|
||||
List<LinkData> emulationLink = new ArrayList<LinkData>();
|
||||
for (AcceptApplication acceptApplication : acceptApplicationList) {
|
||||
// linkCallData needs to be modified - remove callHistogram on purpose
|
||||
final LinkData acceptedLinkData = new LinkData(linkData.getFromApplication(), acceptApplication.getApplication(), linkData.getLinkCallDataMap());
|
||||
final LinkData acceptedLinkData = new LinkData(linkData.getFromApplication(), acceptApplication.getApplication());
|
||||
acceptedLinkData.setLinkCallDataMap(linkData.getLinkCallDataMap());
|
||||
emulationLink.add(acceptedLinkData);
|
||||
traceEmulationLink(acceptedLinkData);
|
||||
}
|
||||
|
||||
+2
-1
@@ -77,7 +77,8 @@ public class ErrorCountToCalleCheckerTest {
|
||||
}
|
||||
|
||||
linkCallDataMap.addCallData(fromApplication.getName(), fromApplication.getServiceType(), toApplication.getName(), toApplication.getServiceType(), timeHistogramList);
|
||||
LinkData linkData = new LinkData(fromApplication, toApplication, linkCallDataMap);
|
||||
LinkData linkData = new LinkData(fromApplication, toApplication);
|
||||
linkData.setLinkCallDataMap(linkCallDataMap);
|
||||
linkDataMap.addLinkData(linkData);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -77,7 +77,8 @@ public class ErrorRateToCalleCheckerTest {
|
||||
}
|
||||
|
||||
linkCallDataMap.addCallData(fromApplication.getName(), fromApplication.getServiceType(), toApplication.getName(), toApplication.getServiceType(), timeHistogramList);
|
||||
LinkData linkData = new LinkData(fromApplication, toApplication, linkCallDataMap);
|
||||
LinkData linkData = new LinkData(fromApplication, toApplication);
|
||||
linkData.setLinkCallDataMap(linkCallDataMap);
|
||||
linkDataMap.addLinkData(linkData);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -71,7 +71,8 @@ public class SlowCountToCalleCheckerTest {
|
||||
}
|
||||
|
||||
linkCallDataMap.addCallData(fromApplication.getName(), fromApplication.getServiceType(), toApplication.getName(), toApplication.getServiceType(), timeHistogramList);
|
||||
LinkData linkData = new LinkData(fromApplication, toApplication, linkCallDataMap);
|
||||
LinkData linkData = new LinkData(fromApplication, toApplication);
|
||||
linkData.setLinkCallDataMap(linkCallDataMap);
|
||||
linkDataMap.addLinkData(linkData);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -72,7 +72,8 @@ public class SlowRateToCalleCheckerTest {
|
||||
}
|
||||
|
||||
linkCallDataMap.addCallData(fromApplication.getName(), fromApplication.getServiceType(), toApplication.getName(), toApplication.getServiceType(), timeHistogramList);
|
||||
LinkData linkData = new LinkData(fromApplication, toApplication, linkCallDataMap);
|
||||
LinkData linkData = new LinkData(fromApplication, toApplication);
|
||||
linkData.setLinkCallDataMap(linkCallDataMap);
|
||||
linkDataMap.addLinkData(linkData);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -71,7 +71,8 @@ public class TotalCountToCalleCheckerTest {
|
||||
}
|
||||
|
||||
linkCallDataMap.addCallData(fromApplication.getName(), fromApplication.getServiceType(), toApplication.getName(), toApplication.getServiceType(), timeHistogramList);
|
||||
LinkData linkData = new LinkData(fromApplication, toApplication, linkCallDataMap);
|
||||
LinkData linkData = new LinkData(fromApplication, toApplication);
|
||||
linkData.setLinkCallDataMap(linkCallDataMap);
|
||||
linkDataMap.addLinkData(linkData);
|
||||
}
|
||||
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 2014 NAVER Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.navercorp.pinpoint.web.applicationmap.rawdata;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.navercorp.pinpoint.common.ServiceType;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.navercorp.pinpoint.web.util.TimeWindow;
|
||||
import com.navercorp.pinpoint.web.util.TimeWindowDownSampler;
|
||||
import com.navercorp.pinpoint.web.vo.LinkKey;
|
||||
import com.navercorp.pinpoint.web.vo.Range;
|
||||
|
||||
/**
|
||||
* @author jaehong.kim
|
||||
*/
|
||||
public class LinkCallDataTest {
|
||||
|
||||
private static final long ONE_MINUTE = 6000 * 10;
|
||||
private static final long ONE_HOUR = TimeUnit.HOURS.toMillis(1);
|
||||
private static final long SIX_HOURS = TimeUnit.HOURS.toMillis(6);
|
||||
private static final long TWELVE_HOURS = TimeUnit.HOURS.toMillis(12);
|
||||
private static final long ONE_DAY = TimeUnit.DAYS.toMillis(1);
|
||||
private static final long TWO_DAY = TimeUnit.DAYS.toMillis(2);
|
||||
|
||||
|
||||
@Test
|
||||
public void addCallData() {
|
||||
LinkKey key = new LinkKey("fromApplication", ServiceType.STAND_ALONE, "toApplication", ServiceType.STAND_ALONE);
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
LinkCallData data1 = new LinkCallData(key);
|
||||
data1.addCallData(currentTime, (short) 100, 1L);
|
||||
data1.addCallData(currentTime + ONE_MINUTE, (short) 100, 1L);
|
||||
data1.addCallData(currentTime + ONE_MINUTE + ONE_MINUTE, (short) 100, 1L);
|
||||
data1.addCallData(currentTime + ONE_MINUTE + ONE_MINUTE + ONE_MINUTE, (short) 100, 1L);
|
||||
data1.addCallData(currentTime + ONE_MINUTE + ONE_MINUTE + ONE_MINUTE + ONE_MINUTE, (short) 100, 1L);
|
||||
|
||||
System.out.println(data1.getTimeHistogram().size());
|
||||
|
||||
Range range = new Range(currentTime, currentTime + SIX_HOURS);
|
||||
TimeWindow window = new TimeWindow(range, TimeWindowDownSampler.SAMPLER);
|
||||
LinkCallData data2 = new LinkCallData(key, window);
|
||||
data2.addCallData(currentTime, (short) 100, 1L);
|
||||
data2.addCallData(currentTime + ONE_MINUTE, (short) 100, 1L);
|
||||
data2.addCallData(currentTime + ONE_MINUTE + ONE_MINUTE, (short) 100, 1L);
|
||||
data2.addCallData(currentTime + ONE_MINUTE + ONE_MINUTE + ONE_MINUTE, (short) 100, 1L);
|
||||
data2.addCallData(currentTime + ONE_MINUTE + ONE_MINUTE + ONE_MINUTE + ONE_MINUTE, (short) 100, 1L);
|
||||
|
||||
System.out.println(data2.getTimeHistogram().size());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user