Showing
31 changed files
with
143 additions
and
124 deletions
... | ... | @@ -23,7 +23,6 @@ import com.google.common.util.concurrent.FutureCallback; |
23 | 23 | import com.google.common.util.concurrent.Futures; |
24 | 24 | import com.google.common.util.concurrent.ListenableFuture; |
25 | 25 | import com.google.gson.Gson; |
26 | -import com.google.gson.JsonArray; | |
27 | 26 | import com.google.gson.JsonObject; |
28 | 27 | import com.google.gson.JsonParser; |
29 | 28 | import org.thingsboard.server.actors.ActorSystemContext; |
... | ... | @@ -47,7 +46,7 @@ import org.thingsboard.server.common.msg.core.AttributesUpdateRequest; |
47 | 46 | import org.thingsboard.server.common.msg.core.BasicCommandAckResponse; |
48 | 47 | import org.thingsboard.server.common.msg.core.BasicGetAttributesResponse; |
49 | 48 | import org.thingsboard.server.common.msg.core.BasicStatusCodeResponse; |
50 | -import org.thingsboard.server.common.msg.core.BasicToDeviceSessionActorMsg; | |
49 | +import org.thingsboard.server.common.msg.core.BasicActorSystemToDeviceSessionActorMsg; | |
51 | 50 | import org.thingsboard.server.common.msg.core.GetAttributesRequest; |
52 | 51 | import org.thingsboard.server.common.msg.core.RuleEngineError; |
53 | 52 | import org.thingsboard.server.common.msg.core.RuleEngineErrorMsg; |
... | ... | @@ -57,13 +56,12 @@ import org.thingsboard.server.common.msg.core.SessionOpenMsg; |
57 | 56 | import org.thingsboard.server.common.msg.core.TelemetryUploadRequest; |
58 | 57 | import org.thingsboard.server.common.msg.core.ToDeviceRpcRequestMsg; |
59 | 58 | import org.thingsboard.server.common.msg.core.ToDeviceRpcResponseMsg; |
60 | -import org.thingsboard.server.common.msg.core.ToDeviceSessionActorMsg; | |
59 | +import org.thingsboard.server.common.msg.core.ActorSystemToDeviceSessionActorMsg; | |
61 | 60 | import org.thingsboard.server.common.msg.core.ToServerRpcRequestMsg; |
62 | 61 | import org.thingsboard.server.common.msg.device.DeviceToDeviceActorMsg; |
63 | 62 | import org.thingsboard.server.common.msg.kv.BasicAttributeKVMsg; |
64 | 63 | import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequest; |
65 | 64 | import org.thingsboard.server.common.msg.session.FromDeviceMsg; |
66 | -import org.thingsboard.server.common.msg.session.FromDeviceRequestMsg; | |
67 | 65 | import org.thingsboard.server.common.msg.session.SessionMsgType; |
68 | 66 | import org.thingsboard.server.common.msg.session.SessionType; |
69 | 67 | import org.thingsboard.server.common.msg.session.ToDeviceMsg; |
... | ... | @@ -74,7 +72,6 @@ import org.thingsboard.server.extensions.api.device.DeviceAttributesEventNotific |
74 | 72 | import org.thingsboard.server.extensions.api.device.DeviceNameOrTypeUpdateMsg; |
75 | 73 | import org.thingsboard.server.extensions.api.plugins.msg.FromDeviceRpcResponse; |
76 | 74 | import org.thingsboard.server.extensions.api.plugins.msg.RpcError; |
77 | -import org.thingsboard.server.gen.cluster.ClusterAPIProtos; | |
78 | 75 | import org.thingsboard.server.service.rpc.ToDeviceRpcRequestActorMsg; |
79 | 76 | import org.thingsboard.server.service.rpc.ToServerRpcResponseActorMsg; |
80 | 77 | |
... | ... | @@ -156,7 +153,7 @@ public class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcesso |
156 | 153 | boolean sent = rpcSubscriptions.size() > 0; |
157 | 154 | Set<SessionId> syncSessionSet = new HashSet<>(); |
158 | 155 | rpcSubscriptions.entrySet().forEach(sub -> { |
159 | - ToDeviceSessionActorMsg response = new BasicToDeviceSessionActorMsg(rpcRequest, sub.getKey()); | |
156 | + ActorSystemToDeviceSessionActorMsg response = new BasicActorSystemToDeviceSessionActorMsg(rpcRequest, sub.getKey()); | |
160 | 157 | sendMsgToSessionActor(response, sub.getValue().getServer()); |
161 | 158 | if (SessionType.SYNC == sub.getValue().getType()) { |
162 | 159 | syncSessionSet.add(sub.getKey()); |
... | ... | @@ -198,7 +195,7 @@ public class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcesso |
198 | 195 | if (data != null) { |
199 | 196 | logger.debug("[{}] Queue put [{}] timeout detected!", deviceId, msg.getId()); |
200 | 197 | ToDeviceMsg toDeviceMsg = new RuleEngineErrorMsg(data.getSessionMsgType(), RuleEngineError.QUEUE_PUT_TIMEOUT); |
201 | - sendMsgToSessionActor(new BasicToDeviceSessionActorMsg(toDeviceMsg, data.getSessionId()), data.getServerAddress()); | |
198 | + sendMsgToSessionActor(new BasicActorSystemToDeviceSessionActorMsg(toDeviceMsg, data.getSessionId()), data.getServerAddress()); | |
202 | 199 | } |
203 | 200 | } |
204 | 201 | |
... | ... | @@ -210,7 +207,7 @@ public class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcesso |
210 | 207 | logger.debug("[{}] Queue put [{}] ack detected. Remaining acks: {}!", deviceId, msg.getId(), remainingAcks); |
211 | 208 | if (remainingAcks == 0) { |
212 | 209 | ToDeviceMsg toDeviceMsg = BasicStatusCodeResponse.onSuccess(data.getSessionMsgType(), data.getRequestId()); |
213 | - sendMsgToSessionActor(new BasicToDeviceSessionActorMsg(toDeviceMsg, data.getSessionId()), data.getServerAddress()); | |
210 | + sendMsgToSessionActor(new BasicActorSystemToDeviceSessionActorMsg(toDeviceMsg, data.getSessionId()), data.getServerAddress()); | |
214 | 211 | } |
215 | 212 | } |
216 | 213 | } |
... | ... | @@ -248,7 +245,7 @@ public class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcesso |
248 | 245 | body.getMethod(), |
249 | 246 | body.getParams() |
250 | 247 | ); |
251 | - ToDeviceSessionActorMsg response = new BasicToDeviceSessionActorMsg(rpcRequest, sessionId); | |
248 | + ActorSystemToDeviceSessionActorMsg response = new BasicActorSystemToDeviceSessionActorMsg(rpcRequest, sessionId); | |
252 | 249 | sendMsgToSessionActor(response, server); |
253 | 250 | }; |
254 | 251 | } |
... | ... | @@ -302,14 +299,14 @@ public class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcesso |
302 | 299 | public void onSuccess(@Nullable List<List<AttributeKvEntry>> result) { |
303 | 300 | BasicGetAttributesResponse response = BasicGetAttributesResponse.onSuccess(request.getMsgType(), |
304 | 301 | request.getRequestId(), BasicAttributeKVMsg.from(result.get(0), result.get(1))); |
305 | - sendMsgToSessionActor(new BasicToDeviceSessionActorMsg(response, src.getSessionId()), src.getServerAddress()); | |
302 | + sendMsgToSessionActor(new BasicActorSystemToDeviceSessionActorMsg(response, src.getSessionId()), src.getServerAddress()); | |
306 | 303 | } |
307 | 304 | |
308 | 305 | @Override |
309 | 306 | public void onFailure(Throwable t) { |
310 | 307 | if (t instanceof Exception) { |
311 | 308 | ToDeviceMsg toDeviceMsg = BasicStatusCodeResponse.onError(SessionMsgType.GET_ATTRIBUTES_REQUEST, request.getRequestId(), (Exception) t); |
312 | - sendMsgToSessionActor(new BasicToDeviceSessionActorMsg(toDeviceMsg, src.getSessionId()), src.getServerAddress()); | |
309 | + sendMsgToSessionActor(new BasicActorSystemToDeviceSessionActorMsg(toDeviceMsg, src.getSessionId()), src.getServerAddress()); | |
313 | 310 | } else { |
314 | 311 | logger.error("[{}] Failed to process attributes request", deviceId, t); |
315 | 312 | } |
... | ... | @@ -391,14 +388,14 @@ public class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcesso |
391 | 388 | if (data != null) { |
392 | 389 | logger.debug("[{}] Client side RPC request [{}] timeout detected!", deviceId, msg.getId()); |
393 | 390 | ToDeviceMsg toDeviceMsg = new RuleEngineErrorMsg(SessionMsgType.TO_SERVER_RPC_REQUEST, RuleEngineError.TIMEOUT); |
394 | - sendMsgToSessionActor(new BasicToDeviceSessionActorMsg(toDeviceMsg, data.getSessionId()), data.getServer()); | |
391 | + sendMsgToSessionActor(new BasicActorSystemToDeviceSessionActorMsg(toDeviceMsg, data.getSessionId()), data.getServer()); | |
395 | 392 | } |
396 | 393 | } |
397 | 394 | |
398 | 395 | void processToServerRPCResponse(ActorContext context, ToServerRpcResponseActorMsg msg) { |
399 | 396 | ToServerRpcRequestMetadata data = toServerRpcPendingMap.remove(msg.getMsg().getRequestId()); |
400 | 397 | if (data != null) { |
401 | - sendMsgToSessionActor(new BasicToDeviceSessionActorMsg(msg.getMsg(), data.getSessionId()), data.getServer()); | |
398 | + sendMsgToSessionActor(new BasicActorSystemToDeviceSessionActorMsg(msg.getMsg(), data.getSessionId()), data.getServer()); | |
402 | 399 | } |
403 | 400 | } |
404 | 401 | |
... | ... | @@ -409,7 +406,7 @@ public class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcesso |
409 | 406 | pendingMsgs.put(tbMsg.getId(), pendingMsgData); |
410 | 407 | scheduleMsgWithDelay(context, new DeviceActorQueueTimeoutMsg(tbMsg.getId(), systemContext.getQueuePersistenceTimeout()), systemContext.getQueuePersistenceTimeout()); |
411 | 408 | } else { |
412 | - ToDeviceSessionActorMsg response = new BasicToDeviceSessionActorMsg(BasicStatusCodeResponse.onSuccess(sessionMsgType, requestId), pendingMsgData.getSessionId()); | |
409 | + ActorSystemToDeviceSessionActorMsg response = new BasicActorSystemToDeviceSessionActorMsg(BasicStatusCodeResponse.onSuccess(sessionMsgType, requestId), pendingMsgData.getSessionId()); | |
413 | 410 | sendMsgToSessionActor(response, pendingMsgData.getServerAddress()); |
414 | 411 | } |
415 | 412 | context.parent().tell(new DeviceActorToRuleEngineMsg(context.self(), tbMsg), context.self()); |
... | ... | @@ -436,7 +433,7 @@ public class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcesso |
436 | 433 | if (notification != null) { |
437 | 434 | ToDeviceMsg finalNotification = notification; |
438 | 435 | attributeSubscriptions.entrySet().forEach(sub -> { |
439 | - ToDeviceSessionActorMsg response = new BasicToDeviceSessionActorMsg(finalNotification, sub.getKey()); | |
436 | + ActorSystemToDeviceSessionActorMsg response = new BasicActorSystemToDeviceSessionActorMsg(finalNotification, sub.getKey()); | |
440 | 437 | sendMsgToSessionActor(response, sub.getValue().getServer()); |
441 | 438 | }); |
442 | 439 | } |
... | ... | @@ -462,7 +459,7 @@ public class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcesso |
462 | 459 | BasicCommandAckResponse response = success |
463 | 460 | ? BasicCommandAckResponse.onSuccess(SessionMsgType.TO_DEVICE_RPC_REQUEST, responseMsg.getRequestId()) |
464 | 461 | : BasicCommandAckResponse.onError(SessionMsgType.TO_DEVICE_RPC_REQUEST, responseMsg.getRequestId(), new TimeoutException()); |
465 | - sendMsgToSessionActor(new BasicToDeviceSessionActorMsg(response, msg.getSessionId()), msg.getServerAddress()); | |
462 | + sendMsgToSessionActor(new BasicActorSystemToDeviceSessionActorMsg(response, msg.getSessionId()), msg.getServerAddress()); | |
466 | 463 | } |
467 | 464 | } |
468 | 465 | } |
... | ... | @@ -517,7 +514,7 @@ public class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcesso |
517 | 514 | } |
518 | 515 | } |
519 | 516 | |
520 | - private void sendMsgToSessionActor(ToDeviceSessionActorMsg response, Optional<ServerAddress> sessionAddress) { | |
517 | + private void sendMsgToSessionActor(ActorSystemToDeviceSessionActorMsg response, Optional<ServerAddress> sessionAddress) { | |
521 | 518 | if (sessionAddress.isPresent()) { |
522 | 519 | ServerAddress address = sessionAddress.get(); |
523 | 520 | logger.debug("{} Forwarding msg: {}", address, response); |
... | ... | @@ -530,7 +527,7 @@ public class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcesso |
530 | 527 | |
531 | 528 | void processCredentialsUpdate() { |
532 | 529 | sessions.forEach((k, v) -> { |
533 | - sendMsgToSessionActor(new BasicToDeviceSessionActorMsg(new SessionCloseNotification(), k), v.getServer()); | |
530 | + sendMsgToSessionActor(new BasicActorSystemToDeviceSessionActorMsg(new SessionCloseNotification(), k), v.getServer()); | |
534 | 531 | }); |
535 | 532 | attributeSubscriptions.clear(); |
536 | 533 | rpcSubscriptions.clear(); | ... | ... |
... | ... | @@ -43,6 +43,7 @@ import org.thingsboard.server.dao.user.UserService; |
43 | 43 | import org.thingsboard.server.service.script.NashornJsEngine; |
44 | 44 | import scala.concurrent.duration.Duration; |
45 | 45 | |
46 | +import java.util.Collections; | |
46 | 47 | import java.util.List; |
47 | 48 | import java.util.Set; |
48 | 49 | import java.util.concurrent.TimeUnit; |
... | ... | @@ -63,15 +64,24 @@ class DefaultTbContext implements TbContext { |
63 | 64 | |
64 | 65 | @Override |
65 | 66 | public void tellNext(TbMsg msg, String relationType) { |
66 | - tellNext(msg, relationType, null); | |
67 | + tellNext(msg, Collections.singleton(relationType), null); | |
68 | + } | |
69 | + | |
70 | + @Override | |
71 | + public void tellNext(TbMsg msg, Set<String> relationTypes) { | |
72 | + tellNext(msg, relationTypes, null); | |
67 | 73 | } |
68 | 74 | |
69 | 75 | @Override |
70 | 76 | public void tellNext(TbMsg msg, String relationType, Throwable th) { |
77 | + tellNext(msg, Collections.singleton(relationType), th); | |
78 | + } | |
79 | + | |
80 | + private void tellNext(TbMsg msg, Set<String> relationTypes, Throwable th) { | |
71 | 81 | if (nodeCtx.getSelf().isDebugMode()) { |
72 | - mainCtx.persistDebugOutput(nodeCtx.getTenantId(), nodeCtx.getSelf().getId(), msg, relationType, th); | |
82 | + relationTypes.forEach(relationType -> mainCtx.persistDebugOutput(nodeCtx.getTenantId(), nodeCtx.getSelf().getId(), msg, relationType, th)); | |
73 | 83 | } |
74 | - nodeCtx.getChainActor().tell(new RuleNodeToRuleChainTellNextMsg(nodeCtx.getSelf().getId(), relationType, msg), nodeCtx.getSelfActor()); | |
84 | + nodeCtx.getChainActor().tell(new RuleNodeToRuleChainTellNextMsg(nodeCtx.getSelf().getId(), relationTypes, msg), nodeCtx.getSelfActor()); | |
75 | 85 | } |
76 | 86 | |
77 | 87 | @Override |
... | ... | @@ -118,12 +128,6 @@ class DefaultTbContext implements TbContext { |
118 | 128 | } |
119 | 129 | |
120 | 130 | @Override |
121 | - public void tellNext(TbMsg msg, Set<String> relationTypes) { | |
122 | - //TODO: fix this to send set of relations instead of loop. | |
123 | - relationTypes.forEach(type -> tellNext(msg, type)); | |
124 | - } | |
125 | - | |
126 | - @Override | |
127 | 131 | public ListeningExecutor getJsExecutor() { |
128 | 132 | return mainCtx.getJsExecutor(); |
129 | 133 | } | ... | ... |
... | ... | @@ -54,6 +54,8 @@ public class RuleChainActor extends ComponentActor<RuleChainId, RuleChainActorMe |
54 | 54 | case RULE_CHAIN_TO_RULE_CHAIN_MSG: |
55 | 55 | processor.onRuleChainToRuleChainMsg((RuleChainToRuleChainMsg) msg); |
56 | 56 | break; |
57 | + case CLUSTER_EVENT_MSG: | |
58 | + break; | |
57 | 59 | default: |
58 | 60 | return false; |
59 | 61 | } | ... | ... |
... | ... | @@ -206,9 +206,8 @@ public class RuleChainActorMessageProcessor extends ComponentMsgProcessor<RuleCh |
206 | 206 | void onTellNext(RuleNodeToRuleChainTellNextMsg envelope) { |
207 | 207 | checkActive(); |
208 | 208 | RuleNodeId originator = envelope.getOriginator(); |
209 | - String targetRelationType = envelope.getRelationType(); | |
210 | 209 | List<RuleNodeRelation> relations = nodeRoutes.get(originator).stream() |
211 | - .filter(r -> targetRelationType == null || targetRelationType.equalsIgnoreCase(r.getType())) | |
210 | + .filter(r -> contains(envelope.getRelationTypes(), r.getType())) | |
212 | 211 | .collect(Collectors.toList()); |
213 | 212 | |
214 | 213 | TbMsg msg = envelope.getMsg(); |
... | ... | @@ -237,6 +236,18 @@ public class RuleChainActorMessageProcessor extends ComponentMsgProcessor<RuleCh |
237 | 236 | } |
238 | 237 | } |
239 | 238 | |
239 | + private boolean contains(Set<String> relationTypes, String type) { | |
240 | + if (relationTypes == null) { | |
241 | + return true; | |
242 | + } | |
243 | + for (String relationType : relationTypes) { | |
244 | + if (relationType.equalsIgnoreCase(type)) { | |
245 | + return true; | |
246 | + } | |
247 | + } | |
248 | + return false; | |
249 | + } | |
250 | + | |
240 | 251 | private void enqueueAndForwardMsgCopyToChain(TbMsg msg, EntityId target, String fromRelationType) { |
241 | 252 | RuleChainId targetRCId = new RuleChainId(target.getId()); |
242 | 253 | TbMsg copyMsg = msg.copy(UUIDs.timeBased(), targetRCId, null, DEFAULT_CLUSTER_PARTITION); | ... | ... |
... | ... | @@ -21,6 +21,8 @@ import org.thingsboard.server.common.msg.MsgType; |
21 | 21 | import org.thingsboard.server.common.msg.TbActorMsg; |
22 | 22 | import org.thingsboard.server.common.msg.TbMsg; |
23 | 23 | |
24 | +import java.util.Set; | |
25 | + | |
24 | 26 | /** |
25 | 27 | * Created by ashvayka on 19.03.18. |
26 | 28 | */ |
... | ... | @@ -28,7 +30,7 @@ import org.thingsboard.server.common.msg.TbMsg; |
28 | 30 | final class RuleNodeToRuleChainTellNextMsg implements TbActorMsg { |
29 | 31 | |
30 | 32 | private final RuleNodeId originator; |
31 | - private final String relationType; | |
33 | + private final Set<String> relationTypes; | |
32 | 34 | private final TbMsg msg; |
33 | 35 | |
34 | 36 | @Override | ... | ... |
... | ... | @@ -39,8 +39,12 @@ public abstract class ContextAwareActor extends UntypedActor { |
39 | 39 | logger.debug("Processing msg: {}", msg); |
40 | 40 | } |
41 | 41 | if (msg instanceof TbActorMsg) { |
42 | - if(!process((TbActorMsg) msg)){ | |
43 | - logger.warning("Unknown message: {}!", msg); | |
42 | + try { | |
43 | + if (!process((TbActorMsg) msg)) { | |
44 | + logger.warning("Unknown message: {}!", msg); | |
45 | + } | |
46 | + } catch (Exception e) { | |
47 | + throw e; | |
44 | 48 | } |
45 | 49 | } else { |
46 | 50 | logger.warning("Unknown message: {}!", msg); | ... | ... |
... | ... | @@ -211,6 +211,10 @@ public class DefaultActorService implements ActorService { |
211 | 211 | @Override |
212 | 212 | public void onReceivedMsg(ServerAddress source, ClusterAPIProtos.ClusterMessage msg) { |
213 | 213 | ServerAddress serverAddress = new ServerAddress(source.getHost(), source.getPort()); |
214 | + log.info("Received msg [{}] from [{}]", msg.getMessageType().name(), serverAddress); | |
215 | + if(log.isDebugEnabled()){ | |
216 | + log.info("MSG: ", msg); | |
217 | + } | |
214 | 218 | switch (msg.getMessageType()) { |
215 | 219 | case CLUSTER_ACTOR_MESSAGE: |
216 | 220 | java.util.Optional<TbActorMsg> decodedMsg = actorContext.getEncodingService() | ... | ... |
... | ... | @@ -46,7 +46,7 @@ class ASyncMsgProcessor extends AbstractSessionActorMsgProcessor { |
46 | 46 | } |
47 | 47 | |
48 | 48 | @Override |
49 | - protected void processToDeviceActorMsg(ActorContext ctx, ToDeviceActorSessionMsg msg) { | |
49 | + protected void processToDeviceActorMsg(ActorContext ctx, TransportToDeviceSessionActorMsg msg) { | |
50 | 50 | updateSessionCtx(msg, SessionType.ASYNC); |
51 | 51 | if (firstMsg) { |
52 | 52 | toDeviceMsg(new SessionOpenMsg()).ifPresent(m -> forwardToAppActor(ctx, m)); | ... | ... |
... | ... | @@ -45,7 +45,7 @@ abstract class AbstractSessionActorMsgProcessor extends AbstractContextAwareMsgP |
45 | 45 | this.sessionId = sessionId; |
46 | 46 | } |
47 | 47 | |
48 | - protected abstract void processToDeviceActorMsg(ActorContext ctx, ToDeviceActorSessionMsg msg); | |
48 | + protected abstract void processToDeviceActorMsg(ActorContext ctx, TransportToDeviceSessionActorMsg msg); | |
49 | 49 | |
50 | 50 | protected abstract void processTimeoutMsg(ActorContext context, SessionTimeoutMsg msg); |
51 | 51 | |
... | ... | @@ -63,12 +63,12 @@ abstract class AbstractSessionActorMsgProcessor extends AbstractContextAwareMsgP |
63 | 63 | protected void cleanupSession(ActorContext ctx) { |
64 | 64 | } |
65 | 65 | |
66 | - protected void updateSessionCtx(ToDeviceActorSessionMsg msg, SessionType type) { | |
66 | + protected void updateSessionCtx(TransportToDeviceSessionActorMsg msg, SessionType type) { | |
67 | 67 | sessionCtx = msg.getSessionMsg().getSessionContext(); |
68 | 68 | deviceToDeviceActorMsgPrototype = new BasicDeviceToDeviceActorMsg(msg, type); |
69 | 69 | } |
70 | 70 | |
71 | - protected DeviceToDeviceActorMsg toDeviceMsg(ToDeviceActorSessionMsg msg) { | |
71 | + protected DeviceToDeviceActorMsg toDeviceMsg(TransportToDeviceSessionActorMsg msg) { | |
72 | 72 | AdaptorToSessionActorMsg adaptorMsg = msg.getSessionMsg(); |
73 | 73 | return new BasicDeviceToDeviceActorMsg(deviceToDeviceActorMsgPrototype, adaptorMsg.getMsg()); |
74 | 74 | } | ... | ... |
... | ... | @@ -17,7 +17,6 @@ package org.thingsboard.server.actors.session; |
17 | 17 | |
18 | 18 | import akka.actor.OneForOneStrategy; |
19 | 19 | import akka.actor.SupervisorStrategy; |
20 | -import akka.japi.Function; | |
21 | 20 | import org.thingsboard.server.actors.ActorSystemContext; |
22 | 21 | import org.thingsboard.server.actors.service.ContextAwareActor; |
23 | 22 | import org.thingsboard.server.actors.service.ContextBasedCreator; |
... | ... | @@ -25,8 +24,8 @@ import org.thingsboard.server.actors.shared.SessionTimeoutMsg; |
25 | 24 | import org.thingsboard.server.common.data.id.SessionId; |
26 | 25 | import org.thingsboard.server.common.msg.TbActorMsg; |
27 | 26 | import org.thingsboard.server.common.msg.cluster.ClusterEventMsg; |
28 | -import org.thingsboard.server.common.msg.core.ToDeviceSessionActorMsg; | |
29 | -import org.thingsboard.server.common.msg.session.ToDeviceActorSessionMsg; | |
27 | +import org.thingsboard.server.common.msg.core.ActorSystemToDeviceSessionActorMsg; | |
28 | +import org.thingsboard.server.common.msg.session.TransportToDeviceSessionActorMsg; | |
30 | 29 | import org.thingsboard.server.common.msg.session.SessionCtrlMsg; |
31 | 30 | import org.thingsboard.server.common.msg.session.SessionMsg; |
32 | 31 | import org.thingsboard.server.common.msg.session.SessionType; |
... | ... | @@ -63,38 +62,37 @@ public class SessionActor extends ContextAwareActor { |
63 | 62 | |
64 | 63 | @Override |
65 | 64 | protected boolean process(TbActorMsg msg) { |
66 | - //TODO Move everything here, to work with TbActorMsg | |
67 | - return false; | |
68 | - } | |
69 | - | |
70 | - @Override | |
71 | - public void onReceive(Object msg) throws Exception { | |
72 | - logger.debug("[{}] Processing: {}.", sessionId, msg); | |
73 | - if (msg instanceof ToDeviceActorSessionMsg) { | |
74 | - processDeviceMsg((ToDeviceActorSessionMsg) msg); | |
75 | - } else if (msg instanceof ToDeviceSessionActorMsg) { | |
76 | - processToDeviceMsg((ToDeviceSessionActorMsg) msg); | |
77 | - } else if (msg instanceof SessionTimeoutMsg) { | |
78 | - processTimeoutMsg((SessionTimeoutMsg) msg); | |
79 | - } else if (msg instanceof SessionCtrlMsg) { | |
80 | - processSessionCtrlMsg((SessionCtrlMsg) msg); | |
81 | - } else if (msg instanceof ClusterEventMsg) { | |
82 | - processClusterEvent((ClusterEventMsg) msg); | |
83 | - } else { | |
84 | - logger.warning("[{}] Unknown msg: {}", sessionId, msg); | |
65 | + switch (msg.getMsgType()) { | |
66 | + case TRANSPORT_TO_DEVICE_SESSION_ACTOR_MSG: | |
67 | + processTransportToSessionMsg((TransportToDeviceSessionActorMsg) msg); | |
68 | + break; | |
69 | + case ACTOR_SYSTEM_TO_DEVICE_SESSION_ACTOR_MSG: | |
70 | + processActorsToSessionMsg((ActorSystemToDeviceSessionActorMsg) msg); | |
71 | + break; | |
72 | + case SESSION_TIMEOUT_MSG: | |
73 | + processTimeoutMsg((SessionTimeoutMsg) msg); | |
74 | + break; | |
75 | + case SESSION_CTRL_MSG: | |
76 | + processSessionCloseMsg((SessionCtrlMsg) msg); | |
77 | + break; | |
78 | + case CLUSTER_EVENT_MSG: | |
79 | + processClusterEvent((ClusterEventMsg) msg); | |
80 | + break; | |
81 | + default: return false; | |
85 | 82 | } |
83 | + return true; | |
86 | 84 | } |
87 | 85 | |
88 | 86 | private void processClusterEvent(ClusterEventMsg msg) { |
89 | 87 | processor.processClusterEvent(context(), msg); |
90 | 88 | } |
91 | 89 | |
92 | - private void processDeviceMsg(ToDeviceActorSessionMsg msg) { | |
90 | + private void processTransportToSessionMsg(TransportToDeviceSessionActorMsg msg) { | |
93 | 91 | initProcessor(msg); |
94 | 92 | processor.processToDeviceActorMsg(context(), msg); |
95 | 93 | } |
96 | 94 | |
97 | - private void processToDeviceMsg(ToDeviceSessionActorMsg msg) { | |
95 | + private void processActorsToSessionMsg(ActorSystemToDeviceSessionActorMsg msg) { | |
98 | 96 | processor.processToDeviceMsg(context(), msg.getMsg()); |
99 | 97 | } |
100 | 98 | |
... | ... | @@ -106,7 +104,7 @@ public class SessionActor extends ContextAwareActor { |
106 | 104 | } |
107 | 105 | } |
108 | 106 | |
109 | - private void processSessionCtrlMsg(SessionCtrlMsg msg) { | |
107 | + private void processSessionCloseMsg(SessionCtrlMsg msg) { | |
110 | 108 | if (processor != null) { |
111 | 109 | processor.processSessionCtrlMsg(context(), msg); |
112 | 110 | } else if (msg instanceof SessionCloseMsg) { |
... | ... | @@ -116,7 +114,7 @@ public class SessionActor extends ContextAwareActor { |
116 | 114 | } |
117 | 115 | } |
118 | 116 | |
119 | - private void initProcessor(ToDeviceActorSessionMsg msg) { | |
117 | + private void initProcessor(TransportToDeviceSessionActorMsg msg) { | |
120 | 118 | if (processor == null) { |
121 | 119 | SessionMsg sessionMsg = (SessionMsg) msg.getSessionMsg(); |
122 | 120 | if (sessionMsg.getSessionContext().getSessionType() == SessionType.SYNC) { | ... | ... |
... | ... | @@ -17,7 +17,6 @@ package org.thingsboard.server.actors.session; |
17 | 17 | |
18 | 18 | import java.util.HashMap; |
19 | 19 | import java.util.Map; |
20 | -import java.util.UUID; | |
21 | 20 | |
22 | 21 | import akka.actor.*; |
23 | 22 | import org.thingsboard.server.actors.ActorSystemContext; |
... | ... | @@ -33,8 +32,9 @@ import akka.event.Logging; |
33 | 32 | import akka.event.LoggingAdapter; |
34 | 33 | import org.thingsboard.server.common.msg.cluster.ClusterEventMsg; |
35 | 34 | import org.thingsboard.server.common.msg.core.SessionCloseMsg; |
36 | -import org.thingsboard.server.common.msg.core.ToDeviceSessionActorMsg; | |
35 | +import org.thingsboard.server.common.msg.core.ActorSystemToDeviceSessionActorMsg; | |
37 | 36 | import org.thingsboard.server.common.msg.session.SessionCtrlMsg; |
37 | +import org.thingsboard.server.common.msg.session.TransportToDeviceSessionActorMsg; | |
38 | 38 | |
39 | 39 | public class SessionManagerActor extends ContextAwareActor { |
40 | 40 | |
... | ... | @@ -104,7 +104,7 @@ public class SessionManagerActor extends ContextAwareActor { |
104 | 104 | } |
105 | 105 | |
106 | 106 | private void forwardToSessionActor(SessionAwareMsg msg) { |
107 | - if (msg instanceof ToDeviceSessionActorMsg || msg instanceof SessionCloseMsg) { | |
107 | + if (msg instanceof ActorSystemToDeviceSessionActorMsg || msg instanceof SessionCloseMsg) { | |
108 | 108 | String sessionIdStr = msg.getSessionId().toUidStr(); |
109 | 109 | ActorRef sessionActor = sessionActors.get(sessionIdStr); |
110 | 110 | if (sessionActor != null) { | ... | ... |
... | ... | @@ -22,7 +22,7 @@ import org.thingsboard.server.common.msg.cluster.ClusterEventMsg; |
22 | 22 | import org.thingsboard.server.common.msg.cluster.ServerAddress; |
23 | 23 | import org.thingsboard.server.common.msg.device.DeviceToDeviceActorMsg; |
24 | 24 | import org.thingsboard.server.common.msg.session.*; |
25 | -import org.thingsboard.server.common.msg.session.ToDeviceActorSessionMsg; | |
25 | +import org.thingsboard.server.common.msg.session.TransportToDeviceSessionActorMsg; | |
26 | 26 | import org.thingsboard.server.common.msg.session.ctrl.SessionCloseMsg; |
27 | 27 | import org.thingsboard.server.common.msg.session.ex.SessionException; |
28 | 28 | |
... | ... | @@ -41,7 +41,7 @@ class SyncMsgProcessor extends AbstractSessionActorMsgProcessor { |
41 | 41 | } |
42 | 42 | |
43 | 43 | @Override |
44 | - protected void processToDeviceActorMsg(ActorContext ctx, ToDeviceActorSessionMsg msg) { | |
44 | + protected void processToDeviceActorMsg(ActorContext ctx, TransportToDeviceSessionActorMsg msg) { | |
45 | 45 | updateSessionCtx(msg, SessionType.SYNC); |
46 | 46 | pendingMsg = toDeviceMsg(msg); |
47 | 47 | pendingResponse = true; | ... | ... |
... | ... | @@ -17,13 +17,20 @@ package org.thingsboard.server.actors.shared; |
17 | 17 | |
18 | 18 | import lombok.Data; |
19 | 19 | import org.thingsboard.server.common.data.id.SessionId; |
20 | +import org.thingsboard.server.common.msg.MsgType; | |
21 | +import org.thingsboard.server.common.msg.TbActorMsg; | |
20 | 22 | |
21 | 23 | import java.io.Serializable; |
22 | 24 | |
23 | 25 | @Data |
24 | -public class SessionTimeoutMsg implements Serializable { | |
26 | +public class SessionTimeoutMsg implements Serializable, TbActorMsg { | |
25 | 27 | |
26 | 28 | private static final long serialVersionUID = 1L; |
27 | 29 | |
28 | 30 | private final SessionId sessionId; |
31 | + | |
32 | + @Override | |
33 | + public MsgType getMsgType() { | |
34 | + return MsgType.SESSION_TIMEOUT_MSG; | |
35 | + } | |
29 | 36 | } | ... | ... |
... | ... | @@ -107,7 +107,7 @@ public class ConsistentClusterRoutingService implements ClusterRoutingService, D |
107 | 107 | |
108 | 108 | @Override |
109 | 109 | public void onServerAdded(ServerInstance server) { |
110 | - log.debug("On server added event: {}", server); | |
110 | + log.info("On server added event: {}", server); | |
111 | 111 | addNode(server); |
112 | 112 | logCircle(); |
113 | 113 | } |
... | ... | @@ -119,7 +119,7 @@ public class ConsistentClusterRoutingService implements ClusterRoutingService, D |
119 | 119 | |
120 | 120 | @Override |
121 | 121 | public void onServerRemoved(ServerInstance server) { |
122 | - log.debug("On server removed event: {}", server); | |
122 | + log.info("On server removed event: {}", server); | |
123 | 123 | removeNode(server); |
124 | 124 | logCircle(); |
125 | 125 | } | ... | ... |
... | ... | @@ -22,16 +22,11 @@ import io.grpc.stub.StreamObserver; |
22 | 22 | import lombok.extern.slf4j.Slf4j; |
23 | 23 | import org.springframework.beans.factory.annotation.Autowired; |
24 | 24 | import org.springframework.stereotype.Service; |
25 | -import org.springframework.util.SerializationUtils; | |
26 | 25 | import org.thingsboard.server.actors.rpc.RpcBroadcastMsg; |
27 | 26 | import org.thingsboard.server.actors.rpc.RpcSessionCreateRequestMsg; |
28 | -import org.thingsboard.server.common.data.id.EntityId; | |
29 | 27 | import org.thingsboard.server.common.msg.TbActorMsg; |
30 | 28 | import org.thingsboard.server.common.msg.cluster.ServerAddress; |
31 | -import org.thingsboard.server.common.msg.core.ToDeviceSessionActorMsg; | |
32 | 29 | |
33 | -import org.thingsboard.server.extensions.api.plugins.rpc.RpcMsg; | |
34 | -import org.thingsboard.server.extensions.core.plugin.telemetry.sub.Subscription; | |
35 | 30 | import org.thingsboard.server.gen.cluster.ClusterAPIProtos; |
36 | 31 | |
37 | 32 | import org.thingsboard.server.gen.cluster.ClusterRpcServiceGrpc; | ... | ... |
... | ... | @@ -19,15 +19,7 @@ import io.grpc.stub.StreamObserver; |
19 | 19 | import org.thingsboard.server.actors.rpc.RpcBroadcastMsg; |
20 | 20 | import org.thingsboard.server.common.msg.TbActorMsg; |
21 | 21 | import org.thingsboard.server.common.msg.cluster.ServerAddress; |
22 | -import org.thingsboard.server.common.msg.cluster.ToAllNodesMsg; | |
23 | -import org.thingsboard.server.common.msg.core.ToDeviceSessionActorMsg; | |
24 | -import org.thingsboard.server.common.msg.device.DeviceToDeviceActorMsg; | |
25 | -import org.thingsboard.server.extensions.api.device.ToDeviceActorNotificationMsg; | |
26 | -import org.thingsboard.server.extensions.api.plugins.msg.ToPluginRpcResponseDeviceMsg; | |
27 | -import org.thingsboard.server.extensions.api.plugins.rpc.PluginRpcMsg; | |
28 | -import org.thingsboard.server.extensions.core.plugin.telemetry.sub.Subscription; | |
29 | 22 | import org.thingsboard.server.gen.cluster.ClusterAPIProtos; |
30 | -import org.thingsboard.server.service.rpc.ToDeviceRpcRequestActorMsg; | |
31 | 23 | |
32 | 24 | import java.util.UUID; |
33 | 25 | ... | ... |
... | ... | @@ -101,6 +101,6 @@ public enum MsgType { |
101 | 101 | /** |
102 | 102 | * Message that is sent from Rule Engine to the Device Actor when message is successfully pushed to queue. |
103 | 103 | */ |
104 | - RULE_ENGINE_QUEUE_PUT_ACK_MSG; | |
104 | + RULE_ENGINE_QUEUE_PUT_ACK_MSG, ACTOR_SYSTEM_TO_DEVICE_SESSION_ACTOR_MSG, TRANSPORT_TO_DEVICE_SESSION_ACTOR_MSG, SESSION_TIMEOUT_MSG, SESSION_CTRL_MSG; | |
105 | 105 | |
106 | 106 | } | ... | ... |
common/message/src/main/java/org/thingsboard/server/common/msg/core/ActorSystemToDeviceSessionActorMsg.java
renamed from
common/message/src/main/java/org/thingsboard/server/common/msg/core/ToDeviceSessionActorMsg.java
... | ... | @@ -24,7 +24,7 @@ import java.io.Serializable; |
24 | 24 | /** |
25 | 25 | * @author Andrew Shvayka |
26 | 26 | */ |
27 | -public interface ToDeviceSessionActorMsg extends SessionAwareMsg, Serializable, TbActorMsg { | |
27 | +public interface ActorSystemToDeviceSessionActorMsg extends SessionAwareMsg, Serializable, TbActorMsg { | |
28 | 28 | |
29 | 29 | ToDeviceMsg getMsg(); |
30 | 30 | } | ... | ... |
common/message/src/main/java/org/thingsboard/server/common/msg/core/BasicActorSystemToDeviceSessionActorMsg.java
renamed from
common/message/src/main/java/org/thingsboard/server/common/msg/core/BasicToDeviceSessionActorMsg.java
... | ... | @@ -19,12 +19,12 @@ import org.thingsboard.server.common.data.id.SessionId; |
19 | 19 | import org.thingsboard.server.common.msg.MsgType; |
20 | 20 | import org.thingsboard.server.common.msg.session.ToDeviceMsg; |
21 | 21 | |
22 | -public class BasicToDeviceSessionActorMsg implements ToDeviceSessionActorMsg { | |
22 | +public class BasicActorSystemToDeviceSessionActorMsg implements ActorSystemToDeviceSessionActorMsg { | |
23 | 23 | |
24 | 24 | private final ToDeviceMsg msg; |
25 | 25 | private final SessionId sessionId; |
26 | 26 | |
27 | - public BasicToDeviceSessionActorMsg(ToDeviceMsg msg, SessionId sessionId) { | |
27 | + public BasicActorSystemToDeviceSessionActorMsg(ToDeviceMsg msg, SessionId sessionId) { | |
28 | 28 | super(); |
29 | 29 | this.msg = msg; |
30 | 30 | this.sessionId = sessionId; |
... | ... | @@ -47,6 +47,6 @@ public class BasicToDeviceSessionActorMsg implements ToDeviceSessionActorMsg { |
47 | 47 | |
48 | 48 | @Override |
49 | 49 | public MsgType getMsgType() { |
50 | - return null; | |
50 | + return MsgType.ACTOR_SYSTEM_TO_DEVICE_SESSION_ACTOR_MSG; | |
51 | 51 | } |
52 | 52 | } | ... | ... |
... | ... | @@ -24,7 +24,7 @@ import org.thingsboard.server.common.msg.MsgType; |
24 | 24 | import org.thingsboard.server.common.msg.cluster.ServerAddress; |
25 | 25 | import org.thingsboard.server.common.msg.session.FromDeviceMsg; |
26 | 26 | import org.thingsboard.server.common.msg.session.SessionType; |
27 | -import org.thingsboard.server.common.msg.session.ToDeviceActorSessionMsg; | |
27 | +import org.thingsboard.server.common.msg.session.TransportToDeviceSessionActorMsg; | |
28 | 28 | |
29 | 29 | import java.util.Optional; |
30 | 30 | |
... | ... | @@ -45,7 +45,7 @@ public class BasicDeviceToDeviceActorMsg implements DeviceToDeviceActorMsg { |
45 | 45 | this(null, other.getTenantId(), other.getCustomerId(), other.getDeviceId(), other.getSessionId(), other.getSessionType(), msg); |
46 | 46 | } |
47 | 47 | |
48 | - public BasicDeviceToDeviceActorMsg(ToDeviceActorSessionMsg msg, SessionType sessionType) { | |
48 | + public BasicDeviceToDeviceActorMsg(TransportToDeviceSessionActorMsg msg, SessionType sessionType) { | |
49 | 49 | this(null, msg.getTenantId(), msg.getCustomerId(), msg.getDeviceId(), msg.getSessionId(), sessionType, msg.getSessionMsg().getMsg()); |
50 | 50 | } |
51 | 51 | ... | ... |
common/message/src/main/java/org/thingsboard/server/common/msg/session/BasicTransportToDeviceSessionActorMsg.java
renamed from
common/message/src/main/java/org/thingsboard/server/common/msg/session/BasicToDeviceActorSessionMsg.java
... | ... | @@ -20,15 +20,16 @@ import org.thingsboard.server.common.data.id.CustomerId; |
20 | 20 | import org.thingsboard.server.common.data.id.DeviceId; |
21 | 21 | import org.thingsboard.server.common.data.id.SessionId; |
22 | 22 | import org.thingsboard.server.common.data.id.TenantId; |
23 | +import org.thingsboard.server.common.msg.MsgType; | |
23 | 24 | |
24 | -public class BasicToDeviceActorSessionMsg implements ToDeviceActorSessionMsg { | |
25 | +public class BasicTransportToDeviceSessionActorMsg implements TransportToDeviceSessionActorMsg { | |
25 | 26 | |
26 | 27 | private final TenantId tenantId; |
27 | 28 | private final CustomerId customerId; |
28 | 29 | private final DeviceId deviceId; |
29 | 30 | private final AdaptorToSessionActorMsg msg; |
30 | 31 | |
31 | - public BasicToDeviceActorSessionMsg(Device device, AdaptorToSessionActorMsg msg) { | |
32 | + public BasicTransportToDeviceSessionActorMsg(Device device, AdaptorToSessionActorMsg msg) { | |
32 | 33 | super(); |
33 | 34 | this.tenantId = device.getTenantId(); |
34 | 35 | this.customerId = device.getCustomerId(); |
... | ... | @@ -36,13 +37,6 @@ public class BasicToDeviceActorSessionMsg implements ToDeviceActorSessionMsg { |
36 | 37 | this.msg = msg; |
37 | 38 | } |
38 | 39 | |
39 | - public BasicToDeviceActorSessionMsg(ToDeviceActorSessionMsg deviceMsg) { | |
40 | - this.tenantId = deviceMsg.getTenantId(); | |
41 | - this.customerId = deviceMsg.getCustomerId(); | |
42 | - this.deviceId = deviceMsg.getDeviceId(); | |
43 | - this.msg = deviceMsg.getSessionMsg(); | |
44 | - } | |
45 | - | |
46 | 40 | @Override |
47 | 41 | public DeviceId getDeviceId() { |
48 | 42 | return deviceId; |
... | ... | @@ -69,8 +63,12 @@ public class BasicToDeviceActorSessionMsg implements ToDeviceActorSessionMsg { |
69 | 63 | |
70 | 64 | @Override |
71 | 65 | public String toString() { |
72 | - return "BasicToDeviceActorSessionMsg [tenantId=" + tenantId + ", customerId=" + customerId + ", deviceId=" + deviceId + ", msg=" + msg | |
66 | + return "BasicTransportToDeviceSessionActorMsg [tenantId=" + tenantId + ", customerId=" + customerId + ", deviceId=" + deviceId + ", msg=" + msg | |
73 | 67 | + "]"; |
74 | 68 | } |
75 | 69 | |
70 | + @Override | |
71 | + public MsgType getMsgType() { | |
72 | + return MsgType.TRANSPORT_TO_DEVICE_SESSION_ACTOR_MSG; | |
73 | + } | |
76 | 74 | } | ... | ... |
... | ... | @@ -15,8 +15,9 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.common.msg.session; |
17 | 17 | |
18 | +import org.thingsboard.server.common.msg.TbActorMsg; | |
18 | 19 | import org.thingsboard.server.common.msg.aware.SessionAwareMsg; |
19 | 20 | |
20 | -public interface SessionCtrlMsg extends SessionAwareMsg { | |
21 | +public interface SessionCtrlMsg extends SessionAwareMsg, TbActorMsg { | |
21 | 22 | |
22 | 23 | } | ... | ... |
common/message/src/main/java/org/thingsboard/server/common/msg/session/TransportToDeviceSessionActorMsg.java
renamed from
common/message/src/main/java/org/thingsboard/server/common/msg/session/ToDeviceActorSessionMsg.java
... | ... | @@ -15,12 +15,13 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.common.msg.session; |
17 | 17 | |
18 | +import org.thingsboard.server.common.msg.TbActorMsg; | |
18 | 19 | import org.thingsboard.server.common.msg.aware.CustomerAwareMsg; |
19 | 20 | import org.thingsboard.server.common.msg.aware.DeviceAwareMsg; |
20 | 21 | import org.thingsboard.server.common.msg.aware.SessionAwareMsg; |
21 | 22 | import org.thingsboard.server.common.msg.aware.TenantAwareMsg; |
22 | 23 | |
23 | -public interface ToDeviceActorSessionMsg extends DeviceAwareMsg, CustomerAwareMsg, TenantAwareMsg, SessionAwareMsg { | |
24 | +public interface TransportToDeviceSessionActorMsg extends DeviceAwareMsg, CustomerAwareMsg, TenantAwareMsg, SessionAwareMsg, TbActorMsg { | |
24 | 25 | |
25 | 26 | AdaptorToSessionActorMsg getSessionMsg(); |
26 | 27 | ... | ... |
... | ... | @@ -16,6 +16,7 @@ |
16 | 16 | package org.thingsboard.server.common.msg.session.ctrl; |
17 | 17 | |
18 | 18 | import org.thingsboard.server.common.data.id.SessionId; |
19 | +import org.thingsboard.server.common.msg.MsgType; | |
19 | 20 | import org.thingsboard.server.common.msg.session.SessionCtrlMsg; |
20 | 21 | |
21 | 22 | public class SessionCloseMsg implements SessionCtrlMsg { |
... | ... | @@ -60,4 +61,8 @@ public class SessionCloseMsg implements SessionCtrlMsg { |
60 | 61 | return timeout; |
61 | 62 | } |
62 | 63 | |
64 | + @Override | |
65 | + public MsgType getMsgType() { | |
66 | + return MsgType.SESSION_CTRL_MSG; | |
67 | + } | |
63 | 68 | } | ... | ... |
... | ... | @@ -59,7 +59,7 @@ |
59 | 59 | <velocity.version>1.7</velocity.version> |
60 | 60 | <velocity-tools.version>2.0</velocity-tools.version> |
61 | 61 | <mail.version>1.4.3</mail.version> |
62 | - <curator.version>2.11.0</curator.version> | |
62 | + <curator.version>4.0.1</curator.version> | |
63 | 63 | <protobuf.version>3.0.2</protobuf.version> |
64 | 64 | <grpc.version>1.12.0</grpc.version> |
65 | 65 | <lombok.version>1.16.18</lombok.version> | ... | ... |
... | ... | @@ -38,8 +38,6 @@ import org.thingsboard.server.common.transport.quota.QuotaService; |
38 | 38 | import org.thingsboard.server.transport.coap.adaptors.CoapTransportAdaptor; |
39 | 39 | import org.thingsboard.server.transport.coap.session.CoapExchangeObserverProxy; |
40 | 40 | import org.thingsboard.server.transport.coap.session.CoapSessionCtx; |
41 | -import org.slf4j.Logger; | |
42 | -import org.slf4j.LoggerFactory; | |
43 | 41 | import org.springframework.util.ReflectionUtils; |
44 | 42 | |
45 | 43 | @Slf4j |
... | ... | @@ -186,7 +184,7 @@ public class CoapTransportResource extends CoapResource { |
186 | 184 | throw new IllegalArgumentException("Unsupported msg type: " + type); |
187 | 185 | } |
188 | 186 | log.trace("Processing msg: {}", msg); |
189 | - processor.process(new BasicToDeviceActorSessionMsg(ctx.getDevice(), msg)); | |
187 | + processor.process(new BasicTransportToDeviceSessionActorMsg(ctx.getDevice(), msg)); | |
190 | 188 | } catch (AdaptorException e) { |
191 | 189 | log.debug("Failed to decode payload {}", e); |
192 | 190 | exchange.respond(ResponseCode.BAD_REQUEST, e.getMessage()); | ... | ... |
... | ... | @@ -108,8 +108,8 @@ public class CoapServerTest { |
108 | 108 | |
109 | 109 | @Override |
110 | 110 | public void process(SessionAwareMsg toActorMsg) { |
111 | - if (toActorMsg instanceof ToDeviceActorSessionMsg) { | |
112 | - AdaptorToSessionActorMsg sessionMsg = ((ToDeviceActorSessionMsg) toActorMsg).getSessionMsg(); | |
111 | + if (toActorMsg instanceof TransportToDeviceSessionActorMsg) { | |
112 | + AdaptorToSessionActorMsg sessionMsg = ((TransportToDeviceSessionActorMsg) toActorMsg).getSessionMsg(); | |
113 | 113 | try { |
114 | 114 | FromDeviceMsg deviceMsg = sessionMsg.getMsg(); |
115 | 115 | ToDeviceMsg toDeviceMsg = null; | ... | ... |
... | ... | @@ -30,7 +30,7 @@ import org.thingsboard.server.common.data.security.DeviceTokenCredentials; |
30 | 30 | import org.thingsboard.server.common.msg.core.*; |
31 | 31 | import org.thingsboard.server.common.msg.session.AdaptorToSessionActorMsg; |
32 | 32 | import org.thingsboard.server.common.msg.session.BasicAdaptorToSessionActorMsg; |
33 | -import org.thingsboard.server.common.msg.session.BasicToDeviceActorSessionMsg; | |
33 | +import org.thingsboard.server.common.msg.session.BasicTransportToDeviceSessionActorMsg; | |
34 | 34 | import org.thingsboard.server.common.msg.session.FromDeviceMsg; |
35 | 35 | import org.thingsboard.server.common.transport.SessionMsgProcessor; |
36 | 36 | import org.thingsboard.server.common.transport.adaptor.JsonConverter; |
... | ... | @@ -219,7 +219,7 @@ public class DeviceApiController { |
219 | 219 | |
220 | 220 | private void process(HttpSessionCtx ctx, FromDeviceMsg request) { |
221 | 221 | AdaptorToSessionActorMsg msg = new BasicAdaptorToSessionActorMsg(ctx, request); |
222 | - processor.process(new BasicToDeviceActorSessionMsg(ctx.getDevice(), msg)); | |
222 | + processor.process(new BasicTransportToDeviceSessionActorMsg(ctx.getDevice(), msg)); | |
223 | 223 | } |
224 | 224 | |
225 | 225 | private boolean quotaExceeded(HttpServletRequest request, DeferredResult<ResponseEntity> responseWriter) { | ... | ... |
... | ... | @@ -30,7 +30,7 @@ import org.thingsboard.server.common.data.Device; |
30 | 30 | import org.thingsboard.server.common.data.security.DeviceTokenCredentials; |
31 | 31 | import org.thingsboard.server.common.data.security.DeviceX509Credentials; |
32 | 32 | import org.thingsboard.server.common.msg.session.AdaptorToSessionActorMsg; |
33 | -import org.thingsboard.server.common.msg.session.BasicToDeviceActorSessionMsg; | |
33 | +import org.thingsboard.server.common.msg.session.BasicTransportToDeviceSessionActorMsg; | |
34 | 34 | import org.thingsboard.server.common.msg.session.ctrl.SessionCloseMsg; |
35 | 35 | import org.thingsboard.server.common.transport.SessionMsgProcessor; |
36 | 36 | import org.thingsboard.server.common.transport.adaptor.AdaptorException; |
... | ... | @@ -207,7 +207,7 @@ public class MqttTransportHandler extends ChannelInboundHandlerAdapter implement |
207 | 207 | log.warn("[{}] Failed to process publish msg [{}][{}]", sessionId, topicName, msgId, e); |
208 | 208 | } |
209 | 209 | if (msg != null) { |
210 | - processor.process(new BasicToDeviceActorSessionMsg(deviceSessionCtx.getDevice(), msg)); | |
210 | + processor.process(new BasicTransportToDeviceSessionActorMsg(deviceSessionCtx.getDevice(), msg)); | |
211 | 211 | } else { |
212 | 212 | log.info("[{}] Closing current session due to invalid publish msg [{}][{}]", sessionId, topicName, msgId); |
213 | 213 | ctx.close(); |
... | ... | @@ -227,11 +227,11 @@ public class MqttTransportHandler extends ChannelInboundHandlerAdapter implement |
227 | 227 | try { |
228 | 228 | if (topicName.equals(DEVICE_ATTRIBUTES_TOPIC)) { |
229 | 229 | AdaptorToSessionActorMsg msg = adaptor.convertToActorMsg(deviceSessionCtx, SUBSCRIBE_ATTRIBUTES_REQUEST, mqttMsg); |
230 | - processor.process(new BasicToDeviceActorSessionMsg(deviceSessionCtx.getDevice(), msg)); | |
230 | + processor.process(new BasicTransportToDeviceSessionActorMsg(deviceSessionCtx.getDevice(), msg)); | |
231 | 231 | grantedQoSList.add(getMinSupportedQos(reqQoS)); |
232 | 232 | } else if (topicName.equals(DEVICE_RPC_REQUESTS_SUB_TOPIC)) { |
233 | 233 | AdaptorToSessionActorMsg msg = adaptor.convertToActorMsg(deviceSessionCtx, SUBSCRIBE_RPC_COMMANDS_REQUEST, mqttMsg); |
234 | - processor.process(new BasicToDeviceActorSessionMsg(deviceSessionCtx.getDevice(), msg)); | |
234 | + processor.process(new BasicTransportToDeviceSessionActorMsg(deviceSessionCtx.getDevice(), msg)); | |
235 | 235 | grantedQoSList.add(getMinSupportedQos(reqQoS)); |
236 | 236 | } else if (topicName.equals(DEVICE_RPC_RESPONSE_SUB_TOPIC)) { |
237 | 237 | grantedQoSList.add(getMinSupportedQos(reqQoS)); |
... | ... | @@ -261,10 +261,10 @@ public class MqttTransportHandler extends ChannelInboundHandlerAdapter implement |
261 | 261 | try { |
262 | 262 | if (topicName.equals(DEVICE_ATTRIBUTES_TOPIC)) { |
263 | 263 | AdaptorToSessionActorMsg msg = adaptor.convertToActorMsg(deviceSessionCtx, UNSUBSCRIBE_ATTRIBUTES_REQUEST, mqttMsg); |
264 | - processor.process(new BasicToDeviceActorSessionMsg(deviceSessionCtx.getDevice(), msg)); | |
264 | + processor.process(new BasicTransportToDeviceSessionActorMsg(deviceSessionCtx.getDevice(), msg)); | |
265 | 265 | } else if (topicName.equals(DEVICE_RPC_REQUESTS_SUB_TOPIC)) { |
266 | 266 | AdaptorToSessionActorMsg msg = adaptor.convertToActorMsg(deviceSessionCtx, UNSUBSCRIBE_RPC_COMMANDS_REQUEST, mqttMsg); |
267 | - processor.process(new BasicToDeviceActorSessionMsg(deviceSessionCtx.getDevice(), msg)); | |
267 | + processor.process(new BasicTransportToDeviceSessionActorMsg(deviceSessionCtx.getDevice(), msg)); | |
268 | 268 | } else if (topicName.equals(DEVICE_ATTRIBUTES_RESPONSES_TOPIC)) { |
269 | 269 | deviceSessionCtx.setDisallowAttributeResponses(); |
270 | 270 | } | ... | ... |
... | ... | @@ -30,7 +30,7 @@ import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry; |
30 | 30 | import org.thingsboard.server.common.data.relation.EntityRelation; |
31 | 31 | import org.thingsboard.server.common.msg.core.*; |
32 | 32 | import org.thingsboard.server.common.msg.session.BasicAdaptorToSessionActorMsg; |
33 | -import org.thingsboard.server.common.msg.session.BasicToDeviceActorSessionMsg; | |
33 | +import org.thingsboard.server.common.msg.session.BasicTransportToDeviceSessionActorMsg; | |
34 | 34 | import org.thingsboard.server.common.msg.session.ctrl.SessionCloseMsg; |
35 | 35 | import org.thingsboard.server.common.transport.SessionMsgProcessor; |
36 | 36 | import org.thingsboard.server.common.transport.adaptor.AdaptorException; |
... | ... | @@ -96,8 +96,8 @@ public class GatewaySessionCtx { |
96 | 96 | GatewayDeviceSessionCtx ctx = new GatewayDeviceSessionCtx(this, device); |
97 | 97 | devices.put(deviceName, ctx); |
98 | 98 | log.debug("[{}] Added device [{}] to the gateway session", gatewaySessionId, deviceName); |
99 | - processor.process(new BasicToDeviceActorSessionMsg(device, new BasicAdaptorToSessionActorMsg(ctx, new AttributesSubscribeMsg()))); | |
100 | - processor.process(new BasicToDeviceActorSessionMsg(device, new BasicAdaptorToSessionActorMsg(ctx, new RpcSubscribeMsg()))); | |
99 | + processor.process(new BasicTransportToDeviceSessionActorMsg(device, new BasicAdaptorToSessionActorMsg(ctx, new AttributesSubscribeMsg()))); | |
100 | + processor.process(new BasicTransportToDeviceSessionActorMsg(device, new BasicAdaptorToSessionActorMsg(ctx, new RpcSubscribeMsg()))); | |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
... | ... | @@ -136,7 +136,7 @@ public class GatewaySessionCtx { |
136 | 136 | JsonConverter.parseWithTs(request, element.getAsJsonObject()); |
137 | 137 | } |
138 | 138 | GatewayDeviceSessionCtx deviceSessionCtx = devices.get(deviceName); |
139 | - processor.process(new BasicToDeviceActorSessionMsg(deviceSessionCtx.getDevice(), | |
139 | + processor.process(new BasicTransportToDeviceSessionActorMsg(deviceSessionCtx.getDevice(), | |
140 | 140 | new BasicAdaptorToSessionActorMsg(deviceSessionCtx, request))); |
141 | 141 | } |
142 | 142 | } else { |
... | ... | @@ -152,7 +152,7 @@ public class GatewaySessionCtx { |
152 | 152 | Integer requestId = jsonObj.get("id").getAsInt(); |
153 | 153 | String data = jsonObj.get("data").toString(); |
154 | 154 | GatewayDeviceSessionCtx deviceSessionCtx = devices.get(deviceName); |
155 | - processor.process(new BasicToDeviceActorSessionMsg(deviceSessionCtx.getDevice(), | |
155 | + processor.process(new BasicTransportToDeviceSessionActorMsg(deviceSessionCtx.getDevice(), | |
156 | 156 | new BasicAdaptorToSessionActorMsg(deviceSessionCtx, new ToDeviceRpcResponseMsg(requestId, data)))); |
157 | 157 | } else { |
158 | 158 | throw new JsonSyntaxException(CAN_T_PARSE_VALUE + json); |
... | ... | @@ -174,7 +174,7 @@ public class GatewaySessionCtx { |
174 | 174 | JsonObject deviceData = deviceEntry.getValue().getAsJsonObject(); |
175 | 175 | request.add(JsonConverter.parseValues(deviceData).stream().map(kv -> new BaseAttributeKvEntry(kv, ts)).collect(Collectors.toList())); |
176 | 176 | GatewayDeviceSessionCtx deviceSessionCtx = devices.get(deviceName); |
177 | - processor.process(new BasicToDeviceActorSessionMsg(deviceSessionCtx.getDevice(), | |
177 | + processor.process(new BasicTransportToDeviceSessionActorMsg(deviceSessionCtx.getDevice(), | |
178 | 178 | new BasicAdaptorToSessionActorMsg(deviceSessionCtx, request))); |
179 | 179 | } |
180 | 180 | } else { |
... | ... | @@ -207,7 +207,7 @@ public class GatewaySessionCtx { |
207 | 207 | request = new BasicGetAttributesRequest(requestId, null, keys); |
208 | 208 | } |
209 | 209 | GatewayDeviceSessionCtx deviceSessionCtx = devices.get(deviceName); |
210 | - processor.process(new BasicToDeviceActorSessionMsg(deviceSessionCtx.getDevice(), | |
210 | + processor.process(new BasicTransportToDeviceSessionActorMsg(deviceSessionCtx.getDevice(), | |
211 | 211 | new BasicAdaptorToSessionActorMsg(deviceSessionCtx, request))); |
212 | 212 | ack(msg); |
213 | 213 | } else { | ... | ... |