Showing
7 changed files
with
20 additions
and
12 deletions
@@ -16,6 +16,7 @@ | @@ -16,6 +16,7 @@ | ||
16 | package org.thingsboard.server.service.cluster.discovery; | 16 | package org.thingsboard.server.service.cluster.discovery; |
17 | 17 | ||
18 | import lombok.extern.slf4j.Slf4j; | 18 | import lombok.extern.slf4j.Slf4j; |
19 | +import org.apache.commons.lang3.RandomStringUtils; | ||
19 | import org.springframework.beans.factory.annotation.Autowired; | 20 | import org.springframework.beans.factory.annotation.Autowired; |
20 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | 21 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
21 | import org.springframework.context.annotation.DependsOn; | 22 | import org.springframework.context.annotation.DependsOn; |
@@ -37,14 +38,17 @@ public class DummyDiscoveryService implements DiscoveryService { | @@ -37,14 +38,17 @@ public class DummyDiscoveryService implements DiscoveryService { | ||
37 | @Autowired | 38 | @Autowired |
38 | private ServerInstanceService serverInstance; | 39 | private ServerInstanceService serverInstance; |
39 | 40 | ||
41 | + private String nodeId; | ||
42 | + | ||
40 | @PostConstruct | 43 | @PostConstruct |
41 | public void init() { | 44 | public void init() { |
42 | log.info("Initializing..."); | 45 | log.info("Initializing..."); |
46 | + this.nodeId = RandomStringUtils.randomAlphabetic(10); | ||
43 | } | 47 | } |
44 | 48 | ||
45 | @Override | 49 | @Override |
46 | public String getNodeId() { | 50 | public String getNodeId() { |
47 | - return null; | 51 | + return nodeId; |
48 | } | 52 | } |
49 | 53 | ||
50 | @Override | 54 | @Override |
@@ -59,8 +59,11 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { | @@ -59,8 +59,11 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { | ||
59 | @Value("${js.remote.max_requests_timeout}") | 59 | @Value("${js.remote.max_requests_timeout}") |
60 | private long maxRequestsTimeout; | 60 | private long maxRequestsTimeout; |
61 | 61 | ||
62 | - @Value("${js.remote.response_poll_duration}") | ||
63 | - private long responsePollDuration; | 62 | + @Value("${js.remote.response_poll_interval}") |
63 | + private int responsePollDuration; | ||
64 | + | ||
65 | + @Value("${js.remote.response_auto_commit_interval}") | ||
66 | + private int autoCommitInterval; | ||
64 | 67 | ||
65 | @Getter | 68 | @Getter |
66 | @Value("${js.remote.max_errors}") | 69 | @Value("${js.remote.max_errors}") |
@@ -82,7 +85,7 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { | @@ -82,7 +85,7 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { | ||
82 | responseBuilder.clientId(discoveryService.getNodeId()); | 85 | responseBuilder.clientId(discoveryService.getNodeId()); |
83 | responseBuilder.groupId("rule-engine-node"); | 86 | responseBuilder.groupId("rule-engine-node"); |
84 | responseBuilder.autoCommit(true); | 87 | responseBuilder.autoCommit(true); |
85 | - responseBuilder.autoCommitIntervalMs(100); | 88 | + responseBuilder.autoCommitIntervalMs(autoCommitInterval); |
86 | responseBuilder.decoder(new RemoteJsResponseDecoder()); | 89 | responseBuilder.decoder(new RemoteJsResponseDecoder()); |
87 | 90 | ||
88 | TbKafkaRequestTemplate.TbKafkaRequestTemplateBuilder | 91 | TbKafkaRequestTemplate.TbKafkaRequestTemplateBuilder |
@@ -415,7 +415,7 @@ kafka: | @@ -415,7 +415,7 @@ kafka: | ||
415 | buffer.memory: "${TB_BUFFER_MEMORY:33554432}" | 415 | buffer.memory: "${TB_BUFFER_MEMORY:33554432}" |
416 | 416 | ||
417 | js: | 417 | js: |
418 | - evaluator: "${JS_EVALUATOR:local}" # local/remote | 418 | + evaluator: "${JS_EVALUATOR:remote}" # local/remote |
419 | # Built-in JVM JavaScript environment properties | 419 | # Built-in JVM JavaScript environment properties |
420 | local: | 420 | local: |
421 | # Use Sandboxed (secured) JVM JavaScript environment | 421 | # Use Sandboxed (secured) JVM JavaScript environment |
@@ -438,5 +438,7 @@ js: | @@ -438,5 +438,7 @@ js: | ||
438 | max_requests_timeout: "${REMOTE_JS_MAX_REQUEST_TIMEOUT:10000}" | 438 | max_requests_timeout: "${REMOTE_JS_MAX_REQUEST_TIMEOUT:10000}" |
439 | # JS response poll interval | 439 | # JS response poll interval |
440 | response_poll_interval: "${REMOTE_JS_RESPONSE_POLL_INTERVAL_MS:25}" | 440 | response_poll_interval: "${REMOTE_JS_RESPONSE_POLL_INTERVAL_MS:25}" |
441 | + # JS response auto commit interval | ||
442 | + response_auto_commit_interval: "${REMOTE_JS_RESPONSE_AUTO_COMMIT_INTERVAL_MS:100}" | ||
441 | # Maximum allowed JavaScript execution errors before JavaScript will be blacklisted | 443 | # Maximum allowed JavaScript execution errors before JavaScript will be blacklisted |
442 | max_errors: "${REMOTE_JS_SANDBOX_MAX_ERRORS:3}" | 444 | max_errors: "${REMOTE_JS_SANDBOX_MAX_ERRORS:3}" |
@@ -15,8 +15,6 @@ | @@ -15,8 +15,6 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.common.msg.session; | 16 | package org.thingsboard.server.common.msg.session; |
17 | 17 | ||
18 | -import java.util.Optional; | ||
19 | - | ||
20 | public class BasicSessionActorToAdaptorMsg extends BasicSessionMsg implements SessionActorToAdaptorMsg { | 18 | public class BasicSessionActorToAdaptorMsg extends BasicSessionMsg implements SessionActorToAdaptorMsg { |
21 | 19 | ||
22 | private final ToDeviceMsg msg; | 20 | private final ToDeviceMsg msg; |
@@ -15,11 +15,12 @@ | @@ -15,11 +15,12 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.common.msg.session; | 16 | package org.thingsboard.server.common.msg.session; |
17 | 17 | ||
18 | -import org.thingsboard.server.common.data.security.DeviceCredentialsFilter; | ||
19 | -import org.thingsboard.server.common.msg.aware.SessionAwareMsg; | 18 | +import org.thingsboard.server.common.data.id.SessionId; |
20 | import org.thingsboard.server.common.msg.session.ex.SessionException; | 19 | import org.thingsboard.server.common.msg.session.ex.SessionException; |
21 | 20 | ||
22 | -public interface SessionContext extends SessionAwareMsg { | 21 | +public interface SessionContext { |
22 | + | ||
23 | + SessionId getSessionId(); | ||
23 | 24 | ||
24 | SessionType getSessionType(); | 25 | SessionType getSessionType(); |
25 | 26 |
@@ -40,7 +40,7 @@ public class TBKafkaConsumerTemplate<T> { | @@ -40,7 +40,7 @@ public class TBKafkaConsumerTemplate<T> { | ||
40 | @Builder | 40 | @Builder |
41 | private TBKafkaConsumerTemplate(TbKafkaSettings settings, TbKafkaDecoder<T> decoder, | 41 | private TBKafkaConsumerTemplate(TbKafkaSettings settings, TbKafkaDecoder<T> decoder, |
42 | String clientId, String groupId, String topic, | 42 | String clientId, String groupId, String topic, |
43 | - boolean autoCommit, long autoCommitIntervalMs) { | 43 | + boolean autoCommit, int autoCommitIntervalMs) { |
44 | Properties props = settings.toProps(); | 44 | Properties props = settings.toProps(); |
45 | props.put(ConsumerConfig.CLIENT_ID_CONFIG, clientId); | 45 | props.put(ConsumerConfig.CLIENT_ID_CONFIG, clientId); |
46 | props.put(ConsumerConfig.GROUP_ID_CONFIG, groupId); | 46 | props.put(ConsumerConfig.GROUP_ID_CONFIG, groupId); |
@@ -46,7 +46,7 @@ public class TbKafkaSettings { | @@ -46,7 +46,7 @@ public class TbKafkaSettings { | ||
46 | private int retries; | 46 | private int retries; |
47 | 47 | ||
48 | @Value("${kafka.batch.size}") | 48 | @Value("${kafka.batch.size}") |
49 | - private long batchSize; | 49 | + private int batchSize; |
50 | 50 | ||
51 | @Value("${kafka.linger.ms}") | 51 | @Value("${kafka.linger.ms}") |
52 | private long lingerMs; | 52 | private long lingerMs; |