diff --git a/jastadd-mquat-base/src/main/java/de/tudresden/inf/st/mquat/eris/coupling/ERISAccessPath.java b/jastadd-mquat-base/src/main/java/de/tudresden/inf/st/mquat/eris/coupling/ERISAccessPath.java new file mode 100644 index 0000000000000000000000000000000000000000..560d3df15709794c6c05b0460a3592d8010ef00f --- /dev/null +++ b/jastadd-mquat-base/src/main/java/de/tudresden/inf/st/mquat/eris/coupling/ERISAccessPath.java @@ -0,0 +1,131 @@ +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; + } +} diff --git a/jastadd-mquat-base/src/main/java/de/tudresden/inf/st/mquat/eris/coupling/ERISBenchmarkResult.java b/jastadd-mquat-base/src/main/java/de/tudresden/inf/st/mquat/eris/coupling/ERISBenchmarkResult.java new file mode 100644 index 0000000000000000000000000000000000000000..d4a8478ca247127892b7a88d242d72681cc17f52 --- /dev/null +++ b/jastadd-mquat-base/src/main/java/de/tudresden/inf/st/mquat/eris/coupling/ERISBenchmarkResult.java @@ -0,0 +1,70 @@ +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; + } +} diff --git a/jastadd-mquat-base/src/main/java/de/tudresden/inf/st/mquat/eris/coupling/ERISLPConfiguration.java b/jastadd-mquat-base/src/main/java/de/tudresden/inf/st/mquat/eris/coupling/ERISLPConfiguration.java index 3e72da9f103b626f2da8f6a472c2f09019e0f620..57231628cc284cc38b6525e18ae479b617a4ddfb 100644 --- a/jastadd-mquat-base/src/main/java/de/tudresden/inf/st/mquat/eris/coupling/ERISLPConfiguration.java +++ b/jastadd-mquat-base/src/main/java/de/tudresden/inf/st/mquat/eris/coupling/ERISLPConfiguration.java @@ -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; + } } diff --git a/jastadd-mquat-base/src/main/java/de/tudresden/inf/st/mquat/eris/coupling/ERISReader.java b/jastadd-mquat-base/src/main/java/de/tudresden/inf/st/mquat/eris/coupling/ERISReader.java index 73c23ce27d143d569cea254c4dc6c2126a9c4844..d784b400e1c0046355c7fa29033f9be92aa4b1f8 100644 --- a/jastadd-mquat-base/src/main/java/de/tudresden/inf/st/mquat/eris/coupling/ERISReader.java +++ b/jastadd-mquat-base/src/main/java/de/tudresden/inf/st/mquat/eris/coupling/ERISReader.java @@ -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));