Skip to content

Commit

Permalink
0.23.0
Browse files Browse the repository at this point in the history
* Fix updating subscription value for multiple requester subscriptions to the same path.
* Fix updating list requests for previously non-existing nodes.
* Update Jackson dependencies.
* Fix configuration NPE for programmatically created links.
* Add jzlib dependency.
  • Loading branch information
a-hansen authored Oct 16, 2019
1 parent 6aa92a9 commit 9414a9f
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 39 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ subprojects {
apply plugin: 'java-library'
apply plugin: 'maven'

version = '0.22.3'
version = '0.23.0'
sourceCompatibility = 1.7
targetCompatibility = 1.7

Expand All @@ -30,6 +30,6 @@ subprojects {
}

wrapper {
gradleVersion = '5.6'
gradleVersion = '5.6.2'
}

12 changes: 7 additions & 5 deletions internal/runtime_shared/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ apply from: '../../bintray.gradle'
description = 'Shared Runtime for the SDK'

dependencies {
api 'org.bouncycastle:bcprov-jdk15on:1.62'
api 'io.netty:netty-all:4.1.38.Final'
api 'org.bouncycastle:bcprov-jdk15on:1.64'
api 'io.netty:netty-all:4.1.42.Final'
//jzlib is an optional dependency of netty, it is possible to trigger usage
implementation 'com.jcraft:jzlib:1.1.3'
api 'com.beust:jcommander:1.72'
api 'org.msgpack:jackson-dataformat-msgpack:0.8.17'
api 'org.msgpack:jackson-dataformat-msgpack:0.8.18'
//the following overrides the dependency in jackson-dataformat-msgpack
//and can be removed once msgpack catches up to 2.9.9.3
api 'com.fasterxml.jackson.core:jackson-databind:2.9.9.3'
//and can be removed once msgpack catches up to 2.9.10
api 'com.fasterxml.jackson.core:jackson-databind:2.9.10'
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ public URLInfo getAuthEndpoint() {
* Get a config from the dslink.json file.
*/
public <T> T getConfig(String field, T defaultVal) {
if (configs == null) {
return defaultVal;
}
JsonObject param = configs.get(field);
if (param == null) {
return defaultVal;
Expand Down
65 changes: 36 additions & 29 deletions sdk/dslink/src/main/java/org/dsa/iot/dslink/link/Requester.java
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ private void sendRequest(RequestWrapper wrapper,
private static class HandlerAdapter implements Handler<SubscriptionValue> {

Sub first;
SubscriptionValue lastEvent;
ConcurrentLinkedQueue<Sub> list = null;
int qos = 0;
int size;
Expand All @@ -596,42 +597,48 @@ public void handle(SubscriptionValue event) {
for (Sub s : list) {
s.handle(event);
}
lastEvent = event;
}

synchronized void add(SubData data, Handler<SubscriptionValue> handler) {
Integer q = data.getQos();
if (q == null) {
q = 0;
}
if (q > qos) {
this.qos = q;
}
if (first != null) {
if (first.isSameHandler(handler)) {
if (first.isQosChange(q)) {
qos = q;
void add(SubData data, Handler<SubscriptionValue> handler) {
Sub sub = null;
synchronized (this) {
Integer q = data.getQos();
if (q == null) {
q = 0;
}
if (q > qos) {
this.qos = q;
}
if (first != null) {
if (first.isSameHandler(handler)) {
if (first.isQosChange(q)) {
qos = q;
}
return;
}
return;
}
}
if (list == null) {
list = new ConcurrentLinkedQueue<>();
list.add(first);
first = null;
list.add(new Sub(handler, q));
size++;
return;
}
for (Sub sub : list) {
if (sub.isSameHandler(handler)) {
if (sub.isQosChange(q)) {
updateQos();
if (list == null) {
list = new ConcurrentLinkedQueue<>();
list.add(first);
first = null;
} else {
for (Sub tmp : list) {
if (tmp.isSameHandler(handler)) {
if (tmp.isQosChange(q)) {
updateQos();
}
return;
}
}
return;
}
size++;
sub = new Sub(handler, q);
list.add(sub);
}
if (lastEvent != null) {
sub.handle(lastEvent);
}
size++;
list.add(new Sub(handler, q));
}

int qos() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ public class ListResponse extends Response {

private final DSLink link;
private final SubscriptionManager manager;
private final int rid;
private final Node node;
private Node node;
private final String path;

private final int rid;
private final Map<Node, Boolean> updates = new HashMap<>();

public ListResponse(DSLink link, SubscriptionManager manager,
Expand Down Expand Up @@ -277,6 +276,11 @@ public void multiChildrenUpdate(List<Node> children) {
link.getWriter().writeResponse(resp);
}

public void nodeCreated(Node node) {
this.node = node;
link.getWriter().writeResponse(getJsonResponse(null));
}

@Override
public void populate(JsonObject in) {
JsonArray updates = in.get("updates");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ public void postChildUpdate(Node child, boolean removed) {
if (resp != null) {
resp.childUpdate(child, removed);
}
if (!removed) {
resp = pathSubsMap.get(child.getPath());
if (resp != null) {
resp.nodeCreated(child);
}
}
}

/**
Expand Down

0 comments on commit 9414a9f

Please sign in to comment.