Commit 7c1e8d44a04a496e6cc4ff84f61bf492a559b051

Authored by Igor Kulikov
2 parents ee8f7405 20318fff

Version set to 2.0.3

... ... @@ -20,7 +20,7 @@
20 20 <modelVersion>4.0.0</modelVersion>
21 21 <parent>
22 22 <groupId>org.thingsboard</groupId>
23   - <version>2.0.2</version>
  23 + <version>2.0.3</version>
24 24 <artifactId>thingsboard</artifactId>
25 25 </parent>
26 26 <artifactId>application</artifactId>
... ...
... ... @@ -15,6 +15,11 @@
15 15 #
16 16
17 17 export JAVA_OPTS="$JAVA_OPTS -Dplatform=@pkg.platform@ -Dinstall.data_dir=@pkg.installFolder@/data"
  18 +export JAVA_OPTS="$JAVA_OPTS -Xloggc:@pkg.logFolder@/gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDetails -XX:+PrintGCDateStamps"
  19 +export JAVA_OPTS="$JAVA_OPTS -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10"
  20 +export JAVA_OPTS="$JAVA_OPTS -XX:GCLogFileSize=10M -XX:-UseBiasedLocking -XX:+UseTLAB -XX:+ResizeTLAB -XX:+PerfDisableSharedMem -XX:+UseCondCardMark"
  21 +export JAVA_OPTS="$JAVA_OPTS -XX:CMSWaitDuration=10000 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+CMSParallelInitialMarkEnabled"
  22 +export JAVA_OPTS="$JAVA_OPTS -XX:+CMSEdenChunksRecordAlways -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly"
18 23 export LOG_FILENAME=${pkg.name}.out
19 24 export LOADER_PATH=${pkg.installFolder}/conf,${pkg.installFolder}/extensions
20 25 export SQL_DATA_FOLDER=${pkg.installFolder}/data/sql
... ...
... ... @@ -36,14 +36,17 @@ import org.springframework.web.bind.annotation.RequestParam;
36 36 import org.springframework.web.bind.annotation.ResponseBody;
37 37 import org.springframework.web.bind.annotation.RestController;
38 38 import org.springframework.web.context.request.async.DeferredResult;
  39 +import org.thingsboard.rule.engine.api.msg.DeviceAttributesEventNotificationMsg;
39 40 import org.thingsboard.server.common.data.DataConstants;
40 41 import org.thingsboard.server.common.data.EntityType;
41 42 import org.thingsboard.server.common.data.audit.ActionType;
42 43 import org.thingsboard.server.common.data.exception.ThingsboardException;
  44 +import org.thingsboard.server.common.data.id.DeviceId;
43 45 import org.thingsboard.server.common.data.id.EntityId;
44 46 import org.thingsboard.server.common.data.id.EntityIdFactory;
45 47 import org.thingsboard.server.common.data.id.UUIDBased;
46 48 import org.thingsboard.server.common.data.kv.Aggregation;
  49 +import org.thingsboard.server.common.data.kv.AttributeKey;
47 50 import org.thingsboard.server.common.data.kv.AttributeKvEntry;
48 51 import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry;
49 52 import org.thingsboard.server.common.data.kv.BaseTsKvQuery;
... ... @@ -55,6 +58,7 @@ import org.thingsboard.server.common.data.kv.LongDataEntry;
55 58 import org.thingsboard.server.common.data.kv.StringDataEntry;
56 59 import org.thingsboard.server.common.data.kv.TsKvEntry;
57 60 import org.thingsboard.server.common.data.kv.TsKvQuery;
  61 +import org.thingsboard.server.common.msg.cluster.SendToClusterMsg;
58 62 import org.thingsboard.server.common.msg.core.TelemetryUploadRequest;
59 63 import org.thingsboard.server.common.transport.adaptor.JsonConverter;
60 64 import org.thingsboard.server.dao.attributes.AttributesService;
... ... @@ -72,9 +76,12 @@ import javax.annotation.PostConstruct;
72 76 import javax.annotation.PreDestroy;
73 77 import java.util.ArrayList;
74 78 import java.util.Arrays;
  79 +import java.util.HashSet;
75 80 import java.util.LinkedHashMap;
76 81 import java.util.List;
77 82 import java.util.Map;
  83 +import java.util.Set;
  84 +import java.util.UUID;
78 85 import java.util.concurrent.ExecutorService;
79 86 import java.util.concurrent.Executors;
80 87 import java.util.stream.Collectors;
... ... @@ -276,6 +283,7 @@ public class TelemetryController extends BaseController {
276 283 return getImmediateDeferredResult("Empty keys: " + keysStr, HttpStatus.BAD_REQUEST);
277 284 }
278 285 SecurityUser user = getCurrentUser();
  286 +
279 287 if (DataConstants.SERVER_SCOPE.equals(scope) ||
280 288 DataConstants.SHARED_SCOPE.equals(scope) ||
281 289 DataConstants.CLIENT_SCOPE.equals(scope)) {
... ... @@ -285,6 +293,14 @@ public class TelemetryController extends BaseController {
285 293 @Override
286 294 public void onSuccess(@Nullable List<Void> tmp) {
287 295 logAttributesDeleted(user, entityId, scope, keys, null);
  296 + if (entityId.getEntityType() == EntityType.DEVICE) {
  297 + DeviceId deviceId = new DeviceId(entityId.getId());
  298 + Set<AttributeKey> keysToNotify = new HashSet<>();
  299 + keys.forEach(key -> keysToNotify.add(new AttributeKey(scope, key)));
  300 + DeviceAttributesEventNotificationMsg notificationMsg = DeviceAttributesEventNotificationMsg.onDelete(
  301 + user.getTenantId(), deviceId, keysToNotify);
  302 + actorService.onMsg(new SendToClusterMsg(deviceId, notificationMsg));
  303 + }
288 304 result.setResult(new ResponseEntity<>(HttpStatus.OK));
289 305 }
290 306
... ... @@ -315,6 +331,12 @@ public class TelemetryController extends BaseController {
315 331 @Override
316 332 public void onSuccess(@Nullable Void tmp) {
317 333 logAttributesUpdated(user, entityId, scope, attributes, null);
  334 + if (entityId.getEntityType() == EntityType.DEVICE) {
  335 + DeviceId deviceId = new DeviceId(entityId.getId());
  336 + DeviceAttributesEventNotificationMsg notificationMsg = DeviceAttributesEventNotificationMsg.onUpdate(
  337 + user.getTenantId(), deviceId, scope, attributes);
  338 + actorService.onMsg(new SendToClusterMsg(deviceId, notificationMsg));
  339 + }
318 340 result.setResult(new ResponseEntity(HttpStatus.OK));
319 341 }
320 342
... ... @@ -494,7 +516,7 @@ public class TelemetryController extends BaseController {
494 516
495 517 private void logAttributesDeleted(SecurityUser user, EntityId entityId, String scope, List<String> keys, Throwable e) {
496 518 try {
497   - logEntityAction(user, (UUIDBased & EntityId)entityId, null, null, ActionType.ATTRIBUTES_DELETED, toException(e),
  519 + logEntityAction(user, (UUIDBased & EntityId) entityId, null, null, ActionType.ATTRIBUTES_DELETED, toException(e),
498 520 scope, keys);
499 521 } catch (ThingsboardException te) {
500 522 log.warn("Failed to log attributes delete", te);
... ... @@ -503,7 +525,7 @@ public class TelemetryController extends BaseController {
503 525
504 526 private void logAttributesUpdated(SecurityUser user, EntityId entityId, String scope, List<AttributeKvEntry> attributes, Throwable e) {
505 527 try {
506   - logEntityAction(user, (UUIDBased & EntityId)entityId, null, null, ActionType.ATTRIBUTES_UPDATED, toException(e),
  528 + logEntityAction(user, (UUIDBased & EntityId) entityId, null, null, ActionType.ATTRIBUTES_UPDATED, toException(e),
507 529 scope, attributes);
508 530 } catch (ThingsboardException te) {
509 531 log.warn("Failed to log attributes update", te);
... ... @@ -513,7 +535,7 @@ public class TelemetryController extends BaseController {
513 535
514 536 private void logAttributesRead(SecurityUser user, EntityId entityId, String scope, List<String> keys, Throwable e) {
515 537 try {
516   - logEntityAction(user, (UUIDBased & EntityId)entityId, null, null, ActionType.ATTRIBUTES_READ, toException(e),
  538 + logEntityAction(user, (UUIDBased & EntityId) entityId, null, null, ActionType.ATTRIBUTES_READ, toException(e),
517 539 scope, keys);
518 540 } catch (ThingsboardException te) {
519 541 log.warn("Failed to log attributes read", te);
... ...
... ... @@ -60,7 +60,6 @@ import javax.annotation.PostConstruct;
60 60 import javax.annotation.PreDestroy;
61 61 import java.util.ArrayList;
62 62 import java.util.Collections;
63   -import java.util.HashMap;
64 63 import java.util.HashSet;
65 64 import java.util.Iterator;
66 65 import java.util.List;
... ... @@ -68,6 +67,7 @@ import java.util.Map;
68 67 import java.util.Optional;
69 68 import java.util.Set;
70 69 import java.util.TreeMap;
  70 +import java.util.concurrent.ConcurrentHashMap;
71 71 import java.util.concurrent.ExecutorService;
72 72 import java.util.concurrent.Executors;
73 73 import java.util.function.Consumer;
... ... @@ -120,8 +120,8 @@ public class DefaultTelemetrySubscriptionService implements TelemetrySubscriptio
120 120 }
121 121 }
122 122
123   - private final Map<EntityId, Set<Subscription>> subscriptionsByEntityId = new HashMap<>();
124   - private final Map<String, Map<Integer, Subscription>> subscriptionsByWsSessionId = new HashMap<>();
  123 + private final Map<EntityId, Set<Subscription>> subscriptionsByEntityId = new ConcurrentHashMap<>();
  124 + private final Map<String, Map<Integer, Subscription>> subscriptionsByWsSessionId = new ConcurrentHashMap<>();
125 125
126 126 @Override
127 127 public void addLocalWsSubscription(String sessionId, EntityId entityId, SubscriptionState sub) {
... ... @@ -453,9 +453,9 @@ public class DefaultTelemetrySubscriptionService implements TelemetrySubscriptio
453 453 }
454 454
455 455 private void registerSubscription(String sessionId, EntityId entityId, Subscription subscription) {
456   - Set<Subscription> deviceSubscriptions = subscriptionsByEntityId.computeIfAbsent(entityId, k -> new HashSet<>());
  456 + Set<Subscription> deviceSubscriptions = subscriptionsByEntityId.computeIfAbsent(entityId, k -> ConcurrentHashMap.newKeySet());
457 457 deviceSubscriptions.add(subscription);
458   - Map<Integer, Subscription> sessionSubscriptions = subscriptionsByWsSessionId.computeIfAbsent(sessionId, k -> new HashMap<>());
  458 + Map<Integer, Subscription> sessionSubscriptions = subscriptionsByWsSessionId.computeIfAbsent(sessionId, k -> new ConcurrentHashMap<>());
459 459 sessionSubscriptions.put(subscription.getSubscriptionId(), subscription);
460 460 }
461 461
... ...
... ... @@ -12,4 +12,30 @@
12 12 <startargument>-Dinstall.data_dir=%BASE%\data</startargument>
13 13 <startargument>-jar</startargument>
14 14 <startargument>%BASE%\lib\${pkg.name}.jar</startargument>
  15 + <startargument>-Xloggc:%BASE%\logs\gc.log</startargument>
  16 + <startargument>-XX:+HeapDumpOnOutOfMemoryError</startargument>
  17 + <startargument>-XX:+PrintGCDetails</startargument>
  18 + <startargument>-XX:+PrintGCDateStamps</startargument>
  19 + <startargument>-XX:+PrintHeapAtGC</startargument>
  20 + <startargument>-XX:+PrintTenuringDistribution</startargument>
  21 + <startargument>-XX:+PrintGCApplicationStoppedTime</startargument>
  22 + <startargument>-XX:+UseGCLogFileRotation</startargument>
  23 + <startargument>-XX:NumberOfGCLogFiles=10</startargument>
  24 + <startargument>-XX:GCLogFileSize=10M</startargument>
  25 + <startargument>-XX:-UseBiasedLocking</startargument>
  26 + <startargument>-XX:+UseTLAB</startargument>
  27 + <startargument>-XX:+ResizeTLAB</startargument>
  28 + <startargument>-XX:+PerfDisableSharedMem</startargument>
  29 + <startargument>-XX:+UseCondCardMark</startargument>
  30 + <startargument>-XX:CMSWaitDuration=10000</startargument>
  31 + <startargument>-XX:+UseParNewGC</startargument>
  32 + <startargument>-XX:+UseConcMarkSweepGC</startargument>
  33 + <startargument>-XX:+CMSParallelRemarkEnabled</startargument>
  34 + <startargument>-XX:+CMSParallelInitialMarkEnabled</startargument>
  35 + <startargument>-XX:+CMSEdenChunksRecordAlways</startargument>
  36 + <startargument>-XX:CMSInitiatingOccupancyFraction=75</startargument>
  37 + <startargument>-XX:+UseCMSInitiatingOccupancyOnly</startargument>
  38 + <startargument>-Xms512m</startargument>
  39 + <startargument>-Xmx1024m</startargument>
  40 +
15 41 </service>
... ...
... ... @@ -20,7 +20,7 @@
20 20 <modelVersion>4.0.0</modelVersion>
21 21 <parent>
22 22 <groupId>org.thingsboard</groupId>
23   - <version>2.0.2</version>
  23 + <version>2.0.3</version>
24 24 <artifactId>common</artifactId>
25 25 </parent>
26 26 <groupId>org.thingsboard.common</groupId>
... ...
... ... @@ -20,7 +20,7 @@
20 20 <modelVersion>4.0.0</modelVersion>
21 21 <parent>
22 22 <groupId>org.thingsboard</groupId>
23   - <version>2.0.2</version>
  23 + <version>2.0.3</version>
24 24 <artifactId>common</artifactId>
25 25 </parent>
26 26 <groupId>org.thingsboard.common</groupId>
... ...
... ... @@ -20,7 +20,7 @@
20 20 <modelVersion>4.0.0</modelVersion>
21 21 <parent>
22 22 <groupId>org.thingsboard</groupId>
23   - <version>2.0.2</version>
  23 + <version>2.0.3</version>
24 24 <artifactId>thingsboard</artifactId>
25 25 </parent>
26 26 <groupId>org.thingsboard</groupId>
... ...
... ... @@ -20,7 +20,7 @@
20 20 <modelVersion>4.0.0</modelVersion>
21 21 <parent>
22 22 <groupId>org.thingsboard</groupId>
23   - <version>2.0.2</version>
  23 + <version>2.0.3</version>
24 24 <artifactId>common</artifactId>
25 25 </parent>
26 26 <groupId>org.thingsboard.common</groupId>
... ...
... ... @@ -20,7 +20,7 @@
20 20 <modelVersion>4.0.0</modelVersion>
21 21 <parent>
22 22 <groupId>org.thingsboard</groupId>
23   - <version>2.0.2</version>
  23 + <version>2.0.3</version>
24 24 <artifactId>thingsboard</artifactId>
25 25 </parent>
26 26 <artifactId>dao</artifactId>
... ...
1   -VERSION=2.0.2
  1 +VERSION=2.0.3
2 2 PROJECT=thingsboard
3 3 APP=cassandra-setup
4 4
... ...
1   -VERSION=2.0.2
  1 +VERSION=2.0.3
2 2 PROJECT=thingsboard
3 3 APP=cassandra
4 4
... ...
... ... @@ -18,7 +18,7 @@ version: '2'
18 18
19 19 services:
20 20 tb:
21   - image: "thingsboard/application:2.0.2"
  21 + image: "thingsboard/application:2.0.3"
22 22 ports:
23 23 - "8080:8080"
24 24 - "1883:1883"
... ...
... ... @@ -22,7 +22,7 @@ spec:
22 22 containers:
23 23 - name: cassandra-setup
24 24 imagePullPolicy: Always
25   - image: thingsboard/cassandra-setup:2.0.2
  25 + image: thingsboard/cassandra-setup:2.0.3
26 26 env:
27 27 - name: ADD_DEMO_DATA
28 28 value: "true"
... ...
... ... @@ -54,7 +54,7 @@ spec:
54 54 topologyKey: "kubernetes.io/hostname"
55 55 containers:
56 56 - name: cassandra
57   - image: thingsboard/cassandra:2.0.2
  57 + image: thingsboard/cassandra:2.0.3
58 58 imagePullPolicy: Always
59 59 ports:
60 60 - containerPort: 7000
... ...
... ... @@ -84,7 +84,7 @@ spec:
84 84 containers:
85 85 - name: tb
86 86 imagePullPolicy: Always
87   - image: thingsboard/application:2.0.2
  87 + image: thingsboard/application:2.0.3
88 88 ports:
89 89 - containerPort: 8080
90 90 name: ui
... ...
... ... @@ -87,7 +87,7 @@ spec:
87 87 containers:
88 88 - name: zk
89 89 imagePullPolicy: Always
90   - image: thingsboard/zk:2.0.2
  90 + image: thingsboard/zk:2.0.3
91 91 ports:
92 92 - containerPort: 2181
93 93 name: client
... ...
1   -VERSION=2.0.2
  1 +VERSION=2.0.3
2 2 PROJECT=thingsboard
3 3 APP=application
4 4
... ...
1   -VERSION=2.0.2
  1 +VERSION=2.0.3
2 2 PROJECT=thingsboard
3 3 APP=zk
4 4
... ...
... ... @@ -19,12 +19,12 @@
19 19 <modelVersion>4.0.0</modelVersion>
20 20 <parent>
21 21 <groupId>org.thingsboard</groupId>
22   - <version>2.0.2</version>
  22 + <version>2.0.3</version>
23 23 <artifactId>thingsboard</artifactId>
24 24 </parent>
25 25 <groupId>org.thingsboard</groupId>
26 26 <artifactId>netty-mqtt</artifactId>
27   - <version>2.0.2</version>
  27 + <version>2.0.3</version>
28 28 <packaging>jar</packaging>
29 29
30 30 <name>Netty MQTT Client</name>
... ...
... ... @@ -20,7 +20,7 @@
20 20 <modelVersion>4.0.0</modelVersion>
21 21 <groupId>org.thingsboard</groupId>
22 22 <artifactId>thingsboard</artifactId>
23   - <version>2.0.2</version>
  23 + <version>2.0.3</version>
24 24 <packaging>pom</packaging>
25 25
26 26 <name>Thingsboard</name>
... ...
... ... @@ -20,7 +20,7 @@
20 20 <modelVersion>4.0.0</modelVersion>
21 21 <parent>
22 22 <groupId>org.thingsboard</groupId>
23   - <version>2.0.2</version>
  23 + <version>2.0.3</version>
24 24 <artifactId>thingsboard</artifactId>
25 25 </parent>
26 26 <artifactId>rule-engine</artifactId>
... ...
... ... @@ -22,7 +22,7 @@
22 22 <modelVersion>4.0.0</modelVersion>
23 23 <parent>
24 24 <groupId>org.thingsboard</groupId>
25   - <version>2.0.2</version>
  25 + <version>2.0.3</version>
26 26 <artifactId>rule-engine</artifactId>
27 27 </parent>
28 28 <groupId>org.thingsboard.rule-engine</groupId>
... ...
... ... @@ -22,7 +22,7 @@
22 22 <modelVersion>4.0.0</modelVersion>
23 23 <parent>
24 24 <groupId>org.thingsboard</groupId>
25   - <version>2.0.2</version>
  25 + <version>2.0.3</version>
26 26 <artifactId>rule-engine</artifactId>
27 27 </parent>
28 28 <groupId>org.thingsboard.rule-engine</groupId>
... ...
... ... @@ -20,7 +20,7 @@
20 20 <modelVersion>4.0.0</modelVersion>
21 21 <parent>
22 22 <groupId>org.thingsboard</groupId>
23   - <version>2.0.2</version>
  23 + <version>2.0.3</version>
24 24 <artifactId>thingsboard</artifactId>
25 25 </parent>
26 26 <groupId>org.thingsboard</groupId>
... ...
... ... @@ -20,7 +20,7 @@
20 20 <modelVersion>4.0.0</modelVersion>
21 21 <parent>
22 22 <groupId>org.thingsboard</groupId>
23   - <version>2.0.2</version>
  23 + <version>2.0.3</version>
24 24 <artifactId>transport</artifactId>
25 25 </parent>
26 26 <groupId>org.thingsboard.transport</groupId>
... ...
... ... @@ -20,7 +20,7 @@
20 20 <modelVersion>4.0.0</modelVersion>
21 21 <parent>
22 22 <groupId>org.thingsboard</groupId>
23   - <version>2.0.2</version>
  23 + <version>2.0.3</version>
24 24 <artifactId>transport</artifactId>
25 25 </parent>
26 26 <groupId>org.thingsboard.transport</groupId>
... ...
... ... @@ -20,7 +20,7 @@
20 20 <modelVersion>4.0.0</modelVersion>
21 21 <parent>
22 22 <groupId>org.thingsboard</groupId>
23   - <version>2.0.2</version>
  23 + <version>2.0.3</version>
24 24 <artifactId>transport</artifactId>
25 25 </parent>
26 26 <groupId>org.thingsboard.transport</groupId>
... ...
... ... @@ -86,7 +86,7 @@ public class GatewayDeviceSessionCtx extends DeviceAwareSessionContext {
86 86 if (responseMsg.isSuccess()) {
87 87 SessionMsgType requestMsgType = responseMsg.getRequestMsgType();
88 88 Integer requestId = responseMsg.getRequestId();
89   - if (requestId >= 0 && requestMsgType == SessionMsgType.POST_ATTRIBUTES_REQUEST || requestMsgType == SessionMsgType.POST_TELEMETRY_REQUEST) {
  89 + if (requestId >= 0 && (requestMsgType == SessionMsgType.POST_ATTRIBUTES_REQUEST || requestMsgType == SessionMsgType.POST_TELEMETRY_REQUEST)) {
90 90 return Optional.of(MqttTransportHandler.createMqttPubAckMsg(requestId));
91 91 }
92 92 }
... ...
... ... @@ -90,6 +90,7 @@ public class GatewaySessionCtx {
90 90 device.setTenantId(gateway.getTenantId());
91 91 device.setName(deviceName);
92 92 device.setType(deviceType);
  93 + device.setCustomerId(gateway.getCustomerId());
93 94 device = deviceService.saveDevice(device);
94 95 relationService.saveRelationAsync(new EntityRelation(gateway.getId(), device.getId(), "Created"));
95 96 processor.onDeviceAdded(device);
... ...
... ... @@ -20,7 +20,7 @@
20 20 <modelVersion>4.0.0</modelVersion>
21 21 <parent>
22 22 <groupId>org.thingsboard</groupId>
23   - <version>2.0.2</version>
  23 + <version>2.0.3</version>
24 24 <artifactId>thingsboard</artifactId>
25 25 </parent>
26 26 <groupId>org.thingsboard</groupId>
... ...
1 1 {
2 2 "name": "thingsboard",
3 3 "private": true,
4   - "version": "2.0.2",
  4 + "version": "2.0.3",
5 5 "description": "Thingsboard UI",
6 6 "licenses": [
7 7 {
... ...
... ... @@ -20,7 +20,7 @@
20 20 <modelVersion>4.0.0</modelVersion>
21 21 <parent>
22 22 <groupId>org.thingsboard</groupId>
23   - <version>2.0.2</version>
  23 + <version>2.0.3</version>
24 24 <artifactId>thingsboard</artifactId>
25 25 </parent>
26 26 <groupId>org.thingsboard</groupId>
... ...