use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.
the class RpcCallProcessorTest method multipleAcceptApplications_with_AliasAndOriginal.
@Test
public void multipleAcceptApplications_with_AliasAndOriginal() {
ServiceType AliasServiceType = of(1008, "TEST_ALIAS_CLIENT", ALIAS);
ServiceType ServerServiceType = of(1009, "TEST_ALIAS_SERVER", RECORD_STATISTICS, TERMINAL);
// Given
ServiceType rpcClientServiceType = mock(ServiceType.class);
when(rpcClientServiceType.isRpcClient()).thenReturn(true);
String rpcUri = "accept.host/foo";
Application fromApplication = new Application("WAS", ServiceType.TEST_STAND_ALONE);
Application toApplication = new Application(rpcUri, rpcClientServiceType);
LinkDataMap linkDataMap = new LinkDataMap();
linkDataMap.addLinkData(new LinkData(fromApplication, toApplication));
Application expectedToApplication1 = new Application("AliasClient", AliasServiceType);
Application expectedToApplication2 = new Application("AliasServer", ServerServiceType);
when(hostApplicationMapDao.findAcceptApplicationName(fromApplication, testRange)).thenReturn(Sets.newHashSet(new AcceptApplication(rpcUri, expectedToApplication1), new AcceptApplication(rpcUri, expectedToApplication2)));
// When
VirtualLinkMarker virtualLinkMarker = new VirtualLinkMarker();
RpcCallProcessor rpcCallProcessor = new RpcCallProcessor(hostApplicationMapDao, virtualLinkMarker);
LinkDataMap replacedLinkDataMap = rpcCallProcessor.processLinkDataMap(linkDataMap, testRange);
// Then
LinkKey originalLinkKey = new LinkKey(fromApplication, toApplication);
Assert.assertNull(replacedLinkDataMap.getLinkData(originalLinkKey));
LinkKey replacedLinkKey2 = new LinkKey(fromApplication, expectedToApplication2);
LinkData replacedLinkData2 = replacedLinkDataMap.getLinkData(replacedLinkKey2);
Assert.assertNotNull(replacedLinkData2);
Assert.assertEquals(fromApplication, replacedLinkData2.getFromApplication());
Assert.assertEquals(expectedToApplication2, replacedLinkData2.getToApplication());
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.
the class WasOnlyProcessorTest method shouldFilterLinksToTerminalNodes.
@Test
public void shouldFilterLinksToTerminalNodes() {
// Given
Application fromApplication = new Application("WAS", ServiceType.TEST_STAND_ALONE);
ServiceType terminalServiceType = ServiceTypeFactory.of(2222, "TERMINAL", ServiceTypeProperty.TERMINAL);
Application toApplication = new Application("TERMINAL", terminalServiceType);
LinkData wasToTerminalLinkData = new LinkData(fromApplication, toApplication);
LinkDataMap linkDataMap = new LinkDataMap();
linkDataMap.addLinkData(wasToTerminalLinkData);
// When
WasOnlyProcessor wasOnlyProcessor = new WasOnlyProcessor();
LinkDataMap filteredLinkDataMap = wasOnlyProcessor.processLinkDataMap(linkDataMap, testRange);
// Then
Assert.assertTrue(filteredLinkDataMap.getLinkDataList().isEmpty());
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.
the class HbaseMapStatisticsCallerDao method selectCaller.
@Override
public LinkDataMap selectCaller(Application callerApplication, Range range) {
Objects.requireNonNull(callerApplication, "callerApplication");
Objects.requireNonNull(range, "range");
final TimeWindow timeWindow = new TimeWindow(range, TimeWindowDownSampler.SAMPLER);
// find distributed key.
final Scan scan = createScan(callerApplication, range, DESCRIPTOR.getName());
ResultsExtractor<LinkDataMap> resultExtractor = new RowMapReduceResultExtractor<>(mapStatisticsCallerMapper, new MapStatisticsTimeWindowReducer(timeWindow));
TableName mapStatisticsCalleeTableName = tableNameProvider.getTableName(DESCRIPTOR.getTable());
LinkDataMap linkDataMap = this.hbaseTemplate.findParallel(mapStatisticsCalleeTableName, scan, rowKeyDistributorByHashPrefix, resultExtractor, MAP_STATISTICS_CALLEE_VER2_NUM_PARTITIONS);
logger.debug("tableInfo({}). Caller data. {}, {} : ", mapStatisticsCalleeTableName.getNameAsString(), linkDataMap, range);
if (linkDataMap != null && linkDataMap.size() > 0) {
return linkDataMap;
}
return new LinkDataMap();
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.
the class MapStatisticsCalleeMapper method mapRow.
@Override
public LinkDataMap mapRow(Result result, int rowNum) throws Exception {
if (result.isEmpty()) {
return new LinkDataMap();
}
logger.debug("mapRow:{}", rowNum);
final byte[] rowKey = getOriginalKey(result.getRow());
final Buffer row = new FixedBuffer(rowKey);
final Application calleeApplication = readCalleeApplication(row);
final long timestamp = TimeUtils.recoveryTimeMillis(row.readLong());
final LinkDataMap linkDataMap = new LinkDataMap();
for (Cell cell : result.rawCells()) {
final byte[] qualifier = CellUtil.cloneQualifier(cell);
final Application callerApplication = readCallerApplication(qualifier, calleeApplication.getServiceType());
if (filter.filter(callerApplication)) {
continue;
}
long requestCount = Bytes.toLong(cell.getValueArray(), cell.getValueOffset());
short histogramSlot = ApplicationMapStatisticsUtils.getHistogramSlotFromColumnName(qualifier);
String callerHost = ApplicationMapStatisticsUtils.getHost(qualifier);
// nodes, they would not have reached here in the first place.
if (calleeApplication.getServiceType().isQueue()) {
callerHost = StringUtils.defaultString(callerHost);
}
boolean isError = histogramSlot == (short) -1;
if (logger.isDebugEnabled()) {
logger.debug(" Fetched Callee. {} callerHost:{} -> {} (slot:{}/{}), ", callerApplication, callerHost, calleeApplication, histogramSlot, requestCount);
}
final short slotTime = (isError) ? (short) -1 : histogramSlot;
linkDataMap.addLinkData(callerApplication, callerApplication.getName(), calleeApplication, callerHost, timestamp, slotTime, requestCount);
if (logger.isDebugEnabled()) {
logger.debug(" Fetched Callee. statistics:{}", linkDataMap);
}
}
return linkDataMap;
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.
the class MapStatisticsCallerMapper method mapRow.
@Override
public LinkDataMap mapRow(Result result, int rowNum) throws Exception {
if (result.isEmpty()) {
return new LinkDataMap();
}
logger.debug("mapRow:{}", rowNum);
final byte[] rowKey = getOriginalKey(result.getRow());
final Buffer row = new FixedBuffer(rowKey);
final Application caller = readCallerApplication(row);
final long timestamp = TimeUtils.recoveryTimeMillis(row.readLong());
// key is destApplicationName.
final LinkDataMap linkDataMap = new LinkDataMap();
for (Cell cell : result.rawCells()) {
final Buffer buffer = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
final Application callee = readCalleeApplication(buffer);
if (filter.filter(callee)) {
continue;
}
String calleeHost = buffer.readPrefixedString();
short histogramSlot = buffer.readShort();
boolean isError = histogramSlot == (short) -1;
String callerAgentId = buffer.readPrefixedString();
long requestCount = getValueToLong(cell);
if (logger.isDebugEnabled()) {
logger.debug(" Fetched Caller.(New) {} {} -> {} (slot:{}/{}) calleeHost:{}", caller, callerAgentId, callee, histogramSlot, requestCount, calleeHost);
}
final short slotTime = (isError) ? (short) -1 : histogramSlot;
if (StringUtils.isEmpty(calleeHost)) {
calleeHost = callee.getName();
}
linkDataMap.addLinkData(caller, callerAgentId, callee, calleeHost, timestamp, slotTime, requestCount);
}
return linkDataMap;
}
Aggregations