Code synch up for appc-event-listener bundle 73/27873/4
authorSkip Wonnell <skip@att.com>
Wed, 10 Jan 2018 20:28:49 +0000 (14:28 -0600)
committerSkip Wonnell <skip@att.com>
Thu, 11 Jan 2018 01:29:14 +0000 (01:29 +0000)
Change-Id: I6362ba99c6e15b78c65a2e3bbcb841c78e8c606c
Issue-ID: APPC-382
Signed-off-by: Skip Wonnell <skip@att.com>
appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/AppcEventListenerActivator.java
appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/operation/ProviderOperations.java
appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/ListenerProperties.java
appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/ControllerImpl.java
appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/EventHandlerImpl.java

index 0b1eb53..a65b315 100644 (file)
@@ -79,11 +79,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
      */
@@ -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;
     }
 }
index d3ac83d..0e70449 100644 (file)
@@ -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));
     }
 
 }
index 7908d3a..2f5a6a0 100644 (file)
@@ -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"),
index b830b6f..143ec62 100644 (file)
@@ -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();
         }
     }
 
index 85ce930..4b49597 100644 (file)
@@ -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;