From 8b637c9e9456963e1e24ec0e6306903d2e765c1f Mon Sep 17 00:00:00 2001 From: vparomskiy Date: Fri, 23 Mar 2018 16:54:48 +0200 Subject: [PATCH 01/11] add cassandra properties in test suite --- .../server/actors/plugin/PluginActorMessageProcessor.java | 1 + application/src/main/resources/thingsboard.yml | 4 ++-- .../quota/inmemory/HostRequestIntervalRegistry.java | 5 +++-- .../server/dao/timeseries/CassandraBaseTimeseriesDao.java | 3 --- .../thingsboard/server/dao/util/BufferedRateLimiter.java | 8 ++++++-- dao/src/test/resources/cassandra-test.properties | 5 +++++ 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/actors/plugin/PluginActorMessageProcessor.java b/application/src/main/java/org/thingsboard/server/actors/plugin/PluginActorMessageProcessor.java index 7dfe9a5d81..2af30d4b49 100644 --- a/application/src/main/java/org/thingsboard/server/actors/plugin/PluginActorMessageProcessor.java +++ b/application/src/main/java/org/thingsboard/server/actors/plugin/PluginActorMessageProcessor.java @@ -106,6 +106,7 @@ public class PluginActorMessageProcessor extends ComponentMsgProcessor try { pluginImpl.process(trustedCtx, msg.getRuleTenantId(), msg.getRuleId(), msg.getMsg()); } catch (Exception ex) { + logger.debug("[{}] Failed to process RuleToPlugin msg: [{}] [{}]", tenantId, msg.getMsg(), ex); RuleToPluginMsg ruleMsg = msg.getMsg(); MsgType responceMsgType = MsgType.RULE_ENGINE_ERROR; Integer requestId = 0; diff --git a/application/src/main/resources/thingsboard.yml b/application/src/main/resources/thingsboard.yml index 07face1059..c47fc28fbd 100644 --- a/application/src/main/resources/thingsboard.yml +++ b/application/src/main/resources/thingsboard.yml @@ -133,7 +133,7 @@ quota: intervalMin: 2 database: - type: "${DATABASE_TYPE:cassandra}" # cassandra OR sql + type: "${DATABASE_TYPE:sql}" # cassandra OR sql # Cassandra driver configuration parameters cassandra: @@ -226,7 +226,7 @@ caffeine: specs: relations: timeToLiveInMinutes: 1440 - maxSize: 0 + maxSize: 100000 deviceCredentials: timeToLiveInMinutes: 1440 maxSize: 100000 diff --git a/common/transport/src/main/java/org/thingsboard/server/common/transport/quota/inmemory/HostRequestIntervalRegistry.java b/common/transport/src/main/java/org/thingsboard/server/common/transport/quota/inmemory/HostRequestIntervalRegistry.java index 8d254a08c6..3782ed22ed 100644 --- a/common/transport/src/main/java/org/thingsboard/server/common/transport/quota/inmemory/HostRequestIntervalRegistry.java +++ b/common/transport/src/main/java/org/thingsboard/server/common/transport/quota/inmemory/HostRequestIntervalRegistry.java @@ -61,13 +61,14 @@ public class HostRequestIntervalRegistry { } public long tick(String clientHostId) { + IntervalCount intervalCount = hostCounts.computeIfAbsent(clientHostId, s -> new IntervalCount(intervalDurationMs)); + long currentCount = intervalCount.resetIfExpiredAndTick(); if (whiteList.contains(clientHostId)) { return 0; } else if (blackList.contains(clientHostId)) { return Long.MAX_VALUE; } - IntervalCount intervalCount = hostCounts.computeIfAbsent(clientHostId, s -> new IntervalCount(intervalDurationMs)); - return intervalCount.resetIfExpiredAndTick(); + return currentCount; } public void clean() { diff --git a/dao/src/main/java/org/thingsboard/server/dao/timeseries/CassandraBaseTimeseriesDao.java b/dao/src/main/java/org/thingsboard/server/dao/timeseries/CassandraBaseTimeseriesDao.java index cf141711a5..cda4b1669b 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/timeseries/CassandraBaseTimeseriesDao.java +++ b/dao/src/main/java/org/thingsboard/server/dao/timeseries/CassandraBaseTimeseriesDao.java @@ -439,8 +439,6 @@ public class CassandraBaseTimeseriesDao extends CassandraAbstractAsyncDao implem private PreparedStatement getLatestStmt() { if (latestInsertStmt == null) { -// latestInsertStmt = new PreparedStatement[DataType.values().length]; -// for (DataType type : DataType.values()) { latestInsertStmt = prepare(INSERT_INTO + ModelConstants.TS_KV_LATEST_CF + "(" + ModelConstants.ENTITY_TYPE_COLUMN + "," + ModelConstants.ENTITY_ID_COLUMN + @@ -451,7 +449,6 @@ public class CassandraBaseTimeseriesDao extends CassandraAbstractAsyncDao implem "," + ModelConstants.LONG_VALUE_COLUMN + "," + ModelConstants.DOUBLE_VALUE_COLUMN + ")" + " VALUES(?, ?, ?, ?, ?, ?, ?, ?)"); -// } } return latestInsertStmt; } diff --git a/dao/src/main/java/org/thingsboard/server/dao/util/BufferedRateLimiter.java b/dao/src/main/java/org/thingsboard/server/dao/util/BufferedRateLimiter.java index de07dbfa47..2acd623a37 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/util/BufferedRateLimiter.java +++ b/dao/src/main/java/org/thingsboard/server/dao/util/BufferedRateLimiter.java @@ -29,6 +29,7 @@ import java.util.concurrent.atomic.AtomicInteger; @Component @Slf4j +@NoSqlDao public class BufferedRateLimiter implements AsyncRateLimiter { private final ListeningExecutorService pool = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10)); @@ -113,6 +114,9 @@ public class BufferedRateLimiter implements AsyncRateLimiter { lockedFuture.cancelFuture(); return Futures.immediateFailedFuture(new IllegalStateException("Rate Limit Buffer is full. Reject")); } + if(permits.get() < permitsLimit) { + reprocessQueue(); + } return lockedFuture.future; } catch (InterruptedException e) { return Futures.immediateFailedFuture(new IllegalStateException("Rate Limit Task interrupted. Reject")); @@ -130,8 +134,8 @@ public class BufferedRateLimiter implements AsyncRateLimiter { expiredCount++; } } - log.info("Permits maxBuffer is [{}] max concurrent [{}] expired [{}]", maxQueueSize.getAndSet(0), - maxGrantedPermissions.getAndSet(0), expiredCount); + log.info("Permits maxBuffer is [{}] max concurrent [{}] expired [{}] current granted [{}]", maxQueueSize.getAndSet(0), + maxGrantedPermissions.getAndSet(0), expiredCount, permits.get()); } private class LockedFuture { diff --git a/dao/src/test/resources/cassandra-test.properties b/dao/src/test/resources/cassandra-test.properties index 82fcbe1949..737687f053 100644 --- a/dao/src/test/resources/cassandra-test.properties +++ b/dao/src/test/resources/cassandra-test.properties @@ -47,3 +47,8 @@ cassandra.query.default_fetch_size=2000 cassandra.query.ts_key_value_partitioning=HOURS cassandra.query.max_limit_per_request=1000 +cassandra.query.buffer_size=100000 +cassandra.query.concurrent_limit=1000 +cassandra.query.permit_max_wait_time=20000 +cassandra.query.rate_limit_print_interval_ms=30000 + From 7b1a39fb68f153daf2f48c7aa7198d4deaab95d3 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Fri, 23 Mar 2018 20:59:26 +0200 Subject: [PATCH 02/11] Rule Chain hover and select improvements. --- ui/src/app/locale/locale.constant.js | 1 + ui/src/app/rulechain/rulechain.controller.js | 11 +++++ ui/src/app/rulechain/rulechain.scss | 51 ++++++++++++++++---- ui/src/app/rulechain/rulechain.tpl.html | 7 +++ ui/src/app/rulechain/rulenode.tpl.html | 1 + 5 files changed, 62 insertions(+), 9 deletions(-) diff --git a/ui/src/app/locale/locale.constant.js b/ui/src/app/locale/locale.constant.js index cca2a11648..a7b2b443da 100644 --- a/ui/src/app/locale/locale.constant.js +++ b/ui/src/app/locale/locale.constant.js @@ -1177,6 +1177,7 @@ export default angular.module('thingsboard.locale', []) "type": "Type", "description": "Description", "delete": "Delete rule node", + "delete-selected-objects": "Delete selected nodes and connections", "rulenode-details": "Rule node details", "debug-mode": "Debug mode", "configuration": "Configuration", diff --git a/ui/src/app/rulechain/rulechain.controller.js b/ui/src/app/rulechain/rulechain.controller.js index b792f138f8..565e72b444 100644 --- a/ui/src/app/rulechain/rulechain.controller.js +++ b/ui/src/app/rulechain/rulechain.controller.js @@ -81,6 +81,9 @@ export function RuleChainController($stateParams, $scope, $compile, $q, $mdUtil, vm.saveRuleChain = saveRuleChain; vm.revertRuleChain = revertRuleChain; + vm.objectsSelected = objectsSelected; + vm.deleteSelected = deleteSelected; + vm.keyDown = function (evt) { if (evt.keyCode === ctrlKeyCode) { vm.ctrlDown = true; @@ -632,6 +635,14 @@ export function RuleChainController($stateParams, $scope, $compile, $q, $mdUtil, }); } + function objectsSelected() { + return vm.modelservice.nodes.getSelectedNodes().length > 0 || + vm.modelservice.edges.getSelectedEdges().length > 0 + } + + function deleteSelected() { + vm.modelservice.deleteSelected(); + } } /*@ngInject*/ diff --git a/ui/src/app/rulechain/rulechain.scss b/ui/src/app/rulechain/rulechain.scss index 26a5225a68..c1d1376d50 100644 --- a/ui/src/app/rulechain/rulechain.scss +++ b/ui/src/app/rulechain/rulechain.scss @@ -121,10 +121,6 @@ .fc-node { z-index: 1; outline: none; - &.fc-hover, &.fc-selected { - -webkit-filter: brightness(70%); - filter: brightness(70%); - } &.fc-dragging { z-index: 10; } @@ -132,6 +128,26 @@ padding: 0 15px; text-align: center; } + .fc-node-overlay { + position: absolute; + pointer-events: none; + left: 0; + top: 0; + right: 0; + bottom: 0; + background-color: #000; + opacity: 0; + } + &.fc-hover { + .fc-node-overlay { + opacity: 0.25; + } + } + &.fc-selected { + .fc-node-overlay { + opacity: 0.25; + } + } } .fc-leftConnectors, .fc-rightConnectors { @@ -181,6 +197,7 @@ stroke: gray; stroke-width: 4; fill: transparent; + transition: stroke-width .2s; &.fc-selected { stroke: red; stroke-width: 4; @@ -232,20 +249,29 @@ .fc-edge-label { position: absolute; user-select: none; - pointer-events: none; + transition: transform .2s; opacity: 0.8; + &.fc-hover { + transform: scale(1.25); + } + &.fc-selected { + .fc-edge-label-text { + span { + border: solid red; + color: red; + } + } + } } .fc-edge-label-text { position: absolute; - left: 50%; - -webkit-transform: translateX(-50%); - transform: translateX(-50%); + -webkit-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); white-space: nowrap; text-align: center; font-size: 14px; font-weight: 600; - top: 5px; span { border: solid 2px #003a79; border-radius: 10px; @@ -255,6 +281,13 @@ } } +.fc-select-rectangle { + border: 2px dashed #5262ff; + position: absolute; + background: rgba(20,125,255,0.1); + z-index: 2; +} + @keyframes dash { from { stroke-dashoffset: 500; diff --git a/ui/src/app/rulechain/rulechain.tpl.html b/ui/src/app/rulechain/rulechain.tpl.html index 9f1141e887..eec376ea42 100644 --- a/ui/src/app/rulechain/rulechain.tpl.html +++ b/ui/src/app/rulechain/rulechain.tpl.html @@ -112,6 +112,13 @@