From f27edde6a6937491f0e4f4fdae82aa842edcfabf Mon Sep 17 00:00:00 2001 From: crusader Date: Fri, 4 May 2018 20:44:16 +0900 Subject: [PATCH] ing --- service/CollectorService.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/service/CollectorService.go b/service/CollectorService.go index f6bfa93..64fd7f5 100644 --- a/service/CollectorService.go +++ b/service/CollectorService.go @@ -82,7 +82,7 @@ func (s *CollectorService) RemoveSensorConfigs(sensorConfigs []*ocmsc.SensorConf } for _, sensorConfig := range sensorConfigs { - s.scheduleMap.Delete(sensorConfig.ConfigID) + s.removeSchedule(sensorConfig.ConfigID) } return nil @@ -97,6 +97,15 @@ func (s *CollectorService) addSchedule(interval int64, sensorConfig *ocmsc.Senso 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) { logging.Logger().Debugf("CollectorService.collectTask for sensor config id[%s] of crawler[%s]", sensorConfig.ConfigID, sensorConfig.Crawler.Name)