From 595174709561e4786d663c03d3ea41885163cc2d Mon Sep 17 00:00:00 2001 From: Jan Bols Date: Fri, 6 Jul 2018 17:19:33 +0200 Subject: [PATCH 1/2] When firing an RpcBroadcastMsg message or a ToAllNodesMsg from one node, the other nodes never get notified because the messages doesn't have a serverAddress. As a result firing such a method is not forwarded to the other cluster nodes. This PR adds the serverAddress for each node that the message is sent to so the other nodes get the message and can react to component lifecycle changes. --- .../server/actors/rpc/RpcManagerActor.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/actors/rpc/RpcManagerActor.java b/application/src/main/java/org/thingsboard/server/actors/rpc/RpcManagerActor.java index 3f3f70b424..2034d6fbd3 100644 --- a/application/src/main/java/org/thingsboard/server/actors/rpc/RpcManagerActor.java +++ b/application/src/main/java/org/thingsboard/server/actors/rpc/RpcManagerActor.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -29,11 +29,7 @@ import org.thingsboard.server.common.msg.cluster.ServerAddress; import org.thingsboard.server.gen.cluster.ClusterAPIProtos; import org.thingsboard.server.service.cluster.discovery.ServerInstance; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.Queue; -import java.util.UUID; +import java.util.*; /** * @author Andrew Shvayka @@ -88,7 +84,17 @@ public class RpcManagerActor extends ContextAwareActor { private void onMsg(RpcBroadcastMsg msg) { log.debug("Forwarding msg to session actors {}", msg); - sessionActors.keySet().forEach(address -> onMsg(msg.getMsg())); + sessionActors.keySet().forEach(address -> { + ClusterAPIProtos.ClusterMessage msgWithServerAddress = msg.getMsg() + .toBuilder() + .setServerAddress(ClusterAPIProtos.ServerAddress + .newBuilder() + .setHost(address.getHost()) + .setPort(address.getPort()) + .build()) + .build(); + onMsg(msgWithServerAddress); + }); pendingMsgs.values().forEach(queue -> queue.add(msg.getMsg())); } From 5f258b95d92a5049f2b20354761982aed0aff94a Mon Sep 17 00:00:00 2001 From: Jan Bols Date: Fri, 6 Jul 2018 22:37:04 +0200 Subject: [PATCH 2/2] Keep exact header. --- .../java/org/thingsboard/server/actors/rpc/RpcManagerActor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/java/org/thingsboard/server/actors/rpc/RpcManagerActor.java b/application/src/main/java/org/thingsboard/server/actors/rpc/RpcManagerActor.java index 2034d6fbd3..9e38c17aff 100644 --- a/application/src/main/java/org/thingsboard/server/actors/rpc/RpcManagerActor.java +++ b/application/src/main/java/org/thingsboard/server/actors/rpc/RpcManagerActor.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS,