Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RpcContext新增remoteApplicationName字段 #3816

Merged
merged 1 commit into from
Apr 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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