Handle 429 error Too Many Requests 13/121713/1
authorPawel <pawel.kasperkiewicz@nokia.com>
Mon, 7 Jun 2021 08:46:00 +0000 (10:46 +0200)
committerPawel <pawel.kasperkiewicz@nokia.com>
Mon, 7 Jun 2021 08:46:00 +0000 (10:46 +0200)
Issue-ID: DCAEGEN2-2827
Signed-off-by: Pawel <pawel.kasperkiewicz@nokia.com>
Change-Id: Iedfb6572f008876b52a102948aeb640d27e51314

33 files changed:
Changelog.md
pom.xml
rest-services/cbs-client/pom.xml
rest-services/dmaap-client/pom.xml
rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/error/ClientErrorReasons.java
rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/impl/MessageRouterPublisherImpl.java
rest-services/dmaap-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/model/config/DmaapConnectionPoolConfig.java
rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/api/MessageRouterPublisherIT.java
rest-services/dmaap-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/dmaap/client/api/MessageRouterPublisherTest.java
rest-services/http-client/pom.xml
rest-services/model/pom.xml
rest-services/pom.xml
security/crypt-password/pom.xml
security/pom.xml
security/ssl/pom.xml
services/common/pom.xml
services/external-schema-manager/pom.xml
services/hv-ves-client/pom.xml
services/hv-ves-client/producer/api/pom.xml
services/hv-ves-client/producer/ct/pom.xml
services/hv-ves-client/producer/impl/pom.xml
services/hv-ves-client/producer/pom.xml
services/hv-ves-client/protobuf/pom.xml
services/pom.xml
standardization/api-custom-header/pom.xml
standardization/moher-api/healthstate/pom.xml
standardization/moher-api/metrics/pom.xml
standardization/moher-api/pom.xml
standardization/moher-api/server-adapters/pom.xml
standardization/moher-api/server-adapters/reactor-netty/pom.xml
standardization/moher-api/server-adapters/spring-webflux/pom.xml
standardization/pom.xml
version.properties

index 14a885d..63efe6d 100644 (file)
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
 The format is based on [Keep a Changelog](http://keepachangelog.com/)
 and this project adheres to [Semantic Versioning](http://semver.org/).    
 
+## [1.8.6] - 07/06/2021
+### Added
+    - [DCAEGEN2-2827] (https://jira.onap.org/browse/DCAEGEN2-2827) - Handle 429 error Too Many Requests
+
 ## [1.8.5] - 02/06/2021
 ### Added
     - [DCAEGEN2-2752] (https://jira.onap.org/browse/DCAEGEN2-2752) - Update CBS-Client to read policy configuration from a file exposed by policy-sidecar container
diff --git a/pom.xml b/pom.xml
index 9b866ec..5b1512f 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
 
     <groupId>org.onap.dcaegen2.services</groupId>
     <artifactId>sdk</artifactId>
-    <version>1.8.5-SNAPSHOT</version>
+    <version>1.8.6-SNAPSHOT</version>
 
     <name>dcaegen2-services-sdk</name>
     <description>Common SDK repo for all DCAE Services</description>
index 071763c..717e3a4 100644 (file)
@@ -7,7 +7,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.services.sdk</groupId>
         <artifactId>dcaegen2-services-sdk-rest-services</artifactId>
-        <version>1.8.5-SNAPSHOT</version>
+        <version>1.8.6-SNAPSHOT</version>
     </parent>
 
     <groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId>
index f3a612a..2462a44 100644 (file)
@@ -7,7 +7,7 @@
   <parent>
     <groupId>org.onap.dcaegen2.services.sdk</groupId>
     <artifactId>dcaegen2-services-sdk-rest-services</artifactId>
-    <version>1.8.5-SNAPSHOT</version>
+    <version>1.8.6-SNAPSHOT</version>
   </parent>
 
   <groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId>
index 431843a..f6e5c2b 100644 (file)
@@ -30,7 +30,8 @@ public class ClientErrorReasons {
             .header("408 Request Timeout")
             .text("Client timeout exception occurred, Error code is %1")
             .messageId("SVC0001")
-            .variables(Collections.singletonList("408")).build();
+            .variables(Collections.singletonList("408"))
+            .build();
 
     public static final ClientErrorReason SERVICE_UNAVAILABLE = ImmutableClientErrorReason.builder()
             .header("503 Service unavailable")
@@ -38,4 +39,10 @@ public class ClientErrorReasons {
             .messageId("SVC2001")
             .build();
 
+    public static final ClientErrorReason CONNECTION_POLL_LIMIT = ImmutableClientErrorReason.builder()
+            .header("429 Too Many Requests")
+            .text("Pending acquire queue has reached its maximum size")
+            .messageId("SVC2000")
+            .variables(Collections.singletonList("429"))
+            .build();
 }
index 6e4679c..534fca6 100644 (file)
@@ -50,6 +50,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
+import reactor.netty.internal.shaded.reactor.pool.PoolAcquirePendingLimitException;
 
 import java.net.ConnectException;
 import java.time.Duration;
@@ -95,6 +96,7 @@ public class MessageRouterPublisherImpl implements MessageRouterPublisher {
                         e -> LOGGER.error("Timeout exception occurred when sending items to DMaaP MR", e))
                 .onErrorResume(ReadTimeoutException.class, e -> buildErrorResponse(ClientErrorReasons.TIMEOUT))
                 .doOnError(ConnectException.class, e -> LOGGER.error("DMaaP MR is unavailable, {}", e.getMessage()))
+                .onErrorResume(PoolAcquirePendingLimitException.class, e -> buildErrorResponse(ClientErrorReasons.CONNECTION_POLL_LIMIT))
                 .onErrorResume(ConnectException.class, e -> buildErrorResponse(ClientErrorReasons.SERVICE_UNAVAILABLE))
                 .onErrorResume(RetryableException.class, e -> Mono.just(buildResponse(e.getResponse(), batch)));
     }
index 38166e4..4a4add0 100644 (file)
 package org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.model.config;
 
 import org.immutables.value.Value;
+import reactor.netty.resources.ConnectionProvider;
 
 @Value.Immutable
 public interface DmaapConnectionPoolConfig {
 
     @Value.Default
     default int connectionPool(){
-        return 16;
+        return ConnectionProvider.DEFAULT_POOL_MAX_CONNECTIONS;
     }
     @Value.Default
     default int maxLifeTime(){
index 70adf59..a1ad951 100644 (file)
@@ -95,6 +95,18 @@ class MessageRouterPublisherIT {
             + "}"
             + "}"
             + "}";
+    private static final String CONNECTION_POLL_LIMIT_MESSAGE = "429 Too Many Requests\n"
+            + "{"
+            + "\"requestError\":"
+            + "{"
+            + "\"serviceException\":"
+            + "{"
+            + "\"messageId\":\"SVC2000\","
+            + "\"text\":\"Pending acquire queue has reached its maximum size\","
+            + "\"variables\":[\"429\"]"
+            + "}"
+            + "}"
+            + "}";
 
     private final MessageRouterPublisher publisher = DmaapClientFactory
             .createMessageRouterPublisher(MessageRouterPublisherConfig.createDefault());
@@ -570,6 +582,48 @@ class MessageRouterPublisherIT {
                 .withHeader("Authorization" ,"Basic dXNlcm5hbWU6cGFzc3dvcmQ="), VerificationTimes.exactly(1));
     }
 
+    @Test
+    void publisher_shouldHandleError429WhenConnectionPollLimitsHasBeenReached() {
+        //given
+        final String topic = "TOPIC17";
+        final String topicUrl = String.format("%s/%s", PROXY_MOCK_EVENTS_PATH, topic);
+
+        final List<String> twoJsonMessages = List.of("{\"message\":\"message1\"}",
+                "{\"differentMessage\":\"message2\"}");
+        final Flux<JsonElement> plainBatch = plainBatch(twoJsonMessages);
+
+        final MessageRouterPublishRequest publishRequest = createPublishRequest(topicUrl, Duration.ofSeconds(1));
+
+        final MessageRouterPublishResponse expectedResponse = errorPublishResponse(
+                CONNECTION_POLL_LIMIT_MESSAGE);
+
+        final String path = String.format("/events/%s", topic);
+
+        //maxConnectionPoll + pendingAcquireMaxCount(default 2*maxConnectionPoll)
+        final int maxNumberOfConcurrentRequest = 3;
+        MOCK_SERVER_CLIENT
+                .when(request().withPath(path), Times.exactly(maxNumberOfConcurrentRequest))
+                .respond(response().withStatusCode(429).withDelay(TimeUnit.SECONDS,1));
+
+        MOCK_SERVER_CLIENT
+                .when(request().withPath(path), Times.once())
+                .respond(response().withStatusCode(200));
+
+        final MessageRouterPublisher publisher = DmaapClientFactory.createMessageRouterPublisher(connectionPoolConfiguration());
+
+        //when
+        final Flux<MessageRouterPublishResponse> result = publisher.put(publishRequest, plainBatch);
+
+        for(int i = 0; i < maxNumberOfConcurrentRequest; i++) {
+            publisher.put(publishRequest, plainBatch).subscribe();
+        }
+
+        //then
+        StepVerifier.create(result)
+                .expectNext(expectedResponse)
+                .expectComplete()
+                .verify();
+    }
 
     private MessageRouterPublisherConfig retryConfig(int retryInterval, int retryCount) {
         return ImmutableMessageRouterPublisherConfig.builder()
@@ -582,7 +636,7 @@ class MessageRouterPublisherIT {
     private MessageRouterPublisherConfig connectionPoolConfiguration() {
         return ImmutableMessageRouterPublisherConfig.builder()
                 .connectionPoolConfig(ImmutableDmaapConnectionPoolConfig.builder()
-                        .connectionPool(10)
+                        .connectionPool(1)
                         .maxIdleTime(10)
                         .maxLifeTime(20)
                         .build())
@@ -592,7 +646,7 @@ class MessageRouterPublisherIT {
     private MessageRouterPublisherConfig connectionPoolAndRetryConfiguration() {
         return ImmutableMessageRouterPublisherConfig.builder()
                 .connectionPoolConfig(ImmutableDmaapConnectionPoolConfig.builder()
-                        .connectionPool(10)
+                        .connectionPool(1)
                         .maxIdleTime(10)
                         .maxLifeTime(20)
                         .build())
index 82a2b00..97fd26f 100644 (file)
@@ -64,6 +64,7 @@ class MessageRouterPublisherTest {
     private static final String FAILING_WITH_403_RESP_PATH = "/events/TOPIC403";
     private static final String FAILING_WITH_404_RESP_PATH = "/events/TOPIC404";
     private static final String FAILING_WITH_500_RESP_PATH = "/events/TOPIC500";
+    private static final String FAILING_WITH_429_RESP_PATH = "/events/TOPIC429";
     private static final Duration TIMEOUT = Duration.ofSeconds(10);
     private static final Flux<JsonPrimitive> messageBatch = Flux.just("ala", "ma", "kota")
             .map(JsonPrimitive::new);
@@ -82,6 +83,7 @@ class MessageRouterPublisherTest {
                 .post(FAILING_WITH_403_RESP_PATH, (req, resp) -> sendError(resp, 403, ERROR_MESSAGE))
                 .post(FAILING_WITH_404_RESP_PATH, (req, resp) -> sendError(resp, 404, ERROR_MESSAGE))
                 .post(FAILING_WITH_500_RESP_PATH, (req, resp) -> sendError(resp, 500, ERROR_MESSAGE))
+                .post(FAILING_WITH_429_RESP_PATH, (req, resp) -> sendError(resp, 429, ERROR_MESSAGE))
         );
     }
 
@@ -107,7 +109,8 @@ class MessageRouterPublisherTest {
             FAILING_WITH_401_RESP_PATH + "," + "401 Unauthorized",
             FAILING_WITH_403_RESP_PATH + "," + "403 Forbidden",
             FAILING_WITH_404_RESP_PATH + "," + "404 Not Found",
-            FAILING_WITH_500_RESP_PATH + "," + "500 Internal Server Error"
+            FAILING_WITH_500_RESP_PATH + "," + "500 Internal Server Error",
+            FAILING_WITH_429_RESP_PATH + "," + "429 Too Many Requests"
     })
     void publisher_shouldHandleError(String failingPath, String failReason) {
         //given
index 3669aab..1533840 100644 (file)
@@ -28,7 +28,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.services.sdk</groupId>
         <artifactId>dcaegen2-services-sdk-rest-services</artifactId>
-        <version>1.8.5-SNAPSHOT</version>
+        <version>1.8.6-SNAPSHOT</version>
     </parent>
 
     <groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId>
index ea018c1..431039e 100644 (file)
@@ -27,7 +27,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.services.sdk</groupId>
         <artifactId>dcaegen2-services-sdk-rest-services</artifactId>
-        <version>1.8.5-SNAPSHOT</version>
+        <version>1.8.6-SNAPSHOT</version>
     </parent>
 
     <groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId>
index e419086..0f777a2 100644 (file)
@@ -7,7 +7,7 @@
   <parent>
     <groupId>org.onap.dcaegen2.services</groupId>
     <artifactId>sdk</artifactId>
-    <version>1.8.5-SNAPSHOT</version>
+    <version>1.8.6-SNAPSHOT</version>
   </parent>
 
   <groupId>org.onap.dcaegen2.services.sdk</groupId>
index e72800b..64a5784 100644 (file)
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.services.sdk.security</groupId>
         <artifactId>dcaegen2-services-sdk-security</artifactId>
-        <version>1.8.5-SNAPSHOT</version>
+        <version>1.8.6-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
index a540517..4450f5c 100644 (file)
@@ -7,7 +7,7 @@
   <parent>
     <groupId>org.onap.dcaegen2.services</groupId>
     <artifactId>sdk</artifactId>
-    <version>1.8.5-SNAPSHOT</version>
+    <version>1.8.6-SNAPSHOT</version>
   </parent>
 
   <groupId>org.onap.dcaegen2.services.sdk.security</groupId>
index 17c294f..9d93724 100644 (file)
@@ -6,7 +6,7 @@
   <parent>
     <groupId>org.onap.dcaegen2.services.sdk.security</groupId>
     <artifactId>dcaegen2-services-sdk-security</artifactId>
-    <version>1.8.5-SNAPSHOT</version>
+    <version>1.8.6-SNAPSHOT</version>
   </parent>
 
   <artifactId>ssl</artifactId>
index c16a234..4633ef8 100644 (file)
@@ -7,7 +7,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.services.sdk</groupId>
         <artifactId>dcaegen2-services-sdk-services</artifactId>
-        <version>1.8.5-SNAPSHOT</version>
+        <version>1.8.6-SNAPSHOT</version>
     </parent>
 
     <artifactId>dcaegen2-services-sdk-services-common</artifactId>
index 33dd7c0..834e706 100644 (file)
@@ -7,7 +7,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.services.sdk</groupId>
         <artifactId>dcaegen2-services-sdk-services</artifactId>
-        <version>1.8.5-SNAPSHOT</version>
+        <version>1.8.6-SNAPSHOT</version>
     </parent>
 
     <artifactId>dcaegen2-services-sdk-services-external-schema-manager</artifactId>
index 4394d9e..e1f3217 100644 (file)
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.onap.dcaegen2.services.sdk</groupId>
     <artifactId>dcaegen2-services-sdk-services</artifactId>
-    <version>1.8.5-SNAPSHOT</version>
+    <version>1.8.6-SNAPSHOT</version>
   </parent>
 
   <artifactId>dcaegen2-services-sdk-services-hvvesclient</artifactId>
index 734a33c..daf5f51 100644 (file)
@@ -26,7 +26,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.services.sdk</groupId>
         <artifactId>hvvesclient-producer</artifactId>
-        <version>1.8.5-SNAPSHOT</version>
+        <version>1.8.6-SNAPSHOT</version>
     </parent>
 
     <artifactId>hvvesclient-producer-api</artifactId>
index 488aec7..dc7cdba 100644 (file)
@@ -26,7 +26,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.services.sdk</groupId>
         <artifactId>hvvesclient-producer</artifactId>
-        <version>1.8.5-SNAPSHOT</version>
+        <version>1.8.6-SNAPSHOT</version>
     </parent>
 
     <artifactId>hvvesclient-producer-ct</artifactId>
index d9c1885..56ac186 100644 (file)
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.onap.dcaegen2.services.sdk</groupId>
     <artifactId>hvvesclient-producer</artifactId>
-    <version>1.8.5-SNAPSHOT</version>
+    <version>1.8.6-SNAPSHOT</version>
   </parent>
 
   <artifactId>hvvesclient-producer-impl</artifactId>
index 1beed9d..ceecd1d 100644 (file)
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.onap.dcaegen2.services.sdk</groupId>
     <artifactId>dcaegen2-services-sdk-services-hvvesclient</artifactId>
-    <version>1.8.5-SNAPSHOT</version>
+    <version>1.8.6-SNAPSHOT</version>
   </parent>
 
   <artifactId>hvvesclient-producer</artifactId>
index 6026731..50cb9d8 100644 (file)
@@ -26,7 +26,7 @@
     <parent>
         <artifactId>dcaegen2-services-sdk-services-hvvesclient</artifactId>
         <groupId>org.onap.dcaegen2.services.sdk</groupId>
-        <version>1.8.5-SNAPSHOT</version>
+        <version>1.8.6-SNAPSHOT</version>
     </parent>
 
     <name>High Volume VES Collector Client :: Protobuf</name>
index 6c2ed3f..f07c4eb 100644 (file)
@@ -26,7 +26,7 @@
   <parent>
     <groupId>org.onap.dcaegen2.services</groupId>
     <artifactId>sdk</artifactId>
-    <version>1.8.5-SNAPSHOT</version>
+    <version>1.8.6-SNAPSHOT</version>
   </parent>
 
   <groupId>org.onap.dcaegen2.services.sdk</groupId>
index d4834b0..b6e5e91 100644 (file)
@@ -7,7 +7,7 @@
   <parent>
     <groupId>org.onap.dcaegen2.services.sdk</groupId>
     <artifactId>dcaegen2-services-sdk-standardization</artifactId>
-    <version>1.8.5-SNAPSHOT</version>
+    <version>1.8.6-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
   
index c257e3d..ec10bbc 100644 (file)
@@ -25,7 +25,7 @@
     <parent>
         <artifactId>dcaegen2-sdk-moher-api</artifactId>
         <groupId>org.onap.dcaegen2.services.sdk</groupId>
-        <version>1.8.5-SNAPSHOT</version>
+        <version>1.8.6-SNAPSHOT</version>
     </parent>
 
     <name>Monitoring and Healthcheck :: Health state</name>
index 1e337e0..de8e224 100644 (file)
@@ -26,7 +26,7 @@
     <parent>
         <artifactId>dcaegen2-sdk-moher-api</artifactId>
         <groupId>org.onap.dcaegen2.services.sdk</groupId>
-        <version>1.8.5-SNAPSHOT</version>
+        <version>1.8.6-SNAPSHOT</version>
     </parent>
 
     <name>Monitoring and Healthcheck :: Metrics</name>
index fbece46..079c914 100644 (file)
@@ -26,7 +26,7 @@
     <parent>
         <artifactId>dcaegen2-services-sdk-standardization</artifactId>
         <groupId>org.onap.dcaegen2.services.sdk</groupId>
-        <version>1.8.5-SNAPSHOT</version>
+        <version>1.8.6-SNAPSHOT</version>
     </parent>
 
     <name>Monitoring and Healthcheck</name>
index 7be8167..8e5d807 100644 (file)
@@ -25,7 +25,7 @@
     <parent>
         <artifactId>dcaegen2-sdk-moher-api</artifactId>
         <groupId>org.onap.dcaegen2.services.sdk</groupId>
-        <version>1.8.5-SNAPSHOT</version>
+        <version>1.8.6-SNAPSHOT</version>
     </parent>
 
     <name>Monitoring and Healthcheck :: Server Adapters</name>
index 2b31827..1122ae8 100644 (file)
@@ -25,7 +25,7 @@
     <parent>
         <artifactId>dcaegen2-sdk-moher-server-adapters</artifactId>
         <groupId>org.onap.dcaegen2.services.sdk</groupId>
-        <version>1.8.5-SNAPSHOT</version>
+        <version>1.8.6-SNAPSHOT</version>
     </parent>
 
     <name>Monitoring and Healthcheck :: Server Adapters :: Reactor Netty</name>
index e72a2a6..cd48de4 100644 (file)
@@ -25,7 +25,7 @@
     <parent>
         <artifactId>dcaegen2-sdk-moher-server-adapters</artifactId>
         <groupId>org.onap.dcaegen2.services.sdk</groupId>
-        <version>1.8.5-SNAPSHOT</version>
+        <version>1.8.6-SNAPSHOT</version>
     </parent>
 
     <name>Monitoring and Healthcheck :: Server Adapters :: Spring Webflux</name>
index 19dd0a1..c7e5ad3 100644 (file)
@@ -8,7 +8,7 @@
   <parent>
     <groupId>org.onap.dcaegen2.services</groupId>
     <artifactId>sdk</artifactId>
-    <version>1.8.5-SNAPSHOT</version>
+    <version>1.8.6-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 
index c5caaca..9b83c5e 100644 (file)
@@ -1,6 +1,6 @@
 major=1
 minor=8
-patch=5
+patch=6
 base_version=${major}.${minor}.${patch}
 release_version=${base_version}
 snapshot_version=${base_version}-SNAPSHOT