Search in sources :

Example 1 with DataCollector

use of com.navercorp.pinpoint.web.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());
        DataCollector collector = collectorMap.get(checkerCategory.getDataCollectorCategory());
        if (collector == null) {
            collector = dataCollectorFactory.createDataCollector(checkerCategory, application, timeSlotEndTime);
            collectorMap.put(collector.getDataCollectorCategory(), collector);
        }
        AlarmChecker checker = checkerCategory.createChecker(collector, rule);
        checkers.add(checker);
    }
}
Also used : HashMap(java.util.HashMap) DataCollectorCategory(com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory) Rule(com.navercorp.pinpoint.web.alarm.vo.Rule) DataCollector(com.navercorp.pinpoint.web.alarm.collector.DataCollector) AlarmChecker(com.navercorp.pinpoint.web.alarm.checker.AlarmChecker)

Example 2 with DataCollector

use of com.navercorp.pinpoint.web.alarm.collector.DataCollector in project pinpoint by naver.

the class ReaderTest method beforeClass.

@BeforeClass
public static void beforeClass() {
    applicationIndexDao = new ApplicationIndexDao() {

        @Override
        public List<Application> selectAllApplicationNames() {
            List<Application> apps = new LinkedList<Application>();
            for (int i = 0; i < 7; i++) {
                apps.add(new Application(APP_NAME + i, 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() {

        private Map<String, Rule> ruleMap;

        {
            ruleMap = new HashMap<String, Rule>();
            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, ""));
            }
        }

        @Override
        public List<Rule> selectRuleByApplicationId(String applicationId) {
            List<Rule> rules = new LinkedList<Rule>();
            rules.add(ruleMap.get(applicationId));
            return rules;
        }
    };
    dataCollectorFactory = new DataCollectorFactory() {

        @Override
        public DataCollector createDataCollector(CheckerCategory checker, Application application, long timeSlotEndTime) {
            return new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, null, null, 0, 0);
        }
    };
}
Also used : ApplicationIndexDao(com.navercorp.pinpoint.web.dao.ApplicationIndexDao) HashMap(java.util.HashMap) DataCollector(com.navercorp.pinpoint.web.alarm.collector.DataCollector) ResponseTimeDataCollector(com.navercorp.pinpoint.web.alarm.collector.ResponseTimeDataCollector) ResponseTimeDataCollector(com.navercorp.pinpoint.web.alarm.collector.ResponseTimeDataCollector) AlarmServiceImpl(com.navercorp.pinpoint.web.service.AlarmServiceImpl) List(java.util.List) LinkedList(java.util.LinkedList) Rule(com.navercorp.pinpoint.web.alarm.vo.Rule) Application(com.navercorp.pinpoint.web.vo.Application) BeforeClass(org.junit.BeforeClass)

Aggregations

DataCollector (com.navercorp.pinpoint.web.alarm.collector.DataCollector)2 Rule (com.navercorp.pinpoint.web.alarm.vo.Rule)2 HashMap (java.util.HashMap)2 DataCollectorCategory (com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory)1 AlarmChecker (com.navercorp.pinpoint.web.alarm.checker.AlarmChecker)1 ResponseTimeDataCollector (com.navercorp.pinpoint.web.alarm.collector.ResponseTimeDataCollector)1 ApplicationIndexDao (com.navercorp.pinpoint.web.dao.ApplicationIndexDao)1 AlarmServiceImpl (com.navercorp.pinpoint.web.service.AlarmServiceImpl)1 Application (com.navercorp.pinpoint.web.vo.Application)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 BeforeClass (org.junit.BeforeClass)1