use of com.navercorp.pinpoint.batch.alarm.collector.DataCollector in project pinpoint by naver.
the class AlarmReaderTest method beforeClass.
@BeforeClass
public static void beforeClass() {
applicationIndexDao = new ApplicationIndexDao() {
@Override
public List<Application> selectAllApplicationNames() {
List<Application> apps = new LinkedList<>();
for (int i = 0; i < 7; i++) {
apps.add(new Application(APP_NAME + i, ServiceType.STAND_ALONE));
}
return apps;
}
@Override
public List<Application> selectApplicationName(String applicationName) {
List<Application> apps = new LinkedList<>();
apps.add(new Application(APP_NAME, ServiceType.STAND_ALONE));
return apps;
}
@Override
public List<String> selectAgentIds(String applicationName) {
return null;
}
@Override
public void deleteApplicationName(String applicationName) {
}
@Override
public void deleteAgentIds(Map<String, List<String>> applicationAgentIdMap) {
}
@Override
public void deleteAgentId(String applicationName, String agentId) {
}
};
alarmService = new AlarmServiceImpl(mock(AlarmDao.class), mock(WebhookSendInfoDao.class)) {
private final Map<String, Rule> ruleMap;
{
ruleMap = new HashMap<>();
for (int i = 0; i <= 6; i++) {
ruleMap.put(APP_NAME + i, new Rule(APP_NAME + i, SERVICE_TYPE, CheckerCategory.SLOW_COUNT.getName(), 76, "testGroup", false, false, false, ""));
}
}
@Override
public List<Rule> selectRuleByApplicationId(String applicationId) {
List<Rule> rules = new LinkedList<>();
rules.add(ruleMap.get(applicationId));
return rules;
}
};
dataCollectorFactory = mock(DataCollectorFactory.class);
when(dataCollectorFactory.createDataCollector(any(), any(), anyLong())).thenAnswer(new Answer<DataCollector>() {
@Override
public DataCollector answer(InvocationOnMock invocation) throws Throwable {
return new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, null, null, 0, 0);
}
});
}
use of com.navercorp.pinpoint.batch.alarm.collector.DataCollector in project pinpoint by naver.
the class AlarmReader method addChecker.
private void addChecker(Application application) {
List<Rule> rules = alarmService.selectRuleByApplicationId(application.getName());
long timeSlotEndTime = System.currentTimeMillis();
Map<DataCollectorCategory, DataCollector> collectorMap = new HashMap<>();
for (Rule rule : rules) {
CheckerCategory checkerCategory = CheckerCategory.getValue(rule.getCheckerName());
AlarmCheckerFactory factory = checkerRegistry.getCheckerFactory(checkerCategory);
DataCollector collector = collectorMap.get(checkerCategory.getDataCollectorCategory());
if (collector == null) {
collector = dataCollectorFactory.createDataCollector(checkerCategory, application, timeSlotEndTime);
collectorMap.put(collector.getDataCollectorCategory(), collector);
}
AlarmChecker<?> checker = factory.createChecker(collector, rule);
checkers.add(checker);
}
}
use of com.navercorp.pinpoint.batch.alarm.collector.DataCollector 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