public static SphereClient of(final SphereClient delegate, final int maxParallelRequests) { return of(delegate, maxParallelRequests, true); } }
public static SphereClient of(final SphereClient delegate, final int maxParallelRequests) { return new QueueSphereClientDecorator(delegate, maxParallelRequests); } }
public static SphereClient of(final SphereClient delegate, final int maxParallelRequests) { return of(delegate, maxParallelRequests, true); } }
public static SphereClient of(final SphereClient delegate, final int maxParallelRequests, final boolean closeUnderlyingClient) { return new QueueSphereClientDecorator(delegate, maxParallelRequests, closeUnderlyingClient); }
public static SphereClient of(final SphereClient delegate, final int maxParallelRequests) { return of(delegate, maxParallelRequests, true); } }
public static SphereClient of(final SphereClient delegate, final int maxParallelRequests, final boolean closeUnderlyingClient) { return new QueueSphereClientDecorator(delegate, maxParallelRequests, closeUnderlyingClient); }
RunningSubscription(final QueryDsl<T, C> seedQuery, final Function<T, String> idExtractor, final SphereClient sphereClient, final Subscriber<? super T> subscriber, final SubscriptionImpl<T, C> tcSubscription) { this.idExtractor = idExtractor; this.tcSubscription = tcSubscription; this.seedQuery = seedQuery.withSort(QuerySort.of("id asc")).withFetchTotal(false); this.sphereClient = QueueSphereClientDecorator.of(sphereClient, 1, false); this.subscriber = subscriber; }
public static SphereClient of(final SphereClient delegate, final int maxParallelRequests, final boolean closeUnderlyingClient) { return new QueueSphereClientDecorator(delegate, maxParallelRequests, closeUnderlyingClient); }
ForAllSubscription(final QueryDsl<T, C> seedQuery, final SphereClient sphereClient, final Subscriber<? super T> subscriber) { this.seedQuery = seedQuery.withSort(QuerySort.of("id asc")).withFetchTotal(false).withLimit(ELEMENTS_PER_QUERY); this.sphereClient = QueueSphereClientDecorator.of(sphereClient, 1, false); this.subscriber = subscriber; }
@Test public void worksAtAll() throws Exception { final SphereClient client = QueueSphereClientDecorator.of(FAKE_SPHERE_CLIENT, 100); final String s = execute(client, SPHERE_REQUEST_SUCCESS); assertThat(s).isEqualTo(DUMMY_RESULT); }
@Test public void underTheLimitNewRequestsAreProcessed() throws Exception { final SphereClient client = QueueSphereClientDecorator.of(FAKE_SPHERE_CLIENT, MAX_PARALLEL_REQUESTS); for (int i = 0; i < MAX_PARALLEL_REQUESTS - 1; i++) { client.execute(SPHERE_REQUEST_FINISH_ON_COMMAND); } final String s = execute(client, SPHERE_REQUEST_SUCCESS); assertThat(s).isEqualTo(DUMMY_RESULT); }
@Test public void requestsOverMaxParallelAreNotProcessed() throws Exception { final FakeSphereClient delegate = new FakeSphereClient(); final SphereClient client = QueueSphereClientDecorator.of(delegate, MAX_PARALLEL_REQUESTS); final int numberOfRequests = MAX_PARALLEL_REQUESTS + 20; for (int i = 0; i < numberOfRequests; i++) { client.execute(SPHERE_REQUEST_FINISH_ON_COMMAND); } delegate.waitForRequestCount(MAX_PARALLEL_REQUESTS); Thread.sleep(100);//test if in the meantime no request is processed assertThat(delegate.getUsageCounter()).isEqualTo(MAX_PARALLEL_REQUESTS); delegate.release(); delegate.waitForRequestCount(numberOfRequests); Thread.sleep(100);//test if in the meantime no request is processed assertThat(delegate.getUsageCounter()).isEqualTo(numberOfRequests); }