diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 57f13791e..0668c88ba 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -12,6 +12,7 @@ on:
jobs:
build_maven:
runs-on: ubuntu-latest
+ timeout-minutes: 30
steps:
- uses: actions/checkout@v3
diff --git a/gateleen-cache/pom.xml b/gateleen-cache/pom.xml
index 5bd3b3ef0..4d60b14f0 100644
--- a/gateleen-cache/pom.xml
+++ b/gateleen-cache/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-cache
diff --git a/gateleen-core/pom.xml b/gateleen-core/pom.xml
index 7d588256f..957753aee 100644
--- a/gateleen-core/pom.xml
+++ b/gateleen-core/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-core
diff --git a/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/AbstractHttpClient.java b/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/AbstractHttpClient.java
index 05a1f6131..27d312587 100644
--- a/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/AbstractHttpClient.java
+++ b/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/AbstractHttpClient.java
@@ -4,11 +4,15 @@
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.MultiMap;
+import io.vertx.core.Promise;
+import io.vertx.core.Vertx;
import io.vertx.core.http.*;
import java.util.List;
import java.util.function.Function;
+import static io.vertx.core.Future.succeededFuture;
+
/**
* Base class with empty method implementations.
*
@@ -16,6 +20,12 @@
*/
public abstract class AbstractHttpClient implements HttpClient {
+ private final Vertx vertx;
+
+ public AbstractHttpClient(Vertx vertx) {
+ this.vertx = vertx;
+ }
+
protected abstract HttpClientRequest doRequest(HttpMethod method, String uri);
public HttpClientRequest options(String uri) {
@@ -51,12 +61,14 @@ public Function> redirectHandler() {
@Override
public void close(Handler> handler) {
- throw new UnsupportedOperationException();
+ close().onComplete(handler);
}
@Override
public Future close() {
- throw new UnsupportedOperationException();
+ Promise promise = Promise.promise();
+ vertx.runOnContext(v -> promise.complete());
+ return promise.future();
}
@Override
@@ -71,7 +83,7 @@ public Future request(RequestOptions requestOptions) {
@Override
public void request(HttpMethod httpMethod, int i, String s, String s1, Handler> handler) {
- Future.succeededFuture(doRequest(httpMethod, s1)).onComplete(handler);
+ vertx.runOnContext(v -> succeededFuture(doRequest(httpMethod, s1)).onComplete(handler));
}
@Override
@@ -81,6 +93,7 @@ public Future request(HttpMethod httpMethod, int i, String s,
@Override
public void request(HttpMethod httpMethod, String s, String s1, Handler> handler) {
+ throw new UnsupportedOperationException();
}
@Override
@@ -90,7 +103,7 @@ public Future request(HttpMethod httpMethod, String s, String
@Override
public void request(HttpMethod method, String requestURI, Handler> handler) {
- throw new UnsupportedOperationException();
+ vertx.runOnContext(v -> succeededFuture(doRequest(method, requestURI)).onComplete(handler));
}
@Override
@@ -152,4 +165,4 @@ public Future webSocketAbs(String s, MultiMap multiMap, WebsocketVers
public boolean isMetricsEnabled() {
throw new UnsupportedOperationException();
}
-}
\ No newline at end of file
+}
diff --git a/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/LocalHttpClient.java b/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/LocalHttpClient.java
index 1750f7d64..07848ea76 100644
--- a/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/LocalHttpClient.java
+++ b/gateleen-core/src/main/java/org/swisspush/gateleen/core/http/LocalHttpClient.java
@@ -15,6 +15,7 @@ public class LocalHttpClient extends AbstractHttpClient {
private Vertx vertx;
public LocalHttpClient(Vertx vertx) {
+ super(vertx);
this.vertx = vertx;
}
diff --git a/gateleen-delegate/pom.xml b/gateleen-delegate/pom.xml
index 95b90af42..bd39abc0a 100644
--- a/gateleen-delegate/pom.xml
+++ b/gateleen-delegate/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-delegate
diff --git a/gateleen-delta/pom.xml b/gateleen-delta/pom.xml
index bdfc0d567..16dfa340a 100644
--- a/gateleen-delta/pom.xml
+++ b/gateleen-delta/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-delta
diff --git a/gateleen-expansion/pom.xml b/gateleen-expansion/pom.xml
index 28428cacd..1398fb037 100644
--- a/gateleen-expansion/pom.xml
+++ b/gateleen-expansion/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-expansion
diff --git a/gateleen-expansion/src/main/java/org/swisspush/gateleen/expansion/ExpansionHandler.java b/gateleen-expansion/src/main/java/org/swisspush/gateleen/expansion/ExpansionHandler.java
index a75f5c399..d0dd971bd 100755
--- a/gateleen-expansion/src/main/java/org/swisspush/gateleen/expansion/ExpansionHandler.java
+++ b/gateleen-expansion/src/main/java/org/swisspush/gateleen/expansion/ExpansionHandler.java
@@ -5,16 +5,24 @@
import io.vertx.core.MultiMap;
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
-import io.vertx.core.http.*;
+import io.vertx.core.http.HttpClient;
+import io.vertx.core.http.HttpClientRequest;
+import io.vertx.core.http.HttpClientResponse;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.swisspush.gateleen.core.http.RequestLoggerFactory;
import org.swisspush.gateleen.core.storage.ResourceStorage;
-import org.swisspush.gateleen.core.util.*;
+import org.swisspush.gateleen.core.util.ExpansionDeltaUtil;
import org.swisspush.gateleen.core.util.ExpansionDeltaUtil.CollectionResourceContainer;
import org.swisspush.gateleen.core.util.ExpansionDeltaUtil.SlashHandling;
+import org.swisspush.gateleen.core.util.HttpServerRequestUtil;
+import org.swisspush.gateleen.core.util.ResourceCollectionException;
+import org.swisspush.gateleen.core.util.ResponseStatusCodeLogUtil;
+import org.swisspush.gateleen.core.util.StatusCode;
import org.swisspush.gateleen.routing.Rule;
import org.swisspush.gateleen.routing.RuleFeaturesProvider;
import org.swisspush.gateleen.routing.RuleProvider;
@@ -25,6 +33,7 @@
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
+import static org.swisspush.gateleen.core.util.StatusCode.INTERNAL_SERVER_ERROR;
import static org.swisspush.gateleen.routing.RuleFeatures.Feature.EXPAND_ON_BACKEND;
import static org.swisspush.gateleen.routing.RuleFeatures.Feature.STORAGE_EXPAND;
import static org.swisspush.gateleen.routing.RuleProvider.RuleChangesObserver;
@@ -491,7 +500,9 @@ private void removeZipParameter(final HttpServerRequest request) {
private void makeStorageExpandRequest(final String targetUri, final List subResourceNames, final HttpServerRequest req, final DeltaHandler handler) {
Logger log = RequestLoggerFactory.getLogger(ExpansionHandler.class, req);
- httpClient.request(HttpMethod.POST, targetUri + "?storageExpand=true").onComplete(asyncResult -> {
+ HttpMethod reqMethod = HttpMethod.POST;
+ String reqUri = targetUri + "?storageExpand=true";
+ httpClient.request(reqMethod, reqUri).onComplete(asyncResult -> {
if (asyncResult.failed()) {
log.warn("Failed request to {}: {}", targetUri + "?storageExpand=true", asyncResult.cause());
return;
@@ -512,16 +523,23 @@ private void makeStorageExpandRequest(final String targetUri, final List subReso
cReq.write(payload);
cReq.send(event -> {
+ if (event.failed()) {
+ Throwable ex = event.cause();
+ log.debug("{} {}", reqMethod, reqUri, ex);
+ var exWrappr = new ResourceCollectionException(ex.getMessage(), INTERNAL_SERVER_ERROR);
+ handler.handle(new ResourceNode(SERIOUS_EXCEPTION, exWrappr));
+ }
HttpClientResponse cRes = event.result();
cRes.bodyHandler(data -> {
if (StatusCode.NOT_FOUND.getStatusCode() == cRes.statusCode()) {
- log.debug("requested resource could not be found: {}", targetUri);
+ log.debug("NotFound: {}", targetUri);
handler.handle(new ResourceNode(SERIOUS_EXCEPTION, new ResourceCollectionException(cRes.statusMessage(), StatusCode.NOT_FOUND)));
} else if (StatusCode.INTERNAL_SERVER_ERROR.getStatusCode() == cRes.statusCode()) {
- log.error("error in request resource : {} message : {}", targetUri, data.toString());
- handler.handle(new ResourceNode(SERIOUS_EXCEPTION, new ResourceCollectionException(data.toString(), StatusCode.INTERNAL_SERVER_ERROR)));
+ String fullResponseBody = data.toString();
+ log.error("{}: {}: {}", INTERNAL_SERVER_ERROR, targetUri, fullResponseBody);
+ handler.handle(new ResourceNode(SERIOUS_EXCEPTION, new ResourceCollectionException(fullResponseBody, StatusCode.INTERNAL_SERVER_ERROR)));
} else if (StatusCode.METHOD_NOT_ALLOWED.getStatusCode() == cRes.statusCode()) {
- log.error("POST requests (storageExpand) not allowed for uri: {}", targetUri);
+ log.error("storageExpand not allowed for: {}", targetUri);
handler.handle(new ResourceNode(SERIOUS_EXCEPTION, new ResourceCollectionException(cRes.statusMessage(), StatusCode.METHOD_NOT_ALLOWED)));
} else {
String eTag = geteTag(cRes.headers());
diff --git a/gateleen-hook-js/pom.xml b/gateleen-hook-js/pom.xml
index 82d59c13a..317dcfc30 100644
--- a/gateleen-hook-js/pom.xml
+++ b/gateleen-hook-js/pom.xml
@@ -4,7 +4,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-hook-js
jar
diff --git a/gateleen-hook/pom.xml b/gateleen-hook/pom.xml
index 9b9884225..993117b3f 100644
--- a/gateleen-hook/pom.xml
+++ b/gateleen-hook/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-hook
diff --git a/gateleen-hook/src/main/java/org/swisspush/gateleen/hook/HookHandler.java b/gateleen-hook/src/main/java/org/swisspush/gateleen/hook/HookHandler.java
index d38c1c9ab..f0ec0542e 100755
--- a/gateleen-hook/src/main/java/org/swisspush/gateleen/hook/HookHandler.java
+++ b/gateleen-hook/src/main/java/org/swisspush/gateleen/hook/HookHandler.java
@@ -29,6 +29,7 @@
import org.swisspush.gateleen.core.util.*;
import org.swisspush.gateleen.hook.queueingstrategy.*;
import org.swisspush.gateleen.hook.reducedpropagation.ReducedPropagationManager;
+import org.swisspush.gateleen.logging.LogAppenderRepository;
import org.swisspush.gateleen.logging.LoggingResourceManager;
import org.swisspush.gateleen.monitoring.MonitoringHandler;
import org.swisspush.gateleen.queue.expiry.ExpiryCheckHandler;
@@ -47,6 +48,8 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import static io.vertx.core.http.HttpMethod.DELETE;
+import static io.vertx.core.http.HttpMethod.PUT;
import static org.swisspush.gateleen.core.util.HttpRequestHeader.CONTENT_LENGTH;
/**
@@ -105,6 +108,7 @@ public class HookHandler implements LoggableResource {
private final ResourceStorage hookStorage;
private final MonitoringHandler monitoringHandler;
private final LoggingResourceManager loggingResourceManager;
+ private final LogAppenderRepository logAppenderRepository;
private final HttpClient selfClient;
private final String userProfilePath;
private final String hookRootUri;
@@ -135,9 +139,9 @@ public class HookHandler implements LoggableResource {
* @param hookRootUri hookRootUri
*/
public HookHandler(Vertx vertx, HttpClient selfClient, final ResourceStorage storage,
- LoggingResourceManager loggingResourceManager, MonitoringHandler monitoringHandler,
+ LoggingResourceManager loggingResourceManager, LogAppenderRepository logAppenderRepository, MonitoringHandler monitoringHandler,
String userProfilePath, String hookRootUri) {
- this(vertx, selfClient, storage, loggingResourceManager, monitoringHandler, userProfilePath, hookRootUri,
+ this(vertx, selfClient, storage, loggingResourceManager, logAppenderRepository, monitoringHandler, userProfilePath, hookRootUri,
new QueueClient(vertx, monitoringHandler));
}
@@ -155,16 +159,16 @@ public HookHandler(Vertx vertx, HttpClient selfClient, final ResourceStorage sto
* @param requestQueue requestQueue
*/
public HookHandler(Vertx vertx, HttpClient selfClient, final ResourceStorage storage,
- LoggingResourceManager loggingResourceManager, MonitoringHandler monitoringHandler,
+ LoggingResourceManager loggingResourceManager, LogAppenderRepository logAppenderRepository, MonitoringHandler monitoringHandler,
String userProfilePath, String hookRootUri, RequestQueue requestQueue) {
- this(vertx, selfClient, storage, loggingResourceManager, monitoringHandler, userProfilePath, hookRootUri,
+ this(vertx, selfClient, storage, loggingResourceManager, logAppenderRepository, monitoringHandler, userProfilePath, hookRootUri,
requestQueue, false);
}
public HookHandler(Vertx vertx, HttpClient selfClient, final ResourceStorage storage,
- LoggingResourceManager loggingResourceManager, MonitoringHandler monitoringHandler,
+ LoggingResourceManager loggingResourceManager, LogAppenderRepository logAppenderRepository, MonitoringHandler monitoringHandler,
String userProfilePath, String hookRootUri, RequestQueue requestQueue, boolean listableRoutes) {
- this(vertx, selfClient, storage, loggingResourceManager, monitoringHandler, userProfilePath, hookRootUri,
+ this(vertx, selfClient, storage, loggingResourceManager, logAppenderRepository, monitoringHandler, userProfilePath, hookRootUri,
requestQueue, false, null);
}
@@ -183,18 +187,18 @@ public HookHandler(Vertx vertx, HttpClient selfClient, final ResourceStorage sto
* @param reducedPropagationManager reducedPropagationManager
*/
public HookHandler(Vertx vertx, HttpClient selfClient, final ResourceStorage storage,
- LoggingResourceManager loggingResourceManager, MonitoringHandler monitoringHandler,
+ LoggingResourceManager loggingResourceManager, LogAppenderRepository logAppenderRepository, MonitoringHandler monitoringHandler,
String userProfilePath, String hookRootUri, RequestQueue requestQueue, boolean listableRoutes,
ReducedPropagationManager reducedPropagationManager) {
- this(vertx, selfClient, storage, loggingResourceManager, monitoringHandler, userProfilePath, hookRootUri,
+ this(vertx, selfClient, storage, loggingResourceManager, logAppenderRepository, monitoringHandler, userProfilePath, hookRootUri,
requestQueue, listableRoutes, reducedPropagationManager, null, storage);
}
public HookHandler(Vertx vertx, HttpClient selfClient, final ResourceStorage storage,
- LoggingResourceManager loggingResourceManager, MonitoringHandler monitoringHandler,
+ LoggingResourceManager loggingResourceManager, LogAppenderRepository logAppenderRepository, MonitoringHandler monitoringHandler,
String userProfilePath, String hookRootUri, RequestQueue requestQueue, boolean listableRoutes,
ReducedPropagationManager reducedPropagationManager, Handler doneHandler, ResourceStorage hookStorage) {
- this(vertx, selfClient, storage, loggingResourceManager, monitoringHandler, userProfilePath, hookRootUri,
+ this(vertx, selfClient, storage, loggingResourceManager, logAppenderRepository, monitoringHandler, userProfilePath, hookRootUri,
requestQueue, listableRoutes, reducedPropagationManager, doneHandler, hookStorage, Router.DEFAULT_ROUTER_MULTIPLIER);
}
@@ -218,7 +222,7 @@ public HookHandler(Vertx vertx, HttpClient selfClient, final ResourceStorage sto
* the number of {@link Router} instances within a cluster
*/
public HookHandler(Vertx vertx, HttpClient selfClient, final ResourceStorage userProfileStorage,
- LoggingResourceManager loggingResourceManager, MonitoringHandler monitoringHandler,
+ LoggingResourceManager loggingResourceManager, LogAppenderRepository logAppenderRepository, MonitoringHandler monitoringHandler,
String userProfilePath, String hookRootUri, RequestQueue requestQueue, boolean listableRoutes,
ReducedPropagationManager reducedPropagationManager, Handler doneHandler, ResourceStorage hookStorage,
int routeMultiplier) {
@@ -227,6 +231,7 @@ public HookHandler(Vertx vertx, HttpClient selfClient, final ResourceStorage use
this.selfClient = selfClient;
this.userProfileStorage = userProfileStorage;
this.loggingResourceManager = loggingResourceManager;
+ this.logAppenderRepository = logAppenderRepository;
this.monitoringHandler = monitoringHandler;
this.userProfilePath = userProfilePath;
this.hookRootUri = hookRootUri;
@@ -502,24 +507,28 @@ public boolean handle(final RoutingContext ctx) {
/*
* 1) Un- / Register Listener / Routes
*/
- if (isHookListenerRegistration(request)) {
- handleListenerRegistration(request);
- return true;
- }
-
- if (isHookListenerUnregistration(request)) {
- handleListenerUnregistration(request);
- return true;
- }
-
- if (isHookRouteRegistration(request)) {
- handleRouteRegistration(request);
- return true;
+ var requestMethod = request.method();
+ if (requestMethod == PUT) {
+ var requestUri = request.uri();
+ if (requestUri.contains(HOOKS_LISTENERS_URI_PART)) {
+ handleListenerRegistration(request);
+ return true;
+ }
+ if (requestUri.contains(HOOKS_ROUTE_URI_PART)) {
+ handleRouteRegistration(request);
+ return true;
+ }
}
-
- if (isHookRouteUnregistration(request)) {
- handleRouteUnregistration(request);
- return true;
+ if (requestMethod == DELETE) {
+ var requestUri = request.uri();
+ if (requestUri.contains(HOOKS_LISTENERS_URI_PART)) {
+ handleListenerUnregistration(request);
+ return true;
+ }
+ if (requestUri.contains(HOOKS_ROUTE_URI_PART)) {
+ handleRouteUnregistration(request);
+ return true;
+ }
}
/*
@@ -1612,7 +1621,8 @@ private boolean headersFilterPatternEquals(Pattern headersFilterPatternLeft, Pat
* @return Route
*/
private Route createRoute(String urlPattern, HttpHook hook) {
- return new Route(vertx, userProfileStorage, loggingResourceManager, monitoringHandler, userProfilePath, hook, urlPattern, selfClient);
+ return new Route(vertx, userProfileStorage, loggingResourceManager, logAppenderRepository, monitoringHandler,
+ userProfilePath, hook, urlPattern, selfClient);
}
/**
@@ -1654,46 +1664,6 @@ private String getListenerUrlSegment(String requestUrl) {
return requestUrl.substring(pos + HOOKS_LISTENERS_URI_PART.length());
}
- /**
- * Checks if the given request is a listener unregistration instruction.
- *
- * @param request request
- * @return boolean
- */
- private boolean isHookListenerUnregistration(HttpServerRequest request) {
- return request.uri().contains(HOOKS_LISTENERS_URI_PART) && HttpMethod.DELETE == request.method();
- }
-
- /**
- * Checks if the given request is a listener registration instruction.
- *
- * @param request request
- * @return boolean
- */
- private boolean isHookListenerRegistration(HttpServerRequest request) {
- return request.uri().contains(HOOKS_LISTENERS_URI_PART) && HttpMethod.PUT == request.method();
- }
-
- /**
- * Checks if the given request is a route registration instruction.
- *
- * @param request request
- * @return boolean
- */
- private boolean isHookRouteRegistration(HttpServerRequest request) {
- return request.uri().contains(HOOKS_ROUTE_URI_PART) && HttpMethod.PUT == request.method();
- }
-
- /**
- * Checks if the given request is a route registration instruction.
- *
- * @param request request
- * @return boolean
- */
- private boolean isHookRouteUnregistration(HttpServerRequest request) {
- return request.uri().contains(HOOKS_ROUTE_URI_PART) && HttpMethod.DELETE == request.method();
- }
-
/**
* @param request Request to extract the value from. This instance gets manipulated
* internally during call.
diff --git a/gateleen-hook/src/main/java/org/swisspush/gateleen/hook/Route.java b/gateleen-hook/src/main/java/org/swisspush/gateleen/hook/Route.java
index fdc320ebe..85080e44b 100755
--- a/gateleen-hook/src/main/java/org/swisspush/gateleen/hook/Route.java
+++ b/gateleen-hook/src/main/java/org/swisspush/gateleen/hook/Route.java
@@ -10,6 +10,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.swisspush.gateleen.core.storage.ResourceStorage;
+import org.swisspush.gateleen.logging.LogAppenderRepository;
import org.swisspush.gateleen.logging.LoggingResourceManager;
import org.swisspush.gateleen.monitoring.MonitoringHandler;
import org.swisspush.gateleen.routing.Forwarder;
@@ -44,6 +45,7 @@ public class Route {
private Vertx vertx;
private LoggingResourceManager loggingResourceManager;
+ private LogAppenderRepository logAppenderRepository;
private MonitoringHandler monitoringHandler;
private String userProfilePath;
private ResourceStorage storage;
@@ -76,10 +78,12 @@ public class Route {
* @param httpHook httpHook
* @param urlPattern - this can be a listener or a normal urlPattern (eg. for a route)
*/
- public Route(Vertx vertx, ResourceStorage storage, LoggingResourceManager loggingResourceManager, MonitoringHandler monitoringHandler, String userProfilePath, HttpHook httpHook, String urlPattern, HttpClient selfClient) {
+ public Route(Vertx vertx, ResourceStorage storage, LoggingResourceManager loggingResourceManager, LogAppenderRepository logAppenderRepository,
+ MonitoringHandler monitoringHandler, String userProfilePath, HttpHook httpHook, String urlPattern, HttpClient selfClient) {
this.vertx = vertx;
this.storage = storage;
this.loggingResourceManager = loggingResourceManager;
+ this.logAppenderRepository = logAppenderRepository;
this.monitoringHandler = monitoringHandler;
this.userProfilePath = userProfilePath;
this.httpHook = httpHook;
@@ -97,7 +101,8 @@ public Route(Vertx vertx, ResourceStorage storage, LoggingResourceManager loggin
* Creates the forwarder for this hook.
*/
private void createForwarder() {
- forwarder = new Forwarder(vertx, client, rule, storage, loggingResourceManager, monitoringHandler, userProfilePath, null);
+ forwarder = new Forwarder(vertx, client, rule, storage, loggingResourceManager, logAppenderRepository,
+ monitoringHandler, userProfilePath, null);
}
/**
diff --git a/gateleen-hook/src/test/java/org/swisspush/gateleen/hook/HookHandlerTest.java b/gateleen-hook/src/test/java/org/swisspush/gateleen/hook/HookHandlerTest.java
index f49eaf75c..30bcf706f 100644
--- a/gateleen-hook/src/test/java/org/swisspush/gateleen/hook/HookHandlerTest.java
+++ b/gateleen-hook/src/test/java/org/swisspush/gateleen/hook/HookHandlerTest.java
@@ -21,6 +21,7 @@
import org.swisspush.gateleen.core.http.*;
import org.swisspush.gateleen.core.storage.MockResourceStorage;
import org.swisspush.gateleen.hook.reducedpropagation.ReducedPropagationManager;
+import org.swisspush.gateleen.logging.LogAppenderRepository;
import org.swisspush.gateleen.logging.LoggingResourceManager;
import org.swisspush.gateleen.monitoring.MonitoringHandler;
import org.swisspush.gateleen.queue.expiry.ExpiryCheckHandler;
@@ -49,6 +50,7 @@ public class HookHandlerTest {
private HttpClient httpClient;
private MockResourceStorage storage;
private LoggingResourceManager loggingResourceManager;
+ private LogAppenderRepository logAppenderRepository;
private MonitoringHandler monitoringHandler;
private RequestQueue requestQueue;
private ReducedPropagationManager reducedPropagationManager;
@@ -66,12 +68,13 @@ public void setUp() {
Mockito.when(httpClient.request(any(HttpMethod.class), anyString())).thenReturn(Mockito.mock(Future.class));
storage = new MockResourceStorage();
loggingResourceManager = Mockito.mock(LoggingResourceManager.class);
+ logAppenderRepository = Mockito.mock(LogAppenderRepository.class);
monitoringHandler = Mockito.mock(MonitoringHandler.class);
requestQueue = Mockito.mock(RequestQueue.class);
reducedPropagationManager = Mockito.mock(ReducedPropagationManager.class);
- hookHandler = new HookHandler(vertx, httpClient, storage, loggingResourceManager, monitoringHandler,
+ hookHandler = new HookHandler(vertx, httpClient, storage, loggingResourceManager, logAppenderRepository, monitoringHandler,
"userProfilePath", HOOK_ROOT_URI, requestQueue, false, reducedPropagationManager);
hookHandler.init();
}
@@ -218,7 +221,7 @@ public boolean matches(Object argument) {
@Test
public void testListenerEnqueueWithReducedPropagationQueueingStrategyButNoManager(TestContext context) throws InterruptedException {
- hookHandler = new HookHandler(vertx, httpClient, storage, loggingResourceManager, monitoringHandler,
+ hookHandler = new HookHandler(vertx, httpClient, storage, loggingResourceManager, logAppenderRepository, monitoringHandler,
"userProfilePath", HOOK_ROOT_URI, requestQueue, false, null);
hookHandler.init();
diff --git a/gateleen-kafka/pom.xml b/gateleen-kafka/pom.xml
index b3a75eaf1..b87f15412 100644
--- a/gateleen-kafka/pom.xml
+++ b/gateleen-kafka/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-kafka
diff --git a/gateleen-logging/pom.xml b/gateleen-logging/pom.xml
index f437c9b76..90bb6650c 100644
--- a/gateleen-logging/pom.xml
+++ b/gateleen-logging/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-logging
diff --git a/gateleen-logging/src/main/java/org/swisspush/gateleen/logging/DefaultLogAppenderRepository.java b/gateleen-logging/src/main/java/org/swisspush/gateleen/logging/DefaultLogAppenderRepository.java
new file mode 100644
index 000000000..870edef97
--- /dev/null
+++ b/gateleen-logging/src/main/java/org/swisspush/gateleen/logging/DefaultLogAppenderRepository.java
@@ -0,0 +1,45 @@
+package org.swisspush.gateleen.logging;
+
+import io.vertx.core.Handler;
+import io.vertx.core.Vertx;
+import io.vertx.core.eventbus.Message;
+import org.apache.logging.log4j.core.Appender;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.swisspush.gateleen.logging.LoggingResourceManager.UPDATE_ADDRESS;
+
+/**
+ * Default implementation of the {@link LogAppenderRepository} caching the {@link Appender} instances in a {@link Map}
+ *
+ * @author https://github.com/mcweba [Marc-Andre Weber]
+ */
+public class DefaultLogAppenderRepository implements LogAppenderRepository {
+
+ private Map appenderMap = new HashMap<>();
+
+ public DefaultLogAppenderRepository(Vertx vertx) {
+ vertx.eventBus().consumer(UPDATE_ADDRESS, (Handler>) event -> clearRepository());
+ }
+
+ @Override
+ public boolean hasAppender(String name) {
+ return appenderMap.containsKey(name);
+ }
+
+ @Override
+ public void addAppender(String name, Appender appender) {
+ appenderMap.put(name, appender);
+ }
+
+ @Override
+ public Appender getAppender(String name) {
+ return appenderMap.get(name);
+ }
+
+ @Override
+ public void clearRepository() {
+ appenderMap.clear();
+ }
+}
diff --git a/gateleen-logging/src/main/java/org/swisspush/gateleen/logging/LogAppenderRepository.java b/gateleen-logging/src/main/java/org/swisspush/gateleen/logging/LogAppenderRepository.java
new file mode 100644
index 000000000..74ba1eb31
--- /dev/null
+++ b/gateleen-logging/src/main/java/org/swisspush/gateleen/logging/LogAppenderRepository.java
@@ -0,0 +1,20 @@
+package org.swisspush.gateleen.logging;
+
+import org.apache.logging.log4j.core.Appender;
+
+/**
+ * A repository holding {@link Appender} instances. The repository allows to reuse an appender
+ * instead of creating a new one for every log statement
+ *
+ * @author https://github.com/mcweba [Marc-Andre Weber]
+ */
+public interface LogAppenderRepository {
+
+ boolean hasAppender(String name);
+
+ void addAppender(String name, Appender appender);
+
+ Appender getAppender(String name);
+
+ void clearRepository();
+}
diff --git a/gateleen-logging/src/main/java/org/swisspush/gateleen/logging/LoggingHandler.java b/gateleen-logging/src/main/java/org/swisspush/gateleen/logging/LoggingHandler.java
index 372eff7d6..9b7ca5c9d 100755
--- a/gateleen-logging/src/main/java/org/swisspush/gateleen/logging/LoggingHandler.java
+++ b/gateleen-logging/src/main/java/org/swisspush/gateleen/logging/LoggingHandler.java
@@ -38,6 +38,7 @@ public class LoggingHandler {
private Buffer responsePayload;
private LoggingResource loggingResource;
private EventBus eventBus;
+ private LogAppenderRepository logAppenderRepository;
private String currentDestination;
@@ -64,11 +65,11 @@ public class LoggingHandler {
private static final String DEFAULT = "default";
private Map loggers = new HashMap<>();
- private Map appenders = new HashMap<>();
private Logger log;
- public LoggingHandler(LoggingResourceManager loggingResourceManager, HttpServerRequest request, EventBus eventBus) {
+ public LoggingHandler(LoggingResourceManager loggingResourceManager, LogAppenderRepository logAppenderRepository, HttpServerRequest request, EventBus eventBus) {
+ this.logAppenderRepository = logAppenderRepository;
this.request = request;
this.eventBus = eventBus;
this.loggingResource = loggingResourceManager.getLoggingResource();
@@ -187,7 +188,7 @@ private String createLoggerAndGetDestination(Map payloadFilter)
* @return
*/
private Appender getEventBusAppender(String filterDestination, Map destinationOptions) {
- if (!appenders.containsKey(filterDestination)) {
+ if (!logAppenderRepository.hasAppender(filterDestination)) {
/*
*
@@ -204,9 +205,9 @@ private Appender getEventBusAppender(String filterDestination, Map
@@ -242,10 +243,10 @@ private Appender getFileAppender(String filterDestination, String fileName) {
builder.withAppend(true);
PatternLayout layout = PatternLayout.createDefaultLayout();
builder.setLayout(layout);
- appenders.put(filterDestination, builder.build());
+ logAppenderRepository.addAppender(filterDestination, builder.build());
}
- return appenders.get(filterDestination);
+ return logAppenderRepository.getAppender(filterDestination);
}
public void setResponse(HttpClientResponse response) {
diff --git a/gateleen-logging/src/main/java/org/swisspush/gateleen/logging/LoggingResourceManager.java b/gateleen-logging/src/main/java/org/swisspush/gateleen/logging/LoggingResourceManager.java
index 15fd99ceb..452b84248 100755
--- a/gateleen-logging/src/main/java/org/swisspush/gateleen/logging/LoggingResourceManager.java
+++ b/gateleen-logging/src/main/java/org/swisspush/gateleen/logging/LoggingResourceManager.java
@@ -32,7 +32,7 @@
*/
public class LoggingResourceManager implements LoggableResource {
- private static final String UPDATE_ADDRESS = "gateleen.logging-updated";
+ static final String UPDATE_ADDRESS = "gateleen.logging-updated";
private final String loggingUri;
private final ResourceStorage storage;
diff --git a/gateleen-logging/src/main/java/org/swisspush/gateleen/logging/RequestLoggingConsumer.java b/gateleen-logging/src/main/java/org/swisspush/gateleen/logging/RequestLoggingConsumer.java
index d0966fa3a..a1bb6dfb0 100644
--- a/gateleen-logging/src/main/java/org/swisspush/gateleen/logging/RequestLoggingConsumer.java
+++ b/gateleen-logging/src/main/java/org/swisspush/gateleen/logging/RequestLoggingConsumer.java
@@ -24,10 +24,12 @@
public class RequestLoggingConsumer {
private final Vertx vertx;
private final LoggingResourceManager loggingResourceManager;
+ private final LogAppenderRepository logAppenderRepository;
- public RequestLoggingConsumer(Vertx vertx, LoggingResourceManager loggingResourceManager) {
+ public RequestLoggingConsumer(Vertx vertx, LoggingResourceManager loggingResourceManager, LogAppenderRepository logAppenderRepository) {
this.vertx = vertx;
this.loggingResourceManager = loggingResourceManager;
+ this.logAppenderRepository = logAppenderRepository;
vertx.eventBus().localConsumer(Address.requestLoggingConsumerAddress(), (Handler>) event -> {
try {
@@ -66,7 +68,7 @@ public RequestLoggingConsumer(Vertx vertx, LoggingResourceManager loggingResourc
* @param responseHeaders the response headers
*/
private void logRequest(final HttpServerRequest request, final int status, Buffer data, final MultiMap responseHeaders) {
- final LoggingHandler loggingHandler = new LoggingHandler(loggingResourceManager, request, vertx.eventBus());
+ final LoggingHandler loggingHandler = new LoggingHandler(loggingResourceManager, logAppenderRepository, request, vertx.eventBus());
if (HttpMethod.PUT == request.method() || HttpMethod.POST == request.method()) {
loggingHandler.appendRequestPayload(data);
} else if (HttpMethod.GET == request.method()) {
diff --git a/gateleen-logging/src/test/java/org/swisspush/gateleen/logging/DefaultLogAppenderRepositoryTest.java b/gateleen-logging/src/test/java/org/swisspush/gateleen/logging/DefaultLogAppenderRepositoryTest.java
new file mode 100644
index 000000000..a6c30c0e8
--- /dev/null
+++ b/gateleen-logging/src/test/java/org/swisspush/gateleen/logging/DefaultLogAppenderRepositoryTest.java
@@ -0,0 +1,72 @@
+package org.swisspush.gateleen.logging;
+
+import io.vertx.core.Vertx;
+import io.vertx.ext.unit.TestContext;
+import io.vertx.ext.unit.junit.VertxUnitRunner;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.appender.ConsoleAppender;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static com.jayway.awaitility.Awaitility.await;
+import static com.jayway.awaitility.Duration.TWO_SECONDS;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.swisspush.gateleen.logging.LoggingResourceManager.UPDATE_ADDRESS;
+
+/**
+ * Tests for the {@link DefaultLogAppenderRepository} class
+ *
+ * @author https://github.com/mcweba [Marc-Andre Weber]
+ */
+@RunWith(VertxUnitRunner.class)
+public class DefaultLogAppenderRepositoryTest {
+
+ private Vertx vertx;
+ private DefaultLogAppenderRepository repository;
+
+ @Before
+ public void setUp() {
+ vertx = Vertx.vertx();
+ repository = new DefaultLogAppenderRepository(vertx);
+ }
+
+ @Test
+ public void testAppenderNotInRepository(TestContext context) {
+ context.assertFalse(repository.hasAppender("my-appender"));
+ context.assertNull(repository.getAppender("my-appender"));
+ }
+
+ @Test
+ public void testAddAppender(TestContext context) {
+ context.assertFalse(repository.hasAppender("my-appender"));
+
+ Appender appender = new ConsoleAppender.Builder<>().setName("my-appender").build();
+ repository.addAppender("my-appender", appender);
+
+ context.assertTrue(repository.hasAppender("my-appender"));
+ context.assertNotNull(repository.getAppender("my-appender"));
+ }
+
+ @Test
+ public void testClearRepository(TestContext context) {
+ context.assertFalse(repository.hasAppender("my-appender"));
+ Appender appender = new ConsoleAppender.Builder<>().setName("my-appender").build();
+ repository.addAppender("my-appender", appender);
+ context.assertTrue(repository.hasAppender("my-appender"));
+ repository.clearRepository();
+ context.assertFalse(repository.hasAppender("my-appender"));
+ }
+
+ @Test
+ public void testClearRepositoryTriggeredByEventbus(TestContext context) {
+ context.assertFalse(repository.hasAppender("my-appender"));
+ Appender appender = new ConsoleAppender.Builder<>().setName("my-appender").build();
+ repository.addAppender("my-appender", appender);
+ context.assertTrue(repository.hasAppender("my-appender"));
+
+ vertx.eventBus().publish(UPDATE_ADDRESS, true);
+
+ await().atMost(TWO_SECONDS).until(() -> repository.hasAppender("my-appender"), equalTo(false));
+ }
+}
diff --git a/gateleen-logging/src/test/java/org/swisspush/gateleen/logging/LoggingHandlerTest.java b/gateleen-logging/src/test/java/org/swisspush/gateleen/logging/LoggingHandlerTest.java
index 9db672dcc..d5e8b8603 100644
--- a/gateleen-logging/src/test/java/org/swisspush/gateleen/logging/LoggingHandlerTest.java
+++ b/gateleen-logging/src/test/java/org/swisspush/gateleen/logging/LoggingHandlerTest.java
@@ -20,6 +20,9 @@
import java.util.List;
import java.util.Map;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+
/**
* Tests for the {@link LoggingHandler} class
*
@@ -30,21 +33,36 @@ public class LoggingHandlerTest {
private Vertx vertx;
private ResourceStorage storage;
-
+ private LogAppenderRepository logAppenderRepository;
private final String LOGGING_URI = "/playground/server/admin/v1/logging";
private final String GET_REQUEST_URI = "/playground/server/users/v1/test";
- private final String TEST_LOGGING_RESOURCE = ResourcesUtils.loadResource("testresource_logging_handler_test", true);
+ private final String TEST_LOGGING_RESOURCE = ResourcesUtils
+ .loadResource("testresource_logging_handler_test", true);
+ private final String TEST_LOGGING_RESOURCE_WITH_DESTINATION = ResourcesUtils
+ .loadResource("testresource_with_destination_logging_handler_test", true);
@Before
public void setUp() {
vertx = Mockito.mock(Vertx.class);
Mockito.when(vertx.eventBus()).thenReturn(Mockito.mock(EventBus.class));
- storage = new MockResourceStorage(ImmutableMap.of(LOGGING_URI, TEST_LOGGING_RESOURCE));
+ logAppenderRepository = Mockito.spy(new DefaultLogAppenderRepository(vertx));
+ }
+
+ @Test
+ public void testLoggingWithDestination(TestContext context) {
+ storage = new MockResourceStorage(ImmutableMap.of(LOGGING_URI, TEST_LOGGING_RESOURCE_WITH_DESTINATION));
+ LoggingResourceManager manager = new LoggingResourceManager(vertx, storage, LOGGING_URI);
+ GETRequest request = new GETRequest();
+ LoggingHandler loggingHandler = new LoggingHandler(manager, logAppenderRepository, request, vertx.eventBus());
+
+ context.assertTrue(loggingHandler.isActive());
+ Mockito.verify(logAppenderRepository, Mockito.times(1)).addAppender(eq("eventBusLog"), any(EventBusAppender.class));
}
@Test
public void testCustomSorting(TestContext context) {
+ storage = new MockResourceStorage(ImmutableMap.of(LOGGING_URI, TEST_LOGGING_RESOURCE));
LoggingResourceManager manager = new LoggingResourceManager(vertx, storage, LOGGING_URI);
LoggingResource loggingResource = manager.getLoggingResource();
@@ -58,7 +76,7 @@ public void testCustomSorting(TestContext context) {
GETRequest request = new GETRequest();
- LoggingHandler loggingHandler = new LoggingHandler(manager, request, vertx.eventBus());
+ LoggingHandler loggingHandler = new LoggingHandler(manager, logAppenderRepository, request, vertx.eventBus());
// Check whether "active" is set to TRUE, which means the Logging for the GET Request
// is happening and is not aborted (which was the case before the fix (NEMO-5551))
diff --git a/gateleen-logging/src/test/java/org/swisspush/gateleen/logging/LoggingResourceManagerTest.java b/gateleen-logging/src/test/java/org/swisspush/gateleen/logging/LoggingResourceManagerTest.java
index ae0248b6e..a50b9e3f5 100755
--- a/gateleen-logging/src/test/java/org/swisspush/gateleen/logging/LoggingResourceManagerTest.java
+++ b/gateleen-logging/src/test/java/org/swisspush/gateleen/logging/LoggingResourceManagerTest.java
@@ -48,7 +48,6 @@ public class LoggingResourceManagerTest {
private static final Logger logger = LoggerFactory.getLogger( LoggingResourceManagerTest.class );
private Vertx vertx;
private ResourceStorage storage;
-
private final String LOGGING_URI = "/playground/server/admin/v1/logging";
private final String INITIAL_LOGGING_RESOURCE = ResourcesUtils.loadResource("testresource_inital_logging_resource", true);
@@ -152,7 +151,7 @@ public HttpServerResponse response() {
public void invalidRegexGetsRejected( TestContext testContext ) {
// Wire up victim instance
final String loggingUrl = "/houston/server/admin/v1/logging";
- final LoggingResourceManager loggingResourceManager = new LoggingResourceManager( vertx , storage , loggingUrl );
+ final LoggingResourceManager loggingResourceManager = new LoggingResourceManager(vertx, storage, loggingUrl);
// Mock a request
final Integer[] responseStatusCode = new Integer[]{ null };
diff --git a/gateleen-logging/src/test/resources/testresource_with_destination_logging_handler_test b/gateleen-logging/src/test/resources/testresource_with_destination_logging_handler_test
new file mode 100644
index 000000000..41b36449a
--- /dev/null
+++ b/gateleen-logging/src/test/resources/testresource_with_destination_logging_handler_test
@@ -0,0 +1,25 @@
+{
+ "headers": [],
+ "payload": {
+ "destinations": [
+ {
+ "name" : "eventBusLog",
+ "type" : "eventBus",
+ "address" : "some_eventbus_address",
+ "metadata" : "meta 1",
+ "transmission": "send"
+ }
+ ],
+ "filters": [
+ {
+ "url": "/playground/nsa/v1/acknowledgment/.*",
+ "method": "GET",
+ "reject": "true"
+ },
+ {
+ "url": "/playground/server/users/v1/.*",
+ "destination": "eventBusLog"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/gateleen-merge/pom.xml b/gateleen-merge/pom.xml
index fbe96f859..fc1c9677d 100644
--- a/gateleen-merge/pom.xml
+++ b/gateleen-merge/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-merge
diff --git a/gateleen-monitoring/pom.xml b/gateleen-monitoring/pom.xml
index d0b883238..9ee9242f6 100644
--- a/gateleen-monitoring/pom.xml
+++ b/gateleen-monitoring/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-monitoring
diff --git a/gateleen-packing/pom.xml b/gateleen-packing/pom.xml
index 4c8d8ce2d..748fbbbbf 100644
--- a/gateleen-packing/pom.xml
+++ b/gateleen-packing/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-packing
diff --git a/gateleen-player/pom.xml b/gateleen-player/pom.xml
index b5f313b43..08199f54c 100644
--- a/gateleen-player/pom.xml
+++ b/gateleen-player/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-player
diff --git a/gateleen-playground/pom.xml b/gateleen-playground/pom.xml
index e2b0667e5..da797a45f 100644
--- a/gateleen-playground/pom.xml
+++ b/gateleen-playground/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-playground
diff --git a/gateleen-playground/src/main/java/org/swisspush/gateleen/playground/Server.java b/gateleen-playground/src/main/java/org/swisspush/gateleen/playground/Server.java
index 426357ec4..70dad222d 100755
--- a/gateleen-playground/src/main/java/org/swisspush/gateleen/playground/Server.java
+++ b/gateleen-playground/src/main/java/org/swisspush/gateleen/playground/Server.java
@@ -46,6 +46,8 @@
import org.swisspush.gateleen.kafka.KafkaMessageSender;
import org.swisspush.gateleen.kafka.KafkaMessageValidator;
import org.swisspush.gateleen.kafka.KafkaProducerRepository;
+import org.swisspush.gateleen.logging.DefaultLogAppenderRepository;
+import org.swisspush.gateleen.logging.LogAppenderRepository;
import org.swisspush.gateleen.logging.LogController;
import org.swisspush.gateleen.logging.LoggingResourceManager;
import org.swisspush.gateleen.monitoring.CustomRedisMonitor;
@@ -119,6 +121,7 @@ public class Server extends AbstractVerticle {
* Managers
*/
private LoggingResourceManager loggingResourceManager;
+ private LogAppenderRepository logAppenderRepository;
private ConfigurationResourceManager configurationResourceManager;
private ValidationResourceManager validationResourceManager;
private ValidationSchemaProvider validationSchemaProvider;
@@ -221,9 +224,11 @@ public void start() {
"channels/([^/]+).*", configurationResourceManager, SERVER_ROOT + "/admin/v1/hookconfig");
eventBusHandler.setEventbusBridgePingInterval(RunConfig.EVENTBUS_BRIDGE_PING_INTERVAL);
+ logAppenderRepository = new DefaultLogAppenderRepository(vertx);
loggingResourceManager = new LoggingResourceManager(vertx, storage, SERVER_ROOT + "/admin/v1/logging");
loggingResourceManager.enableResourceLogging(true);
+
ContentTypeConstraintRepository repository = new ContentTypeConstraintRepository();
contentTypeConstraintHandler = new ContentTypeConstraintHandler(configurationResourceManager, repository,
SERVER_ROOT + "/admin/v1/contentTypeConstraints",
@@ -244,9 +249,9 @@ public void start() {
queueClient, lock);
reducedPropagationManager.startExpiredQueueProcessing(5000);
- hookHandler = new HookHandler(vertx, selfClient, storage, loggingResourceManager, monitoringHandler,
- SERVER_ROOT + "/users/v1/%s/profile", SERVER_ROOT + "/hooks/v1/", queueClient,
- false, reducedPropagationManager);
+ hookHandler = new HookHandler(vertx, selfClient, storage, loggingResourceManager, logAppenderRepository,
+ monitoringHandler,SERVER_ROOT + "/users/v1/%s/profile",
+ SERVER_ROOT + "/hooks/v1/", queueClient,false, reducedPropagationManager);
hookHandler.enableResourceLogging(true);
authorizer = new Authorizer(vertx, storage, SERVER_ROOT + "/security/v1/", ROLE_PATTERN, ROLE_PREFIX, props);
@@ -287,6 +292,7 @@ public void start() {
.withInfo(info)
.withMonitoringHandler(monitoringHandler)
.withLoggingResourceManager(loggingResourceManager)
+ .withLogAppenderRepository(logAppenderRepository)
.withResourceLogging(true)
.withRoutingConfiguration(configurationResourceManager, SERVER_ROOT + "/admin/v1/routing/config")
.withHttpClientFactory(this::createHttpClientForRouter)
diff --git a/gateleen-qos/pom.xml b/gateleen-qos/pom.xml
index dbed480a7..2f722e5c3 100644
--- a/gateleen-qos/pom.xml
+++ b/gateleen-qos/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-qos
diff --git a/gateleen-queue/pom.xml b/gateleen-queue/pom.xml
index e1175cc44..d4ee1b6e6 100644
--- a/gateleen-queue/pom.xml
+++ b/gateleen-queue/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-queue
diff --git a/gateleen-routing/pom.xml b/gateleen-routing/pom.xml
index f6829aea1..631a3bbac 100644
--- a/gateleen-routing/pom.xml
+++ b/gateleen-routing/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-routing
diff --git a/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/AbstractForwarder.java b/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/AbstractForwarder.java
index 036a8c91d..b19927871 100644
--- a/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/AbstractForwarder.java
+++ b/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/AbstractForwarder.java
@@ -8,6 +8,7 @@
import org.swisspush.gateleen.core.util.HttpHeaderUtil;
import org.swisspush.gateleen.core.util.ResponseStatusCodeLogUtil;
import org.swisspush.gateleen.core.util.StatusCode;
+import org.swisspush.gateleen.logging.LogAppenderRepository;
import org.swisspush.gateleen.logging.LoggingResourceManager;
import org.swisspush.gateleen.monitoring.MonitoringHandler;
@@ -15,11 +16,13 @@ public abstract class AbstractForwarder implements Handler {
protected final Rule rule;
protected final LoggingResourceManager loggingResourceManager;
+ protected final LogAppenderRepository logAppenderRepository;
protected final MonitoringHandler monitoringHandler;
- public AbstractForwarder(Rule rule, LoggingResourceManager loggingResourceManager, MonitoringHandler monitoringHandler) {
+ public AbstractForwarder(Rule rule, LoggingResourceManager loggingResourceManager, LogAppenderRepository logAppenderRepository, MonitoringHandler monitoringHandler) {
this.rule = rule;
this.loggingResourceManager = loggingResourceManager;
+ this.logAppenderRepository = logAppenderRepository;
this.monitoringHandler = monitoringHandler;
}
diff --git a/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/Forwarder.java b/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/Forwarder.java
index 9d8469d19..ad38f4a4e 100755
--- a/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/Forwarder.java
+++ b/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/Forwarder.java
@@ -18,6 +18,7 @@
import org.swisspush.gateleen.core.util.ResponseStatusCodeLogUtil;
import org.swisspush.gateleen.core.util.StatusCode;
import org.swisspush.gateleen.core.util.StringUtils;
+import org.swisspush.gateleen.logging.LogAppenderRepository;
import org.swisspush.gateleen.logging.LoggingHandler;
import org.swisspush.gateleen.logging.LoggingResourceManager;
import org.swisspush.gateleen.logging.LoggingWriteStream;
@@ -46,6 +47,7 @@ public class Forwarder extends AbstractForwarder {
private int port;
private Rule rule;
private LoggingResourceManager loggingResourceManager;
+ private LogAppenderRepository logAppenderRepository;
private MonitoringHandler monitoringHandler;
private ResourceStorage storage;
@Nullable
@@ -64,13 +66,14 @@ public class Forwarder extends AbstractForwarder {
private static final Logger LOG = LoggerFactory.getLogger(Forwarder.class);
public Forwarder(Vertx vertx, HttpClient client, Rule rule, final ResourceStorage storage,
- LoggingResourceManager loggingResourceManager, MonitoringHandler monitoringHandler,
+ LoggingResourceManager loggingResourceManager, LogAppenderRepository logAppenderRepository, MonitoringHandler monitoringHandler,
String userProfilePath, @Nullable AuthStrategy authStrategy) {
- super(rule, loggingResourceManager, monitoringHandler);
+ super(rule, loggingResourceManager, logAppenderRepository, monitoringHandler);
this.vertx = vertx;
this.client = client;
this.rule = rule;
this.loggingResourceManager = loggingResourceManager;
+ this.logAppenderRepository = logAppenderRepository;
this.monitoringHandler = monitoringHandler;
this.storage = storage;
this.urlPattern = Pattern.compile(rule.getUrlPattern());
@@ -233,7 +236,7 @@ String applyHeaderFunctions(final Logger log, MultiMap headers) {
private void handleRequest(final HttpServerRequest req, final Buffer bodyData, final String targetUri,
final Logger log, final Map profileHeaderMap,
Optional authHeader, @Nullable final Handler afterHandler) {
- final LoggingHandler loggingHandler = new LoggingHandler(loggingResourceManager, req, vertx.eventBus());
+ final LoggingHandler loggingHandler = new LoggingHandler(loggingResourceManager, logAppenderRepository, req, vertx.eventBus());
final String uniqueId = req.headers().get("x-rp-unique_id");
final String timeout = req.headers().get("x-timeout");
diff --git a/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/NullForwarder.java b/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/NullForwarder.java
index 1d9cc3f16..8d1b8fb48 100755
--- a/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/NullForwarder.java
+++ b/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/NullForwarder.java
@@ -12,6 +12,7 @@
import org.swisspush.gateleen.core.http.HttpRequest;
import org.swisspush.gateleen.core.http.RequestLoggerFactory;
import org.swisspush.gateleen.core.util.StatusCode;
+import org.swisspush.gateleen.logging.LogAppenderRepository;
import org.swisspush.gateleen.logging.LoggingHandler;
import org.swisspush.gateleen.logging.LoggingResourceManager;
import org.swisspush.gateleen.monitoring.MonitoringHandler;
@@ -25,8 +26,8 @@ public class NullForwarder extends AbstractForwarder {
private EventBus eventBus;
- public NullForwarder(Rule rule, LoggingResourceManager loggingResourceManager, MonitoringHandler monitoringHandler, EventBus eventBus) {
- super(rule, loggingResourceManager, monitoringHandler);
+ public NullForwarder(Rule rule, LoggingResourceManager loggingResourceManager, LogAppenderRepository logAppenderRepository, MonitoringHandler monitoringHandler, EventBus eventBus) {
+ super(rule, loggingResourceManager, logAppenderRepository, monitoringHandler);
this.eventBus = eventBus;
}
@@ -40,7 +41,7 @@ public void handle(final RoutingContext ctx) {
}
monitoringHandler.updateRequestPerRuleMonitoring(ctx.request(), rule.getMetricName());
- final LoggingHandler loggingHandler = new LoggingHandler(loggingResourceManager, ctx.request(), eventBus);
+ final LoggingHandler loggingHandler = new LoggingHandler(loggingResourceManager, logAppenderRepository, ctx.request(), eventBus);
log.debug("Not forwarding request: {} with rule {}", ctx.request().uri(), rule.getRuleIdentifier());
final HeadersMultiMap requestHeaders = new HeadersMultiMap();
requestHeaders.addAll(ctx.request().headers());
diff --git a/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/Router.java b/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/Router.java
index 116e5ce9e..2ff24a333 100755
--- a/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/Router.java
+++ b/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/Router.java
@@ -22,6 +22,7 @@
import org.swisspush.gateleen.core.refresh.Refreshable;
import org.swisspush.gateleen.core.storage.ResourceStorage;
import org.swisspush.gateleen.core.util.*;
+import org.swisspush.gateleen.logging.LogAppenderRepository;
import org.swisspush.gateleen.logging.LoggingResourceManager;
import org.swisspush.gateleen.monitoring.MonitoringHandler;
import org.swisspush.gateleen.routing.auth.AuthStrategy;
@@ -57,6 +58,7 @@ public class Router implements Refreshable, LoggableResource, ConfigurationResou
private final String serverUri;
private io.vertx.ext.web.Router router;
private final LoggingResourceManager loggingResourceManager;
+ private final LogAppenderRepository logAppenderRepository;
private final MonitoringHandler monitoringHandler;
private final Logger log = LoggerFactory.getLogger(Router.class);
private final Logger cleanupLogger = LoggerFactory.getLogger(Router.class.getName() + "Cleanup");
@@ -103,6 +105,7 @@ public static RouterBuilder builder() {
final ResourceStorage storage,
final Map properties,
LoggingResourceManager loggingResourceManager,
+ LogAppenderRepository logAppenderRepository,
MonitoringHandler monitoringHandler,
HttpClient selfClient,
String serverPath,
@@ -118,6 +121,7 @@ public static RouterBuilder builder() {
this.storage = storage;
this.properties = properties;
this.loggingResourceManager = loggingResourceManager;
+ this.logAppenderRepository = logAppenderRepository;
this.monitoringHandler = monitoringHandler;
this.selfClient = selfClient;
this.vertx = vertx;
@@ -316,14 +320,18 @@ private void createForwarders(List rules, io.vertx.ext.web.Router newRoute
AuthStrategy authStrategy = selectAuthStrategy(rule);
Handler forwarder;
if (rule.getPath() == null) {
- forwarder = new NullForwarder(rule, loggingResourceManager, monitoringHandler, vertx.eventBus());
+ forwarder = new NullForwarder(rule, loggingResourceManager, logAppenderRepository, monitoringHandler,
+ vertx.eventBus());
} else if (rule.getStorage() != null) {
- forwarder = new StorageForwarder(vertx.eventBus(), rule, loggingResourceManager, monitoringHandler);
+ forwarder = new StorageForwarder(vertx.eventBus(), rule, loggingResourceManager, logAppenderRepository,
+ monitoringHandler);
} else if (rule.getScheme().equals("local")) {
- forwarder = new Forwarder(vertx, selfClient, rule, this.storage, loggingResourceManager, monitoringHandler, userProfileUri, authStrategy);
+ forwarder = new Forwarder(vertx, selfClient, rule, this.storage, loggingResourceManager, logAppenderRepository,
+ monitoringHandler, userProfileUri, authStrategy);
} else {
HttpClient client = httpClientFactory.createHttpClient(rule.buildHttpClientOptions());
- forwarder = new Forwarder(vertx, client, rule, this.storage, loggingResourceManager, monitoringHandler, userProfileUri, authStrategy);
+ forwarder = new Forwarder(vertx, client, rule, this.storage, loggingResourceManager, logAppenderRepository,
+ monitoringHandler, userProfileUri, authStrategy);
newClients.add(client);
}
diff --git a/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/RouterBuilder.java b/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/RouterBuilder.java
index 30ee39bc6..6db535ed9 100644
--- a/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/RouterBuilder.java
+++ b/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/RouterBuilder.java
@@ -9,6 +9,7 @@
import org.swisspush.gateleen.core.configuration.ConfigurationResourceManager;
import org.swisspush.gateleen.core.http.HttpClientFactory;
import org.swisspush.gateleen.core.storage.ResourceStorage;
+import org.swisspush.gateleen.logging.LogAppenderRepository;
import org.swisspush.gateleen.logging.LoggingResourceManager;
import org.swisspush.gateleen.monitoring.MonitoringHandler;
import org.swisspush.gateleen.routing.auth.OAuthProvider;
@@ -33,6 +34,7 @@ public class RouterBuilder {
private ResourceStorage storage;
private Map properties;
private LoggingResourceManager loggingResourceManager;
+ private LogAppenderRepository logAppenderRepository;
private MonitoringHandler monitoringHandler;
private HttpClient selfClient;
private String serverPath;
@@ -88,6 +90,7 @@ public Router build() {
storage,
properties,
loggingResourceManager,
+ logAppenderRepository,
monitoringHandler,
selfClient,
serverPath,
@@ -161,6 +164,12 @@ public RouterBuilder withLoggingResourceManager(LoggingResourceManager loggingRe
return this;
}
+ public RouterBuilder withLogAppenderRepository(LogAppenderRepository logAppenderRepository) {
+ ensureNotBuilt();
+ this.logAppenderRepository = logAppenderRepository;
+ return this;
+ }
+
public RouterBuilder withMonitoringHandler(MonitoringHandler monitoringHandler) {
ensureNotBuilt();
this.monitoringHandler = monitoringHandler;
diff --git a/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/StorageForwarder.java b/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/StorageForwarder.java
index 2d3497f71..a53a6a0f9 100755
--- a/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/StorageForwarder.java
+++ b/gateleen-routing/src/main/java/org/swisspush/gateleen/routing/StorageForwarder.java
@@ -22,6 +22,7 @@
import org.swisspush.gateleen.core.util.Address;
import org.swisspush.gateleen.core.util.ResponseStatusCodeLogUtil;
import org.swisspush.gateleen.core.util.StatusCode;
+import org.swisspush.gateleen.logging.LogAppenderRepository;
import org.swisspush.gateleen.logging.LoggingHandler;
import org.swisspush.gateleen.logging.LoggingResourceManager;
import org.swisspush.gateleen.monitoring.MonitoringHandler;
@@ -40,8 +41,8 @@ public class StorageForwarder extends AbstractForwarder {
private String address;
private CORSHandler corsHandler;
- public StorageForwarder(EventBus eventBus, Rule rule, LoggingResourceManager loggingResourceManager, MonitoringHandler monitoringHandler) {
- super(rule, loggingResourceManager, monitoringHandler);
+ public StorageForwarder(EventBus eventBus, Rule rule, LoggingResourceManager loggingResourceManager, LogAppenderRepository logAppenderRepository, MonitoringHandler monitoringHandler) {
+ super(rule, loggingResourceManager, logAppenderRepository, monitoringHandler);
this.eventBus = eventBus;
this.address = Address.storageAddress() + "-" + rule.getStorage();
urlPattern = Pattern.compile(rule.getUrlPattern());
@@ -50,7 +51,7 @@ public StorageForwarder(EventBus eventBus, Rule rule, LoggingResourceManager log
@Override
public void handle(final RoutingContext ctx) {
- final LoggingHandler loggingHandler = new LoggingHandler(loggingResourceManager, ctx.request(), this.eventBus);
+ final LoggingHandler loggingHandler = new LoggingHandler(loggingResourceManager, logAppenderRepository, ctx.request(), this.eventBus);
final String targetUri = urlPattern.matcher(ctx.request().uri()).replaceAll(rule.getPath()).replaceAll("\\/\\/", "/");
final Logger log = RequestLoggerFactory.getLogger(StorageForwarder.class, ctx.request());
diff --git a/gateleen-routing/src/test/java/org/swisspush/gateleen/routing/ForwarderTest.java b/gateleen-routing/src/test/java/org/swisspush/gateleen/routing/ForwarderTest.java
index 2ae714280..42222e58a 100644
--- a/gateleen-routing/src/test/java/org/swisspush/gateleen/routing/ForwarderTest.java
+++ b/gateleen-routing/src/test/java/org/swisspush/gateleen/routing/ForwarderTest.java
@@ -20,6 +20,7 @@
import org.swisspush.gateleen.core.http.HeaderFunctions;
import org.swisspush.gateleen.core.storage.MockResourceStorage;
import org.swisspush.gateleen.core.storage.ResourceStorage;
+import org.swisspush.gateleen.logging.LogAppenderRepository;
import org.swisspush.gateleen.logging.LoggingResourceManager;
import org.swisspush.gateleen.monitoring.MonitoringHandler;
@@ -31,6 +32,7 @@ public class ForwarderTest {
private Vertx vertx;
private LoggingResourceManager loggingResourceManager;
+ private LogAppenderRepository logAppenderRepository;
private MonitoringHandler monitoringHandler;
private HttpClient httpClient;
private ResourceStorage storage;
@@ -77,6 +79,7 @@ private static Rule extractRule(String rulePattern) {
public void setUp() {
vertx = Mockito.mock(Vertx.class);
loggingResourceManager = Mockito.mock(LoggingResourceManager.class);
+ logAppenderRepository = Mockito.mock(LogAppenderRepository.class);
monitoringHandler = Mockito.mock(MonitoringHandler.class);
httpClient = Mockito.mock(HttpClient.class);
storage = new MockResourceStorage(ImmutableMap.of(RULES_PATH, RULES));
@@ -86,7 +89,7 @@ public void setUp() {
@Test
public void testHeaderFunctionsGivenHostUpdatedByConfiguredRuleHostHeader() {
Rule rule = extractRule("/ruleWithHostHeader");
- Forwarder forwarder = new Forwarder(vertx, httpClient, rule, storage, loggingResourceManager,
+ Forwarder forwarder = new Forwarder(vertx, httpClient, rule, storage, loggingResourceManager, logAppenderRepository,
monitoringHandler, USER_PROFILE_PATH, null);
MultiMap reqHeaders = new HeadersMultiMap();
reqHeaders.add(HOST_HEADER, HOST_OLD);
@@ -98,7 +101,7 @@ public void testHeaderFunctionsGivenHostUpdatedByConfiguredRuleHostHeader() {
@Test
public void testHeaderFunctionsDefaultHostHeaderUpdatedByConfiguredRuleHostHeader() {
Rule rule = extractRule("/ruleWithHostHeader");
- Forwarder forwarder = new Forwarder(vertx, httpClient, rule, storage, loggingResourceManager,
+ Forwarder forwarder = new Forwarder(vertx, httpClient, rule, storage, loggingResourceManager, logAppenderRepository,
monitoringHandler, USER_PROFILE_PATH, null);
MultiMap reqHeaders = new HeadersMultiMap();
reqHeaders.add(HOST_HEADER, HOST_DEFAULT);
@@ -119,7 +122,7 @@ public void testHeaderFunctionsDefaultHostHeaderUpdatedByConfiguredRuleHostHeade
@Test
public void testHeaderFunctionsGivenHostHeaderUpdatedToDefaultHostHeaderWhenEqualToConfiguredRuleHostHeader() {
Rule rule = extractRule("/ruleWithHostHeader");
- Forwarder forwarder = new Forwarder(vertx, httpClient, rule, storage, loggingResourceManager,
+ Forwarder forwarder = new Forwarder(vertx, httpClient, rule, storage, loggingResourceManager, logAppenderRepository,
monitoringHandler, USER_PROFILE_PATH, null);
MultiMap reqHeaders = new HeadersMultiMap();
reqHeaders.add(HOST_HEADER, HOST_NEW);
@@ -131,7 +134,7 @@ public void testHeaderFunctionsGivenHostHeaderUpdatedToDefaultHostHeaderWhenEqua
@Test
public void testHeaderFunctionsGivenHostHeaderUpdatedByDefaultHostHeaderWhenNoConfiguredRuleHostHeader() {
Rule rule = extractRule("/ruleWithoutHeader");
- Forwarder forwarder = new Forwarder(vertx, httpClient, rule, storage, loggingResourceManager,
+ Forwarder forwarder = new Forwarder(vertx, httpClient, rule, storage, loggingResourceManager, logAppenderRepository,
monitoringHandler, USER_PROFILE_PATH, null);
MultiMap reqHeaders = new HeadersMultiMap();
reqHeaders.add(HOST_HEADER, HOST_OLD);
@@ -143,7 +146,7 @@ public void testHeaderFunctionsGivenHostHeaderUpdatedByDefaultHostHeaderWhenNoCo
@Test
public void testHeaderFunctionsGivenDefaultHostHeaderRemainsWhenNoConfiguredRuleHostHeader() {
Rule rule = extractRule("/ruleWithoutHeader");
- Forwarder forwarder = new Forwarder(vertx, httpClient, rule, storage, loggingResourceManager,
+ Forwarder forwarder = new Forwarder(vertx, httpClient, rule, storage, loggingResourceManager, logAppenderRepository,
monitoringHandler, USER_PROFILE_PATH, null);
MultiMap reqHeaders = new HeadersMultiMap();
reqHeaders.add(HOST_HEADER, HOST_DEFAULT);
diff --git a/gateleen-runconfig/pom.xml b/gateleen-runconfig/pom.xml
index a50672a77..ea2e2b941 100644
--- a/gateleen-runconfig/pom.xml
+++ b/gateleen-runconfig/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-runconfig
diff --git a/gateleen-scheduler/pom.xml b/gateleen-scheduler/pom.xml
index 0a97209dd..fca23c166 100644
--- a/gateleen-scheduler/pom.xml
+++ b/gateleen-scheduler/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-scheduler
diff --git a/gateleen-security/pom.xml b/gateleen-security/pom.xml
index 7489d13fe..2c588e337 100644
--- a/gateleen-security/pom.xml
+++ b/gateleen-security/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-security
diff --git a/gateleen-test/pom.xml b/gateleen-test/pom.xml
index e85e73d61..a3ae749a1 100644
--- a/gateleen-test/pom.xml
+++ b/gateleen-test/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-test
jar
diff --git a/gateleen-test/src/test/java/org/swisspush/gateleen/AbstractTest.java b/gateleen-test/src/test/java/org/swisspush/gateleen/AbstractTest.java
index 93a3562fd..334549dff 100755
--- a/gateleen-test/src/test/java/org/swisspush/gateleen/AbstractTest.java
+++ b/gateleen-test/src/test/java/org/swisspush/gateleen/AbstractTest.java
@@ -44,6 +44,8 @@
import org.swisspush.gateleen.hook.HookHandler;
import org.swisspush.gateleen.hook.reducedpropagation.ReducedPropagationManager;
import org.swisspush.gateleen.hook.reducedpropagation.impl.RedisReducedPropagationStorage;
+import org.swisspush.gateleen.logging.DefaultLogAppenderRepository;
+import org.swisspush.gateleen.logging.LogAppenderRepository;
import org.swisspush.gateleen.logging.LogController;
import org.swisspush.gateleen.logging.LoggingResourceManager;
import org.swisspush.gateleen.merge.MergeHandler;
@@ -152,11 +154,15 @@ public static void setupBeforeClass(TestContext context) {
ConfigurationResourceManager configurationResourceManager = new ConfigurationResourceManager(vertx, storage);
String eventBusConfigurationResource = SERVER_ROOT + "/admin/v1/hookconfig";
- EventBusHandler eventBusHandler = new EventBusHandler(vertx, SERVER_ROOT + "/event/v1/", SERVER_ROOT + "/event/v1/sock/", "event-", "channels/([^/]+).*", configurationResourceManager, eventBusConfigurationResource);
+ EventBusHandler eventBusHandler = new EventBusHandler(vertx, SERVER_ROOT + "/event/v1/",
+ SERVER_ROOT + "/event/v1/sock/", "event-",
+ "channels/([^/]+).*", configurationResourceManager, eventBusConfigurationResource);
eventBusHandler.setEventbusBridgePingInterval(RunConfig.EVENTBUS_BRIDGE_PING_INTERVAL);
- LoggingResourceManager loggingResourceManager = new LoggingResourceManager(vertx, storage, SERVER_ROOT + "/admin/v1/logging");
+ LogAppenderRepository logAppenderRepository = new DefaultLogAppenderRepository(vertx);
+ LoggingResourceManager loggingResourceManager = new LoggingResourceManager(vertx, storage,
+ SERVER_ROOT + "/admin/v1/logging");
UserProfileHandler userProfileHandler = new UserProfileHandler(vertx, storage, RunConfig.buildUserProfileConfiguration());
RoleProfileHandler roleProfileHandler = new RoleProfileHandler(vertx, storage, SERVER_ROOT + "/roles/v1/([^/]+)/profile");
qosHandler = new QoSHandler(vertx, storage, SERVER_ROOT + "/admin/v1/qos", props, PREFIX);
@@ -164,18 +170,22 @@ public static void setupBeforeClass(TestContext context) {
Lock lock = new RedisBasedLock(redisProvider);
QueueClient queueClient = new QueueClient(vertx, monitoringHandler);
- ReducedPropagationManager reducedPropagationManager = new ReducedPropagationManager(vertx, new RedisReducedPropagationStorage(redisProvider), queueClient, lock);
+ ReducedPropagationManager reducedPropagationManager = new ReducedPropagationManager(vertx,
+ new RedisReducedPropagationStorage(redisProvider), queueClient, lock);
reducedPropagationManager.startExpiredQueueProcessing(1000);
- hookHandler = new HookHandler(vertx, selfClient, storage, loggingResourceManager, monitoringHandler,
- SERVER_ROOT + "/users/v1/%s/profile", ROOT + "/server/hooks/v1/", queueClient, false, reducedPropagationManager);
+ hookHandler = new HookHandler(vertx, selfClient, storage, loggingResourceManager, logAppenderRepository, monitoringHandler,
+ SERVER_ROOT + "/users/v1/%s/profile", ROOT + "/server/hooks/v1/",
+ queueClient, false, reducedPropagationManager);
propertyHandler = new PropertyHandler(ROOT, props);
- schedulerResourceManager = new SchedulerResourceManager(vertx, redisProvider, storage, monitoringHandler, SERVER_ROOT + "/admin/v1/schedulers");
+ schedulerResourceManager = new SchedulerResourceManager(vertx, redisProvider, storage, monitoringHandler,
+ SERVER_ROOT + "/admin/v1/schedulers");
ResetMetricsController resetMetricsController = new ResetMetricsController(vertx);
resetMetricsController.registerResetMetricsControlMBean(JMX_DOMAIN, PREFIX);
LogController logController = new LogController();
logController.registerLogConfiguratorMBean(JMX_DOMAIN);
ZipExtractHandler zipExtractHandler = new ZipExtractHandler(selfClient);
- DelegateHandler delegateHandler = new DelegateHandler(vertx, selfClient, storage, monitoringHandler, DELEGATE_ROOT, props, null);
+ DelegateHandler delegateHandler = new DelegateHandler(vertx, selfClient, storage, monitoringHandler,
+ DELEGATE_ROOT, props, null);
MergeHandler mergeHandler = new MergeHandler(selfClient);
cacheHandler = new CacheHandler(
@@ -187,19 +197,22 @@ public static void setupBeforeClass(TestContext context) {
// ------
RuleProvider ruleProvider = new RuleProvider(vertx, RULES_ROOT, storage, props);
- QueueCircuitBreakerRulePatternToCircuitMapping rulePatternToCircuitMapping = new QueueCircuitBreakerRulePatternToCircuitMapping();
+ QueueCircuitBreakerRulePatternToCircuitMapping rulePatternToCircuitMapping =
+ new QueueCircuitBreakerRulePatternToCircuitMapping();
- QueueCircuitBreakerConfigurationResourceManager queueCircuitBreakerConfigurationResourceManager = new QueueCircuitBreakerConfigurationResourceManager(vertx, storage, SERVER_ROOT + "/admin/v1/circuitbreaker");
+ QueueCircuitBreakerConfigurationResourceManager queueCircuitBreakerConfigurationResourceManager =
+ new QueueCircuitBreakerConfigurationResourceManager(vertx, storage, SERVER_ROOT + "/admin/v1/circuitbreaker");
QueueCircuitBreakerStorage queueCircuitBreakerStorage = new RedisQueueCircuitBreakerStorage(redisProvider);
- QueueCircuitBreakerHttpRequestHandler requestHandler = new QueueCircuitBreakerHttpRequestHandler(vertx, queueCircuitBreakerStorage,
- SERVER_ROOT + "/queuecircuitbreaker/circuit");
+ QueueCircuitBreakerHttpRequestHandler requestHandler = new QueueCircuitBreakerHttpRequestHandler(vertx,
+ queueCircuitBreakerStorage,SERVER_ROOT + "/queuecircuitbreaker/circuit");
QueueCircuitBreaker queueCircuitBreaker = new QueueCircuitBreakerImpl(vertx, lock,
Address.redisquesAddress(), queueCircuitBreakerStorage, ruleProvider, rulePatternToCircuitMapping,
queueCircuitBreakerConfigurationResourceManager, requestHandler, CIRCUIT_BREAKER_REST_API_PORT);
new QueueProcessor(vertx, selfClient, monitoringHandler, queueCircuitBreaker);
- final QueueBrowser queueBrowser = new QueueBrowser(vertx, SERVER_ROOT + "/queuing", Address.redisquesAddress(), monitoringHandler);
+ final QueueBrowser queueBrowser = new QueueBrowser(vertx, SERVER_ROOT + "/queuing",
+ Address.redisquesAddress(), monitoringHandler);
new CustomRedisMonitor(vertx, redisProvider, "main", "rest-storage", 10).start();
Router router = Router.builder()
diff --git a/gateleen-testhelper/pom.xml b/gateleen-testhelper/pom.xml
index 7d14dae23..20c8ab7d5 100644
--- a/gateleen-testhelper/pom.xml
+++ b/gateleen-testhelper/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-testhelper
diff --git a/gateleen-user/pom.xml b/gateleen-user/pom.xml
index 61183eb0a..3b080a704 100644
--- a/gateleen-user/pom.xml
+++ b/gateleen-user/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-user
diff --git a/gateleen-validation/pom.xml b/gateleen-validation/pom.xml
index 3d1048040..787aff883 100644
--- a/gateleen-validation/pom.xml
+++ b/gateleen-validation/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
gateleen-validation
diff --git a/pom.xml b/pom.xml
index c42c9890c..a79221d3b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
org.swisspush.gateleen
gateleen
- 2.0.2-SNAPSHOT
+ 2.0.3-SNAPSHOT
pom
gateleen
Middleware library based on Vert.x to build advanced JSON/REST communication servers