From 23c27ddcd79913d11eac16eb42c5a43899de97a1 Mon Sep 17 00:00:00 2001 From: Ravi Pendurty Date: Tue, 16 Jun 2020 11:23:52 +0200 Subject: client side readtimeout support clientside readtimeout support for mountpoint-registrar using the updated dmaap client library Issue-ID: SDNC-1246 Signed-off-by: Ravi Pendurty Change-Id: I7e60c7b30c0378dfb09b16160714e742162b1790 Signed-off-by: Ravi Pendurty --- sdnr/wt/mountpoint-registrar/provider/pom.xml | 2 +- .../impl/DMaaPVESMsgConsumerImpl.java | 3 +++ .../impl/DMaaPVESMsgConsumerMain.java | 4 ++++ .../sdnr/wt/mountpointregistrar/impl/FaultConfig.java | 17 +++++++++++++++++ .../impl/MountpointRegistrarImpl.java | 2 +- .../mountpointregistrar/impl/PNFRegistrationConfig.java | 17 ++++++++++++++++- .../test/PNFRegistrationConfigTest.java | 5 ++++- .../wt/mountpointregistrar/test/TestFaultConfig.java | 4 ++++ 8 files changed, 50 insertions(+), 4 deletions(-) (limited to 'sdnr/wt/mountpoint-registrar') diff --git a/sdnr/wt/mountpoint-registrar/provider/pom.xml b/sdnr/wt/mountpoint-registrar/provider/pom.xml index 8d64d67b7..60210ea8e 100644 --- a/sdnr/wt/mountpoint-registrar/provider/pom.xml +++ b/sdnr/wt/mountpoint-registrar/provider/pom.xml @@ -105,7 +105,7 @@ org.onap.dmaap.messagerouter.dmaapclient dmaapClient - 1.1.10 + 1.1.12 org.onap.ccsdk.features.sdnr.wt diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java index bf8596cbc..1164a9a88 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java @@ -66,6 +66,9 @@ public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer { if (noData) { LOG.debug(name + " received ResponseCode: " + consumerResponse.getResponseCode()); LOG.debug(name + " received ResponseMessage: " + consumerResponse.getResponseMessage()); + if ((consumerResponse.getResponseCode() == null) && (consumerResponse.getResponseMessage().contains("SocketTimeoutException"))) { + LOG.warn("Client timeout while waiting for response from Server {}", consumerResponse.getResponseMessage()); + } pauseThread(); } } catch (Exception e) { diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java index 6d608bf05..26afd19aa 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java @@ -63,6 +63,8 @@ public class DMaaPVESMsgConsumerMain implements Runnable { consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_PROTOCOL, pnfRegistrationConfig.getProtocol()); consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_USERNAME, pnfRegistrationConfig.getUsername()); consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_PASSWORD, pnfRegistrationConfig.getPassword()); + consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT, pnfRegistrationConfig.getClientReadTimeout()); + consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT, pnfRegistrationConfig.getClientConnectTimeout()); } else if (domain.equalsIgnoreCase("fault")) { this.faultConfig = (FaultConfig) domainConfig; consumerClass = faultConfig.getConsumerClass(); @@ -79,6 +81,8 @@ public class DMaaPVESMsgConsumerMain implements Runnable { consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_PROTOCOL, faultConfig.getProtocol()); consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_USERNAME, faultConfig.getUsername()); consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_PASSWORD, faultConfig.getPassword()); + consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT, faultConfig.getClientReadTimeout()); + consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT, faultConfig.getClientConnectTimeout()); } if (consumerClass != null) { diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultConfig.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultConfig.java index 90757e6d5..dc0ed9cdd 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultConfig.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultConfig.java @@ -61,6 +61,12 @@ public class FaultConfig implements Configuration { public static final String PROPERTY_KEY_CONSUMER_FETCHPAUSE = "fetchPause"; private static final String DEFAULT_VALUE_CONSUMER_FETCHPAUSE = "5000"; + + public static final String PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT="jersey.config.client.readTimeout"; + private static final String DEFAULT_VALUE_CONSUMER_CLIENT_READTIMEOUT="25000"; + + public static final String PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT="jersey.config.client.connectTimeout"; + private static final String DEFAULT_VALUE_CONSUMER_CLIENT_CONNECTTIMEOUT="25000"; private final ConfigurationFileRepresentation configuration; @@ -91,6 +97,8 @@ public class FaultConfig implements Configuration { configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_TIMEOUT, DEFAULT_VALUE_CONSUMER_TIMEOUT); configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_LIMIT, DEFAULT_VALUE_CONSUMER_LIMIT); configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_FETCHPAUSE, DEFAULT_VALUE_CONSUMER_FETCHPAUSE); + configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT, DEFAULT_VALUE_CONSUMER_CLIENT_READTIMEOUT); + configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT, DEFAULT_VALUE_CONSUMER_CLIENT_CONNECTTIMEOUT); } @@ -145,5 +153,14 @@ public class FaultConfig implements Configuration { public String getContenttype() { return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CONTENTTYPE); } + + public String getClientReadTimeout() { + return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT); + } + + public String getClientConnectTimeout() { + return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT); + } + } diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MountpointRegistrarImpl.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MountpointRegistrarImpl.java index 1155462c4..a993f23c9 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MountpointRegistrarImpl.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MountpointRegistrarImpl.java @@ -39,7 +39,7 @@ public class MountpointRegistrarImpl implements AutoCloseable, IConfigChangedLis private GeneralConfig generalConfig; private boolean dmaapEnabled = false; - Map configMap = new HashMap<>(); + private Map configMap = new HashMap<>(); // Blueprint 1 public MountpointRegistrarImpl() { diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFRegistrationConfig.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFRegistrationConfig.java index 26ece6b6d..79f96db32 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFRegistrationConfig.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFRegistrationConfig.java @@ -63,6 +63,12 @@ public class PNFRegistrationConfig implements Configuration { public static final String PROPERTY_KEY_CONSUMER_FETCHPAUSE = "fetchPause"; private static final String DEFAULT_VALUE_CONSUMER_FETCHPAUSE = "5000"; + public static final String PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT="jersey.config.client.readTimeout"; + private static final String DEFAULT_VALUE_CONSUMER_CLIENT_READTIMEOUT="25000"; + + public static final String PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT="jersey.config.client.connectTimeout"; + private static final String DEFAULT_VALUE_CONSUMER_CLIENT_CONNECTTIMEOUT="25000"; + private final ConfigurationFileRepresentation configuration; public PNFRegistrationConfig(ConfigurationFileRepresentation configuration) { @@ -91,7 +97,8 @@ public class PNFRegistrationConfig implements Configuration { configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_TIMEOUT, DEFAULT_VALUE_CONSUMER_TIMEOUT); configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_LIMIT, DEFAULT_VALUE_CONSUMER_LIMIT); configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_FETCHPAUSE, DEFAULT_VALUE_CONSUMER_FETCHPAUSE); - + configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT, DEFAULT_VALUE_CONSUMER_CLIENT_READTIMEOUT); + configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT, DEFAULT_VALUE_CONSUMER_CLIENT_CONNECTTIMEOUT); } public String getConsumerClass() { @@ -145,4 +152,12 @@ public class PNFRegistrationConfig implements Configuration { public String getContenttype() { return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CONTENTTYPE); } + + public String getClientReadTimeout() { + return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT); + } + + public String getClientConnectTimeout() { + return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT); + } } diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/PNFRegistrationConfigTest.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/PNFRegistrationConfigTest.java index 1049bf902..39488f887 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/PNFRegistrationConfigTest.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/PNFRegistrationConfigTest.java @@ -47,6 +47,8 @@ public class PNFRegistrationConfigTest { "timeout=20000\n" + "limit=10000\n" + "fetchPause=5000\n" + + "jersey.config.client.readTimeout=25000\n" + + "jersey.config.client.connectTimeout=25000\n" + ""; private ConfigurationFileRepresentation cfg; @@ -71,7 +73,8 @@ public class PNFRegistrationConfigTest { assertEquals("http", pnfCfg.getProtocol()); assertEquals("username", pnfCfg.getUsername()); assertEquals("password", pnfCfg.getPassword()); - + assertEquals("25000", pnfCfg.getClientReadTimeout()); + assertEquals("25000", pnfCfg.getClientConnectTimeout()); } catch (IOException e) { // TODO Auto-generated catch block diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestFaultConfig.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestFaultConfig.java index 73cd5aaba..e07b9757c 100644 --- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestFaultConfig.java +++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestFaultConfig.java @@ -47,6 +47,8 @@ public class TestFaultConfig { "timeout=20000\n" + "limit=10000\n" + "fetchPause=5000\n" + + "jersey.config.client.readTimeout=25000\n" + + "jersey.config.client.connectTimeout=25000\n" + "\n" + ""; @@ -72,6 +74,8 @@ public class TestFaultConfig { assertEquals("http", faultCfg.getProtocol()); assertEquals("username", faultCfg.getUsername()); assertEquals("password", faultCfg.getPassword()); + assertEquals("25000", faultCfg.getClientReadTimeout()); + assertEquals("25000", faultCfg.getClientConnectTimeout()); } catch (IOException e) { // TODO Auto-generated catch block -- cgit 1.2.3-korg