Commit aeb05b06 authored by Spiros Koulouzis's avatar Spiros Koulouzis

parse sysbench results

parent 7ebd6258
...@@ -23,6 +23,7 @@ import nl.uva.sne.drip.api.dao.AnsibleOutputDao; ...@@ -23,6 +23,7 @@ import nl.uva.sne.drip.api.dao.AnsibleOutputDao;
import nl.uva.sne.drip.api.exception.NotFoundException; import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.data.v1.external.User; import nl.uva.sne.drip.data.v1.external.User;
import nl.uva.sne.drip.data.v1.external.ansible.AnsibleOutput; import nl.uva.sne.drip.data.v1.external.ansible.AnsibleOutput;
import nl.uva.sne.drip.data.v1.external.ansible.AnsibleResult;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostAuthorize; import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PostFilter; import org.springframework.security.access.prepost.PostFilter;
...@@ -43,11 +44,11 @@ public class AnsibleOutputService { ...@@ -43,11 +44,11 @@ public class AnsibleOutputService {
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))") @PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public AnsibleOutput findOne(String id) { public AnsibleOutput findOne(String id) {
AnsibleOutput creds = ansibleOutputDao.findOne(id); AnsibleOutput ansibleOut = ansibleOutputDao.findOne(id);
if (creds == null) { if (ansibleOut == null) {
throw new NotFoundException(); throw new NotFoundException();
} }
return creds; return ansibleOut;
} }
@PostFilter("(filterObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))") @PostFilter("(filterObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
...@@ -57,19 +58,19 @@ public class AnsibleOutputService { ...@@ -57,19 +58,19 @@ public class AnsibleOutputService {
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))") @PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public AnsibleOutput delete(String id) { public AnsibleOutput delete(String id) {
AnsibleOutput creds = ansibleOutputDao.findOne(id); AnsibleOutput ansibleOut = ansibleOutputDao.findOne(id);
if (creds == null) { if (ansibleOut == null) {
throw new NotFoundException(); throw new NotFoundException();
} }
ansibleOutputDao.delete(creds); ansibleOutputDao.delete(ansibleOut);
return creds; return ansibleOut;
} }
public AnsibleOutput save(AnsibleOutput clusterCred) { public AnsibleOutput save(AnsibleOutput ansibleOut) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername(); String owner = user.getUsername();
clusterCred.setOwner(owner); ansibleOut.setOwner(owner);
return ansibleOutputDao.save(clusterCred); return ansibleOutputDao.save(ansibleOut);
} }
@PostAuthorize("(hasRole('ROLE_ADMIN'))") @PostAuthorize("(hasRole('ROLE_ADMIN'))")
...@@ -81,9 +82,31 @@ public class AnsibleOutputService { ...@@ -81,9 +82,31 @@ public class AnsibleOutputService {
List<AnsibleOutput> all = findAll(); List<AnsibleOutput> all = findAll();
Set<String> hashset = new HashSet<>(); Set<String> hashset = new HashSet<>();
for (AnsibleOutput ans : all) { for (AnsibleOutput ans : all) {
hashset.add(ans.getAnsiibleResult().getCmd().get(0)); AnsibleResult res = ans.getAnsibleResult();
if (res != null) {
List<String> commandList = res.getCmd();
if (commandList != null) {
hashset.add(commandList.get(0));
}
}
} }
return new ArrayList<>(hashset); return new ArrayList<>(hashset);
} }
public List<AnsibleOutput> findByCommand(String command) {
List<AnsibleOutput> all = findAll();
List<AnsibleOutput> filtered = new ArrayList<>();
for (AnsibleOutput ans : all) {
AnsibleResult res = ans.getAnsibleResult();
if (res != null) {
List<String> commandList = res.getCmd();
if (commandList != null && commandList.get(0).equals(command)) {
filtered.add(ans);
}
}
}
return filtered;
}
} }
...@@ -15,9 +15,16 @@ ...@@ -15,9 +15,16 @@
*/ */
package nl.uva.sne.drip.api.service; package nl.uva.sne.drip.api.service;
import java.util.List;
import nl.uva.sne.drip.api.dao.BenchmarkResultDao; import nl.uva.sne.drip.api.dao.BenchmarkResultDao;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.data.v1.external.User;
import nl.uva.sne.drip.data.v1.external.ansible.BenchmarkResult;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
...@@ -31,6 +38,43 @@ public class BenchmarkResultService { ...@@ -31,6 +38,43 @@ public class BenchmarkResultService {
@Autowired @Autowired
private BenchmarkResultDao benchmarkResultDao; private BenchmarkResultDao benchmarkResultDao;
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public BenchmarkResult findOne(String id) {
BenchmarkResult benchmarkResult = benchmarkResultDao.findOne(id);
if (benchmarkResult == null) {
throw new NotFoundException();
}
return benchmarkResult;
}
@PostFilter("(filterObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public List<BenchmarkResult> findAll() {
return benchmarkResultDao.findAll();
}
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public BenchmarkResult delete(String id) {
BenchmarkResult benchmarkResult = benchmarkResultDao.findOne(id);
if (benchmarkResult == null) {
throw new NotFoundException();
}
benchmarkResultDao.delete(benchmarkResult);
return benchmarkResult;
}
public BenchmarkResult save(BenchmarkResult benchmarkResult) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
benchmarkResult.setOwner(owner);
return benchmarkResultDao.save(benchmarkResult);
}
@PostAuthorize("(hasRole('ROLE_ADMIN'))")
public void deleteAll() {
benchmarkResultDao.deleteAll();
}
public List<BenchmarkResult> findBySysbench() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.s
}
} }
...@@ -18,6 +18,7 @@ package nl.uva.sne.drip.api.service; ...@@ -18,6 +18,7 @@ package nl.uva.sne.drip.api.service;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
...@@ -26,7 +27,6 @@ import java.util.Map; ...@@ -26,7 +27,6 @@ import java.util.Map;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import nl.uva.sne.drip.api.dao.AnsibleOutputDao;
import nl.uva.sne.drip.api.dao.DeployDao; import nl.uva.sne.drip.api.dao.DeployDao;
import nl.uva.sne.drip.api.exception.NotFoundException; import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.api.rpc.DRIPCaller; import nl.uva.sne.drip.api.rpc.DRIPCaller;
...@@ -51,8 +51,12 @@ import org.springframework.security.core.context.SecurityContextHolder; ...@@ -51,8 +51,12 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import nl.uva.sne.drip.api.dao.KeyPairDao; import nl.uva.sne.drip.api.dao.KeyPairDao;
import nl.uva.sne.drip.api.exception.KeyException; import nl.uva.sne.drip.api.exception.KeyException;
import nl.uva.sne.drip.commons.utils.MessageGenerator;
import nl.uva.sne.drip.data.v1.external.KeyPair; import nl.uva.sne.drip.data.v1.external.KeyPair;
import nl.uva.sne.drip.data.v1.external.ansible.AnsibleOutput; import nl.uva.sne.drip.data.v1.external.ansible.AnsibleOutput;
import nl.uva.sne.drip.data.v1.external.ansible.AnsibleResult;
import nl.uva.sne.drip.data.v1.external.ansible.BenchmarkResult;
import nl.uva.sne.drip.data.v1.external.ansible.SysbenchCPUBenchmark;
/** /**
* *
...@@ -83,6 +87,9 @@ public class DeployService { ...@@ -83,6 +87,9 @@ public class DeployService {
@Autowired @Autowired
private PlaybookService playbookService; private PlaybookService playbookService;
@Autowired
private BenchmarkResultService benchmarkResultService;
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))") @PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public DeployResponse findOne(String id) { public DeployResponse findOne(String id) {
DeployResponse creds = deployDao.findOne(id); DeployResponse creds = deployDao.findOne(id);
...@@ -121,11 +128,12 @@ public class DeployService { ...@@ -121,11 +128,12 @@ public class DeployService {
deployInfo.getManagerType().toLowerCase(), deployInfo.getManagerType().toLowerCase(),
deployInfo.getConfigurationID()); deployInfo.getConfigurationID());
// Message response = MessageGenerator.generateArtificialMessage(System.getProperty("user.home") Message response = MessageGenerator.generateArtificialMessage(System.getProperty("user.home")
// + File.separator + "workspace" + File.separator + "DRIP" + File.separator + "workspace" + File.separator + "DRIP"
// + File.separator + "docs" + File.separator + "json_samples" + File.separator + "docs" + File.separator + "json_samples"
// + File.separator + "deployer_ansible_response_benchmark.json"); + File.separator + "deployer_ansible_response_benchmark.json");
Message response = (deployer.call(deployerInvokationMessage));
// Message response = (deployer.call(deployerInvokationMessage));
List<MessageParameter> params = response.getParameters(); List<MessageParameter> params = response.getParameters();
DeployResponse deploy = handleResponse(params, deployInfo); DeployResponse deploy = handleResponse(params, deployInfo);
deploy.setProvisionID(deployInfo.getProvisionID()); deploy.setProvisionID(deployInfo.getProvisionID());
...@@ -252,12 +260,10 @@ public class DeployService { ...@@ -252,12 +260,10 @@ public class DeployService {
for (AnsibleOutput ansOut : outputList) { for (AnsibleOutput ansOut : outputList) {
Map<String, Object> map = provisionService.findOne(deployInfo.getProvisionID()).getKeyValue(); Map<String, Object> map = provisionService.findOne(deployInfo.getProvisionID()).getKeyValue();
String nodeType = nodeTypeCahche.get(ansOut.getHost()); String nodeType = nodeTypeCahche.get(ansOut.getHost());
String domain = domainCahche.get(ansOut.getHost()); String domain = domainCahche.get(ansOut.getHost());
if (nodeType == null) { if (nodeType == null) {
List<Map<String, Object>> components = (List<Map<String, Object>>) map.get("components"); List<Map<String, Object>> components = (List<Map<String, Object>>) map.get("components");
for (Map<String, Object> component : components) { for (Map<String, Object> component : components) {
String publicAddress = (String) component.get("public_address"); String publicAddress = (String) component.get("public_address");
if (publicAddress.equals(ansOut.getHost())) { if (publicAddress.equals(ansOut.getHost())) {
...@@ -266,7 +272,7 @@ public class DeployService { ...@@ -266,7 +272,7 @@ public class DeployService {
domain = (String) component.get("domain"); domain = (String) component.get("domain");
nodeTypeCahche.put(ansOut.getHost(), nodeType); nodeTypeCahche.put(ansOut.getHost(), nodeType);
domainCahche.put(ansOut.getHost(), value); domainCahche.put(ansOut.getHost(), domain);
// ansOut.setCloudProviderName(""); // ansOut.setCloudProviderName("");
break; break;
} }
...@@ -276,6 +282,9 @@ public class DeployService { ...@@ -276,6 +282,9 @@ public class DeployService {
ansOut.setCloudDeploymentDomain(domain); ansOut.setCloudDeploymentDomain(domain);
ansOut.setProvisionID(deployInfo.getProvisionID()); ansOut.setProvisionID(deployInfo.getProvisionID());
ansOut = ansibleOutputService.save(ansOut); ansOut = ansibleOutputService.save(ansOut);
BenchmarkResult benchmarkResult = parseToBenchmarkResult(ansOut);
benchmarkResultService.save(benchmarkResult);
outputListIds.add(ansOut.getId()); outputListIds.add(ansOut.getId());
} }
deployResponse.setAnsibleOutputList(outputListIds); deployResponse.setAnsibleOutputList(outputListIds);
...@@ -283,4 +292,102 @@ public class DeployService { ...@@ -283,4 +292,102 @@ public class DeployService {
} }
return deployResponse; return deployResponse;
} }
private BenchmarkResult parseToBenchmarkResult(AnsibleOutput ansOut) {
AnsibleResult res = ansOut.getAnsibleResult();
if (res != null) {
List<String> cmdList = res.getCmd();
if (cmdList != null) {
switch (cmdList.get(0)) {
case "sysbench":
String[] out = res.getStdout().split("\n");
String version = getSysbeanchVersion(out[0]);
int numOfThreads = getNumberOfThreads(out[3]);
Double executionTime = getExecutionTime(out[14]);
int totalNumberOfEvents = getTotalNumberOfEvents(out[15]);
long minExecutionTimePerRequest = getMinExecutionTimePerRequest(out[18]);
long avgExecutionTimePerRequest = getAvgExecutionTimePerRequest(out[19]);
long maxExecutionTimePerRequest = getMaxExecutionTimePerRequest(out[20]);
long approx95Percentile = getApprox95Percentile(out[21]);
double avgEventsPerThread = getAvgEventsPerThread(out[24]);
double stddevEventsPerThread = getStddevEventsPerThread(out[24]);
double avgExecTimePerThread = getAvgExecTimePerThread(out[24]);
double stddevExecTimePerThread = getStddevExecTimePerThread(out[24]);
SysbenchCPUBenchmark b = new SysbenchCPUBenchmark();
b.setSysbenchVersion(version);
b.setNumberOfThreads(numOfThreads);
b.setExecutionTime(executionTime * 1000);
b.setTotalNumberOfEvents(totalNumberOfEvents);
b.setAvgEventsPerThread(avgEventsPerThread);
b.setStddevEventsPerThread(stddevEventsPerThread);
b.setAvgExecTimePerThread(avgExecTimePerThread * 1000);
b.setStddevExecTimePerThread(stddevExecTimePerThread);
b.setApprox95Percentile(approx95Percentile);
b.setMinExecutionTimePerRequest(minExecutionTimePerRequest);
b.setAvgExecTimePerThread(avgExecutionTimePerRequest);
b.setMaxExecutionTimePerRequest(maxExecutionTimePerRequest);
return b;
default:
return null;
}
}
}
return null;
}
private String getSysbeanchVersion(String string) {
return string.replaceAll("sysbench", "").replaceAll(": multi-threaded system evaluation benchmark", "");
}
private int getNumberOfThreads(String string) {
return Integer.valueOf(string.replaceAll("Number of threads: ", ""));
}
private Double getExecutionTime(String string) {
return Double.valueOf(string.replaceAll("total time:", "").replaceAll("s", "").trim());
}
private int getTotalNumberOfEvents(String string) {
return Integer.valueOf(string.replaceAll("total number of events:", "").replaceAll("s", "").trim());
}
private Double getAvgEventsPerThread(String string) {
return Double.valueOf(string.replaceAll("events (avg/stddev):", "").replaceAll("s", "").trim().split("/")[0]);
}
private Double getStddevEventsPerThread(String string) {
return Double.valueOf(string.replaceAll("events (avg/stddev):", "").replaceAll("s", "").trim().split("/")[1]);
}
private Double getAvgExecTimePerThread(String string) {
return Double.valueOf(string.replaceAll("execution time (avg/stddev):", "").replaceAll("s", "").trim().split("/")[0]);
}
private Double getStddevExecTimePerThread(String string) {
return Double.valueOf(string.replaceAll("execution time (avg/stddev):", "").replaceAll("s", "").trim().split("/")[0]);
}
private long getMinExecutionTimePerRequest(String string) {
return Long.valueOf(string.replaceAll("min:", "").replaceAll("ms", "").trim());
}
private long getAvgExecutionTimePerRequest(String string) {
return Long.valueOf(string.replaceAll("avg:", "").replaceAll("ms", "").trim());
}
private long getMaxExecutionTimePerRequest(String string) {
return Long.valueOf(string.replaceAll("max:", "").replaceAll("ms", "").trim());
}
private long getApprox95Percentile(String string) {
return Long.valueOf(string.replaceAll("approx. 95 percentile::", "").replaceAll("ms", "").trim());
}
} }
...@@ -58,8 +58,8 @@ public class AnsibleOutputController { ...@@ -58,8 +58,8 @@ public class AnsibleOutputController {
@RequestMapping(method = RequestMethod.GET, params = {"command"}) @RequestMapping(method = RequestMethod.GET, params = {"command"})
@RolesAllowed({UserService.USER, UserService.ADMIN}) @RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody public @ResponseBody
AnsibleOutput getByCommand(@RequestParam(value = "command") String command) { List<AnsibleOutput> getByCommand(@RequestParam(value = "command") String command) {
return null; return ansibleOutputService.findByCommand(command);
} }
@RequestMapping(value = "/ids", method = RequestMethod.GET) @RequestMapping(value = "/ids", method = RequestMethod.GET)
......
...@@ -17,14 +17,23 @@ package nl.uva.sne.drip.api.v1.rest; ...@@ -17,14 +17,23 @@ package nl.uva.sne.drip.api.v1.rest;
import com.webcohesion.enunciate.metadata.rs.ResponseCode; import com.webcohesion.enunciate.metadata.rs.ResponseCode;
import com.webcohesion.enunciate.metadata.rs.StatusCodes; import com.webcohesion.enunciate.metadata.rs.StatusCodes;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.security.RolesAllowed;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.api.service.BenchmarkResultService; import nl.uva.sne.drip.api.service.BenchmarkResultService;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.data.v1.external.ansible.BenchmarkResult;
import nl.uva.sne.drip.data.v1.external.ansible.BenchmarkResult;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/** /**
* This controller is responsible for deploying a cluster on provisoned
* resources.
* *
* @author S. Koulouzis * @author S. Koulouzis
*/ */
...@@ -34,7 +43,57 @@ import org.springframework.stereotype.Controller; ...@@ -34,7 +43,57 @@ import org.springframework.stereotype.Controller;
@StatusCodes({ @StatusCodes({
@ResponseCode(code = 401, condition = "Bad credentials") @ResponseCode(code = 401, condition = "Bad credentials")
}) })
public class Benchmark { public class BenchmarkController {
private BenchmarkResultService benchmarkResultService; private BenchmarkResultService benchmarkResultService;
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
BenchmarkResult get(@PathVariable("id") String id) {
BenchmarkResult resp = benchmarkResultService.findOne(id);
if (resp == null) {
throw new NotFoundException();
}
return resp;
}
@RequestMapping(method = RequestMethod.GET)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
List<BenchmarkResult> getBySysbench() {
return benchmarkResultService.findBySysbench();
}
@RequestMapping(value = "/ids", method = RequestMethod.GET)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
List<String> getIds() {
List<BenchmarkResult> all = benchmarkResultService.findAll();
List<String> ids = new ArrayList<>(all.size());
for (BenchmarkResult pi : all) {
ids.add(pi.getId());
}
return ids;
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
String delete(@PathVariable("id") String id) {
BenchmarkResult Key = benchmarkResultService.findOne(id);
if (Key != null) {
benchmarkResultService.delete(id);
return "Deleted : " + id;
}
throw new NotFoundException();
}
@RequestMapping(value = "/all", method = RequestMethod.DELETE)
@RolesAllowed({UserService.ADMIN})
public @ResponseBody
String deleteAll() {
benchmarkResultService.deleteAll();
return "Done";
}
} }
...@@ -31,35 +31,22 @@ import org.json.JSONException; ...@@ -31,35 +31,22 @@ import org.json.JSONException;
public class MessageGenerator { public class MessageGenerator {
public static Message generateArtificialMessage(String path) throws IOException, TimeoutException, InterruptedException, JSONException { public static Message generateArtificialMessage(String path) throws IOException, TimeoutException, InterruptedException, JSONException {
// String strResponse = "{\"creationDate\":1488368936945,\"parameters\":["
// + "{\"name\":\"f293ff03-4b82-49e2-871a-899aadf821ce\","
// + "\"encoding\":\"UTF-8\",\"value\":"
// + "\"publicKeyPath: /tmp/Input-4007028381500/user.pem\\nuserName: "
// + "zh9314\\nsubnets:\\n- {name: s1, subnet: 192.168.10.0, "
// + "netmask: 255.255.255.0}\\ncomponents:\\n- "
// + "name: faab6756-61b6-4800-bffa-ae9d859a9d6c\\n "
// + "type: Switch.nodes.Compute\\n nodetype: t2.medium\\n "
// + "OStype: Ubuntu 16.04\\n domain: ec2.us-east-1.amazonaws.com\\n "
// + "script: /tmp/Input-4007028381500/guiscipt.sh\\n "
// + "installation: null\\n role: master\\n "
// + "dockers: mogswitch/InputDistributor\\n "
// + "public_address: 54.144.0.91\\n instanceId: i-0e78cbf853328b820\\n "
// + "ethernet_port:\\n - {name: p1, subnet_name: s1, "
// + "address: 192.168.10.10}\\n- name: 1c75eedf-8497-46fe-aeb8-dab6a62154cb\\n "
// + "type: Switch.nodes.Compute\\n nodetype: t2.medium\\n OStype: Ubuntu 16.04\\n domain: ec2.us-east-1.amazonaws.com\\n script: /tmp/Input-4007028381500/guiscipt.sh\\n installation: null\\n role: slave\\n dockers: mogswitch/ProxyTranscoder\\n public_address: 34.207.254.160\\n instanceId: i-0a99ea18fcc77ed7a\\n ethernet_port:\\n - {name: p1, subnet_name: s1, address: 192.168.10.11}\\n\"},{\"name\":\"kubernetes\",\"encoding\":\"UTF-8\",\"value\":\"54.144.0.91 ubuntu /tmp/Input-4007028381500/Virginia.pem master\\n34.207.254.160 ubuntu /tmp/Input-4007028381500/Virginia.pem slave\\n\"}]}";
// String strResponse = "{\"creationDate\":1488805337447,\"parameters\":[{\"name\":\"2e5dafb6-5a1c-4a66-9dca-5841f99ea735\",\"encoding\":\"UTF-8\",\"value\":\"publicKeyPath: /tmp/Input-11594765342486/user.pem\\nuserName: zh9314\\nsubnets:\\n- {name: s1, subnet: 192.168.10.0, netmask: 255.255.255.0}\\ncomponents:\\n- name: 8fcc1788d9ee462c826572c79fdb2a6a\\n type: Switch.nodes.Compute\\n nodeType: t2.medium\\n OStype: Ubuntu 16.04\\n script: /tmp/Input-11594765342486/guiscipt.sh\\n domain: ec2.us-east-1.amazonaws.com\\n installation: null\\n clusterType: swarm\\n role: master\\n dockers: mogswitch/ProxyTranscoder:1.0\\n public_address: 34.207.73.18\\n instanceId: i-0e82b5624a0df99b1\\n ethernet_port:\\n - {name: p1, subnet_name: s1, address: 192.168.10.10}\\n- name: 8fcc1788d9ee462c826572c79fdb2a6a\\n type: Switch.nodes.Compute\\n nodeType: t2.medium\\n OStype: Ubuntu 16.04\\n script: /tmp/Input-11594765342486/guiscipt.sh\\n domain: ec2.us-east-1.amazonaws.com\\n installation: null\\n clusterType: swarm\\n role: slave\\n dockers: mogswitch/ProxyTranscoder:1.0\\n public_address: 34.207.73.18\\n instanceId: i-0e82b5624a0df99b1\\n ethernet_port:\\n - {name: p1, subnet_name: s1, address: 192.168.10.11}\\n\"},{\"name\":\"kubernetes\",\"encoding\":\"UTF-8\",\"value\":\"34.207.73.18 ubuntu /tmp/Input-11594765342486/Virginia.pem master\\n34.207.73.18 ubuntu /tmp/Input-11594765342486/Virginia.pem slave\\n\"}]}";
String strResponse = FileUtils.readFileToString(new File(path)); String strResponse = FileUtils.readFileToString(new File(path));
String clean = strResponse;
if (strResponse.contains("'null'")) { if (strResponse.contains("'null'")) {
strResponse = strResponse.replaceAll("'null'", "null").replaceAll("\'", "\"").replaceAll(" ", ""); clean = strResponse.replaceAll("'null'", "null").replaceAll("\'", "\"").replaceAll(" ", "");
} }
if (strResponse.contains("\"value\":{\"")) { if (clean.contains("\"value\":{\"")) {
return Converter.string2Message(strResponse); return Converter.string2Message(clean);
}
if (clean.contains("\"null\"")) {
clean = clean.replaceAll("\"null\"", "null");
} }
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
return mapper.readValue(strResponse, Message.class); return mapper.readValue(clean, Message.class);
} }
} }
...@@ -49,7 +49,6 @@ public class AnsibleOutput extends OwnedObject { ...@@ -49,7 +49,6 @@ public class AnsibleOutput extends OwnedObject {
@JsonProperty("result") @JsonProperty("result")
private AnsibleResult result; private AnsibleResult result;
@Indexed
@JsonProperty("provisionID") @JsonProperty("provisionID")
private String provisionID; private String provisionID;
...@@ -64,7 +63,7 @@ public class AnsibleOutput extends OwnedObject { ...@@ -64,7 +63,7 @@ public class AnsibleOutput extends OwnedObject {
} }
@JsonProperty("result") @JsonProperty("result")
public AnsibleResult getAnsiibleResult() { public AnsibleResult getAnsibleResult() {
return result; return result;
} }
......
...@@ -25,7 +25,6 @@ import java.util.List; ...@@ -25,7 +25,6 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Date; import java.util.Date;
import org.springframework.data.mongodb.core.index.Indexed;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
...@@ -33,20 +32,18 @@ public class AnsibleResult { ...@@ -33,20 +32,18 @@ public class AnsibleResult {
@JsonProperty("msg") @JsonProperty("msg")
private String msg; private String msg;
@JsonProperty("changed") @JsonProperty("changed")
private Boolean changed; private Boolean changed;
@Indexed
@JsonProperty("end") @JsonProperty("end")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss.SSSSSS") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss.SSSSSS")
private Date end; private Date end;
@Indexed
@JsonProperty("start") @JsonProperty("start")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss.SSSSSS") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss.SSSSSS")
private Date start; private Date start;
@Indexed
@JsonProperty("delta") @JsonProperty("delta")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss.SSSSSS") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss.SSSSSS")
private Date delta; private Date delta;
...@@ -60,12 +57,11 @@ public class AnsibleResult { ...@@ -60,12 +57,11 @@ public class AnsibleResult {
@JsonProperty("cmd") @JsonProperty("cmd")
private List<String> cmd; private List<String> cmd;
@JsonProperty("stdout_lines") // @JsonProperty("stdout_lines")
private List<String> stdout_lines; // private List<String> stdout_lines;
@JsonProperty("results")
private List<AnsibleResult_> results = null;
// @JsonProperty("results")
// private List<AnsibleResult_> results = null;
@JsonProperty("msg") @JsonProperty("msg")
public String getMsg() { public String getMsg() {
return msg; return msg;
...@@ -86,16 +82,15 @@ public class AnsibleResult { ...@@ -86,16 +82,15 @@ public class AnsibleResult {
this.changed = changed; this.changed = changed;
} }
@JsonProperty("results") // @JsonProperty("results")
public List<AnsibleResult_> getAnsibleResults() { // public List<AnsibleResult_> getAnsibleResults() {
return results; // return results;
} // }
//
@JsonProperty("results") // @JsonProperty("results")
public void setAnsibleResults(List<AnsibleResult_> results) { // public void setAnsibleResults(List<AnsibleResult_> results) {
this.results = results; // this.results = results;
} // }
@JsonProperty("end") @JsonProperty("end")
public Date getEnd() { public Date getEnd() {
return end; return end;
...@@ -156,14 +151,14 @@ public class AnsibleResult { ...@@ -156,14 +151,14 @@ public class AnsibleResult {
this.delta = delta; this.delta = delta;
} }
@JsonProperty("stdout_lines") // @JsonProperty("stdout_lines")
public List<String> getStdout_lines() { // public List<String> getStdout_lines() {
return stdout_lines; // return stdout_lines;
} // }
//
@JsonProperty("stdout_lines") // @JsonProperty("stdout_lines")
public void setStdout_lines(List<String> stdout_lines) { // public void setStdout_lines(List<String> stdout_lines) {
this.stdout_lines = stdout_lines; // this.stdout_lines = stdout_lines;
} // }
} }
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.data.v1.external.ansible;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
/**
*
* @author S. Koulouzis
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"_ansible_parsed",
"changed",
"_ansible_no_log",
"cache_updated",
"_ansible_item_result",
"item",
"invocation",
"cache_update_time"
})
public class AnsibleResult_ {
@JsonProperty("_ansible_parsed")
private Boolean ansibleParsed;
@JsonProperty("changed")
private Boolean changed;
@JsonProperty("_ansible_no_log")
private Boolean ansibleNoLog;
@JsonProperty("cache_updated")
private Boolean cacheUpdated;
@JsonProperty("_ansible_item_result")
private Boolean ansibleItemAnsibleResult;
@JsonProperty("item")
private List<String> item = null;
@JsonProperty("invocation")
private Invocation invocation;
@JsonProperty("cache_update_time")
private Integer cacheUpdateTime;
@JsonProperty("_ansible_parsed")
public Boolean getAnsibleParsed() {
return ansibleParsed;
}
@JsonProperty("_ansible_parsed")
public void setAnsibleParsed(Boolean ansibleParsed) {
this.ansibleParsed = ansibleParsed;
}
@JsonProperty("changed")
public Boolean getChanged() {
return changed;
}
@JsonProperty("changed")
public void setChanged(Boolean changed) {
this.changed = changed;
}
@JsonProperty("_ansible_no_log")
public Boolean getAnsibleNoLog() {
return ansibleNoLog;
}
@JsonProperty("_ansible_no_log")
public void setAnsibleNoLog(Boolean ansibleNoLog) {
this.ansibleNoLog = ansibleNoLog;
}
@JsonProperty("cache_updated")
public Boolean getCacheUpdated() {
return cacheUpdated;
}
@JsonProperty("cache_updated")
public void setCacheUpdated(Boolean cacheUpdated) {
this.cacheUpdated = cacheUpdated;
}
@JsonProperty("_ansible_item_result")
public Boolean getAnsibleItemAnsibleResult() {
return ansibleItemAnsibleResult;
}
@JsonProperty("_ansible_item_result")
public void setAnsibleItemAnsibleResult(Boolean ansibleItemAnsibleResult) {
this.ansibleItemAnsibleResult = ansibleItemAnsibleResult;
}
@JsonProperty("item")
public List<String> getItem() {
return item;
}
@JsonProperty("item")
public void setItem(List<String> item) {
this.item = item;
}
@JsonProperty("invocation")
public Invocation getInvocation() {
return invocation;
}
@JsonProperty("invocation")
public void setInvocation(Invocation invocation) {
this.invocation = invocation;
}
@JsonProperty("cache_update_time")
public Integer getCacheUpdateTime() {
return cacheUpdateTime;
}
@JsonProperty("cache_update_time")
public void setCacheUpdateTime(Integer cacheUpdateTime) {
this.cacheUpdateTime = cacheUpdateTime;
}
}
...@@ -19,7 +19,6 @@ import com.fasterxml.jackson.annotation.JsonFormat; ...@@ -19,7 +19,6 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Date; import java.util.Date;
import nl.uva.sne.drip.data.v1.external.OwnedObject; import nl.uva.sne.drip.data.v1.external.OwnedObject;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Document;
/** /**
...@@ -29,9 +28,8 @@ import org.springframework.data.mongodb.core.mapping.Document; ...@@ -29,9 +28,8 @@ import org.springframework.data.mongodb.core.mapping.Document;
@Document @Document
public class BenchmarkResult extends OwnedObject { public class BenchmarkResult extends OwnedObject {
@Indexed
private String host; private String host;
@Indexed
private String cloudProvider; private String cloudProvider;
@JsonProperty("end") @JsonProperty("end")
......
...@@ -26,13 +26,18 @@ public class SysbenchCPUBenchmark extends BenchmarkResult { ...@@ -26,13 +26,18 @@ public class SysbenchCPUBenchmark extends BenchmarkResult {
private String sysbenchVersion; private String sysbenchVersion;
private int numberOfThreads; private int numberOfThreads;
private int totalNumberOfEvents;
private double executionTime; private double executionTime;
private int avgEventsPerThread; private int totalNumberOfEvents;
private int stddevEventsPerThread; private double avgEventsPerThread;
private double stddevEventsPerThread;
private double avgExecTimePerThread;
private double stddevExecTimePerThread;
private int avgExecTimePerThread; private double minExecutionTimePerRequest;
private int stddevExecTimePerThread; private double avgExecutionTimePerRequest;
private double maxExecutionTimePerRequest;
private double approx95Percentile;
/** /**
* @return the sysbenchVersion * @return the sysbenchVersion
...@@ -93,57 +98,113 @@ public class SysbenchCPUBenchmark extends BenchmarkResult { ...@@ -93,57 +98,113 @@ public class SysbenchCPUBenchmark extends BenchmarkResult {
/** /**
* @return the avgEventsPerThread * @return the avgEventsPerThread
*/ */
public int getAvgEventsPerThread() { public double getAvgEventsPerThread() {
return avgEventsPerThread; return avgEventsPerThread;
} }
/** /**
* @param avgEventsPerThread the avgEventsPerThread to set * @param avgEventsPerThread the avgEventsPerThread to set
*/ */
public void setAvgEventsPerThread(int avgEventsPerThread) { public void setAvgEventsPerThread(double avgEventsPerThread) {
this.avgEventsPerThread = avgEventsPerThread; this.avgEventsPerThread = avgEventsPerThread;
} }
/** /**
* @return the stddevEventsPerThread * @return the stddevEventsPerThread
*/ */
public int getStddevEventsPerThread() { public double getStddevEventsPerThread() {
return stddevEventsPerThread; return stddevEventsPerThread;
} }
/** /**
* @param stddevEventsPerThread the stddevEventsPerThread to set * @param stddevEventsPerThread the stddevEventsPerThread to set
*/ */
public void setStddevEventsPerThread(int stddevEventsPerThread) { public void setStddevEventsPerThread(double stddevEventsPerThread) {
this.stddevEventsPerThread = stddevEventsPerThread; this.stddevEventsPerThread = stddevEventsPerThread;
} }
/** /**
* @return the avgExecTimePerThread * @return the avgExecTimePerThread
*/ */
public int getAvgExecTimePerThread() { public double getAvgExecTimePerThread() {
return avgExecTimePerThread; return avgExecTimePerThread;
} }
/** /**
* @param avgExecTimePerThread the avgExecTimePerThread to set * @param avgExecTimePerThread the avgExecTimePerThread to set
*/ */
public void setAvgExecTimePerThread(int avgExecTimePerThread) { public void setAvgExecTimePerThread(double avgExecTimePerThread) {
this.avgExecTimePerThread = avgExecTimePerThread; this.avgExecTimePerThread = avgExecTimePerThread;
} }
/** /**
* @return the stddevExecTimePerThread * @return the stddevExecTimePerThread
*/ */
public int getStddevExecTimePerThread() { public double getStddevExecTimePerThread() {
return stddevExecTimePerThread; return stddevExecTimePerThread;
} }
/** /**
* @param stddevExecTimePerThread the stddevExecTimePerThread to set * @param stddevExecTimePerThread the stddevExecTimePerThread to set
*/ */
public void setStddevExecTimePerThread(int stddevExecTimePerThread) { public void setStddevExecTimePerThread(double stddevExecTimePerThread) {
this.stddevExecTimePerThread = stddevExecTimePerThread; this.stddevExecTimePerThread = stddevExecTimePerThread;
} }
/**
* @return the minExecutionTimePerRequest
*/
public double getMinExecutionTimePerRequest() {
return minExecutionTimePerRequest;
}
/**
* @param minExecutionTimePerRequest the minExecutionTimePerRequest to set
*/
public void setMinExecutionTimePerRequest(double minExecutionTimePerRequest) {
this.minExecutionTimePerRequest = minExecutionTimePerRequest;
}
/**
* @return the avgExecutionTimePerRequest
*/
public double getAvgExecutionTimePerRequest() {
return avgExecutionTimePerRequest;
}
/**
* @param avgExecutionTimePerRequest the avgExecutionTimePerRequest to set
*/
public void setAvgExecutionTimePerRequest(double avgExecutionTimePerRequest) {
this.avgExecutionTimePerRequest = avgExecutionTimePerRequest;
}
/**
* @return the maxExecutionTimePerRequest
*/
public double getMaxExecutionTimePerRequest() {
return maxExecutionTimePerRequest;
}
/**
* @param maxExecutionTimePerRequest the maxExecutionTimePerRequest to set
*/
public void setMaxExecutionTimePerRequest(double maxExecutionTimePerRequest) {
this.maxExecutionTimePerRequest = maxExecutionTimePerRequest;
}
/**
* @return the approx95Percentile
*/
public double getApprox95Percentile() {
return approx95Percentile;
}
/**
* @param approx95Percentile the approx95Percentile to set
*/
public void setApprox95Percentile(double approx95Percentile) {
this.approx95Percentile = approx95Percentile;
}
} }
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