Commit 285a79ab0a64991a830832d60cedf9b8ff161c92
Merge branch '20230509' into 'master_dev'
20230509 See merge request yunteng/thingskit!193
Showing
5 changed files
with
51 additions
and
12 deletions
... | ... | @@ -30,6 +30,7 @@ import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequest; |
30 | 30 | import org.thingsboard.server.dao.yunteng.service.TkDeviceService; |
31 | 31 | import org.thingsboard.server.dao.yunteng.service.TkDeviceTaskCenterService; |
32 | 32 | import org.thingsboard.server.dao.yunteng.service.TkTaskCenterService; |
33 | +import org.thingsboard.server.queue.util.TbCoreComponent; | |
33 | 34 | import org.thingsboard.server.service.rpc.TbCoreDeviceRpcService; |
34 | 35 | import org.thingsboard.server.service.security.model.SecurityUser; |
35 | 36 | import java.time.LocalDateTime; |
... | ... | @@ -39,6 +40,7 @@ import java.util.*; |
39 | 40 | @Component("rpcCommandTask") |
40 | 41 | @RequiredArgsConstructor |
41 | 42 | @Slf4j |
43 | +@TbCoreComponent | |
42 | 44 | public class RpcCommandTask { |
43 | 45 | @Value("${server.rest.server_side_rpc.default_timeout:10000}") |
44 | 46 | protected long defaultTimeout; | ... | ... |
... | ... | @@ -124,7 +124,7 @@ public class DeviceDTO extends TenantDTO { |
124 | 124 | private JsonNode customerAdditionalInfo; |
125 | 125 | |
126 | 126 | public DeviceState getDeviceState() { |
127 | - if (lastOnlineTime == null) { | |
127 | + if (statusTime == null) { | |
128 | 128 | return DeviceState.INACTIVE; |
129 | 129 | } |
130 | 130 | return deviceState; | ... | ... |
... | ... | @@ -297,7 +297,7 @@ public class TcpTransportHandler extends ChannelInboundHandlerAdapter implements |
297 | 297 | |
298 | 298 | if (DataConstants.PROVISION.equals(accessToken) || DataConstants.PROVISION.equals(accessToken)) { |
299 | 299 | deviceSessionCtx.setProvisionOnly(true); |
300 | - ctx.writeAndFlush(createTcpConnAckMsg(CONNECTION_ACCEPTED.name())); | |
300 | + pushDeviceMsg(ctx,CONNECTION_ACCEPTED.name()); | |
301 | 301 | } else { |
302 | 302 | TkScriptInvokeService.authScripts.forEach(id -> { |
303 | 303 | ListenableFuture item = context.getJsEngine().invokeFunction(id, accessToken); |
... | ... | @@ -347,9 +347,7 @@ public class TcpTransportHandler extends ChannelInboundHandlerAdapter implements |
347 | 347 | } |
348 | 348 | |
349 | 349 | |
350 | - private ByteBuf createTcpConnAckMsg(String msg) { | |
351 | - return Unpooled.copiedBuffer(ByteUtils.getBytes(msg, ByteUtils.UTF_8)); | |
352 | - } | |
350 | + | |
353 | 351 | |
354 | 352 | @Override |
355 | 353 | public void channelReadComplete(ChannelHandlerContext ctx) { |
... | ... | @@ -450,7 +448,7 @@ public class TcpTransportHandler extends ChannelInboundHandlerAdapter implements |
450 | 448 | public void onSuccess(Void msg) { |
451 | 449 | SessionMetaData sessionMetaData = transportService.registerAsyncSession(deviceSessionCtx.getSessionInfo(), TcpTransportHandler.this); |
452 | 450 | checkGatewaySession(sessionMetaData); |
453 | - ctx.writeAndFlush(createTcpConnAckMsg(authEntry.getSuccess())); | |
451 | + pushDeviceMsg(ctx,authEntry.getSuccess()); | |
454 | 452 | deviceSessionCtx.setConnected(true); |
455 | 453 | log.debug("[{}] Client connected!", sessionId); |
456 | 454 | |
... | ... | @@ -474,7 +472,8 @@ public class TcpTransportHandler extends ChannelInboundHandlerAdapter implements |
474 | 472 | private void onValidateFailed(ChannelHandlerContext ctx, MqttConnectReturnCode msg) { |
475 | 473 | authedCounter.incrementAndGet(); |
476 | 474 | if (TkScriptInvokeService.authScripts.size() == authedCounter.intValue()) { |
477 | - ctx.writeAndFlush(createTcpConnAckMsg(msg.name())); | |
475 | + pushDeviceMsg(ctx,msg.name()); | |
476 | + | |
478 | 477 | ctx.close(); |
479 | 478 | } |
480 | 479 | } | ... | ... |
... | ... | @@ -41,7 +41,7 @@ |
41 | 41 | <pkg.copyInstallScripts>false</pkg.copyInstallScripts> |
42 | 42 | <pkg.win.dist>${project.build.directory}/windows</pkg.win.dist> |
43 | 43 | <pkg.implementationTitle>ThingsBoard MQTT Transport Service</pkg.implementationTitle> |
44 | - <pkg.mainClass>org.thingsboard.server.tcp.ThingsboardMqttTransportApplication</pkg.mainClass> | |
44 | + <pkg.mainClass>org.thingsboard.server.mqtt.ThingsboardMqttTransportApplication</pkg.mainClass> | |
45 | 45 | </properties> |
46 | 46 | |
47 | 47 | <dependencies> | ... | ... |
... | ... | @@ -28,9 +28,9 @@ server: |
28 | 28 | # Zookeeper connection parameters. Used for service discovery. |
29 | 29 | zk: |
30 | 30 | # Enable/disable zookeeper discovery service. |
31 | - enabled: "${ZOOKEEPER_ENABLED:true}" | |
31 | + enabled: "${ZOOKEEPER_ENABLED:false}" | |
32 | 32 | # Zookeeper connect string |
33 | - url: "${ZOOKEEPER_URL:47.99.141.212:2181}" | |
33 | + url: "${ZOOKEEPER_URL:localhost:2181}" | |
34 | 34 | # Zookeeper retry interval in milliseconds |
35 | 35 | retry_interval_ms: "${ZOOKEEPER_RETRY_INTERVAL_MS:3000}" |
36 | 36 | # Zookeeper connection timeout in milliseconds |
... | ... | @@ -68,7 +68,7 @@ redis: |
68 | 68 | # db index |
69 | 69 | db: "${REDIS_DB:0}" |
70 | 70 | # db password |
71 | - password: "${REDIS_PASSWORD:redis@6379}" | |
71 | + password: "${REDIS_PASSWORD:}" | |
72 | 72 | # pool config |
73 | 73 | pool_config: |
74 | 74 | maxTotal: "${REDIS_POOL_CONFIG_MAX_TOTAL:128}" |
... | ... | @@ -83,6 +83,42 @@ redis: |
83 | 83 | numberTestsPerEvictionRun: "${REDIS_POOL_CONFIG_NUMBER_TESTS_PER_EVICTION_RUN:3}" |
84 | 84 | blockWhenExhausted: "${REDIS_POOL_CONFIG_BLOCK_WHEN_EXHAUSTED:true}" |
85 | 85 | |
86 | +# Actor system parameters | |
87 | +actors: | |
88 | + rule: | |
89 | +# # Specify thread pool size for database request callbacks executor service | |
90 | +# db_callback_thread_pool_size: "${ACTORS_RULE_DB_CALLBACK_THREAD_POOL_SIZE:50}" | |
91 | + # Specify thread pool size for javascript executor service | |
92 | + js_thread_pool_size: "${ACTORS_RULE_JS_THREAD_POOL_SIZE:50}" | |
93 | +js: | |
94 | + evaluator: "${JS_EVALUATOR:local}" # local/remote | |
95 | + # Built-in JVM JavaScript environment properties | |
96 | + local: | |
97 | + # Use Sandboxed (secured) JVM JavaScript environment | |
98 | + use_js_sandbox: "${USE_LOCAL_JS_SANDBOX:true}" | |
99 | + # Specify thread pool size for JavaScript sandbox resource monitor | |
100 | + monitor_thread_pool_size: "${LOCAL_JS_SANDBOX_MONITOR_THREAD_POOL_SIZE:4}" | |
101 | + # Maximum CPU time in milliseconds allowed for script execution | |
102 | + max_cpu_time: "${LOCAL_JS_SANDBOX_MAX_CPU_TIME:8000}" | |
103 | + # Maximum allowed JavaScript execution errors before JavaScript will be blacklisted | |
104 | + max_errors: "${LOCAL_JS_SANDBOX_MAX_ERRORS:3}" | |
105 | + # JS Eval max request timeout. 0 - no timeout | |
106 | + max_requests_timeout: "${LOCAL_JS_MAX_REQUEST_TIMEOUT:0}" | |
107 | + # Maximum time in seconds for black listed function to stay in the list. | |
108 | + max_black_list_duration_sec: "${LOCAL_JS_SANDBOX_MAX_BLACKLIST_DURATION_SEC:60}" | |
109 | + stats: | |
110 | + enabled: "${TB_JS_LOCAL_STATS_ENABLED:false}" | |
111 | + print_interval_ms: "${TB_JS_LOCAL_STATS_PRINT_INTERVAL_MS:10000}" | |
112 | + # Remote JavaScript environment properties | |
113 | + remote: | |
114 | + # Maximum allowed JavaScript execution errors before JavaScript will be blacklisted | |
115 | + max_errors: "${REMOTE_JS_SANDBOX_MAX_ERRORS:3}" | |
116 | + # Maximum time in seconds for black listed function to stay in the list. | |
117 | + max_black_list_duration_sec: "${REMOTE_JS_SANDBOX_MAX_BLACKLIST_DURATION_SEC:60}" | |
118 | + stats: | |
119 | + enabled: "${TB_JS_REMOTE_STATS_ENABLED:false}" | |
120 | + print_interval_ms: "${TB_JS_REMOTE_STATS_PRINT_INTERVAL_MS:10000}" | |
121 | + | |
86 | 122 | # TCP_ server parameters |
87 | 123 | transport: |
88 | 124 | tcp: |
... | ... | @@ -163,7 +199,7 @@ transport: |
163 | 199 | queue: |
164 | 200 | type: "${TB_QUEUE_TYPE:kafka}" # kafka (Apache Kafka) or aws-sqs (AWS SQS) or pubsub (PubSub) or service-bus (Azure Service Bus) or rabbitmq (RabbitMQ) |
165 | 201 | kafka: |
166 | - bootstrap.servers: "${TB_KAFKA_SERVERS:47.99.141.212:9092}" | |
202 | + bootstrap.servers: "${TB_KAFKA_SERVERS:localhost:9092}" | |
167 | 203 | acks: "${TB_KAFKA_ACKS:all}" |
168 | 204 | retries: "${TB_KAFKA_RETRIES:1}" |
169 | 205 | batch.size: "${TB_KAFKA_BATCH_SIZE:16384}" |
... | ... | @@ -345,3 +381,5 @@ management: |
345 | 381 | exposure: |
346 | 382 | # Expose metrics endpoint (use value 'prometheus' to enable prometheus metrics). |
347 | 383 | include: '${METRICS_ENDPOINTS_EXPOSE:info}' |
384 | + | |
385 | + | ... | ... |