use of alluxio.stress.TaskResult in project alluxio by Alluxio.
the class StressBenchDefinition method join.
@Override
public String join(StressBenchConfig config, Map<WorkerInfo, String> taskResults) throws Exception {
if (taskResults.isEmpty()) {
throw new IOException("No results from any workers.");
}
AtomicReference<IOException> error = new AtomicReference<>(null);
List<TaskResult> results = taskResults.entrySet().stream().map(entry -> {
try {
return JsonSerializable.fromJson(entry.getValue().trim(), new TaskResult[0]);
} catch (IOException | ClassNotFoundException e) {
// add log here because the exception details are lost at the client side
LOG.warn("Failed to parse result into class {}", TaskResult.class, e);
error.set(new IOException(String.format("Failed to parse task output from %s into result class %s: %s", entry.getKey().getAddress().getHost(), TaskResult.class, entry.getValue().trim()), e));
}
return null;
}).collect(Collectors.toList());
if (error.get() != null) {
throw error.get();
}
return results.get(0).aggregator().aggregate(results).toJson();
}
Aggregations