* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
* ============LICENSE_END=========================================================
*/
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+
+import org.onap.appc.adapter.factory.DmaapMessageAdapterFactoryImpl;
import org.onap.appc.adapter.factory.MessageService;
import org.onap.appc.adapter.message.Consumer;
import org.onap.appc.adapter.message.MessageAdapterFactory;
import org.onap.appc.listener.ListenerProperties;
import org.onap.appc.listener.util.Mapper;
import org.onap.appc.logging.LoggingConstants;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
*/
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;
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);
messageService = MessageService.parse(props.getProperty(ListenerProperties.KEYS.MESSAGE_SERVICE));
LOG.info(String.format(
- "Configured to use %s client on host pool [%s]. Reading from [%s] filtered by %s. Wriring to [%s]. Authenticated using %s",
+ "Configured to use %s client on host pool [%s]. Reading from [%s] filtered by %s. Writing to [%s]. Authenticated using %s",
messageService, hostnames, readTopic, filter_json, writeTopics, apiKey));
}
}
}
Consumer out = null;
- BundleContext ctx = FrameworkUtil.getBundle(EventHandlerImpl.class).getBundleContext();
+ BundleContext ctx = null;
+ Bundle bundle = FrameworkUtil.getBundle(EventHandlerImpl.class);
+ if(bundle != null) {
+ ctx = bundle.getBundleContext();
+ }
+
if (ctx != null) {
ServiceReference svcRef = ctx.getServiceReference(MessageAdapterFactory.class.getName());
if (svcRef != null) {
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);
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")) {
this.writeTopics = writeTopics;
}
+ @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;