private String buildOutputFileName() { return dbName + "." + "benchmark" + "." + storageConfiguration.getBenchmark().getMode(); }
public VariantStorageEngineSampler newVariantStorageEngineSampler(ConnectionType type) { switch (type) { case REST: URI rest = storageConfiguration.getBenchmark().getRest(); return new VariantStorageEngineRestSampler(rest.getHost(), rest.getPath(), rest.getPort()); case DIRECT: return new VariantStorageEngineDirectSampler(); case GRPC: throw new UnsupportedOperationException("Unsupported type " + ConnectionType.GRPC); default: throw new IllegalArgumentException("Unknown type " + type); } }
private void checkParams() { if (configuration.getBenchmark().getDatabaseName() == null || configuration.getBenchmark().getDatabaseName().isEmpty()) { throw new ParameterException("Database name is null or empty. Please provide database name."); } if (configuration.getBenchmark().getTable() == null || configuration.getBenchmark().getTable().isEmpty()) { throw new ParameterException("Table name is null or empty. Please provide table name."); } if (configuration.getBenchmark().getDatabase().getHosts() == null || configuration.getBenchmark().getDatabase().getHosts().isEmpty()) { throw new ParameterException("Database name is null or empty. Please provide Database name."); } }
private void setHost(BenchmarkCommandOptions.VariantBenchmarkCommandOptions options) throws URISyntaxException { URIBuilder uriBuilder = null; String host = options.host; if (host == null) { uriBuilder = new URIBuilder(configuration.getBenchmark().getRest()); } else { uriBuilder = new URIBuilder(host); } String storageRest = commandOptions.commonCommandOptions.params.get("storage.rest"); if (StringUtils.isNotEmpty(storageRest) && storageRest.equals("true")) { uriBuilder.setPath(uriBuilder.getPath().concat(VariantStorageEngineRestSampler.STORAGE_REST_PATH)); } else { uriBuilder.setPath(uriBuilder.getPath().concat(VariantStorageEngineRestSampler.REST_PATH)); } configuration.getBenchmark().setRest(new URI(uriBuilder.toString())); }
public BenchmarkStats variantBenchmark() throws ClassNotFoundException, StorageEngineException, InstantiationException, IllegalAccessException, ExecutionException, InterruptedException { BenchmarkRunner benchmarkRunner = new VariantBenchmarkRunner(storageConfiguration); BenchmarkStats benchmarkStats = benchmarkRunner.query(storageConfiguration.getBenchmark().getNumRepetitions(), new HashSet<>(storageConfiguration.getBenchmark().getQueries())); return benchmarkStats; }
private <T> List<Future<T>> executeThreads(String test, Callable<T> task) throws ExecutionException, InterruptedException { int concurrency = storageConfiguration.getBenchmark().getConcurrency(); // System.out.println("concurrency :: " + concurrency); ExecutorService executorService = Executors.newFixedThreadPool(10); List<Future<T>> futureList = new ArrayList<>(10); for (int i = 0; i < concurrency; i++) { futureList.add(executorService.submit(task)); } int totalTime = 0; for (Future<T> queryResultFuture : futureList) { totalTime += ((QueryResult) queryResultFuture.get()).getDbTime(); // System.out.println("queryResultFuture.get().getDbTime() = " + queryResultFuture.get().getDbTime()); // System.out.println("queryResultFuture.get().getResult().size() = " + queryResultFuture.get().getResult().get(0)); } benchmarkStats.addExecutionTime(test, totalTime); benchmarkStats.addStdDeviation(test, totalTime); return futureList; } }
private void variant() throws IOException, URISyntaxException { BenchmarkCommandOptions.VariantBenchmarkCommandOptions options = commandOptions.variantBenchmarkCommandOptions; Path outdirPath = getBenchmarkPath(options); Path jmeterHome = Paths.get(appHome, "benchmark", "jmeter"); Path dataDir = Paths.get(appHome, "benchmark", "data", "hsapiens"); if (StringUtils.isNotEmpty(options.dbName)) { configuration.getBenchmark().setDatabaseName(options.dbName); } if (options.repetition != null) { configuration.getBenchmark().setNumRepetitions(options.repetition); } if (options.concurrency != null) { configuration.getBenchmark().setConcurrency(options.concurrency); } if (options.delay != null) { configuration.getBenchmark().setDelay(options.delay); } setHost(options); configuration.getBenchmark().setMode(options.executionMode.name()); configuration.getBenchmark().setConnectionType(options.connectionType.name()); VariantBenchmarkRunner variantBenchmarkRunner = new VariantBenchmarkRunner(configuration, jmeterHome, outdirPath); QueryOptions queryOptions = new QueryOptions(); queryOptions.append(QueryOptions.LIMIT, options.limit); queryOptions.append(QueryOptions.COUNT, options.count); variantBenchmarkRunner.addThreadGroup(options.connectionType, options.executionMode, dataDir, options.baseQuery, options.queryFile, options.query, queryOptions); variantBenchmarkRunner.run(); }
public BenchmarkRunner(StorageConfiguration storageConfiguration, Path jmeterHome, Path outdir) throws IOException { StorageEngineFactory.configure(storageConfiguration); this.storageConfiguration = storageConfiguration; storageEngine = storageConfiguration.getDefaultStorageEngineId(); dbName = storageConfiguration.getBenchmark().getDatabaseName(); this.jmeterHome = jmeterHome; this.outdir = outdir; init(); }
private void init(String storageEngine) throws IllegalAccessException, InstantiationException, ClassNotFoundException, StorageEngineException { StorageEngineFactory storageEngineFactory = StorageEngineFactory.get(storageConfiguration); VariantStorageEngine variantStorageEngine = storageEngineFactory.getVariantStorageEngine(storageEngine, storageConfiguration.getBenchmark().getDatabaseName()); variantDBAdaptor = variantStorageEngine.getDBAdaptor(); }
public void addThreadGroup(List<? extends Sampler> samplers) { // Loop Controller LoopController loopController = new LoopController(); loopController.setLoops(storageConfiguration.getBenchmark().getNumRepetitions()); loopController.setFirst(true); loopController.setProperty(TestElement.TEST_CLASS, LoopController.class.getName()); loopController.setProperty(TestElement.GUI_CLASS, LoopControlPanel.class.getName()); loopController.initialize(); // Thread Group ThreadGroup threadGroup = new ThreadGroup(); threadGroup.setName("Thread-Group"); threadGroup.setNumThreads(storageConfiguration.getBenchmark().getConcurrency()); threadGroup.setRampUp(1); threadGroup.setSamplerController(loopController); threadGroup.setProperty(TestElement.TEST_CLASS, ThreadGroup.class.getName()); threadGroup.setProperty(TestElement.GUI_CLASS, ThreadGroupGui.class.getName()); // Construct Test Plan from previously initialized elements HashTree threadGroupHashTree = testPlanTree.add(testPlan, threadGroup); ConstantTimer timer = new ConstantTimer(); timer.setDelay(String.valueOf(storageConfiguration.getBenchmark().getDelay())); timer.setName("timer"); // Add samplers to the ThreadGroup threadGroupHashTree.add(samplers); // Add timer to the ThreadGroup threadGroupHashTree.add(timer); }
benchmarkStats.printSummary(storageConfiguration.getBenchmark().getDatabaseName(), storageConfiguration.getBenchmark().getTable(), storageConfiguration.getBenchmark().getNumRepetitions(), storageConfiguration.getBenchmark().getConcurrency()); return benchmarkStats;