Search in sources :

Example 1 with StreamParameters

use of org.zalando.nakadi.service.subscription.StreamParameters in project nakadi by zalando.

the class StreamingStateTest method prepareMocks.

@Before
public void prepareMocks() throws Exception {
    state = new StreamingState();
    final StreamingContext contextMock = mock(StreamingContext.class);
    when(contextMock.getCursorComparator()).thenReturn(Comparator.comparing(NakadiCursor::getOffset));
    when(contextMock.getSessionId()).thenReturn(SESSION_ID);
    when(contextMock.isInState(Mockito.same(state))).thenReturn(true);
    subscription = mock(Subscription.class);
    when(contextMock.getSubscription()).thenReturn(subscription);
    timelineService = mock(TimelineService.class);
    when(contextMock.getTimelineService()).thenReturn(timelineService);
    final MetricRegistry metricRegistry = mock(MetricRegistry.class);
    when(metricRegistry.register(any(), any())).thenReturn(null);
    when(contextMock.getMetricRegistry()).thenReturn(metricRegistry);
    zkMock = mock(ZkSubscriptionClient.class);
    when(contextMock.getZkClient()).thenReturn(zkMock);
    cursorConverter = mock(CursorConverter.class);
    when(contextMock.getCursorConverter()).thenReturn(cursorConverter);
    final Client client = mock(Client.class);
    when(client.getClientId()).thenReturn("consumingAppId");
    final StreamParameters spMock = createStreamParameters(1000, 100L, 100, 100L, 100, 100, 100, client);
    when(contextMock.getParameters()).thenReturn(spMock);
    state.setContext(contextMock, "test");
}
Also used : StreamingContext(org.zalando.nakadi.service.subscription.StreamingContext) ZkSubscriptionClient(org.zalando.nakadi.service.subscription.zk.ZkSubscriptionClient) MetricRegistry(com.codahale.metrics.MetricRegistry) TimelineService(org.zalando.nakadi.service.timeline.TimelineService) Subscription(org.zalando.nakadi.domain.Subscription) ZkSubscription(org.zalando.nakadi.service.subscription.zk.ZkSubscription) ZkSubscriptionClient(org.zalando.nakadi.service.subscription.zk.ZkSubscriptionClient) Client(org.zalando.nakadi.security.Client) CursorConverter(org.zalando.nakadi.service.CursorConverter) StreamParametersTest.createStreamParameters(org.zalando.nakadi.service.subscription.StreamParametersTest.createStreamParameters) StreamParameters(org.zalando.nakadi.service.subscription.StreamParameters) Before(org.junit.Before)

Example 2 with StreamParameters

use of org.zalando.nakadi.service.subscription.StreamParameters in project nakadi by zalando.

the class SubscriptionStreamController method streamEvents.

@RequestMapping(value = "/subscriptions/{subscription_id}/events", method = RequestMethod.GET)
public StreamingResponseBody streamEvents(@PathVariable("subscription_id") final String subscriptionId, @Nullable @RequestParam(value = "max_uncommitted_events", required = false) final Integer maxUncommittedEvents, @Nullable @RequestParam(value = "batch_limit", required = false) final Integer batchLimit, @Nullable @RequestParam(value = "stream_limit", required = false) final Long streamLimit, @Nullable @RequestParam(value = "batch_flush_timeout", required = false) final Integer batchTimeout, @Nullable @RequestParam(value = "stream_timeout", required = false) final Long streamTimeout, @Nullable @RequestParam(value = "stream_keep_alive_limit", required = false) final Integer streamKeepAliveLimit, final HttpServletRequest request, final HttpServletResponse response, final Client client) {
    final UserStreamParameters userParameters = new UserStreamParameters(batchLimit, streamLimit, batchTimeout, streamTimeout, streamKeepAliveLimit, maxUncommittedEvents, ImmutableList.of());
    final StreamParameters streamParameters = StreamParameters.of(userParameters, nakadiSettings.getDefaultCommitTimeoutSeconds(), client);
    return stream(subscriptionId, request, response, client, streamParameters);
}
Also used : UserStreamParameters(org.zalando.nakadi.view.UserStreamParameters) StreamParameters(org.zalando.nakadi.service.subscription.StreamParameters) UserStreamParameters(org.zalando.nakadi.view.UserStreamParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

StreamParameters (org.zalando.nakadi.service.subscription.StreamParameters)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 Before (org.junit.Before)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 Subscription (org.zalando.nakadi.domain.Subscription)1 Client (org.zalando.nakadi.security.Client)1 CursorConverter (org.zalando.nakadi.service.CursorConverter)1 StreamParametersTest.createStreamParameters (org.zalando.nakadi.service.subscription.StreamParametersTest.createStreamParameters)1 StreamingContext (org.zalando.nakadi.service.subscription.StreamingContext)1 ZkSubscription (org.zalando.nakadi.service.subscription.zk.ZkSubscription)1 ZkSubscriptionClient (org.zalando.nakadi.service.subscription.zk.ZkSubscriptionClient)1 TimelineService (org.zalando.nakadi.service.timeline.TimelineService)1 UserStreamParameters (org.zalando.nakadi.view.UserStreamParameters)1