Browse Source

Set default js timeout to 1500. Removed transfer delay - replace it by multiplier

pull/6905/head
Volodymyr Babak 4 years ago
parent
commit
5253705f45
  1. 6
      application/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java
  2. 2
      application/src/main/resources/thingsboard.yml
  3. 2
      docker/tb-node.env
  4. 1
      docker/tb-node/conf/logback.xml

6
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<TbProtoQueueMsg<JsInvokeProtos.RemoteJsResponse>> 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<TbProtoQueueMsg<JsInvokeProtos.RemoteJsResponse>>() {

2
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:

2
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

1
docker/tb-node/conf/logback.xml

@ -41,6 +41,7 @@
</appender>
<logger name="org.thingsboard.server" level="INFO" />
<logger name="org.thingsboard.server.service.script" level="TRACE" />
<logger name="com.google.common.util.concurrent.AggregateFuture" level="OFF" />
<root level="INFO">

Loading…
Cancel
Save