Skip to content

Commit eee58d7

Browse files
committed
Add RpcAddressable to allow upper layer adding address mapping logic for its business object
1 parent 1688919 commit eee58d7

6 files changed

Lines changed: 97 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.cloudstack.framework.messaging;
20+
21+
public interface RpcAddressable {
22+
String getAddress();
23+
}

‎framework/ipc/src/org/apache/cloudstack/framework/messaging/RpcProvider.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ public interface RpcProvider extends TransportMultiplexier {
2727
void registerRpcServiceEndpoint(RpcServiceEndpoint rpcEndpoint);
2828
void unregisteRpcServiceEndpoint(RpcServiceEndpoint rpcEndpoint);
2929

30+
RpcClientCall newCall(TransportEndpoint sourceEndpoint, RpcAddressable targetAddress);
3031
RpcClientCall newCall(TransportEndpoint sourceEndpoint, String targetAddress);
32+
3133
RpcClientCall newCall(String targetAddress);
34+
RpcClientCall newCall(RpcAddressable targetAddress);
3235

3336
void registerCall(RpcClientCall call);
3437
void cancelCall(RpcClientCall call);

‎framework/ipc/src/org/apache/cloudstack/framework/messaging/RpcProviderImpl.java‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ public RpcClientCall newCall(TransportEndpoint sourceEndpoint, String targetAddr
9292

9393
return call;
9494
}
95+
96+
@Override
97+
public RpcClientCall newCall(TransportEndpoint sourceEndpoint, RpcAddressable targetAddress) {
98+
long callTag = getNextCallTag();
99+
RpcClientCallImpl call = new RpcClientCallImpl(this);
100+
call.setSourceAddress(sourceEndpoint.getEndpointAddress());
101+
call.setTargetAddress(targetAddress.getAddress());
102+
call.setCallTag(callTag);
103+
104+
return call;
105+
}
95106

96107
@Override
97108
public RpcClientCall newCall(String targetAddress) {
@@ -100,6 +111,12 @@ public RpcClientCall newCall(String targetAddress) {
100111
return null;
101112
}
102113

114+
@Override
115+
public RpcClientCall newCall(RpcAddressable targetAddress) {
116+
return newCall(targetAddress.getAddress());
117+
}
118+
119+
103120
@Override
104121
public void registerCall(RpcClientCall call) {
105122
assert(call != null);

‎framework/ipc/test/org/apache/cloudstack/framework/messaging/ClientOnlyEventDrivenStyle.java‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
119
package org.apache.cloudstack.framework.messaging;
220

321
public class ClientOnlyEventDrivenStyle {

‎framework/ipc/test/org/apache/cloudstack/framework/messaging/ClientOnlyListenerStyle.java‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
119
package org.apache.cloudstack.framework.messaging;
220

321
public class ClientOnlyListenerStyle {

‎framework/ipc/test/org/apache/cloudstack/framework/messaging/TestCommand.java‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
119
package org.apache.cloudstack.framework.messaging;
220

321
@OnwireName(name="TestCommand")

0 commit comments

Comments
 (0)