Commit 302cb2c5 authored by Daniel Seybold's avatar Daniel Seybold

refactored the calls of tsbs

parent 6a430a62
Pipeline #81230 passed with stage
in 21 minutes and 44 seconds
......@@ -23,7 +23,7 @@ import javax.validation.constraints.*;
/**
* DBEndpoint
*/
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class DBEndpoint {
@JsonProperty("ipAddress")
private String ipAddress = null;
......
......@@ -22,7 +22,7 @@ import javax.validation.constraints.*;
* a list of the database endpoints to issue the workload
*/
@ApiModel(description = "a list of the database endpoints to issue the workload")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class DBEndpoints extends java.util.ArrayList<DBEndpoint> {
@Override
......
......@@ -25,7 +25,7 @@ import javax.validation.constraints.*;
/**
* DatabaseConfig
*/
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class DatabaseConfig {
/**
* Gets or Sets databaseBinding
......
......@@ -23,7 +23,7 @@ import javax.validation.constraints.*;
/**
* DatabaseConfigProperty
*/
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class DatabaseConfigProperty {
@JsonProperty("name")
private String name = null;
......
......@@ -23,7 +23,7 @@ import javax.validation.constraints.*;
/**
* Error
*/
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class Error {
@JsonProperty("code")
private Integer code = null;
......
......@@ -24,7 +24,7 @@ import javax.validation.constraints.*;
/**
* MeasurementConfig
*/
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class MeasurementConfig {
@JsonProperty("interval")
private Integer interval = null;
......
......@@ -25,7 +25,7 @@ import javax.validation.constraints.*;
/**
* TPCCWorkload
*/
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class TPCCWorkload {
@JsonProperty("dbEndpoints")
private DBEndpoints dbEndpoints = null;
......
......@@ -23,7 +23,7 @@ import javax.validation.constraints.*;
/**
* TPCCWorkloadConfig
*/
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class TPCCWorkloadConfig {
@JsonProperty("activeWarehouses")
private Integer activeWarehouses = null;
......
......@@ -25,7 +25,7 @@ import javax.validation.constraints.*;
* parameters for the data generation phase
*/
@ApiModel(description = "parameters for the data generation phase")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class TSBSDataGeneration {
@JsonProperty("usecase")
private String usecase = null;
......
......@@ -25,7 +25,7 @@ import javax.validation.constraints.*;
/**
* TSBSLoadExecution
*/
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class TSBSLoadExecution {
@JsonProperty("workers")
private BigDecimal workers = null;
......
......@@ -25,7 +25,7 @@ import javax.validation.constraints.*;
/**
* TSBSQueryExecution
*/
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class TSBSQueryExecution {
@JsonProperty("workers")
private BigDecimal workers = null;
......
......@@ -25,7 +25,7 @@ import javax.validation.constraints.*;
* parameters for the query generation phase
*/
@ApiModel(description = "parameters for the query generation phase")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class TSBSQueryGeneration {
@JsonProperty("usecase")
private String usecase = null;
......
......@@ -29,7 +29,7 @@ import javax.validation.constraints.*;
/**
* TSBSWorkload
*/
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class TSBSWorkload {
@JsonProperty("dbEndpoints")
private DBEndpoints dbEndpoints = null;
......
......@@ -23,7 +23,7 @@ import javax.validation.constraints.*;
/**
* TSDBMSDBMSProperties
*/
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class TSDBMSDBMSProperties {
@JsonProperty("name")
private String name = null;
......
......@@ -24,7 +24,7 @@ import javax.validation.constraints.*;
/**
* WorkloadConfig
*/
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class WorkloadConfig {
/**
* Gets or Sets workloadType
......
......@@ -25,7 +25,7 @@ import javax.validation.constraints.*;
/**
* WorkloadProcessInstance
*/
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class WorkloadProcessInstance {
@JsonProperty("processId")
private String processId = null;
......
......@@ -23,7 +23,7 @@ import javax.validation.constraints.*;
/**
* WorkloadProcessSubmissionError
*/
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class WorkloadProcessSubmissionError {
@JsonProperty("message")
private String message = null;
......
......@@ -27,7 +27,7 @@ import javax.validation.constraints.*;
/**
* YCSBWorkload
*/
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class YCSBWorkload {
@JsonProperty("dbEndpoints")
private DBEndpoints dbEndpoints = null;
......
package de.uulm.omi.dbms.workload.api;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class ApiException extends Exception{
private int code;
public ApiException (int code, String msg) {
......
......@@ -5,7 +5,7 @@ import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class ApiOriginFilter implements javax.servlet.Filter {
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
......
......@@ -3,7 +3,7 @@ package de.uulm.omi.dbms.workload.api;
import javax.xml.bind.annotation.XmlTransient;
@javax.xml.bind.annotation.XmlRootElement
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class ApiResponseMessage {
public static final int ERROR = 1;
public static final int WARNING = 2;
......
package de.uulm.omi.dbms.workload.api;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class NotFoundException extends ApiException {
private int code;
public NotFoundException (int code, String msg) {
......
package de.uulm.omi.dbms.workload.api;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class StringUtil {
/**
* Check if the given array contains the given value (with case-insensitive comparison).
......
......@@ -35,7 +35,7 @@ import javax.validation.constraints.*;
@Produces({ "application/json" })
@io.swagger.annotations.Api(description = "the workload API")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class WorkloadApi {
private final WorkloadApiService delegate;
......@@ -107,21 +107,72 @@ public class WorkloadApi {
return delegate.workloadTpccPost(taskId,workload,securityContext);
}
@POST
@Path("/tsbs")
@Path("/tsbs/executeQueries")
@Produces({ "application/json" })
@io.swagger.annotations.ApiOperation(value = "generates the data, queries, loads and executes the TSBS workload against a supported DBMS", notes = "Prepare and execute the TSBS workload ", response = WorkloadProcessInstance.class, tags={ })
@io.swagger.annotations.ApiOperation(value = "executes TSBS queries based on the loaded data", notes = "Execute queries ", response = WorkloadProcessInstance.class, tags={ })
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "returns the state of the started workloadProcess", response = WorkloadProcessInstance.class),
@io.swagger.annotations.ApiResponse(code = 403, message = "already a workloadProcess running", response = WorkloadProcessSubmissionError.class),
@io.swagger.annotations.ApiResponse(code = 200, message = "Unexpected error", response = Error.class) })
public Response workloadTsbsPost(@ApiParam(value = "the id of the workload execution task, used as prefix for result files",required=true) @QueryParam("taskId") String taskId
public Response workloadTsbsExecuteQueriesPost(@ApiParam(value = "the id of the workload execution task, used as prefix for result files",required=true) @QueryParam("taskId") String taskId
,@ApiParam(value = "the TSBS workload configuration" ,required=true) TSBSWorkload workload
,@Context SecurityContext securityContext)
throws NotFoundException {
return delegate.workloadTsbsPost(taskId,workload,securityContext);
return delegate.workloadTsbsExecuteQueriesPost(taskId,workload,securityContext);
}
@POST
@Path("/tsbs/generateData")
@Produces({ "application/json" })
@io.swagger.annotations.ApiOperation(value = "generates the TSBS data", notes = "Generate data ", response = WorkloadProcessInstance.class, tags={ })
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "returns the state of the started workloadProcess", response = WorkloadProcessInstance.class),
@io.swagger.annotations.ApiResponse(code = 403, message = "already a workloadProcess running", response = WorkloadProcessSubmissionError.class),
@io.swagger.annotations.ApiResponse(code = 200, message = "Unexpected error", response = Error.class) })
public Response workloadTsbsGenerateDataPost(@ApiParam(value = "the id of the workload execution task, used as prefix for result files",required=true) @QueryParam("taskId") String taskId
,@ApiParam(value = "the TSBS workload configuration" ,required=true) TSBSWorkload workload
,@Context SecurityContext securityContext)
throws NotFoundException {
return delegate.workloadTsbsGenerateDataPost(taskId,workload,securityContext);
}
@POST
@Path("/tsbs/generateQueries")
@Produces({ "application/json" })
@io.swagger.annotations.ApiOperation(value = "generates the TSBS quires in the DBMS-specific format", notes = "Generate TSBS queries ", response = WorkloadProcessInstance.class, tags={ })
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "returns the state of the started workloadProcess", response = WorkloadProcessInstance.class),
@io.swagger.annotations.ApiResponse(code = 403, message = "already a workloadProcess running", response = WorkloadProcessSubmissionError.class),
@io.swagger.annotations.ApiResponse(code = 200, message = "Unexpected error", response = Error.class) })
public Response workloadTsbsGenerateQueriesPost(@ApiParam(value = "the id of the workload execution task, used as prefix for result files",required=true) @QueryParam("taskId") String taskId
,@ApiParam(value = "the TSBS workload configuration" ,required=true) TSBSWorkload workload
,@Context SecurityContext securityContext)
throws NotFoundException {
return delegate.workloadTsbsGenerateQueriesPost(taskId,workload,securityContext);
}
@POST
@Path("/tsbs/loadData")
@Produces({ "application/json" })
@io.swagger.annotations.ApiOperation(value = "loads the data in the specified timeseries DBMS", notes = "Load data ", response = WorkloadProcessInstance.class, tags={ })
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "returns the state of the started workloadProcess", response = WorkloadProcessInstance.class),
@io.swagger.annotations.ApiResponse(code = 403, message = "already a workloadProcess running", response = WorkloadProcessSubmissionError.class),
@io.swagger.annotations.ApiResponse(code = 200, message = "Unexpected error", response = Error.class) })
public Response workloadTsbsLoadDataPost(@ApiParam(value = "the id of the workload execution task, used as prefix for result files",required=true) @QueryParam("taskId") String taskId
,@ApiParam(value = "the TSBS workload configuration" ,required=true) TSBSWorkload workload
,@Context SecurityContext securityContext)
throws NotFoundException {
return delegate.workloadTsbsLoadDataPost(taskId,workload,securityContext);
}
@POST
@Path("/ycsb")
......
......@@ -21,11 +21,14 @@ import java.io.InputStream;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
import javax.validation.constraints.*;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public abstract class WorkloadApiService {
public abstract Response workloadResultGet( @NotNull String taskId, @NotNull String workloadType,SecurityContext securityContext) throws NotFoundException;
public abstract Response workloadStatusGet( String applicationInstanceId,SecurityContext securityContext) throws NotFoundException;
public abstract Response workloadTpccPost( @NotNull String taskId,TPCCWorkload workload,SecurityContext securityContext) throws NotFoundException;
public abstract Response workloadTsbsPost( @NotNull String taskId,TSBSWorkload workload,SecurityContext securityContext) throws NotFoundException;
public abstract Response workloadTsbsExecuteQueriesPost( @NotNull String taskId,TSBSWorkload workload,SecurityContext securityContext) throws NotFoundException;
public abstract Response workloadTsbsGenerateDataPost( @NotNull String taskId,TSBSWorkload workload,SecurityContext securityContext) throws NotFoundException;
public abstract Response workloadTsbsGenerateQueriesPost( @NotNull String taskId,TSBSWorkload workload,SecurityContext securityContext) throws NotFoundException;
public abstract Response workloadTsbsLoadDataPost( @NotNull String taskId,TSBSWorkload workload,SecurityContext securityContext) throws NotFoundException;
public abstract Response workloadYcsbPost( @NotNull String taskId,YCSBWorkload workload,SecurityContext securityContext) throws NotFoundException;
}
......@@ -3,7 +3,7 @@ package de.uulm.omi.dbms.workload.api.factories;
import de.uulm.omi.dbms.workload.api.WorkloadApiService;
import de.uulm.omi.dbms.workload.api.impl.WorkloadApiServiceImpl;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-14T14:57:28.782+02:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2020-05-15T11:19:36.337+02:00")
public class WorkloadApiServiceFactory {
private final static WorkloadApiService service = new WorkloadApiServiceImpl();
......
......@@ -11,9 +11,10 @@ import de.uulm.omi.dbms.workload.api.NotFoundException;
import de.uulm.omi.dbms.workload.api.WorkloadApiService;
import de.uulm.omi.utils.TextFileLoader;
import de.uulm.omi.utils.WorkloadApiProperties;
import de.uulm.omi.utils.WorkloadProcessChecker;
import de.uulm.omi.workload.WorkloadProcess;
import de.uulm.omi.workload.tpcc.TPCCCommandBuilder;
import de.uulm.omi.workload.tsbs.Runner;
import de.uulm.omi.workload.tsbs.TSBSCommandBuilder;
import de.uulm.omi.workload.ycsb.YCSBCommandBuilder;
import java.io.File;
import java.io.FileNotFoundException;
......@@ -46,6 +47,10 @@ public class WorkloadApiServiceImpl extends WorkloadApiService {
private final String TPCC_RESULT_FOLDER = "TPCC/";
private static final String TPCC_BINARY = "./cockroach";
//TSBS constants
private final String TSBS_RESULT_FOLDER = "TSBS/";
private static final String TSBS_BINARY = "/opt/workloads/tsbs/bin/";
@Override
public Response workloadResultGet(@NotNull String taskId, @NotNull String workloadType,
......@@ -202,29 +207,137 @@ public class WorkloadApiServiceImpl extends WorkloadApiService {
}
@Override
public Response workloadTsbsPost(String taskId, TSBSWorkload workload,
public Response workloadTsbsExecuteQueriesPost(String taskId, TSBSWorkload workload,
SecurityContext securityContext) throws NotFoundException {
//Phase 0: check if already a workloadProcess running
if(WorkloadProcessChecker.checkWorkloadProcessStatee() != null){
return WorkloadProcessChecker.checkWorkloadProcessStatee();
}
WorkloadProcess workloadProcess = WorkloadProcess.getInstance();
if (workloadProcess.isRunning()) {
WorkloadProcessSubmissionError workloadProcessSubmissionError = new WorkloadProcessSubmissionError();
workloadProcessSubmissionError.setMessage(
"There is already a workloadProcess running, please wait until workloadProcess is finished!");
return Response.status(Status.FORBIDDEN).entity(workloadProcessSubmissionError).build();
Properties properties = WorkloadApiProperties.getInstance().getProperties();
Long workloadTimestamp = System.currentTimeMillis();
String executeQueriesCommand = TSBSCommandBuilder.executeQueriesCommand(TSBS_BINARY, properties.getProperty(WorkloadApiProperties.WORKLOAD_DATA_FOLDER), workload.getDbms(), workload.getTsbsQueryExecution(), workload.getDbEndpoints() );
executeQueriesCommand += " &> " + properties.getProperty(WorkloadApiProperties.WORKLOAD_RESULTS_FOLDER) + TSBS_RESULT_FOLDER + taskId.trim() + ".txt";
LOGGER.debug(executeQueriesCommand);
workloadProcess
.startWorkload(TSBS_BINARY, UNIX_SHELL, UNIX_COMMAND_PARAM, executeQueriesCommand, taskId,
workloadTimestamp);
WorkloadProcessInstance workloadProcessInstance = new WorkloadProcessInstance();
workloadProcessInstance.setProcessStatus(ProcessStatus.RUNNING);
workloadProcessInstance.setTimestamp(BigDecimal.valueOf(workloadProcess.getStartTimestamp()));
workloadProcessInstance.setProcessId(workloadProcess.getProcessId());
return Response.ok().entity(workloadProcessInstance).build();
}
@Override
public Response workloadTsbsGenerateDataPost(String taskId, TSBSWorkload workload,
SecurityContext securityContext) throws NotFoundException {
if(WorkloadProcessChecker.checkWorkloadProcessStatee() != null){
return WorkloadProcessChecker.checkWorkloadProcessStatee();
}
WorkloadProcess workloadProcess = WorkloadProcess.getInstance();
Properties properties = WorkloadApiProperties.getInstance().getProperties();
Long workloadTimestamp = System.currentTimeMillis();
LOGGER.debug(workload.toString());
//Phase 1: generate data
LOGGER.debug("Starting phase 1: data generations");
String generateDataCommand= "";
generateDataCommand = TSBSCommandBuilder
.generateDataCommand( TSBS_BINARY, workload.getDbms(), workload.getTsbsDataGeneration());
generateDataCommand += properties.getProperty(WorkloadApiProperties.WORKLOAD_DATA_FOLDER) + workload.getDbms().toString().toLowerCase() + "-data.gz";
LOGGER.debug("Generate data command: " + generateDataCommand);
workloadProcess
.startWorkload(TSBS_BINARY, UNIX_SHELL, UNIX_COMMAND_PARAM, generateDataCommand, taskId,
workloadTimestamp);
WorkloadProcessInstance workloadProcessInstance = new WorkloadProcessInstance();
workloadProcessInstance.setProcessStatus(ProcessStatus.RUNNING);
workloadProcessInstance.setTimestamp(BigDecimal.valueOf(workloadProcess.getStartTimestamp()));
workloadProcessInstance.setProcessId(workloadProcess.getProcessId());
return Response.ok().entity(workloadProcessInstance).build();
}
@Override
public Response workloadTsbsGenerateQueriesPost(String taskId, TSBSWorkload workload,
SecurityContext securityContext) throws NotFoundException {
if(WorkloadProcessChecker.checkWorkloadProcessStatee() != null){
return WorkloadProcessChecker.checkWorkloadProcessStatee();
}
WorkloadProcess workloadProcess = WorkloadProcess.getInstance();
Properties properties = WorkloadApiProperties.getInstance().getProperties();
Long workloadTimestamp = System.currentTimeMillis();
String generateQueriesCommand = "";
generateQueriesCommand = TSBSCommandBuilder.generateQueriesCommand(TSBS_BINARY, workload.getDbms(), workload.getTsbsDataGeneration(), workload.getTsbsQueryGeneration());
generateQueriesCommand += properties.getProperty(WorkloadApiProperties.WORKLOAD_DATA_FOLDER) + workload.getDbms().toString().toLowerCase() + "-queries.gz" ;
LOGGER.debug(generateQueriesCommand);
workloadProcess
.startWorkload(TSBS_BINARY, UNIX_SHELL, UNIX_COMMAND_PARAM, generateQueriesCommand, taskId,
workloadTimestamp);
WorkloadProcessInstance workloadProcessInstance = new WorkloadProcessInstance();
workloadProcessInstance.setProcessStatus(ProcessStatus.RUNNING);
workloadProcessInstance.setTimestamp(BigDecimal.valueOf(workloadProcess.getStartTimestamp()));
workloadProcessInstance.setProcessId(workloadProcess.getProcessId());
Runner tsbsRunner = new Runner(workload, taskId);
new Thread(tsbsRunner).start();
return Response.ok().entity(workloadProcessInstance).build();
}
@Override
public Response workloadTsbsLoadDataPost(String taskId, TSBSWorkload workload,
SecurityContext securityContext) throws NotFoundException {
if(WorkloadProcessChecker.checkWorkloadProcessStatee() != null){
return WorkloadProcessChecker.checkWorkloadProcessStatee();
}
WorkloadProcess workloadProcess = WorkloadProcess.getInstance();
Properties properties = WorkloadApiProperties.getInstance().getProperties();
Long workloadTimestamp = System.currentTimeMillis();
String loadCommand = "";
loadCommand = TSBSCommandBuilder.generateLoadCommand(TSBS_BINARY, properties.getProperty(WorkloadApiProperties.WORKLOAD_DATA_FOLDER), workload.getDbms(), workload.getTsbsLoadExecution(),workload.getDbEndpoints());
loadCommand += " &> " + properties.getProperty(WorkloadApiProperties.WORKLOAD_RESULTS_FOLDER) + TSBS_RESULT_FOLDER + taskId.trim() + "_load.txt";
LOGGER.debug(loadCommand);
workloadProcess
.startWorkload(TSBS_BINARY, UNIX_SHELL, UNIX_COMMAND_PARAM, loadCommand, taskId,
workloadTimestamp);
WorkloadProcessInstance workloadProcessInstance = new WorkloadProcessInstance();
workloadProcessInstance.setProcessStatus(ProcessStatus.RUNNING);
workloadProcessInstance.setTimestamp(BigDecimal.valueOf(workloadProcess.getStartTimestamp()));
workloadProcessInstance.setProcessId(workloadProcess.getProcessId());
return Response.ok().entity(workloadProcessInstance).build();
}
......
package de.uulm.omi.utils;
import de.uulm.omi.cloudiator.dbms.evaluator.model.WorkloadProcessSubmissionError;
import de.uulm.omi.workload.WorkloadProcess;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
/**
* Created by Daniel Seybold on 15.05.2020.
*/
public class WorkloadProcessChecker {
public static Response checkWorkloadProcessStatee(){
//check if already a workloadProcess running
WorkloadProcess workloadProcess = WorkloadProcess.getInstance();
if (workloadProcess.isRunning()) {
WorkloadProcessSubmissionError workloadProcessSubmissionError = new WorkloadProcessSubmissionError();
workloadProcessSubmissionError.setMessage(
"There is already a workloadProcess running, please wait until workloadProcess is finished!");
Response response = Response.status(Status.FORBIDDEN).entity(workloadProcessSubmissionError).build();
return response;
}
else return null;
}
}
......@@ -39,6 +39,9 @@ public class Runner implements Runnable {
//TODO: in case of failure set ProcessInstance state to error!
//TODO: refactor to have one api call per phase and pass always the whole workload object, this will avoid the issue that checks the state in between the phases
WorkloadProcess workloadProcess = WorkloadProcess.getInstance();
Properties properties = WorkloadApiProperties.getInstance().getProperties();
......
......@@ -74,11 +74,46 @@ paths:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
/workload/tsbs:
/workload/tsbs/generateData:
post:
summary: generates the TSBS data
description: |
Generate data
parameters:
- name: taskId
description: >-
the id of the workload execution task, used as prefix for result
files
in: query
required: true
type: string
- name: workload
in: body
description: the TSBS workload configuration
required: true
schema:
$ref: '#/definitions/TSBSWorkload'
responses:
'