diff --git a/service/SensorConfigService.go b/service/SensorConfigService.go index 6520ef7..17bf1f0 100644 --- a/service/SensorConfigService.go +++ b/service/SensorConfigService.go @@ -126,13 +126,13 @@ func (s *SensorConfigService) UpdateConfig(tempFilePath string) error { return err } - //delete(s.sensorConfigs, sc.ConfigID) - //s.sensorConfigs[sc.ID.String()] = sc - //s.sortSensorConfigPerContainer() - // - //if err := s.ContainerService.Send(occp.ToContainerType(sc.Crawler.Container), "SensorConfigService.UpdateConfig", sc); nil != err { - // return err - //} + delete(s.sensorConfigs, sc.SensorID.String()) + s.sensorConfigs[sc.SensorID.String()] = sc + s.sortSensorConfigPerContainer() + + if err := s.ContainerService.Send(occp.ToContainerType(sc.Crawler.MetaCrawlerContainerKey), "SensorConfigService.UpdateConfig", sc); nil != err { + return err + } return nil } @@ -152,9 +152,9 @@ func (s *SensorConfigService) RemoveConfig(sensorConfigID string) error { delete(s.sensorConfigs, sensorConfigID) s.sortSensorConfigPerContainer() - //if err := s.ContainerService.Send(occp.ToContainerType(sc.Crawler.Container), "SensorConfigService.RemoveConfig", sensorConfigID); nil != err { - // return err - //} + if err := s.ContainerService.Send(occp.ToContainerType(sc.Crawler.MetaCrawlerContainerKey), "SensorConfigService.RemoveConfig", sensorConfigID); nil != err { + return err + } return nil } @@ -283,8 +283,8 @@ func (s *SensorConfigService) sortSensorConfigPerContainer() { s.sensorConfigsPerContainer = nil s.sensorConfigsPerContainer = make(map[occp.ContainerType][]*ocmsc.SensorConfig) - //for _, sensorConfig := range s.sensorConfigs { - // containerType := occp.ToContainerType(sensorConfig.Crawler.Container) - // s.sensorConfigsPerContainer[containerType] = append(s.sensorConfigsPerContainer[containerType], sensorConfig) - //} + for _, sensorConfig := range s.sensorConfigs { + containerType := occp.ToContainerType(sensorConfig.Crawler.MetaCrawlerContainerKey) + s.sensorConfigsPerContainer[containerType] = append(s.sensorConfigsPerContainer[containerType], sensorConfig) + } }