use of teetime.stage.taskfarm.exception.TaskFarmInvalidPipeException in project TeeTime by teetime-framework.
the class TaskFarmHistoryService method getSumOfPipePushThroughputs.
private double getSumOfPipePushThroughputs() {
this.lastPullThroughputs = new HashMap<IMonitorablePipe, Long>();
this.lastPushThroughputs = new HashMap<IMonitorablePipe, Long>();
// NOPMD
double sum = 0;
try {
for (ITaskFarmDuplicable<I, O> enclosedStage : this.taskFarmStage.getWorkerStages()) {
IMonitorablePipe inputPipe = (IMonitorablePipe) enclosedStage.getInputPort().getPipe();
if (inputPipe != null) {
// we record the throughput measurements as a sum in the history
// and separately in maps for further use
long pushThroughput = inputPipe.getPushThroughput();
this.lastPushThroughputs.put(inputPipe, pushThroughput);
long pullThroughput = inputPipe.getPullThroughput();
this.lastPullThroughputs.put(inputPipe, pullThroughput);
sum += pullThroughput;
}
}
} 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.", e);
}
return sum;
}
use of teetime.stage.taskfarm.exception.TaskFarmInvalidPipeException in project TeeTime by teetime-framework.
the class DynamicTaskFarmStage method getStageIndexWithLeastRemainingInput.
// FIXME the task farm itself should not choose which stage to remove.
// Instead, a strategy from outside the task farm should determine.
private int getStageIndexWithLeastRemainingInput() {
// NOPMD (DU: caused by loop)
int currentMinimum = Integer.MAX_VALUE;
// NOPMD (DU: caused by loop)
int currentMinumumStageIndex = getWorkerStages().size() - 1;
// do not remove basic stage
for (int i = 1; i < getWorkerStages().size(); i++) {
final ITaskFarmDuplicable<I, O> instance = getWorkerStages().get(i);
InputPort<I> port = instance.getInputPort();
IMonitorablePipe monitorablePipe = null;
try {
monitorablePipe = (IMonitorablePipe) port.getPipe();
} 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. Instead, the type is " + port.getPipe().getClass().getSimpleName() + ".", e);
}
if (monitorablePipe != null && monitorablePipe.size() < currentMinimum) {
currentMinimum = monitorablePipe.size();
currentMinumumStageIndex = i;
}
}
return currentMinumumStageIndex;
}
use of teetime.stage.taskfarm.exception.TaskFarmInvalidPipeException in project TeeTime by teetime-framework.
the class SingleTaskFarmMonitoringService method getMeanAndSumThroughput.
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
private double getMeanAndSumThroughput(final DynamicTaskFarmStage<?, ?, ?> taskFarmStage, final MeanThroughputType type, final boolean mean) {
double sum = 0;
double count = 0;
try {
for (ITaskFarmDuplicable<?, ?> enclosedStage : taskFarmStage.getWorkerStages()) {
IMonitorablePipe inputPipe = (IMonitorablePipe) enclosedStage.getInputPort().getPipe();
if (inputPipe != null) {
long pullThroughput = 0;
long pushThroughput = 0;
if (this.history == null) {
pullThroughput = inputPipe.getPullThroughput();
pushThroughput = inputPipe.getPushThroughput();
} else {
pullThroughput = this.history.getLastPullThroughputOfPipe(inputPipe);
pushThroughput = this.history.getLastPushThroughputOfPipe(inputPipe);
}
switch(type) {
case PULL:
sum += pullThroughput;
break;
case PUSH:
sum += pushThroughput;
break;
default:
break;
}
count++;
}
}
} 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.", e);
}
// calculate the mean value if necessary
if (mean && count > 0) {
sum /= count;
}
return sum;
}
Aggregations