use of com.navercorp.pinpoint.web.vo.Range in project pinpoint by naver.
the class SampledAgentStatResultExtractorTest method one_to_one_sampler_should_not_down_sample_data_points.
@Test
public void one_to_one_sampler_should_not_down_sample_data_points() throws Exception {
// Given
final int numValues = 10;
final long initialTimestamp = System.currentTimeMillis();
final long finalTimestamp = initialTimestamp + (DEFAULT_TIME_INTERVAL * numValues);
final TimeWindow timeWindow = new TimeWindow(new Range(initialTimestamp, finalTimestamp), ONE_TO_ONE_SAMPLER);
final List<TestAgentStatDataPoint> dataPoints = createDataPoints(finalTimestamp, DEFAULT_TIME_INTERVAL, numValues);
final Map<Long, List<TestAgentStatDataPoint>> expectedDataPointSlotMap = getExpectedDataPointSlotMap(timeWindow, dataPoints);
when(this.rowMapper.mapRow(this.result, 0)).thenReturn(dataPoints);
TestAgentStatSampler testAgentStatSampler = new TestAgentStatSampler();
SampledAgentStatResultExtractor<TestAgentStatDataPoint, TestSampledAgentStatDataPoint> resultExtractor = new SampledAgentStatResultExtractor<>(timeWindow, this.rowMapper, testAgentStatSampler);
// When
List<TestSampledAgentStatDataPoint> sampledDataPoints = resultExtractor.extractData(this.resultScanner);
// Then
for (TestSampledAgentStatDataPoint sampledDataPoint : sampledDataPoints) {
List<TestAgentStatDataPoint> expectedSampledDataPoints = expectedDataPointSlotMap.get(sampledDataPoint.getBaseTimestamp());
Assert.assertEquals(expectedSampledDataPoints, sampledDataPoint.getDataPointsToSample());
}
}
use of com.navercorp.pinpoint.web.vo.Range in project pinpoint by naver.
the class BFSLinkSelectorTest method testCallee_3tier.
@Test
public void testCallee_3tier() throws Exception {
// APP_A -> APP_B -> APP_C
when(calleeDao.selectCallee(any(Application.class), any(Range.class))).thenReturn(newEmptyLinkDataMap());
int callCount_A_B = 30;
LinkDataMap linkDataMap_A_B = new LinkDataMap();
linkDataMap_A_B.addLinkData(APP_A, "agentA", APP_B, "agentB", 1000, BaseHistogramSchema.NORMAL_SCHEMA.getNormalSlot().getSlotTime(), callCount_A_B);
when(calleeDao.selectCallee(eq(APP_B), any(Range.class))).thenReturn(linkDataMap_A_B);
int callCount_B_C = 40;
LinkDataMap linkDataMap_B_C = new LinkDataMap();
linkDataMap_B_C.addLinkData(APP_B, "agentB", APP_C, "agentC", 1000, BaseHistogramSchema.NORMAL_SCHEMA.getNormalSlot().getSlotTime(), callCount_B_C);
when(calleeDao.selectCallee(eq(APP_C), any(Range.class))).thenReturn(linkDataMap_B_C);
when(callerDao.selectCaller(any(Application.class), any(Range.class))).thenReturn(newEmptyLinkDataMap());
when(hostApplicationMapDao.findAcceptApplicationName(any(Application.class), any(Range.class))).thenReturn(new HashSet<AcceptApplication>());
LinkSelector linkSelector = createLinkSelector();
LinkDataDuplexMap linkData = linkSelector.select(APP_C, range, oneDepth);
Assert.assertEquals(linkData.size(), 1);
Assert.assertEquals(linkData.getTotalCount(), callCount_B_C);
Assert.assertEquals(linkData.getSourceLinkDataList().size(), 0);
Assert.assertEquals(linkData.getTargetLinkDataList().size(), 1);
Assert.assertEquals(linkData.getTotalCount(), callCount_B_C);
// depth 2
LinkSelector linkSelector2 = createLinkSelector();
LinkDataDuplexMap linkData_depth2 = linkSelector2.select(APP_C, range, twoDepth);
Assert.assertEquals(linkData_depth2.size(), 2);
LinkKey linkKey_A_B = new LinkKey(APP_A, APP_B);
assertTarget_Source_TotalCount("APP_A->APP_B", linkData_depth2, linkKey_A_B, callCount_A_B);
LinkKey linkKey_B_C = new LinkKey(APP_B, APP_C);
assertTarget_Source_TotalCount("APP_B->APP_C", linkData_depth2, linkKey_B_C, callCount_B_C);
}
use of com.navercorp.pinpoint.web.vo.Range in project pinpoint by naver.
the class DataSourceChartGroupSerializerTest method serializeTest.
@Test
public void serializeTest() throws Exception {
long currentTimeMillis = System.currentTimeMillis();
TimeWindow timeWindow = new TimeWindow(new Range(currentTimeMillis - 300000, currentTimeMillis));
List<SampledDataSource> sampledDataSourceList = createSampledDataSourceList(timeWindow);
DataSourceChartGroup dataSourceChartGroup = new DataSourceChartGroup(timeWindow, sampledDataSourceList, serviceTypeRegistryService);
String jsonValue = mapper.writeValueAsString(dataSourceChartGroup);
Map map = mapper.readValue(jsonValue, Map.class);
Assert.assertTrue(map.containsKey("id"));
Assert.assertTrue(map.containsKey("jdbcUrl"));
Assert.assertTrue(map.containsKey("databaseName"));
Assert.assertTrue(map.containsKey("serviceType"));
Assert.assertTrue(map.containsKey("charts"));
}
use of com.navercorp.pinpoint.web.vo.Range in project pinpoint by naver.
the class LinkSerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
AgentHistogramList list = new AgentHistogramList();
AgentHistogram histogram = new AgentHistogram(new Application("test", ServiceType.STAND_ALONE));
list.addAgentHistogram(histogram);
Node node1 = new Node(new Application("test1", ServiceType.STAND_ALONE));
Node node2 = new Node(new Application("test1", ServiceType.STAND_ALONE));
Link link = new Link(CreateType.Source, node1, node2, new Range(0, 1));
ObjectWriter objectWriter = MAPPER.writerWithDefaultPrettyPrinter();
String s = objectWriter.writeValueAsString(link);
logger.debug(s);
}
use of com.navercorp.pinpoint.web.vo.Range in project pinpoint by naver.
the class AgentEventTimelineTest method multipleFilters.
@Test
public void multipleFilters() {
// Given
Range timelineRange = new Range(100, 200);
List<AgentEvent> agentEvents = Arrays.asList(createAgentEvent(110, AgentEventType.AGENT_PING), createAgentEvent(120, AgentEventType.AGENT_CONNECTED), createAgentEvent(130, AgentEventType.AGENT_SHUTDOWN), createAgentEvent(140, AgentEventType.AGENT_UNEXPECTED_SHUTDOWN), createAgentEvent(150, AgentEventType.AGENT_CLOSED_BY_SERVER), createAgentEvent(160, AgentEventType.AGENT_UNEXPECTED_CLOSE_BY_SERVER), createAgentEvent(170, AgentEventType.USER_THREAD_DUMP), createAgentEvent(180, AgentEventType.OTHER));
Set<AgentEventType> includedAgentEventTypes = new HashSet<AgentEventType>() {
{
add(AgentEventType.AGENT_PING);
add(AgentEventType.AGENT_CONNECTED);
add(AgentEventType.AGENT_SHUTDOWN);
add(AgentEventType.AGENT_CLOSED_BY_SERVER);
}
};
AgentEventFilter excludeUnexpectedEventsFilter = new AgentEventFilter.ExcludeFilter(AgentEventType.AGENT_UNEXPECTED_SHUTDOWN, AgentEventType.AGENT_UNEXPECTED_CLOSE_BY_SERVER);
AgentEventFilter excludeUserThreadDumpFilter = new AgentEventFilter.ExcludeFilter(AgentEventType.USER_THREAD_DUMP);
AgentEventFilter excludeOtherFilter = new AgentEventFilter.ExcludeFilter(AgentEventType.OTHER);
// When
AgentEventTimeline timeline = new AgentEventTimelineBuilder(timelineRange, 1).from(agentEvents).addFilter(excludeUnexpectedEventsFilter).addFilter(excludeUserThreadDumpFilter).addFilter(excludeOtherFilter).build();
// Then
int allEventsTotalCount = 0;
for (AgentEventTimelineSegment segment : timeline.getTimelineSegments()) {
AgentEventMarker marker = segment.getValue();
allEventsTotalCount += marker.getTotalCount();
Map<AgentEventType, Integer> eventTypeCountMap = marker.getTypeCounts();
Assert.assertTrue(includedAgentEventTypes.containsAll(eventTypeCountMap.keySet()));
Assert.assertFalse(eventTypeCountMap.keySet().contains(AgentEventType.AGENT_UNEXPECTED_SHUTDOWN));
Assert.assertFalse(eventTypeCountMap.keySet().contains(AgentEventType.AGENT_UNEXPECTED_CLOSE_BY_SERVER));
Assert.assertFalse(eventTypeCountMap.keySet().contains(AgentEventType.USER_THREAD_DUMP));
Assert.assertFalse(eventTypeCountMap.keySet().contains(AgentEventType.OTHER));
}
Assert.assertEquals(allEventsTotalCount, includedAgentEventTypes.size());
}
Aggregations