diff options
author | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2018-05-11 18:26:57 +0200 |
---|---|---|
committer | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2018-05-11 18:26:57 +0200 |
commit | a176ab885edbffbdf28a7afecf1f174175066173 (patch) | |
tree | f6899a86ef39018d960fb111fafb383e00c2bea2 /src/main/java | |
parent | 3271165f71b5aee7bc9b5186ee2566c8dd2f2626 (diff) |
Fix Sdc controller
Add a check every 2 mins to ensure Sdc controllers are well running
Issue-ID: CLAMP-151
Change-Id: I3c9b10ecc4ce88f60a50484b5e86746ad09a8fc9
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/onap/clamp/clds/Application.java | 2 | ||||
-rw-r--r-- | src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java | 21 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/main/java/org/onap/clamp/clds/Application.java b/src/main/java/org/onap/clamp/clds/Application.java index d9989d433..5975b9d47 100644 --- a/src/main/java/org/onap/clamp/clds/Application.java +++ b/src/main/java/org/onap/clamp/clds/Application.java @@ -48,6 +48,7 @@ import org.springframework.boot.web.support.SpringBootServletInitializer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication @ComponentScan(basePackages = { @@ -59,6 +60,7 @@ import org.springframework.scheduling.annotation.EnableAsync; }) @EnableConfigurationProperties @EnableAsync +@EnableScheduling public class Application extends SpringBootServletInitializer { protected static final EELFLogger EELF_LOGGER = EELFManager.getInstance().getLogger(Application.class); diff --git a/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java b/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java index 7cca263d1..46c483f99 100644 --- a/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java @@ -36,12 +36,14 @@ import org.onap.clamp.clds.config.ClampProperties; import org.onap.clamp.clds.config.sdc.SdcControllersConfiguration; import org.onap.clamp.clds.exception.sdc.controller.SdcControllerException; import org.onap.clamp.clds.sdc.controller.SdcSingleController; +import org.onap.clamp.clds.sdc.controller.SdcSingleControllerStatus; import org.onap.clamp.clds.sdc.controller.installer.CsarInstaller; import org.onap.clamp.clds.sdc.controller.installer.CsarInstallerImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; +import org.springframework.scheduling.annotation.Scheduled; @Configuration @Profile("clamp-sdc-controller") @@ -63,19 +65,34 @@ public class CldsSdcControllerConfiguration { try { sdcController.initSdc(); } catch (SdcControllerException e) { - logger.error("Exception caught during initialization of sdc controller", e); + logger.error("Exception caught when starting sdc controller", e); } sdcControllersList.add(sdcController); }); } + @Scheduled(fixedRate = 120000) + public void checkAllSdcControllers() { + logger.info("Checking that all SDC Controllers defined are up and running"); + for (SdcSingleController controller : sdcControllersList) { + try { + if (SdcSingleControllerStatus.STOPPED.equals(controller.getControllerStatus())) { + controller.initSdc(); + } + } catch (SdcControllerException e) { + logger.error("Exception caught when rebooting sdc controller", e); + } + } + logger.info("SDC Controllers check completed"); + } + @PreDestroy public void killSdcControllers() { sdcControllersList.forEach(e -> { try { e.closeSdc(); } catch (SdcControllerException e1) { - logger.error("Exception caught during initialization of sdc controller", e1); + logger.error("Exception caught when stopping sdc controller", e1); } }); } |