Commit 74f5d34b authored by ipatini's avatar ipatini
Browse files

EMS: Common: Removed @Value annotations and the corresponding fields...

EMS: Common: Removed @Value annotations and the corresponding fields (emsRecoveryFile and netdataRecoveryFile) in recovery Task classes, and replaced them by adding the 'SelfHealingProperties.Recovery.file' Map property that contains the same information.
parent 3af7a6a5
......@@ -11,14 +11,12 @@ package eu.melodic.event.common.recovery;
import eu.melodic.event.common.client.SshClientProperties;
import eu.melodic.event.common.collector.CollectorContext;
import eu.melodic.event.util.EmsConstant;
import eu.melodic.event.util.EventBus;
import eu.melodic.event.util.PasswordUtil;
import lombok.Getter;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.stereotype.Component;
......@@ -42,14 +40,13 @@ public class EmsClientRecoveryTask<P extends SshClientProperties> extends VmNode
"/opt/baguette-client/bin/run.sh",0, 10000)
));
@Value("${" + EmsConstant.EMS_PROPERTIES_PREFIX + "self.healing.recovery.file.baguette:}")
private String emsRecoveryFile;
public EmsClientRecoveryTask(@NonNull EventBus<String, Object, Object> eventBus, @NonNull PasswordUtil passwordUtil, @NonNull TaskScheduler taskScheduler, @NonNull CollectorContext<P> collectorContext) {
super(eventBus, passwordUtil, taskScheduler, collectorContext);
public EmsClientRecoveryTask(@NonNull EventBus<String, Object, Object> eventBus, @NonNull PasswordUtil passwordUtil, @NonNull TaskScheduler taskScheduler, @NonNull CollectorContext<P> collectorContext, @NonNull SelfHealingProperties selfHealingProperties) {
super(eventBus, passwordUtil, taskScheduler, selfHealingProperties, collectorContext);
}
public void runNodeRecovery() throws Exception {
String emsRecoveryFile = selfHealingProperties.getRecovery().getFile().get("baguette");
log.debug("runNodeRecovery: file={}", emsRecoveryFile);
if (StringUtils.isNotBlank(emsRecoveryFile))
runNodeRecovery(emsRecoveryFile);
else
......
......@@ -9,14 +9,12 @@
package eu.melodic.event.common.recovery;
import eu.melodic.event.util.EmsConstant;
import eu.melodic.event.util.EventBus;
import eu.melodic.event.util.PasswordUtil;
import lombok.Getter;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.stereotype.Component;
......@@ -40,14 +38,13 @@ public class NetdataAgentLocalRecoveryTask extends ShellRecoveryTask {
"sudo netdata",0, 10000)
));
@Value("${" + EmsConstant.EMS_PROPERTIES_PREFIX + "self.healing.recovery.file.netdata:}")
private String netdataRecoveryFile;
public NetdataAgentLocalRecoveryTask(@NonNull EventBus<String, Object, Object> eventBus, @NonNull PasswordUtil passwordUtil, @NonNull TaskScheduler taskScheduler) {
super(eventBus, taskScheduler);
public NetdataAgentLocalRecoveryTask(@NonNull EventBus<String, Object, Object> eventBus, @NonNull PasswordUtil passwordUtil, @NonNull TaskScheduler taskScheduler, @NonNull SelfHealingProperties selfHealingProperties) {
super(eventBus, passwordUtil, taskScheduler, selfHealingProperties);
}
public void runNodeRecovery() throws Exception {
String netdataRecoveryFile = selfHealingProperties.getRecovery().getFile().get("netdata");
log.debug("runNodeRecovery: file={}", netdataRecoveryFile);
if (StringUtils.isNotBlank(netdataRecoveryFile))
runNodeRecovery(netdataRecoveryFile);
else
......
......@@ -11,14 +11,12 @@ package eu.melodic.event.common.recovery;
import eu.melodic.event.common.client.SshClientProperties;
import eu.melodic.event.common.collector.CollectorContext;
import eu.melodic.event.util.EmsConstant;
import eu.melodic.event.util.EventBus;
import eu.melodic.event.util.PasswordUtil;
import lombok.Getter;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.stereotype.Component;
......@@ -42,14 +40,13 @@ public class NetdataAgentRecoveryTask<P extends SshClientProperties> extends VmN
"sudo netdata",0, 10000)
));
@Value("${" + EmsConstant.EMS_PROPERTIES_PREFIX + "self.healing.recovery.file.netdata:}")
private String netdataRecoveryFile;
public NetdataAgentRecoveryTask(@NonNull EventBus<String, Object, Object> eventBus, @NonNull PasswordUtil passwordUtil, @NonNull TaskScheduler taskScheduler, @NonNull CollectorContext<P> collectorContext) {
super(eventBus, passwordUtil, taskScheduler, collectorContext);
public NetdataAgentRecoveryTask(@NonNull EventBus<String, Object, Object> eventBus, @NonNull PasswordUtil passwordUtil, @NonNull TaskScheduler taskScheduler, @NonNull CollectorContext<P> collectorContext, @NonNull SelfHealingProperties selfHealingProperties) {
super(eventBus, passwordUtil, taskScheduler, selfHealingProperties, collectorContext);
}
public void runNodeRecovery() throws Exception {
String netdataRecoveryFile = selfHealingProperties.getRecovery().getFile().get("netdata");
log.debug("runNodeRecovery: file={}", netdataRecoveryFile);
if (StringUtils.isNotBlank(netdataRecoveryFile))
runNodeRecovery(netdataRecoveryFile);
else
......
......@@ -14,6 +14,9 @@ import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import java.util.HashMap;
import java.util.Map;
@Data
@Configuration
@ConfigurationProperties(prefix = EmsConstant.EMS_PROPERTIES_PREFIX + "self.healing")
......@@ -26,5 +29,7 @@ public class SelfHealingProperties {
private long delay = 10000;
private long retryDelay = 60000;
private int maxRetries = 3;
private Map<String,String> file = new HashMap<>();
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment