diff options
author | Balaji, Ramya (rb111y) <rb111y@att.com> | 2019-01-30 22:26:13 -0500 |
---|---|---|
committer | Patrick Brady <patrick.brady@att.com> | 2019-02-05 18:08:40 +0000 |
commit | 6bcb029d5f4110fd3e07ccb6a662c3712ef748fb (patch) | |
tree | d3087706e66f61587d519775fd690a07e9f9b007 /appc-event-listener | |
parent | 6b1cd6d21d3c7477851604cfbeea37ff7d71022c (diff) |
listener bundle change for multiple ansible
Changes to event listener and dependent
bundles
Issue-ID: APPC-1376
Change-Id: I26e9f6f39caa2a0b0ad46a3a61d21db9f0c05d47
Signed-off-by: Balaji, Ramya (rb111y) <rb111y@att.com>
Diffstat (limited to 'appc-event-listener')
5 files changed, 161 insertions, 32 deletions
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/EventHandler.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/EventHandler.java index 20d4a6ad4..c2b7c4bbf 100644 --- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/EventHandler.java +++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/EventHandler.java @@ -2,22 +2,22 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ============================================================================= * 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. * See the License for the specific language governing permissions and * limitations under the License. - * + * * ============LICENSE_END========================================================= */ @@ -36,14 +36,14 @@ public interface EventHandler { /** * Gets a list of messages as Strings on the read topic. - * + * * @return A list of String messages. Never returns null. */ public List<String> getIncomingEvents(); /** * Gets a list of messages as String on the read topic. - * + * * @param limit * The maximum amount of entries to return * @return A list of String messages. Never returns null. @@ -72,7 +72,7 @@ public interface EventHandler { /** * Posts the String message to the write topic(s). - * + * * @param event * The String to post. */ @@ -96,7 +96,7 @@ public interface EventHandler { /** * Set the client/group id used to read messages - * + * * @param clientId * The new clientId to use */ @@ -109,7 +109,7 @@ public interface EventHandler { /** * Set the client/group name used to read messages. - * + * * @param clientName * The new clientName to use */ @@ -122,7 +122,7 @@ public interface EventHandler { /** * Set the name of the topic to read from. - * + * * @param topic * The new topic to read from */ @@ -135,7 +135,7 @@ public interface EventHandler { /** * Set the name of the topic to write to - * + * * @param topic * The new topic to write to */ @@ -143,7 +143,7 @@ public interface EventHandler { /** * Adds a DMaaP host to the host pool - * + * * @param host * The host to add to the pool in <host>:<port> format */ @@ -151,7 +151,7 @@ public interface EventHandler { /** * Remove the host name from the pool if it exists - * + * * @param host * The host to add to the pool in <host>:<port> format */ @@ -159,7 +159,7 @@ public interface EventHandler { /** * Get all of the hosts in the DMaaP pool - * + * * @return A collection of host in <host>:<port> format */ public Collection<String> getPool(); @@ -170,15 +170,36 @@ public interface EventHandler { public void clearCredentials(); /** + * Sets Blacklist time for a server with response problem in seconds + */ + void setResponseProblemBlacklistTime(String duration); + + /** + * Sets Blacklist time for a server with server problem in seconds + */ + void setServerProblemBlacklistTime(String duration); + + /** + * Sets Blacklist time for a server with DNS problem in seconds + */ + void setDnsIssueBlacklistTime(String duration); + + /** + * Sets Blacklist time for a server with IO Exception problem in seconds + */ + void setIOExceptionBlacklistTime(String duration); + /** * Set the api credentials and make future requests as an authenticated user - * + * * @param access * The access portion of the credentials (either user name or api key) * @param secret * The secret portion of the credentials (either password or api secret) */ + + public void setCredentials(String access, String secret); - + /** * Close consumer/producer DMaaP clients */ diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/ListenerProperties.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/ListenerProperties.java index 107b0f67e..74ead9485 100644 --- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/ListenerProperties.java +++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/ListenerProperties.java @@ -2,22 +2,22 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ============================================================================= * 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. * See the License for the specific language governing permissions and * limitations under the License. - * + * * ============LICENSE_END========================================================= */ @@ -89,7 +89,7 @@ public class ListenerProperties { /** * Returns a property matching a given KEYS - * + * * @param key * The KEYS object who's value to return. * @return The value of the property or null if none exists @@ -100,7 +100,7 @@ public class ListenerProperties { /** * Returns a property matching a given string. - * + * * @param key * The key who's value to return. * @return The value of the property or null if none exists @@ -111,7 +111,7 @@ public class ListenerProperties { /** * Returns a property matching a given KEYS - * + * * @param key * The KEYS object who's value to return. * @param defaultValue @@ -124,7 +124,7 @@ public class ListenerProperties { /** * Returns a property matching a given string. - * + * * @param key * The key who's value to return. * @param defaultValue @@ -218,6 +218,27 @@ public class ListenerProperties { TOPIC_READ_TIMEOUT("topic.read.timeout"), /** + * Blacklist time for a server with response problem in seconds + */ + + PROBLEM_WITH_RESPONSE_BLACKLIST_TIME("topic.responseProblem.blacklistTime"), + /** + * Blacklist time for a server with server problem in seconds + */ + + PROBLEM_SERVERSIDE_ERROR_BLACKLIST_TIME("topic.serverError.blacklistTime"), + /** + * Blacklist time for a server with DNS problem in seconds + */ + + PROBLEM_DNS_BLACKLIST_TIME("topic.dnsIssue.blacklistTime"), + /** + * Blacklist time for a server with IO Exception problem in seconds + */ + + PROBLEM_IO_EXCEPTION_BLACKLIST_TIME("topic.ioException.blacklistTime"), + + /** * The name of the client to use. Should be unique to the application. */ CLIENT_NAME("client.name"), diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/EventHandlerImpl.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/EventHandlerImpl.java index 3019aaf33..74193c2b8 100644 --- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/EventHandlerImpl.java +++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/EventHandlerImpl.java @@ -2,22 +2,22 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ============================================================================= * 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. * See the License for the specific language governing permissions and * limitations under the License. - * + * * ============LICENSE_END========================================================= */ @@ -100,6 +100,27 @@ public class EventHandlerImpl implements EventHandler { */ private String filter_json; + + /* + * Blacklist time for a server with response problem in seconds + */ + private String responseProblemBlacklistTime; + + /* + * Blacklist time for a server with server problem in seconds + */ + private String serverProblemBlacklistTime; + + /* + * Blacklist time for a server with DNS problem in seconds + */ + private String dnsIssueBlacklistTime; + + /* + * Blacklist time for a server with IO Exception problem in seconds + */ + private String ioExceptionBlacklistTime; + private MessageService messageService; private Consumer reader = null; @@ -115,6 +136,10 @@ public class EventHandlerImpl implements EventHandler { clientId = props.getProperty(ListenerProperties.KEYS.CLIENT_ID, "0"); apiKey = props.getProperty(ListenerProperties.KEYS.AUTH_USER_KEY); apiSecret = props.getProperty(ListenerProperties.KEYS.AUTH_SECRET_KEY); + responseProblemBlacklistTime = props.getProperty(ListenerProperties.KEYS.PROBLEM_WITH_RESPONSE_BLACKLIST_TIME); + serverProblemBlacklistTime = props.getProperty(ListenerProperties.KEYS.PROBLEM_SERVERSIDE_ERROR_BLACKLIST_TIME); + dnsIssueBlacklistTime = props.getProperty(ListenerProperties.KEYS.PROBLEM_DNS_BLACKLIST_TIME); + ioExceptionBlacklistTime = props.getProperty(ListenerProperties.KEYS.PROBLEM_IO_EXCEPTION_BLACKLIST_TIME); filter_json = props.getProperty(ListenerProperties.KEYS.TOPIC_READ_FILTER); @@ -218,6 +243,26 @@ public class EventHandlerImpl implements EventHandler { try { out = ((MessageAdapterFactory) ctx.getService(svcRef)) .createConsumer(pool, readTopic, clientName, clientId, filter_json, apiKey, apiSecret); + + if (out != null && responseProblemBlacklistTime != null && responseProblemBlacklistTime.length() > 0) + { + out.setResponseProblemBlacklistTime(responseProblemBlacklistTime); + } + + if (out != null && serverProblemBlacklistTime != null && serverProblemBlacklistTime.length() > 0) + { + out.setServerProblemBlacklistTime(serverProblemBlacklistTime); + } + + if (out != null && dnsIssueBlacklistTime != null && dnsIssueBlacklistTime.length() > 0) + { + out.setDnsIssueBlacklistTime(dnsIssueBlacklistTime); + } + + if (out != null && ioExceptionBlacklistTime != null && ioExceptionBlacklistTime.length() > 0) + { + out.setIOExceptionBlacklistTime(ioExceptionBlacklistTime); + } } catch (Exception e) { //TODO:create eelf message LOG.error("EvenHandlerImp.getConsumer calling MessageAdapterFactor.createConsumer", e); @@ -250,6 +295,25 @@ public class EventHandlerImpl implements EventHandler { if (svcRef != null) { out = ((MessageAdapterFactory) ctx.getService(svcRef)) .createProducer(pool, writeTopics, apiKey, apiSecret); + if (out != null && responseProblemBlacklistTime != null && responseProblemBlacklistTime.length() > 0) + { + out.setResponseProblemBlacklistTime(responseProblemBlacklistTime); + } + + if (out != null && serverProblemBlacklistTime != null && serverProblemBlacklistTime.length() > 0) + { + out.setServerProblemBlacklistTime(serverProblemBlacklistTime); + } + + if (out != null && dnsIssueBlacklistTime != null && dnsIssueBlacklistTime.length() > 0) + { + out.setDnsIssueBlacklistTime(dnsIssueBlacklistTime); + } + + if (out != null && ioExceptionBlacklistTime != null && ioExceptionBlacklistTime.length() > 0) + { + out.setIOExceptionBlacklistTime(ioExceptionBlacklistTime); + } if (out != null) { for (String url : pool) { if (url.contains("3905") || url.contains("https")) { @@ -331,6 +395,26 @@ public class EventHandlerImpl implements EventHandler { } @Override + public void setResponseProblemBlacklistTime(String duration){ + this.responseProblemBlacklistTime = duration; + } + + @Override + public void setServerProblemBlacklistTime(String duration){ + this.serverProblemBlacklistTime = duration; + } + + @Override + public void setDnsIssueBlacklistTime(String duration){ + this.dnsIssueBlacklistTime = duration; + } + + @Override + public void setIOExceptionBlacklistTime(String duration){ + this.ioExceptionBlacklistTime = duration; + } + + @Override public void clearCredentials() { apiKey = null; apiSecret = null; diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/ListenerPropertiesTest.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/ListenerPropertiesTest.java index 088553e76..c83555c50 100644 --- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/ListenerPropertiesTest.java +++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/ListenerPropertiesTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ============================================================================= @@ -121,7 +121,7 @@ public class ListenerPropertiesTest { @Test public void testKeys() { // Hardcode count so tests must be updated when values are added - assertEquals(15, ListenerProperties.KEYS.values().length); + assertEquals(19, ListenerProperties.KEYS.values().length); Properties tmp = new Properties(); try { diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/resources/org/onap/appc/default.properties b/appc-event-listener/appc-event-listener-bundle/src/test/resources/org/onap/appc/default.properties index bacbe53f3..c729c7b0a 100644 --- a/appc-event-listener/appc-event-listener-bundle/src/test/resources/org/onap/appc/default.properties +++ b/appc-event-listener/appc-event-listener-bundle/src/test/resources/org/onap/appc/default.properties @@ -2,7 +2,7 @@ # ============LICENSE_START======================================================= # ONAP : APPC # ================================================================================ -# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. +# Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. # ================================================================================ # Copyright (C) 2017 Amdocs # ============================================================================= @@ -58,7 +58,10 @@ appc.ClosedLoop.threads.queuesize.max=1000 appc.ClosedLoop.threads.poolsize.min=1 appc.ClosedLoop.threads.poolsize.max=2 appc.ClosedLoop.provider.url=https://admin:password@localhost:8443/restconf/operations/appc-provider:topology-operation - +appc.ClosedLoop.topic.responseProblem.blacklistTime=60 +appc.ClosedLoop.topic.serverError.blacklistTime=60 +appc.ClosedLoop.topic.dnsIssue.blacklistTime=60 +appc.ClosedLoop.topic.ioException.blacklistTime=60 |