Showing
3 changed files
with
34 additions
and
67 deletions
application/src/main/java/org/thingsboard/server/service/cluster/rpc/RpcSessionCreationFuture.java
deleted
100644 → 0
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.service.cluster.rpc; | |
17 | - | |
18 | -import io.grpc.stub.StreamObserver; | |
19 | -import org.thingsboard.server.gen.cluster.ClusterAPIProtos; | |
20 | - | |
21 | -import java.util.concurrent.*; | |
22 | - | |
23 | -/** | |
24 | - * @author Andrew Shvayka | |
25 | - */ | |
26 | -public class RpcSessionCreationFuture implements Future<StreamObserver<ClusterAPIProtos.ToRpcServerMessage>> { | |
27 | - | |
28 | - private final BlockingQueue<StreamObserver<ClusterAPIProtos.ToRpcServerMessage>> queue = new ArrayBlockingQueue<>(1); | |
29 | - | |
30 | - public void onMsg(StreamObserver<ClusterAPIProtos.ToRpcServerMessage> result) throws InterruptedException { | |
31 | - queue.put(result); | |
32 | - } | |
33 | - | |
34 | - @Override | |
35 | - public boolean cancel(boolean mayInterruptIfRunning) { | |
36 | - return false; | |
37 | - } | |
38 | - | |
39 | - @Override | |
40 | - public boolean isCancelled() { | |
41 | - return false; | |
42 | - } | |
43 | - | |
44 | - @Override | |
45 | - public boolean isDone() { | |
46 | - return false; | |
47 | - } | |
48 | - | |
49 | - @Override | |
50 | - public StreamObserver<ClusterAPIProtos.ToRpcServerMessage> get() throws InterruptedException, ExecutionException { | |
51 | - return this.queue.take(); | |
52 | - } | |
53 | - | |
54 | - @Override | |
55 | - public StreamObserver<ClusterAPIProtos.ToRpcServerMessage> get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { | |
56 | - StreamObserver<ClusterAPIProtos.ToRpcServerMessage> result = this.queue.poll(timeout, unit); | |
57 | - if (result == null) { | |
58 | - throw new TimeoutException(); | |
59 | - } else { | |
60 | - return result; | |
61 | - } | |
62 | - } | |
63 | -} |
... | ... | @@ -95,3 +95,33 @@ service ClusterRpcService { |
95 | 95 | rpc handlePluginMsgs(stream ToRpcServerMessage) returns (stream ToRpcServerMessage) {} |
96 | 96 | } |
97 | 97 | |
98 | +message ClusterMessage { | |
99 | + MessageType messageType = 1; | |
100 | + MessageMataInfo messageMetaInfo = 2; | |
101 | + ServerAddress serverAdresss = 3; | |
102 | + bytes payload = 4; | |
103 | +} | |
104 | + | |
105 | +message ServerAddress { | |
106 | + string host = 1; | |
107 | + int32 port = 2; | |
108 | +} | |
109 | + | |
110 | +message MessageMataInfo { | |
111 | + string payloadMetaInfo = 1; | |
112 | + repeated string tags = 2; | |
113 | +} | |
114 | + | |
115 | + | |
116 | +enum MessageType { | |
117 | + | |
118 | + //Cluster control messages | |
119 | + RPC_SESSION_CREATE_REQUEST_MSG = 0; | |
120 | + TO_ALL_NODES_MSG = 1; | |
121 | + RPC_SESSION_TELL_MSG = 2; | |
122 | + RPC_BROADCAST_MSG = 3; | |
123 | + CONNECT_RPC_MESSAGE =4; | |
124 | + | |
125 | + //CLUSTER_DATA_MESSAGE | |
126 | + CLUSTER_NETWORK_SERVER_DATA_MESSAGE = 5; | |
127 | +} | ... | ... |
rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbAlarmNode.java
1 | 1 | /** |
2 | 2 | * Copyright © 2016-2018 The Thingsboard Authors |
3 | - * <p> | |
3 | + * | |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
6 | 6 | * You may obtain a copy of the License at |
7 | - * <p> | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * <p> | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ... | ... |