Search in sources :

Example 1 with WorkloadGenerator

use of io.openmessaging.benchmark.WorkloadGenerator in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class OMB method runWorkload.

public OMBWorkloadResult runWorkload(File testDir, OMBDriver driver, List<String> workers, OMBWorkload workload) throws Exception {
    File driverFile = new File(testDir, "driver.yaml");
    File resultFile = new File(testDir, String.format("result_%s.json", workload.getName().replaceAll(" ", "_")));
    Files.writeString(driverFile.toPath(), MAPPER.writeValueAsString(driver));
    LOGGER.info("Wrote driver to {}", driverFile.getAbsolutePath());
    workload.validate();
    try (Worker worker = workers.isEmpty() ? new LocalWorker() : new DistributedWorkersEnsemble(workers);
        WorkloadGenerator generator = new WorkloadGenerator(driver.name, workload, worker)) {
        LOGGER.info("--------------- WORKLOAD: {} --- DRIVER: {} ---------------", workload.name, driver.name);
        worker.initializeDriver(driverFile);
        TestResult result = generator.run();
        try {
            worker.stopAll();
        } catch (IOException e) {
        }
        LOGGER.info("Writing test result into {}", resultFile.getAbsolutePath());
        WRITER.writeValue(resultFile, result);
    } catch (Exception e) {
        LOGGER.error("Failed to run the workload '{}' for driver '{}'", workload.name, driverFile.getAbsolutePath(), e);
        throw e;
    }
    TestMetadataCapture.getInstance().storeOmbData(ombCluster, workload, driver, this);
    return new OMBWorkloadResult(resultFile, createTestResult(resultFile));
}
Also used : LocalWorker(io.openmessaging.benchmark.worker.LocalWorker) DistributedWorkersEnsemble(io.openmessaging.benchmark.worker.DistributedWorkersEnsemble) WorkloadGenerator(io.openmessaging.benchmark.WorkloadGenerator) Worker(io.openmessaging.benchmark.worker.Worker) LocalWorker(io.openmessaging.benchmark.worker.LocalWorker) TestResult(io.openmessaging.benchmark.TestResult) IOException(java.io.IOException) File(java.io.File) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

TestResult (io.openmessaging.benchmark.TestResult)1 WorkloadGenerator (io.openmessaging.benchmark.WorkloadGenerator)1 DistributedWorkersEnsemble (io.openmessaging.benchmark.worker.DistributedWorkersEnsemble)1 LocalWorker (io.openmessaging.benchmark.worker.LocalWorker)1 Worker (io.openmessaging.benchmark.worker.Worker)1 File (java.io.File)1 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1