Commit c79548b8 authored by Julia Abramenko's avatar Julia Abramenko

- added command generation for loading

- added command generation for executing Queries
parent 527b97b0
Pipeline #59049 failed with stage
in 16 minutes and 38 seconds
......@@ -180,7 +180,10 @@ public class WorkloadApiServiceImpl extends WorkloadApiService {
while (processData.isAlive()) {
Thread.sleep(1000);
}
System.out.println("finished data generating");
System.out.println("finished data generation");
String fileToLoad = TSBS_RESULT_FOLDER + taskId + "-"+ workload.getTsbsDataConfig().getFormat() + "-data.gz";
String queriesToExecute = TSBS_RESULT_FOLDER + taskId + "-" + workload.getTsbsDataConfig().getFormat() + "-" + workload.getTsbsQueryConfig().getQueryType() + ".gz";
//Generate Queries
String generateQueriesCommand = "";
......@@ -199,17 +202,21 @@ public class WorkloadApiServiceImpl extends WorkloadApiService {
// Benchmarking insert/write performance
String loadCommand = "";
loadCommand = TSBSCommandBuilder.loadCommand(workload.getTsbsDataConfig(), workload.getTsbsLoadConfig(), TSBS_BINARY);
ProcessBuilder loadProcess = new ProcessBuilder();
loadProcess.command(UNIX_SHELL, UNIX_COMMAND_PARAM, loadCommand);
loadCommand = TSBSCommandBuilder.loadCommand(workload.getTsbsDataConfig(), workload.getTsbsLoadConfig(), fileToLoad);
loadCommand += " > " + TSBS_RESULT_FOLDER + taskId + "_load_metrics.csv";
ProcessBuilder loadProcess = new ProcessBuilder();
loadProcess.command(UNIX_SHELL, UNIX_COMMAND_PARAM, loadCommand);
Process processLoad = loadProcess.start();
while (processLoad.isAlive()) {
Thread.sleep(1000);
}
System.out.println("finished loading");
// Execute Queries
String exeQueries = "cat " + queriesToExecute + " | gunzip > | ";
exeQueries += TSBSCommandBuilder.executeQueries(workload.getTsbsDataConfig(), workload.getTsbsQueryExecution(), queriesToExecute);
workloadProcess
.startWorkload(TSBS_BINARY, UNIX_SHELL, UNIX_COMMAND_PARAM, "ping www.google.com", taskId,
.startWorkload(TSBS_BINARY, UNIX_SHELL, UNIX_COMMAND_PARAM, exeQueries, taskId,
workloadTimestamp);
WorkloadProcessInstance workloadProcessInstance = new WorkloadProcessInstance();
workloadProcessInstance.setTimestamp(BigDecimal.valueOf(workloadProcess.getStartTimestamp()));
......
......@@ -114,27 +114,24 @@ public class TSBSCommandBuilder {
else return generateQueryCommand;
}
public static String loadCommand(TSBSDataConfig dataConfig, TSBSLoadConfig loadConfig, String tsbsBinary) {
public static String loadCommand(TSBSDataConfig dataConfig, TSBSLoadConfig loadConfig, String fileToLoad) {
checkNotNull(dataConfig);
checkNotNull(loadConfig);
boolean fail = false;
String loadingCommand = "";
//NUM_WORKERS=2 BATCH_SIZE=30 BULK_DATA_DIR=/tmp scripts/load_influx.sh > /tmp/load_metrics.csv
if (loadConfig.getNumberOfWorkers().intValue() > 0) {
loadingCommand += "NUM_WORKERS=" + loadConfig.getNumberOfWorkers().toString() + " ";
} else fail=true;
if (loadConfig.getBatchSize().intValue() > 0) {
loadingCommand += "BATCH_SIZE=" + loadConfig.getBatchSize().toString() + " ";
String loadingCommand = "tsbs_load_";
loadingCommand += dataConfig.getFormat().toString().toLowerCase() + " ";
if(loadConfig.getBatchSize().intValue() > 0) {
loadingCommand += "-batch-size=" + loadConfig.getBatchSize().toString() + " ";
} else fail = true;
if(loadConfig.getNumberOfWorkers().intValue() > 0) {
loadingCommand += "-workers=" + loadConfig.getNumberOfWorkers().toString() + " ";
} else fail=true;
loadingCommand += "BULK_DATA_DIR=" + tsbsBinary + "/load_" + dataConfig.getFormat().toString().toLowerCase()
+ ".sh > /tmp/load_metrics.csv ";
if (loadConfig.getDbmsPorperties().size() > 0) {
for(TSDBMSDBMSProperties key : loadConfig.getDbmsPorperties()) {
loadingCommand += "" + key.getName().toLowerCase() + " " + "\"" +key.getValue().toLowerCase() + "\" ";
if(loadConfig.getDbmsPorperties().size() > 0) {
for(TSDBMSDBMSProperties prop : loadConfig.getDbmsPorperties()) {
loadingCommand += prop.getName() + "=" + "\"" + prop.getValue() + "\" ";
}
} else fail=true;
} else fail = true;
loadingCommand += "-file=" + "\"" + fileToLoad + "\"";
System.out.println(loadingCommand);
if (fail) {
LOGGER.error("Loading command cannot be executed.");
return "";
......@@ -143,4 +140,26 @@ public class TSBSCommandBuilder {
}
public static String executeQueries(TSBSDataConfig dataConfig, TSBSQueryExecution quExe, String queriesToExecute) {
String exeQueries = "tsbs_load_" + dataConfig.getFormat() + " ";
boolean fail=false;
if(quExe.getWorkers().intValue() > 0) {
exeQueries += "-workers=" + quExe.getWorkers() + " ";
} else fail = true;
if(quExe.getDbmsPorperties().size() > 0 ) {
for(TSDBMSDBMSProperties prop : quExe.getDbmsPorperties()) {
exeQueries += prop.getName() + "=\"" + prop.getValue() + "\" ";
}
} else fail = true;
System.out.println(exeQueries);
if (fail) {
LOGGER.error("Query execution cannot be executed.");
return "";
}else {
exeQueries += "-file=" + "\"" + queriesToExecute + "\"";
return exeQueries;
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment