Commit e99951f1 authored by nseydoux's avatar nseydoux
Browse files

Adapted the annoucement mechanism to edr dedicated properties

parent 29fa6368
......@@ -42,7 +42,7 @@ public class TopologyEndPoint {
public Response present(){
return Response
.status(HttpURLConnection.HTTP_OK)
.entity(Node.getInstance().getKBManager().getAnnouncement())
.entity(Node.getInstance().getKBManager().getAnnouncement(true))
.build();
}
......@@ -97,7 +97,7 @@ public class TopologyEndPoint {
Node.getInstance().addDownstreamNode(profile);
LOGGER.trace("Announced content added to "+Node.getInstance().getName()+" KB");
}
Model annouce = Node.getInstance().getKBManager().getAnnounceModel();
Model annouce = Node.getInstance().getKBManager().getAnnounceModel(false);
if(annouce != null){
LOGGER.debug("Responding to annouce from "+remote);
StringWriter sw = new StringWriter();
......
......@@ -186,21 +186,26 @@ public class KBManager {
return sw.toString();
}
public synchronized String getAnnouncement(){
/**
*
* @param parent if true, the annouce is for a parent, else it is for a child
* @return
*/
public synchronized String getAnnouncement(Boolean parent){
Model m = this.getAnnounceModel(parent);
Map<String, String> subs = new HashMap<String, String>();
subs.put("id", Node.getInstance().getName());
try {
Model annoucementGraph = this.constructModel(this.queries.getTemplateQueries().get("get_description").substitute(subs));
StringWriter sw = new StringWriter();
annoucementGraph.write(sw, "TTL");
return sw.toString();
} catch (IncompleteSubstitutionException e) {
e.printStackTrace();
}
return null;
StringWriter sw = new StringWriter();
m.write(sw, "TTL");
return sw.toString();
}
public synchronized Model getAnnounceModel(){
/**
*
* @param parent if true, the annouce is for a parent, else it is for a child
* @return
*/
public synchronized Model getAnnounceModel(Boolean parent){
Map<String, String> subs = new HashMap<String, String>();
subs.put("id", Node.getInstance().getName());
try {
......
......@@ -227,7 +227,7 @@ public class Node {
}
public void announce(){
String announcement = this.kb.getAnnouncement();
String announcement = this.kb.getAnnouncement(true);
LOGGER.debug("Announcement : "+announcement);
if(announcement != null){
LOGGER.debug("Announcing to "+this.config.getRemotes().size()+" remotes");
......@@ -427,8 +427,6 @@ public class Node {
}
}
public void processUpstreamMessage(Model message){
this.getKBManager().addToModel(message);
this.im.propagateInterests();
......
{
"name": "simple-building",
"centralized": "adp",
"common_knowledge":[],
"common_knowledge":["http://w3id.org/laas-iot/edr"],
"layers": {
"type": "building",
"count": 1,
......
{"id": 2, "remotes": ["http://localhost:6001"], "local": "false", "tbox": [], "port": 6002, "centralized": false, "host": "http://localhost", "name": "room0002", "reasoning": true, "queries": "queries/devices", "sensors": [{"endpoint": "http://localhost:9003", "produces": "temperature"}, {"endpoint": "http://localhost:9004", "produces": "luminosity"}], "feature": "room0002feature"}
\ No newline at end of file
{
"id": 2,
"remotes": [
"http://localhost:6001"
],
"local": "false",
"tbox": [],
"port": 6002,
"centralized": false,
"host": "http://localhost",
"name": "room0002",
"reasoning": true,
"queries": "queries/devices",
"sensors": [
{
"endpoint": "http://localhost:9003",
"produces": "temperature"
},
{
"endpoint": "http://localhost:9004",
"produces": "luminosity"
}
],
"feature": "room0002feature"
}
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