From b0cac2f9008b567a694c08a4c77ead7a52011551 Mon Sep 17 00:00:00 2001 From: Michael Darakananda Date: Fri, 6 Jan 2017 12:58:10 +1100 Subject: [PATCH] delete PullOption (#1507) --- .../java/com/google/cloud/pubsub/PubSub.java | 58 ------------------- .../com/google/cloud/pubsub/PubSubTest.java | 14 ----- .../cloud/pubsub/SerializationTest.java | 6 -- .../google/cloud/pubsub/SubscriptionTest.java | 1 - 4 files changed, 79 deletions(-) diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/PubSub.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/PubSub.java index d58234a4a45b..43e558347551 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/PubSub.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/PubSub.java @@ -77,64 +77,6 @@ public static ListOption pageToken(String pageToken) { } } - /** Class for specifying options for pulling messages. */ - final class PullOption extends Option { - - private static final long serialVersionUID = 4792164134340316582L; - - enum OptionType implements Option.OptionType { - EXECUTOR_FACTORY, - MAX_QUEUED_CALLBACKS; - - @SuppressWarnings("unchecked") - T get(Map options) { - return (T) options.get(this); - } - - Integer getInteger(Map options) { - return get(options); - } - - ExecutorFactory getExecutorFactory(Map options) { - return get(options); - } - } - - private PullOption(Option.OptionType option, Object value) { - super(option, value); - } - - /** - * Returns an option to specify the maximum number of messages that can be queued in the message - * consumer at any time. Queued messages are already pulled messages that are either waiting to - * be processed or being processed. Queued messages will have their acknowledge deadline renewed - * until they are acknowledged or "nacked". If not provided, at most 100 messages can be in the - * queue. - */ - public static PullOption maxQueuedCallbacks(int maxQueuedCallbacks) { - return new PullOption(OptionType.MAX_QUEUED_CALLBACKS, maxQueuedCallbacks); - } - - /** - * Returns an option to specify the executor used to execute message processor callbacks. The - * executor determines the number of messages that can be processed at the same time. If not - * provided, a single-threaded executor is used to execute message processor callbacks. - * - *

The {@link ExecutorFactory} object can be used to handle creation and release of the - * executor, possibly reusing existing executors. {@link ExecutorFactory#get()} is called when - * the message consumer is created. {@link ExecutorFactory#release(ExecutorService)} is called - * when the message consumer is closed. - * - *

For the created option to be serializable, the provided executor factory should implement - * {@link java.io.Serializable}. - * - * @param executorFactory the executor factory. - */ - public static PullOption executorFactory(ExecutorFactory executorFactory) { - return new PullOption(OptionType.EXECUTOR_FACTORY, executorFactory); - } - } - /** * Creates a new topic. * diff --git a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/PubSubTest.java b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/PubSubTest.java index 78322f4eed95..940e35e3f7ad 100644 --- a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/PubSubTest.java +++ b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/PubSubTest.java @@ -21,7 +21,6 @@ import com.google.cloud.GrpcServiceOptions.ExecutorFactory; import com.google.cloud.pubsub.PubSub.ListOption; -import com.google.cloud.pubsub.PubSub.PullOption; import org.easymock.EasyMock; import org.junit.Test; @@ -43,17 +42,4 @@ public void testListOption() { assertEquals(PAGE_SIZE, listOption.getValue()); assertEquals(ListOption.OptionType.PAGE_SIZE, listOption.getOptionType()); } - - @Test - @SuppressWarnings("unchecked") - public void testPullOptions() { - // max queued callbacks - PullOption pullOption = PullOption.maxQueuedCallbacks(MAX_QUEUED_CALLBACKS); - assertEquals(MAX_QUEUED_CALLBACKS, pullOption.getValue()); - assertEquals(PullOption.OptionType.MAX_QUEUED_CALLBACKS, pullOption.getOptionType()); - ExecutorFactory executorFactory = EasyMock.createStrictMock(ExecutorFactory.class); - pullOption = PullOption.executorFactory(executorFactory); - assertSame(executorFactory, pullOption.getValue()); - assertEquals(PullOption.OptionType.EXECUTOR_FACTORY, pullOption.getOptionType()); - } } diff --git a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/SerializationTest.java b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/SerializationTest.java index 30c7e1ea5685..7a284705c133 100644 --- a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/SerializationTest.java +++ b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/SerializationTest.java @@ -21,7 +21,6 @@ import com.google.cloud.NoCredentials; import com.google.cloud.Restorable; import com.google.cloud.pubsub.PubSub.ListOption; -import com.google.cloud.pubsub.PubSub.PullOption; import java.io.Serializable; import java.util.concurrent.ScheduledExecutorService; @@ -41,9 +40,6 @@ public class SerializationTest extends BaseSerializationTest { new Topic(PUB_SUB, new TopicInfo.BuilderImpl(TOPIC_INFO)); private static final ListOption PAGE_TOKEN_OPTION = ListOption.pageToken("cursor"); private static final ListOption PAGE_SIZE_OPTION = ListOption.pageSize(42); - private static final PullOption MAX_QUEUED_CALLBACKS_OPTION = PullOption.maxQueuedCallbacks(42); - private static final PullOption EXECUTOR_FACTORY_OPTION = - PullOption.executorFactory(new TestExecutorFactory()); public static class TestExecutorFactory implements ExecutorFactory, Serializable { @@ -91,8 +87,6 @@ protected Serializable[] serializableObjects() { TOPIC, PAGE_TOKEN_OPTION, PAGE_SIZE_OPTION, - MAX_QUEUED_CALLBACKS_OPTION, - EXECUTOR_FACTORY_OPTION }; } diff --git a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/SubscriptionTest.java b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/SubscriptionTest.java index a70ab0efcd87..0df868983d2b 100644 --- a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/SubscriptionTest.java +++ b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/SubscriptionTest.java @@ -30,7 +30,6 @@ import com.google.cloud.Identity; import com.google.cloud.Policy; import com.google.cloud.Role; -import com.google.cloud.pubsub.PubSub.PullOption; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.util.concurrent.Futures;