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));
}
Aggregations