From 82f9eed985466340efa83a05060262e18c1ba2c2 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Tue, 5 Jul 2022 17:22:11 +0300 Subject: [PATCH 01/21] Add handling of failed remote js responses. Do not block script due to timeout message because of queue connectivity --- .../service/script/RemoteJsInvokeService.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java index 3bee5ca720..27ee22e459 100644 --- a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java +++ b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java @@ -192,14 +192,33 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { Futures.addCallback(future, new FutureCallback>() { @Override public void onSuccess(@Nullable TbProtoQueueMsg result) { - queueInvokeMsgs.incrementAndGet(); + if (result == null) { + queueInvokeMsgs.incrementAndGet(); + } else { + JsInvokeProtos.JsInvokeResponse invokeResponse = result.getValue().getInvokeResponse(); + if (invokeResponse.getSuccess()) { + queueInvokeMsgs.incrementAndGet(); + } else { + JsInvokeProtos.JsInvokeErrorCode errorCode = invokeResponse.getErrorCode(); + final RuntimeException e = new RuntimeException(invokeResponse.getErrorDetails()); + onScriptExecutionError(scriptId, e, scriptBody); + if (JsInvokeProtos.JsInvokeErrorCode.TIMEOUT_ERROR.equals(errorCode)) { + queueTimeoutMsgs.incrementAndGet(); + queueFailedMsgs.incrementAndGet(); + } else if (JsInvokeProtos.JsInvokeErrorCode.COMPILATION_ERROR.equals(errorCode) + || JsInvokeProtos.JsInvokeErrorCode.RUNTIME_ERROR.equals(errorCode)) { + queueFailedMsgs.incrementAndGet(); + } + } + } } @Override public void onFailure(Throwable t) { - onScriptExecutionError(scriptId, t, scriptBody); if (t instanceof TimeoutException || (t.getCause() != null && t.getCause() instanceof TimeoutException)) { queueTimeoutMsgs.incrementAndGet(); + } else { + onScriptExecutionError(scriptId, t, scriptBody); } queueFailedMsgs.incrementAndGet(); } From a35f8b9a380ece27344b15878ebe4aae53d3eed7 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Tue, 5 Jul 2022 17:41:54 +0300 Subject: [PATCH 02/21] Code review updates --- .../service/script/RemoteJsInvokeService.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java index 27ee22e459..3fda3df46e 100644 --- a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java +++ b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java @@ -192,23 +192,20 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { Futures.addCallback(future, new FutureCallback>() { @Override public void onSuccess(@Nullable TbProtoQueueMsg result) { - if (result == null) { - queueInvokeMsgs.incrementAndGet(); - } else { + if (result != null) { JsInvokeProtos.JsInvokeResponse invokeResponse = result.getValue().getInvokeResponse(); if (invokeResponse.getSuccess()) { queueInvokeMsgs.incrementAndGet(); } else { JsInvokeProtos.JsInvokeErrorCode errorCode = invokeResponse.getErrorCode(); final RuntimeException e = new RuntimeException(invokeResponse.getErrorDetails()); - onScriptExecutionError(scriptId, e, scriptBody); if (JsInvokeProtos.JsInvokeErrorCode.TIMEOUT_ERROR.equals(errorCode)) { + onScriptExecutionError(scriptId, e, scriptBody); queueTimeoutMsgs.incrementAndGet(); - queueFailedMsgs.incrementAndGet(); - } else if (JsInvokeProtos.JsInvokeErrorCode.COMPILATION_ERROR.equals(errorCode) - || JsInvokeProtos.JsInvokeErrorCode.RUNTIME_ERROR.equals(errorCode)) { - queueFailedMsgs.incrementAndGet(); + } else if (JsInvokeProtos.JsInvokeErrorCode.COMPILATION_ERROR.equals(errorCode)) { + onScriptExecutionError(scriptId, e, scriptBody); } + queueFailedMsgs.incrementAndGet(); } } } @@ -217,8 +214,6 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { public void onFailure(Throwable t) { if (t instanceof TimeoutException || (t.getCause() != null && t.getCause() instanceof TimeoutException)) { queueTimeoutMsgs.incrementAndGet(); - } else { - onScriptExecutionError(scriptId, t, scriptBody); } queueFailedMsgs.incrementAndGet(); } From 0c7f23260990dda5e41a586b99d39922192a4d03 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Thu, 7 Jul 2022 10:39:15 +0300 Subject: [PATCH 03/21] Code review updates - move result processing into transform method --- .../service/script/RemoteJsInvokeService.java | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java index 3fda3df46e..a477ca9e80 100644 --- a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java +++ b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java @@ -192,22 +192,6 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { Futures.addCallback(future, new FutureCallback>() { @Override public void onSuccess(@Nullable TbProtoQueueMsg result) { - if (result != null) { - JsInvokeProtos.JsInvokeResponse invokeResponse = result.getValue().getInvokeResponse(); - if (invokeResponse.getSuccess()) { - queueInvokeMsgs.incrementAndGet(); - } else { - JsInvokeProtos.JsInvokeErrorCode errorCode = invokeResponse.getErrorCode(); - final RuntimeException e = new RuntimeException(invokeResponse.getErrorDetails()); - if (JsInvokeProtos.JsInvokeErrorCode.TIMEOUT_ERROR.equals(errorCode)) { - onScriptExecutionError(scriptId, e, scriptBody); - queueTimeoutMsgs.incrementAndGet(); - } else if (JsInvokeProtos.JsInvokeErrorCode.COMPILATION_ERROR.equals(errorCode)) { - onScriptExecutionError(scriptId, e, scriptBody); - } - queueFailedMsgs.incrementAndGet(); - } - } } @Override @@ -223,10 +207,18 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { log.trace("doInvokeFunction js-response took {}ms for uuid {}", stopWatch.getTotalTimeMillis(), response.getKey()); JsInvokeProtos.JsInvokeResponse invokeResult = response.getValue().getInvokeResponse(); if (invokeResult.getSuccess()) { + queueInvokeMsgs.incrementAndGet(); return invokeResult.getResult(); } else { final RuntimeException e = new RuntimeException(invokeResult.getErrorDetails()); - onScriptExecutionError(scriptId, e, scriptBody); + JsInvokeProtos.JsInvokeErrorCode errorCode = invokeResult.getErrorCode(); + if (JsInvokeProtos.JsInvokeErrorCode.TIMEOUT_ERROR.equals(errorCode)) { + onScriptExecutionError(scriptId, e, scriptBody); + queueTimeoutMsgs.incrementAndGet(); + } else if (JsInvokeProtos.JsInvokeErrorCode.COMPILATION_ERROR.equals(errorCode)) { + onScriptExecutionError(scriptId, e, scriptBody); + } + queueFailedMsgs.incrementAndGet(); log.debug("[{}] Failed to compile script due to [{}]: {}", scriptId, invokeResult.getErrorCode().name(), invokeResult.getErrorDetails()); throw e; } From 723194d946b44940d9df2a9a72c2895981f24126 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Thu, 7 Jul 2022 10:46:58 +0300 Subject: [PATCH 04/21] Updates for nashorn script processing. Code refactoring --- .../service/script/AbstractNashornJsInvokeService.java | 2 ++ .../server/service/script/RemoteJsInvokeService.java | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/script/AbstractNashornJsInvokeService.java b/application/src/main/java/org/thingsboard/server/service/script/AbstractNashornJsInvokeService.java index 6aac90b281..d731ef1536 100644 --- a/application/src/main/java/org/thingsboard/server/service/script/AbstractNashornJsInvokeService.java +++ b/application/src/main/java/org/thingsboard/server/service/script/AbstractNashornJsInvokeService.java @@ -159,6 +159,8 @@ public abstract class AbstractNashornJsInvokeService extends AbstractJsInvokeSer } else { return ((Invocable) engine).invokeFunction(functionName, args); } + } catch (ScriptException e) { + throw new ExecutionException(e); } catch (Exception e) { onScriptExecutionError(scriptId, e, functionName); throw new ExecutionException(e); diff --git a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java index a477ca9e80..e92e36befd 100644 --- a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java +++ b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java @@ -211,15 +211,14 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { return invokeResult.getResult(); } else { final RuntimeException e = new RuntimeException(invokeResult.getErrorDetails()); - JsInvokeProtos.JsInvokeErrorCode errorCode = invokeResult.getErrorCode(); - if (JsInvokeProtos.JsInvokeErrorCode.TIMEOUT_ERROR.equals(errorCode)) { + if (JsInvokeProtos.JsInvokeErrorCode.TIMEOUT_ERROR.equals(invokeResult.getErrorCode())) { onScriptExecutionError(scriptId, e, scriptBody); queueTimeoutMsgs.incrementAndGet(); - } else if (JsInvokeProtos.JsInvokeErrorCode.COMPILATION_ERROR.equals(errorCode)) { + } else if (JsInvokeProtos.JsInvokeErrorCode.COMPILATION_ERROR.equals(invokeResult.getErrorCode())) { onScriptExecutionError(scriptId, e, scriptBody); } queueFailedMsgs.incrementAndGet(); - log.debug("[{}] Failed to compile script due to [{}]: {}", scriptId, invokeResult.getErrorCode().name(), invokeResult.getErrorDetails()); + log.debug("[{}] Failed to invoke function due to [{}]: {}", scriptId, invokeResult.getErrorCode().name(), invokeResult.getErrorDetails()); throw e; } }, callbackExecutor); From 21f6c58a89ed49d5185824daaad625e1e834b75b Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Thu, 7 Jul 2022 12:23:56 +0300 Subject: [PATCH 05/21] Invoke msg count fix --- .../server/service/script/RemoteJsInvokeService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java index e92e36befd..addd39f39a 100644 --- a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java +++ b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java @@ -192,6 +192,7 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { Futures.addCallback(future, new FutureCallback>() { @Override public void onSuccess(@Nullable TbProtoQueueMsg result) { + queueInvokeMsgs.incrementAndGet(); } @Override @@ -207,7 +208,6 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { log.trace("doInvokeFunction js-response took {}ms for uuid {}", stopWatch.getTotalTimeMillis(), response.getKey()); JsInvokeProtos.JsInvokeResponse invokeResult = response.getValue().getInvokeResponse(); if (invokeResult.getSuccess()) { - queueInvokeMsgs.incrementAndGet(); return invokeResult.getResult(); } else { final RuntimeException e = new RuntimeException(invokeResult.getErrorDetails()); From 52b0d7e39e0ed7805a5e4958ca0db6eeaa5a8102 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Thu, 7 Jul 2022 13:10:29 +0300 Subject: [PATCH 06/21] Take into account queue transfer delay --- .../server/service/script/RemoteJsInvokeService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java index addd39f39a..fad92fe217 100644 --- a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java +++ b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java @@ -51,6 +51,8 @@ import java.util.concurrent.atomic.AtomicInteger; @Service public class RemoteJsInvokeService extends AbstractJsInvokeService { + private static final int QUEUE_TRANSFER_DELAY = 2000; + @Value("${queue.js.max_eval_requests_timeout}") private long maxEvalRequestsTimeout; @@ -186,7 +188,7 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { ListenableFuture> future = requestTemplate.send(new TbProtoJsQueueMsg<>(UUID.randomUUID(), jsRequestWrapper)); if (maxRequestsTimeout > 0) { - future = Futures.withTimeout(future, maxRequestsTimeout, TimeUnit.MILLISECONDS, timeoutExecutorService); + future = Futures.withTimeout(future, maxRequestsTimeout + QUEUE_TRANSFER_DELAY, TimeUnit.MILLISECONDS, timeoutExecutorService); } queuePushedMsgs.incrementAndGet(); Futures.addCallback(future, new FutureCallback>() { From be6ddb903605c1f959c6eaadab1bcd49fb64745f Mon Sep 17 00:00:00 2001 From: fe-dev Date: Thu, 7 Jul 2022 13:36:13 +0300 Subject: [PATCH 07/21] UI: Fix custom legend for flot widgets settings --- .../settings/chart/flot-widget-settings.component.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/flot-widget-settings.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/flot-widget-settings.component.html index 2cf14d066d..d2d0a5fdaf 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/flot-widget-settings.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/flot-widget-settings.component.html @@ -288,19 +288,19 @@
widgets.chart.custom-legend-settings - + + fxLayoutAlign="center" style="height: 100%;"> {{ 'widgets.chart.enable-custom-legend' | translate }} - + widget-config.advanced-settings -
+
widgets.chart.label-keys-list
From bd46e162ff570d3614c0de503eb459d4def32706 Mon Sep 17 00:00:00 2001 From: fe-dev Date: Thu, 7 Jul 2022 13:58:40 +0300 Subject: [PATCH 08/21] UI: Add min height for header --- .../lib/settings/chart/flot-widget-settings.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/flot-widget-settings.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/flot-widget-settings.component.html index d2d0a5fdaf..3ecc56b602 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/flot-widget-settings.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/flot-widget-settings.component.html @@ -288,7 +288,7 @@
widgets.chart.custom-legend-settings - + From 5253705f458d2edf70e6b944d2e6760cfabe8feb Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Thu, 7 Jul 2022 17:52:14 +0300 Subject: [PATCH 09/21] Set default js timeout to 1500. Removed transfer delay - replace it by multiplier --- .../server/service/script/RemoteJsInvokeService.java | 6 ++---- application/src/main/resources/thingsboard.yml | 2 +- docker/tb-node.env | 2 ++ docker/tb-node/conf/logback.xml | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java index fad92fe217..163028f009 100644 --- a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java +++ b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java @@ -51,8 +51,6 @@ import java.util.concurrent.atomic.AtomicInteger; @Service public class RemoteJsInvokeService extends AbstractJsInvokeService { - private static final int QUEUE_TRANSFER_DELAY = 2000; - @Value("${queue.js.max_eval_requests_timeout}") private long maxEvalRequestsTimeout; @@ -172,7 +170,7 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { .setScriptIdMSB(scriptId.getMostSignificantBits()) .setScriptIdLSB(scriptId.getLeastSignificantBits()) .setFunctionName(functionName) - .setTimeout((int) maxRequestsTimeout) + .setTimeout((int) (maxRequestsTimeout * 0.75)) // timeout on JS executor must be less than on Java .setScriptBody(scriptBody); for (Object arg : args) { @@ -188,7 +186,7 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { ListenableFuture> future = requestTemplate.send(new TbProtoJsQueueMsg<>(UUID.randomUUID(), jsRequestWrapper)); if (maxRequestsTimeout > 0) { - future = Futures.withTimeout(future, maxRequestsTimeout + QUEUE_TRANSFER_DELAY, TimeUnit.MILLISECONDS, timeoutExecutorService); + future = Futures.withTimeout(future, maxRequestsTimeout, TimeUnit.MILLISECONDS, timeoutExecutorService); } queuePushedMsgs.incrementAndGet(); Futures.addCallback(future, new FutureCallback>() { diff --git a/application/src/main/resources/thingsboard.yml b/application/src/main/resources/thingsboard.yml index 9b458734f7..bccd35851e 100644 --- a/application/src/main/resources/thingsboard.yml +++ b/application/src/main/resources/thingsboard.yml @@ -1044,7 +1044,7 @@ queue: # JS Eval max request timeout max_eval_requests_timeout: "${REMOTE_JS_MAX_EVAL_REQUEST_TIMEOUT:60000}" # JS max request timeout - max_requests_timeout: "${REMOTE_JS_MAX_REQUEST_TIMEOUT:10000}" + max_requests_timeout: "${REMOTE_JS_MAX_REQUEST_TIMEOUT:1500}" # JS response poll interval response_poll_interval: "${REMOTE_JS_RESPONSE_POLL_INTERVAL_MS:25}" rule-engine: diff --git a/docker/tb-node.env b/docker/tb-node.env index ba66757ecc..c6fb1348f4 100644 --- a/docker/tb-node.env +++ b/docker/tb-node.env @@ -5,6 +5,8 @@ ZOOKEEPER_URL=zookeeper:2181 JS_EVALUATOR=remote TRANSPORT_TYPE=remote +TB_JS_REMOTE_STATS_ENABLED=true + HTTP_LOG_CONTROLLER_ERROR_STACK_TRACE=false TB_QUEUE_PARTITIONS_VIRTUAL_NODES_SIZE=64 diff --git a/docker/tb-node/conf/logback.xml b/docker/tb-node/conf/logback.xml index bc694d704d..587be18d20 100644 --- a/docker/tb-node/conf/logback.xml +++ b/docker/tb-node/conf/logback.xml @@ -41,6 +41,7 @@ + From e32c42749f0691618dd1dc20932521867f02bf27 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Fri, 8 Jul 2022 12:03:05 +0300 Subject: [PATCH 10/21] Revert default logging --- docker/tb-node.env | 2 -- docker/tb-node/conf/logback.xml | 1 - msa/js-executor/docker/Dockerfile | 1 + 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/docker/tb-node.env b/docker/tb-node.env index c6fb1348f4..ba66757ecc 100644 --- a/docker/tb-node.env +++ b/docker/tb-node.env @@ -5,8 +5,6 @@ ZOOKEEPER_URL=zookeeper:2181 JS_EVALUATOR=remote TRANSPORT_TYPE=remote -TB_JS_REMOTE_STATS_ENABLED=true - HTTP_LOG_CONTROLLER_ERROR_STACK_TRACE=false TB_QUEUE_PARTITIONS_VIRTUAL_NODES_SIZE=64 diff --git a/docker/tb-node/conf/logback.xml b/docker/tb-node/conf/logback.xml index 587be18d20..bc694d704d 100644 --- a/docker/tb-node/conf/logback.xml +++ b/docker/tb-node/conf/logback.xml @@ -41,7 +41,6 @@ - diff --git a/msa/js-executor/docker/Dockerfile b/msa/js-executor/docker/Dockerfile index 620d712ad1..d17138d923 100644 --- a/msa/js-executor/docker/Dockerfile +++ b/msa/js-executor/docker/Dockerfile @@ -29,6 +29,7 @@ COPY package/linux/conf ./conf COPY package/linux/conf ./config COPY src/api ./api COPY src/queue ./queue +COPY src/config ./config COPY src/server.js ./ RUN chmod a+x /tmp/*.sh \ From b4592f5f925d7f580896c1bfb8aefbd73d858071 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Fri, 8 Jul 2022 14:15:55 +0300 Subject: [PATCH 11/21] Fix incorrect start JavaScript Executor AWS SQS queue --- msa/js-executor/api/utils.ts | 6 --- msa/js-executor/queue/awsSqsTemplate.ts | 60 ++++++++++++------------- 2 files changed, 28 insertions(+), 38 deletions(-) diff --git a/msa/js-executor/api/utils.ts b/msa/js-executor/api/utils.ts index b43a5f05f2..361025f806 100644 --- a/msa/js-executor/api/utils.ts +++ b/msa/js-executor/api/utils.ts @@ -39,12 +39,6 @@ export function isString(value: any): boolean { return typeof value === 'string'; } -export function sleep(ms: number): Promise { - return new Promise((resolve) => { - setTimeout(resolve, ms); - }); -} - export function parseJsErrorDetails(err: any): string | undefined { if (!err) { return undefined; diff --git a/msa/js-executor/queue/awsSqsTemplate.ts b/msa/js-executor/queue/awsSqsTemplate.ts index 36ec9b5270..c48b18050a 100644 --- a/msa/js-executor/queue/awsSqsTemplate.ts +++ b/msa/js-executor/queue/awsSqsTemplate.ts @@ -34,7 +34,6 @@ import { SQSClient } from '@aws-sdk/client-sqs'; import uuid from 'uuid-random'; -import { sleep } from '../api/utils'; export class AwsSqsTemplate implements IQueue { @@ -48,11 +47,11 @@ export class AwsSqsTemplate implements IQueue { private sqsClient: SQSClient; private requestQueueURL: string - private stopped = false; private queueUrls = new Map(); private queueAttributes: { [n: string]: string } = { FifoQueue: 'true' }; + private timer: NodeJS.Timer; name = 'AWS SQS'; @@ -91,40 +90,37 @@ export class AwsSqsTemplate implements IQueue { const params: ReceiveMessageRequest = { MaxNumberOfMessages: 10, QueueUrl: this.requestQueueURL, - WaitTimeSeconds: this.pollInterval / 1000 + WaitTimeSeconds: Math.round(this.pollInterval / 10) }; - while (!this.stopped) { - let pollStartTs = new Date().getTime(); - const messagesResponse: ReceiveMessageResult = await this.sqsClient.send(new ReceiveMessageCommand(params)); - const messages = messagesResponse.Messages; - - if (messages && messages.length > 0) { - const entries: DeleteMessageBatchRequestEntry[] = []; - - messages.forEach(message => { - entries.push({ - Id: message.MessageId, - ReceiptHandle: message.ReceiptHandle - }); - messageProcessor.onJsInvokeMessage(JSON.parse(message.Body || '')); + this.timer = setTimeout(() => {this.processMessage(messageProcessor, params)}, this.pollInterval); + } + + private async processMessage(messageProcessor: JsInvokeMessageProcessor, params: ReceiveMessageRequest) { + const messagesResponse: ReceiveMessageResult = await this.sqsClient.send(new ReceiveMessageCommand(params)); + const messages = messagesResponse.Messages; + + if (messages && messages.length > 0) { + const entries: DeleteMessageBatchRequestEntry[] = []; + + messages.forEach(message => { + entries.push({ + Id: message.MessageId, + ReceiptHandle: message.ReceiptHandle }); + messageProcessor.onJsInvokeMessage(JSON.parse(message.Body || '')); + }); - const deleteBatch: DeleteMessageBatchRequest = { - QueueUrl: this.requestQueueURL, - Entries: entries - }; - try { - await this.sqsClient.send(new DeleteMessageBatchCommand(deleteBatch)) - } catch (err: any) { - this.logger.error("Failed to delete messages from queue.", err.message); - } - } else { - let pollDuration = new Date().getTime() - pollStartTs; - if (pollDuration < this.pollInterval) { - await sleep(this.pollInterval - pollDuration); - } + const deleteBatch: DeleteMessageBatchRequest = { + QueueUrl: this.requestQueueURL, + Entries: entries + }; + try { + await this.sqsClient.send(new DeleteMessageBatchCommand(deleteBatch)) + } catch (err: any) { + this.logger.error("Failed to delete messages from queue.", err.message); } } + this.timer = setTimeout(() => {this.processMessage(messageProcessor, params)}, this.pollInterval); } async send(responseTopic: string, scriptId: string, rawResponse: Buffer, headers: any): Promise { @@ -182,8 +178,8 @@ export class AwsSqsTemplate implements IQueue { } async destroy(): Promise { - this.stopped = true; this.logger.info('Stopping AWS SQS resources...'); + clearTimeout(this.timer); if (this.sqsClient) { this.logger.info('Stopping AWS SQS client...'); try { From f9cc85d5a8b8af6e04cceb601bccfc4e8280396d Mon Sep 17 00:00:00 2001 From: Ekaterina Chantsova Date: Fri, 8 Jul 2022 14:54:24 +0300 Subject: [PATCH 12/21] UI: Fix binding to dashboard timewindow for widgets group within state widget --- .../dashboard-page/layout/dashboard-layout.component.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/layout/dashboard-layout.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/layout/dashboard-layout.component.ts index 374c6d9b3d..a4bef1fc21 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/layout/dashboard-layout.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/layout/dashboard-layout.component.ts @@ -27,7 +27,7 @@ import { IDashboardComponent, WidgetContextMenuItem } from '@home/models/dashboard-component.models'; -import { Subscription } from 'rxjs'; +import { merge, Subscription } from 'rxjs'; import { Hotkey } from 'angular2-hotkeys'; import { TranslateService } from '@ngx-translate/core'; import { ItemBufferService } from '@app/core/services/item-buffer.service'; @@ -94,7 +94,11 @@ export class DashboardLayoutComponent extends PageComponent implements ILayoutCo } ngOnInit(): void { - this.rxSubscriptions.push(this.dashboard.dashboardTimewindowChanged.subscribe( + const dashboardTimewindowChanged = [this.dashboard.dashboardTimewindowChanged]; + if (this.parentDashboard) { + dashboardTimewindowChanged.push(this.parentDashboard.dashboardTimewindowChanged); + } + this.rxSubscriptions.push(merge(...dashboardTimewindowChanged).subscribe( (dashboardTimewindow) => { this.dashboardCtx.dashboardTimewindow = dashboardTimewindow; this.dashboardCtx.runChangeDetection(); From 60853dd5d6319e45f268dd741d5c0bc6a54d8c16 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Fri, 8 Jul 2022 15:25:00 +0300 Subject: [PATCH 13/21] Refactor JavaScript Executor AWS SQS queue --- msa/js-executor/queue/awsSqsTemplate.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/msa/js-executor/queue/awsSqsTemplate.ts b/msa/js-executor/queue/awsSqsTemplate.ts index c48b18050a..259d285cf2 100644 --- a/msa/js-executor/queue/awsSqsTemplate.ts +++ b/msa/js-executor/queue/awsSqsTemplate.ts @@ -90,12 +90,12 @@ export class AwsSqsTemplate implements IQueue { const params: ReceiveMessageRequest = { MaxNumberOfMessages: 10, QueueUrl: this.requestQueueURL, - WaitTimeSeconds: Math.round(this.pollInterval / 10) + WaitTimeSeconds: Math.ceil(this.pollInterval / 10) }; - this.timer = setTimeout(() => {this.processMessage(messageProcessor, params)}, this.pollInterval); + this.timer = setTimeout(() => {this.getAndProcessMessage(messageProcessor, params)}, this.pollInterval); } - private async processMessage(messageProcessor: JsInvokeMessageProcessor, params: ReceiveMessageRequest) { + private async getAndProcessMessage(messageProcessor: JsInvokeMessageProcessor, params: ReceiveMessageRequest) { const messagesResponse: ReceiveMessageResult = await this.sqsClient.send(new ReceiveMessageCommand(params)); const messages = messagesResponse.Messages; @@ -120,7 +120,7 @@ export class AwsSqsTemplate implements IQueue { this.logger.error("Failed to delete messages from queue.", err.message); } } - this.timer = setTimeout(() => {this.processMessage(messageProcessor, params)}, this.pollInterval); + this.timer = setTimeout(() => {this.getAndProcessMessage(messageProcessor, params)}, this.pollInterval); } async send(responseTopic: string, scriptId: string, rawResponse: Buffer, headers: any): Promise { From 3a148467f96570caeb544ca953ed6ac4b7c89957 Mon Sep 17 00:00:00 2001 From: Andrii Shvaika Date: Fri, 8 Jul 2022 16:02:33 +0300 Subject: [PATCH 14/21] Minor fix for the commit request --- .../vc/DefaultEntitiesVersionControlService.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/sync/vc/DefaultEntitiesVersionControlService.java b/application/src/main/java/org/thingsboard/server/service/sync/vc/DefaultEntitiesVersionControlService.java index 005e90001b..b0e7b67f25 100644 --- a/application/src/main/java/org/thingsboard/server/service/sync/vc/DefaultEntitiesVersionControlService.java +++ b/application/src/main/java/org/thingsboard/server/service/sync/vc/DefaultEntitiesVersionControlService.java @@ -139,18 +139,24 @@ public class DefaultEntitiesVersionControlService implements EntitiesVersionCont DonAsynchron.withCallback(pendingCommit, commit -> { cachePut(commit.getTxId(), new VersionCreationResult()); try { - List> gitFutures = new ArrayList<>(); + EntitiesExportCtx theCtx; switch (request.getType()) { case SINGLE_ENTITY: { - handleSingleEntityRequest(new SimpleEntitiesExportCtx(user, commit, (SingleEntityVersionCreateRequest) request)); + var ctx = new SimpleEntitiesExportCtx(user, commit, (SingleEntityVersionCreateRequest) request); + handleSingleEntityRequest(ctx); + theCtx = ctx; break; } case COMPLEX: { - handleComplexRequest(new ComplexEntitiesExportCtx(user, commit, (ComplexVersionCreateRequest) request)); + var ctx = new ComplexEntitiesExportCtx(user, commit, (ComplexVersionCreateRequest) request); + handleComplexRequest(ctx); + theCtx = ctx; break; } + default: + throw new RuntimeException("Unsupported request type: " + request.getType()); } - var resultFuture = Futures.transformAsync(Futures.allAsList(gitFutures), f -> gitServiceQueue.push(commit), executor); + var resultFuture = Futures.transformAsync(Futures.allAsList(theCtx.getFutures()), f -> gitServiceQueue.push(commit), executor); DonAsynchron.withCallback(resultFuture, result -> cachePut(commit.getTxId(), result), e -> processCommitError(user, request, commit, e), executor); } catch (Exception e) { processCommitError(user, request, commit, e); From 64332ecaa07735ee5bc6e5d7e644cf0aec396dd8 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Fri, 8 Jul 2022 16:19:30 +0300 Subject: [PATCH 15/21] Improve log config. Fix black box tests. --- application/src/main/conf/logback.xml | 2 +- application/src/main/resources/logback.xml | 2 +- docker/tb-node/conf/logback.xml | 26 +++++++++++++++++++ docker/tb-transports/coap/conf/logback.xml | 5 ++++ docker/tb-transports/http/conf/logback.xml | 5 ++++ docker/tb-transports/lwm2m/conf/logback.xml | 4 +++ docker/tb-transports/mqtt/conf/logback.xml | 4 +++ docker/tb-transports/snmp/conf/logback.xml | 4 +++ docker/tb-vc-executor/conf/logback.xml | 7 +++-- .../server/msa/ContainerTestSuite.java | 2 +- .../server/msa/ThingsBoardDbInstaller.java | 2 +- msa/tb/docker/logback.xml | 2 ++ msa/vc-executor/src/main/conf/logback.xml | 4 ++- .../src/main/resources/logback.xml | 6 ++--- transport/coap/src/main/conf/logback.xml | 2 +- transport/coap/src/main/resources/logback.xml | 3 +-- transport/http/src/main/conf/logback.xml | 2 +- transport/http/src/main/resources/logback.xml | 2 +- transport/lwm2m/src/main/conf/logback.xml | 2 +- .../lwm2m/src/main/resources/logback.xml | 2 +- transport/mqtt/src/main/conf/logback.xml | 2 +- transport/mqtt/src/main/resources/logback.xml | 2 +- transport/snmp/src/main/conf/logback.xml | 2 +- transport/snmp/src/main/resources/logback.xml | 2 +- 24 files changed, 75 insertions(+), 21 deletions(-) diff --git a/application/src/main/conf/logback.xml b/application/src/main/conf/logback.xml index 6d2c95ee84..284af71953 100644 --- a/application/src/main/conf/logback.xml +++ b/application/src/main/conf/logback.xml @@ -37,7 +37,7 @@ - + diff --git a/application/src/main/resources/logback.xml b/application/src/main/resources/logback.xml index 4784ad2d43..941bd7d278 100644 --- a/application/src/main/resources/logback.xml +++ b/application/src/main/resources/logback.xml @@ -27,7 +27,7 @@ - + diff --git a/docker/tb-node/conf/logback.xml b/docker/tb-node/conf/logback.xml index bc694d704d..c17e8a43cf 100644 --- a/docker/tb-node/conf/logback.xml +++ b/docker/tb-node/conf/logback.xml @@ -42,6 +42,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docker/tb-transports/coap/conf/logback.xml b/docker/tb-transports/coap/conf/logback.xml index 1a3e8ef6b3..65d13a55cf 100644 --- a/docker/tb-transports/coap/conf/logback.xml +++ b/docker/tb-transports/coap/conf/logback.xml @@ -42,6 +42,11 @@ + + + + + diff --git a/docker/tb-transports/http/conf/logback.xml b/docker/tb-transports/http/conf/logback.xml index 05361fe680..a3ae374bb7 100644 --- a/docker/tb-transports/http/conf/logback.xml +++ b/docker/tb-transports/http/conf/logback.xml @@ -42,6 +42,11 @@ + + + + + diff --git a/docker/tb-transports/lwm2m/conf/logback.xml b/docker/tb-transports/lwm2m/conf/logback.xml index d2485675ee..5546167f3d 100644 --- a/docker/tb-transports/lwm2m/conf/logback.xml +++ b/docker/tb-transports/lwm2m/conf/logback.xml @@ -42,6 +42,10 @@ + + + + diff --git a/docker/tb-transports/mqtt/conf/logback.xml b/docker/tb-transports/mqtt/conf/logback.xml index 09bcaea84c..d4e7b811f8 100644 --- a/docker/tb-transports/mqtt/conf/logback.xml +++ b/docker/tb-transports/mqtt/conf/logback.xml @@ -42,6 +42,10 @@ + + + + diff --git a/docker/tb-transports/snmp/conf/logback.xml b/docker/tb-transports/snmp/conf/logback.xml index dc53ddd8a3..0b6fbc726b 100644 --- a/docker/tb-transports/snmp/conf/logback.xml +++ b/docker/tb-transports/snmp/conf/logback.xml @@ -42,6 +42,10 @@ + + + + diff --git a/docker/tb-vc-executor/conf/logback.xml b/docker/tb-vc-executor/conf/logback.xml index dc95b3a885..ebde7cbd69 100644 --- a/docker/tb-vc-executor/conf/logback.xml +++ b/docker/tb-vc-executor/conf/logback.xml @@ -40,8 +40,11 @@ - - + + + + + diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ContainerTestSuite.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ContainerTestSuite.java index 60934bdbbf..ffd2e1f50a 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ContainerTestSuite.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ContainerTestSuite.java @@ -95,7 +95,7 @@ public class ContainerTestSuite { new File(targetDir + "docker-compose.postgres.volumes.yml"), new File(targetDir + "docker-compose." + QUEUE_TYPE + ".yml"), new File(targetDir + (IS_REDIS_CLUSTER ? "docker-compose.redis-cluster.yml" : "docker-compose.redis.yml")), - new File(targetDir + (IS_HYBRID_MODE ? "docker-compose.redis-cluster.volumes.yml" : "docker-compose.redis.volumes.yml")) + new File(targetDir + (IS_REDIS_CLUSTER ? "docker-compose.redis-cluster.volumes.yml" : "docker-compose.redis.volumes.yml")) )); Map queueEnv = new HashMap<>(); diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ThingsBoardDbInstaller.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ThingsBoardDbInstaller.java index c39932b572..eedf070fac 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ThingsBoardDbInstaller.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ThingsBoardDbInstaller.java @@ -46,7 +46,7 @@ public class ThingsBoardDbInstaller extends ExternalResource { private final static String TB_MQTT_TRANSPORT_LOG_VOLUME = "tb-mqtt-transport-log-test-volume"; private final static String TB_SNMP_TRANSPORT_LOG_VOLUME = "tb-snmp-transport-log-test-volume"; private final static String TB_VC_EXECUTOR_LOG_VOLUME = "tb-vc-executor-log-test-volume"; - private final static String JAVA_OPTS = "-Xmx384m -Xss256k"; + private final static String JAVA_OPTS = "-Xmx512m"; private final DockerComposeExecutor dockerCompose; diff --git a/msa/tb/docker/logback.xml b/msa/tb/docker/logback.xml index 92fab7bc88..01fc5d30a8 100644 --- a/msa/tb/docker/logback.xml +++ b/msa/tb/docker/logback.xml @@ -42,6 +42,8 @@ + + diff --git a/msa/vc-executor/src/main/conf/logback.xml b/msa/vc-executor/src/main/conf/logback.xml index c0f33852a6..d7468ef257 100644 --- a/msa/vc-executor/src/main/conf/logback.xml +++ b/msa/vc-executor/src/main/conf/logback.xml @@ -35,8 +35,10 @@ + + - + diff --git a/msa/vc-executor/src/main/resources/logback.xml b/msa/vc-executor/src/main/resources/logback.xml index e25a1995c1..e0a240aee3 100644 --- a/msa/vc-executor/src/main/resources/logback.xml +++ b/msa/vc-executor/src/main/resources/logback.xml @@ -25,11 +25,11 @@ - - + + - + diff --git a/transport/coap/src/main/conf/logback.xml b/transport/coap/src/main/conf/logback.xml index a769cbe364..d7468ef257 100644 --- a/transport/coap/src/main/conf/logback.xml +++ b/transport/coap/src/main/conf/logback.xml @@ -38,7 +38,7 @@ - + diff --git a/transport/coap/src/main/resources/logback.xml b/transport/coap/src/main/resources/logback.xml index 44ddb3d372..e0a240aee3 100644 --- a/transport/coap/src/main/resources/logback.xml +++ b/transport/coap/src/main/resources/logback.xml @@ -28,9 +28,8 @@ - - + diff --git a/transport/http/src/main/conf/logback.xml b/transport/http/src/main/conf/logback.xml index a769cbe364..d7468ef257 100644 --- a/transport/http/src/main/conf/logback.xml +++ b/transport/http/src/main/conf/logback.xml @@ -38,7 +38,7 @@ - + diff --git a/transport/http/src/main/resources/logback.xml b/transport/http/src/main/resources/logback.xml index 44ddb3d372..80f9525f2e 100644 --- a/transport/http/src/main/resources/logback.xml +++ b/transport/http/src/main/resources/logback.xml @@ -30,7 +30,7 @@ - + diff --git a/transport/lwm2m/src/main/conf/logback.xml b/transport/lwm2m/src/main/conf/logback.xml index a769cbe364..d7468ef257 100644 --- a/transport/lwm2m/src/main/conf/logback.xml +++ b/transport/lwm2m/src/main/conf/logback.xml @@ -38,7 +38,7 @@ - + diff --git a/transport/lwm2m/src/main/resources/logback.xml b/transport/lwm2m/src/main/resources/logback.xml index 44ddb3d372..80f9525f2e 100644 --- a/transport/lwm2m/src/main/resources/logback.xml +++ b/transport/lwm2m/src/main/resources/logback.xml @@ -30,7 +30,7 @@ - + diff --git a/transport/mqtt/src/main/conf/logback.xml b/transport/mqtt/src/main/conf/logback.xml index a769cbe364..d7468ef257 100644 --- a/transport/mqtt/src/main/conf/logback.xml +++ b/transport/mqtt/src/main/conf/logback.xml @@ -38,7 +38,7 @@ - + diff --git a/transport/mqtt/src/main/resources/logback.xml b/transport/mqtt/src/main/resources/logback.xml index 44ddb3d372..80f9525f2e 100644 --- a/transport/mqtt/src/main/resources/logback.xml +++ b/transport/mqtt/src/main/resources/logback.xml @@ -30,7 +30,7 @@ - + diff --git a/transport/snmp/src/main/conf/logback.xml b/transport/snmp/src/main/conf/logback.xml index a769cbe364..d7468ef257 100644 --- a/transport/snmp/src/main/conf/logback.xml +++ b/transport/snmp/src/main/conf/logback.xml @@ -38,7 +38,7 @@ - + diff --git a/transport/snmp/src/main/resources/logback.xml b/transport/snmp/src/main/resources/logback.xml index 44ddb3d372..80f9525f2e 100644 --- a/transport/snmp/src/main/resources/logback.xml +++ b/transport/snmp/src/main/resources/logback.xml @@ -30,7 +30,7 @@ - + From af52540cb21f3a95f139efacd350b4fc63e36559 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Fri, 8 Jul 2022 16:58:34 +0300 Subject: [PATCH 16/21] Added max execution requests timeout for remote JS executors --- .../server/service/script/RemoteJsInvokeService.java | 5 ++++- application/src/main/resources/thingsboard.yml | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java index 163028f009..3715580286 100644 --- a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java +++ b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java @@ -57,6 +57,9 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { @Value("${queue.js.max_requests_timeout}") private long maxRequestsTimeout; + @Value("${queue.js.max_exec_requests_timeout}") + private long maxExecRequestsTimeout; + @Getter @Value("${js.remote.max_errors}") private int maxErrors; @@ -170,7 +173,7 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { .setScriptIdMSB(scriptId.getMostSignificantBits()) .setScriptIdLSB(scriptId.getLeastSignificantBits()) .setFunctionName(functionName) - .setTimeout((int) (maxRequestsTimeout * 0.75)) // timeout on JS executor must be less than on Java + .setTimeout((int) maxExecRequestsTimeout) .setScriptBody(scriptBody); for (Object arg : args) { diff --git a/application/src/main/resources/thingsboard.yml b/application/src/main/resources/thingsboard.yml index bccd35851e..cc009029cf 100644 --- a/application/src/main/resources/thingsboard.yml +++ b/application/src/main/resources/thingsboard.yml @@ -1044,7 +1044,9 @@ queue: # JS Eval max request timeout max_eval_requests_timeout: "${REMOTE_JS_MAX_EVAL_REQUEST_TIMEOUT:60000}" # JS max request timeout - max_requests_timeout: "${REMOTE_JS_MAX_REQUEST_TIMEOUT:1500}" + max_requests_timeout: "${REMOTE_JS_MAX_REQUEST_TIMEOUT:10000}" + # JS execution max request timeout + max_exec_requests_timeout: "${REMOTE_JS_MAX_EXEC_REQUEST_TIMEOUT:2000}" # JS response poll interval response_poll_interval: "${REMOTE_JS_RESPONSE_POLL_INTERVAL_MS:25}" rule-engine: From bd7faa05b53185bea37c2c6ac71e104a4761ae03 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Fri, 8 Jul 2022 17:01:29 +0300 Subject: [PATCH 17/21] Added default value for remote max exec requests timeout --- .../server/service/script/RemoteJsInvokeService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java index 3715580286..86b364afd4 100644 --- a/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java +++ b/application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java @@ -57,7 +57,7 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { @Value("${queue.js.max_requests_timeout}") private long maxRequestsTimeout; - @Value("${queue.js.max_exec_requests_timeout}") + @Value("${queue.js.max_exec_requests_timeout:2000}") private long maxExecRequestsTimeout; @Getter From 518807f8638dfdae69cc9f4be7e4bd2bc842e381 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Fri, 8 Jul 2022 18:30:20 +0300 Subject: [PATCH 18/21] Update base image for nodejs microservices --- msa/js-executor/docker/Dockerfile | 2 +- msa/web-ui/docker/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/msa/js-executor/docker/Dockerfile b/msa/js-executor/docker/Dockerfile index d17138d923..8746e1db54 100644 --- a/msa/js-executor/docker/Dockerfile +++ b/msa/js-executor/docker/Dockerfile @@ -14,7 +14,7 @@ # limitations under the License. # -FROM node:16.15.1-bullseye-slim +FROM thingsboard/node:16.15.1-bullseye-slim ENV NODE_ENV production ENV DOCKER_MODE true diff --git a/msa/web-ui/docker/Dockerfile b/msa/web-ui/docker/Dockerfile index 66c0ea9893..7b047381ae 100644 --- a/msa/web-ui/docker/Dockerfile +++ b/msa/web-ui/docker/Dockerfile @@ -14,7 +14,7 @@ # limitations under the License. # -FROM node:16.15.1-bullseye-slim +FROM thingsboard/node:16.15.1-bullseye-slim ENV NODE_ENV production ENV DOCKER_MODE true From 8924c5e209350a6ea1d601979ee59457f12a4da0 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Fri, 8 Jul 2022 18:41:41 +0300 Subject: [PATCH 19/21] Update dashboard-layout.component.ts --- .../dashboard-page/layout/dashboard-layout.component.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/layout/dashboard-layout.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/layout/dashboard-layout.component.ts index a4bef1fc21..c331578e2b 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/layout/dashboard-layout.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/layout/dashboard-layout.component.ts @@ -27,7 +27,7 @@ import { IDashboardComponent, WidgetContextMenuItem } from '@home/models/dashboard-component.models'; -import { merge, Subscription } from 'rxjs'; +import { Subscription } from 'rxjs'; import { Hotkey } from 'angular2-hotkeys'; import { TranslateService } from '@ngx-translate/core'; import { ItemBufferService } from '@app/core/services/item-buffer.service'; @@ -94,11 +94,8 @@ export class DashboardLayoutComponent extends PageComponent implements ILayoutCo } ngOnInit(): void { - const dashboardTimewindowChanged = [this.dashboard.dashboardTimewindowChanged]; - if (this.parentDashboard) { - dashboardTimewindowChanged.push(this.parentDashboard.dashboardTimewindowChanged); - } - this.rxSubscriptions.push(merge(...dashboardTimewindowChanged).subscribe( + const dashboardTimewindowChanged = this.parentDashboard ? this.parentDashboard.dashboardTimewindowChanged : this.dashboard.dashboardTimewindowChanged; + this.rxSubscriptions.push(dashboardTimewindowChanged.subscribe( (dashboardTimewindow) => { this.dashboardCtx.dashboardTimewindow = dashboardTimewindow; this.dashboardCtx.runChangeDetection(); From d8ada9f1ef0056ffb8e8f6aaf141d480c611b21f Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Fri, 8 Jul 2022 18:57:10 +0300 Subject: [PATCH 20/21] Fix VC permissions --- .../server/controller/EntitiesVersionControlController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/controller/EntitiesVersionControlController.java b/application/src/main/java/org/thingsboard/server/controller/EntitiesVersionControlController.java index 65b5f10407..f2bfbc9478 100644 --- a/application/src/main/java/org/thingsboard/server/controller/EntitiesVersionControlController.java +++ b/application/src/main/java/org/thingsboard/server/controller/EntitiesVersionControlController.java @@ -192,7 +192,7 @@ public class EntitiesVersionControlController extends BaseController { @GetMapping(value = "/version/{requestId}/status") public VersionCreationResult getVersionCreateRequestStatus(@ApiParam(value = VC_REQUEST_ID_PARAM_DESCRIPTION, required = true) @PathVariable UUID requestId) throws Exception { - accessControlService.checkPermission(getCurrentUser(), Resource.VERSION_CONTROL, Operation.READ); + accessControlService.checkPermission(getCurrentUser(), Resource.VERSION_CONTROL, Operation.WRITE); return versionControlService.getVersionCreateStatus(getCurrentUser(), requestId); } @@ -469,7 +469,7 @@ public class EntitiesVersionControlController extends BaseController { @GetMapping(value = "/entity/{requestId}/status") public VersionLoadResult getVersionLoadRequestStatus(@ApiParam(value = VC_REQUEST_ID_PARAM_DESCRIPTION, required = true) @PathVariable UUID requestId) throws Exception { - accessControlService.checkPermission(getCurrentUser(), Resource.VERSION_CONTROL, Operation.READ); + accessControlService.checkPermission(getCurrentUser(), Resource.VERSION_CONTROL, Operation.WRITE); return versionControlService.getVersionLoadStatus(getCurrentUser(), requestId); } From e1c696f7cb8fdd5cf5afb2bf5fc3416e06e3c3b4 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Fri, 8 Jul 2022 18:59:22 +0300 Subject: [PATCH 21/21] Fix style errors --- .../dashboard-page/layout/dashboard-layout.component.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/layout/dashboard-layout.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/layout/dashboard-layout.component.ts index c331578e2b..fcee0b2f0a 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/layout/dashboard-layout.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/layout/dashboard-layout.component.ts @@ -94,7 +94,8 @@ export class DashboardLayoutComponent extends PageComponent implements ILayoutCo } ngOnInit(): void { - const dashboardTimewindowChanged = this.parentDashboard ? this.parentDashboard.dashboardTimewindowChanged : this.dashboard.dashboardTimewindowChanged; + const dashboardTimewindowChanged = this.parentDashboard ? + this.parentDashboard.dashboardTimewindowChanged : this.dashboard.dashboardTimewindowChanged; this.rxSubscriptions.push(dashboardTimewindowChanged.subscribe( (dashboardTimewindow) => { this.dashboardCtx.dashboardTimewindow = dashboardTimewindow;