@Test public void callSelfHealing () { final AtomicBoolean selfHealingMethodCalled = new AtomicBoolean(false); experiment.setExperimentState(SELF_HEALING); doNothing().when(experiment).evaluateRunningExperiment(); doReturn(true).when(experiment).canRunSelfHealing(); experiment.setSelfHealingMethod(() -> selfHealingMethodCalled.set(true)); experiment.callSelfHealing(); verify(experiment).evaluateRunningExperiment(); assertTrue(selfHealingMethodCalled.get()); }
void callSelfHealing () { int selfHealingAttempts = getSelfHealingCounter().get(); try { if (canRunSelfHealing()) { selfHealingAttempts = getSelfHealingCounter().incrementAndGet(); log.info("Running self healing for the {} time", selfHealingAttempts); sendNotification(NotificationLevel.WARN, "Running self healing for the " + selfHealingAttempts + " time."); lastSelfHealingTime = Instant.now(); selfHealingMethod.run(); } } catch (Exception e) { sendNotification(NotificationLevel.ERROR, AN_EXCEPTION_OCCURRED_WHILE_RUNNING_SELF_HEALING); log.error("An error occurred while calling self healing method", e); } finally { evaluateRunningExperiment(); if (selfHealingAttempts >= DEFAULT_MAXIMUM_SELF_HEALING_RETRIES && getExperimentState().equals(ExperimentState.SELF_HEALING)) { sendNotification(NotificationLevel.ERROR, MAXIMUM_SELF_HEALING_RETRIES_REACHED); setExperimentState(ExperimentState.FAILED); } } }
Experiment { void callSelfHealing () { int selfHealingAttempts = getSelfHealingCounter().get(); try { if (canRunSelfHealing()) { selfHealingAttempts = getSelfHealingCounter().incrementAndGet(); log.info("Running self healing for the {} time", selfHealingAttempts); sendNotification(NotificationLevel.WARN, "Running self healing for the " + selfHealingAttempts + " time."); lastSelfHealingTime = Instant.now(); selfHealingMethod.run(); } } catch (Exception e) { sendNotification(NotificationLevel.ERROR, AN_EXCEPTION_OCCURRED_WHILE_RUNNING_SELF_HEALING); log.error("An error occurred while calling self healing method", e); } finally { evaluateRunningExperiment(); if (selfHealingAttempts >= DEFAULT_MAXIMUM_SELF_HEALING_RETRIES && getExperimentState().equals(ExperimentState.SELF_HEALING)) { sendNotification(NotificationLevel.ERROR, MAXIMUM_SELF_HEALING_RETRIES_REACHED); setExperimentState(ExperimentState.FAILED); } } } }
Experiment { void callSelfHealing () { int selfHealingAttempts = getSelfHealingCounter().get(); try { if (canRunSelfHealing()) { selfHealingAttempts = getSelfHealingCounter().incrementAndGet(); log.info("Running self healing for the {} time", selfHealingAttempts); sendNotification(NotificationLevel.WARN, "Running self healing for the " + selfHealingAttempts + " time."); lastSelfHealingTime = Instant.now(); selfHealingMethod.run(); } } catch (Exception e) { sendNotification(NotificationLevel.ERROR, AN_EXCEPTION_OCCURRED_WHILE_RUNNING_SELF_HEALING); log.error("An error occurred while calling self healing method", e); } finally { evaluateRunningExperiment(); if (selfHealingAttempts >= DEFAULT_MAXIMUM_SELF_HEALING_RETRIES && getExperimentState().equals(ExperimentState.SELF_HEALING)) { sendNotification(NotificationLevel.ERROR, MAXIMUM_SELF_HEALING_RETRIES_REACHED); setExperimentState(ExperimentState.FAILED); } } } Experiment(Container container); }
Experiment { void callSelfHealing () { int selfHealingAttempts = getSelfHealingCounter().get(); try { if (canRunSelfHealing()) { selfHealingAttempts = getSelfHealingCounter().incrementAndGet(); log.info("Running self healing for the {} time", selfHealingAttempts); sendNotification(NotificationLevel.WARN, "Running self healing for the " + selfHealingAttempts + " time."); lastSelfHealingTime = Instant.now(); selfHealingMethod.run(); } } catch (Exception e) { sendNotification(NotificationLevel.ERROR, AN_EXCEPTION_OCCURRED_WHILE_RUNNING_SELF_HEALING); log.error("An error occurred while calling self healing method", e); } finally { evaluateRunningExperiment(); if (selfHealingAttempts >= DEFAULT_MAXIMUM_SELF_HEALING_RETRIES && getExperimentState().equals(ExperimentState.SELF_HEALING)) { sendNotification(NotificationLevel.ERROR, MAXIMUM_SELF_HEALING_RETRIES_REACHED); setExperimentState(ExperimentState.FAILED); } } } Experiment(Container container); String getExperimentMethodName(); Container getContainer(); void setPreferredExperiment(String preferredExperiment); Instant getLastSelfHealingTime(); @JsonIgnore Platform getExperimentLayer(); String getExperimentLayerName(); @JsonIgnore ExperimentMethod getExperimentMethod(); Runnable getSelfHealingMethod(); void setSelfHealingMethod(Runnable selfHealingMethod); @JsonIgnore Runnable getFinalizeMethod(); void setFinalizeMethod(Runnable finalizeMethod); @JsonIgnore Callable<ContainerHealth> getCheckContainerHealth(); void setCheckContainerHealth(Callable<ContainerHealth> checkContainerHealth); void setFinalizationDuration(Duration finalizationDuration); String getId(); ExperimentType getExperimentType(); AtomicInteger getSelfHealingCounter(); ExperimentState getExperimentState(); Instant getStartTime(); void setMinimumDuration(Duration minimumDuration); void setMaximumDuration(Duration maximumDuration); Boolean getWasSelfHealingRequired(); @Override String toString(); }
Experiment { void callSelfHealing () { int selfHealingAttempts = getSelfHealingCounter().get(); try { if (canRunSelfHealing()) { selfHealingAttempts = getSelfHealingCounter().incrementAndGet(); log.info("Running self healing for the {} time", selfHealingAttempts); sendNotification(NotificationLevel.WARN, "Running self healing for the " + selfHealingAttempts + " time."); lastSelfHealingTime = Instant.now(); selfHealingMethod.run(); } } catch (Exception e) { sendNotification(NotificationLevel.ERROR, AN_EXCEPTION_OCCURRED_WHILE_RUNNING_SELF_HEALING); log.error("An error occurred while calling self healing method", e); } finally { evaluateRunningExperiment(); if (selfHealingAttempts >= DEFAULT_MAXIMUM_SELF_HEALING_RETRIES && getExperimentState().equals(ExperimentState.SELF_HEALING)) { sendNotification(NotificationLevel.ERROR, MAXIMUM_SELF_HEALING_RETRIES_REACHED); setExperimentState(ExperimentState.FAILED); } } } Experiment(Container container); String getExperimentMethodName(); Container getContainer(); void setPreferredExperiment(String preferredExperiment); Instant getLastSelfHealingTime(); @JsonIgnore Platform getExperimentLayer(); String getExperimentLayerName(); @JsonIgnore ExperimentMethod getExperimentMethod(); Runnable getSelfHealingMethod(); void setSelfHealingMethod(Runnable selfHealingMethod); @JsonIgnore Runnable getFinalizeMethod(); void setFinalizeMethod(Runnable finalizeMethod); @JsonIgnore Callable<ContainerHealth> getCheckContainerHealth(); void setCheckContainerHealth(Callable<ContainerHealth> checkContainerHealth); void setFinalizationDuration(Duration finalizationDuration); String getId(); ExperimentType getExperimentType(); AtomicInteger getSelfHealingCounter(); ExperimentState getExperimentState(); Instant getStartTime(); void setMinimumDuration(Duration minimumDuration); void setMaximumDuration(Duration maximumDuration); Boolean getWasSelfHealingRequired(); @Override String toString();  }