This commit is contained in:
crusader 2018-05-04 20:44:16 +09:00
parent 7b191518b0
commit f27edde6a6

View File

@ -82,7 +82,7 @@ func (s *CollectorService) RemoveSensorConfigs(sensorConfigs []*ocmsc.SensorConf
} }
for _, sensorConfig := range sensorConfigs { for _, sensorConfig := range sensorConfigs {
s.scheduleMap.Delete(sensorConfig.ConfigID) s.removeSchedule(sensorConfig.ConfigID)
} }
return nil return nil
@ -97,6 +97,15 @@ func (s *CollectorService) addSchedule(interval int64, sensorConfig *ocmsc.Senso
s.scheduleMap.Store(sensorConfig.ConfigID, scheduleID) s.scheduleMap.Store(sensorConfig.ConfigID, scheduleID)
} }
func (s *CollectorService) removeSchedule(configID string) {
scheduleID, ok := s.scheduleMap.Load(configID)
if !ok {
return
}
s.scheduleMap.Delete(configID)
s.scheduler.Cancel(scheduleID.(string))
}
func (s *CollectorService) collectTask(sensorConfig *ocmsc.SensorConfig) { func (s *CollectorService) collectTask(sensorConfig *ocmsc.SensorConfig) {
logging.Logger().Debugf("CollectorService.collectTask for sensor config id[%s] of crawler[%s]", sensorConfig.ConfigID, sensorConfig.Crawler.Name) logging.Logger().Debugf("CollectorService.collectTask for sensor config id[%s] of crawler[%s]", sensorConfig.ConfigID, sensorConfig.Crawler.Name)