Search in sources :

Example 1 with StressBenchConfig

use of alluxio.stress.job.StressBenchConfig in project alluxio by Alluxio.

the class StressBenchDefinition method selectExecutors.

@Override
public Set<Pair<WorkerInfo, ArrayList<String>>> selectExecutors(StressBenchConfig config, List<WorkerInfo> jobWorkerInfoList, SelectExecutorsContext context) {
    Set<Pair<WorkerInfo, ArrayList<String>>> result = Sets.newHashSet();
    // sort copy of workers by hashcode
    List<WorkerInfo> workerList = Lists.newArrayList(jobWorkerInfoList);
    workerList.sort(Comparator.comparing(w -> w.getAddress().getHost()));
    // take the first subset, according to cluster limit
    int clusterLimit = config.getClusterLimit();
    if (clusterLimit == 0) {
        clusterLimit = workerList.size();
    }
    if (clusterLimit < 0) {
        // if negative, reverse the list
        clusterLimit = -clusterLimit;
        Collections.reverse(workerList);
    }
    workerList = workerList.subList(0, clusterLimit);
    for (WorkerInfo worker : workerList) {
        LOG.info("Generating job for worker {}", worker.getId());
        ArrayList<String> args = new ArrayList<>(2);
        // Add the worker hostname + worker id as the unique task id for each distributed task.
        // The worker id is used since there may be multiple workers on a single host.
        args.add(BaseParameters.ID_FLAG);
        args.add(worker.getAddress().getHost() + "-" + worker.getId());
        result.add(new Pair<>(worker, args));
    }
    return result;
}
Also used : JsonSerializable(alluxio.util.JsonSerializable) LoggerFactory(org.slf4j.LoggerFactory) UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) PropertyKey(alluxio.conf.PropertyKey) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) Lists(com.google.common.collect.Lists) RunTaskContext(alluxio.job.RunTaskContext) CloseableResource(alluxio.resource.CloseableResource) WorkerInfo(alluxio.wire.WorkerInfo) Map(java.util.Map) UfsIOParameters(alluxio.stress.worker.UfsIOParameters) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) Logger(org.slf4j.Logger) ServerConfiguration(alluxio.conf.ServerConfiguration) ImmutableMap(com.google.common.collect.ImmutableMap) Set(java.util.Set) SelectExecutorsContext(alluxio.job.SelectExecutorsContext) IOException(java.io.IOException) Pair(alluxio.collections.Pair) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) List(java.util.List) PlanDefinition(alluxio.job.plan.PlanDefinition) StressBenchConfig(alluxio.stress.job.StressBenchConfig) UnderFileSystem(alluxio.underfs.UnderFileSystem) BaseParameters(alluxio.stress.BaseParameters) Comparator(java.util.Comparator) TaskResult(alluxio.stress.TaskResult) Collections(java.util.Collections) ShellUtils(alluxio.util.ShellUtils) MountPointInfo(alluxio.wire.MountPointInfo) ArrayList(java.util.ArrayList) WorkerInfo(alluxio.wire.WorkerInfo) Pair(alluxio.collections.Pair)

Example 2 with StressBenchConfig

use of alluxio.stress.job.StressBenchConfig 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();
}
Also used : JsonSerializable(alluxio.util.JsonSerializable) LoggerFactory(org.slf4j.LoggerFactory) UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) PropertyKey(alluxio.conf.PropertyKey) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) Lists(com.google.common.collect.Lists) RunTaskContext(alluxio.job.RunTaskContext) CloseableResource(alluxio.resource.CloseableResource) WorkerInfo(alluxio.wire.WorkerInfo) Map(java.util.Map) UfsIOParameters(alluxio.stress.worker.UfsIOParameters) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) Logger(org.slf4j.Logger) ServerConfiguration(alluxio.conf.ServerConfiguration) ImmutableMap(com.google.common.collect.ImmutableMap) Set(java.util.Set) SelectExecutorsContext(alluxio.job.SelectExecutorsContext) IOException(java.io.IOException) Pair(alluxio.collections.Pair) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) List(java.util.List) PlanDefinition(alluxio.job.plan.PlanDefinition) StressBenchConfig(alluxio.stress.job.StressBenchConfig) UnderFileSystem(alluxio.underfs.UnderFileSystem) BaseParameters(alluxio.stress.BaseParameters) Comparator(java.util.Comparator) TaskResult(alluxio.stress.TaskResult) Collections(java.util.Collections) ShellUtils(alluxio.util.ShellUtils) MountPointInfo(alluxio.wire.MountPointInfo) TaskResult(alluxio.stress.TaskResult) AtomicReference(java.util.concurrent.atomic.AtomicReference) IOException(java.io.IOException)

Aggregations

Pair (alluxio.collections.Pair)2 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)2 PropertyKey (alluxio.conf.PropertyKey)2 ServerConfiguration (alluxio.conf.ServerConfiguration)2 RunTaskContext (alluxio.job.RunTaskContext)2 SelectExecutorsContext (alluxio.job.SelectExecutorsContext)2 PlanDefinition (alluxio.job.plan.PlanDefinition)2 CloseableResource (alluxio.resource.CloseableResource)2 BaseParameters (alluxio.stress.BaseParameters)2 TaskResult (alluxio.stress.TaskResult)2 StressBenchConfig (alluxio.stress.job.StressBenchConfig)2 UfsIOParameters (alluxio.stress.worker.UfsIOParameters)2 UnderFileSystem (alluxio.underfs.UnderFileSystem)2 UnderFileSystemConfiguration (alluxio.underfs.UnderFileSystemConfiguration)2 JsonSerializable (alluxio.util.JsonSerializable)2 ShellUtils (alluxio.util.ShellUtils)2 MountPointInfo (alluxio.wire.MountPointInfo)2 WorkerInfo (alluxio.wire.WorkerInfo)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 Lists (com.google.common.collect.Lists)2