aboutsummaryrefslogtreecommitdiffstats
path: root/appc-event-listener
diff options
context:
space:
mode:
authorSkip Wonnell <skip@att.com>2018-01-10 14:28:49 -0600
committerSkip Wonnell <skip@att.com>2018-01-11 01:29:14 +0000
commit3b7892e138cf77cbdbadc13a83bf50726c3b22a7 (patch)
tree933e19bb6cf850706afdba89cfb5b2ff69341aa4 /appc-event-listener
parentff3c47b5cd2333ee97816b11999edb9c493ee9b8 (diff)
Code synch up for appc-event-listener bundle
Change-Id: I6362ba99c6e15b78c65a2e3bbcb841c78e8c606c Issue-ID: APPC-382 Signed-off-by: Skip Wonnell <skip@att.com>
Diffstat (limited to 'appc-event-listener')
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/AppcEventListenerActivator.java21
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/operation/ProviderOperations.java62
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/ListenerProperties.java6
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/ControllerImpl.java13
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/EventHandlerImpl.java2
5 files changed, 57 insertions, 47 deletions
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/AppcEventListenerActivator.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/AppcEventListenerActivator.java
index 0b1eb5328..a65b315e4 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/AppcEventListenerActivator.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/AppcEventListenerActivator.java
@@ -80,11 +80,6 @@ public class AppcEventListenerActivator implements BundleActivator {
private Configuration configuration;
/**
- * The bundle context
- */
- private static BundleContext context;
-
- /**
* The reference to the actual implementation object that implements the services
*/
private Controller adapter;
@@ -113,8 +108,6 @@ public class AppcEventListenerActivator implements BundleActivator {
public void start(BundleContext ctx) throws Exception {
LOG.info("Starting Bundle " + getName());
- context = ctx;
-
configuration = ConfigurationFactory.getConfiguration();
Properties props = configuration.getProperties();
@@ -126,8 +119,6 @@ public class AppcEventListenerActivator implements BundleActivator {
demoProps.setListenerClass(org.onap.appc.listener.demo.impl.ListenerImpl.class);
listeners.add(demoProps);
- // ===========================================================================
-
ListenerProperties clLCMProps = new ListenerProperties("appc.LCM", props);
clLCMProps.setListenerClass(org.onap.appc.listener.LCM.impl.ListenerImpl.class);
listeners.add(clLCMProps);
@@ -194,8 +185,14 @@ public class AppcEventListenerActivator implements BundleActivator {
private boolean isAppcOamPropsListenerEnabled(ListenerProperties listenerProperties) {
final Properties appcOamProperties = listenerProperties.getProperties();
- return appcOamProperties == null
- || !Boolean.parseBoolean(appcOamProperties.getProperty(
- ListenerProperties.KEYS.DISABLED.getPropertySuffix()));
+ boolean result;
+ if (appcOamProperties == null) {
+ result = true;
+ } else {
+ result = !Boolean.parseBoolean(appcOamProperties.getProperty(
+ ListenerProperties.KEYS.DISABLED.getPropertySuffix()));
+ }
+
+ return result;
}
}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/operation/ProviderOperations.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/operation/ProviderOperations.java
index d3ac83d1b..0e7044930 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/operation/ProviderOperations.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/operation/ProviderOperations.java
@@ -66,7 +66,7 @@ import java.security.cert.X509Certificate;
public class ProviderOperations {
- private static final EELFLogger LOG = EELFManager.getInstance().getLogger(ProviderOperations.class);
+ private final EELFLogger LOG = EELFManager.getInstance().getLogger(ProviderOperations.class);
private URL url;
private String basic_auth;
@@ -182,32 +182,35 @@ public class ProviderOperations {
@SuppressWarnings("deprecation")
private HttpClient getHttpClient() throws APPCException {
HttpClient client;
- if (url.getProtocol().equals("https")) {
- try {
- KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
- trustStore.load(null, null);
- MySSLSocketFactory sf = new MySSLSocketFactory(trustStore);
- sf.setHostnameVerifier(MySSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
-
- HttpParams params = new BasicHttpParams();
- HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
- HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
-
- SchemeRegistry registry = new SchemeRegistry();
- registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
- registry.register(new Scheme("https", sf, 443));
- registry.register(new Scheme("https", sf, 8443));
- registry.register(new Scheme("http", sf, 8181));
-
- ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);
- client = new DefaultHttpClient(ccm, params);
- } catch (Exception e) {
+ switch (url.getProtocol()) {
+ case "https":
+ try {
+ KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
+ trustStore.load(null, null);
+ MySSLSocketFactory sf = new MySSLSocketFactory(trustStore);
+ sf.setHostnameVerifier(MySSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+
+ HttpParams params = new BasicHttpParams();
+ HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
+ HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
+
+ SchemeRegistry registry = new SchemeRegistry();
+ registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
+ registry.register(new Scheme("https", sf, 443));
+ registry.register(new Scheme("https", sf, 8443));
+ registry.register(new Scheme("http", sf, 8181));
+
+ ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);
+ client = new DefaultHttpClient(ccm, params);
+ } catch (Exception e) {
+ client = new DefaultHttpClient();
+ }
+ break;
+ case "http":
client = new DefaultHttpClient();
- }
- } else if (url.getProtocol().equals("http")) {
- client = new DefaultHttpClient();
- } else {
- throw new APPCException(
+ break;
+ default:
+ throw new APPCException(
"The provider.topology.url property is invalid. The url did not start with http[s]");
}
return client;
@@ -243,7 +246,7 @@ public class ProviderOperations {
@Override
public Socket createSocket(Socket socket, String host, int port, boolean autoClose)
- throws IOException, UnknownHostException {
+ throws IOException {
return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
}
@@ -254,10 +257,7 @@ public class ProviderOperations {
}
public static boolean isSucceeded(Integer code) {
- if (code == null) {
- return false;
- }
- return ((code == 100) || (code == 400)); // only 100 & 400 statuses are success
+ return code != null && ((code == 100) || (code == 400));
}
}
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 7908d3a1b..2f5a6a0f5 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
@@ -182,9 +182,9 @@ public class ListenerProperties {
* as well.<br>
* Examples:
* <ul>
- * <li>server1.appc.openecomp.org</li>
- * <li>server1.appc.openecomp.org:3904</li>
- * <li>server1.appc.openecomp.org,server2.appc.openecomp.org</li>
+ * <li>server1.appc.onap.org</li>
+ * <li>server1.appc.onap.org:3904</li>
+ * <li>server1.appc.onap.org,server2.appc.onap.org</li>
* </ul>
*/
HOSTS("poolMembers"),
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/ControllerImpl.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/ControllerImpl.java
index b830b6fc7..143ec6219 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/ControllerImpl.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/ControllerImpl.java
@@ -115,10 +115,21 @@ public class ControllerImpl implements Controller {
}
itr.remove();
}
+ // disable new tasks from being submitted
executor.shutdown();
+ int timeout=300;
try {
- executor.awaitTermination(10, TimeUnit.SECONDS);
+ if (!executor.awaitTermination(timeout, TimeUnit.SECONDS)) {
+ LOG.error("Not all tasks completed execution after " + timeout + " seconds. " +
+ "Attempting to stop all actively executing tasks.");
+ executor.shutdownNow();
+ }
+ if (!executor.awaitTermination(timeout, TimeUnit.SECONDS)) {
+ LOG.error("Could not terminate all tasks after " + (timeout*2) + " seconds.");
+ }
} catch (InterruptedException e) {
+ executor.shutdownNow();
+ Thread.currentThread().interrupt();
}
}
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 85ce93001..4b4959725 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
@@ -26,6 +26,8 @@ package org.onap.appc.listener.impl;
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;