From 544cd3a33b03e5122ca5eb78fd7e760dc6d65da1 Mon Sep 17 00:00:00 2001 From: Carl Mastrangelo Date: Wed, 10 Feb 2016 10:40:16 -0800 Subject: [PATCH] pause --- .../java/io/grpc/auth/ClientAuthInterceptor.java | 7 +++---- .../io/grpc/auth/ClientAuthInterceptorTests.java | 16 +++++++++------- .../io/grpc/benchmarks/TransportBenchmark.java | 4 ++-- .../io/grpc/benchmarks/qps/OpenLoopClient.java | 2 +- .../java/io/grpc/internal/ClientCallImpl.java | 5 ++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/auth/src/main/java/io/grpc/auth/ClientAuthInterceptor.java b/auth/src/main/java/io/grpc/auth/ClientAuthInterceptor.java index add337f8f2..1a3fac9b15 100644 --- a/auth/src/main/java/io/grpc/auth/ClientAuthInterceptor.java +++ b/auth/src/main/java/io/grpc/auth/ClientAuthInterceptor.java @@ -64,12 +64,11 @@ public final class ClientAuthInterceptor implements ClientInterceptor { private Metadata cached; private Map> lastMetadata; - // TODO(louiscryan): refresh token asynchronously with this executor. - private Executor executor; - public ClientAuthInterceptor(Credentials credentials, Executor executor) { + public ClientAuthInterceptor( + Credentials credentials, @SuppressWarnings("unused") Executor executor) { this.credentials = Preconditions.checkNotNull(credentials); - this.executor = Preconditions.checkNotNull(executor); + // TODO(louiscryan): refresh token asynchronously with this executor. } @Override diff --git a/auth/src/test/java/io/grpc/auth/ClientAuthInterceptorTests.java b/auth/src/test/java/io/grpc/auth/ClientAuthInterceptorTests.java index 6736bd0964..e561ee8c63 100644 --- a/auth/src/test/java/io/grpc/auth/ClientAuthInterceptorTests.java +++ b/auth/src/test/java/io/grpc/auth/ClientAuthInterceptorTests.java @@ -46,6 +46,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.ListMultimap; import com.google.common.collect.Multimaps; +import com.google.common.util.concurrent.MoreExecutors; import io.grpc.CallOptions; import io.grpc.Channel; @@ -68,7 +69,7 @@ import org.mockito.MockitoAnnotations; import java.io.IOException; import java.net.URI; import java.util.Date; -import java.util.concurrent.Executors; +import java.util.concurrent.Executor; /** * Tests for {@link ClientAuthInterceptor}. @@ -76,11 +77,13 @@ import java.util.concurrent.Executors; @RunWith(JUnit4.class) public class ClientAuthInterceptorTests { - public static final Metadata.Key AUTHORIZATION = Metadata.Key.of("Authorization", + private static final Metadata.Key AUTHORIZATION = Metadata.Key.of("Authorization", Metadata.ASCII_STRING_MARSHALLER); - public static final Metadata.Key EXTRA_AUTHORIZATION = Metadata.Key.of( + private static final Metadata.Key EXTRA_AUTHORIZATION = Metadata.Key.of( "Extra-Authorization", Metadata.ASCII_STRING_MARSHALLER); + private final Executor executor = MoreExecutors.directExecutor(); + @Mock Credentials credentials; @@ -105,14 +108,13 @@ public class ClientAuthInterceptorTests { /** Set up for test. */ @Before - public void startUp() throws IOException { + public void startUp() { MockitoAnnotations.initMocks(this); descriptor = MethodDescriptor.create( MethodDescriptor.MethodType.UNKNOWN, "a.service/method", stringMarshaller, intMarshaller); when(channel.newCall(same(descriptor), any(CallOptions.class))).thenReturn(call); doReturn("localhost:443").when(channel).authority(); - interceptor = new ClientAuthInterceptor(credentials, - Executors.newSingleThreadExecutor()); + interceptor = new ClientAuthInterceptor(credentials, executor); } @Test @@ -161,7 +163,7 @@ public class ClientAuthInterceptorTests { return token; } }; - interceptor = new ClientAuthInterceptor(oAuth2Credentials, Executors.newSingleThreadExecutor()); + interceptor = new ClientAuthInterceptor(oAuth2Credentials, executor); ClientCall interceptedCall = interceptor.interceptCall(descriptor, CallOptions.DEFAULT, channel); Metadata headers = new Metadata(); diff --git a/benchmarks/src/jmh/java/io/grpc/benchmarks/TransportBenchmark.java b/benchmarks/src/jmh/java/io/grpc/benchmarks/TransportBenchmark.java index 8381bf5bfb..469a2e26fe 100644 --- a/benchmarks/src/jmh/java/io/grpc/benchmarks/TransportBenchmark.java +++ b/benchmarks/src/jmh/java/io/grpc/benchmarks/TransportBenchmark.java @@ -85,8 +85,8 @@ public class TransportBenchmark { @Setup public void setUp() throws Exception { - AbstractServerImplBuilder serverBuilder; - AbstractManagedChannelImplBuilder channelBuilder; + AbstractServerImplBuilder serverBuilder; + AbstractManagedChannelImplBuilder channelBuilder; switch (transport) { case INPROCESS: { diff --git a/benchmarks/src/main/java/io/grpc/benchmarks/qps/OpenLoopClient.java b/benchmarks/src/main/java/io/grpc/benchmarks/qps/OpenLoopClient.java index ad29a4b15c..97e026eda8 100644 --- a/benchmarks/src/main/java/io/grpc/benchmarks/qps/OpenLoopClient.java +++ b/benchmarks/src/main/java/io/grpc/benchmarks/qps/OpenLoopClient.java @@ -221,7 +221,7 @@ public class OpenLoopClient { }); } - private void waitForRpcsToComplete(int duration) throws InterruptedException { + private void waitForRpcsToComplete(int duration) { long now = System.nanoTime(); long end = now + duration * 1000 * 1000 * 1000; while (histogram.getTotalCount() < numRpcs && now < end) { diff --git a/core/src/main/java/io/grpc/internal/ClientCallImpl.java b/core/src/main/java/io/grpc/internal/ClientCallImpl.java index bfc554df01..20b5610e36 100644 --- a/core/src/main/java/io/grpc/internal/ClientCallImpl.java +++ b/core/src/main/java/io/grpc/internal/ClientCallImpl.java @@ -46,7 +46,6 @@ import com.google.common.base.Throwables; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.MoreExecutors; import io.grpc.CallOptions; import io.grpc.ClientCall; @@ -98,7 +97,7 @@ final class ClientCallImpl extends ClientCall // If we know that the executor is a direct executor, we don't need to wrap it with a // SerializingExecutor. This is purely for performance reasons. // See https://github.com/grpc/grpc-java/issues/368 - this.callExecutor = executor == MoreExecutors.directExecutor() + this.callExecutor = executor == directExecutor() ? new SerializeReentrantCallsDirectExecutor() : new SerializingExecutor(executor); // Propagate the context from the thread which initiated the call to all callbacks. @@ -254,7 +253,7 @@ final class ClientCallImpl extends ClientCall } } // Propagate later Context cancellation to the remote side. - this.context.addListener(this, MoreExecutors.directExecutor()); + this.context.addListener(this, directExecutor()); } /**