From db3d9fbf74cd4f475f9fbef4b2af0173eddd6ca2 Mon Sep 17 00:00:00 2001 From: Antoine Auger Date: Tue, 11 Jul 2017 17:10:02 +0200 Subject: [PATCH] Better measurement for the iQAS overhead, updating iQAS_out just before publishing to Kafka topic --- .../iqas/model/observation/Knowledge.java | 13 +++++++++++ .../isae/iqas/model/observation/RawData.java | 6 ++--- .../isae/iqas/pipelines/OutputPipeline.java | 23 ++++++++++--------- .../resources/web/js/script_view_request.js | 2 ++ 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/main/java/fr/isae/iqas/model/observation/Knowledge.java b/src/main/java/fr/isae/iqas/model/observation/Knowledge.java index df78247f..69f619a1 100644 --- a/src/main/java/fr/isae/iqas/model/observation/Knowledge.java +++ b/src/main/java/fr/isae/iqas/model/observation/Knowledge.java @@ -96,6 +96,19 @@ public String toString() { } } + @Override + public void addTimestamp(String stepName, long timestamp) { + Individual obsValueInd = obsModel.getIndividual( pref.get("qoo") + "obsValue"); + String previousValue = obsValueInd.getProperty(qooP.get("qoo:obsTimestampsValue")).getString(); + if (previousValue.equals("")) { + previousValue = previousValue.concat(stepName + ":" + String.valueOf(timestamp)); + } + else { + previousValue = previousValue.concat(";" + stepName + ":" + String.valueOf(timestamp)); + } + obsValueInd.setPropertyValue(qooP.get("qoo:obsTimestampsValue"), obsModel.createLiteral(previousValue)); + } + /** * Getters and setters for a specific QoO attribute */ diff --git a/src/main/java/fr/isae/iqas/model/observation/RawData.java b/src/main/java/fr/isae/iqas/model/observation/RawData.java index 61a23254..605809e6 100644 --- a/src/main/java/fr/isae/iqas/model/observation/RawData.java +++ b/src/main/java/fr/isae/iqas/model/observation/RawData.java @@ -103,12 +103,12 @@ public String getTimestamps() { return timestamps; } - public void addTimestamp(String stepName, String timestampString) { + public void addTimestamp(String stepName, long timestamp) { if (this.timestamps.equals("")) { - this.timestamps = this.timestamps.concat(stepName + ":" + timestampString); + this.timestamps = this.timestamps.concat(stepName + ":" + String.valueOf(timestamp)); } else { - this.timestamps = this.timestamps.concat(";" + stepName + ":" + timestampString); + this.timestamps = this.timestamps.concat(";" + stepName + ":" + String.valueOf(timestamp)); } } diff --git a/src/main/java/fr/isae/iqas/pipelines/OutputPipeline.java b/src/main/java/fr/isae/iqas/pipelines/OutputPipeline.java index 00530acc..0fe1493f 100644 --- a/src/main/java/fr/isae/iqas/pipelines/OutputPipeline.java +++ b/src/main/java/fr/isae/iqas/pipelines/OutputPipeline.java @@ -166,9 +166,7 @@ public Graph, ProducerRecord 0) { if (interestAttr.contains(OBS_ACCURACY)) { @@ -193,7 +191,10 @@ public Graph, ProducerRecord rawDataToProdRecord = builder.add( - Flow.of(RawData.class).map(r -> new ProducerRecord(getTopicToPublish(), mapper.writeValueAsString(r))) + Flow.of(RawData.class).map(r -> { + r.addTimestamp("iQAS_out", System.currentTimeMillis()); + return new ProducerRecord(getTopicToPublish(), mapper.writeValueAsString(r)); + }) ); builder.from(consumRecordToRawData.out()) @@ -218,9 +219,7 @@ public Graph, ProducerRecord 0) { if (interestAttr.contains(OBS_ACCURACY)) { @@ -249,7 +248,10 @@ public Graph, ProducerRecord infoToProdRecord = builder.add( - Flow.of(Information.class).map(r -> new ProducerRecord(getTopicToPublish(), mapper.writeValueAsString(r))) + Flow.of(Information.class).map(r -> { + r.addTimestamp("iQAS_out", System.currentTimeMillis()); + return new ProducerRecord(getTopicToPublish(), mapper.writeValueAsString(r)); + }) ); builder.from(consumRecordToInfo.out()) @@ -274,9 +276,7 @@ else if (askedLevelFinal == KNOWLEDGE) { sensorDataObject.getString("date"), sensorDataObject.getString("value"), sensorDataObject.getString("producer"), - sensorDataObject.getString("timestamps"), - "iQAS_out", - System.currentTimeMillis()); + sensorDataObject.getString("timestamps")); if (getQooParams().size() > 0) { if (interestAttr.contains(OBS_ACCURACY)) { @@ -320,6 +320,7 @@ else if (askedLevelFinal == KNOWLEDGE) { } } + knowledgeTemp.addTimestamp("iQAS_out", System.currentTimeMillis()); return new ProducerRecord(getTopicToPublish(), knowledgeTemp.toString()); }) ); diff --git a/src/main/resources/web/js/script_view_request.js b/src/main/resources/web/js/script_view_request.js index 95ca6fa3..e54a4c0c 100644 --- a/src/main/resources/web/js/script_view_request.js +++ b/src/main/resources/web/js/script_view_request.js @@ -246,6 +246,7 @@ $(function () { }], yAxes: [{ id: 'A', + label: 'freshness (ms)', type: 'linear', position: 'left', ticks: { @@ -253,6 +254,7 @@ $(function () { } }, { id: 'B', + label: 'accuracy (%)', type: 'linear', position: 'right', ticks: {