target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void propagatesProxyErrorsWithCause() { IOException cause = new IOException(); listener.proxyErrorOccurred(cause); verify(delegate1).proxyErrorOccurred(cause); verify(delegate2).proxyErrorOccurred(cause); verify(delegate3).proxyErrorOccurred(cause); }
@Override public void proxyErrorOccurred(Throwable cause) { listeners.forEach(listener -> listener.proxyErrorOccurred(cause)); }
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(Throwable cause) { listeners.forEach(listener -> listener.proxyErrorOccurred(cause)); } }
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(Throwable cause) { listeners.forEach(listener -> listener.proxyErrorOccurred(cause)); } CompositeHttpErrorStatusListener(List<HttpErrorStatusListener> listeners); }
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(Throwable cause) { listeners.forEach(listener -> listener.proxyErrorOccurred(cause)); } CompositeHttpErrorStatusListener(List<HttpErrorStatusListener> listeners); @Override void proxyErrorOccurred(Throwable ca...
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(Throwable cause) { listeners.forEach(listener -> listener.proxyErrorOccurred(cause)); } CompositeHttpErrorStatusListener(List<HttpErrorStatusListener> listeners); @Override void proxyErrorOccurred(Throwable ca...
@Test public void propagatesProxyErrorsWithStatusAndCause() { IOException cause = new IOException(); listener.proxyErrorOccurred(INTERNAL_SERVER_ERROR, cause); verify(delegate1).proxyErrorOccurred(INTERNAL_SERVER_ERROR, cause); verify(delegate2).proxyErrorOccurred(INTERNAL_SERVER_ERROR, cause); verify(delegate3).proxyE...
@Override public void proxyErrorOccurred(Throwable cause) { listeners.forEach(listener -> listener.proxyErrorOccurred(cause)); }
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(Throwable cause) { listeners.forEach(listener -> listener.proxyErrorOccurred(cause)); } }
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(Throwable cause) { listeners.forEach(listener -> listener.proxyErrorOccurred(cause)); } CompositeHttpErrorStatusListener(List<HttpErrorStatusListener> listeners); }
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(Throwable cause) { listeners.forEach(listener -> listener.proxyErrorOccurred(cause)); } CompositeHttpErrorStatusListener(List<HttpErrorStatusListener> listeners); @Override void proxyErrorOccurred(Throwable ca...
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(Throwable cause) { listeners.forEach(listener -> listener.proxyErrorOccurred(cause)); } CompositeHttpErrorStatusListener(List<HttpErrorStatusListener> listeners); @Override void proxyErrorOccurred(Throwable ca...
@Test public void propagatesProxyWriteFailures() { IOException cause = new IOException(); listener.proxyWriteFailure(request, response, cause); verify(delegate1).proxyWriteFailure(request, response, cause); verify(delegate2).proxyWriteFailure(request, response, cause); verify(delegate3).proxyWriteFailure(request, respo...
@Override public void proxyWriteFailure(LiveHttpRequest request, LiveHttpResponse response, Throwable cause) { listeners.forEach(listener -> listener.proxyWriteFailure(request, response, cause)); }
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyWriteFailure(LiveHttpRequest request, LiveHttpResponse response, Throwable cause) { listeners.forEach(listener -> listener.proxyWriteFailure(request, response, cause)); } }
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyWriteFailure(LiveHttpRequest request, LiveHttpResponse response, Throwable cause) { listeners.forEach(listener -> listener.proxyWriteFailure(request, response, cause)); } CompositeHttpErrorStatusListener(List<HttpErrorStatu...
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyWriteFailure(LiveHttpRequest request, LiveHttpResponse response, Throwable cause) { listeners.forEach(listener -> listener.proxyWriteFailure(request, response, cause)); } CompositeHttpErrorStatusListener(List<HttpErrorStatu...
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyWriteFailure(LiveHttpRequest request, LiveHttpResponse response, Throwable cause) { listeners.forEach(listener -> listener.proxyWriteFailure(request, response, cause)); } CompositeHttpErrorStatusListener(List<HttpErrorStatu...
@Test public void usesTheOriginSpecifiedInTheOriginsRestrictionCookie() { MapBackedConfiguration config = new MapBackedConfiguration(); config.set("originRestrictionCookie", ORIGINS_RESTRICTION_COOKIE); environment = new Environment.Builder() .configuration(new StyxConfig(config)) .build(); BackendService backendServic...
@Override public BackendServiceClient createClient(BackendService backendService, OriginsInventory originsInventory, OriginStatsFactory originStatsFactory) { Configuration styxConfig = environment.configuration(); String originRestrictionCookie = styxConfig.get("originRestrictionCookie").orElse(null); boolean stickySes...
StyxBackendServiceClientFactory implements BackendServiceClientFactory { @Override public BackendServiceClient createClient(BackendService backendService, OriginsInventory originsInventory, OriginStatsFactory originStatsFactory) { Configuration styxConfig = environment.configuration(); String originRestrictionCookie = ...
StyxBackendServiceClientFactory implements BackendServiceClientFactory { @Override public BackendServiceClient createClient(BackendService backendService, OriginsInventory originsInventory, OriginStatsFactory originStatsFactory) { Configuration styxConfig = environment.configuration(); String originRestrictionCookie = ...
StyxBackendServiceClientFactory implements BackendServiceClientFactory { @Override public BackendServiceClient createClient(BackendService backendService, OriginsInventory originsInventory, OriginStatsFactory originStatsFactory) { Configuration styxConfig = environment.configuration(); String originRestrictionCookie = ...
StyxBackendServiceClientFactory implements BackendServiceClientFactory { @Override public BackendServiceClient createClient(BackendService backendService, OriginsInventory originsInventory, OriginStatsFactory originStatsFactory) { Configuration styxConfig = environment.configuration(); String originRestrictionCookie = ...
@Test public void propagatesProxyingFailures() { IOException cause = new IOException(); listener.proxyingFailure(request, response, cause); verify(delegate1).proxyingFailure(request, response, cause); verify(delegate2).proxyingFailure(request, response, cause); verify(delegate3).proxyingFailure(request, response, cause...
@Override public void proxyingFailure(LiveHttpRequest request, LiveHttpResponse response, Throwable cause) { listeners.forEach(listener -> listener.proxyingFailure(request, response, cause)); }
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyingFailure(LiveHttpRequest request, LiveHttpResponse response, Throwable cause) { listeners.forEach(listener -> listener.proxyingFailure(request, response, cause)); } }
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyingFailure(LiveHttpRequest request, LiveHttpResponse response, Throwable cause) { listeners.forEach(listener -> listener.proxyingFailure(request, response, cause)); } CompositeHttpErrorStatusListener(List<HttpErrorStatusLis...
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyingFailure(LiveHttpRequest request, LiveHttpResponse response, Throwable cause) { listeners.forEach(listener -> listener.proxyingFailure(request, response, cause)); } CompositeHttpErrorStatusListener(List<HttpErrorStatusLis...
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyingFailure(LiveHttpRequest request, LiveHttpResponse response, Throwable cause) { listeners.forEach(listener -> listener.proxyingFailure(request, response, cause)); } CompositeHttpErrorStatusListener(List<HttpErrorStatusLis...
@Test public void propagatesProxyErrorsWithRequests() { LiveHttpRequest request = LiveHttpRequest.get("/foo").build(); IOException cause = new IOException(); InetSocketAddress clientAddress = InetSocketAddress.createUnresolved("127.0.0.1", 0); listener.proxyErrorOccurred(request, clientAddress, INTERNAL_SERVER_ERROR, c...
@Override public void proxyErrorOccurred(Throwable cause) { listeners.forEach(listener -> listener.proxyErrorOccurred(cause)); }
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(Throwable cause) { listeners.forEach(listener -> listener.proxyErrorOccurred(cause)); } }
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(Throwable cause) { listeners.forEach(listener -> listener.proxyErrorOccurred(cause)); } CompositeHttpErrorStatusListener(List<HttpErrorStatusListener> listeners); }
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(Throwable cause) { listeners.forEach(listener -> listener.proxyErrorOccurred(cause)); } CompositeHttpErrorStatusListener(List<HttpErrorStatusListener> listeners); @Override void proxyErrorOccurred(Throwable ca...
CompositeHttpErrorStatusListener implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(Throwable cause) { listeners.forEach(listener -> listener.proxyErrorOccurred(cause)); } CompositeHttpErrorStatusListener(List<HttpErrorStatusListener> listeners); @Override void proxyErrorOccurred(Throwable ca...
@Test public void contentIsModified() { Config config = new Config("MyExtraText"); String originalBody = "OriginalBody"; AggregateRequestBodyExamplePlugin plugin = new AggregateRequestBodyExamplePlugin(config); LiveHttpRequest request = LiveHttpRequest.post("/", ByteStream.from(originalBody, UTF_8)).build(); HttpInterc...
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return request.aggregate(10000) .map(fullRequest -> { String body = fullRequest.bodyAs(UTF_8); return fullRequest.newBuilder() .body(body + config.extraText(), UTF_8) .build().stream(); }).flatMap(chain::proceed); }
AggregateRequestBodyExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return request.aggregate(10000) .map(fullRequest -> { String body = fullRequest.bodyAs(UTF_8); return fullRequest.newBuilder() .body(body + config.extraText(), UTF_8) .buil...
AggregateRequestBodyExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return request.aggregate(10000) .map(fullRequest -> { String body = fullRequest.bodyAs(UTF_8); return fullRequest.newBuilder() .body(body + config.extraText(), UTF_8) .buil...
AggregateRequestBodyExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return request.aggregate(10000) .map(fullRequest -> { String body = fullRequest.bodyAs(UTF_8); return fullRequest.newBuilder() .body(body + config.extraText(), UTF_8) .buil...
AggregateRequestBodyExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return request.aggregate(10000) .map(fullRequest -> { String body = fullRequest.bodyAs(UTF_8); return fullRequest.newBuilder() .body(body + config.extraText(), UTF_8) .buil...
@Test public void replacesLiveContent() { ReplaceLiveContentExampleConfig config = new ReplaceLiveContentExampleConfig("myNewContent"); ReplaceLiveContentExamplePlugin plugin = new ReplaceLiveContentExamplePlugin(config); LiveHttpRequest request = get("/").build(); HttpInterceptor.Chain chain = request1 -> Eventual.of(...
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .map(response -> response.newBuilder() .body(body -> body.replaceWith(ByteStream.from(config.replacement(), UTF_8))) .build()); }
ReplaceLiveContentExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .map(response -> response.newBuilder() .body(body -> body.replaceWith(ByteStream.from(config.replacement(), UTF_8))) .build()); } }
ReplaceLiveContentExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .map(response -> response.newBuilder() .body(body -> body.replaceWith(ByteStream.from(config.replacement(), UTF_8))) .build()); } ReplaceLiveCon...
ReplaceLiveContentExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .map(response -> response.newBuilder() .body(body -> body.replaceWith(ByteStream.from(config.replacement(), UTF_8))) .build()); } ReplaceLiveCon...
ReplaceLiveContentExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .map(response -> response.newBuilder() .body(body -> body.replaceWith(ByteStream.from(config.replacement(), UTF_8))) .build()); } ReplaceLiveCon...
@Test public void addsExtraHeaders() { HttpInterceptor.Chain chain = request -> { assertThat(request.header("myRequestHeader").orElse(null), is("foo")); return Eventual.of(response(OK).build()); }; LiveHttpRequest request = get("/foo") .build(); LiveHttpResponse response = Mono.from(plugin.intercept(request, chain)).bl...
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header("myRequestHeader", config.requestHeaderValue()) .build(); return chain.proceed(newRequest).map(response -> response.newBuilder() .header("myResponseHeader", config.resp...
ModifyHeadersExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header("myRequestHeader", config.requestHeaderValue()) .build(); return chain.proceed(newRequest).map(response -> response.newBu...
ModifyHeadersExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header("myRequestHeader", config.requestHeaderValue()) .build(); return chain.proceed(newRequest).map(response -> response.newBu...
ModifyHeadersExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header("myRequestHeader", config.requestHeaderValue()) .build(); return chain.proceed(newRequest).map(response -> response.newBu...
ModifyHeadersExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header("myRequestHeader", config.requestHeaderValue()) .build(); return chain.proceed(newRequest).map(response -> response.newBu...
@Test public void modifiesContent() { Config config = new Config("MyExtraText"); ModifyContentByAggregationExamplePlugin plugin = new ModifyContentByAggregationExamplePlugin(config); LiveHttpRequest request = get("/").build(); HttpInterceptor.Chain chain = anyRequest -> Eventual.of(response() .body("OriginalBody", UTF_...
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .flatMap(response -> response.aggregate(10000)) .map(response -> { String body = response.bodyAs(UTF_8); return response.newBuilder() .body(body + config.extraText(), UTF_8) .build(); }) .map(Http...
ModifyContentByAggregationExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .flatMap(response -> response.aggregate(10000)) .map(response -> { String body = response.bodyAs(UTF_8); return response.newBuilder() .b...
ModifyContentByAggregationExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .flatMap(response -> response.aggregate(10000)) .map(response -> { String body = response.bodyAs(UTF_8); return response.newBuilder() .b...
ModifyContentByAggregationExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .flatMap(response -> response.aggregate(10000)) .map(response -> { String body = response.bodyAs(UTF_8); return response.newBuilder() .b...
ModifyContentByAggregationExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(request) .flatMap(response -> response.aggregate(10000)) .map(response -> { String body = response.bodyAs(UTF_8); return response.newBuilder() .b...
@Test public void returnsEarlyWhenHeaderIsPresent() { EarlyReturnExamplePlugin plugin = new EarlyReturnExamplePlugin(); LiveHttpRequest request = LiveHttpRequest.get("/") .header("X-Respond", "foo") .build(); HttpInterceptor.Chain chain = request1 -> Eventual.of(LiveHttpResponse.response().build()); Eventual<LiveHttpRe...
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { if (request.header("X-Respond").isPresent()) { return Eventual.of(HttpResponse.response(OK) .header(CONTENT_TYPE, "text/plain; charset=utf-8") .body("Responding from plugin", UTF_8) .build() .stream()); } else { return chain.p...
EarlyReturnExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { if (request.header("X-Respond").isPresent()) { return Eventual.of(HttpResponse.response(OK) .header(CONTENT_TYPE, "text/plain; charset=utf-8") .body("Responding from plugin", UTF_8)...
EarlyReturnExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { if (request.header("X-Respond").isPresent()) { return Eventual.of(HttpResponse.response(OK) .header(CONTENT_TYPE, "text/plain; charset=utf-8") .body("Responding from plugin", UTF_8)...
EarlyReturnExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { if (request.header("X-Respond").isPresent()) { return Eventual.of(HttpResponse.response(OK) .header(CONTENT_TYPE, "text/plain; charset=utf-8") .body("Responding from plugin", UTF_8)...
EarlyReturnExamplePlugin implements Plugin { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { if (request.header("X-Respond").isPresent()) { return Eventual.of(HttpResponse.response(OK) .header(CONTENT_TYPE, "text/plain; charset=utf-8") .body("Responding from plugin", UTF_8)...
@Test public void logsThrowables() { Exception exception = new Exception("This is just a test"); httpErrorStatusCauseLogger.proxyErrorOccurred(INTERNAL_SERVER_ERROR, exception); assertThat(loggingTestSupport.log(), hasItem( loggingEvent( ERROR, "Failure status=\"500 Internal Server Error\"", "java.lang.Exception", "Thi...
@Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, cause); } }
HttpErrorStatusCauseLogger implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, ca...
HttpErrorStatusCauseLogger implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, ca...
HttpErrorStatusCauseLogger implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, ca...
HttpErrorStatusCauseLogger implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, ca...
@Test public void logsThrowablesWithStatus5xxExcluding500WithoutStackTrace() { Exception exception = new Exception("This is just a test"); httpErrorStatusCauseLogger.proxyErrorOccurred(BAD_GATEWAY, exception); assertThat(loggingTestSupport.log(), hasItem( loggingEvent( ERROR, "Failure status=\"502 Bad Gateway\", except...
@Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, cause); } }
HttpErrorStatusCauseLogger implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, ca...
HttpErrorStatusCauseLogger implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, ca...
HttpErrorStatusCauseLogger implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, ca...
HttpErrorStatusCauseLogger implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, ca...
@Test public void retryOnlyOnceIfSingleError() throws IOException { doThrow(new IOException()).doNothing().when(task).run(); tryTimes(3, task, (e) -> assertThat(e, is(instanceOf(IOException.class)))); verify(task, times(2)).run(); }
public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { task.run()...
IoRetry { public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { ...
IoRetry { public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { ...
IoRetry { public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { ...
IoRetry { public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { ...
@Test public void logsInternalServerErrorWithRequest() { LiveHttpRequest request = LiveHttpRequest.get("/foo").build(); Exception exception = new Exception("This is just a test"); httpErrorStatusCauseLogger.proxyErrorOccurred(request, InetSocketAddress.createUnresolved("localhost", 80), INTERNAL_SERVER_ERROR, exception...
@Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, cause); } }
HttpErrorStatusCauseLogger implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, ca...
HttpErrorStatusCauseLogger implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, ca...
HttpErrorStatusCauseLogger implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, ca...
HttpErrorStatusCauseLogger implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, ca...
@Test public void logsOtherExceptionsWithoutRequest() { LiveHttpRequest request = LiveHttpRequest.get("/foo").build(); Exception exception = new Exception("This is just a test"); httpErrorStatusCauseLogger.proxyErrorOccurred(request, InetSocketAddress.createUnresolved("127.0.0.1", 0), BAD_GATEWAY, exception); assertTha...
@Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, cause); } }
HttpErrorStatusCauseLogger implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, ca...
HttpErrorStatusCauseLogger implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, ca...
HttpErrorStatusCauseLogger implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, ca...
HttpErrorStatusCauseLogger implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { if (status.code() > 500) { LOG.error("Failure status=\"{}\", exception=\"{}\"", status, withoutStackTrace(cause)); } else { LOG.error("Failure status=\"{}\"", status, ca...
@Test public void buildsPipelineWithInterceptors() throws Exception { HttpHandler pipeline = new InterceptorPipelineBuilder(environment, plugins, handler, false).build(); LiveHttpResponse response = Mono.from(pipeline.handle(get("/foo").build(), requestContext())).block(); assertThat(response.header("plug1"), isValue("...
public RoutingObject build() { List<HttpInterceptor> interceptors = ImmutableList.copyOf(instrument(plugins, environment)); return new HttpInterceptorPipeline(interceptors, handler, trackRequests); }
InterceptorPipelineBuilder { public RoutingObject build() { List<HttpInterceptor> interceptors = ImmutableList.copyOf(instrument(plugins, environment)); return new HttpInterceptorPipeline(interceptors, handler, trackRequests); } }
InterceptorPipelineBuilder { public RoutingObject build() { List<HttpInterceptor> interceptors = ImmutableList.copyOf(instrument(plugins, environment)); return new HttpInterceptorPipeline(interceptors, handler, trackRequests); } InterceptorPipelineBuilder(Environment environment, Iterable<NamedPlugin> plugins, RoutingO...
InterceptorPipelineBuilder { public RoutingObject build() { List<HttpInterceptor> interceptors = ImmutableList.copyOf(instrument(plugins, environment)); return new HttpInterceptorPipeline(interceptors, handler, trackRequests); } InterceptorPipelineBuilder(Environment environment, Iterable<NamedPlugin> plugins, RoutingO...
InterceptorPipelineBuilder { public RoutingObject build() { List<HttpInterceptor> interceptors = ImmutableList.copyOf(instrument(plugins, environment)); return new HttpInterceptorPipeline(interceptors, handler, trackRequests); } InterceptorPipelineBuilder(Environment environment, Iterable<NamedPlugin> plugins, RoutingO...
@Test public void pluginExceptionsAreNotRecordedAsStyxUnexpectedErrors() { errorListener.proxyErrorOccurred(INTERNAL_SERVER_ERROR, new PluginException("bad")); assertThat(count("styx.response.status.500"), is(1)); assertThat(statusCountsExcluding("styx.response.status.500"), everyItem(is(0))); assertThat(meterCount("st...
@Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { record(status); if (isError(status)) { incrementExceptionCounter(cause, status); } }
HttpErrorStatusMetrics implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { record(status); if (isError(status)) { incrementExceptionCounter(cause, status); } } }
HttpErrorStatusMetrics implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { record(status); if (isError(status)) { incrementExceptionCounter(cause, status); } } HttpErrorStatusMetrics(MetricRegistry metricRegistry); }
HttpErrorStatusMetrics implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { record(status); if (isError(status)) { incrementExceptionCounter(cause, status); } } HttpErrorStatusMetrics(MetricRegistry metricRegistry); @Override void proxyErrorOccurred...
HttpErrorStatusMetrics implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { record(status); if (isError(status)) { incrementExceptionCounter(cause, status); } } HttpErrorStatusMetrics(MetricRegistry metricRegistry); @Override void proxyErrorOccurred...
@Test public void nonErrorStatusesIsNotRecordedForProxyEvenIfExceptionIsSupplied() { MetricRegistry registry = mock(MetricRegistry.class); HttpErrorStatusMetrics reporter = new HttpErrorStatusMetrics(registry); reset(registry); reporter.proxyErrorOccurred(OK, new RuntimeException("This shouldn't happen")); verifyZeroIn...
@Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { record(status); if (isError(status)) { incrementExceptionCounter(cause, status); } }
HttpErrorStatusMetrics implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { record(status); if (isError(status)) { incrementExceptionCounter(cause, status); } } }
HttpErrorStatusMetrics implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { record(status); if (isError(status)) { incrementExceptionCounter(cause, status); } } HttpErrorStatusMetrics(MetricRegistry metricRegistry); }
HttpErrorStatusMetrics implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { record(status); if (isError(status)) { incrementExceptionCounter(cause, status); } } HttpErrorStatusMetrics(MetricRegistry metricRegistry); @Override void proxyErrorOccurred...
HttpErrorStatusMetrics implements HttpErrorStatusListener { @Override public void proxyErrorOccurred(HttpResponseStatus status, Throwable cause) { record(status); if (isError(status)) { incrementExceptionCounter(cause, status); } } HttpErrorStatusMetrics(MetricRegistry metricRegistry); @Override void proxyErrorOccurred...
@Test public void appendsHttp10RequestVersionInResponseViaHeader() throws Exception { LiveHttpResponse response = Mono.from(interceptor.intercept(get("/foo").build(), ANY_RESPONSE_HANDLER)).block(); assertThat(response.headers().get(VIA), isValue("1.1 styx")); }
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header(VIA, viaHeader(request)) .build(); return chain.proceed(newRequest) .map(response -> response.newBuilder() .header(VIA, viaHeader(response)) .build()); }
ViaHeaderAppendingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header(VIA, viaHeader(request)) .build(); return chain.proceed(newRequest) .map(response -> response.newBuilder() .h...
ViaHeaderAppendingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header(VIA, viaHeader(request)) .build(); return chain.proceed(newRequest) .map(response -> response.newBuilder() .h...
ViaHeaderAppendingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header(VIA, viaHeader(request)) .build(); return chain.proceed(newRequest) .map(response -> response.newBuilder() .h...
ViaHeaderAppendingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header(VIA, viaHeader(request)) .build(); return chain.proceed(newRequest) .map(response -> response.newBuilder() .h...
@Test public void appendsViaHeaderValueAtEndOfListInResponse() throws Exception { LiveHttpResponse response = Mono.from(interceptor.intercept(get("/foo").build(), returnsResponse(response() .header(VIA, "1.0 ricky, 1.1 mertz, 1.0 lucy") .build()))).block(); assertThat(response.headers().get(VIA), isValue("1.0 ricky, 1....
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header(VIA, viaHeader(request)) .build(); return chain.proceed(newRequest) .map(response -> response.newBuilder() .header(VIA, viaHeader(response)) .build()); }
ViaHeaderAppendingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header(VIA, viaHeader(request)) .build(); return chain.proceed(newRequest) .map(response -> response.newBuilder() .h...
ViaHeaderAppendingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header(VIA, viaHeader(request)) .build(); return chain.proceed(newRequest) .map(response -> response.newBuilder() .h...
ViaHeaderAppendingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header(VIA, viaHeader(request)) .build(); return chain.proceed(newRequest) .map(response -> response.newBuilder() .h...
ViaHeaderAppendingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { LiveHttpRequest newRequest = request.newBuilder() .header(VIA, viaHeader(request)) .build(); return chain.proceed(newRequest) .map(response -> response.newBuilder() .h...
@Test public void addsRequestIdToTheHeaders() { requestEnrichingInterceptor.intercept(get("/some-uri").build(), recording); assertThat(recording.recordedRequest().header(REQUEST_ID_DEFAULT), is(notNullValue())); }
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); @Override Eventual<LiveHttpResponse> intercept(...
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); @Override Eventual<LiveHttpResponse> intercept(...
@Test public void setsTheRemoteAddressToTheForwardedForList() { requestEnrichingInterceptor.intercept(get("").build(), recording); assertThat(recording.recordedRequest().header(X_FORWARDED_FOR), isValue("127.0.0.1")); }
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); @Override Eventual<LiveHttpResponse> intercept(...
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); @Override Eventual<LiveHttpResponse> intercept(...
@Test public void appendsTheRemoteAddressToTheForwardedForList() { requestEnrichingInterceptor.intercept(get("/some") .header(X_FORWARDED_FOR, "172.21.175.59").build(), recording); assertThat(recording.recordedRequest().header(X_FORWARDED_FOR), isValue("172.21.175.59, 127.0.0.1")); }
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); @Override Eventual<LiveHttpResponse> intercept(...
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); @Override Eventual<LiveHttpResponse> intercept(...
@Test public void noRetriesForOtherExceptions() throws IOException { doThrow(new NullPointerException()).doNothing().when(task).run(); try { tryTimes(3, task, null); fail("An exception should have been thrown"); } catch (NullPointerException e) { verify(task, times(1)).run(); } }
public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { task.run()...
IoRetry { public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { ...
IoRetry { public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { ...
IoRetry { public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { ...
IoRetry { public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { ...
@Test public void addsXForwardedProtoToHttpWhenAbsent() { requestEnrichingInterceptor.intercept(get("/some").build(), recording); assertThat(recording.recordedRequest().header(X_FORWARDED_PROTO), isValue("http")); }
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); @Override Eventual<LiveHttpResponse> intercept(...
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); @Override Eventual<LiveHttpResponse> intercept(...
@Test public void addsXForwardedProtoToHttpsWhenAbsent() { requestEnrichingInterceptor.intercept(get("/some").build(), recordingSecure); assertThat(recordingSecure.recordedRequest().header(X_FORWARDED_PROTO), isValue("https")); }
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); @Override Eventual<LiveHttpResponse> intercept(...
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); @Override Eventual<LiveHttpResponse> intercept(...
@Test public void retainsXForwardedProtoWhenPresentInHttpMessage() { requestEnrichingInterceptor.intercept(get("/some").addHeader(X_FORWARDED_PROTO, "https").build(), recording); assertThat(recording.recordedRequest().header(X_FORWARDED_PROTO), isValue("https")); requestEnrichingInterceptor.intercept(get("/some").addHe...
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); @Override Eventual<LiveHttpResponse> intercept(...
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); @Override Eventual<LiveHttpResponse> intercept(...
@Test public void retainsXForwardedProtoWhenPresentInHttpsMessage() { requestEnrichingInterceptor.intercept(get("/some").addHeader(X_FORWARDED_PROTO, "http").build(), recording); assertThat(recording.recordedRequest().header(X_FORWARDED_PROTO), isValue("http")); requestEnrichingInterceptor.intercept(get("/some").addHea...
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); }
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); @Override Eventual<LiveHttpResponse> intercept(...
RequestEnrichingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(enrich(request, chain.context())); } RequestEnrichingInterceptor(StyxHeaderConfig styxHeaderConfig); @Override Eventual<LiveHttpResponse> intercept(...
@Test public void logsRequestsAndResponses() { LiveHttpRequest request = get("/") .version(HttpVersion.HTTP_1_1) .header("ReqHeader", "ReqHeaderValue") .cookies(requestCookie("ReqCookie", "ReqCookieValue")) .build(); consume(interceptor.intercept(request, chain( response(OK) .header("RespHeader", "RespHeaderValue") .co...
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { boolean secure = chain.context().isSecure(); logger.logRequest(request, null, secure); return chain.proceed(request).map(response -> { logger.logResponse(request, response, secure); return response; }); }
HttpMessageLoggingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { boolean secure = chain.context().isSecure(); logger.logRequest(request, null, secure); return chain.proceed(request).map(response -> { logger.logResponse(request, resp...
HttpMessageLoggingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { boolean secure = chain.context().isSecure(); logger.logRequest(request, null, secure); return chain.proceed(request).map(response -> { logger.logResponse(request, resp...
HttpMessageLoggingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { boolean secure = chain.context().isSecure(); logger.logRequest(request, null, secure); return chain.proceed(request).map(response -> { logger.logResponse(request, resp...
HttpMessageLoggingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { boolean secure = chain.context().isSecure(); logger.logRequest(request, null, secure); return chain.proceed(request).map(response -> { logger.logResponse(request, resp...
@Test public void logsRequestsAndResponsesShort() { interceptor = new HttpMessageLoggingInterceptor(false, httpMessageFormatter); LiveHttpRequest request = get("/") .header("ReqHeader", "ReqHeaderValue") .cookies(requestCookie("ReqCookie", "ReqCookieValue")) .build(); consume(interceptor.intercept(request, chain( respo...
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { boolean secure = chain.context().isSecure(); logger.logRequest(request, null, secure); return chain.proceed(request).map(response -> { logger.logResponse(request, response, secure); return response; }); }
HttpMessageLoggingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { boolean secure = chain.context().isSecure(); logger.logRequest(request, null, secure); return chain.proceed(request).map(response -> { logger.logResponse(request, resp...
HttpMessageLoggingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { boolean secure = chain.context().isSecure(); logger.logRequest(request, null, secure); return chain.proceed(request).map(response -> { logger.logResponse(request, resp...
HttpMessageLoggingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { boolean secure = chain.context().isSecure(); logger.logRequest(request, null, secure); return chain.proceed(request).map(response -> { logger.logResponse(request, resp...
HttpMessageLoggingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { boolean secure = chain.context().isSecure(); logger.logRequest(request, null, secure); return chain.proceed(request).map(response -> { logger.logResponse(request, resp...
@Test public void logsSecureRequests() { LiveHttpRequest request = get("/") .header("ReqHeader", "ReqHeaderValue") .cookies(requestCookie("ReqCookie", "ReqCookieValue")) .build(); consume(interceptor.intercept(request, chain(response(OK)))); assertThat(responseLogSupport.log(), contains( loggingEvent(INFO, "requestId="...
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { boolean secure = chain.context().isSecure(); logger.logRequest(request, null, secure); return chain.proceed(request).map(response -> { logger.logResponse(request, response, secure); return response; }); }
HttpMessageLoggingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { boolean secure = chain.context().isSecure(); logger.logRequest(request, null, secure); return chain.proceed(request).map(response -> { logger.logResponse(request, resp...
HttpMessageLoggingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { boolean secure = chain.context().isSecure(); logger.logRequest(request, null, secure); return chain.proceed(request).map(response -> { logger.logResponse(request, resp...
HttpMessageLoggingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { boolean secure = chain.context().isSecure(); logger.logRequest(request, null, secure); return chain.proceed(request).map(response -> { logger.logResponse(request, resp...
HttpMessageLoggingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { boolean secure = chain.context().isSecure(); logger.logRequest(request, null, secure); return chain.proceed(request).map(response -> { logger.logResponse(request, resp...
@Test public void resolvesConfigurationContext() { LiveHttpRequest request = get("/").build(); Configuration.Context context = context(ImmutableMap.of("key1", "value1", "key2", "value2")); ConfigurationContextResolver configurationContextResolver = configurationContextResolver(request, context); ConfigurationContextRes...
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { Configuration.Context context = configurationContextResolver.resolve(request); chain.context().add("config.context", context); return chain.proceed(request); }
ConfigurationContextResolverInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { Configuration.Context context = configurationContextResolver.resolve(request); chain.context().add("config.context", context); return chain.proceed(request);...
ConfigurationContextResolverInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { Configuration.Context context = configurationContextResolver.resolve(request); chain.context().add("config.context", context); return chain.proceed(request);...
ConfigurationContextResolverInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { Configuration.Context context = configurationContextResolver.resolve(request); chain.context().add("config.context", context); return chain.proceed(request);...
ConfigurationContextResolverInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { Configuration.Context context = configurationContextResolver.resolve(request); chain.context().add("config.context", context); return chain.proceed(request);...
@Test public void removesHopByHopHeadersFromResponse() throws Exception { LiveHttpResponse response = Mono.from(interceptor.intercept(get("/foo").build(), returnsResponse(response() .header(TE, "foo") .header(PROXY_AUTHENTICATE, "foo") .header(PROXY_AUTHORIZATION, "bar") .build()))).block(); assertThat(response.header(...
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(removeHopByHopHeaders(request)) .map(HopByHopHeadersRemovingInterceptor::removeHopByHopHeaders); }
HopByHopHeadersRemovingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(removeHopByHopHeaders(request)) .map(HopByHopHeadersRemovingInterceptor::removeHopByHopHeaders); } }
HopByHopHeadersRemovingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(removeHopByHopHeaders(request)) .map(HopByHopHeadersRemovingInterceptor::removeHopByHopHeaders); } }
HopByHopHeadersRemovingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(removeHopByHopHeaders(request)) .map(HopByHopHeadersRemovingInterceptor::removeHopByHopHeaders); } @Override Eventual<LiveHttpResponse> inte...
HopByHopHeadersRemovingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(removeHopByHopHeaders(request)) .map(HopByHopHeadersRemovingInterceptor::removeHopByHopHeaders); } @Override Eventual<LiveHttpResponse> inte...
@Test public void removesConnectionHeadersFromResponse() throws Exception { LiveHttpResponse response = Mono.from(interceptor.intercept(get("/foo").build(), returnsResponse(response() .header(CONNECTION, "Foo, Bar, Baz") .header("Foo", "abc") .header("Foo", "def") .header("Bar", "one, two, three") .build()))).block(); ...
@Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(removeHopByHopHeaders(request)) .map(HopByHopHeadersRemovingInterceptor::removeHopByHopHeaders); }
HopByHopHeadersRemovingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(removeHopByHopHeaders(request)) .map(HopByHopHeadersRemovingInterceptor::removeHopByHopHeaders); } }
HopByHopHeadersRemovingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(removeHopByHopHeaders(request)) .map(HopByHopHeadersRemovingInterceptor::removeHopByHopHeaders); } }
HopByHopHeadersRemovingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(removeHopByHopHeaders(request)) .map(HopByHopHeadersRemovingInterceptor::removeHopByHopHeaders); } @Override Eventual<LiveHttpResponse> inte...
HopByHopHeadersRemovingInterceptor implements HttpInterceptor { @Override public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request, Chain chain) { return chain.proceed(removeHopByHopHeaders(request)) .map(HopByHopHeadersRemovingInterceptor::removeHopByHopHeaders); } @Override Eventual<LiveHttpResponse> inte...
@Test public void illegalArgumentExceptionAndNoAttemptsForInvalidArgument() throws IOException { doNothing().when(task).run(); try { tryTimes(0, task, null); fail("An exception should have been thrown"); } catch (IllegalArgumentException e) { verify(task, times(0)).run(); } }
public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { task.run()...
IoRetry { public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { ...
IoRetry { public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { ...
IoRetry { public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { ...
IoRetry { public static void tryTimes(int times, IOAction task, Consumer<IOException> errorHandler) throws UncheckedIOException, IllegalArgumentException { if (times < 1) { throw new IllegalArgumentException("The number of retries should be a positive integer. It was " + times); } int retries = 0; while (true) { try { ...
@Test public void relaysReloadToRegistryDelegate() { FileBackedRegistry<BackendService> delegate = mock(FileBackedRegistry.class); when(delegate.reload()).thenReturn(CompletableFuture.completedFuture(ReloadResult.reloaded("relaod ok"))); registry = new FileBackedBackendServicesRegistry(delegate, FileMonitor.DISABLED); ...
@Override public CompletableFuture<ReloadResult> reload() { return this.fileBackedRegistry.reload() .thenApply(outcome -> logReloadAttempt("Admin Interface", outcome)); }
FileBackedBackendServicesRegistry extends AbstractStyxService implements Registry<BackendService>, FileChangeMonitor.Listener { @Override public CompletableFuture<ReloadResult> reload() { return this.fileBackedRegistry.reload() .thenApply(outcome -> logReloadAttempt("Admin Interface", outcome)); } }
FileBackedBackendServicesRegistry extends AbstractStyxService implements Registry<BackendService>, FileChangeMonitor.Listener { @Override public CompletableFuture<ReloadResult> reload() { return this.fileBackedRegistry.reload() .thenApply(outcome -> logReloadAttempt("Admin Interface", outcome)); } @VisibleForTesting F...
FileBackedBackendServicesRegistry extends AbstractStyxService implements Registry<BackendService>, FileChangeMonitor.Listener { @Override public CompletableFuture<ReloadResult> reload() { return this.fileBackedRegistry.reload() .thenApply(outcome -> logReloadAttempt("Admin Interface", outcome)); } @VisibleForTesting F...
FileBackedBackendServicesRegistry extends AbstractStyxService implements Registry<BackendService>, FileChangeMonitor.Listener { @Override public CompletableFuture<ReloadResult> reload() { return this.fileBackedRegistry.reload() .thenApply(outcome -> logReloadAttempt("Admin Interface", outcome)); } @VisibleForTesting F...
@Test public void relaysAddListenerToRegistryDelegate() { FileBackedRegistry<BackendService> delegate = mock(FileBackedRegistry.class); Registry.ChangeListener<BackendService> listener = mock(Registry.ChangeListener.class); registry = new FileBackedBackendServicesRegistry(delegate, FileMonitor.DISABLED); registry.addLi...
@Override public Registry<BackendService> addListener(ChangeListener<BackendService> changeListener) { return this.fileBackedRegistry.addListener(changeListener); }
FileBackedBackendServicesRegistry extends AbstractStyxService implements Registry<BackendService>, FileChangeMonitor.Listener { @Override public Registry<BackendService> addListener(ChangeListener<BackendService> changeListener) { return this.fileBackedRegistry.addListener(changeListener); } }
FileBackedBackendServicesRegistry extends AbstractStyxService implements Registry<BackendService>, FileChangeMonitor.Listener { @Override public Registry<BackendService> addListener(ChangeListener<BackendService> changeListener) { return this.fileBackedRegistry.addListener(changeListener); } @VisibleForTesting FileBac...
FileBackedBackendServicesRegistry extends AbstractStyxService implements Registry<BackendService>, FileChangeMonitor.Listener { @Override public Registry<BackendService> addListener(ChangeListener<BackendService> changeListener) { return this.fileBackedRegistry.addListener(changeListener); } @VisibleForTesting FileBac...
FileBackedBackendServicesRegistry extends AbstractStyxService implements Registry<BackendService>, FileChangeMonitor.Listener { @Override public Registry<BackendService> addListener(ChangeListener<BackendService> changeListener) { return this.fileBackedRegistry.addListener(changeListener); } @VisibleForTesting FileBac...
@Test public void relaysGetToRegistryDelegate() { FileBackedRegistry<BackendService> delegate = mock(FileBackedRegistry.class); registry = new FileBackedBackendServicesRegistry(delegate, FileMonitor.DISABLED); registry.get(); verify(delegate).get(); }
@Override public Iterable<BackendService> get() { return this.fileBackedRegistry.get(); }
FileBackedBackendServicesRegistry extends AbstractStyxService implements Registry<BackendService>, FileChangeMonitor.Listener { @Override public Iterable<BackendService> get() { return this.fileBackedRegistry.get(); } }
FileBackedBackendServicesRegistry extends AbstractStyxService implements Registry<BackendService>, FileChangeMonitor.Listener { @Override public Iterable<BackendService> get() { return this.fileBackedRegistry.get(); } @VisibleForTesting FileBackedBackendServicesRegistry(FileBackedRegistry<BackendService> fileBackedReg...
FileBackedBackendServicesRegistry extends AbstractStyxService implements Registry<BackendService>, FileChangeMonitor.Listener { @Override public Iterable<BackendService> get() { return this.fileBackedRegistry.get(); } @VisibleForTesting FileBackedBackendServicesRegistry(FileBackedRegistry<BackendService> fileBackedReg...
FileBackedBackendServicesRegistry extends AbstractStyxService implements Registry<BackendService>, FileChangeMonitor.Listener { @Override public Iterable<BackendService> get() { return this.fileBackedRegistry.get(); } @VisibleForTesting FileBackedBackendServicesRegistry(FileBackedRegistry<BackendService> fileBackedReg...
@Test public void reloadsDelegateRegistryOnStart() { FileBackedRegistry<BackendService> delegate = mock(FileBackedRegistry.class); when(delegate.reload()).thenReturn(completedFuture(reloaded("Changes applied!"))); registry = new FileBackedBackendServicesRegistry(delegate, FileMonitor.DISABLED); await(registry.start());...
@Override public CompletableFuture<ReloadResult> reload() { return this.fileBackedRegistry.reload() .thenApply(outcome -> logReloadAttempt("Admin Interface", outcome)); }
FileBackedBackendServicesRegistry extends AbstractStyxService implements Registry<BackendService>, FileChangeMonitor.Listener { @Override public CompletableFuture<ReloadResult> reload() { return this.fileBackedRegistry.reload() .thenApply(outcome -> logReloadAttempt("Admin Interface", outcome)); } }
FileBackedBackendServicesRegistry extends AbstractStyxService implements Registry<BackendService>, FileChangeMonitor.Listener { @Override public CompletableFuture<ReloadResult> reload() { return this.fileBackedRegistry.reload() .thenApply(outcome -> logReloadAttempt("Admin Interface", outcome)); } @VisibleForTesting F...
FileBackedBackendServicesRegistry extends AbstractStyxService implements Registry<BackendService>, FileChangeMonitor.Listener { @Override public CompletableFuture<ReloadResult> reload() { return this.fileBackedRegistry.reload() .thenApply(outcome -> logReloadAttempt("Admin Interface", outcome)); } @VisibleForTesting F...
FileBackedBackendServicesRegistry extends AbstractStyxService implements Registry<BackendService>, FileChangeMonitor.Listener { @Override public CompletableFuture<ReloadResult> reload() { return this.fileBackedRegistry.reload() .thenApply(outcome -> logReloadAttempt("Admin Interface", outcome)); } @VisibleForTesting F...
@Test public void canBeStartedOnlyOnce() { FileChangeMonitor.Listener listener = mock(FileChangeMonitor.Listener.class); FileChangeMonitor monitor = new FileChangeMonitor(monitoredFile.toString()); monitor.start(listener); Exception e = assertThrows(IllegalStateException.class, () -> monitor.start(listener)); assertTha...
@Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile); throw new IllegalStateException(message)...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
@Test public void initialPollNotifiesListeners() { monitor.start(listener); verify(listener, timeout(3000).times(1)).fileChanged(); }
@Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile); throw new IllegalStateException(message)...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
@Test public void notifiesListenersOnFileChange() throws Exception { monitor.start(listener); verify(listener, timeout(3000).times(1)).fileChanged(); Thread.sleep(250); for (int i = 2; i < 10; i++) { write(monitoredFile, format("content-v%d", i)); verify(listener, timeout(3000).times(i)).fileChanged(); LOGGER.info(form...
@Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile); throw new IllegalStateException(message)...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
@Test public void recoversFromFileDeletions() throws Exception { monitor.start(listener); verify(listener, timeout(3000).times(1)).fileChanged(); delete(monitoredFile); Thread.sleep(2000); write(monitoredFile, "some new content"); verify(listener, timeout(3000).times(2)).fileChanged(); }
@Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile); throw new IllegalStateException(message)...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
@Test public void detectsFileSizeChanges() throws Exception { monitor.start(listener); verify(listener, timeout(3000).times(1)).fileChanged(); }
@Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile); throw new IllegalStateException(message)...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
@Test public void recoversFromTruncatedFiles() throws Exception { monitor.start(listener); verify(listener, timeout(3000).times(1)).fileChanged(); write(monitoredFile, ""); verify(listener, timeout(3000).times(2)).fileChanged(); write(monitoredFile, "some new content"); verify(listener, timeout(3000).times(3)).fileChan...
@Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile); throw new IllegalStateException(message)...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
FileChangeMonitor implements FileMonitor { @Override public void start(Listener listener) { LOGGER.debug("start, initialDelay={}, pollPeriod={}", new Object[] {initialDelay, pollPeriod}); synchronized (this) { if (monitoredTask != null) { String message = format("File monitor for '%s' is already started", monitoredFile...
@Test public void sendsData() throws InterruptedException { registry.register("values", sequenceGauge(123L, 4567L, 8901L)); for (int i = 0; i < 3; i++) { service.report(); } assertThat(sender.data, contains("test.values=123", "test.values=4567", "test.values=8901")); }
@VisibleForTesting void report() { this.reporter.report(); }
GraphiteReporterService extends AbstractStyxService { @VisibleForTesting void report() { this.reporter.report(); } }
GraphiteReporterService extends AbstractStyxService { @VisibleForTesting void report() { this.reporter.report(); } private GraphiteReporterService(Builder builder); }
GraphiteReporterService extends AbstractStyxService { @VisibleForTesting void report() { this.reporter.report(); } private GraphiteReporterService(Builder builder); }
GraphiteReporterService extends AbstractStyxService { @VisibleForTesting void report() { this.reporter.report(); } private GraphiteReporterService(Builder builder); }
@Test public void printsTheCurrentTime() throws Exception { assertThat(healthCheckTimestamp.check().toString(), matchesRegex( "Result\\{isHealthy=true, message=1970-01-01T00:00:00.001\\+0000, timestamp=.*\\}")); }
@Override protected Result check() { ZonedDateTime now = Instant.ofEpochMilli(clock.tickMillis()).atZone(UTC); return healthy(DATE_TIME_FORMATTER.format(now)); }
HealthCheckTimestamp extends HealthCheck { @Override protected Result check() { ZonedDateTime now = Instant.ofEpochMilli(clock.tickMillis()).atZone(UTC); return healthy(DATE_TIME_FORMATTER.format(now)); } }
HealthCheckTimestamp extends HealthCheck { @Override protected Result check() { ZonedDateTime now = Instant.ofEpochMilli(clock.tickMillis()).atZone(UTC); return healthy(DATE_TIME_FORMATTER.format(now)); } HealthCheckTimestamp(); HealthCheckTimestamp(Clock clock); }
HealthCheckTimestamp extends HealthCheck { @Override protected Result check() { ZonedDateTime now = Instant.ofEpochMilli(clock.tickMillis()).atZone(UTC); return healthy(DATE_TIME_FORMATTER.format(now)); } HealthCheckTimestamp(); HealthCheckTimestamp(Clock clock); }
HealthCheckTimestamp extends HealthCheck { @Override protected Result check() { ZonedDateTime now = Instant.ofEpochMilli(clock.tickMillis()).atZone(UTC); return healthy(DATE_TIME_FORMATTER.format(now)); } HealthCheckTimestamp(); HealthCheckTimestamp(Clock clock); static final String NAME; }
@Test public void closesClientWhenBackendServicesAreUpdated() { BackendServiceClient firstClient = mock(BackendServiceClient.class); BackendServiceClient secondClient = mock(BackendServiceClient.class); BackendServiceClientFactory clientFactory = mock(BackendServiceClientFactory.class); when(clientFactory.createClient(...
@Override public void onChange(Registry.Changes<BackendService> changes) { changes.removed().forEach(backendService -> routes.remove(backendService.path()).close()); concat(changes.added(), changes.updated()).forEach(backendService -> { ProxyToClientPipeline pipeline = routes.get(backendService.path()); if (pipeline !=...
BackendServicesRouter implements HttpRouter, Registry.ChangeListener<BackendService> { @Override public void onChange(Registry.Changes<BackendService> changes) { changes.removed().forEach(backendService -> routes.remove(backendService.path()).close()); concat(changes.added(), changes.updated()).forEach(backendService -...
BackendServicesRouter implements HttpRouter, Registry.ChangeListener<BackendService> { @Override public void onChange(Registry.Changes<BackendService> changes) { changes.removed().forEach(backendService -> routes.remove(backendService.path()).close()); concat(changes.added(), changes.updated()).forEach(backendService -...
BackendServicesRouter implements HttpRouter, Registry.ChangeListener<BackendService> { @Override public void onChange(Registry.Changes<BackendService> changes) { changes.removed().forEach(backendService -> routes.remove(backendService.path()).close()); concat(changes.added(), changes.updated()).forEach(backendService -...
BackendServicesRouter implements HttpRouter, Registry.ChangeListener<BackendService> { @Override public void onChange(Registry.Changes<BackendService> changes) { changes.removed().forEach(backendService -> routes.remove(backendService.path()).close()); concat(changes.added(), changes.updated()).forEach(backendService -...
@Test public void closesClientWhenBackendServicesAreRemoved() { BackendServiceClient firstClient = mock(BackendServiceClient.class); BackendServiceClient secondClient = mock(BackendServiceClient.class); ArgumentCaptor<OriginsInventory> originsInventory = forClass(OriginsInventory.class); BackendServiceClientFactory cli...
@Override public void onChange(Registry.Changes<BackendService> changes) { changes.removed().forEach(backendService -> routes.remove(backendService.path()).close()); concat(changes.added(), changes.updated()).forEach(backendService -> { ProxyToClientPipeline pipeline = routes.get(backendService.path()); if (pipeline !=...
BackendServicesRouter implements HttpRouter, Registry.ChangeListener<BackendService> { @Override public void onChange(Registry.Changes<BackendService> changes) { changes.removed().forEach(backendService -> routes.remove(backendService.path()).close()); concat(changes.added(), changes.updated()).forEach(backendService -...
BackendServicesRouter implements HttpRouter, Registry.ChangeListener<BackendService> { @Override public void onChange(Registry.Changes<BackendService> changes) { changes.removed().forEach(backendService -> routes.remove(backendService.path()).close()); concat(changes.added(), changes.updated()).forEach(backendService -...
BackendServicesRouter implements HttpRouter, Registry.ChangeListener<BackendService> { @Override public void onChange(Registry.Changes<BackendService> changes) { changes.removed().forEach(backendService -> routes.remove(backendService.path()).close()); concat(changes.added(), changes.updated()).forEach(backendService -...
BackendServicesRouter implements HttpRouter, Registry.ChangeListener<BackendService> { @Override public void onChange(Registry.Changes<BackendService> changes) { changes.removed().forEach(backendService -> routes.remove(backendService.path()).close()); concat(changes.added(), changes.updated()).forEach(backendService -...
@Test public void deregistersAndReregistersMetricsAppropriately() { CodaHaleMetricRegistry metrics = new CodaHaleMetricRegistry(); Environment environment = new Environment.Builder() .metricRegistry(metrics) .build(); BackendServicesRouter router = new BackendServicesRouter( new StyxBackendServiceClientFactory(environm...
@Override public void onChange(Registry.Changes<BackendService> changes) { changes.removed().forEach(backendService -> routes.remove(backendService.path()).close()); concat(changes.added(), changes.updated()).forEach(backendService -> { ProxyToClientPipeline pipeline = routes.get(backendService.path()); if (pipeline !=...
BackendServicesRouter implements HttpRouter, Registry.ChangeListener<BackendService> { @Override public void onChange(Registry.Changes<BackendService> changes) { changes.removed().forEach(backendService -> routes.remove(backendService.path()).close()); concat(changes.added(), changes.updated()).forEach(backendService -...
BackendServicesRouter implements HttpRouter, Registry.ChangeListener<BackendService> { @Override public void onChange(Registry.Changes<BackendService> changes) { changes.removed().forEach(backendService -> routes.remove(backendService.path()).close()); concat(changes.added(), changes.updated()).forEach(backendService -...
BackendServicesRouter implements HttpRouter, Registry.ChangeListener<BackendService> { @Override public void onChange(Registry.Changes<BackendService> changes) { changes.removed().forEach(backendService -> routes.remove(backendService.path()).close()); concat(changes.added(), changes.updated()).forEach(backendService -...
BackendServicesRouter implements HttpRouter, Registry.ChangeListener<BackendService> { @Override public void onChange(Registry.Changes<BackendService> changes) { changes.removed().forEach(backendService -> routes.remove(backendService.path()).close()); concat(changes.added(), changes.updated()).forEach(backendService -...
@Test public void no_routes_always_throws_NoServiceConfiguredException() throws Exception { PathPrefixRouter router = buildRouter(emptyMap()); assertThrows(NoServiceConfiguredException.class, () -> Mono.from(router.handle(LiveHttpRequest.get("/").build(), null)).block() ); }
@Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { String path = request.path(); for (PrefixRoute route : routes) { if (path.startsWith(route.prefix)) { return route.routingObject.handle(request, context); } } return Eventual.error(new NoServiceConfiguredExcep...
PathPrefixRouter implements RoutingObject { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { String path = request.path(); for (PrefixRoute route : routes) { if (path.startsWith(route.prefix)) { return route.routingObject.handle(request, context); } } return...
PathPrefixRouter implements RoutingObject { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { String path = request.path(); for (PrefixRoute route : routes) { if (path.startsWith(route.prefix)) { return route.routingObject.handle(request, context); } } return...
PathPrefixRouter implements RoutingObject { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { String path = request.path(); for (PrefixRoute route : routes) { if (path.startsWith(route.prefix)) { return route.routingObject.handle(request, context); } } return...
PathPrefixRouter implements RoutingObject { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { String path = request.path(); for (PrefixRoute route : routes) { if (path.startsWith(route.prefix)) { return route.routingObject.handle(request, context); } } return...
@Test public void sendsExceptionUponMultipleSubscription() { HttpHandler handler = (request, context) -> Eventual.of(response(OK).build()); StandardHttpPipeline pipeline = new StandardHttpPipeline(handler); Eventual<LiveHttpResponse> responseObservable = pipeline.handle(get("/").build(), requestContext()); LiveHttpResp...
@Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { HttpInterceptorChain interceptorsChain = new HttpInterceptorChain(interceptors, 0, handler, context, requestTracker); return interceptorsChain.proceed(request); }
StandardHttpPipeline implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { HttpInterceptorChain interceptorsChain = new HttpInterceptorChain(interceptors, 0, handler, context, requestTracker); return interceptorsChain.proceed(request); } ...
StandardHttpPipeline implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { HttpInterceptorChain interceptorsChain = new HttpInterceptorChain(interceptors, 0, handler, context, requestTracker); return interceptorsChain.proceed(request); } ...
StandardHttpPipeline implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { HttpInterceptorChain interceptorsChain = new HttpInterceptorChain(interceptors, 0, handler, context, requestTracker); return interceptorsChain.proceed(request); } ...
StandardHttpPipeline implements HttpHandler { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { HttpInterceptorChain interceptorsChain = new HttpInterceptorChain(interceptors, 0, handler, context, requestTracker); return interceptorsChain.proceed(request); } ...
@Test public void loadsPlugins() { ConfiguredPluginFactory f1 = new ConfiguredPluginFactory("plugin1", any -> stubPlugin("MyResponse1")); ConfiguredPluginFactory f2 = new ConfiguredPluginFactory("plugin2", any -> stubPlugin("MyResponse2")); StyxServerComponents components = new StyxServerComponents.Builder() .styxConfi...
public List<NamedPlugin> plugins() { return plugins; }
StyxServerComponents { public List<NamedPlugin> plugins() { return plugins; } }
StyxServerComponents { public List<NamedPlugin> plugins() { return plugins; } private StyxServerComponents(Builder builder); }
StyxServerComponents { public List<NamedPlugin> plugins() { return plugins; } private StyxServerComponents(Builder builder); boolean showBanner(); Environment environment(); Map<String, StyxService> services(); List<NamedPlugin> plugins(); StyxObjectStore<RoutingObjectRecord> routeDatabase(); StyxObjectStore<StyxObjec...
StyxServerComponents { public List<NamedPlugin> plugins() { return plugins; } private StyxServerComponents(Builder builder); boolean showBanner(); Environment environment(); Map<String, StyxService> services(); List<NamedPlugin> plugins(); StyxObjectStore<RoutingObjectRecord> routeDatabase(); StyxObjectStore<StyxObjec...
@Test public void loadsServices() { StyxServerComponents components = new StyxServerComponents.Builder() .styxConfig(new StyxConfig()) .services((env, routeDb) -> ImmutableMap.of( "service1", mock(StyxService.class), "service2", mock(StyxService.class))) .build(); Map<String, StyxService> services = components.services...
public Map<String, StyxService> services() { return services; }
StyxServerComponents { public Map<String, StyxService> services() { return services; } }
StyxServerComponents { public Map<String, StyxService> services() { return services; } private StyxServerComponents(Builder builder); }
StyxServerComponents { public Map<String, StyxService> services() { return services; } private StyxServerComponents(Builder builder); boolean showBanner(); Environment environment(); Map<String, StyxService> services(); List<NamedPlugin> plugins(); StyxObjectStore<RoutingObjectRecord> routeDatabase(); StyxObjectStore<...
StyxServerComponents { public Map<String, StyxService> services() { return services; } private StyxServerComponents(Builder builder); boolean showBanner(); Environment environment(); Map<String, StyxService> services(); List<NamedPlugin> plugins(); StyxObjectStore<RoutingObjectRecord> routeDatabase(); StyxObjectStore<...
@Test public void exposesAdditionalServices() { StyxServerComponents components = new StyxServerComponents.Builder() .styxConfig(new StyxConfig()) .additionalServices(ImmutableMap.of( "service1", mock(StyxService.class), "service2", mock(StyxService.class))) .build(); Map<String, StyxService> services = components.serv...
public Map<String, StyxService> services() { return services; }
StyxServerComponents { public Map<String, StyxService> services() { return services; } }
StyxServerComponents { public Map<String, StyxService> services() { return services; } private StyxServerComponents(Builder builder); }
StyxServerComponents { public Map<String, StyxService> services() { return services; } private StyxServerComponents(Builder builder); boolean showBanner(); Environment environment(); Map<String, StyxService> services(); List<NamedPlugin> plugins(); StyxObjectStore<RoutingObjectRecord> routeDatabase(); StyxObjectStore<...
StyxServerComponents { public Map<String, StyxService> services() { return services; } private StyxServerComponents(Builder builder); boolean showBanner(); Environment environment(); Map<String, StyxService> services(); List<NamedPlugin> plugins(); StyxObjectStore<RoutingObjectRecord> routeDatabase(); StyxObjectStore<...
@Test public void createsEnvironment() { Configuration config = new Configuration.MapBackedConfiguration() .set("foo", "abc") .set("bar", "def"); StyxServerComponents components = new StyxServerComponents.Builder() .styxConfig(new StyxConfig(config)) .build(); Environment environment = components.environment(); assertT...
public Environment environment() { return environment; }
StyxServerComponents { public Environment environment() { return environment; } }
StyxServerComponents { public Environment environment() { return environment; } private StyxServerComponents(Builder builder); }
StyxServerComponents { public Environment environment() { return environment; } private StyxServerComponents(Builder builder); boolean showBanner(); Environment environment(); Map<String, StyxService> services(); List<NamedPlugin> plugins(); StyxObjectStore<RoutingObjectRecord> routeDatabase(); StyxObjectStore<StyxObj...
StyxServerComponents { public Environment environment() { return environment; } private StyxServerComponents(Builder builder); boolean showBanner(); Environment environment(); Map<String, StyxService> services(); List<NamedPlugin> plugins(); StyxObjectStore<RoutingObjectRecord> routeDatabase(); StyxObjectStore<StyxObj...
@Test public void formatsDoublesToTwoDecimalPlaces() throws InterruptedException { registry.register("values", sequenceGauge(78.99, 234.0, 123.456)); for (int i = 0; i < 3; i++) { service.report(); } assertThat(sender.data, contains("test.values=78.99", "test.values=234.00", "test.values=123.46")); }
@VisibleForTesting void report() { this.reporter.report(); }
GraphiteReporterService extends AbstractStyxService { @VisibleForTesting void report() { this.reporter.report(); } }
GraphiteReporterService extends AbstractStyxService { @VisibleForTesting void report() { this.reporter.report(); } private GraphiteReporterService(Builder builder); }
GraphiteReporterService extends AbstractStyxService { @VisibleForTesting void report() { this.reporter.report(); } private GraphiteReporterService(Builder builder); }
GraphiteReporterService extends AbstractStyxService { @VisibleForTesting void report() { this.reporter.report(); } private GraphiteReporterService(Builder builder); }
@Test public void registersVersionMetric() { MetricRegistry metrics = new CodaHaleMetricRegistry(); CoreMetrics.registerCoreMetrics(version, metrics); Gauge gauge = metrics.getGauges().get("styx.version.buildnumber"); assertThat(gauge.getValue(), is(3)); }
public static void registerCoreMetrics(Version buildInfo, MetricRegistry metrics) { registerVersionMetric(buildInfo, metrics); registerJvmMetrics(metrics); metrics.register("os", new OperatingSystemMetricSet()); }
CoreMetrics { public static void registerCoreMetrics(Version buildInfo, MetricRegistry metrics) { registerVersionMetric(buildInfo, metrics); registerJvmMetrics(metrics); metrics.register("os", new OperatingSystemMetricSet()); } }
CoreMetrics { public static void registerCoreMetrics(Version buildInfo, MetricRegistry metrics) { registerVersionMetric(buildInfo, metrics); registerJvmMetrics(metrics); metrics.register("os", new OperatingSystemMetricSet()); } private CoreMetrics(); }
CoreMetrics { public static void registerCoreMetrics(Version buildInfo, MetricRegistry metrics) { registerVersionMetric(buildInfo, metrics); registerJvmMetrics(metrics); metrics.register("os", new OperatingSystemMetricSet()); } private CoreMetrics(); static void registerCoreMetrics(Version buildInfo, MetricRegistry me...
CoreMetrics { public static void registerCoreMetrics(Version buildInfo, MetricRegistry metrics) { registerVersionMetric(buildInfo, metrics); registerJvmMetrics(metrics); metrics.register("os", new OperatingSystemMetricSet()); } private CoreMetrics(); static void registerCoreMetrics(Version buildInfo, MetricRegistry me...
@Test public void registersJvmMetrics() { MetricRegistry metrics = new CodaHaleMetricRegistry(); CoreMetrics.registerCoreMetrics(version, metrics); Map<String, Gauge> gauges = metrics.getGauges(); assertThat(gauges.keySet(), hasItems( "jvm.thread.blocked.count", "jvm.thread.count", "jvm.thread.daemon.count", "jvm.threa...
public static void registerCoreMetrics(Version buildInfo, MetricRegistry metrics) { registerVersionMetric(buildInfo, metrics); registerJvmMetrics(metrics); metrics.register("os", new OperatingSystemMetricSet()); }
CoreMetrics { public static void registerCoreMetrics(Version buildInfo, MetricRegistry metrics) { registerVersionMetric(buildInfo, metrics); registerJvmMetrics(metrics); metrics.register("os", new OperatingSystemMetricSet()); } }
CoreMetrics { public static void registerCoreMetrics(Version buildInfo, MetricRegistry metrics) { registerVersionMetric(buildInfo, metrics); registerJvmMetrics(metrics); metrics.register("os", new OperatingSystemMetricSet()); } private CoreMetrics(); }
CoreMetrics { public static void registerCoreMetrics(Version buildInfo, MetricRegistry metrics) { registerVersionMetric(buildInfo, metrics); registerJvmMetrics(metrics); metrics.register("os", new OperatingSystemMetricSet()); } private CoreMetrics(); static void registerCoreMetrics(Version buildInfo, MetricRegistry me...
CoreMetrics { public static void registerCoreMetrics(Version buildInfo, MetricRegistry metrics) { registerVersionMetric(buildInfo, metrics); registerJvmMetrics(metrics); metrics.register("os", new OperatingSystemMetricSet()); } private CoreMetrics(); static void registerCoreMetrics(Version buildInfo, MetricRegistry me...
@Test public void registersOperatingSystemMetrics() { MetricRegistry metrics = new CodaHaleMetricRegistry(); CoreMetrics.registerCoreMetrics(version, metrics); Map<String, Gauge> gauges = metrics.getGauges(); assertThat(gauges.keySet(), hasItems( "os.process.cpu.load", "os.process.cpu.time", "os.system.cpu.load", "os.m...
public static void registerCoreMetrics(Version buildInfo, MetricRegistry metrics) { registerVersionMetric(buildInfo, metrics); registerJvmMetrics(metrics); metrics.register("os", new OperatingSystemMetricSet()); }
CoreMetrics { public static void registerCoreMetrics(Version buildInfo, MetricRegistry metrics) { registerVersionMetric(buildInfo, metrics); registerJvmMetrics(metrics); metrics.register("os", new OperatingSystemMetricSet()); } }
CoreMetrics { public static void registerCoreMetrics(Version buildInfo, MetricRegistry metrics) { registerVersionMetric(buildInfo, metrics); registerJvmMetrics(metrics); metrics.register("os", new OperatingSystemMetricSet()); } private CoreMetrics(); }
CoreMetrics { public static void registerCoreMetrics(Version buildInfo, MetricRegistry metrics) { registerVersionMetric(buildInfo, metrics); registerJvmMetrics(metrics); metrics.register("os", new OperatingSystemMetricSet()); } private CoreMetrics(); static void registerCoreMetrics(Version buildInfo, MetricRegistry me...
CoreMetrics { public static void registerCoreMetrics(Version buildInfo, MetricRegistry metrics) { registerVersionMetric(buildInfo, metrics); registerJvmMetrics(metrics); metrics.register("os", new OperatingSystemMetricSet()); } private CoreMetrics(); static void registerCoreMetrics(Version buildInfo, MetricRegistry me...
@Test public void suppliesConfiguredPlugin() { String yaml = "" + "plugins:\n" + " active: myPlugin\n" + " all:\n" + " myPlugin:\n" + " factory:\n" + " class: com.hotels.styx.startup.extensions.PluginLoadingForStartupTest$MyPluginFactory\n" + " classPath: " + FIXTURES_CLASS_PATH + "\n" + " config:\n" + " testConfigurat...
public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFact...
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFact...
@Test public void providesNamesForAllActivatedPlugins() { String yaml = "" + "plugins:\n" + " active: myPlugin0,myPlugin2\n" + " all:\n" + " myPlugin0:\n" + " factory:\n" + " class: com.hotels.styx.startup.extensions.PluginLoadingForStartupTest$MyPluginFactory\n" + " classPath: " + FIXTURES_CLASS_PATH + "\n" + " config...
public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFact...
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFact...
@Test public void providesNamesForAllPluginsWhenHttpPipelineAttributeIsPresent() { String yaml = "" + "plugins:\n" + " all:\n" + " myPlugin0:\n" + " factory:\n" + " class: com.hotels.styx.startup.extensions.PluginLoadingForStartupTest$MyPluginFactory\n" + " classPath: " + FIXTURES_CLASS_PATH + "\n" + " config:\n" + " t...
public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFact...
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFact...
@Test public void throwsExceptionIfThereIsNoPluginMatchingActiveName() { String yaml = "" + "plugins:\n" + " active: myPlugin\n" + " all:\n" + " otherPlugin:\n" + " factory:\n" + " class: com.hotels.styx.startup.extensions.PluginLoadingForStartupTest$MyPluginFactory\n" + " classPath: " + FIXTURES_CLASS_PATH + "\n" + " ...
public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFact...
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFact...
@Test public void throwsExceptionIfFactoryClassDoesNotExist() { String yaml = "" + "plugins:\n" + " active: myPlugin\n" + " all:\n" + " - name: myPlugin\n" + " factory:\n" + " class: com.hotels.styx.startup.extensions.PluginLoadingForStartupTest$MyPluginFactoryDoesNotExist\n" + " classPath: " + FIXTURES_CLASS_PATH + "\...
public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFact...
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFact...
@Test public void throwsExceptionIfListOfPluginsNotSpecified() { String yaml = "" + "plugins:\n" + " active: myPlugin\n"; Exception e = assertThrows(RuntimeException.class, () -> PluginLoadingForStartup.loadPlugins(environment(yaml))); assertThat(e.getMessage(), matchesPattern("(?s).*No list of all plugins specified.*"...
public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFact...
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFact...
@Test public void throwsExceptionIfFactoryFailsToLoadPlugin() { String yaml = "" + "plugins:\n" + " active: myPlugin\n" + " all:\n" + " myPlugin:\n" + " factory:\n" + " class: com.hotels.styx.startup.extensions.PluginLoadingForStartupTest$FailingPluginFactory\n" + " classPath: " + FIXTURES_CLASS_PATH + "\n"; Exception ...
public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); }
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFact...
PluginLoadingForStartup { public static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFactory> factories) { return loadPluginsFromFactories(environment, factories); } private PluginLoadingForStartup(); static List<NamedPlugin> loadPlugins(Environment environment, List<ConfiguredPluginFact...
@Test public void sendsMultipleMetrics() throws InterruptedException { registry.register("longs", sequenceGauge(123L, 4567L)); registry.register("ints", sequenceGauge(98, 654)); for (int i = 0; i < 4; i++) { service.report(); } assertThat(sender.data, containsInAnyOrder("test.longs=123", "test.ints=98", "test.longs=456...
@VisibleForTesting void report() { this.reporter.report(); }
GraphiteReporterService extends AbstractStyxService { @VisibleForTesting void report() { this.reporter.report(); } }
GraphiteReporterService extends AbstractStyxService { @VisibleForTesting void report() { this.reporter.report(); } private GraphiteReporterService(Builder builder); }
GraphiteReporterService extends AbstractStyxService { @VisibleForTesting void report() { this.reporter.report(); } private GraphiteReporterService(Builder builder); }
GraphiteReporterService extends AbstractStyxService { @VisibleForTesting void report() { this.reporter.report(); } private GraphiteReporterService(Builder builder); }
@Test public void testStartUpProdServletContext() throws ServletException { env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION); webConfigurer.onStartup(servletContext); assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry); assertThat(servletContext.get...
@Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); } EnumSet<DispatcherType> disps = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWA...
WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { @Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); ...
WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { @Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); ...
WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { @Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); ...
WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { @Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); ...
@Test public void testStartUpDevServletContext() throws ServletException { env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT); webConfigurer.onStartup(servletContext); assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry); assertThat(servletContext.get...
@Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); } EnumSet<DispatcherType> disps = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWA...
WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { @Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); ...
WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { @Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); ...
WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { @Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); ...
WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { @Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); ...
@Test public void createEventEntityShouldSetAllNonProcessContextRelatedFields() { CloudProcessStartedEventImpl event = buildProcessStartedEvent(); ProcessStartedAuditEventEntity auditEventEntity = eventConverter.createEventEntity(event); assertThat(auditEventEntity).isNotNull(); assertThat(auditEventEntity.getEventId()...
@Override protected ProcessStartedAuditEventEntity createEventEntity(CloudRuntimeEvent cloudRuntimeEvent) { return new ProcessStartedAuditEventEntity((CloudProcessStartedEvent) cloudRuntimeEvent); }
ProcessStartedEventConverter extends BaseEventToEntityConverter { @Override protected ProcessStartedAuditEventEntity createEventEntity(CloudRuntimeEvent cloudRuntimeEvent) { return new ProcessStartedAuditEventEntity((CloudProcessStartedEvent) cloudRuntimeEvent); } }
ProcessStartedEventConverter extends BaseEventToEntityConverter { @Override protected ProcessStartedAuditEventEntity createEventEntity(CloudRuntimeEvent cloudRuntimeEvent) { return new ProcessStartedAuditEventEntity((CloudProcessStartedEvent) cloudRuntimeEvent); } ProcessStartedEventConverter(EventContextInfoAppender e...
ProcessStartedEventConverter extends BaseEventToEntityConverter { @Override protected ProcessStartedAuditEventEntity createEventEntity(CloudRuntimeEvent cloudRuntimeEvent) { return new ProcessStartedAuditEventEntity((CloudProcessStartedEvent) cloudRuntimeEvent); } ProcessStartedEventConverter(EventContextInfoAppender e...
ProcessStartedEventConverter extends BaseEventToEntityConverter { @Override protected ProcessStartedAuditEventEntity createEventEntity(CloudRuntimeEvent cloudRuntimeEvent) { return new ProcessStartedAuditEventEntity((CloudProcessStartedEvent) cloudRuntimeEvent); } ProcessStartedEventConverter(EventContextInfoAppender e...
@Test public void convertToEntityShouldReturnCreatedEntity() { ProcessStartedAuditEventEntity auditEventEntity = new ProcessStartedAuditEventEntity(); CloudProcessStartedEventImpl cloudRuntimeEvent = new CloudProcessStartedEventImpl(); doReturn(auditEventEntity).when(eventConverter).createEventEntity(cloudRuntimeEvent)...
@Override protected ProcessStartedAuditEventEntity createEventEntity(CloudRuntimeEvent cloudRuntimeEvent) { return new ProcessStartedAuditEventEntity((CloudProcessStartedEvent) cloudRuntimeEvent); }
ProcessStartedEventConverter extends BaseEventToEntityConverter { @Override protected ProcessStartedAuditEventEntity createEventEntity(CloudRuntimeEvent cloudRuntimeEvent) { return new ProcessStartedAuditEventEntity((CloudProcessStartedEvent) cloudRuntimeEvent); } }
ProcessStartedEventConverter extends BaseEventToEntityConverter { @Override protected ProcessStartedAuditEventEntity createEventEntity(CloudRuntimeEvent cloudRuntimeEvent) { return new ProcessStartedAuditEventEntity((CloudProcessStartedEvent) cloudRuntimeEvent); } ProcessStartedEventConverter(EventContextInfoAppender e...
ProcessStartedEventConverter extends BaseEventToEntityConverter { @Override protected ProcessStartedAuditEventEntity createEventEntity(CloudRuntimeEvent cloudRuntimeEvent) { return new ProcessStartedAuditEventEntity((CloudProcessStartedEvent) cloudRuntimeEvent); } ProcessStartedEventConverter(EventContextInfoAppender e...
ProcessStartedEventConverter extends BaseEventToEntityConverter { @Override protected ProcessStartedAuditEventEntity createEventEntity(CloudRuntimeEvent cloudRuntimeEvent) { return new ProcessStartedAuditEventEntity((CloudProcessStartedEvent) cloudRuntimeEvent); } ProcessStartedEventConverter(EventContextInfoAppender e...
@Test public void convertToAPIShouldCreateAPIEventAndCallEventContextInfoAppender() { ProcessStartedAuditEventEntity auditEventEntity = new ProcessStartedAuditEventEntity(); CloudProcessStartedEventImpl apiEvent = new CloudProcessStartedEventImpl(); doReturn(apiEvent).when(eventConverter).createAPIEvent(auditEventEntit...
@Override protected CloudRuntimeEventImpl<?, ?> createAPIEvent(AuditEventEntity auditEventEntity) { ProcessStartedAuditEventEntity processStartedAuditEventEntity = (ProcessStartedAuditEventEntity) auditEventEntity; return new CloudProcessStartedEventImpl(processStartedAuditEventEntity.getEventId(), processStartedAuditE...
ProcessStartedEventConverter extends BaseEventToEntityConverter { @Override protected CloudRuntimeEventImpl<?, ?> createAPIEvent(AuditEventEntity auditEventEntity) { ProcessStartedAuditEventEntity processStartedAuditEventEntity = (ProcessStartedAuditEventEntity) auditEventEntity; return new CloudProcessStartedEventImpl...
ProcessStartedEventConverter extends BaseEventToEntityConverter { @Override protected CloudRuntimeEventImpl<?, ?> createAPIEvent(AuditEventEntity auditEventEntity) { ProcessStartedAuditEventEntity processStartedAuditEventEntity = (ProcessStartedAuditEventEntity) auditEventEntity; return new CloudProcessStartedEventImpl...
ProcessStartedEventConverter extends BaseEventToEntityConverter { @Override protected CloudRuntimeEventImpl<?, ?> createAPIEvent(AuditEventEntity auditEventEntity) { ProcessStartedAuditEventEntity processStartedAuditEventEntity = (ProcessStartedAuditEventEntity) auditEventEntity; return new CloudProcessStartedEventImpl...
ProcessStartedEventConverter extends BaseEventToEntityConverter { @Override protected CloudRuntimeEventImpl<?, ?> createAPIEvent(AuditEventEntity auditEventEntity) { ProcessStartedAuditEventEntity processStartedAuditEventEntity = (ProcessStartedAuditEventEntity) auditEventEntity; return new CloudProcessStartedEventImpl...
@Test public void receiveEventShouldStoreEntity() { CloudRuntimeEvent cloudRuntimeEvent = mock(CloudRuntimeEventImpl.class); when(cloudRuntimeEvent.getEventType()).thenReturn(ProcessRuntimeEvent.ProcessEvents.PROCESS_CREATED); EventToEntityConverter converter = mock(EventToEntityConverter.class); when(converters.getCon...
@SuppressWarnings("unchecked") @Override @StreamListener(AuditConsumerChannels.AUDIT_CONSUMER) public void receiveCloudRuntimeEvent(@Headers Map<String, Object> headers, CloudRuntimeEvent<?, ?>... events) { if (events != null) { AtomicInteger counter = new AtomicInteger(0); for (CloudRuntimeEvent event : events) { Even...
AuditConsumerChannelHandlerImpl implements AuditConsumerChannelHandler { @SuppressWarnings("unchecked") @Override @StreamListener(AuditConsumerChannels.AUDIT_CONSUMER) public void receiveCloudRuntimeEvent(@Headers Map<String, Object> headers, CloudRuntimeEvent<?, ?>... events) { if (events != null) { AtomicInteger coun...
AuditConsumerChannelHandlerImpl implements AuditConsumerChannelHandler { @SuppressWarnings("unchecked") @Override @StreamListener(AuditConsumerChannels.AUDIT_CONSUMER) public void receiveCloudRuntimeEvent(@Headers Map<String, Object> headers, CloudRuntimeEvent<?, ?>... events) { if (events != null) { AtomicInteger coun...
AuditConsumerChannelHandlerImpl implements AuditConsumerChannelHandler { @SuppressWarnings("unchecked") @Override @StreamListener(AuditConsumerChannels.AUDIT_CONSUMER) public void receiveCloudRuntimeEvent(@Headers Map<String, Object> headers, CloudRuntimeEvent<?, ?>... events) { if (events != null) { AtomicInteger coun...
AuditConsumerChannelHandlerImpl implements AuditConsumerChannelHandler { @SuppressWarnings("unchecked") @Override @StreamListener(AuditConsumerChannels.AUDIT_CONSUMER) public void receiveCloudRuntimeEvent(@Headers Map<String, Object> headers, CloudRuntimeEvent<?, ?>... events) { if (events != null) { AtomicInteger coun...
@Test public void messageIdShouldBeSet(){ CloudRuntimeEvent cloudRuntimeEvent = mock(CloudRuntimeEventImpl.class); when(cloudRuntimeEvent.getEventType()).thenReturn(ProcessRuntimeEvent.ProcessEvents.PROCESS_CREATED); EventToEntityConverter converter = mock(EventToEntityConverter.class); when(converters.getConverterByEv...
@SuppressWarnings("unchecked") @Override @StreamListener(AuditConsumerChannels.AUDIT_CONSUMER) public void receiveCloudRuntimeEvent(@Headers Map<String, Object> headers, CloudRuntimeEvent<?, ?>... events) { if (events != null) { AtomicInteger counter = new AtomicInteger(0); for (CloudRuntimeEvent event : events) { Even...
AuditConsumerChannelHandlerImpl implements AuditConsumerChannelHandler { @SuppressWarnings("unchecked") @Override @StreamListener(AuditConsumerChannels.AUDIT_CONSUMER) public void receiveCloudRuntimeEvent(@Headers Map<String, Object> headers, CloudRuntimeEvent<?, ?>... events) { if (events != null) { AtomicInteger coun...
AuditConsumerChannelHandlerImpl implements AuditConsumerChannelHandler { @SuppressWarnings("unchecked") @Override @StreamListener(AuditConsumerChannels.AUDIT_CONSUMER) public void receiveCloudRuntimeEvent(@Headers Map<String, Object> headers, CloudRuntimeEvent<?, ?>... events) { if (events != null) { AtomicInteger coun...
AuditConsumerChannelHandlerImpl implements AuditConsumerChannelHandler { @SuppressWarnings("unchecked") @Override @StreamListener(AuditConsumerChannels.AUDIT_CONSUMER) public void receiveCloudRuntimeEvent(@Headers Map<String, Object> headers, CloudRuntimeEvent<?, ?>... events) { if (events != null) { AtomicInteger coun...
AuditConsumerChannelHandlerImpl implements AuditConsumerChannelHandler { @SuppressWarnings("unchecked") @Override @StreamListener(AuditConsumerChannels.AUDIT_CONSUMER) public void receiveCloudRuntimeEvent(@Headers Map<String, Object> headers, CloudRuntimeEvent<?, ?>... events) { if (events != null) { AtomicInteger coun...
@Test public void testGet() { String key = MemCacheUtil.toKey("123", "module.c"); MemCacheTemplate<String> memCacheTemplate = getMemCacheTemplate(); if (memCacheTemplate.set(key, "dsadsadsadsadas")) { String value = memCacheTemplate.get(key); Assert.assertEquals("dsadsadsadsadas", value); memCacheTemplate.delete(key); ...
@Override public T get(String key) { T value = null; MemcacheClient oneL1 = null; if (masterL1List != null && masterL1List.size() > 0) { oneL1 = chooseOneL1Client(); if (oneL1 != null) { value = get(key, oneL1); } } if (value == null) { value = get(key, master); } if (value == null && slave != null) { value = get(key, ...
MemCacheTemplate implements CacheAble<T> { @Override public T get(String key) { T value = null; MemcacheClient oneL1 = null; if (masterL1List != null && masterL1List.size() > 0) { oneL1 = chooseOneL1Client(); if (oneL1 != null) { value = get(key, oneL1); } } if (value == null) { value = get(key, master); } if (value ==...
MemCacheTemplate implements CacheAble<T> { @Override public T get(String key) { T value = null; MemcacheClient oneL1 = null; if (masterL1List != null && masterL1List.size() > 0) { oneL1 = chooseOneL1Client(); if (oneL1 != null) { value = get(key, oneL1); } } if (value == null) { value = get(key, master); } if (value ==...
MemCacheTemplate implements CacheAble<T> { @Override public T get(String key) { T value = null; MemcacheClient oneL1 = null; if (masterL1List != null && masterL1List.size() > 0) { oneL1 = chooseOneL1Client(); if (oneL1 != null) { value = get(key, oneL1); } } if (value == null) { value = get(key, master); } if (value ==...
MemCacheTemplate implements CacheAble<T> { @Override public T get(String key) { T value = null; MemcacheClient oneL1 = null; if (masterL1List != null && masterL1List.size() > 0) { oneL1 = chooseOneL1Client(); if (oneL1 != null) { value = get(key, oneL1); } } if (value == null) { value = get(key, master); } if (value ==...
@Test public void testGetAsyncSlow(){ ApiHttpClient client = new ApacheHttpClient(100, 1000, 1000, 1024*100); String result = client.getAsync("http: ApiLogger.debug(result); Assert.assertTrue(StringUtils.isBlank(result)); }
public String getAsync(final String url){ return getAsync(url, soTimeOut); }
ApacheHttpClient implements ApiHttpClient { public String getAsync(final String url){ return getAsync(url, soTimeOut); } }
ApacheHttpClient implements ApiHttpClient { public String getAsync(final String url){ return getAsync(url, soTimeOut); } ApacheHttpClient(); ApacheHttpClient(int maxConPerHost, int conTimeOutMs, int soTimeOutMs, int maxSize); ApacheHttpClient(int maxConPerHost, int conTimeOutMs, int soTimeOutMs, int maxSize,int minTh...
ApacheHttpClient implements ApiHttpClient { public String getAsync(final String url){ return getAsync(url, soTimeOut); } ApacheHttpClient(); ApacheHttpClient(int maxConPerHost, int conTimeOutMs, int soTimeOutMs, int maxSize); ApacheHttpClient(int maxConPerHost, int conTimeOutMs, int soTimeOutMs, int maxSize,int minTh...
ApacheHttpClient implements ApiHttpClient { public String getAsync(final String url){ return getAsync(url, soTimeOut); } ApacheHttpClient(); ApacheHttpClient(int maxConPerHost, int conTimeOutMs, int soTimeOutMs, int maxSize); ApacheHttpClient(int maxConPerHost, int conTimeOutMs, int soTimeOutMs, int maxSize,int minTh...
@Test public void testBuildGet(){ ApiHttpClient client = new ApacheHttpClient(100, 1000, 1000, 1024*100); String headvalue="headvalue"; List<Integer> ids=new ArrayList<Integer>(); ids.add(11); ids.add(12); String result = client.buildGet("http: .withHeader(TEST_HEADER_PREFIX + "ahead", headvalue) .withParam("uid", "1")...
public RequestBuilder buildGet(String url){ HttpMethod get=new GetMethod(url); HttpClientRequestBuilder ret=new HttpClientRequestBuilder(url,get,HttpManager.isBlockResource(url)); return ret; }
ApacheHttpClient implements ApiHttpClient { public RequestBuilder buildGet(String url){ HttpMethod get=new GetMethod(url); HttpClientRequestBuilder ret=new HttpClientRequestBuilder(url,get,HttpManager.isBlockResource(url)); return ret; } }
ApacheHttpClient implements ApiHttpClient { public RequestBuilder buildGet(String url){ HttpMethod get=new GetMethod(url); HttpClientRequestBuilder ret=new HttpClientRequestBuilder(url,get,HttpManager.isBlockResource(url)); return ret; } ApacheHttpClient(); ApacheHttpClient(int maxConPerHost, int conTimeOutMs, int soT...
ApacheHttpClient implements ApiHttpClient { public RequestBuilder buildGet(String url){ HttpMethod get=new GetMethod(url); HttpClientRequestBuilder ret=new HttpClientRequestBuilder(url,get,HttpManager.isBlockResource(url)); return ret; } ApacheHttpClient(); ApacheHttpClient(int maxConPerHost, int conTimeOutMs, int soT...
ApacheHttpClient implements ApiHttpClient { public RequestBuilder buildGet(String url){ HttpMethod get=new GetMethod(url); HttpClientRequestBuilder ret=new HttpClientRequestBuilder(url,get,HttpManager.isBlockResource(url)); return ret; } ApacheHttpClient(); ApacheHttpClient(int maxConPerHost, int conTimeOutMs, int soT...
@Test public void testBuildPost(){ ApiHttpClient client = new ApacheHttpClient(100, 1000, 1000, 1024*100); String headvalue="headvalue"; String result=client.buildPost("http: .withHeader(TEST_HEADER_PREFIX+"ahead", headvalue).withParam("uid", "1") .withParam("uid", "2").withParam("uid2", new String[]{"3","4"}) .withPar...
public RequestBuilder buildPost(String url){ PostMethod post = new PostMethod(url); HttpClientRequestBuilder ret=new HttpClientRequestBuilder(url,post,HttpManager.isBlockResource(url)); return ret; }
ApacheHttpClient implements ApiHttpClient { public RequestBuilder buildPost(String url){ PostMethod post = new PostMethod(url); HttpClientRequestBuilder ret=new HttpClientRequestBuilder(url,post,HttpManager.isBlockResource(url)); return ret; } }
ApacheHttpClient implements ApiHttpClient { public RequestBuilder buildPost(String url){ PostMethod post = new PostMethod(url); HttpClientRequestBuilder ret=new HttpClientRequestBuilder(url,post,HttpManager.isBlockResource(url)); return ret; } ApacheHttpClient(); ApacheHttpClient(int maxConPerHost, int conTimeOutMs, i...
ApacheHttpClient implements ApiHttpClient { public RequestBuilder buildPost(String url){ PostMethod post = new PostMethod(url); HttpClientRequestBuilder ret=new HttpClientRequestBuilder(url,post,HttpManager.isBlockResource(url)); return ret; } ApacheHttpClient(); ApacheHttpClient(int maxConPerHost, int conTimeOutMs, i...
ApacheHttpClient implements ApiHttpClient { public RequestBuilder buildPost(String url){ PostMethod post = new PostMethod(url); HttpClientRequestBuilder ret=new HttpClientRequestBuilder(url,post,HttpManager.isBlockResource(url)); return ret; } ApacheHttpClient(); ApacheHttpClient(int maxConPerHost, int conTimeOutMs, i...
@Test public void testPostByteArray() throws UnsupportedEncodingException{ ApiHttpClient client = new ApacheHttpClient(100, 1000, 1000, 1024*100); byte[] bytes = "test".getBytes("UTF-8"); String result=client.postMulti("http: ApiLogger.debug(result); Assert.assertTrue(Arrays.equals(bytes, result.getBytes("UTF-8"))); }
public String postMulti(String url, Map<String, Object> nameValues){ return postMulti(url,nameValues,DEFAULT_CHARSET); }
ApacheHttpClient implements ApiHttpClient { public String postMulti(String url, Map<String, Object> nameValues){ return postMulti(url,nameValues,DEFAULT_CHARSET); } }
ApacheHttpClient implements ApiHttpClient { public String postMulti(String url, Map<String, Object> nameValues){ return postMulti(url,nameValues,DEFAULT_CHARSET); } ApacheHttpClient(); ApacheHttpClient(int maxConPerHost, int conTimeOutMs, int soTimeOutMs, int maxSize); ApacheHttpClient(int maxConPerHost, int conTimeO...
ApacheHttpClient implements ApiHttpClient { public String postMulti(String url, Map<String, Object> nameValues){ return postMulti(url,nameValues,DEFAULT_CHARSET); } ApacheHttpClient(); ApacheHttpClient(int maxConPerHost, int conTimeOutMs, int soTimeOutMs, int maxSize); ApacheHttpClient(int maxConPerHost, int conTimeO...
ApacheHttpClient implements ApiHttpClient { public String postMulti(String url, Map<String, Object> nameValues){ return postMulti(url,nameValues,DEFAULT_CHARSET); } ApacheHttpClient(); ApacheHttpClient(int maxConPerHost, int conTimeOutMs, int soTimeOutMs, int maxSize); ApacheHttpClient(int maxConPerHost, int conTimeO...
@Test public void testStatus() { String result = McqBaseManager.status(); Assert.assertEquals("\r\nreading_mcq(yangwm,true):\ttrue", result); ApiLogger.debug("testStatus result:" + result); }
public static String status() { StringBuilder sb = new StringBuilder(512); sb.append("\r\nreading_mcq(yangwm,true):\t"); sb.append(IS_ALL_READ.get()); return sb.toString(); }
McqBaseManager { public static String status() { StringBuilder sb = new StringBuilder(512); sb.append("\r\nreading_mcq(yangwm,true):\t"); sb.append(IS_ALL_READ.get()); return sb.toString(); } }
McqBaseManager { public static String status() { StringBuilder sb = new StringBuilder(512); sb.append("\r\nreading_mcq(yangwm,true):\t"); sb.append(IS_ALL_READ.get()); return sb.toString(); } }
McqBaseManager { public static String status() { StringBuilder sb = new StringBuilder(512); sb.append("\r\nreading_mcq(yangwm,true):\t"); sb.append(IS_ALL_READ.get()); return sb.toString(); } static void stopReadAll(); static void startReadAll(); static String status(); }
McqBaseManager { public static String status() { StringBuilder sb = new StringBuilder(512); sb.append("\r\nreading_mcq(yangwm,true):\t"); sb.append(IS_ALL_READ.get()); return sb.toString(); } static void stopReadAll(); static void startReadAll(); static String status(); static AtomicBoolean IS_ALL_READ; }
@Test public void testParseClients() { Map<String, Integer> clientsConfig = new HashMap<String, Integer>(); clientsConfig.put("1", new Integer("11")); clientsConfig.put("2", new Integer("21")); clientsConfig.put("3", new Integer("31")); clientsConfig.put("4", new Integer("41")); Map<Integer, Integer> clients = Sharding...
public static<T> Map<Integer, T> parseClients(Map<String, T> clientsConfig){ Map<Integer, T> shardingClients = new HashMap<Integer, T>(); for(Map.Entry<String, T> entry : clientsConfig.entrySet()){ List<Integer> dbIdxs = parseDbIdx(entry.getKey()); T client = entry.getValue(); for(Integer dbIdx : dbIdxs){ shardingClien...
ShardingUtil { public static<T> Map<Integer, T> parseClients(Map<String, T> clientsConfig){ Map<Integer, T> shardingClients = new HashMap<Integer, T>(); for(Map.Entry<String, T> entry : clientsConfig.entrySet()){ List<Integer> dbIdxs = parseDbIdx(entry.getKey()); T client = entry.getValue(); for(Integer dbIdx : dbIdxs)...
ShardingUtil { public static<T> Map<Integer, T> parseClients(Map<String, T> clientsConfig){ Map<Integer, T> shardingClients = new HashMap<Integer, T>(); for(Map.Entry<String, T> entry : clientsConfig.entrySet()){ List<Integer> dbIdxs = parseDbIdx(entry.getKey()); T client = entry.getValue(); for(Integer dbIdx : dbIdxs)...
ShardingUtil { public static<T> Map<Integer, T> parseClients(Map<String, T> clientsConfig){ Map<Integer, T> shardingClients = new HashMap<Integer, T>(); for(Map.Entry<String, T> entry : clientsConfig.entrySet()){ List<Integer> dbIdxs = parseDbIdx(entry.getKey()); T client = entry.getValue(); for(Integer dbIdx : dbIdxs)...
ShardingUtil { public static<T> Map<Integer, T> parseClients(Map<String, T> clientsConfig){ Map<Integer, T> shardingClients = new HashMap<Integer, T>(); for(Map.Entry<String, T> entry : clientsConfig.entrySet()){ List<Integer> dbIdxs = parseDbIdx(entry.getKey()); T client = entry.getValue(); for(Integer dbIdx : dbIdxs)...
@Test public void testToJson() { long[] items = new long[10]; for (int i = 0; i < items.length; i++) { items[i] = (2300000000000000L + 101) + (items.length - 1 - i); } ArrayUtil.reverse(items); ApiLogger.debug(Arrays.toString(items)); int count = 20; int page = 1; long[] expecteds = Arrays.copyOf(items, items.length); ...
public static <T> String toJson(PageWrapper<T> pageWrapper, String name, long[] values) { JsonBuilder json = new JsonBuilder(); if (values == null) { json.append(name, "[]"); } else { json.appendStrArr(name, values); } appendJson(json, pageWrapper); json.flip(); return json.toString(); }
PageWrapperUtil { public static <T> String toJson(PageWrapper<T> pageWrapper, String name, long[] values) { JsonBuilder json = new JsonBuilder(); if (values == null) { json.append(name, "[]"); } else { json.appendStrArr(name, values); } appendJson(json, pageWrapper); json.flip(); return json.toString(); } }
PageWrapperUtil { public static <T> String toJson(PageWrapper<T> pageWrapper, String name, long[] values) { JsonBuilder json = new JsonBuilder(); if (values == null) { json.append(name, "[]"); } else { json.appendStrArr(name, values); } appendJson(json, pageWrapper); json.flip(); return json.toString(); } }
PageWrapperUtil { public static <T> String toJson(PageWrapper<T> pageWrapper, String name, long[] values) { JsonBuilder json = new JsonBuilder(); if (values == null) { json.append(name, "[]"); } else { json.appendStrArr(name, values); } appendJson(json, pageWrapper); json.flip(); return json.toString(); } static Strin...
PageWrapperUtil { public static <T> String toJson(PageWrapper<T> pageWrapper, String name, long[] values) { JsonBuilder json = new JsonBuilder(); if (values == null) { json.append(name, "[]"); } else { json.appendStrArr(name, values); } appendJson(json, pageWrapper); json.flip(); return json.toString(); } static Strin...
@Test public void testWrap() { long[] items = new long[10]; for (int i = 0; i < items.length; i++) { items[i] = (2300000000000000L + 101) + (items.length - 1 - i); } ApiLogger.debug(Arrays.toString(items)); int count = 20; long[] expecteds = Arrays.copyOf(items, items.length); PageWrapper<long[]> pageWrapper = PageWrap...
public static PageWrapper<long[]> wrap(long[] ids, int count) { PageWrapper<long[]> wrapper = new PageWrapper<long[]>(0, 0, ids); wrapper.totalNumber = ids.length; if (ids.length > 1) { wrapper.nextCursor = ids[ids.length - 1] + MAX_ID_ADJECT; } wrapper.result = Arrays.copyOf(ids, Math.min(ids.length, count)); return w...
PageWrapperUtil { public static PageWrapper<long[]> wrap(long[] ids, int count) { PageWrapper<long[]> wrapper = new PageWrapper<long[]>(0, 0, ids); wrapper.totalNumber = ids.length; if (ids.length > 1) { wrapper.nextCursor = ids[ids.length - 1] + MAX_ID_ADJECT; } wrapper.result = Arrays.copyOf(ids, Math.min(ids.length,...
PageWrapperUtil { public static PageWrapper<long[]> wrap(long[] ids, int count) { PageWrapper<long[]> wrapper = new PageWrapper<long[]>(0, 0, ids); wrapper.totalNumber = ids.length; if (ids.length > 1) { wrapper.nextCursor = ids[ids.length - 1] + MAX_ID_ADJECT; } wrapper.result = Arrays.copyOf(ids, Math.min(ids.length,...
PageWrapperUtil { public static PageWrapper<long[]> wrap(long[] ids, int count) { PageWrapper<long[]> wrapper = new PageWrapper<long[]>(0, 0, ids); wrapper.totalNumber = ids.length; if (ids.length > 1) { wrapper.nextCursor = ids[ids.length - 1] + MAX_ID_ADJECT; } wrapper.result = Arrays.copyOf(ids, Math.min(ids.length,...
PageWrapperUtil { public static PageWrapper<long[]> wrap(long[] ids, int count) { PageWrapper<long[]> wrapper = new PageWrapper<long[]>(0, 0, ids); wrapper.totalNumber = ids.length; if (ids.length > 1) { wrapper.nextCursor = ids[ids.length - 1] + MAX_ID_ADJECT; } wrapper.result = Arrays.copyOf(ids, Math.min(ids.length,...
@Test public void testCreateMutiGetSql() { String sql = "select a,b from table where a in "; int paramsSize = 10; String result = DaoUtil.createMutiGetSql(sql, paramsSize); ApiLogger.debug("testCreateMutiGetSql result:" + result); int count = 0; char[] chs = result.toCharArray(); for (char ch : chs) { if (ch == '?') { ...
public static String createMutiGetSql(String sql, int paramsSize){ StringBuilder sqlBuf = new StringBuilder().append(sql).append("( ?"); for(int i = 1; i < paramsSize; i++){ sqlBuf.append(", ?"); } return sqlBuf.append(")").toString(); }
DaoUtil { public static String createMutiGetSql(String sql, int paramsSize){ StringBuilder sqlBuf = new StringBuilder().append(sql).append("( ?"); for(int i = 1; i < paramsSize; i++){ sqlBuf.append(", ?"); } return sqlBuf.append(")").toString(); } }
DaoUtil { public static String createMutiGetSql(String sql, int paramsSize){ StringBuilder sqlBuf = new StringBuilder().append(sql).append("( ?"); for(int i = 1; i < paramsSize; i++){ sqlBuf.append(", ?"); } return sqlBuf.append(")").toString(); } }
DaoUtil { public static String createMutiGetSql(String sql, int paramsSize){ StringBuilder sqlBuf = new StringBuilder().append(sql).append("( ?"); for(int i = 1; i < paramsSize; i++){ sqlBuf.append(", ?"); } return sqlBuf.append(")").toString(); } static String createMutiGetEncodedSql(String sql, int paramsSize); stat...
DaoUtil { public static String createMutiGetSql(String sql, int paramsSize){ StringBuilder sqlBuf = new StringBuilder().append(sql).append("( ?"); for(int i = 1; i < paramsSize; i++){ sqlBuf.append(", ?"); } return sqlBuf.append(")").toString(); } static String createMutiGetEncodedSql(String sql, int paramsSize); stat...
@Test public void testCreateMultiInsertSql() { int paramsSize = 1; String result = DaoUtil.createMultiInsertSql("insert into test values", "(?, ?, ?, now())", paramsSize); System.out.println("testCreateMultiInsertSql paramsSize:" + paramsSize + ", result:" + result); Assert.assertEquals("insert into test values(?, ?, ?...
public static String createMultiInsertSql(String sqlPrefix, String sqlSuffix, int valuesSize) { StringBuilder sb = new StringBuilder(sqlPrefix).append(sqlSuffix); for (int i = 1; i < valuesSize; i++) { sb.append(", "); sb.append(sqlSuffix); } return sb.toString(); }
DaoUtil { public static String createMultiInsertSql(String sqlPrefix, String sqlSuffix, int valuesSize) { StringBuilder sb = new StringBuilder(sqlPrefix).append(sqlSuffix); for (int i = 1; i < valuesSize; i++) { sb.append(", "); sb.append(sqlSuffix); } return sb.toString(); } }
DaoUtil { public static String createMultiInsertSql(String sqlPrefix, String sqlSuffix, int valuesSize) { StringBuilder sb = new StringBuilder(sqlPrefix).append(sqlSuffix); for (int i = 1; i < valuesSize; i++) { sb.append(", "); sb.append(sqlSuffix); } return sb.toString(); } }
DaoUtil { public static String createMultiInsertSql(String sqlPrefix, String sqlSuffix, int valuesSize) { StringBuilder sb = new StringBuilder(sqlPrefix).append(sqlSuffix); for (int i = 1; i < valuesSize; i++) { sb.append(", "); sb.append(sqlSuffix); } return sb.toString(); } static String createMutiGetEncodedSql(Stri...
DaoUtil { public static String createMultiInsertSql(String sqlPrefix, String sqlSuffix, int valuesSize) { StringBuilder sb = new StringBuilder(sqlPrefix).append(sqlSuffix); for (int i = 1; i < valuesSize; i++) { sb.append(", "); sb.append(sqlSuffix); } return sb.toString(); } static String createMutiGetEncodedSql(Stri...
@Test public void testGetMulti() { String[] keys = MemCacheUtil.toKeys(new String[] { "123", "456", "789" }, "module.c"); MemCacheTemplate<String> memCacheTemplate = getMemCacheTemplate(); if (memCacheTemplate.set(keys[0], "dsadsadsadsadas")) { Map<String, String> map = memCacheTemplate.getMulti(keys); Assert.assertEqu...
@Override public Map<String, T> getMulti(String[] keys) { Map<String, T> values = new HashMap<String, T>(); MemcacheClient oneL1 = null; if (masterL1List != null && masterL1List.size() > 0) { oneL1 = chooseOneL1Client(); if (oneL1 != null) { values = getMulti(keys, oneL1); } } String[] leftkeys = null; if(keys.length >...
MemCacheTemplate implements CacheAble<T> { @Override public Map<String, T> getMulti(String[] keys) { Map<String, T> values = new HashMap<String, T>(); MemcacheClient oneL1 = null; if (masterL1List != null && masterL1List.size() > 0) { oneL1 = chooseOneL1Client(); if (oneL1 != null) { values = getMulti(keys, oneL1); } }...
MemCacheTemplate implements CacheAble<T> { @Override public Map<String, T> getMulti(String[] keys) { Map<String, T> values = new HashMap<String, T>(); MemcacheClient oneL1 = null; if (masterL1List != null && masterL1List.size() > 0) { oneL1 = chooseOneL1Client(); if (oneL1 != null) { values = getMulti(keys, oneL1); } }...
MemCacheTemplate implements CacheAble<T> { @Override public Map<String, T> getMulti(String[] keys) { Map<String, T> values = new HashMap<String, T>(); MemcacheClient oneL1 = null; if (masterL1List != null && masterL1List.size() > 0) { oneL1 = chooseOneL1Client(); if (oneL1 != null) { values = getMulti(keys, oneL1); } }...
MemCacheTemplate implements CacheAble<T> { @Override public Map<String, T> getMulti(String[] keys) { Map<String, T> values = new HashMap<String, T>(); MemcacheClient oneL1 = null; if (masterL1List != null && masterL1List.size() > 0) { oneL1 = chooseOneL1Client(); if (oneL1 != null) { values = getMulti(keys, oneL1); } }...
@Test public void testMultiGetSql() { String sql = "select * from table where uid=? and type in (?) order by date"; Object[] params = new Object[] { 12345, new Object[] { 1234, 1234 } }; String rs = DaoUtil.expendMultiGetSql(sql, params); Assert.assertEquals("select * from table where uid=? and type in (?,?) order by d...
public static String expendMultiGetSql(String sql, Object[] params) { int lastQuoteIndex = -1; for (int i = 0; i < params.length; i++) { lastQuoteIndex = sql.indexOf('?', lastQuoteIndex + 1); Object param = params[i]; if (param instanceof Object[]) { Object[] nestArrayParam = (Object[]) param; String multipleGetStateme...
DaoUtil { public static String expendMultiGetSql(String sql, Object[] params) { int lastQuoteIndex = -1; for (int i = 0; i < params.length; i++) { lastQuoteIndex = sql.indexOf('?', lastQuoteIndex + 1); Object param = params[i]; if (param instanceof Object[]) { Object[] nestArrayParam = (Object[]) param; String multiple...
DaoUtil { public static String expendMultiGetSql(String sql, Object[] params) { int lastQuoteIndex = -1; for (int i = 0; i < params.length; i++) { lastQuoteIndex = sql.indexOf('?', lastQuoteIndex + 1); Object param = params[i]; if (param instanceof Object[]) { Object[] nestArrayParam = (Object[]) param; String multiple...
DaoUtil { public static String expendMultiGetSql(String sql, Object[] params) { int lastQuoteIndex = -1; for (int i = 0; i < params.length; i++) { lastQuoteIndex = sql.indexOf('?', lastQuoteIndex + 1); Object param = params[i]; if (param instanceof Object[]) { Object[] nestArrayParam = (Object[]) param; String multiple...
DaoUtil { public static String expendMultiGetSql(String sql, Object[] params) { int lastQuoteIndex = -1; for (int i = 0; i < params.length; i++) { lastQuoteIndex = sql.indexOf('?', lastQuoteIndex + 1); Object param = params[i]; if (param instanceof Object[]) { Object[] nestArrayParam = (Object[]) param; String multiple...
@Test public void testGenerateIdForUuid() { IdCreator idCreator = createIdCreator("testuuid:5001,testuuid:5001"); long t1 = System.currentTimeMillis(); int count = 10; for(int i = 0; i < count; i++){ long id = idCreator.generateId(2); ApiLogger.debug("IdCreatorTest testGenerateIdForUuid id:" + id); } long t2 = System.c...
public long generateId(int bizFlagValue){ return getNextId(bizFlagValue); }
IdCreator implements IdCreate { public long generateId(int bizFlagValue){ return getNextId(bizFlagValue); } }
IdCreator implements IdCreate { public long generateId(int bizFlagValue){ return getNextId(bizFlagValue); } }
IdCreator implements IdCreate { public long generateId(int bizFlagValue){ return getNextId(bizFlagValue); } long generateId(int bizFlagValue); NaiveMemcacheClient getIdGenerateClient(); void setIdGenerateClient(NaiveMemcacheClient idGenerateClient); }
IdCreator implements IdCreate { public long generateId(int bizFlagValue){ return getNextId(bizFlagValue); } long generateId(int bizFlagValue); NaiveMemcacheClient getIdGenerateClient(); void setIdGenerateClient(NaiveMemcacheClient idGenerateClient); }
@Test public void testGenerateIdForUid() { IdCreator idCreator = createIdCreator("testuid:5101,testuid:5101"); long t1 = System.currentTimeMillis(); int count = 10; for(int i = 0; i < count; i++){ long id = idCreator.generateId(2); ApiLogger.debug("IdCreatorTest testGenerateIdForUid id:" + id); } long t2 = System.curre...
public long generateId(int bizFlagValue){ return getNextId(bizFlagValue); }
IdCreator implements IdCreate { public long generateId(int bizFlagValue){ return getNextId(bizFlagValue); } }
IdCreator implements IdCreate { public long generateId(int bizFlagValue){ return getNextId(bizFlagValue); } }
IdCreator implements IdCreate { public long generateId(int bizFlagValue){ return getNextId(bizFlagValue); } long generateId(int bizFlagValue); NaiveMemcacheClient getIdGenerateClient(); void setIdGenerateClient(NaiveMemcacheClient idGenerateClient); }
IdCreator implements IdCreate { public long generateId(int bizFlagValue){ return getNextId(bizFlagValue); } long generateId(int bizFlagValue); NaiveMemcacheClient getIdGenerateClient(); void setIdGenerateClient(NaiveMemcacheClient idGenerateClient); }
@Test public void testFormatException(){ WebApiException e = new WebApiException(ExcepFactor.E_PARAM_INVALID_ERROR, "param error"); String result = WebExceptionFormat.formatException(e, "/user/test", "json"); ApiLogger.debug("testFormatException result:" + result); }
public static String formatException(WebApiException e, String path, String type) { if (path == null) { throw new IllegalArgumentException(" path argument is null"); } ExcepFactor factor = e.getFactor(); if (type == null) { } String result; if ("xml".equals(type)) { result = String.format(xmlMsg, path, factor.getErrorC...
WebExceptionFormat { public static String formatException(WebApiException e, String path, String type) { if (path == null) { throw new IllegalArgumentException(" path argument is null"); } ExcepFactor factor = e.getFactor(); if (type == null) { } String result; if ("xml".equals(type)) { result = String.format(xmlMsg, p...
WebExceptionFormat { public static String formatException(WebApiException e, String path, String type) { if (path == null) { throw new IllegalArgumentException(" path argument is null"); } ExcepFactor factor = e.getFactor(); if (type == null) { } String result; if ("xml".equals(type)) { result = String.format(xmlMsg, p...
WebExceptionFormat { public static String formatException(WebApiException e, String path, String type) { if (path == null) { throw new IllegalArgumentException(" path argument is null"); } ExcepFactor factor = e.getFactor(); if (type == null) { } String result; if ("xml".equals(type)) { result = String.format(xmlMsg, p...
WebExceptionFormat { public static String formatException(WebApiException e, String path, String type) { if (path == null) { throw new IllegalArgumentException(" path argument is null"); } ExcepFactor factor = e.getFactor(); if (type == null) { } String result; if ("xml".equals(type)) { result = String.format(xmlMsg, p...
@Test public void testTopN() { Map<String, ? extends VectorInterface> vectorMap = getAllVectorMap(); for (int column = -1; column >= 0; column--) { ApiLogger.debug(column); } long[] result = TopN.top(vectorMap.values(), 20); ApiLogger.debug("result length:" + result.length + ", result" + Arrays.toString(result)); resul...
public static long[] top(Collection<? extends VectorInterface> vectorItems, int n) { VectorInterface[] vectors = getVectors(vectorItems); return top(vectors, n); }
TopN { public static long[] top(Collection<? extends VectorInterface> vectorItems, int n) { VectorInterface[] vectors = getVectors(vectorItems); return top(vectors, n); } }
TopN { public static long[] top(Collection<? extends VectorInterface> vectorItems, int n) { VectorInterface[] vectors = getVectors(vectorItems); return top(vectors, n); } }
TopN { public static long[] top(Collection<? extends VectorInterface> vectorItems, int n) { VectorInterface[] vectors = getVectors(vectorItems); return top(vectors, n); } static long[] top(Collection<? extends VectorInterface> vectorItems, int n); }
TopN { public static long[] top(Collection<? extends VectorInterface> vectorItems, int n) { VectorInterface[] vectors = getVectors(vectorItems); return top(vectors, n); } static long[] top(Collection<? extends VectorInterface> vectorItems, int n); }
@Test public void testTopN() { Map<String, ? extends VectorInterface> vectorMap = getAllVectorMap(); for (int column = -1; column >= 0; column--) { ApiLogger.debug(column); } Object[] result = (Object[]) TopNObject.top(vectorMap.values(), 20); ApiLogger.debug("result length:" + result.length + ", result" + Arrays.toStr...
public static Object[] top(Collection<? extends VectorInterface> vectorItems, int n) { return top(vectorItems, n, CommonConst.EMPTY_OBJECT_ARRAY); }
TopNObject { public static Object[] top(Collection<? extends VectorInterface> vectorItems, int n) { return top(vectorItems, n, CommonConst.EMPTY_OBJECT_ARRAY); } }
TopNObject { public static Object[] top(Collection<? extends VectorInterface> vectorItems, int n) { return top(vectorItems, n, CommonConst.EMPTY_OBJECT_ARRAY); } }
TopNObject { public static Object[] top(Collection<? extends VectorInterface> vectorItems, int n) { return top(vectorItems, n, CommonConst.EMPTY_OBJECT_ARRAY); } static Object[] top(Collection<? extends VectorInterface> vectorItems, int n); static Object[] top(Collection<? extends VectorInterface> vectorItems, int n, ...
TopNObject { public static Object[] top(Collection<? extends VectorInterface> vectorItems, int n) { return top(vectorItems, n, CommonConst.EMPTY_OBJECT_ARRAY); } static Object[] top(Collection<? extends VectorInterface> vectorItems, int n); static Object[] top(Collection<? extends VectorInterface> vectorItems, int n, ...
@Test public void testToJsonStr() { Assert.assertEquals("dal\\\"?[]}das\\\\aa\\n33\\r24\\tkkh\\r86gg\\f11\\b", JsonUtil.toJsonStr("dal\"?[]}das\\aa\n33\r24\tkkh\r86gg\f11\b")); }
public static String toJsonStr(String value) { if (value == null) return null; StringBuilder buf = new StringBuilder(value.length()); for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); switch(c) { case '"': buf.append("\\\""); break; case '\\': buf.append("\\\\"); break; case '\n': buf.append("\\n"); ...
JsonUtil { public static String toJsonStr(String value) { if (value == null) return null; StringBuilder buf = new StringBuilder(value.length()); for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); switch(c) { case '"': buf.append("\\\""); break; case '\\': buf.append("\\\\"); break; case '\n': buf.appe...
JsonUtil { public static String toJsonStr(String value) { if (value == null) return null; StringBuilder buf = new StringBuilder(value.length()); for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); switch(c) { case '"': buf.append("\\\""); break; case '\\': buf.append("\\\\"); break; case '\n': buf.appe...
JsonUtil { public static String toJsonStr(String value) { if (value == null) return null; StringBuilder buf = new StringBuilder(value.length()); for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); switch(c) { case '"': buf.append("\\\""); break; case '\\': buf.append("\\\\"); break; case '\n': buf.appe...
JsonUtil { public static String toJsonStr(String value) { if (value == null) return null; StringBuilder buf = new StringBuilder(value.length()); for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); switch(c) { case '"': buf.append("\\\""); break; case '\\': buf.append("\\\\"); break; case '\n': buf.appe...
@Test public void testIsValidJsonObject() { Assert.assertEquals(true, JsonUtil.isValidJsonObject("{}")); Assert.assertEquals(false, JsonUtil.isValidJsonObject("")); Assert.assertEquals(false, JsonUtil.isValidJsonObject(null)); Assert.assertEquals(true, JsonUtil.isValidJsonObject("{\"uid\":1750715731}")); Assert.assertE...
public static boolean isValidJsonObject(String json){ return isValidJsonObject(json, false); }
JsonUtil { public static boolean isValidJsonObject(String json){ return isValidJsonObject(json, false); } }
JsonUtil { public static boolean isValidJsonObject(String json){ return isValidJsonObject(json, false); } }
JsonUtil { public static boolean isValidJsonObject(String json){ return isValidJsonObject(json, false); } static String toJsonStr(String value); static boolean isValidJsonObject(String json); static boolean isValidJsonObject(String json, boolean allowBlank); static boolean isValidJsonArray(String json); static boolean...
JsonUtil { public static boolean isValidJsonObject(String json){ return isValidJsonObject(json, false); } static String toJsonStr(String value); static boolean isValidJsonObject(String json); static boolean isValidJsonObject(String json, boolean allowBlank); static boolean isValidJsonArray(String json); static boolean...
@Test public void testIsValidJsonArray() { Assert.assertEquals(true, JsonUtil.isValidJsonArray("[]")); Assert.assertEquals(false, JsonUtil.isValidJsonArray("")); Assert.assertEquals(false, JsonUtil.isValidJsonArray(null)); Assert.assertEquals(true, JsonUtil.isValidJsonArray("[{\"uid\":1750715731},{\"uid\":1821155363}]"...
public static boolean isValidJsonArray(String json){ return isValidJsonArray(json, false); }
JsonUtil { public static boolean isValidJsonArray(String json){ return isValidJsonArray(json, false); } }
JsonUtil { public static boolean isValidJsonArray(String json){ return isValidJsonArray(json, false); } }
JsonUtil { public static boolean isValidJsonArray(String json){ return isValidJsonArray(json, false); } static String toJsonStr(String value); static boolean isValidJsonObject(String json); static boolean isValidJsonObject(String json, boolean allowBlank); static boolean isValidJsonArray(String json); static boolean i...
JsonUtil { public static boolean isValidJsonArray(String json){ return isValidJsonArray(json, false); } static String toJsonStr(String value); static boolean isValidJsonObject(String json); static boolean isValidJsonObject(String json, boolean allowBlank); static boolean isValidJsonArray(String json); static boolean i...
@Test public void testToJson() { Assert.assertEquals("[1, 2, 3]", JsonUtil.toJson(new long[]{1, 2, 3})); }
public static String toJson(long[] ids) { StringBuilder sb = new StringBuilder(); sb.append("["); if (ids != null) { for (int i = 0; i < ids.length; i++) { if (i > 0) { sb.append(", "); } sb.append(ids[i]); } } sb.append("]"); return sb.toString(); }
JsonUtil { public static String toJson(long[] ids) { StringBuilder sb = new StringBuilder(); sb.append("["); if (ids != null) { for (int i = 0; i < ids.length; i++) { if (i > 0) { sb.append(", "); } sb.append(ids[i]); } } sb.append("]"); return sb.toString(); } }
JsonUtil { public static String toJson(long[] ids) { StringBuilder sb = new StringBuilder(); sb.append("["); if (ids != null) { for (int i = 0; i < ids.length; i++) { if (i > 0) { sb.append(", "); } sb.append(ids[i]); } } sb.append("]"); return sb.toString(); } }
JsonUtil { public static String toJson(long[] ids) { StringBuilder sb = new StringBuilder(); sb.append("["); if (ids != null) { for (int i = 0; i < ids.length; i++) { if (i > 0) { sb.append(", "); } sb.append(ids[i]); } } sb.append("]"); return sb.toString(); } static String toJsonStr(String value); static boolean isV...
JsonUtil { public static String toJson(long[] ids) { StringBuilder sb = new StringBuilder(); sb.append("["); if (ids != null) { for (int i = 0; i < ids.length; i++) { if (i > 0) { sb.append(", "); } sb.append(ids[i]); } } sb.append("]"); return sb.toString(); } static String toJsonStr(String value); static boolean isV...
@Test public void testSet() { String key = MemCacheUtil.toKey("123", "module.c"); MemCacheTemplate<String> memCacheTemplate = getMemCacheTemplate(); if (memCacheTemplate.set(key, "dsadsadsadsadas")) { String value = memCacheTemplate.get(key); Assert.assertEquals("dsadsadsadsadas", value); memCacheTemplate.delete(key); ...
@Override public boolean set(String key, T value) { return set(key, value, expireTime); }
MemCacheTemplate implements CacheAble<T> { @Override public boolean set(String key, T value) { return set(key, value, expireTime); } }
MemCacheTemplate implements CacheAble<T> { @Override public boolean set(String key, T value) { return set(key, value, expireTime); } }
MemCacheTemplate implements CacheAble<T> { @Override public boolean set(String key, T value) { return set(key, value, expireTime); } @Override T get(String key); @Override Map<String, T> getMulti(String[] keys); @Override boolean set(String key, T value); @Override boolean set(String key, T value, Date expdate); @Supp...
MemCacheTemplate implements CacheAble<T> { @Override public boolean set(String key, T value) { return set(key, value, expireTime); } @Override T get(String key); @Override Map<String, T> getMulti(String[] keys); @Override boolean set(String key, T value); @Override boolean set(String key, T value, Date expdate); @Supp...
@Test public void testMd5() { String strMd5 = MD5Util.md5("123456"); ApiLogger.debug("MD5UtilTest testMd5 strMd5:" + strMd5); Assert.assertEquals("e10adc3949ba59abbe56e057f20f883e", strMd5); }
public static String md5(String src) { return md5(src.getBytes()); }
MD5Util { public static String md5(String src) { return md5(src.getBytes()); } }
MD5Util { public static String md5(String src) { return md5(src.getBytes()); } }
MD5Util { public static String md5(String src) { return md5(src.getBytes()); } static String md5(String src); static String md5(byte[] bytes); static String encodeHex(byte[] bytes); static String md5(long[] array); static byte[] long2Byte(long[] longArray); static void main(String[] args); }
MD5Util { public static String md5(String src) { return md5(src.getBytes()); } static String md5(String src); static String md5(byte[] bytes); static String encodeHex(byte[] bytes); static String md5(long[] array); static byte[] long2Byte(long[] longArray); static void main(String[] args); }