You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by wu...@apache.org on 2018/03/29 07:24:40 UTC
[incubator-skywalking] branch feature/token-auth updated: Fix ci.
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch feature/token-auth
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git
The following commit(s) were added to refs/heads/feature/token-auth by this push:
new 10fb37d Fix ci.
10fb37d is described below
commit 10fb37d63b11696db686c89c08ea05e64ab7ce22
Author: wusheng <wu...@foxmail.com>
AuthorDate: Thu Mar 29 15:24:32 2018 +0800
Fix ci.
---
.../agent/core/remote/AuthenticationFilter.java | 20 +++-----
.../apm/agent/core/remote/GRPCChannelManager.java | 53 +++++++++++-----------
2 files changed, 34 insertions(+), 39 deletions(-)
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/AuthenticationFilter.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/AuthenticationFilter.java
index de55dcd..cd12168 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/AuthenticationFilter.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/AuthenticationFilter.java
@@ -18,15 +18,7 @@
package org.apache.skywalking.apm.agent.core.remote;
-import io.grpc.CallOptions;
-import io.grpc.Channel;
-import io.grpc.ClientCall;
-import io.grpc.ClientInterceptor;
-import io.grpc.ClientInterceptors;
-import io.grpc.ForwardingClientCall;
-import io.grpc.ManagedChannel;
-import io.grpc.Metadata;
-import io.grpc.MethodDescriptor;
+import io.grpc.*;
import org.apache.skywalking.apm.agent.core.conf.Config;
import org.apache.skywalking.apm.util.StringUtil;
@@ -37,7 +29,7 @@ import org.apache.skywalking.apm.util.StringUtil;
*/
public class AuthenticationFilter implements ClientInterceptor {
private static final Metadata.Key<String> AUTH_HEAD_HEADER_NAME =
- Metadata.Key.of("Authentication", Metadata.ASCII_STRING_MARSHALLER);
+ Metadata.Key.of("Authentication", Metadata.ASCII_STRING_MARSHALLER);
public static Channel build(ManagedChannel originChannel) {
if (StringUtil.isEmpty(Config.Agent.AUTHENTICATION)) {
@@ -47,10 +39,12 @@ public class AuthenticationFilter implements ClientInterceptor {
return ClientInterceptors.intercept(originChannel, new AuthenticationFilter());
}
- @Override public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(MethodDescriptor<ReqT, RespT> method,
- CallOptions options, Channel channel) {
+ @Override
+ public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(MethodDescriptor<ReqT, RespT> method,
+ CallOptions options, Channel channel) {
return new ForwardingClientCall.SimpleForwardingClientCall<ReqT, RespT>(channel.newCall(method, options)) {
- @Override public void start(Listener<RespT> responseListener, Metadata headers) {
+ @Override
+ public void start(Listener<RespT> responseListener, Metadata headers) {
headers.put(AUTH_HEAD_HEADER_NAME, Config.Agent.AUTHENTICATION);
super.start(responseListener, headers);
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannelManager.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannelManager.java
index 770d830..54cc88f 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannelManager.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannelManager.java
@@ -24,13 +24,6 @@ import io.grpc.Status;
import io.grpc.StatusRuntimeException;
import io.grpc.internal.DnsNameResolverProvider;
import io.grpc.netty.NettyChannelBuilder;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Random;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
import org.apache.skywalking.apm.agent.core.boot.BootService;
import org.apache.skywalking.apm.agent.core.boot.DefaultNamedThreadFactory;
import org.apache.skywalking.apm.agent.core.conf.Config;
@@ -39,6 +32,14 @@ import org.apache.skywalking.apm.agent.core.logging.api.ILog;
import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
import org.apache.skywalking.apm.util.RunnableWithExceptionProtection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
/**
* @author wusheng
*/
@@ -60,13 +61,13 @@ public class GRPCChannelManager implements BootService, Runnable {
@Override
public void boot() throws Throwable {
connectCheckFuture = Executors
- .newSingleThreadScheduledExecutor(new DefaultNamedThreadFactory("GRPCChannelManager"))
- .scheduleAtFixedRate(new RunnableWithExceptionProtection(this, new RunnableWithExceptionProtection.CallbackWhenException() {
- @Override
- public void handle(Throwable t) {
- logger.error("unexpected exception.", t);
- }
- }), 0, Config.Collector.GRPC_CHANNEL_CHECK_INTERVAL, TimeUnit.SECONDS);
+ .newSingleThreadScheduledExecutor(new DefaultNamedThreadFactory("GRPCChannelManager"))
+ .scheduleAtFixedRate(new RunnableWithExceptionProtection(this, new RunnableWithExceptionProtection.CallbackWhenException() {
+ @Override
+ public void handle(Throwable t) {
+ logger.error("unexpected exception.", t);
+ }
+ }), 0, Config.Collector.GRPC_CHANNEL_CHECK_INTERVAL, TimeUnit.SECONDS);
}
@Override
@@ -94,12 +95,12 @@ public class GRPCChannelManager implements BootService, Runnable {
server = RemoteDownstreamConfig.Collector.GRPC_SERVERS.get(index);
String[] ipAndPort = server.split(":");
NettyChannelBuilder channelBuilder =
- new TLSChannelBuilder(
- NettyChannelBuilder.forAddress(ipAndPort[0], Integer.parseInt(ipAndPort[1]))
- .nameResolverFactory(new DnsNameResolverProvider())
- .maxInboundMessageSize(1024 * 1024 * 50)
- .usePlaintext(true)
- ).buildTLS();
+ new TLSChannelBuilder(
+ NettyChannelBuilder.forAddress(ipAndPort[0], Integer.parseInt(ipAndPort[1]))
+ .nameResolverFactory(new DnsNameResolverProvider())
+ .maxInboundMessageSize(1024 * 1024 * 50)
+ .usePlaintext(true)
+ ).buildTLS();
managedChannel = channelBuilder.build();
publicChannelRef = AuthenticationFilter.build(managedChannel);
if (!managedChannel.isShutdown() && !managedChannel.isTerminated()) {
@@ -150,13 +151,13 @@ public class GRPCChannelManager implements BootService, Runnable {
private boolean isNetworkError(Throwable throwable) {
if (throwable instanceof StatusRuntimeException) {
- StatusRuntimeException statusRuntimeException = (StatusRuntimeException)throwable;
+ StatusRuntimeException statusRuntimeException = (StatusRuntimeException) throwable;
return statusEquals(statusRuntimeException.getStatus(),
- Status.UNAVAILABLE,
- Status.PERMISSION_DENIED,
- Status.UNAUTHENTICATED,
- Status.RESOURCE_EXHAUSTED,
- Status.UNKNOWN
+ Status.UNAVAILABLE,
+ Status.PERMISSION_DENIED,
+ Status.UNAUTHENTICATED,
+ Status.RESOURCE_EXHAUSTED,
+ Status.UNKNOWN
);
}
return false;
--
To stop receiving notification emails like this one, please contact
wusheng@apache.org.