Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions dslink-core/src/main/java/org/iot/dsa/dslink/DSLink.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public DSLink(DSLinkConfig config) throws Exception {
root = tmp;
saveDatabase();
}
if (root instanceof DSRequester) {
requester = (DSRequester) root;
}
add("Root", root).setTransient(true);
}

Expand Down Expand Up @@ -180,7 +183,7 @@ public void run() {
try {
info(info() ? "Stabilizing root node" : null);
stable();
long nextSave = System.currentTimeMillis() + DSTime.MILLIS_HOUR;
long nextSave = System.currentTimeMillis() + DSTime.MILLIS_MINUTE;
while (isRunning()) {
synchronized (this) {
try {
Expand All @@ -190,7 +193,7 @@ public void run() {
}
if (System.currentTimeMillis() > nextSave) {
saveDatabase();
nextSave = System.currentTimeMillis() + DSTime.MILLIS_HOUR;
nextSave = System.currentTimeMillis() + DSTime.MILLIS_MINUTE;
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion dslink-core/src/main/java/org/iot/dsa/io/NodeEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ void writeChildren(DSNode arg) {
try {
info = arg.getInfo(i);
obj = info.getObject();
if (info.isDefault()) { //includes actions
if (info.isTransient()) {
//skip it
} else if (info.isDefault()) { //includes actions
writeDefault(info);
} else if (obj == null) {
out.value((DSElement) null);
Expand Down
32 changes: 20 additions & 12 deletions dslink-core/src/main/java/org/iot/dsa/node/DSNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -647,18 +647,7 @@ public DSNode put(DSInfo info, DSIObject object) {
((DSNode) object).start();
}
info.subscribe();
try {
onChildChanged(info);
} catch (Exception x) {
severe(getPath(), x);
}
if (subscriber != null) {
try {
subscriber.onEvent(this, info, CHILD_CHANGED);
} catch (Exception x) {
severe(getPath(), x);
}
}
childChanged(info);
if (isStable()) {
if (object instanceof DSNode) {
((DSNode) object).stable();
Expand All @@ -667,6 +656,25 @@ public DSNode put(DSInfo info, DSIObject object) {
}
return this;
}

/**
* TEMPORARY
* Call this to indicate that a child has changed
*/
public void childChanged(DSInfo info) {
try {
onChildChanged(info);
} catch (Exception x) {
severe(getPath(), x);
}
if (subscriber != null) {
try {
subscriber.onEvent(this, info, CHILD_CHANGED);
} catch (Exception x) {
severe(getPath(), x);
}
}
}

/**
* Remove the child a the given index.
Expand Down