Search in sources :

Example 1 with Endpoint

use of com.nike.riposte.server.http.Endpoint in project riposte by Nike-Inc.

the class ProxyRouterEndpointExecutionHandler method doChannelRead.

@Override
public PipelineContinuationBehavior doChannelRead(ChannelHandlerContext ctx, Object msg) {
    HttpProcessingState state = ChannelAttributes.getHttpProcessingStateForChannel(ctx).get();
    Endpoint<?> endpoint = state.getEndpointForExecution();
    if (shouldHandleDoChannelReadMessage(msg, endpoint)) {
        ProxyRouterProcessingState proxyRouterState = getOrCreateProxyRouterProcessingState(ctx);
        ProxyRouterEndpoint endpointProxyRouter = ((ProxyRouterEndpoint) endpoint);
        RequestInfo<?> requestInfo = state.getRequestInfo();
        if (msg instanceof HttpRequest) {
            if (requestInfo instanceof RiposteInternalRequestInfo) {
                // Tell this RequestInfo that we'll be managing the release of content chunks, so that when
                // RequestInfo.releaseAllResources() is called we don't have extra reference count removals.
                ((RiposteInternalRequestInfo) requestInfo).contentChunksWillBeReleasedExternally();
            }
            // We're supposed to start streaming. There may be pre-endpoint-execution validation logic or other work
            // that needs to happen before the endpoint is executed, so set up the CompletableFuture for the
            // endpoint call to only execute if the pre-endpoint-execution validation/work chain is successful.
            CompletableFuture<DownstreamRequestFirstChunkInfo> firstChunkFuture = state.getPreEndpointExecutionWorkChain().thenCompose(functionWithTracingAndMdc(aVoid -> endpointProxyRouter.getDownstreamRequestFirstChunkInfo(requestInfo, longRunningTaskExecutor, ctx), ctx));
            Long endpointTimeoutOverride = endpointProxyRouter.completableFutureTimeoutOverrideMillis();
            long callTimeoutValueToUse = (endpointTimeoutOverride == null) ? defaultCompletableFutureTimeoutMillis : endpointTimeoutOverride;
            // When the first chunk is ready, stream it downstream and set up what happens afterward.
            firstChunkFuture.whenComplete((downstreamRequestFirstChunkInfo, throwable) -> {
                Optional<ManualModeTask<HttpResponse>> circuitBreakerManualTask = getCircuitBreaker(downstreamRequestFirstChunkInfo, ctx).map(CircuitBreaker::newManualModeTask);
                StreamingCallback callback = new StreamingCallbackForCtx(ctx, circuitBreakerManualTask, endpointProxyRouter, requestInfo, proxyRouterState);
                if (throwable != null) {
                    // Something blew up trying to determine the first chunk info.
                    callback.unrecoverableErrorOccurred(throwable, true);
                } else if (!ctx.channel().isOpen()) {
                    // The channel was closed for some reason before we were able to start streaming.
                    String errorMsg = "The channel from the original caller was closed before we could begin the " + "downstream call.";
                    Exception channelClosedException = new RuntimeException(errorMsg);
                    runnableWithTracingAndMdc(() -> logger.warn(errorMsg), ctx).run();
                    callback.unrecoverableErrorOccurred(channelClosedException, true);
                } else {
                    try {
                        // Ok we have the first chunk info. Start by setting the downstream call info in the request
                        // info (i.e. for access logs if desired)
                        requestInfo.addRequestAttribute(DOWNSTREAM_CALL_PATH_REQUEST_ATTR_KEY, HttpUtils.extractPath(downstreamRequestFirstChunkInfo.firstChunk.uri()));
                        // Try our circuit breaker (if we have one).
                        Throwable circuitBreakerException = null;
                        try {
                            circuitBreakerManualTask.ifPresent(ManualModeTask::throwExceptionIfCircuitBreakerIsOpen);
                        } catch (Throwable t) {
                            circuitBreakerException = t;
                        }
                        if (circuitBreakerException == null) {
                            // No circuit breaker, or the breaker is closed. We can now stream the first chunk info.
                            String downstreamHost = downstreamRequestFirstChunkInfo.host;
                            int downstreamPort = downstreamRequestFirstChunkInfo.port;
                            HttpRequest downstreamRequestFirstChunk = downstreamRequestFirstChunkInfo.firstChunk;
                            boolean isSecureHttpsCall = downstreamRequestFirstChunkInfo.isHttps;
                            boolean relaxedHttpsValidation = downstreamRequestFirstChunkInfo.relaxedHttpsValidation;
                            boolean performSubSpanAroundDownstreamCall = downstreamRequestFirstChunkInfo.performSubSpanAroundDownstreamCall;
                            boolean addTracingHeadersToDownstreamCall = downstreamRequestFirstChunkInfo.addTracingHeadersToDownstreamCall;
                            // Tell the proxyRouterState about the streaming callback so that
                            // callback.unrecoverableErrorOccurred(...) can be called in the case of an error
                            // on subsequent chunks.
                            proxyRouterState.setStreamingCallback(callback);
                            // Setup the streaming channel future with everything it needs to kick off the
                            // downstream request.
                            proxyRouterState.setStreamingStartTimeNanos(System.nanoTime());
                            CompletableFuture<StreamingChannel> streamingChannel = streamingAsyncHttpClient.streamDownstreamCall(downstreamHost, downstreamPort, downstreamRequestFirstChunk, isSecureHttpsCall, relaxedHttpsValidation, callback, callTimeoutValueToUse, performSubSpanAroundDownstreamCall, addTracingHeadersToDownstreamCall, proxyRouterState, requestInfo, ctx);
                            // Tell the streaming channel future what to do when it completes.
                            streamingChannel = streamingChannel.whenComplete((sc, cause) -> {
                                if (cause == null) {
                                    // Successfully connected and sent the first chunk. We can now safely let
                                    // the remaining content chunks through for streaming.
                                    proxyRouterState.triggerChunkProcessing(sc);
                                } else {
                                    // Something blew up while connecting to the downstream server.
                                    callback.unrecoverableErrorOccurred(cause, true);
                                }
                            });
                            // Set the streaming channel future on the state so it can be connected to.
                            proxyRouterState.setStreamingChannelCompletableFuture(streamingChannel);
                        } else {
                            // Circuit breaker is tripped (or otherwise threw an unexpected exception). Immediately
                            // short circuit the error back to the client.
                            callback.unrecoverableErrorOccurred(circuitBreakerException, true);
                        }
                    } catch (Throwable t) {
                        callback.unrecoverableErrorOccurred(t, true);
                    }
                }
            });
        } else if (msg instanceof HttpContent) {
            HttpContent msgContent = (HttpContent) msg;
            // chunk-streaming behavior and subsequent cleanup for the given HttpContent.
            if (!releaseContentChunkIfStreamAlreadyFailed(msgContent, proxyRouterState)) {
                registerChunkStreamingAction(proxyRouterState, msgContent, ctx);
            }
        }
        return PipelineContinuationBehavior.DO_NOT_FIRE_CONTINUE_EVENT;
    }
    return PipelineContinuationBehavior.CONTINUE;
}
Also used : HttpRequest(io.netty.handler.codec.http.HttpRequest) Span(com.nike.wingtips.Span) LoggerFactory(org.slf4j.LoggerFactory) ResponseInfo(com.nike.riposte.server.http.ResponseInfo) HttpObject(io.netty.handler.codec.http.HttpObject) ProxyRouterEndpoint(com.nike.riposte.server.http.ProxyRouterEndpoint) Map(java.util.Map) HttpRequest(io.netty.handler.codec.http.HttpRequest) CompletionException(java.util.concurrent.CompletionException) EventLoop(io.netty.channel.EventLoop) DownstreamRequestFirstChunkInfo(com.nike.riposte.server.http.ProxyRouterEndpoint.DownstreamRequestFirstChunkInfo) BaseInboundHandlerWithTracingAndMdcSupport(com.nike.riposte.server.handler.base.BaseInboundHandlerWithTracingAndMdcSupport) Endpoint(com.nike.riposte.server.http.Endpoint) HttpUtils(com.nike.riposte.util.HttpUtils) StreamingChannel(com.nike.riposte.client.asynchttp.netty.StreamingAsyncHttpClient.StreamingChannel) ChannelAttributes(com.nike.riposte.server.channelpipeline.ChannelAttributes) CircuitBreaker(com.nike.fastbreak.CircuitBreaker) RiposteInternalRequestInfo(com.nike.riposte.server.http.impl.RiposteInternalRequestInfo) Optional(java.util.Optional) HttpResponse(io.netty.handler.codec.http.HttpResponse) StreamingCallback(com.nike.riposte.client.asynchttp.netty.StreamingAsyncHttpClient.StreamingCallback) HttpProcessingState(com.nike.riposte.server.http.HttpProcessingState) EventExecutor(io.netty.util.concurrent.EventExecutor) RequestInfo(com.nike.riposte.server.http.RequestInfo) CircuitBreakerDelegate(com.nike.fastbreak.CircuitBreakerDelegate) ManualModeTask(com.nike.fastbreak.CircuitBreaker.ManualModeTask) CompletableFuture(java.util.concurrent.CompletableFuture) StreamingAsyncHttpClient(com.nike.riposte.client.asynchttp.netty.StreamingAsyncHttpClient) PipelineContinuationBehavior(com.nike.riposte.server.handler.base.PipelineContinuationBehavior) Deque(java.util.Deque) LastHttpContent(io.netty.handler.codec.http.LastHttpContent) AsyncNettyHelper(com.nike.riposte.util.AsyncNettyHelper) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) HttpContent(io.netty.handler.codec.http.HttpContent) Attribute(io.netty.util.Attribute) OutboundMessageSendHeadersChunkFromResponseInfo(com.nike.riposte.server.channelpipeline.message.OutboundMessageSendHeadersChunkFromResponseInfo) Logger(org.slf4j.Logger) Executor(java.util.concurrent.Executor) AsyncNettyHelper.executeOnlyIfChannelIsActive(com.nike.riposte.util.AsyncNettyHelper.executeOnlyIfChannelIsActive) CircuitBreakerForHttpStatusCode.getDefaultHttpStatusCodeCircuitBreakerForKey(com.nike.fastbreak.CircuitBreakerForHttpStatusCode.getDefaultHttpStatusCodeCircuitBreakerForKey) AsyncNettyHelper.functionWithTracingAndMdc(com.nike.riposte.util.AsyncNettyHelper.functionWithTracingAndMdc) ChannelFuture(io.netty.channel.ChannelFuture) ExecutionException(java.util.concurrent.ExecutionException) FullHttpResponse(io.netty.handler.codec.http.FullHttpResponse) WrapperException(com.nike.backstopper.exception.WrapperException) OutboundMessageSendContentChunk(com.nike.riposte.server.channelpipeline.message.OutboundMessageSendContentChunk) DistributedTracingConfig(com.nike.riposte.server.config.distributedtracing.DistributedTracingConfig) AsyncNettyHelper.runnableWithTracingAndMdc(com.nike.riposte.util.AsyncNettyHelper.runnableWithTracingAndMdc) LastOutboundMessageSendLastContentChunk(com.nike.riposte.server.channelpipeline.message.LastOutboundMessageSendLastContentChunk) Pair(com.nike.internal.util.Pair) ProxyRouterProcessingState(com.nike.riposte.server.http.ProxyRouterProcessingState) CircuitBreaker(com.nike.fastbreak.CircuitBreaker) StreamingCallback(com.nike.riposte.client.asynchttp.netty.StreamingAsyncHttpClient.StreamingCallback) HttpProcessingState(com.nike.riposte.server.http.HttpProcessingState) ProxyRouterProcessingState(com.nike.riposte.server.http.ProxyRouterProcessingState) DownstreamRequestFirstChunkInfo(com.nike.riposte.server.http.ProxyRouterEndpoint.DownstreamRequestFirstChunkInfo) CompletionException(java.util.concurrent.CompletionException) ExecutionException(java.util.concurrent.ExecutionException) WrapperException(com.nike.backstopper.exception.WrapperException) CompletableFuture(java.util.concurrent.CompletableFuture) ManualModeTask(com.nike.fastbreak.CircuitBreaker.ManualModeTask) ProxyRouterEndpoint(com.nike.riposte.server.http.ProxyRouterEndpoint) RiposteInternalRequestInfo(com.nike.riposte.server.http.impl.RiposteInternalRequestInfo) LastHttpContent(io.netty.handler.codec.http.LastHttpContent) HttpContent(io.netty.handler.codec.http.HttpContent)

Example 2 with Endpoint

use of com.nike.riposte.server.http.Endpoint in project riposte by Nike-Inc.

the class PolymorphicSecurityValidatorTest method constructorSingleValidator.

@Test
public void constructorSingleValidator() {
    Endpoint mockEndpoint = mock(Endpoint.class);
    RequestSecurityValidator innerValidator = mock(RequestSecurityValidator.class);
    doReturn(Collections.singletonList(mockEndpoint)).when(innerValidator).endpointsToValidate();
    List<RequestSecurityValidator> validatorList = new ArrayList<>();
    validatorList.add(innerValidator);
    Map<Endpoint<?>, List<RequestSecurityValidator>> validationMap = new PolymorphicSecurityValidator(validatorList).validationMap;
    assertThat(validationMap.size(), is(1));
    assertThat(validationMap.get(mockEndpoint).size(), is(1));
    assertThat(validationMap.get(mockEndpoint).get(0), is(innerValidator));
}
Also used : Endpoint(com.nike.riposte.server.http.Endpoint) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 3 with Endpoint

use of com.nike.riposte.server.http.Endpoint in project riposte by Nike-Inc.

the class PolymorphicSecurityValidatorTest method constructorMultipleValidators.

@Test
public void constructorMultipleValidators() {
    Endpoint mockEndpoint = mock(Endpoint.class);
    RequestSecurityValidator innerVal1 = mock(RequestSecurityValidator.class);
    doReturn(Collections.singletonList(mockEndpoint)).when(innerVal1).endpointsToValidate();
    RequestSecurityValidator innerVal2 = mock(RequestSecurityValidator.class);
    doReturn(Collections.singletonList(mockEndpoint)).when(innerVal2).endpointsToValidate();
    List<RequestSecurityValidator> validatorList = new ArrayList<>();
    validatorList.add(innerVal1);
    validatorList.add(innerVal2);
    Map<Endpoint<?>, List<RequestSecurityValidator>> validationMap = new PolymorphicSecurityValidator(validatorList).validationMap;
    assertThat(validationMap.size(), is(1));
    assertThat(validationMap.get(mockEndpoint).size(), is(2));
    assertThat(validationMap.get(mockEndpoint).get(0), is(innerVal1));
    assertThat(validationMap.get(mockEndpoint).get(1), is(innerVal2));
}
Also used : Endpoint(com.nike.riposte.server.http.Endpoint) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 4 with Endpoint

use of com.nike.riposte.server.http.Endpoint in project riposte by Nike-Inc.

the class CodahaleMetricsListenerTest method initServerConfigMetrics_adds_expected_metrics.

@DataProvider(value = { "true", "false" })
@Test
public void initServerConfigMetrics_adds_expected_metrics(boolean includeServerConfigMetrics) {
    // given
    setupMetricRegistryAndCodahaleMetricsCollector();
    CodahaleMetricsListener instance = CodahaleMetricsListener.newBuilder(cmcMock).withEndpointMetricsHandler(endpointMetricsHandlerMock).withIncludeServerConfigMetrics(includeServerConfigMetrics).build();
    verifyServerStatisticMetrics(instance);
    String expectedBossThreadsGaugeName = name(ServerConfig.class.getSimpleName(), "boss_threads");
    String expectedWorkerThreadsGaugeName = name(ServerConfig.class.getSimpleName(), "worker_threads");
    String expectedMaxRequestSizeInBytesGaugeName = name(ServerConfig.class.getSimpleName(), "max_request_size_in_bytes");
    String expectedEndpointsListGaugeName = name(ServerConfig.class.getSimpleName(), "endpoints");
    List<String> expectedEndpointsListValue = serverConfig.appEndpoints().stream().map(endpoint -> endpoint.getClass().getName() + "-" + instance.getMatchingHttpMethodsAsCombinedString(endpoint) + "-" + endpoint.requestMatcher().matchingPathTemplates()).collect(Collectors.toList());
    // when
    instance.initEndpointAndServerConfigMetrics(serverConfig);
    // then
    if (includeServerConfigMetrics) {
        // Metrics for server config values
        assertThat(registeredGauges).containsKey(expectedBossThreadsGaugeName);
        assertThat(registeredGauges.get(expectedBossThreadsGaugeName).getValue()).isEqualTo(serverConfig.numBossThreads());
        verify(cmcMock).registerNamedMetric(expectedBossThreadsGaugeName, registeredGauges.get(expectedBossThreadsGaugeName));
        assertThat(registeredGauges).containsKey(expectedWorkerThreadsGaugeName);
        assertThat(registeredGauges.get(expectedWorkerThreadsGaugeName).getValue()).isEqualTo(serverConfig.numWorkerThreads());
        verify(cmcMock).registerNamedMetric(expectedWorkerThreadsGaugeName, registeredGauges.get(expectedWorkerThreadsGaugeName));
        assertThat(registeredGauges).containsKey(expectedMaxRequestSizeInBytesGaugeName);
        assertThat(registeredGauges.get(expectedMaxRequestSizeInBytesGaugeName).getValue()).isEqualTo(serverConfig.maxRequestSizeInBytes());
        verify(cmcMock).registerNamedMetric(expectedMaxRequestSizeInBytesGaugeName, registeredGauges.get(expectedMaxRequestSizeInBytesGaugeName));
        assertThat(registeredGauges).containsKey(expectedEndpointsListGaugeName);
        assertThat(registeredGauges.get(expectedEndpointsListGaugeName).getValue()).isEqualTo(expectedEndpointsListValue);
        verify(cmcMock).registerNamedMetric(expectedEndpointsListGaugeName, registeredGauges.get(expectedEndpointsListGaugeName));
    } else {
        // No server config values should have been registered.
        verifyNoMoreInteractions(metricRegistryMock);
    }
    // In either case, the EndpointMetricsHandler should have been called to delegate setting up endpoint-specific metrics.
    verify(endpointMetricsHandlerMock).setupEndpointsMetrics(serverConfig, metricRegistryMock);
}
Also used : Arrays(java.util.Arrays) MetricNamingStrategy(com.nike.riposte.metrics.codahale.CodahaleMetricsListener.MetricNamingStrategy) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ResponseInfo(com.nike.riposte.server.http.ResponseInfo) EndpointMetricsHandlerDefaultImpl(com.nike.riposte.metrics.codahale.impl.EndpointMetricsHandlerDefaultImpl) ServerConfig(com.nike.riposte.server.config.ServerConfig) DataProviderRunner(com.tngtech.java.junit.dataprovider.DataProviderRunner) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) Mockito.doThrow(org.mockito.Mockito.doThrow) Mockito.verifyNoMoreInteractions(org.mockito.Mockito.verifyNoMoreInteractions) Map(java.util.Map) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Counter(com.codahale.metrics.Counter) DEFAULT_REQUEST_AND_RESPONSE_SIZE_HISTOGRAM_SUPPLIER(com.nike.riposte.metrics.codahale.CodahaleMetricsListener.DEFAULT_REQUEST_AND_RESPONSE_SIZE_HISTOGRAM_SUPPLIER) Mockito.doReturn(org.mockito.Mockito.doReturn) Builder(com.nike.riposte.metrics.codahale.CodahaleMetricsListener.Builder) DefaultMetricNamingStrategy(com.nike.riposte.metrics.codahale.CodahaleMetricsListener.DefaultMetricNamingStrategy) Collection(java.util.Collection) Metric(com.codahale.metrics.Metric) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Endpoint(com.nike.riposte.server.http.Endpoint) List(java.util.List) Timer(com.codahale.metrics.Timer) ResponseSender(com.nike.riposte.server.http.ResponseSender) Gauge(com.codahale.metrics.Gauge) NotNull(org.jetbrains.annotations.NotNull) Mockito.mock(org.mockito.Mockito.mock) HttpProcessingState(com.nike.riposte.server.http.HttpProcessingState) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Histogram(com.codahale.metrics.Histogram) RequestInfo(com.nike.riposte.server.http.RequestInfo) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) NANOSECONDS(java.util.concurrent.TimeUnit.NANOSECONDS) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) ServerStatisticsMetricNames(com.nike.riposte.metrics.codahale.CodahaleMetricsListener.ServerStatisticsMetricNames) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) Supplier(java.util.function.Supplier) ServerConfigMetricNames(com.nike.riposte.metrics.codahale.CodahaleMetricsListener.ServerConfigMetricNames) Meter(com.codahale.metrics.Meter) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ArgumentCaptor(org.mockito.ArgumentCaptor) Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) DEFAULT_PREFIX(com.nike.riposte.metrics.codahale.CodahaleMetricsListener.DefaultMetricNamingStrategy.DEFAULT_PREFIX) Whitebox(com.nike.riposte.testutils.Whitebox) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) DEFAULT_WORD_DELIMITER(com.nike.riposte.metrics.codahale.CodahaleMetricsListener.DefaultMetricNamingStrategy.DEFAULT_WORD_DELIMITER) Before(org.junit.Before) MetricRegistry(com.codahale.metrics.MetricRegistry) Logger(org.slf4j.Logger) Executor(java.util.concurrent.Executor) HttpMethod(io.netty.handler.codec.http.HttpMethod) Test(org.junit.Test) StandardEndpoint(com.nike.riposte.server.http.StandardEndpoint) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) Matcher(com.nike.riposte.util.Matcher) Mockito.never(org.mockito.Mockito.never) MetricRegistry.name(com.codahale.metrics.MetricRegistry.name) ServerMetricsEvent(com.nike.riposte.server.metrics.ServerMetricsEvent) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ServerConfig(com.nike.riposte.server.config.ServerConfig) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) Test(org.junit.Test)

Example 5 with Endpoint

use of com.nike.riposte.server.http.Endpoint in project riposte by Nike-Inc.

the class CodahaleMetricsListenerTest method beforeMethod.

@Before
public void beforeMethod() {
    setupMetricRegistryAndCodahaleMetricsCollector();
    endpointMetricsHandlerMock = mock(EndpointMetricsHandler.class);
    mockHistogramSupplier = () -> mock(Histogram.class);
    listener = new CodahaleMetricsListener(cmcMock, endpointMetricsHandlerMock, true, null, null, mockHistogramSupplier);
    serverConfig = new ServerConfig() {

        private final List<Endpoint<?>> endpoints = Arrays.asList(new DummyEndpoint(Matcher.match("/foo")), new DummyEndpoint(Matcher.match("/bar", HttpMethod.POST, HttpMethod.PUT)), new DummyEndpoint(Matcher.multiMatch(Arrays.asList("/multiFoo", "/multiBar"))), new DummyEndpoint(Matcher.multiMatch(Arrays.asList("/multiBaz", "/multiBat"), HttpMethod.PATCH, HttpMethod.OPTIONS)));

        @Override
        @NotNull
        public Collection<@NotNull Endpoint<?>> appEndpoints() {
            return endpoints;
        }

        @Override
        public int numBossThreads() {
            return 3;
        }

        @Override
        public int numWorkerThreads() {
            return 42;
        }

        @Override
        public int maxRequestSizeInBytes() {
            return 42434445;
        }
    };
    listener.initEndpointAndServerConfigMetrics(serverConfig);
    requestInfoMock = mock(RequestInfo.class);
    responseInfoMock = mock(ResponseInfo.class);
    state = new HttpProcessingState();
    state.setRequestInfo(requestInfoMock);
    state.setResponseInfo(responseInfoMock, null);
    requestStartTimeNanos = System.nanoTime() - TimeUnit.MILLISECONDS.toNanos(42);
    state.setRequestStartTimeNanos(requestStartTimeNanos);
}
Also used : ResponseInfo(com.nike.riposte.server.http.ResponseInfo) Histogram(com.codahale.metrics.Histogram) HttpProcessingState(com.nike.riposte.server.http.HttpProcessingState) RequestInfo(com.nike.riposte.server.http.RequestInfo) NotNull(org.jetbrains.annotations.NotNull) ServerConfig(com.nike.riposte.server.config.ServerConfig) Endpoint(com.nike.riposte.server.http.Endpoint) StandardEndpoint(com.nike.riposte.server.http.StandardEndpoint) Collection(java.util.Collection) Before(org.junit.Before)

Aggregations

Endpoint (com.nike.riposte.server.http.Endpoint)16 Test (org.junit.Test)12 StandardEndpoint (com.nike.riposte.server.http.StandardEndpoint)9 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 HttpProcessingState (com.nike.riposte.server.http.HttpProcessingState)6 RequestInfo (com.nike.riposte.server.http.RequestInfo)6 Timer (com.codahale.metrics.Timer)5 ResponseInfo (com.nike.riposte.server.http.ResponseInfo)5 HttpMethod (io.netty.handler.codec.http.HttpMethod)5 Meter (com.codahale.metrics.Meter)4 ServerConfig (com.nike.riposte.server.config.ServerConfig)4 Histogram (com.codahale.metrics.Histogram)3 MetricRegistry (com.codahale.metrics.MetricRegistry)3 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 List (java.util.List)3 Executor (java.util.concurrent.Executor)3 NotNull (org.jetbrains.annotations.NotNull)3 Before (org.junit.Before)3