Browse Source
Merge pull request #8142 from smatvienko-tb/fix/InvokeService_callback_executor
[3.5] ScriptInvokeService - shutdown executors on application exit
pull/8150/head
Andrew Shvayka
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
10 additions and
2 deletions
-
common/script/remote-js-client/src/main/java/org/thingsboard/server/service/script/RemoteJsInvokeService.java
-
common/script/script-api/src/main/java/org/thingsboard/script/api/js/NashornJsInvokeService.java
-
common/script/script-api/src/main/java/org/thingsboard/script/api/tbel/DefaultTbelInvokeService.java
|
|
|
@ -109,17 +109,20 @@ public class RemoteJsInvokeService extends AbstractJsInvokeService { |
|
|
|
private final Lock scriptsLock = new ReentrantLock(); |
|
|
|
|
|
|
|
@PostConstruct |
|
|
|
@Override |
|
|
|
public void init() { |
|
|
|
super.init(); |
|
|
|
requestTemplate.init(); |
|
|
|
} |
|
|
|
|
|
|
|
@PreDestroy |
|
|
|
public void destroy() { |
|
|
|
@Override |
|
|
|
public void stop() { |
|
|
|
super.stop(); |
|
|
|
if (requestTemplate != null) { |
|
|
|
requestTemplate.stop(); |
|
|
|
} |
|
|
|
callbackExecutor.shutdownNow(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
@ -104,6 +104,7 @@ public class NashornJsInvokeService extends AbstractJsInvokeService { |
|
|
|
} |
|
|
|
|
|
|
|
@PostConstruct |
|
|
|
@Override |
|
|
|
public void init() { |
|
|
|
super.init(); |
|
|
|
jsExecutor = MoreExecutors.listeningDecorator(Executors.newWorkStealingPool(jsExecutorThreadPoolSize)); |
|
|
|
@ -122,6 +123,7 @@ public class NashornJsInvokeService extends AbstractJsInvokeService { |
|
|
|
} |
|
|
|
|
|
|
|
@PreDestroy |
|
|
|
@Override |
|
|
|
public void stop() { |
|
|
|
super.stop(); |
|
|
|
if (monitorExecutorService != null) { |
|
|
|
|
|
|
|
@ -119,6 +119,7 @@ public class DefaultTbelInvokeService extends AbstractScriptInvokeService implem |
|
|
|
|
|
|
|
@SneakyThrows |
|
|
|
@PostConstruct |
|
|
|
@Override |
|
|
|
public void init() { |
|
|
|
super.init(); |
|
|
|
OptimizerFactory.setDefaultOptimizer(OptimizerFactory.SAFE_REFLECTIVE); |
|
|
|
@ -142,7 +143,9 @@ public class DefaultTbelInvokeService extends AbstractScriptInvokeService implem |
|
|
|
} |
|
|
|
|
|
|
|
@PreDestroy |
|
|
|
public void destroy() { |
|
|
|
@Override |
|
|
|
public void stop() { |
|
|
|
super.stop(); |
|
|
|
if (executor != null) { |
|
|
|
executor.shutdownNow(); |
|
|
|
} |
|
|
|
|