Commit 14f8e58df064615f1d272ed6aa391b4a5752f5c5

Authored by Andrew Shvayka
1 parent 5aac13b5

Implementation of Generator node and improvements

Showing 29 changed files with 237 additions and 28 deletions
... ... @@ -15,9 +15,12 @@
15 15 */
16 16 package org.thingsboard.server.actors.ruleChain;
17 17
  18 +import akka.actor.ActorContext;
  19 +import akka.actor.ActorRef;
18 20 import org.thingsboard.rule.engine.api.ListeningExecutor;
19 21 import org.thingsboard.rule.engine.api.TbContext;
20 22 import org.thingsboard.server.actors.ActorSystemContext;
  23 +import org.thingsboard.server.common.data.id.RuleNodeId;
21 24 import org.thingsboard.server.common.msg.TbMsg;
22 25 import org.thingsboard.server.common.msg.cluster.ServerAddress;
23 26 import org.thingsboard.server.dao.alarm.AlarmService;
... ... @@ -30,8 +33,10 @@ import org.thingsboard.server.dao.relation.RelationService;
30 33 import org.thingsboard.server.dao.rule.RuleChainService;
31 34 import org.thingsboard.server.dao.timeseries.TimeseriesService;
32 35 import org.thingsboard.server.dao.user.UserService;
  36 +import scala.concurrent.duration.Duration;
33 37
34 38 import java.util.Set;
  39 +import java.util.concurrent.TimeUnit;
35 40
36 41 /**
37 42 * Created by ashvayka on 19.03.18.
... ... @@ -61,7 +66,12 @@ class DefaultTbContext implements TbContext {
61 66
62 67 @Override
63 68 public void tellSelf(TbMsg msg, long delayMs) {
64   - throw new RuntimeException("Not Implemented!");
  69 + //TODO: add persistence layer
  70 + scheduleMsgWithDelay(new RuleNodeToSelfMsg(msg), delayMs, nodeCtx.getSelfActor());
  71 + }
  72 +
  73 + private void scheduleMsgWithDelay(Object msg, long delayInMs, ActorRef target) {
  74 + mainCtx.getScheduler().scheduleOnce(Duration.create(delayInMs, TimeUnit.MILLISECONDS), target, msg, mainCtx.getActorSystem().dispatcher(), nodeCtx.getSelfActor());
65 75 }
66 76
67 77 @Override
... ... @@ -93,6 +103,11 @@ class DefaultTbContext implements TbContext {
93 103 }
94 104
95 105 @Override
  106 + public RuleNodeId getSelfId() {
  107 + return nodeCtx.getSelf().getId();
  108 + }
  109 +
  110 + @Override
96 111 public void tellNext(TbMsg msg, Set<String> relationTypes) {
97 112 relationTypes.forEach(type -> tellNext(msg, type));
98 113 }
... ...
... ... @@ -47,12 +47,25 @@ public class RuleNodeActor extends ComponentActor<RuleNodeId, RuleNodeActorMessa
47 47 case RULE_TO_SELF_ERROR_MSG:
48 48 onRuleNodeToSelfErrorMsg((RuleNodeToSelfErrorMsg) msg);
49 49 break;
  50 + case RULE_TO_SELF_MSG:
  51 + onRuleNodeToSelfMsg((RuleNodeToSelfMsg) msg);
  52 + break;
50 53 default:
51 54 return false;
52 55 }
53 56 return true;
54 57 }
55 58
  59 + private void onRuleNodeToSelfMsg(RuleNodeToSelfMsg msg) {
  60 + logger.debug("[{}] Going to process rule msg: {}", id, msg.getMsg());
  61 + try {
  62 + processor.onRuleToSelfMsg(msg);
  63 + increaseMessagesProcessedCount();
  64 + } catch (Exception e) {
  65 + logAndPersist("onRuleMsg", e);
  66 + }
  67 + }
  68 +
56 69 private void onRuleChainToRuleNodeMsg(RuleChainToRuleNodeMsg msg) {
57 70 logger.debug("[{}] Going to process rule msg: {}", id, msg.getMsg());
58 71 try {
... ...
... ... @@ -18,9 +18,10 @@ package org.thingsboard.server.actors.ruleChain;
18 18 import akka.actor.ActorContext;
19 19 import akka.actor.ActorRef;
20 20 import akka.event.LoggingAdapter;
  21 +import org.thingsboard.rule.engine.api.TbContext;
21 22 import org.thingsboard.rule.engine.api.TbNode;
22 23 import org.thingsboard.rule.engine.api.TbNodeConfiguration;
23   -import org.thingsboard.rule.engine.api.TbNodeState;
  24 +import org.thingsboard.rule.engine.api.TbNodeException;
24 25 import org.thingsboard.server.actors.ActorSystemContext;
25 26 import org.thingsboard.server.actors.shared.ComponentMsgProcessor;
26 27 import org.thingsboard.server.common.data.id.RuleChainId;
... ... @@ -31,6 +32,8 @@ import org.thingsboard.server.common.data.rule.RuleNode;
31 32 import org.thingsboard.server.common.msg.cluster.ClusterEventMsg;
32 33 import org.thingsboard.server.dao.rule.RuleChainService;
33 34
  35 +import java.util.concurrent.ExecutionException;
  36 +
34 37 /**
35 38 * @author Andrew Shvayka
36 39 */
... ... @@ -41,6 +44,7 @@ public class RuleNodeActorMessageProcessor extends ComponentMsgProcessor<RuleNod
41 44 private final RuleChainService service;
42 45 private RuleNode ruleNode;
43 46 private TbNode tbNode;
  47 + private TbContext defaultCtx;
44 48
45 49 RuleNodeActorMessageProcessor(TenantId tenantId, RuleChainId ruleChainId, RuleNodeId ruleNodeId, ActorSystemContext systemContext
46 50 , LoggingAdapter logger, ActorRef parent, ActorRef self) {
... ... @@ -49,6 +53,7 @@ public class RuleNodeActorMessageProcessor extends ComponentMsgProcessor<RuleNod
49 53 this.self = self;
50 54 this.service = systemContext.getRuleChainService();
51 55 this.ruleNode = systemContext.getRuleChainService().findRuleNodeById(entityId);
  56 + this.defaultCtx = new DefaultTbContext(systemContext, new RuleNodeCtx(tenantId, parent, self, ruleNode));
52 57 }
53 58
54 59 @Override
... ... @@ -80,6 +85,14 @@ public class RuleNodeActorMessageProcessor extends ComponentMsgProcessor<RuleNod
80 85
81 86 }
82 87
  88 + public void onRuleToSelfMsg(RuleNodeToSelfMsg msg) throws Exception {
  89 + checkActive();
  90 + if (ruleNode.isDebugMode()) {
  91 + systemContext.persistDebugInput(tenantId, entityId, msg.getMsg());
  92 + }
  93 + tbNode.onMsg(defaultCtx, msg.getMsg());
  94 + }
  95 +
83 96 void onRuleChainToRuleNodeMsg(RuleChainToRuleNodeMsg msg) throws Exception {
84 97 checkActive();
85 98 if (ruleNode.isDebugMode()) {
... ... @@ -91,9 +104,8 @@ public class RuleNodeActorMessageProcessor extends ComponentMsgProcessor<RuleNod
91 104 private TbNode initComponent(RuleNode ruleNode) throws Exception {
92 105 Class<?> componentClazz = Class.forName(ruleNode.getType());
93 106 TbNode tbNode = (TbNode) (componentClazz.newInstance());
94   - tbNode.init(new TbNodeConfiguration(ruleNode.getConfiguration()), new TbNodeState());
  107 + tbNode.init(defaultCtx, new TbNodeConfiguration(ruleNode.getConfiguration()));
95 108 return tbNode;
96 109 }
97 110
98   -
99 111 }
... ...
  1 +/**
  2 + * Copyright © 2016-2018 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.actors.ruleChain;
  17 +
  18 +import lombok.Data;
  19 +import org.thingsboard.server.common.data.id.RuleNodeId;
  20 +import org.thingsboard.server.common.msg.MsgType;
  21 +import org.thingsboard.server.common.msg.TbActorMsg;
  22 +import org.thingsboard.server.common.msg.TbMsg;
  23 +
  24 +/**
  25 + * Created by ashvayka on 19.03.18.
  26 + */
  27 +@Data
  28 +final class RuleNodeToSelfMsg implements TbActorMsg {
  29 +
  30 + private final TbMsg msg;
  31 +
  32 + @Override
  33 + public MsgType getMsgType() {
  34 + return MsgType.RULE_TO_SELF_MSG;
  35 + }
  36 +
  37 +}
... ...
... ... @@ -54,4 +54,9 @@ public enum MsgType {
54 54 */
55 55 RULE_TO_SELF_ERROR_MSG,
56 56
  57 + /**
  58 + * Message that is sent by RuleActor implementation to RuleActor itself to process the message.
  59 + */
  60 + RULE_TO_SELF_MSG,
  61 +
57 62 }
... ...
... ... @@ -15,8 +15,8 @@
15 15 */
16 16 package org.thingsboard.rule.engine.api;
17 17
18   -public interface NodeConfiguration {
  18 +public interface NodeConfiguration<T extends NodeConfiguration> {
19 19
20   - NodeConfiguration defaultConfiguration();
  20 + T defaultConfiguration();
21 21
22 22 }
... ...
... ... @@ -15,6 +15,7 @@
15 15 */
16 16 package org.thingsboard.rule.engine.api;
17 17
  18 +import org.thingsboard.server.common.data.id.RuleNodeId;
18 19 import org.thingsboard.server.common.msg.TbMsg;
19 20 import org.thingsboard.server.common.msg.cluster.ServerAddress;
20 21 import org.thingsboard.server.dao.alarm.AlarmService;
... ... @@ -55,6 +56,8 @@ public interface TbContext {
55 56
56 57 void tellError(TbMsg msg, Throwable th);
57 58
  59 + RuleNodeId getSelfId();
  60 +
58 61 AttributesService getAttributesService();
59 62
60 63 CustomerService getCustomerService();
... ...
... ... @@ -24,7 +24,7 @@ import java.util.concurrent.ExecutionException;
24 24 */
25 25 public interface TbNode {
26 26
27   - void init(TbNodeConfiguration configuration, TbNodeState state) throws TbNodeException;
  27 + void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException;
28 28
29 29 void onMsg(TbContext ctx, TbMsg msg) throws ExecutionException, InterruptedException, TbNodeException;
30 30
... ...
  1 +/**
  2 + * Copyright © 2016-2018 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.rule.engine.debug;
  17 +
  18 +import com.datastax.driver.core.utils.UUIDs;
  19 +import lombok.extern.slf4j.Slf4j;
  20 +import org.thingsboard.rule.engine.TbNodeUtils;
  21 +import org.thingsboard.rule.engine.api.ListeningExecutor;
  22 +import org.thingsboard.rule.engine.api.RuleNode;
  23 +import org.thingsboard.rule.engine.api.TbContext;
  24 +import org.thingsboard.rule.engine.api.TbNode;
  25 +import org.thingsboard.rule.engine.api.TbNodeConfiguration;
  26 +import org.thingsboard.rule.engine.api.TbNodeException;
  27 +import org.thingsboard.rule.engine.filter.TbJsFilterNodeConfiguration;
  28 +import org.thingsboard.rule.engine.js.NashornJsEngine;
  29 +import org.thingsboard.server.common.data.plugin.ComponentType;
  30 +import org.thingsboard.server.common.msg.TbMsg;
  31 +import org.thingsboard.server.common.msg.TbMsgMetaData;
  32 +
  33 +import javax.script.Bindings;
  34 +
  35 +import java.nio.charset.StandardCharsets;
  36 +import java.util.concurrent.TimeUnit;
  37 +
  38 +import static org.thingsboard.rule.engine.DonAsynchron.withCallback;
  39 +
  40 +@Slf4j
  41 +@RuleNode(
  42 + type = ComponentType.ACTION,
  43 + name = "generator",
  44 + configClazz = TbMsgGeneratorNodeConfiguration.class,
  45 + nodeDescription = "Periodically generates messages",
  46 + nodeDetails = "Generates messages with configurable period. ",
  47 + inEnabled = false
  48 +)
  49 +
  50 +public class TbMsgGeneratorNode implements TbNode {
  51 +
  52 + public static final String TB_MSG_GENERATOR_NODE_MSG = "TbMsgGeneratorNodeMsg";
  53 +
  54 + private TbMsgGeneratorNodeConfiguration config;
  55 + private long delay;
  56 +
  57 + @Override
  58 + public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException {
  59 + this.config = TbNodeUtils.convert(configuration, TbMsgGeneratorNodeConfiguration.class);
  60 + this.delay = TimeUnit.SECONDS.toMillis(config.getPeriodInSeconds());
  61 + ctx.tellSelf(newTickMsg(ctx), delay);
  62 + }
  63 +
  64 + @Override
  65 + public void onMsg(TbContext ctx, TbMsg msg) {
  66 + if (msg.getType().equals(TB_MSG_GENERATOR_NODE_MSG)) {
  67 + TbMsgMetaData metaData = new TbMsgMetaData();
  68 + if (config.getMsgMetaData() != null) {
  69 + config.getMsgMetaData().forEach(metaData::putValue);
  70 + }
  71 + ctx.tellNext(new TbMsg(UUIDs.timeBased(), config.getMsgType(), ctx.getSelfId(), metaData, config.getMsgBody().getBytes(StandardCharsets.UTF_8)));
  72 + ctx.tellSelf(newTickMsg(ctx), delay);
  73 + }
  74 + }
  75 +
  76 + private TbMsg newTickMsg(TbContext ctx) {
  77 + return new TbMsg(UUIDs.timeBased(), TB_MSG_GENERATOR_NODE_MSG, ctx.getSelfId(), new TbMsgMetaData(), new byte[]{});
  78 + }
  79 +
  80 + @Override
  81 + public void destroy() {
  82 + }
  83 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2018 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.rule.engine.debug;
  17 +
  18 +import lombok.Data;
  19 +import org.thingsboard.rule.engine.api.NodeConfiguration;
  20 +import java.util.Map;
  21 +
  22 +@Data
  23 +public class TbMsgGeneratorNodeConfiguration implements NodeConfiguration<TbMsgGeneratorNodeConfiguration> {
  24 +
  25 + private int msgCount;
  26 + private int periodInSeconds;
  27 + private String msgType;
  28 + private String msgBody;
  29 + private Map<String, String> msgMetaData;
  30 +
  31 + @Override
  32 + public TbMsgGeneratorNodeConfiguration defaultConfiguration() {
  33 + TbMsgGeneratorNodeConfiguration configuration = new TbMsgGeneratorNodeConfiguration();
  34 + configuration.setMsgCount(0);
  35 + configuration.setPeriodInSeconds(1);
  36 + configuration.setMsgType("DebugMsg");
  37 + configuration.setMsgBody("{}");
  38 + return configuration;
  39 + }
  40 +}
... ...
... ... @@ -29,7 +29,7 @@ import static org.thingsboard.rule.engine.DonAsynchron.withCallback;
29 29 @Slf4j
30 30 @RuleNode(
31 31 type = ComponentType.FILTER,
32   - name = "script", relationTypes = {"True", "False", "Failure"},
  32 + name = "script", relationTypes = {"True", "False"},
33 33 configClazz = TbJsFilterNodeConfiguration.class,
34 34 nodeDescription = "Filter incoming messages using JS script",
35 35 nodeDetails = "Evaluate incoming Message with configured JS condition. " +
... ... @@ -45,7 +45,7 @@ public class TbJsFilterNode implements TbNode {
45 45 private NashornJsEngine jsEngine;
46 46
47 47 @Override
48   - public void init(TbNodeConfiguration configuration, TbNodeState state) throws TbNodeException {
  48 + public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException {
49 49 this.config = TbNodeUtils.convert(configuration, TbJsFilterNodeConfiguration.class);
50 50 this.jsEngine = new NashornJsEngine(config.getJsScript(), "Filter");
51 51 }
... ...
... ... @@ -19,7 +19,7 @@ import lombok.Data;
19 19 import org.thingsboard.rule.engine.api.NodeConfiguration;
20 20
21 21 @Data
22   -public class TbJsFilterNodeConfiguration implements NodeConfiguration {
  22 +public class TbJsFilterNodeConfiguration implements NodeConfiguration<TbJsFilterNodeConfiguration> {
23 23
24 24 private String jsScript;
25 25
... ...
... ... @@ -45,7 +45,7 @@ public class TbJsSwitchNode implements TbNode {
45 45 private NashornJsEngine jsEngine;
46 46
47 47 @Override
48   - public void init(TbNodeConfiguration configuration, TbNodeState state) throws TbNodeException {
  48 + public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException {
49 49 this.config = TbNodeUtils.convert(configuration, TbJsSwitchNodeConfiguration.class);
50 50 this.jsEngine = new NashornJsEngine(config.getJsScript(), "Switch");
51 51 }
... ...
... ... @@ -22,7 +22,7 @@ import org.thingsboard.rule.engine.api.NodeConfiguration;
22 22 import java.util.Set;
23 23
24 24 @Data
25   -public class TbJsSwitchNodeConfiguration implements NodeConfiguration {
  25 +public class TbJsSwitchNodeConfiguration implements NodeConfiguration<TbJsSwitchNodeConfiguration> {
26 26
27 27 private String jsScript;
28 28
... ...
... ... @@ -29,6 +29,7 @@ import org.thingsboard.server.common.msg.TbMsg;
29 29 type = ComponentType.FILTER,
30 30 name = "message type",
31 31 configClazz = TbMsgTypeFilterNodeConfiguration.class,
  32 + relationTypes = {"True", "False"},
32 33 nodeDescription = "Filter incoming messages by Message Type",
33 34 nodeDetails = "Evaluate incoming Message with configured JS condition. " +
34 35 "If incoming MessageType is expected - send Message via <b>Success</b> chain, otherwise <b>Failure</b> chain is used.",
... ... @@ -39,7 +40,7 @@ public class TbMsgTypeFilterNode implements TbNode {
39 40 TbMsgTypeFilterNodeConfiguration config;
40 41
41 42 @Override
42   - public void init(TbNodeConfiguration configuration, TbNodeState state) throws TbNodeException {
  43 + public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException {
43 44 this.config = TbNodeUtils.convert(configuration, TbMsgTypeFilterNodeConfiguration.class);
44 45 }
45 46
... ...
... ... @@ -26,7 +26,7 @@ import java.util.List;
26 26 * Created by ashvayka on 19.01.18.
27 27 */
28 28 @Data
29   -public class TbMsgTypeFilterNodeConfiguration implements NodeConfiguration {
  29 +public class TbMsgTypeFilterNodeConfiguration implements NodeConfiguration<TbMsgTypeFilterNodeConfiguration> {
30 30
31 31 private List<String> messageTypes;
32 32
... ...
... ... @@ -37,7 +37,7 @@ public abstract class TbEntityGetAttrNode<T extends EntityId> implements TbNode
37 37 private TbGetEntityAttrNodeConfiguration config;
38 38
39 39 @Override
40   - public void init(TbNodeConfiguration configuration, TbNodeState state) throws TbNodeException {
  40 + public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException {
41 41 this.config = TbNodeUtils.convert(configuration, TbGetEntityAttrNodeConfiguration.class);
42 42 }
43 43
... ...
... ... @@ -49,7 +49,7 @@ public class TbGetAttributesNode implements TbNode {
49 49 private TbGetAttributesNodeConfiguration config;
50 50
51 51 @Override
52   - public void init(TbNodeConfiguration configuration, TbNodeState state) throws TbNodeException {
  52 + public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException {
53 53 this.config = TbNodeUtils.convert(configuration, TbGetAttributesNodeConfiguration.class);
54 54 }
55 55
... ...
... ... @@ -25,7 +25,7 @@ import java.util.List;
25 25 * Created by ashvayka on 19.01.18.
26 26 */
27 27 @Data
28   -public class TbGetAttributesNodeConfiguration implements NodeConfiguration {
  28 +public class TbGetAttributesNodeConfiguration implements NodeConfiguration<TbGetAttributesNodeConfiguration> {
29 29
30 30 private List<String> clientAttributeNames;
31 31 private List<String> sharedAttributeNames;
... ...
... ... @@ -23,7 +23,7 @@ import java.util.Map;
23 23 import java.util.Optional;
24 24
25 25 @Data
26   -public class TbGetEntityAttrNodeConfiguration implements NodeConfiguration {
  26 +public class TbGetEntityAttrNodeConfiguration implements NodeConfiguration<TbGetEntityAttrNodeConfiguration> {
27 27
28 28 private Map<String, String> attrMapping;
29 29 private boolean isTelemetry = false;
... ...
... ... @@ -38,7 +38,7 @@ public class TbGetRelatedAttributeNode extends TbEntityGetAttrNode<EntityId> {
38 38 private TbGetRelatedAttrNodeConfiguration config;
39 39
40 40 @Override
41   - public void init(TbNodeConfiguration configuration, TbNodeState state) throws TbNodeException {
  41 + public void init(TbContext context, TbNodeConfiguration configuration) throws TbNodeException {
42 42 this.config = TbNodeUtils.convert(configuration, TbGetRelatedAttrNodeConfiguration.class);
43 43 setConfig(config);
44 44 }
... ...
... ... @@ -32,7 +32,7 @@ public abstract class TbAbstractTransformNode implements TbNode {
32 32 private TbTransformNodeConfiguration config;
33 33
34 34 @Override
35   - public void init(TbNodeConfiguration configuration, TbNodeState state) throws TbNodeException {
  35 + public void init(TbContext context, TbNodeConfiguration configuration) throws TbNodeException {
36 36 this.config = TbNodeUtils.convert(configuration, TbTransformNodeConfiguration.class);
37 37 }
38 38
... ...
... ... @@ -49,7 +49,7 @@ public class TbChangeOriginatorNode extends TbAbstractTransformNode {
49 49 private TbChangeOriginatorNodeConfiguration config;
50 50
51 51 @Override
52   - public void init(TbNodeConfiguration configuration, TbNodeState state) throws TbNodeException {
  52 + public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException {
53 53 this.config = TbNodeUtils.convert(configuration, TbChangeOriginatorNodeConfiguration.class);
54 54 validateConfig(config);
55 55 setConfig(config);
... ...
... ... @@ -38,7 +38,7 @@ public class TbTransformMsgNode extends TbAbstractTransformNode {
38 38 private NashornJsEngine jsEngine;
39 39
40 40 @Override
41   - public void init(TbNodeConfiguration configuration, TbNodeState state) throws TbNodeException {
  41 + public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException {
42 42 this.config = TbNodeUtils.convert(configuration, TbTransformMsgNodeConfiguration.class);
43 43 this.jsEngine = new NashornJsEngine(config.getJsScript(), "Transform");
44 44 setConfig(config);
... ...
... ... @@ -144,7 +144,7 @@ public class TbJsFilterNodeTest {
144 144 TbNodeConfiguration nodeConfiguration = new TbNodeConfiguration(mapper.valueToTree(config));
145 145
146 146 node = new TbJsFilterNode();
147   - node.init(nodeConfiguration, null);
  147 + node.init(null, nodeConfiguration);
148 148 }
149 149
150 150 private void mockJsExecutor() {
... ...
... ... @@ -107,7 +107,7 @@ public class TbJsSwitchNodeTest {
107 107 TbNodeConfiguration nodeConfiguration = new TbNodeConfiguration(mapper.valueToTree(config));
108 108
109 109 node = new TbJsSwitchNode();
110   - node.init(nodeConfiguration, null);
  110 + node.init(null, nodeConfiguration);
111 111 }
112 112
113 113 private void mockJsExecutor() {
... ...
... ... @@ -88,7 +88,7 @@ public class TbGetCustomerAttributeNodeTest {
88 88 TbNodeConfiguration nodeConfiguration = new TbNodeConfiguration(mapper.valueToTree(config));
89 89
90 90 node = new TbGetCustomerAttributeNode();
91   - node.init(nodeConfiguration, null);
  91 + node.init(null, nodeConfiguration);
92 92 }
93 93
94 94 @Test
... ... @@ -226,7 +226,7 @@ public class TbGetCustomerAttributeNodeTest {
226 226 TbNodeConfiguration nodeConfiguration = new TbNodeConfiguration(mapper.valueToTree(config));
227 227
228 228 node = new TbGetCustomerAttributeNode();
229   - node.init(nodeConfiguration, null);
  229 + node.init(null, nodeConfiguration);
230 230
231 231
232 232 DeviceId deviceId = new DeviceId(UUIDs.timeBased());
... ...
... ... @@ -119,6 +119,6 @@ public class TbChangeOriginatorNodeTest {
119 119 TbNodeConfiguration nodeConfiguration = new TbNodeConfiguration(mapper.valueToTree(config));
120 120
121 121 node = new TbChangeOriginatorNode();
122   - node.init(nodeConfiguration, null);
  122 + node.init(null, nodeConfiguration);
123 123 }
124 124 }
\ No newline at end of file
... ...
... ... @@ -114,7 +114,7 @@ public class TbTransformMsgNodeTest {
114 114 TbNodeConfiguration nodeConfiguration = new TbNodeConfiguration(mapper.valueToTree(config));
115 115
116 116 node = new TbTransformMsgNode();
117   - node.init(nodeConfiguration, null);
  117 + node.init(null, nodeConfiguration);
118 118 }
119 119
120 120 private void mockJsExecutor() {
... ...