Commit d0b1cc74 authored by Daniel Seybold's avatar Daniel Seybold

enabled first version for tsbs api

parent ac8029e5
Pipeline #64992 passed with stage
in 14 minutes and 18 seconds
......@@ -19,6 +19,7 @@ import de.uulm.omi.evaluation.task.DeployDB;
import de.uulm.omi.evaluation.task.FetchTSBSResult;
import de.uulm.omi.evaluation.task.InitEvaluation;
import de.uulm.omi.evaluation.task.InitRun;
import de.uulm.omi.evaluation.task.TSBSWorkload;
import org.jeasy.flows.engine.WorkFlowEngine;
import org.jeasy.flows.work.WorkReport;
import org.jeasy.flows.workflow.SequentialFlow;
......@@ -64,9 +65,9 @@ public class PerformanceTSBSScenario extends EvaluationScenario {
//TODO: check for refactoring
//YcsbWorkload ycsbWorkload = new YcsbWorkload(this.evaluationContext, this.dbmsClusterContext,
// this.performanceYCSBWrite.getWorkload(), this.performanceYCSBWrite.getWorkloadNetwork(), this.workloadPhaseContext,
// YcsbWorkloadType.LOAD, performanceYCSBWrite.getWorkloadInstances());
TSBSWorkload tsbsWorkload = new TSBSWorkload(this.evaluationContext, this.dbmsClusterContext,
this.performanceTSBS.getWorkloadLoad(), this.performanceTSBS.getWorkloadNetwork(), this.workloadPhaseContext,
performanceTSBS.getWorkloadInstances());
CleanUpRun cleanUpRun = new CleanUpRun(this.evaluationContext, this.dbmsClusterContext);
......@@ -94,7 +95,7 @@ public class PerformanceTSBSScenario extends EvaluationScenario {
.execute(initRun)
.execute(deployDB)
.execute(checkDeployment)
//.execute(ycsbWorkload)
.execute(tsbsWorkload)
.execute(checkWorkload)
.execute(fetchTSBSResult)
//.execute(mergeYCSB)
......
package de.uulm.omi.evaluation.task;
import static com.google.common.base.Preconditions.checkNotNull;
import de.uulm.omi.cloudiator.dbms.evaluator.model.ClusterContext;
import de.uulm.omi.cloudiator.dbms.evaluator.model.DBEndpoints;
import de.uulm.omi.cloudiator.dbms.evaluator.model.EvaluationContext;
import de.uulm.omi.cloudiator.dbms.evaluator.model.EvaluationNetwork;
import de.uulm.omi.cloudiator.dbms.evaluator.model.TSBSLoadWorkload;
import de.uulm.omi.cloudiator.dbms.evaluator.model.WorkloadPhaseContext;
import de.uulm.omi.cloudiator.dbms.evaluator.model.WorkloadProcessInstance;
import de.uulm.omi.dbms.workload.api.DefaultApi;
import de.uulm.omi.utils.ColosseumUtils;
import de.uulm.omi.utils.DBMSNodeType;
import de.uulm.omi.utils.WorkloadApiClientHelper;
import java.io.File;
import java.util.List;
import org.jeasy.flows.work.DefaultWorkReport;
import org.jeasy.flows.work.WorkReport;
import org.jeasy.flows.work.WorkStatus;
/**
* Created by Daniel Seybold on 23.01.2018.
*/
public class TSBSWorkload extends EvaluationTask {
private final TSBSLoadWorkload tsbsLoadWorkload;
private final EvaluationNetwork network;
private final ClusterContext clusterContext;
private final WorkloadPhaseContext workloadPhaseContext;
private final List<String> workloadInstances;
private String loggerPrefix = "";
public TSBSWorkload(EvaluationContext evaluationContext, ClusterContext clusterContext,
TSBSLoadWorkload tsbsLoadWorkload, EvaluationNetwork network,
WorkloadPhaseContext workloadPhaseContext, List<String> workloadInstances) {
super(TaskType.YCSB_LOAD, evaluationContext);
this.tsbsLoadWorkload = tsbsLoadWorkload;
this.network = network;
this.clusterContext = clusterContext;
this.workloadPhaseContext = workloadPhaseContext;
this.workloadInstances = workloadInstances;
}
@Override
public WorkReport call() {
this.loggerPrefix= "RUN " + this.evaluationContext.getRunCounter().intValue() +": ";
//get workloadApi client
List<DefaultApi> workloadClients = WorkloadApiClientHelper.getWorkloadClients(workloadInstances);
Long appInstanceId = Long.valueOf(this.clusterContext.getIdApplicationInstance());
checkNotNull(appInstanceId);
//build endpoints
DBEndpoints dbEndpoints = null;
dbEndpoints = ColosseumUtils.extractDBEndpoints(appInstanceId, this.network.getType().toString(), DBMSNodeType.ALL);
if(dbEndpoints.isEmpty()){
LOGGER.warn(loggerPrefix + "Found no endpoints for applicationInstanceId! Aborting!");
return new DefaultWorkReport(WorkStatus.FAILED);
}
tsbsLoadWorkload.setDbEndpoints(dbEndpoints);
try {
String workloadTask = "tsbs" + evaluationContext.getRunCounter().intValue() + "_" + this.evaluationContext.getScenarioType();
int instanceCounter = 0;
for (DefaultApi workloadClient: workloadClients) {
writeWorkloadSpec(instanceCounter, TRANSACTION_SPEC);
WorkloadProcessInstance result = workloadClient.workloadTsbsLoadPost(workloadTask ,tsbsLoadWorkload);
//TODO: refactor to a list of workloadPhase states
LOGGER.debug(loggerPrefix + "Status: " + result.getProcessStatus().getValue());
this.workloadPhaseContext.setProcessState(result.getProcessStatus().getValue());
instanceCounter++;
}
} catch (de.uulm.omi.dbms.workload.client.ApiException e) {
LOGGER.error(loggerPrefix + "error calling workload API", e);
return new DefaultWorkReport(WorkStatus.FAILED);
}
return new DefaultWorkReport(WorkStatus.COMPLETED);
}
private void writeWorkloadSpec(int instanceCounter, String workloadSpecName){
//Write Spec to disk
LOGGER.debug(loggerPrefix + "Running Workload Spec: " + tsbsLoadWorkload.toString());
String specUri = this.evaluationContext.getEvluationRun() + File.separator + EvaluationTask.SPECS_FOLDER
+ File.separator + instanceCounter + "_" + workloadSpecName;
this.writeReport(specUri, GSON.toJson(tsbsLoadWorkload));
}
}
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