diff --git a/src/main/java/teetime/framework/Execution.java b/src/main/java/teetime/framework/Execution.java index 660133e77ce972305d48699958a3838f66017045..7eb7ffa761dc1790baa35ea0186a80226abdef54 100644 --- a/src/main/java/teetime/framework/Execution.java +++ b/src/main/java/teetime/framework/Execution.java @@ -180,11 +180,17 @@ public final class Execution<T extends Configuration> { instances.add((Configuration) obj); } } catch (ClassNotFoundException e) { - LOGGER.error("Could not find class " + each); + if (LOGGER.isErrorEnabled()) { + LOGGER.error("Could not find class " + each); + } } catch (InstantiationException e) { - LOGGER.error("Could not instantiate class " + each, e); + if (LOGGER.isErrorEnabled()) { + LOGGER.error("Could not instantiate class " + each, e); + } } catch (IllegalAccessException e) { - LOGGER.error("IllegalAccessException arised while instantiating class " + each, e); + if (LOGGER.isErrorEnabled()) { + LOGGER.error("IllegalAccessException arised while instantiating class " + each, e); + } } } return instances; diff --git a/src/main/java/teetime/framework/exceptionHandling/AbstractExceptionListener.java b/src/main/java/teetime/framework/exceptionHandling/AbstractExceptionListener.java index 2960103df1aaee8cca029543a7c646b27c0de638..80ff5314ecbbca89b39a5703ed7eda8db3b5a83e 100644 --- a/src/main/java/teetime/framework/exceptionHandling/AbstractExceptionListener.java +++ b/src/main/java/teetime/framework/exceptionHandling/AbstractExceptionListener.java @@ -26,7 +26,8 @@ import teetime.framework.AbstractStage; /** * Represents a minimalistic StageExceptionListener. * Listener which extend from this one, must a least implement this functionality. - * This abstract class provides a Logger {@link #logger} and the method {@link #onStageException(Exception, AbstractStage)} which is called on every raised exception. + * This abstract class provides a Logger {@link #logger} and the method {@link #onStageException(Exception, AbstractStage)} which is called on every raised + * exception. */ public abstract class AbstractExceptionListener { diff --git a/src/main/java/teetime/framework/exceptionHandling/LoggingExceptionListener.java b/src/main/java/teetime/framework/exceptionHandling/LoggingExceptionListener.java index d2ed8a3b77ba1d74a2efb00b9aae79780124d889..8d992e6a6adba96c25326c63bc8b6d163a7204d4 100644 --- a/src/main/java/teetime/framework/exceptionHandling/LoggingExceptionListener.java +++ b/src/main/java/teetime/framework/exceptionHandling/LoggingExceptionListener.java @@ -25,7 +25,9 @@ class LoggingExceptionListener extends AbstractExceptionListener { @Override public FurtherExecution onStageException(final Exception e, final AbstractStage throwingStage) { - logger.warn("Exception occurred in " + throwingStage.getId(), e); + if (logger.isWarnEnabled()) { + logger.warn("Exception occurred in " + throwingStage.getId(), e); + } return FurtherExecution.CONTINUE; } diff --git a/src/main/java/teetime/stage/taskfarm/adaptation/history/TaskFarmHistoryService.java b/src/main/java/teetime/stage/taskfarm/adaptation/history/TaskFarmHistoryService.java index 4a44caec144f0cb6d75c4a1c9d9af8d704a7e893..036e22f9046f76a7501c2eb8a708ce6694676190 100644 --- a/src/main/java/teetime/stage/taskfarm/adaptation/history/TaskFarmHistoryService.java +++ b/src/main/java/teetime/stage/taskfarm/adaptation/history/TaskFarmHistoryService.java @@ -93,7 +93,8 @@ public class TaskFarmHistoryService<I, O, T extends ITaskFarmDuplicable<I, O>> { } catch (ClassCastException e) { throw new TaskFarmInvalidPipeException( "The input pipe of an enclosed stage instance inside a Task Farm" - + " does not implement IMonitorablePipe, which is required."); + + " does not implement IMonitorablePipe, which is required.", + e); } return sum; diff --git a/src/main/java/teetime/stage/taskfarm/adaptation/reconfiguration/TaskFarmController.java b/src/main/java/teetime/stage/taskfarm/adaptation/reconfiguration/TaskFarmController.java index e681cdeb299b39c00203debc0f786b9946d40dab..c5277afa0ff8a696c641759caca59a831d2f482b 100644 --- a/src/main/java/teetime/stage/taskfarm/adaptation/reconfiguration/TaskFarmController.java +++ b/src/main/java/teetime/stage/taskfarm/adaptation/reconfiguration/TaskFarmController.java @@ -70,7 +70,9 @@ class TaskFarmController<I, O> { * @throws InterruptedException */ public void addStageToTaskFarm() throws InterruptedException { - LOGGER.debug("Add stage (current amount of stages: " + this.taskFarmStage.getEnclosedStageInstances().size() + ")"); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Add stage (current amount of stages: " + this.taskFarmStage.getEnclosedStageInstances().size() + ")"); + } ITaskFarmDuplicable<I, O> newStage = this.taskFarmStage.getBasicEnclosedStage().duplicate(); final CreatePortActionDistributor<I> distributorPortAction = new CreatePortActionDistributor<I>(newStage.getInputPort(), @@ -105,7 +107,7 @@ class TaskFarmController<I, O> { try { this.taskFarmStage.getPipeMonitoringService().addMonitoredItem((IMonitorablePipe) newStage.getInputPort().getPipe()); } catch (ClassCastException e) { - throw new TaskFarmControllerException("A generated pipe is not monitorable."); + throw new TaskFarmControllerException("A generated pipe is not monitorable.", e); } } } @@ -120,10 +122,11 @@ class TaskFarmController<I, O> { return; } - LOGGER.debug("Remove stage (current amount of stages: " + this.taskFarmStage.getEnclosedStageInstances().size() + ")"); - - ITaskFarmDuplicable<I, O> stageToBeRemoved = null; - OutputPort<?> distributorOutputPort = null; + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Remove stage (current amount of stages: " + this.taskFarmStage.getEnclosedStageInstances().size() + ")"); + } + ITaskFarmDuplicable<I, O> stageToBeRemoved; + OutputPort<?> distributorOutputPort; stageToBeRemoved = this.getStageToBeRemoved(); distributorOutputPort = this.getRemoveableDistributorOutputPort(stageToBeRemoved); @@ -140,7 +143,7 @@ class TaskFarmController<I, O> { return; } } catch (ClassCastException e) { - throw new TaskFarmControllerException("Merger and Distributor have a different type than the Task Farm or the Task Farm Controller."); + throw new TaskFarmControllerException("Merger and Distributor have a different type than the Task Farm or the Task Farm Controller.", e); } } @@ -161,14 +164,14 @@ class TaskFarmController<I, O> { } private int getStageIndexWithLeastRemainingInput() { - int currentMinimum = Integer.MAX_VALUE; - int currentMinumumStageIndex = this.taskFarmStage.getEnclosedStageInstances().size() - 1; + int currentMinimum = Integer.MAX_VALUE; // NOPMD DU caused by loop + int currentMinumumStageIndex = this.taskFarmStage.getEnclosedStageInstances().size() - 1; // NOPMD // do not remove basic stage for (int i = 1; i < this.taskFarmStage.getEnclosedStageInstances().size(); i++) { ITaskFarmDuplicable<I, O> instance = this.taskFarmStage.getEnclosedStageInstances().get(i); InputPort<I> port = instance.getInputPort(); - IMonitorablePipe monitorablePipe = null; + IMonitorablePipe monitorablePipe; try { monitorablePipe = (IMonitorablePipe) port.getPipe(); @@ -176,13 +179,14 @@ class TaskFarmController<I, O> { throw new TaskFarmInvalidPipeException( "The input pipe of an enclosed stage instance inside a Task Farm" + " does not implement IMonitorablePipe, which is required. Instead, the type is " - + port.getPipe().getClass().getSimpleName() + "."); + + port.getPipe().getClass().getSimpleName() + ".", + e); } - if (monitorablePipe != null && monitorablePipe.size() < currentMinimum) { currentMinimum = monitorablePipe.size(); currentMinumumStageIndex = i; } + } return currentMinumumStageIndex; diff --git a/src/main/java/teetime/stage/taskfarm/exception/TaskFarmControllerException.java b/src/main/java/teetime/stage/taskfarm/exception/TaskFarmControllerException.java index 2bdc625dd4ce975b8cdfb3a17ff07f5e732cf204..d86220592e895df4c970f23ead5827a765eb597b 100644 --- a/src/main/java/teetime/stage/taskfarm/exception/TaskFarmControllerException.java +++ b/src/main/java/teetime/stage/taskfarm/exception/TaskFarmControllerException.java @@ -30,12 +30,12 @@ public class TaskFarmControllerException extends RuntimeException { * Represents an exception thrown by the task farm reconfiguration component. It * gets thrown if the reconfiguration component is not able to add or remove a * worker stage. - * + * * @param s * error message */ - public TaskFarmControllerException(final String s) { - super(s); + public TaskFarmControllerException(final String s, final Throwable cause) { + super(s, cause); } } diff --git a/src/main/java/teetime/stage/taskfarm/exception/TaskFarmInvalidPipeException.java b/src/main/java/teetime/stage/taskfarm/exception/TaskFarmInvalidPipeException.java index 3bc6893943309163fd29982902029e1270642f53..97cb43cf04bc8a7699b709f34ac5714e9aece6a1 100644 --- a/src/main/java/teetime/stage/taskfarm/exception/TaskFarmInvalidPipeException.java +++ b/src/main/java/teetime/stage/taskfarm/exception/TaskFarmInvalidPipeException.java @@ -30,12 +30,12 @@ public class TaskFarmInvalidPipeException extends RuntimeException { * Represents an exception thrown by the task farm. It * gets thrown if the user tries to monitor a pipe which * does not implement {@link teetime.framework.pipe.IMonitorablePipe IMonitorablePipe}. - * + * * @param s * error message */ - public TaskFarmInvalidPipeException(final String s) { - super(s); + public TaskFarmInvalidPipeException(final String s, final Throwable cause) { + super(s, cause); } } diff --git a/src/main/java/teetime/stage/taskfarm/monitoring/SingleTaskFarmMonitoringService.java b/src/main/java/teetime/stage/taskfarm/monitoring/SingleTaskFarmMonitoringService.java index ca1c6cb9f667e929c71aace7aa2479698f4e24bc..a85fd80c073d7720da988cf70744e39f14a3d4fe 100644 --- a/src/main/java/teetime/stage/taskfarm/monitoring/SingleTaskFarmMonitoringService.java +++ b/src/main/java/teetime/stage/taskfarm/monitoring/SingleTaskFarmMonitoringService.java @@ -138,7 +138,8 @@ public class SingleTaskFarmMonitoringService implements IMonitoringService<TaskF } catch (ClassCastException e) { throw new TaskFarmInvalidPipeException( "The input pipe of an enclosed stage instance inside a Task Farm" - + " does not implement IMonitorablePipe, which is required."); + + " does not implement IMonitorablePipe, which is required.", + e); } // calculate the mean value if necessary diff --git a/src/main/java/teetime/util/framework/list/ListContainerPool.java b/src/main/java/teetime/util/framework/list/ListContainerPool.java index 6aafdee3e42f63b4b5860e214a4f616f4234b54a..ee4d2c270b05aead83dd9d6898bca28591b473d0 100644 --- a/src/main/java/teetime/util/framework/list/ListContainerPool.java +++ b/src/main/java/teetime/util/framework/list/ListContainerPool.java @@ -20,9 +20,9 @@ import java.util.List; public final class ListContainerPool<T> implements ObjectPool<ListContainer<T>> { - private final List<ListContainer<T>> pool = new ArrayList<ListContainer<T>>(); + private final List<ListContainer<T>> pool = new ArrayList<ListContainer<T>>(); - public ListContainerPool(int initialPoolSize) { + public ListContainerPool(int initialPoolSize) { // NOPMD while (initialPoolSize-- > 0) { this.pool.add(this.createNew()); }