Skip to content

Commit

Permalink
Better measurement for the iQAS overhead, updating iQAS_out just befo…
Browse files Browse the repository at this point in the history
…re publishing to Kafka topic
  • Loading branch information
antoineauger committed Jul 11, 2017
1 parent 49f701c commit db3d9fb
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
13 changes: 13 additions & 0 deletions src/main/java/fr/isae/iqas/model/observation/Knowledge.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/fr/isae/iqas/model/observation/RawData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
23 changes: 12 additions & 11 deletions src/main/java/fr/isae/iqas/pipelines/OutputPipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ public Graph<FlowShape<ConsumerRecord<byte[], String>, ProducerRecord<byte[], St
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)) {
Expand All @@ -193,7 +191,10 @@ public Graph<FlowShape<ConsumerRecord<byte[], String>, ProducerRecord<byte[], St
);

final FlowShape<RawData, ProducerRecord> rawDataToProdRecord = builder.add(
Flow.of(RawData.class).map(r -> new ProducerRecord<byte[], String>(getTopicToPublish(), mapper.writeValueAsString(r)))
Flow.of(RawData.class).map(r -> {
r.addTimestamp("iQAS_out", System.currentTimeMillis());
return new ProducerRecord<byte[], String>(getTopicToPublish(), mapper.writeValueAsString(r));
})
);

builder.from(consumRecordToRawData.out())
Expand All @@ -218,9 +219,7 @@ public Graph<FlowShape<ConsumerRecord<byte[], String>, ProducerRecord<byte[], St
sensorDataObject.getString("date"),
sensorDataObject.getString("value"),
producer,
sensorDataObject.getString("timestamps"),
"iQAS_out",
System.currentTimeMillis());
sensorDataObject.getString("timestamps"));

if (getQooParams().size() > 0) {
if (interestAttr.contains(OBS_ACCURACY)) {
Expand Down Expand Up @@ -249,7 +248,10 @@ public Graph<FlowShape<ConsumerRecord<byte[], String>, ProducerRecord<byte[], St
);

final FlowShape<Information, ProducerRecord> infoToProdRecord = builder.add(
Flow.of(Information.class).map(r -> new ProducerRecord<byte[], String>(getTopicToPublish(), mapper.writeValueAsString(r)))
Flow.of(Information.class).map(r -> {
r.addTimestamp("iQAS_out", System.currentTimeMillis());
return new ProducerRecord<byte[], String>(getTopicToPublish(), mapper.writeValueAsString(r));
})
);

builder.from(consumRecordToInfo.out())
Expand All @@ -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)) {
Expand Down Expand Up @@ -320,6 +320,7 @@ else if (askedLevelFinal == KNOWLEDGE) {
}
}

knowledgeTemp.addTimestamp("iQAS_out", System.currentTimeMillis());
return new ProducerRecord<byte[], String>(getTopicToPublish(), knowledgeTemp.toString());
})
);
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/web/js/script_view_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,15 @@ $(function () {
}],
yAxes: [{
id: 'A',
label: 'freshness (ms)',
type: 'linear',
position: 'left',
ticks: {
beginAtZero: true
}
}, {
id: 'B',
label: 'accuracy (%)',
type: 'linear',
position: 'right',
ticks: {
Expand Down

0 comments on commit db3d9fb

Please sign in to comment.