Skip to content

Commit b70b3ea

Browse files
yizhenqianghtynkn
authored andcommitted
Add remoteApplicationName in RpcContext (#3816)
1 parent 2d2be07 commit b70b3ea

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcContext.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ protected RpcContext initialValue() {
8585
private InetSocketAddress localAddress;
8686

8787
private InetSocketAddress remoteAddress;
88+
89+
private String remoteApplicationName;
90+
8891
@Deprecated
8992
private List<Invoker<?>> invokers;
9093
@Deprecated
@@ -149,6 +152,7 @@ public RpcContext copyOf() {
149152
copy.arguments = this.arguments;
150153
copy.localAddress = this.localAddress;
151154
copy.remoteAddress = this.remoteAddress;
155+
copy.remoteApplicationName = this.remoteApplicationName;
152156
copy.invokers = this.invokers;
153157
copy.invoker = this.invoker;
154158
copy.invocation = this.invocation;
@@ -407,6 +411,15 @@ public RpcContext setRemoteAddress(InetSocketAddress address) {
407411
return this;
408412
}
409413

414+
public String getRemoteApplicationName() {
415+
return remoteApplicationName;
416+
}
417+
418+
public RpcContext setRemoteApplicationName(String remoteApplicationName) {
419+
this.remoteApplicationName = remoteApplicationName;
420+
return this;
421+
}
422+
410423
/**
411424
* get remote address string.
412425
*

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ContextFilter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import java.util.HashMap;
3030
import java.util.Map;
3131

32+
import static org.apache.dubbo.common.Constants.REMOTE_APPLICATION_KEY;
33+
3234
/**
3335
* ContextFilter set the provider RpcContext with invoker, invocation, local port it is using and host for
3436
* current execution thread.
@@ -59,8 +61,8 @@ public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcExcept
5961
.setInvoker(invoker)
6062
.setInvocation(invocation)
6163
// .setAttachments(attachments) // merged from dubbox
62-
.setLocalAddress(invoker.getUrl().getHost(),
63-
invoker.getUrl().getPort());
64+
.setLocalAddress(invoker.getUrl().getHost(), invoker.getUrl().getPort())
65+
.setRemoteApplicationName(invoker.getUrl().getParameter(REMOTE_APPLICATION_KEY));
6466

6567
// merged from dubbox
6668
// we may already added some attachments into RpcContext before this filter (e.g. in rest protocol)

0 commit comments

Comments
 (0)