Skip to content
Snippets Groups Projects
Commit 1610b04b authored by Johannes Mey's avatar Johannes Mey
Browse files

Merge branch 'eris-coupling' of git-st.inf.tu-dresden.de:stgroup/ttc18 into eris-coupling

parents fc8d9a60 fc5fbdad
No related branches found
No related tags found
No related merge requests found
package de.tudresden.inf.st.mquat.eris.coupling;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class ERISAccessPath {
private String addressingMode;
private boolean dynamic;
private int id;
private String name;
private List<ERISBenchmarkResult> resultList = new ArrayList<>();
//properties
private String attributeCount;
private int attributeNull;
private int attributeUndefined;
private int dynamicAttributeSize;
private int indexAttributeCount;
private int indexOrderPreserving;
public ERISAccessPath(JSONObject jsonObject) {
addressingMode = jsonObject.getString("addressingMode");
dynamic = jsonObject.getBoolean("dynamic");
id = jsonObject.getInt("id");
name = jsonObject.getString("name");
JSONArray performances = jsonObject.getJSONArray("performances");
for (int i = 0; i< performances.length(); i++){
resultList.add(new ERISBenchmarkResult(performances.getJSONObject(i)));
}
JSONObject properties = jsonObject.getJSONObject("properties");
attributeCount = properties.get("attributeCount").toString();
attributeNull = properties.getInt("attributeNull");
attributeUndefined = properties.getInt("attributeUndefined");
dynamicAttributeSize = properties.getInt("dynamicAttributeSize");
indexAttributeCount = properties.getInt("indexAttributeCount");
indexOrderPreserving = properties.getInt("indexOrderPreserving");
}
public String getAddressingMode() {
return addressingMode;
}
public void setAddressingMode(String addressingMode) {
this.addressingMode = addressingMode;
}
public boolean isDynamic() {
return dynamic;
}
public void setDynamic(boolean dynamic) {
this.dynamic = dynamic;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<ERISBenchmarkResult> getResultList() {
return resultList;
}
public void setResultList(List<ERISBenchmarkResult> resultList) {
this.resultList = resultList;
}
public String getAttributeCount() {
return attributeCount;
}
public void setAttributeCount(String attributeCount) {
this.attributeCount = attributeCount;
}
public int getAttributeNull() {
return attributeNull;
}
public void setAttributeNull(int attributeNull) {
this.attributeNull = attributeNull;
}
public int getAttributeUndefined() {
return attributeUndefined;
}
public void setAttributeUndefined(int attributeUndefined) {
this.attributeUndefined = attributeUndefined;
}
public int getDynamicAttributeSize() {
return dynamicAttributeSize;
}
public void setDynamicAttributeSize(int dynamicAttributeSize) {
this.dynamicAttributeSize = dynamicAttributeSize;
}
public int getIndexAttributeCount() {
return indexAttributeCount;
}
public void setIndexAttributeCount(int indexAttributeCount) {
this.indexAttributeCount = indexAttributeCount;
}
public int getIndexOrderPreserving() {
return indexOrderPreserving;
}
public void setIndexOrderPreserving(int indexOrderPreserving) {
this.indexOrderPreserving = indexOrderPreserving;
}
}
package de.tudresden.inf.st.mquat.eris.coupling;
import org.json.JSONArray;
import org.json.JSONObject;
public class ERISBenchmarkResult {
private int dataSize;
private double insert;
private double link;
private double lookup;
private double scan;
private double storageSize;
public ERISBenchmarkResult(JSONObject jsonObject){
dataSize = jsonObject.getInt("dataSize");
insert = jsonObject.getDouble("insert");
link = jsonObject.getDouble("link");
lookup = jsonObject.getDouble("lookup");
scan = jsonObject.getDouble("scan");
storageSize = jsonObject.getDouble("storageSize");
}
public int getDataSize() {
return dataSize;
}
public void setDataSize(int dataSize) {
this.dataSize = dataSize;
}
public double getInsert() {
return insert;
}
public void setInsert(double insert) {
this.insert = insert;
}
public double getLink() {
return link;
}
public void setLink(double link) {
this.link = link;
}
public double getLookup() {
return lookup;
}
public void setLookup(double lookup) {
this.lookup = lookup;
}
public double getScan() {
return scan;
}
public void setScan(double scan) {
this.scan = scan;
}
public double getStorageSize() {
return storageSize;
}
public void setStorageSize(double storageSize) {
this.storageSize = storageSize;
}
}
......@@ -7,16 +7,12 @@ import java.util.ArrayList;
import java.util.List;
public class ERISLPConfiguration {
private int accessPathId;
private boolean accessPathIsDynamic;
private String accessPathName;
private ERISAccessPath accessPath;
private List<ERISAttribute> attributes;
private List<ERISAttribute> keys;
public ERISLPConfiguration(JSONObject jsonObject, List<ERISAttribute> allAttributes){
accessPathId = jsonObject.getInt("accessPathId");
accessPathIsDynamic = jsonObject.getBoolean("accessPathIsDynamic");
accessPathName = jsonObject.get("accessPathName").toString();
public ERISLPConfiguration(JSONObject jsonObject, List<ERISAttribute> allAttributes, List<ERISAccessPath> accessPaths){
accessPath = accessPaths.stream().filter(ap -> ap.getId() == jsonObject.getInt("accessPathId")).findFirst().get();
JSONArray lpAttributes = jsonObject.getJSONArray("attributes");
attributes = new ArrayList<>();
......@@ -31,4 +27,28 @@ public class ERISLPConfiguration {
}
}
}
public ERISAccessPath getAccessPath() {
return accessPath;
}
public void setAccessPath(ERISAccessPath accessPath) {
this.accessPath = accessPath;
}
public List<ERISAttribute> getAttributes() {
return attributes;
}
public void setAttributes(List<ERISAttribute> attributes) {
this.attributes = attributes;
}
public List<ERISAttribute> getKeys() {
return keys;
}
public void setKeys(List<ERISAttribute> keys) {
this.keys = keys;
}
}
......@@ -12,20 +12,24 @@ import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class ERISReader {
private final String ERIS_URL = "127.0.0.1:5189";
private String sessionID;
private String containerID;
private List<NameValuePair> nodeIDLocalIDMapping = new ArrayList<>();
private enum RequestType {GET, POST}
private List<ERISContainer> containers = new ArrayList<>();
private List<ERISAccessPath> accessPaths = new ArrayList<>();
public ERISReader(){
// curl --data "login=jo&password=jo" http://127.0.0.1:5189/session
......@@ -48,8 +52,30 @@ public class ERISReader {
}
public void read(){
// curl http://127.0.0.1:5189/swctrl/containers?id=<>
// curl http://127.0.0.1:5189/swctrl/accesspaths?id=
try {
URI uri = new URIBuilder()
.setHost(ERIS_URL)
.setScheme("http")
.setPath("swctrl/accesspaths")
.setParameter("id", sessionID)
.build();
//String content = getContent(uri);
String content = new String(Files.readAllBytes(new File("jastadd-mquat-base/src/main/resources/accesspaths.json").toPath()));
JSONArray accesspathList = new JSONArray(content);
for (int i = 0; i < accesspathList.length(); i++){
accessPaths.add(new ERISAccessPath(accesspathList.getJSONObject(i)));
}
} catch (URISyntaxException e){
e.printStackTrace();
} catch (IOException e){
e.printStackTrace();
}
// curl http://127.0.0.1:5189/swctrl/containers?id=<>
try {
URI uri = new URIBuilder()
......@@ -104,7 +130,7 @@ public class ERISReader {
JSONArray configurations = lpInfo.getJSONArray("configuration");
for (int i = 0; i < configurations.length(); i++)
lp.getConfigurations().
add(new ERISLPConfiguration(configurations.getJSONObject(i), ec.getAttributeList()));
add(new ERISLPConfiguration(configurations.getJSONObject(i), ec.getAttributeList(), accessPaths));
JSONObject stats = lpInfo.getJSONObject("statistics");
lp.setStatistics(new ERISLPStatistics(stats));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment