use of com.navercorp.pinpoint.batch.alarm.collector.AgentEventDataCollector in project pinpoint by naver.
the class DeadlockCheckerTest method checkTest2.
@Test
public void checkTest2() {
Rule rule = new Rule(APPLICATION_NAME, SERVICE_TYPE, CheckerCategory.ERROR_COUNT.getName(), 50, "testGroup", false, false, false, "");
Application application = new Application(APPLICATION_NAME, ServiceType.STAND_ALONE);
Range range = Range.newUncheckedRange(START_TIME_MILLIS, CURRENT_TIME_MILLIS);
when(mockAgentEventDao.getAgentEvents(AGENT_ID_1, range, Collections.emptySet())).thenReturn(Arrays.asList(createAgentEvent(AGENT_ID_1, createEventTimestamp(), AgentEventType.AGENT_CLOSED_BY_SERVER)));
when(mockAgentEventDao.getAgentEvents(AGENT_ID_2, range, Collections.emptySet())).thenReturn(Arrays.asList(createAgentEvent(AGENT_ID_2, createEventTimestamp(), AgentEventType.AGENT_SHUTDOWN)));
when(mockAgentEventDao.getAgentEvents(AGENT_ID_3, range, Collections.emptySet())).thenReturn(Arrays.asList(createAgentEvent(AGENT_ID_3, createEventTimestamp(), AgentEventType.AGENT_PING)));
AgentEventDataCollector dataCollector = new AgentEventDataCollector(DataCollectorCategory.AGENT_EVENT, application, mockAgentEventDao, mockApplicationIndexDao, CURRENT_TIME_MILLIS, INTERVAL_MILLIS);
DeadlockChecker checker = new DeadlockChecker(dataCollector, rule);
checker.check();
Assert.assertFalse(checker.isDetected());
String emailMessage = checker.getEmailMessage();
Assert.assertTrue(StringUtils.isEmpty(emailMessage));
List<String> smsMessage = checker.getSmsMessage();
Assert.assertTrue(smsMessage.isEmpty());
}
use of com.navercorp.pinpoint.batch.alarm.collector.AgentEventDataCollector in project pinpoint by naver.
the class DeadlockCheckerTest method checkTest1.
@Test
public void checkTest1() {
Rule rule = new Rule(APPLICATION_NAME, SERVICE_TYPE, CheckerCategory.ERROR_COUNT.getName(), 50, "testGroup", false, false, false, "");
Application application = new Application(APPLICATION_NAME, ServiceType.STAND_ALONE);
Range range = Range.newUncheckedRange(START_TIME_MILLIS, CURRENT_TIME_MILLIS);
when(mockAgentEventDao.getAgentEvents(AGENT_ID_1, range, Collections.emptySet())).thenReturn(Arrays.asList(createAgentEvent(AGENT_ID_1, createEventTimestamp(), AgentEventType.AGENT_CLOSED_BY_SERVER)));
when(mockAgentEventDao.getAgentEvents(AGENT_ID_2, range, Collections.emptySet())).thenReturn(Arrays.asList(createAgentEvent(AGENT_ID_2, createEventTimestamp(), AgentEventType.AGENT_DEADLOCK_DETECTED)));
when(mockAgentEventDao.getAgentEvents(AGENT_ID_3, range, Collections.emptySet())).thenReturn(Arrays.asList(createAgentEvent(AGENT_ID_3, createEventTimestamp(), AgentEventType.AGENT_PING)));
AgentEventDataCollector dataCollector = new AgentEventDataCollector(DataCollectorCategory.AGENT_EVENT, application, mockAgentEventDao, mockApplicationIndexDao, CURRENT_TIME_MILLIS, INTERVAL_MILLIS);
DeadlockChecker checker = new DeadlockChecker(dataCollector, rule);
checker.check();
Assert.assertTrue(checker.isDetected());
String emailMessage = checker.getEmailMessage();
Assert.assertTrue(StringUtils.hasLength(emailMessage));
List<String> smsMessage = checker.getSmsMessage();
Assert.assertTrue(smsMessage.size() == 1);
}
use of com.navercorp.pinpoint.batch.alarm.collector.AgentEventDataCollector in project pinpoint by naver.
the class CheckerRegistry method setup.
private void setup() {
put(CheckerCategory.SLOW_COUNT, new AlarmCheckerFactory() {
@Override
public AlarmChecker<?> createChecker(DataCollector dataCollector, Rule rule) {
return new SlowCountChecker((ResponseTimeDataCollector) dataCollector, rule);
}
});
put(CheckerCategory.SLOW_RATE, new AlarmCheckerFactory() {
@Override
public AlarmChecker<?> createChecker(DataCollector dataCollector, Rule rule) {
return new SlowRateChecker((ResponseTimeDataCollector) dataCollector, rule);
}
});
put(CheckerCategory.ERROR_COUNT, new AlarmCheckerFactory() {
@Override
public AlarmChecker<?> createChecker(DataCollector dataCollector, Rule rule) {
return new ErrorCountChecker((ResponseTimeDataCollector) dataCollector, rule);
}
});
put(CheckerCategory.ERROR_RATE, new AlarmCheckerFactory() {
public AlarmChecker<?> createChecker(DataCollector dataCollector, Rule rule) {
return new ErrorRateChecker((ResponseTimeDataCollector) dataCollector, rule);
}
});
put(CheckerCategory.TOTAL_COUNT, new AlarmCheckerFactory() {
@Override
public AlarmChecker<?> createChecker(DataCollector dataCollector, Rule rule) {
return new ResponseCountChecker((ResponseTimeDataCollector) dataCollector, rule);
}
});
put(CheckerCategory.SLOW_COUNT_TO_CALLEE, new AlarmCheckerFactory() {
@Override
public AlarmChecker<?> createChecker(DataCollector dataCollector, Rule rule) {
return new SlowCountToCalleeChecker((MapStatisticsCallerDataCollector) dataCollector, rule);
}
});
put(CheckerCategory.SLOW_RATE_TO_CALLEE, new AlarmCheckerFactory() {
@Override
public AlarmChecker<?> createChecker(DataCollector dataCollector, Rule rule) {
return new SlowRateToCalleeChecker(dataCollector, rule);
}
});
put(CheckerCategory.ERROR_COUNT_TO_CALLEE, new AlarmCheckerFactory() {
@Override
public AlarmChecker<?> createChecker(DataCollector dataCollector, Rule rule) {
return new ErrorCountToCalleeChecker((MapStatisticsCallerDataCollector) dataCollector, rule);
}
});
put(CheckerCategory.ERROR_RATE_TO_CALLEE, new AlarmCheckerFactory() {
@Override
public AlarmChecker<?> createChecker(DataCollector dataCollector, Rule rule) {
return new ErrorRateToCalleeChecker(dataCollector, rule);
}
});
put(CheckerCategory.TOTAL_COUNT_TO_CALLEE, new AlarmCheckerFactory() {
@Override
public AlarmChecker<?> createChecker(DataCollector dataCollector, Rule rule) {
return new TotalCountToCalleeChecker((MapStatisticsCallerDataCollector) dataCollector, rule);
}
});
put(CheckerCategory.HEAP_USAGE_RATE, new AlarmCheckerFactory() {
@Override
public AlarmChecker<?> createChecker(DataCollector dataCollector, Rule rule) {
return new HeapUsageRateChecker((AgentStatDataCollector) dataCollector, rule);
}
});
// put(CheckerCategory.GC_COUNT, new AlarmCheckerFactory() {
// @Override
// public AlarmChecker<?> createChecker(DataCollector dataCollector, Rule rule) {
// return new GcCountChecker((AgentStatDataCollector)dataCollector, rule);
// }
// });
put(CheckerCategory.JVM_CPU_USAGE_RATE, new AlarmCheckerFactory() {
@Override
public AlarmChecker<?> createChecker(DataCollector dataCollector, Rule rule) {
return new JvmCpuUsageRateChecker((AgentStatDataCollector) dataCollector, rule);
}
});
put(CheckerCategory.SYSTEM_CPU_USAGE_RATE, new AlarmCheckerFactory() {
@Override
public AlarmChecker<?> createChecker(DataCollector dataCollector, Rule rule) {
return new SystemCpuUsageRateChecker((AgentStatDataCollector) dataCollector, rule);
}
});
put(CheckerCategory.DATASOURCE_CONNECTION_USAGE_RATE, new AlarmCheckerFactory() {
@Override
public AlarmChecker<?> createChecker(DataCollector dataCollector, Rule rule) {
return new DataSourceConnectionUsageRateChecker((DataSourceDataCollector) dataCollector, rule);
}
});
put(CheckerCategory.DEADLOCK_OCCURRENCE, new AlarmCheckerFactory() {
@Override
public AlarmChecker<?> createChecker(DataCollector dataCollector, Rule rule) {
return new DeadlockChecker((AgentEventDataCollector) dataCollector, rule);
}
});
put(CheckerCategory.FILE_DESCRIPTOR_COUNT, new AlarmCheckerFactory() {
@Override
public AlarmChecker<?> createChecker(DataCollector dataCollector, Rule rule) {
return new FileDescriptorChecker((FileDescriptorDataCollector) dataCollector, rule);
}
});
}
Aggregations