From 5baa1ed97c1d2b98952a025c3bc76f60587e9670 Mon Sep 17 00:00:00 2001 From: Jozsef Csongvai Date: Mon, 13 Jun 2022 08:53:19 -0400 Subject: Enable long-running processes in ControllerExecutionBB Instead of blocking a thread while waiting for controller response, ControllerExecutionBB is now using camunda receive task to support long running processes without increasing the camunda job timeout. A new property was added to configure the gRPC client's keep alive ping mechanism, which will identify connection issues and prevent the process getting stuck when the controller crashes. Issue-ID: SO-3953 Signed-off-by: Jozsef Csongvai Change-Id: Iaf6438dba76e715dba846bf45ef47b6a91239c4a --- .../org/onap/so/client/cds/CDSProcessingClient.java | 2 ++ .../main/java/org/onap/so/client/cds/CDSProperties.java | 17 +++++++++++++++-- .../org/onap/so/client/cds/TestCDSPropertiesImpl.java | 5 +++++ 3 files changed, 22 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/src/main/java/org/onap/so/client/cds/CDSProcessingClient.java b/common/src/main/java/org/onap/so/client/cds/CDSProcessingClient.java index e40b936daa..6e27b85863 100644 --- a/common/src/main/java/org/onap/so/client/cds/CDSProcessingClient.java +++ b/common/src/main/java/org/onap/so/client/cds/CDSProcessingClient.java @@ -28,6 +28,7 @@ import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLException; import javax.net.ssl.TrustManagerFactory; import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; @@ -107,6 +108,7 @@ public class CDSProcessingClient implements AutoCloseable { log.info("Configure Basic authentication"); builder.intercept(new BasicAuthClientInterceptor(props)).usePlaintext(); } + builder.keepAliveTime(props.getKeepAlivePingMinutes(), TimeUnit.MINUTES); this.channel = builder.build(); this.handler = new CDSProcessingHandler(listener); log.info("CDSProcessingClient started"); diff --git a/common/src/main/java/org/onap/so/client/cds/CDSProperties.java b/common/src/main/java/org/onap/so/client/cds/CDSProperties.java index db566fa3de..f47a70976b 100644 --- a/common/src/main/java/org/onap/so/client/cds/CDSProperties.java +++ b/common/src/main/java/org/onap/so/client/cds/CDSProperties.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,6 +20,7 @@ package org.onap.so.client.cds; +import java.util.concurrent.TimeUnit; import org.onap.so.client.RestProperties; public interface CDSProperties extends RestProperties { @@ -35,4 +36,16 @@ public interface CDSProperties extends RestProperties { boolean getUseSSL(); boolean getUseBasicAuth(); + + /** + * Gets grpc keep alive ping interval, which is useful for detecting connection issues when the server dies + * abruptly. If the value is set lower than what is allowed by the server (default 5 min), the connection will be + * closed after a few pings. + * + * If no value is set this method will default to 6 min (server default minimum + 1) + * + * @see io.grpc.netty.NettyChannelBuilder#keepAliveTime(long, TimeUnit) + * @return + */ + long getKeepAlivePingMinutes(); } diff --git a/common/src/test/java/org/onap/so/client/cds/TestCDSPropertiesImpl.java b/common/src/test/java/org/onap/so/client/cds/TestCDSPropertiesImpl.java index 41238e539e..76dc6ad4ea 100644 --- a/common/src/test/java/org/onap/so/client/cds/TestCDSPropertiesImpl.java +++ b/common/src/test/java/org/onap/so/client/cds/TestCDSPropertiesImpl.java @@ -82,4 +82,9 @@ public class TestCDSPropertiesImpl implements CDSProperties { public boolean getUseBasicAuth() { return true; } + + @Override + public long getKeepAlivePingMinutes() { + return 6L; + } } -- cgit 1.2.3-korg