Skip to content

Commit

Permalink
merged develop in feature/550_queue_splitter
Browse files Browse the repository at this point in the history
  • Loading branch information
zorba71 committed Jan 25, 2024
2 parents 12b48f1 + 7a1d526 commit 57c3987
Show file tree
Hide file tree
Showing 138 changed files with 946 additions and 675 deletions.
2 changes: 1 addition & 1 deletion gateleen-cache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.0.4-SNAPSHOT</version>
<version>2.1.1-SNAPSHOT</version>
</parent>

<artifactId>gateleen-cache</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ public Future<Result<Buffer, StatusCode>> fetchData(final String requestUri, Hea
promise.complete(Result.err(StatusCode.INTERNAL_SERVER_ERROR));
}).onComplete(event -> {
if (event.failed()) {
log.warn("Failed request to {}: {}", requestUri, event.cause());
log.warn("Failed request to {}", requestUri, event.cause());
return;
}
HttpClientRequest cReq = event.result();
cReq.setTimeout(requestTimeoutMs);
cReq.idleTimeout(requestTimeoutMs);
cReq.headers().setAll(requestHeaders);
cReq.headers().set("Accept", "application/json");
cReq.headers().set(SELF_REQUEST_HEADER, "true");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void exec(int executionCounter) {
String message = event.cause().getMessage();
if (message != null && message.startsWith("NOSCRIPT")) {
log.warn("CacheRequestRedisCommand script couldn't be found, reload it");
log.warn("amount the script got loaded: " + executionCounter);
log.warn("amount the script got loaded: {}", executionCounter);
if (executionCounter > 10) {
promise.fail("amount the script got loaded is higher than 10, we abort");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void exec(int executionCounter) {
String message = event.cause().getMessage();
if (message != null && message.startsWith("NOSCRIPT")) {
log.warn("ClearCacheRedisCommand script couldn't be found, reload it");
log.warn("amount the script got loaded: " + executionCounter);
log.warn("amount the script got loaded: {}", executionCounter);
if (executionCounter > 10) {
promise.fail("amount the script got loaded is higher than 10, we abort");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void testNotSupportedCacheControlHeadersAreNotHandled(TestContext context
Request cacheControlMaxAgeZero = new Request(HttpMethod.GET, "/some/path", headers, response);
context.assertFalse(cacheHandler.handle(cacheControlMaxAgeZero));

Mockito.verifyZeroInteractions(response);
Mockito.verifyNoInteractions(response);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.JsonObject;
import io.vertx.core.net.NetClientOptions;
import io.vertx.core.tracing.TracingPolicy;
import io.vertx.ext.unit.Async;
import io.vertx.ext.unit.TestContext;
import io.vertx.ext.unit.junit.Timeout;
import io.vertx.ext.unit.junit.VertxUnitRunner;
import io.vertx.redis.client.PoolOptions;
import io.vertx.redis.client.RedisAPI;
import io.vertx.redis.client.RedisOptions;
import io.vertx.redis.client.RedisStandaloneConnectOptions;
import io.vertx.redis.client.impl.RedisClient;
import org.hamcrest.core.IsEqual;
import org.junit.After;
Expand All @@ -27,11 +30,11 @@
import java.util.Set;
import java.util.concurrent.TimeUnit;

import static com.jayway.awaitility.Awaitility.await;
import static org.awaitility.Awaitility.await;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyString;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.swisspush.gateleen.cache.storage.RedisCacheStorage.CACHED_REQUESTS;
import static org.swisspush.gateleen.cache.storage.RedisCacheStorage.CACHE_PREFIX;

Expand Down Expand Up @@ -59,7 +62,8 @@ public void setUp() {
Mockito.when(lock.acquireLock(anyString(), anyString(), anyLong())).thenReturn(Future.succeededFuture(Boolean.TRUE));
Mockito.when(lock.releaseLock(anyString(), anyString())).thenReturn(Future.succeededFuture(Boolean.TRUE));

RedisAPI redisAPI = RedisAPI.api(new RedisClient(vertx, new RedisOptions()));
RedisAPI redisAPI = RedisAPI.api(new RedisClient(vertx, new NetClientOptions(), new PoolOptions(),
new RedisStandaloneConnectOptions(), TracingPolicy.IGNORE));

redisCacheStorage = new RedisCacheStorage(vertx, lock, () -> Future.succeededFuture(redisAPI), 2000);
jedis = new Jedis(new HostAndPort("localhost", 6379));
Expand Down
2 changes: 1 addition & 1 deletion gateleen-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.swisspush.gateleen</groupId>
<artifactId>gateleen</artifactId>
<version>2.0.4-SNAPSHOT</version>
<version>2.1.1-SNAPSHOT</version>
</parent>

<artifactId>gateleen-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.vertx.core.Promise;
import io.vertx.core.Vertx;
import io.vertx.core.http.*;
import io.vertx.core.net.SSLOptions;

import java.util.List;
import java.util.function.Function;
Expand Down Expand Up @@ -165,4 +166,9 @@ public Future<WebSocket> webSocketAbs(String s, MultiMap multiMap, WebsocketVers
public boolean isMetricsEnabled() {
throw new UnsupportedOperationException();
}

@Override
public Future<Boolean> updateSSLOptions(SSLOptions options, boolean force) {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Future<HttpClientRequest> createClientRequest(HttpMethod method, String r
}
delegateRequest.headers().setAll(headers);
delegateRequest.exceptionHandler(exceptionHandler);
delegateRequest.setTimeout(timeoutMs); // avoids blocking other requests
delegateRequest.idleTimeout(timeoutMs); // avoids blocking other requests
promise.complete(delegateRequest);
});
return promise.future();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,79 @@
package org.swisspush.gateleen.core.http;

import io.netty.handler.codec.http.QueryStringDecoder;
import io.vertx.codegen.annotations.Nullable;
import io.vertx.core.MultiMap;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.http.impl.headers.HeadersMultiMap;
import io.vertx.core.net.HostAndPort;

import javax.net.ssl.SSLPeerUnverifiedException;
import javax.security.cert.X509Certificate;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import java.util.Objects;


/**
* Dummy class implementing {@link HttpServerRequest}. Override this class for your needs.
*
* @author https://github.com/mcweba [Marc-Andre Weber]
*/
public class DummyHttpServerRequest implements FastFailHttpServerRequest {
public class DummyHttpServerRequest extends FastFailHttpServerRequest {

private Charset paramsCharset = StandardCharsets.UTF_8;
private MultiMap params;

@Override public boolean isSSL() { return false; }

@Override
public @Nullable HostAndPort authority() {
return null;
}

@Override
public String getHeader(String headerName) {
return null;
}

@Override
public HttpServerRequest setParamsCharset(String charset) {
Objects.requireNonNull(charset, "Charset must not be null");
Charset current = paramsCharset;
paramsCharset = Charset.forName(charset);
if (!paramsCharset.equals(current)) {
params = null;
}
return this;
}

@Override
public String getParamsCharset() {
return paramsCharset.name();
}

@Override
public MultiMap params() {
if (params == null) {
QueryStringDecoder queryStringDecoder = new QueryStringDecoder(uri(), paramsCharset);
Map<String, List<String>> prms = queryStringDecoder.parameters();
params = new HeadersMultiMap();
if (!prms.isEmpty()) {
for (Map.Entry<String, List<String>> entry : prms.entrySet()) {
params.add(entry.getKey(), entry.getValue());
}
}
}
return params;
}

@Override
public String getParam(String paramName) {
return params.get(paramName);
}

@Override public X509Certificate[] peerCertificateChain() throws SSLPeerUnverifiedException {
return new X509Certificate[0];
}
Expand Down
Loading

0 comments on commit 57c3987

Please sign in to comment.