Commit 045e110e615e552b82bff57c5b96f7768e9f1ffa
1 parent
47514ea1
refactor: 脚本引擎模块调整
TCP模块调整到transport-api 用户脚本测试
Showing
16 changed files
with
50 additions
and
52 deletions
@@ -98,10 +98,6 @@ | @@ -98,10 +98,6 @@ | ||
98 | <scope>test</scope> | 98 | <scope>test</scope> |
99 | </dependency> | 99 | </dependency> |
100 | 100 | ||
101 | - <dependency> | ||
102 | - <groupId>org.javadelight</groupId> | ||
103 | - <artifactId>delight-nashorn-sandbox</artifactId> | ||
104 | - </dependency> | ||
105 | </dependencies> | 101 | </dependencies> |
106 | 102 | ||
107 | </project> | 103 | </project> |
common/transport/tcp/src/main/java/org/thingsboard/server/transport/tcp/adaptors/JsonTcpAdaptor.java
@@ -15,8 +15,6 @@ | @@ -15,8 +15,6 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.transport.tcp.adaptors; | 16 | package org.thingsboard.server.transport.tcp.adaptors; |
17 | 17 | ||
18 | -import com.fasterxml.jackson.databind.JsonNode; | ||
19 | -import com.fasterxml.jackson.databind.ObjectMapper; | ||
20 | import com.google.common.util.concurrent.Futures; | 18 | import com.google.common.util.concurrent.Futures; |
21 | import com.google.common.util.concurrent.ListenableFuture; | 19 | import com.google.common.util.concurrent.ListenableFuture; |
22 | import com.google.common.util.concurrent.MoreExecutors; | 20 | import com.google.common.util.concurrent.MoreExecutors; |
@@ -38,8 +36,8 @@ import org.thingsboard.server.common.data.ota.OtaPackageType; | @@ -38,8 +36,8 @@ import org.thingsboard.server.common.data.ota.OtaPackageType; | ||
38 | import org.thingsboard.server.common.transport.adaptor.AdaptorException; | 36 | import org.thingsboard.server.common.transport.adaptor.AdaptorException; |
39 | import org.thingsboard.server.common.transport.adaptor.JsonConverter; | 37 | import org.thingsboard.server.common.transport.adaptor.JsonConverter; |
40 | import org.thingsboard.server.gen.transport.TransportProtos; | 38 | import org.thingsboard.server.gen.transport.TransportProtos; |
41 | -import org.thingsboard.server.transport.tcp.script.JsInvokeService; | ||
42 | -import org.thingsboard.server.transport.tcp.script.JsScriptType; | 39 | +import org.thingsboard.server.common.yunteng.script.YtScriptInvokeService; |
40 | +import org.thingsboard.server.common.yunteng.script.YtScriptType; | ||
43 | import org.thingsboard.server.transport.tcp.session.DeviceSessionCtx; | 41 | import org.thingsboard.server.transport.tcp.session.DeviceSessionCtx; |
44 | 42 | ||
45 | import java.nio.charset.Charset; | 43 | import java.nio.charset.Charset; |
@@ -59,7 +57,7 @@ public class JsonTcpAdaptor implements TcpTransportAdaptor { | @@ -59,7 +57,7 @@ public class JsonTcpAdaptor implements TcpTransportAdaptor { | ||
59 | 57 | ||
60 | protected static final Charset UTF8 = StandardCharsets.UTF_8; | 58 | protected static final Charset UTF8 = StandardCharsets.UTF_8; |
61 | @Autowired | 59 | @Autowired |
62 | - private JsInvokeService jsEngine; | 60 | + private YtScriptInvokeService jsEngine; |
63 | private static final JsonParser parser = new JsonParser(); | 61 | private static final JsonParser parser = new JsonParser(); |
64 | @Override | 62 | @Override |
65 | public TransportProtos.PostTelemetryMsg convertToPostTelemetry(DeviceSessionCtx ctx, String inbound) throws AdaptorException { | 63 | public TransportProtos.PostTelemetryMsg convertToPostTelemetry(DeviceSessionCtx ctx, String inbound) throws AdaptorException { |
@@ -78,7 +76,7 @@ public class JsonTcpAdaptor implements TcpTransportAdaptor { | @@ -78,7 +76,7 @@ public class JsonTcpAdaptor implements TcpTransportAdaptor { | ||
78 | 76 | ||
79 | @Override | 77 | @Override |
80 | public UUID getJsScriptEngineFunctionId(String scriptBody, String... argNames) throws ExecutionException, InterruptedException { | 78 | public UUID getJsScriptEngineFunctionId(String scriptBody, String... argNames) throws ExecutionException, InterruptedException { |
81 | - return jsEngine.eval(JsScriptType.TCP_TRANSPORT_SCRIPT, scriptBody, argNames).get(); | 79 | + return jsEngine.eval(YtScriptType.TCP_TRANSPORT_SCRIPT, scriptBody, argNames).get(); |
82 | } | 80 | } |
83 | 81 | ||
84 | @Override | 82 | @Override |
@@ -137,6 +137,11 @@ | @@ -137,6 +137,11 @@ | ||
137 | <groupId>org.bouncycastle</groupId> | 137 | <groupId>org.bouncycastle</groupId> |
138 | <artifactId>bcpkix-jdk15on</artifactId> | 138 | <artifactId>bcpkix-jdk15on</artifactId> |
139 | </dependency> | 139 | </dependency> |
140 | + | ||
141 | + <dependency> | ||
142 | + <groupId>org.javadelight</groupId> | ||
143 | + <artifactId>delight-nashorn-sandbox</artifactId> | ||
144 | + </dependency> | ||
140 | </dependencies> | 145 | </dependencies> |
141 | 146 | ||
142 | <build> | 147 | <build> |
common/transport/transport-api/src/main/java/org/thingsboard/server/common/yunteng/script/AbstractNashornYtScriptInvokeService.java
renamed from
common/transport/tcp/src/main/java/org/thingsboard/server/transport/tcp/script/AbstractNashornJsInvokeService.java
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.transport.tcp.script; | 16 | +package org.thingsboard.server.common.yunteng.script; |
17 | 17 | ||
18 | import com.google.common.util.concurrent.FutureCallback; | 18 | import com.google.common.util.concurrent.FutureCallback; |
19 | import com.google.common.util.concurrent.Futures; | 19 | import com.google.common.util.concurrent.Futures; |
@@ -26,6 +26,9 @@ import lombok.extern.slf4j.Slf4j; | @@ -26,6 +26,9 @@ import lombok.extern.slf4j.Slf4j; | ||
26 | import org.springframework.beans.factory.annotation.Value; | 26 | import org.springframework.beans.factory.annotation.Value; |
27 | import org.springframework.scheduling.annotation.Scheduled; | 27 | import org.springframework.scheduling.annotation.Scheduled; |
28 | import org.thingsboard.common.util.ThingsBoardExecutors; | 28 | import org.thingsboard.common.util.ThingsBoardExecutors; |
29 | +import org.thingsboard.server.common.yunteng.script.AbstractYtScriptInvokeService; | ||
30 | +import org.thingsboard.server.common.yunteng.script.YtScriptExecutorService; | ||
31 | +import org.thingsboard.server.common.yunteng.script.YtScriptStatCallback; | ||
29 | import org.thingsboard.server.queue.usagestats.TbApiUsageClient; | 32 | import org.thingsboard.server.queue.usagestats.TbApiUsageClient; |
30 | 33 | ||
31 | import javax.annotation.PostConstruct; | 34 | import javax.annotation.PostConstruct; |
@@ -42,7 +45,7 @@ import java.util.concurrent.atomic.AtomicInteger; | @@ -42,7 +45,7 @@ import java.util.concurrent.atomic.AtomicInteger; | ||
42 | import java.util.concurrent.locks.ReentrantLock; | 45 | import java.util.concurrent.locks.ReentrantLock; |
43 | 46 | ||
44 | @Slf4j | 47 | @Slf4j |
45 | -public abstract class AbstractNashornJsInvokeService extends AbstractJsInvokeService { | 48 | +public abstract class AbstractNashornYtScriptInvokeService extends AbstractYtScriptInvokeService { |
46 | 49 | ||
47 | private NashornSandbox sandbox; | 50 | private NashornSandbox sandbox; |
48 | private ScriptEngine engine; | 51 | private ScriptEngine engine; |
@@ -53,13 +56,13 @@ public abstract class AbstractNashornJsInvokeService extends AbstractJsInvokeSer | @@ -53,13 +56,13 @@ public abstract class AbstractNashornJsInvokeService extends AbstractJsInvokeSer | ||
53 | private final AtomicInteger jsEvalMsgs = new AtomicInteger(0); | 56 | private final AtomicInteger jsEvalMsgs = new AtomicInteger(0); |
54 | private final AtomicInteger jsFailedMsgs = new AtomicInteger(0); | 57 | private final AtomicInteger jsFailedMsgs = new AtomicInteger(0); |
55 | private final AtomicInteger jsTimeoutMsgs = new AtomicInteger(0); | 58 | private final AtomicInteger jsTimeoutMsgs = new AtomicInteger(0); |
56 | - private final FutureCallback<UUID> evalCallback = new JsStatCallback<>(jsEvalMsgs, jsTimeoutMsgs, jsFailedMsgs); | ||
57 | - private final FutureCallback<Object> invokeCallback = new JsStatCallback<>(jsInvokeMsgs, jsTimeoutMsgs, jsFailedMsgs); | 59 | + private final FutureCallback<UUID> evalCallback = new YtScriptStatCallback<>(jsEvalMsgs, jsTimeoutMsgs, jsFailedMsgs); |
60 | + private final FutureCallback<Object> invokeCallback = new YtScriptStatCallback<>(jsInvokeMsgs, jsTimeoutMsgs, jsFailedMsgs); | ||
58 | 61 | ||
59 | private final ReentrantLock evalLock = new ReentrantLock(); | 62 | private final ReentrantLock evalLock = new ReentrantLock(); |
60 | 63 | ||
61 | @Getter | 64 | @Getter |
62 | - private final TcpJsExecutorService jsExecutor; | 65 | + private final YtScriptExecutorService jsExecutor; |
63 | 66 | ||
64 | @Value("${js.local.max_requests_timeout:0}") | 67 | @Value("${js.local.max_requests_timeout:0}") |
65 | private long maxRequestsTimeout; | 68 | private long maxRequestsTimeout; |
@@ -67,7 +70,7 @@ public abstract class AbstractNashornJsInvokeService extends AbstractJsInvokeSer | @@ -67,7 +70,7 @@ public abstract class AbstractNashornJsInvokeService extends AbstractJsInvokeSer | ||
67 | @Value("${js.local.stats.enabled:false}") | 70 | @Value("${js.local.stats.enabled:false}") |
68 | private boolean statsEnabled; | 71 | private boolean statsEnabled; |
69 | 72 | ||
70 | - public AbstractNashornJsInvokeService(TbApiUsageClient apiUsageClient, TcpJsExecutorService jsExecutor) { | 73 | + public AbstractNashornYtScriptInvokeService(TbApiUsageClient apiUsageClient, YtScriptExecutorService jsExecutor) { |
71 | super(); | 74 | super(); |
72 | this.jsExecutor = jsExecutor; | 75 | this.jsExecutor = jsExecutor; |
73 | } | 76 | } |
common/transport/transport-api/src/main/java/org/thingsboard/server/common/yunteng/script/AbstractYtScriptInvokeService.java
renamed from
common/transport/tcp/src/main/java/org/thingsboard/server/transport/tcp/script/AbstractJsInvokeService.java
@@ -13,15 +13,12 @@ | @@ -13,15 +13,12 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.transport.tcp.script; | 16 | +package org.thingsboard.server.common.yunteng.script; |
17 | 17 | ||
18 | import com.google.common.util.concurrent.Futures; | 18 | import com.google.common.util.concurrent.Futures; |
19 | import com.google.common.util.concurrent.ListenableFuture; | 19 | import com.google.common.util.concurrent.ListenableFuture; |
20 | import lombok.extern.slf4j.Slf4j; | 20 | import lombok.extern.slf4j.Slf4j; |
21 | import org.thingsboard.common.util.ThingsBoardThreadFactory; | 21 | import org.thingsboard.common.util.ThingsBoardThreadFactory; |
22 | -import org.thingsboard.server.common.data.ApiUsageRecordKey; | ||
23 | -import org.thingsboard.server.common.data.id.CustomerId; | ||
24 | -import org.thingsboard.server.common.data.id.TenantId; | ||
25 | 22 | ||
26 | import java.util.Map; | 23 | import java.util.Map; |
27 | import java.util.UUID; | 24 | import java.util.UUID; |
@@ -34,7 +31,7 @@ import java.util.concurrent.atomic.AtomicInteger; | @@ -34,7 +31,7 @@ import java.util.concurrent.atomic.AtomicInteger; | ||
34 | * Created by ashvayka on 26.09.18. | 31 | * Created by ashvayka on 26.09.18. |
35 | */ | 32 | */ |
36 | @Slf4j | 33 | @Slf4j |
37 | -public abstract class AbstractJsInvokeService implements JsInvokeService { | 34 | +public abstract class AbstractYtScriptInvokeService implements YtScriptInvokeService { |
38 | 35 | ||
39 | 36 | ||
40 | 37 | ||
@@ -57,7 +54,7 @@ public abstract class AbstractJsInvokeService implements JsInvokeService { | @@ -57,7 +54,7 @@ public abstract class AbstractJsInvokeService implements JsInvokeService { | ||
57 | } | 54 | } |
58 | 55 | ||
59 | @Override | 56 | @Override |
60 | - public ListenableFuture<UUID> eval(JsScriptType scriptType, String scriptBody, String... argNames) { | 57 | + public ListenableFuture<UUID> eval(YtScriptType scriptType, String scriptBody, String... argNames) { |
61 | UUID scriptId = UUID.randomUUID(); | 58 | UUID scriptId = UUID.randomUUID(); |
62 | String functionName = "invokeInternal_" + scriptId.toString().replace('-', '_'); | 59 | String functionName = "invokeInternal_" + scriptId.toString().replace('-', '_'); |
63 | String jsScript = generateJsScript(scriptType, functionName, scriptBody, argNames); | 60 | String jsScript = generateJsScript(scriptType, functionName, scriptBody, argNames); |
@@ -112,9 +109,9 @@ public abstract class AbstractJsInvokeService implements JsInvokeService { | @@ -112,9 +109,9 @@ public abstract class AbstractJsInvokeService implements JsInvokeService { | ||
112 | disableListInfo.incrementAndGet(); | 109 | disableListInfo.incrementAndGet(); |
113 | } | 110 | } |
114 | 111 | ||
115 | - private String generateJsScript(JsScriptType scriptType, String functionName, String scriptBody, String... argNames) { | ||
116 | - if (scriptType == JsScriptType.TCP_TRANSPORT_SCRIPT) { | ||
117 | - return YtTcpScriptFactory.generateRuleNodeScript(functionName, scriptBody, argNames); | 112 | + private String generateJsScript(YtScriptType scriptType, String functionName, String scriptBody, String... argNames) { |
113 | + if (scriptType == YtScriptType.TCP_TRANSPORT_SCRIPT) { | ||
114 | + return YtScriptFactory.generateRuleNodeScript(functionName, scriptBody, argNames); | ||
118 | 115 | ||
119 | } | 116 | } |
120 | throw new RuntimeException("No script factory implemented for scriptType: " + scriptType); | 117 | throw new RuntimeException("No script factory implemented for scriptType: " + scriptType); |
common/transport/transport-api/src/main/java/org/thingsboard/server/common/yunteng/script/NashornYtScriptInvokeService.java
renamed from
common/transport/tcp/src/main/java/org/thingsboard/server/transport/tcp/script/TcpNashornJsInvokeService.java
@@ -13,12 +13,14 @@ | @@ -13,12 +13,14 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.transport.tcp.script; | 16 | +package org.thingsboard.server.common.yunteng.script; |
17 | 17 | ||
18 | import lombok.extern.slf4j.Slf4j; | 18 | import lombok.extern.slf4j.Slf4j; |
19 | import org.springframework.beans.factory.annotation.Value; | 19 | import org.springframework.beans.factory.annotation.Value; |
20 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | 20 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
21 | import org.springframework.stereotype.Service; | 21 | import org.springframework.stereotype.Service; |
22 | +import org.thingsboard.server.common.yunteng.script.AbstractNashornYtScriptInvokeService; | ||
23 | +import org.thingsboard.server.common.yunteng.script.YtScriptExecutorService; | ||
22 | import org.thingsboard.server.queue.usagestats.TbApiUsageClient; | 24 | import org.thingsboard.server.queue.usagestats.TbApiUsageClient; |
23 | 25 | ||
24 | import java.util.concurrent.TimeUnit; | 26 | import java.util.concurrent.TimeUnit; |
@@ -27,7 +29,7 @@ import java.util.concurrent.TimeUnit; | @@ -27,7 +29,7 @@ import java.util.concurrent.TimeUnit; | ||
27 | @ConditionalOnProperty(prefix = "js", value = "evaluator", havingValue = "local", matchIfMissing = true) | 29 | @ConditionalOnProperty(prefix = "js", value = "evaluator", havingValue = "local", matchIfMissing = true) |
28 | @Service | 30 | @Service |
29 | public class | 31 | public class |
30 | -TcpNashornJsInvokeService extends AbstractNashornJsInvokeService { | 32 | +NashornYtScriptInvokeService extends AbstractNashornYtScriptInvokeService { |
31 | 33 | ||
32 | @Value("${js.local.use_js_sandbox}") | 34 | @Value("${js.local.use_js_sandbox}") |
33 | private boolean useJsSandbox; | 35 | private boolean useJsSandbox; |
@@ -44,7 +46,7 @@ TcpNashornJsInvokeService extends AbstractNashornJsInvokeService { | @@ -44,7 +46,7 @@ TcpNashornJsInvokeService extends AbstractNashornJsInvokeService { | ||
44 | @Value("${js.local.max_black_list_duration_sec:60}") | 46 | @Value("${js.local.max_black_list_duration_sec:60}") |
45 | private int maxBlackListDurationSec; | 47 | private int maxBlackListDurationSec; |
46 | 48 | ||
47 | - public TcpNashornJsInvokeService(TbApiUsageClient apiUsageClient, TcpJsExecutorService jsExecutor) { | 49 | + public NashornYtScriptInvokeService(TbApiUsageClient apiUsageClient, YtScriptExecutorService jsExecutor) { |
48 | super(apiUsageClient, jsExecutor); | 50 | super(apiUsageClient, jsExecutor); |
49 | } | 51 | } |
50 | 52 |
common/transport/transport-api/src/main/java/org/thingsboard/server/common/yunteng/script/RemoteJsRequestEncoder.java
renamed from
common/transport/tcp/src/main/java/org/thingsboard/server/transport/tcp/script/RemoteJsRequestEncoder.java
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.transport.tcp.script; | 16 | +package org.thingsboard.server.common.yunteng.script; |
17 | 17 | ||
18 | import com.google.protobuf.InvalidProtocolBufferException; | 18 | import com.google.protobuf.InvalidProtocolBufferException; |
19 | import com.google.protobuf.util.JsonFormat; | 19 | import com.google.protobuf.util.JsonFormat; |
common/transport/transport-api/src/main/java/org/thingsboard/server/common/yunteng/script/RemoteJsResponseDecoder.java
renamed from
common/transport/tcp/src/main/java/org/thingsboard/server/transport/tcp/script/RemoteJsResponseDecoder.java
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.transport.tcp.script; | 16 | +package org.thingsboard.server.common.yunteng.script; |
17 | 17 | ||
18 | import com.google.protobuf.util.JsonFormat; | 18 | import com.google.protobuf.util.JsonFormat; |
19 | import org.thingsboard.server.gen.js.JsInvokeProtos; | 19 | import org.thingsboard.server.gen.js.JsInvokeProtos; |
common/transport/transport-api/src/main/java/org/thingsboard/server/common/yunteng/script/YtRemoteJsInvokeService.java
renamed from
common/transport/tcp/src/main/java/org/thingsboard/server/transport/tcp/script/TcpRemoteJsInvokeService.java
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.transport.tcp.script; | 16 | +package org.thingsboard.server.common.yunteng.script; |
17 | 17 | ||
18 | import com.google.common.util.concurrent.FutureCallback; | 18 | import com.google.common.util.concurrent.FutureCallback; |
19 | import com.google.common.util.concurrent.Futures; | 19 | import com.google.common.util.concurrent.Futures; |
@@ -42,9 +42,9 @@ import java.util.concurrent.*; | @@ -42,9 +42,9 @@ import java.util.concurrent.*; | ||
42 | import java.util.concurrent.atomic.AtomicInteger; | 42 | import java.util.concurrent.atomic.AtomicInteger; |
43 | 43 | ||
44 | @Slf4j | 44 | @Slf4j |
45 | -@ConditionalOnExpression("'${js.evaluator:null}'=='remote' && ('${service.type:null}'=='monolith' || '${service.type:null}'=='tb-core' || '${service.type:null}'=='tb-rule-engine')") | 45 | +@ConditionalOnExpression("'${js.evaluator:null}'=='remote' && ('${service.type:null}'=='monolith' || '${service.type:null}'=='tb-core' || '${service.type:null}'=='tb-transport')") |
46 | @Service | 46 | @Service |
47 | -public class TcpRemoteJsInvokeService extends AbstractJsInvokeService { | 47 | +public class YtRemoteJsInvokeService extends AbstractYtScriptInvokeService { |
48 | 48 | ||
49 | @Value("${queue.js.max_eval_requests_timeout}") | 49 | @Value("${queue.js.max_eval_requests_timeout}") |
50 | private long maxEvalRequestsTimeout; | 50 | private long maxEvalRequestsTimeout; |
@@ -70,7 +70,7 @@ public class TcpRemoteJsInvokeService extends AbstractJsInvokeService { | @@ -70,7 +70,7 @@ public class TcpRemoteJsInvokeService extends AbstractJsInvokeService { | ||
70 | private final ExecutorService callbackExecutor = Executors.newFixedThreadPool( | 70 | private final ExecutorService callbackExecutor = Executors.newFixedThreadPool( |
71 | Runtime.getRuntime().availableProcessors(), ThingsBoardThreadFactory.forName("js-executor-remote-callback")); | 71 | Runtime.getRuntime().availableProcessors(), ThingsBoardThreadFactory.forName("js-executor-remote-callback")); |
72 | 72 | ||
73 | - public TcpRemoteJsInvokeService(TbApiUsageClient apiUsageClient) { | 73 | + public YtRemoteJsInvokeService(TbApiUsageClient apiUsageClient) { |
74 | super(); | 74 | super(); |
75 | } | 75 | } |
76 | 76 |
common/transport/transport-api/src/main/java/org/thingsboard/server/common/yunteng/script/YtScriptExecutorService.java
renamed from
common/transport/tcp/src/main/java/org/thingsboard/server/transport/tcp/script/TcpJsExecutorService.java
@@ -13,14 +13,14 @@ | @@ -13,14 +13,14 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.transport.tcp.script; | 16 | +package org.thingsboard.server.common.yunteng.script; |
17 | 17 | ||
18 | import org.springframework.beans.factory.annotation.Value; | 18 | import org.springframework.beans.factory.annotation.Value; |
19 | import org.springframework.stereotype.Component; | 19 | import org.springframework.stereotype.Component; |
20 | import org.thingsboard.common.util.AbstractListeningExecutor; | 20 | import org.thingsboard.common.util.AbstractListeningExecutor; |
21 | 21 | ||
22 | @Component | 22 | @Component |
23 | -public class TcpJsExecutorService extends AbstractListeningExecutor { | 23 | +public class YtScriptExecutorService extends AbstractListeningExecutor { |
24 | 24 | ||
25 | @Value("${actors.rule.js_thread_pool_size}") | 25 | @Value("${actors.rule.js_thread_pool_size}") |
26 | private int jsExecutorThreadPoolSize; | 26 | private int jsExecutorThreadPoolSize; |
common/transport/transport-api/src/main/java/org/thingsboard/server/common/yunteng/script/YtScriptFactory.java
renamed from
common/transport/tcp/src/main/java/org/thingsboard/server/transport/tcp/script/YtTcpScriptFactory.java
@@ -13,9 +13,9 @@ | @@ -13,9 +13,9 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.transport.tcp.script; | 16 | +package org.thingsboard.server.common.yunteng.script; |
17 | 17 | ||
18 | -public class YtTcpScriptFactory { | 18 | +public class YtScriptFactory { |
19 | 19 | ||
20 | public static final String MSG = "msg"; | 20 | public static final String MSG = "msg"; |
21 | 21 |
common/transport/transport-api/src/main/java/org/thingsboard/server/common/yunteng/script/YtScriptInvokeRequest.java
renamed from
common/transport/tcp/src/main/java/org/thingsboard/server/transport/tcp/script/JsInvokeRequest.java
@@ -13,14 +13,14 @@ | @@ -13,14 +13,14 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.transport.tcp.script; | 16 | +package org.thingsboard.server.common.yunteng.script; |
17 | 17 | ||
18 | import java.util.List; | 18 | import java.util.List; |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * Created by ashvayka on 25.09.18. | 21 | * Created by ashvayka on 25.09.18. |
22 | */ | 22 | */ |
23 | -public class JsInvokeRequest { | 23 | +public class YtScriptInvokeRequest { |
24 | 24 | ||
25 | private String scriptId; | 25 | private String scriptId; |
26 | private String scriptBody; | 26 | private String scriptBody; |
common/transport/transport-api/src/main/java/org/thingsboard/server/common/yunteng/script/YtScriptInvokeResponse.java
renamed from
common/transport/tcp/src/main/java/org/thingsboard/server/transport/tcp/script/JsInvokeResponse.java
@@ -13,14 +13,14 @@ | @@ -13,14 +13,14 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.transport.tcp.script; | 16 | +package org.thingsboard.server.common.yunteng.script; |
17 | 17 | ||
18 | import java.util.List; | 18 | import java.util.List; |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * Created by ashvayka on 25.09.18. | 21 | * Created by ashvayka on 25.09.18. |
22 | */ | 22 | */ |
23 | -public class JsInvokeResponse { | 23 | +public class YtScriptInvokeResponse { |
24 | 24 | ||
25 | private String scriptId; | 25 | private String scriptId; |
26 | private String scriptBody; | 26 | private String scriptBody; |
common/transport/transport-api/src/main/java/org/thingsboard/server/common/yunteng/script/YtScriptInvokeService.java
renamed from
common/transport/tcp/src/main/java/org/thingsboard/server/transport/tcp/script/JsInvokeService.java
@@ -13,17 +13,15 @@ | @@ -13,17 +13,15 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.transport.tcp.script; | 16 | +package org.thingsboard.server.common.yunteng.script; |
17 | 17 | ||
18 | import com.google.common.util.concurrent.ListenableFuture; | 18 | import com.google.common.util.concurrent.ListenableFuture; |
19 | -import org.thingsboard.server.common.data.id.CustomerId; | ||
20 | -import org.thingsboard.server.common.data.id.TenantId; | ||
21 | 19 | ||
22 | import java.util.UUID; | 20 | import java.util.UUID; |
23 | 21 | ||
24 | -public interface JsInvokeService { | 22 | +public interface YtScriptInvokeService { |
25 | 23 | ||
26 | - ListenableFuture<UUID> eval(JsScriptType scriptType, String scriptBody, String... argNames); | 24 | + ListenableFuture<UUID> eval(YtScriptType scriptType, String scriptBody, String... argNames); |
27 | 25 | ||
28 | ListenableFuture<Object> invokeFunction(UUID scriptId, Object... args); | 26 | ListenableFuture<Object> invokeFunction(UUID scriptId, Object... args); |
29 | 27 |
common/transport/transport-api/src/main/java/org/thingsboard/server/common/yunteng/script/YtScriptStatCallback.java
renamed from
common/transport/tcp/src/main/java/org/thingsboard/server/transport/tcp/script/JsStatCallback.java
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.transport.tcp.script; | 16 | +package org.thingsboard.server.common.yunteng.script; |
17 | 17 | ||
18 | import com.google.common.util.concurrent.FutureCallback; | 18 | import com.google.common.util.concurrent.FutureCallback; |
19 | import lombok.AllArgsConstructor; | 19 | import lombok.AllArgsConstructor; |
@@ -23,7 +23,7 @@ import java.util.concurrent.TimeoutException; | @@ -23,7 +23,7 @@ import java.util.concurrent.TimeoutException; | ||
23 | import java.util.concurrent.atomic.AtomicInteger; | 23 | import java.util.concurrent.atomic.AtomicInteger; |
24 | 24 | ||
25 | @AllArgsConstructor | 25 | @AllArgsConstructor |
26 | -public class JsStatCallback<T> implements FutureCallback<T> { | 26 | +public class YtScriptStatCallback<T> implements FutureCallback<T> { |
27 | 27 | ||
28 | private final AtomicInteger jsSuccessMsgs; | 28 | private final AtomicInteger jsSuccessMsgs; |
29 | private final AtomicInteger jsTimeoutMsgs; | 29 | private final AtomicInteger jsTimeoutMsgs; |
common/transport/transport-api/src/main/java/org/thingsboard/server/common/yunteng/script/YtScriptType.java
renamed from
common/transport/tcp/src/main/java/org/thingsboard/server/transport/tcp/script/JsScriptType.java
@@ -13,9 +13,8 @@ | @@ -13,9 +13,8 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.transport.tcp.script; | 16 | +package org.thingsboard.server.common.yunteng.script; |
17 | 17 | ||
18 | -public enum JsScriptType { | ||
19 | - RULE_NODE_SCRIPT, | 18 | +public enum YtScriptType { |
20 | TCP_TRANSPORT_SCRIPT | 19 | TCP_TRANSPORT_SCRIPT |
21 | } | 20 | } |