aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core
diff options
context:
space:
mode:
authortalig <talig@amdocs.com>2017-09-13 18:16:36 +0300
committertalig <talig@amdocs.com>2017-09-13 18:25:16 +0300
commit3e805e4880fb799a7e1eac6ac3ee14162fa1e9e6 (patch)
tree4cf2cbaacb96c96be742804ed002cec21785c096 /openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core
parent45e38d57442499a535f2915aab95a057e106d79f (diff)
Change healing manager logic
Execute all healers even if one/more have failed. Turn off vsp old version indication and log healers errors. This is a temporary solution that would fix non-heat issues only. Change-Id: I1fbcd3cc33a0520034b3dd373e2cfbe7339c06bd Issue-ID: SDC-332 Signed-off-by: talig <talig@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core')
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java72
1 files changed, 46 insertions, 26 deletions
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
index 0f2c0e7ee1..16f9c60d7f 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
@@ -20,6 +20,7 @@
package org.openecomp.sdc.healing.impl;
+import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.sdc.common.errors.Messages;
@@ -33,8 +34,10 @@ import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
-import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
import java.util.Map;
+import java.util.Optional;
/**
* Created by Talio on 11/29/2016.
@@ -45,34 +48,53 @@ public class HealingManagerImpl implements HealingManager {
@Override
public Object heal(HealCode code, Map<String, Object> healParameters) {
- String implClassName = healerCodeToImplClass.get(code.name());
- try {
- Healer healerImpl = getHealerImplInstance(implClassName);
- return healerImpl.heal(healParameters);
+ ArrayList<String> healingFailureMessages = new ArrayList<>();
+
+ Object result =
+ heal(healParameters, healerCodeToImplClass.get(code.name()), healingFailureMessages);
+
+ if (!healingFailureMessages.isEmpty()) {
+ throw new RuntimeException(CommonMethods.listToSeparatedString(healingFailureMessages, '\n'));
+ }
+ return result;
+ }
+ @Override
+ public Optional<String> healAll(Map<String, Object> healParameters) {
+ ArrayList<String> healingFailureMessages = new ArrayList<>();
+
+ for (String implClassName : healerCodeToImplClass.values()) {
+ heal(healParameters, implClassName, healingFailureMessages);
+ }
+
+ return healingFailureMessages.isEmpty() ? Optional.empty()
+ : Optional.of(CommonMethods.listToSeparatedString(healingFailureMessages, '\n'));
+ }
+
+ private Object heal(Map<String, Object> healParameters, String healerImplClassName,
+ ArrayList<String> healingFailureMessages) {
+ Healer healerImpl;
+ try {
+ healerImpl = getHealerImplInstance(healerImplClassName);
} catch (Exception e) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.SELF_HEALING, ErrorLevel.ERROR.name(), LoggerErrorCode
.DATA_ERROR.getErrorCode(), LoggerErrorDescription.CANT_HEAL);
- throw new RuntimeException(String.format(Messages.CANT_LOAD_CLASS.getErrorMessage(),
- implClassName, e.getMessage()));
+ healingFailureMessages
+ .add(String.format(Messages.CANT_LOAD_HEALING_CLASS.getErrorMessage(),
+ healerImplClassName));
+ return null;
}
- }
- @Override
- public void healAll(Map<String, Object> healParameters) {
- for (String implClassName : healerCodeToImplClass.values()) {
- try {
- Healer healerImpl = getHealerImplInstance(implClassName);
- healerImpl.heal(healParameters);
- } catch (Exception e) {
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.SELF_HEALING, ErrorLevel.ERROR.name(), LoggerErrorCode
- .DATA_ERROR.getErrorCode(), LoggerErrorDescription.CANT_HEAL);
- throw new RuntimeException(String.format(Messages.CANT_LOAD_CLASS.getErrorMessage(),
- implClassName, e.getMessage()));
- }
+ try {
+ return healerImpl.heal(healParameters);
+ } catch (Exception e) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.SELF_HEALING, ErrorLevel.ERROR.name(), LoggerErrorCode
+ .DATA_ERROR.getErrorCode(), LoggerErrorDescription.CANT_HEAL);
+ healingFailureMessages.add(e.getMessage());
}
+ return null;
}
private static Map<String, String> initHealers() {
@@ -80,10 +102,8 @@ public class HealingManagerImpl implements HealingManager {
}
private Healer getHealerImplInstance(String implClassName)
- throws ClassNotFoundException, NoSuchMethodException, InstantiationException,
- IllegalAccessException, java.lang.reflect.InvocationTargetException {
- Class<?> clazz = Class.forName(implClassName);
- Constructor<?> constructor = clazz.getConstructor();
- return (Healer) constructor.newInstance();
+ throws InstantiationException, IllegalAccessException, InvocationTargetException,
+ NoSuchMethodException, ClassNotFoundException {
+ return (Healer) Class.forName(implClassName).getConstructor().newInstance();
}
}