Skip to content

Commit a8fbdfa

Browse files
authored
0.56.0
- Eliminate dependencies between specific link connections and DSSession. - Fix blasting of broker with empty messages. Better tracking whether ack required. - Add DSISession and DSITransport - in public api. - Eliminate dstranport dependencies (apis) that won't be used in non-blocking IO (future). - Fix msgpack bug. - Fix handshake with tokens. - Adds DSSession stats.
2 parents 658c1d4 + fbd11cf commit a8fbdfa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+985
-729
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ subprojects {
55
apply plugin: 'maven'
66

77
group 'org.iot-dsa'
8-
version '0.55.0'
8+
version '0.56.0'
99

1010
sourceCompatibility = 1.8
1111
targetCompatibility = 1.8

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/io/DSByteBuffer.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.acuity.iot.dsa.dslink.io;
22

3-
import com.acuity.iot.dsa.dslink.transport.DSTransport;
43
import java.io.InputStream;
54
import java.io.OutputStream;
65
import java.io.PrintStream;
@@ -559,15 +558,6 @@ public int sendTo(ByteBuffer buf) {
559558
return len;
560559
}
561560

562-
/**
563-
* Push bytes from the internal buffer to the transport.
564-
*/
565-
public void sendTo(DSTransport transport, boolean isLast) {
566-
transport.write(buffer, offset, length, isLast);
567-
offset = 0;
568-
length = 0;
569-
}
570-
571561
/**
572562
* Push bytes from the internal buffer to the given.
573563
*/

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/io/msgpack/MsgpackWriter.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.acuity.iot.dsa.dslink.io.msgpack;
22

33
import com.acuity.iot.dsa.dslink.io.DSByteBuffer;
4-
import com.acuity.iot.dsa.dslink.transport.DSTransport;
54
import java.io.IOException;
65
import java.io.OutputStream;
76
import java.nio.ByteBuffer;
@@ -83,10 +82,10 @@ public void writeTo(ByteBuffer out) {
8382

8483
/**
8584
* Writes the internal buffer to the parameter. The internal buffer will be cleared.
85+
public void writeTo(DSITransport out) {
86+
byteBuffer.sendTo(out, (frame == null));
87+
}
8688
*/
87-
public void writeTo(DSTransport out) {
88-
byteBuffer.sendTo(out, (frame == null));
89-
}
9089

9190
/**
9291
* Writes the internal buffer to the parameter. The internal buffer will be cleared.

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/protocol/DSBrokerConnection.java

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,45 @@
11
package com.acuity.iot.dsa.dslink.protocol;
22

3+
import org.iot.dsa.dslink.DSLinkConnection;
34
import org.iot.dsa.node.DSInfo;
45
import org.iot.dsa.node.DSString;
56
import org.iot.dsa.node.action.ActionInvocation;
67
import org.iot.dsa.node.action.ActionResult;
78
import org.iot.dsa.node.action.DSAction;
9+
import org.iot.dsa.util.DSException;
810

911
/**
1012
* Represents an upstream connection to a broker.
1113
*
1214
* @author Aaron Hansen
1315
*/
14-
public abstract class DSBrokerConnection extends DSTransportConnection {
16+
public abstract class DSBrokerConnection extends DSLinkConnection {
1517

1618
///////////////////////////////////////////////////////////////////////////
1719
// Class Fields
1820
///////////////////////////////////////////////////////////////////////////
1921

20-
protected static final String BROKER_URI = "Broker URI";
22+
23+
protected static final String BROKER_ID = "Broker ID";
24+
protected static final String BROKER_FORMAT = "Broker Format";
2125
protected static final String BROKER_PATH = "Path In Broker";
26+
protected static final String BROKER_PUB_KEY = "Broker Public Key";
27+
protected static final String BROKER_SALT = "Broker Salt";
28+
protected static final String BROKER_URI = "Broker URI";
29+
protected static final String BROKER_VERSION = "Broker Version";
2230
protected static final String RECONNECT = "Reconnect";
2331

2432
///////////////////////////////////////////////////////////////////////////
2533
// Instance Fields
2634
///////////////////////////////////////////////////////////////////////////
2735

36+
private DSInfo brokerDsId = getInfo(BROKER_ID);
37+
private DSInfo brokerFormat = getInfo(BROKER_FORMAT);
2838
private DSInfo brokerPath = getInfo(BROKER_PATH);
39+
private DSInfo brokerPubKey = getInfo(BROKER_PUB_KEY);
40+
private DSInfo brokerSalt = getInfo(BROKER_SALT);
41+
private DSInfo brokerUri = getInfo(BROKER_URI);
42+
private DSInfo brokerVersion = getInfo(BROKER_VERSION);
2943

3044
///////////////////////////////////////////////////////////////////////////
3145
// Public Methods
@@ -38,15 +52,27 @@ public String getPathInBroker() {
3852
return brokerPath.getElement().toString();
3953
}
4054

55+
/**
56+
* For the sessions to update
57+
*/
58+
public void setBrokerSalt(String arg) {
59+
put(brokerSalt, DSString.valueOf(arg));
60+
}
61+
4162
///////////////////////////////////////////////////////////////////////////
4263
// Protected Methods
4364
///////////////////////////////////////////////////////////////////////////
4465

4566
@Override
4667
protected void declareDefaults() {
4768
super.declareDefaults();
48-
declareDefault(BROKER_URI, DSString.NULL).setTransient(true).setReadOnly(true);
69+
declareDefault(BROKER_ID, DSString.NULL).setTransient(true).setReadOnly(true);
70+
declareDefault(BROKER_FORMAT, DSString.NULL).setTransient(true).setReadOnly(true);
4971
declareDefault(BROKER_PATH, DSString.NULL).setTransient(true).setReadOnly(true);
72+
declareDefault(BROKER_PUB_KEY, DSString.NULL).setTransient(true).setReadOnly(true);
73+
declareDefault(BROKER_SALT, DSString.NULL).setTransient(true).setReadOnly(true);
74+
declareDefault(BROKER_URI, DSString.NULL).setTransient(true).setReadOnly(true);
75+
declareDefault(BROKER_VERSION, DSString.NULL).setTransient(true).setReadOnly(true);
5076
declareDefault(RECONNECT, new DSAction.Parameterless() {
5177
@Override
5278
public ActionResult invoke(DSInfo target, ActionInvocation invocation) {
@@ -56,6 +82,43 @@ public ActionResult invoke(DSInfo target, ActionInvocation invocation) {
5682
});
5783
}
5884

85+
@Override
86+
protected void doConnect() {
87+
try {
88+
initializeConnection();
89+
getTransport().open();
90+
connOk();
91+
} catch (Exception x) {
92+
connDown(DSException.makeMessage(x));
93+
}
94+
}
95+
96+
protected String getBrokerFormat() {
97+
return brokerFormat.get().toString();
98+
}
99+
100+
protected String getBrokerId() {
101+
return brokerDsId.get().toString();
102+
}
103+
104+
protected String getBrokerKey() {
105+
return brokerPubKey.get().toString();
106+
}
107+
108+
protected String getBrokerSalt() {
109+
return brokerSalt.get().toString();
110+
}
111+
112+
protected String getBrokerUri() {
113+
return brokerUri.get().toString();
114+
}
115+
116+
protected String getBrokerVersion() {
117+
return brokerVersion.get().toString();
118+
}
119+
120+
protected abstract void initializeConnection();
121+
59122
/**
60123
* Creates and starts a thread for running the connection lifecycle.
61124
*/
@@ -67,6 +130,26 @@ protected void onStable() {
67130
t.start();
68131
}
69132

133+
protected void setBrokerFormat(String arg) {
134+
put(brokerFormat, DSString.valueOf(arg));
135+
}
136+
137+
protected void setBrokerId(String arg) {
138+
put(brokerDsId, DSString.valueOf(arg));
139+
}
140+
141+
protected void setBrokerKey(String arg) {
142+
put(brokerPubKey, DSString.valueOf(arg));
143+
}
144+
145+
protected void setBrokerUri(String arg) {
146+
put(brokerUri, DSString.valueOf(arg));
147+
}
148+
149+
protected void setBrokerVersion(String arg) {
150+
put(brokerVersion, DSString.valueOf(arg));
151+
}
152+
70153
protected void setPathInBroker(String path) {
71154
put(brokerPath, DSString.valueOf(path));
72155
}

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/protocol/DSRootLink.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import org.iot.dsa.util.DSUtil;
1313

1414
/**
15-
* Link implementation for standalone v1 and v2 links.
15+
* Links that also the root of the node tree. These links have sys and upstream children.
1616
*
1717
* @author Aaron Hansen
1818
*/
@@ -26,7 +26,6 @@ public class DSRootLink extends DSLink {
2626
// Instance Fields
2727
///////////////////////////////////////////////////////////////////////////
2828

29-
private DSKeys keys;
3029
private DSInfo main;
3130
private DSInfo sys = getInfo(SYS);
3231
private DSInfo upstream;
@@ -39,13 +38,6 @@ public class DSRootLink extends DSLink {
3938
// Public Methods
4039
///////////////////////////////////////////////////////////////////////////
4140

42-
/**
43-
* Public / private keys of the link, used to prove identity with brokers.
44-
*/
45-
public DSKeys getKeys() {
46-
return keys;
47-
}
48-
4941
@Override
5042
public DSMainNode getMain() {
5143
return (DSMainNode) main.getNode();
@@ -67,13 +59,13 @@ public DSLinkConnection getUpstream() {
6759
@Override
6860
protected void declareDefaults() {
6961
super.declareDefaults();
70-
declareDefault(SYS, new DSSysNode(), "Services common to all links.").setAdmin(true);
62+
declareDefault(SYS, new DSSysNode(),
63+
"Services common to all links in the process.").setAdmin(true);
7164
}
7265

7366
@Override
7467
protected DSLink init(DSLinkOptions config) {
7568
super.init(config);
76-
keys = config.getKeys();
7769
main = getInfo(MAIN);
7870
if (main == null) {
7971
String type = getOptions().getMainType();

0 commit comments

Comments
 (0)