diff options
author | a.sreekumar <ajith.sreekumar@bell.ca> | 2020-08-17 11:29:16 +0100 |
---|---|---|
committer | a.sreekumar <ajith.sreekumar@bell.ca> | 2020-08-18 10:11:01 +0100 |
commit | 5b4ed906ca55a2e24973c391c6006d282e0fe82a (patch) | |
tree | e0d8dd524b84eed3f1b2c914f961d16600954dd0 /services/services-onappf/src/main/java/org | |
parent | 6c3192ce8ef5283b97da0853e39a0d571f6bdd7b (diff) |
Changes to make APEX container crash with non zero exitCode
Change-Id: I1d36c28cfb07881ebede1cf918140397b076512c
Issue-ID: POLICY-2753
Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
Diffstat (limited to 'services/services-onappf/src/main/java/org')
-rw-r--r-- | services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java index 609be10c2..7daa22846 100644 --- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java +++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2020 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,8 +25,10 @@ package org.onap.policy.apex.services.onappf; import java.util.Arrays; import org.onap.policy.apex.service.engine.main.ApexPolicyStatisticsManager; import org.onap.policy.apex.services.onappf.exception.ApexStarterException; +import org.onap.policy.apex.services.onappf.exception.ApexStarterRunTimeException; import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterGroup; import org.onap.policy.apex.services.onappf.parameters.ApexStarterParameterHandler; +import org.onap.policy.common.utils.resources.MessageConstants; import org.onap.policy.common.utils.services.Registry; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,8 +40,6 @@ import org.slf4j.LoggerFactory; */ public class ApexStarterMain { - private static final String APEX_STARTER_FAIL_MSG = "start of services-onappf failed"; - private static final Logger LOGGER = LoggerFactory.getLogger(ApexStarterMain.class); private ApexStarterActivator activator; @@ -65,36 +65,30 @@ public class ApexStarterMain { } // Validate that the arguments are sane arguments.validate(); - } catch (final ApexStarterException e) { - LOGGER.error(APEX_STARTER_FAIL_MSG, e); - return; - } - // Read the parameters - try { + // Read the parameters parameterGroup = new ApexStarterParameterHandler().getParameters(arguments); - } catch (final Exception e) { - LOGGER.error(APEX_STARTER_FAIL_MSG, e); - return; - } - // create the activator - activator = new ApexStarterActivator(parameterGroup); - Registry.register(ApexStarterConstants.REG_APEX_STARTER_ACTIVATOR, activator); - Registry.register(ApexPolicyStatisticsManager.REG_APEX_PDP_POLICY_COUNTER, new ApexPolicyStatisticsManager()); - // Start the activator - try { + // create the activator + activator = new ApexStarterActivator(parameterGroup); + Registry.register(ApexStarterConstants.REG_APEX_STARTER_ACTIVATOR, activator); + Registry.register(ApexPolicyStatisticsManager.REG_APEX_PDP_POLICY_COUNTER, + new ApexPolicyStatisticsManager()); + + // Start the activator activator.initialize(); } catch (final ApexStarterException e) { - LOGGER.error("start of ApexStarter failed, used parameters are {}", Arrays.toString(args), e); - Registry.unregister(ApexStarterConstants.REG_APEX_STARTER_ACTIVATOR); - return; + if (null != activator) { + Registry.unregister(ApexStarterConstants.REG_APEX_STARTER_ACTIVATOR); + } + throw new ApexStarterRunTimeException( + String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_APEX_PDP), e); } // Add a shutdown hook to shut everything down in an orderly manner Runtime.getRuntime().addShutdownHook(new ApexStarterShutdownHookClass()); - - LOGGER.info("Started ApexStarter service"); + String successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_APEX_PDP); + LOGGER.info(successMsg); } /** |