Skip to content

Commit

Permalink
Add remoteApplicationName in RpcContext (#3816)
Browse files Browse the repository at this point in the history
  • Loading branch information
manzhizhen authored and htynkn committed Apr 10, 2019
1 parent 2d2be07 commit b70b3ea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ protected RpcContext initialValue() {
private InetSocketAddress localAddress;

private InetSocketAddress remoteAddress;

private String remoteApplicationName;

@Deprecated
private List<Invoker<?>> invokers;
@Deprecated
Expand Down Expand Up @@ -149,6 +152,7 @@ public RpcContext copyOf() {
copy.arguments = this.arguments;
copy.localAddress = this.localAddress;
copy.remoteAddress = this.remoteAddress;
copy.remoteApplicationName = this.remoteApplicationName;
copy.invokers = this.invokers;
copy.invoker = this.invoker;
copy.invocation = this.invocation;
Expand Down Expand Up @@ -407,6 +411,15 @@ public RpcContext setRemoteAddress(InetSocketAddress address) {
return this;
}

public String getRemoteApplicationName() {
return remoteApplicationName;
}

public RpcContext setRemoteApplicationName(String remoteApplicationName) {
this.remoteApplicationName = remoteApplicationName;
return this;
}

/**
* get remote address string.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import java.util.HashMap;
import java.util.Map;

import static org.apache.dubbo.common.Constants.REMOTE_APPLICATION_KEY;

/**
* ContextFilter set the provider RpcContext with invoker, invocation, local port it is using and host for
* current execution thread.
Expand Down Expand Up @@ -59,8 +61,8 @@ public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcExcept
.setInvoker(invoker)
.setInvocation(invocation)
// .setAttachments(attachments) // merged from dubbox
.setLocalAddress(invoker.getUrl().getHost(),
invoker.getUrl().getPort());
.setLocalAddress(invoker.getUrl().getHost(), invoker.getUrl().getPort())
.setRemoteApplicationName(invoker.getUrl().getParameter(REMOTE_APPLICATION_KEY));

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

0 comments on commit b70b3ea

Please sign in to comment.