Commit d7be38d3cf81df2db81b02256e6fd4a383494202

Authored by Andrii Shvaika
2 parents 2a3f17a0 1b5ff691

Merge branch 'master' of github.com:thingsboard/thingsboard

... ... @@ -492,12 +492,14 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene
492 492 boolean hasData = false;
493 493 for (Object v : value) {
494 494 Object[] array = (Object[]) v;
495   - dataBuilder.addTs((long) array[0]);
  495 + TbSubscriptionUpdateTsValue.Builder tsValueBuilder = TbSubscriptionUpdateTsValue.newBuilder();
  496 + tsValueBuilder.setTs((long) array[0]);
496 497 String strVal = (String) array[1];
497 498 if (strVal != null) {
498 499 hasData = true;
499   - dataBuilder.addValue(strVal);
  500 + tsValueBuilder.setValue(strVal);
500 501 }
  502 + dataBuilder.addTsValue(tsValueBuilder.build());
501 503 }
502 504 if (!ignoreEmptyUpdates || hasData) {
503 505 builder.addData(dataBuilder.build());
... ...
... ... @@ -42,6 +42,7 @@ import org.thingsboard.server.gen.transport.TransportProtos.TbSubscriptionCloseP
42 42 import org.thingsboard.server.gen.transport.TransportProtos.TbSubscriptionKetStateProto;
43 43 import org.thingsboard.server.gen.transport.TransportProtos.TbSubscriptionProto;
44 44 import org.thingsboard.server.gen.transport.TransportProtos.TbSubscriptionUpdateProto;
  45 +import org.thingsboard.server.gen.transport.TransportProtos.TbSubscriptionUpdateTsValue;
45 46 import org.thingsboard.server.gen.transport.TransportProtos.TbTimeSeriesSubscriptionProto;
46 47 import org.thingsboard.server.gen.transport.TransportProtos.TbTimeSeriesUpdateProto;
47 48 import org.thingsboard.server.gen.transport.TransportProtos.ToCoreMsg;
... ... @@ -171,10 +172,11 @@ public class TbSubscriptionUtils {
171 172 Map<String, List<Object>> data = new TreeMap<>();
172 173 proto.getDataList().forEach(v -> {
173 174 List<Object> values = data.computeIfAbsent(v.getKey(), k -> new ArrayList<>());
174   - for (int i = 0; i < v.getTsCount(); i++) {
  175 + for (int i = 0; i < v.getTsValueCount(); i++) {
175 176 Object[] value = new Object[2];
176   - value[0] = v.getTs(i);
177   - value[1] = v.getValue(i);
  177 + TbSubscriptionUpdateTsValue tsValue = v.getTsValue(i);
  178 + value[0] = tsValue.getTs();
  179 + value[1] = tsValue.hasValue() ? tsValue.getValue() : null;
178 180 values.add(value);
179 181 }
180 182 });
... ...
... ... @@ -14,6 +14,7 @@
14 14 * limitations under the License.
15 15 */
16 16 syntax = "proto3";
  17 +
17 18 package transport;
18 19
19 20 option java_package = "org.thingsboard.server.gen.transport";
... ... @@ -581,8 +582,12 @@ message TbSubscriptionKetStateProto {
581 582
582 583 message TbSubscriptionUpdateValueListProto {
583 584 string key = 1;
584   - repeated int64 ts = 2;
585   - repeated string value = 3;
  585 + repeated TbSubscriptionUpdateTsValue tsValue = 2;
  586 +}
  587 +
  588 +message TbSubscriptionUpdateTsValue {
  589 + int64 ts = 1;
  590 + optional string value = 2;
586 591 }
587 592
588 593 /**
... ...
... ... @@ -17,7 +17,6 @@ package org.thingsboard.server.transport.lwm2m.server;
17 17
18 18 import lombok.RequiredArgsConstructor;
19 19 import lombok.extern.slf4j.Slf4j;
20   -import org.eclipse.californium.elements.util.SslContextUtil;
21 20 import org.eclipse.californium.scandium.config.DtlsConnectorConfig;
22 21 import org.eclipse.californium.scandium.dtls.cipher.CipherSuite;
23 22 import org.eclipse.leshan.core.node.codec.DefaultLwM2mNodeDecoder;
... ... @@ -29,6 +28,7 @@ import org.springframework.stereotype.Component;
29 28 import org.thingsboard.server.cache.ota.OtaPackageDataCache;
30 29 import org.thingsboard.server.common.data.DataConstants;
31 30 import org.thingsboard.server.common.transport.config.ssl.SslCredentials;
  31 +import org.thingsboard.server.queue.util.AfterStartUp;
32 32 import org.thingsboard.server.queue.util.TbLwM2mTransportComponent;
33 33 import org.thingsboard.server.transport.lwm2m.config.LwM2MTransportServerConfig;
34 34 import org.thingsboard.server.transport.lwm2m.secure.TbLwM2MAuthorizer;
... ... @@ -37,10 +37,7 @@ import org.thingsboard.server.transport.lwm2m.server.store.TbSecurityStore;
37 37 import org.thingsboard.server.transport.lwm2m.server.uplink.DefaultLwM2MUplinkMsgHandler;
38 38 import org.thingsboard.server.transport.lwm2m.utils.LwM2mValueConverterImpl;
39 39
40   -import javax.annotation.PostConstruct;
41 40 import javax.annotation.PreDestroy;
42   -import java.security.PrivateKey;
43   -import java.security.PublicKey;
44 41 import java.security.cert.X509Certificate;
45 42
46 43 import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256;
... ... @@ -71,7 +68,7 @@ public class DefaultLwM2mTransportService implements LwM2MTransportService {
71 68
72 69 private LeshanServer server;
73 70
74   - @PostConstruct
  71 + @AfterStartUp
75 72 public void init() {
76 73 this.server = getLhServer();
77 74 /*
... ...
... ... @@ -88,7 +88,7 @@ public class LwM2mClientContextImpl implements LwM2mClientContext {
88 88 private final Map<String, LwM2mClient> lwM2mClientsByRegistrationId = new ConcurrentHashMap<>();
89 89 private final Map<UUID, Lwm2mDeviceProfileTransportConfiguration> profiles = new ConcurrentHashMap<>();
90 90
91   - @AfterStartUp
  91 + @AfterStartUp(order = Integer.MAX_VALUE - 1)
92 92 public void init() {
93 93 String nodeId = context.getNodeId();
94 94 Set<LwM2mClient> fetchedClients = clientStore.getAll();
... ...
... ... @@ -87,6 +87,12 @@ public class DefaultLwM2MRpcRequestHandler implements LwM2MRpcRequestHandler {
87 87 return;
88 88 }
89 89 LwM2mClient client = clientContext.getClientBySessionInfo(sessionInfo);
  90 +
  91 + if (client == null) {
  92 + log.warn("Missing client for session: [{}]", sessionInfo);
  93 + return;
  94 + }
  95 +
90 96 if (client.getRegistration() == null) {
91 97 this.sendErrorRpcResponse(sessionInfo, rpcRequest.getRequestId(), ResponseCode.INTERNAL_SERVER_ERROR, "Registration is empty");
92 98 return;
... ...