[SDC-DIST] Upgrade sdc-distro-client to v 2.0.0 40/132040/1
authorefiacor <fiachra.corcoran@est.tech>
Tue, 8 Nov 2022 10:26:11 +0000 (10:26 +0000)
committerefiacor <fiachra.corcoran@est.tech>
Tue, 8 Nov 2022 10:28:21 +0000 (10:28 +0000)
Signed-off-by: efiacor <fiachra.corcoran@est.tech>
Issue-ID: DMAAP-1800
Change-Id: Idcfa147dd07a18953972b85f38ec2d46ba3fc009

12 files changed:
Readme.md
appconfig-local/model-loader.properties
pom.xml
src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java
src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java
src/test/java/org/onap/aai/modelloader/config/TestModelLoaderConfig.java
src/test/java/org/onap/aai/modelloader/service/TestModelLoaderServiceWithSdc.java
src/test/resources/model-loader-empty-auth-password.properties
src/test/resources/model-loader-no-auth-password.properties
src/test/resources/model-loader.properties
src/test/resources/sdc_test/model-loader.properties
version.properties

index 3d7aaae..5aa1733 100644 (file)
--- a/Readme.md
+++ b/Readme.md
@@ -54,10 +54,10 @@ _model-loader.properties_
     # Address/port of the SDC
     ml.distribution.ASDC_ADDRESS=<SDC-Hostname>:8443
     
-    # DMaaP consumer group.  
+    # Kafka consumer group.  
     ml.distribution.CONSUMER_GROUP=aai-ml-group
     
-    # DMaaP consumer ID
+    # Kafka consumer ID
     ml.distribution.CONSUMER_ID=aai-ml
     
     # SDC Environment Name.  This must match the environment name configured on the SDC
@@ -73,10 +73,10 @@ _model-loader.properties_
     # obfuscate the cleartext password:  http://www.eclipse.org/jetty/documentation/9.4.x/configuring-security-secure-passwords.html
     ml.distribution.PASSWORD=OBF:<password>
     
-    # How often (in seconds) to poll the DMaaP cluster for new model events
+    # How often (in seconds) to poll the Kafka topic for new model events
     ml.distribution.POLLING_INTERVAL=<integer>
     
-    # Timeout value (in seconds) when polling DMaaP for new model events
+    # Timeout value (in seconds) when polling the Kafka topic for new model events
     ml.distribution.POLLING_TIMEOUT=<integer>
     
     # Username to use when connecting to the SDC
@@ -84,9 +84,6 @@ _model-loader.properties_
     
     # Artifact type we want to download from the SDC (the values below will typically suffice)
     ml.distribution.ARTIFACT_TYPES=MODEL_QUERY_SPEC,TOSCA_CSAR
-    
-    # List of message bus addresses on which to listen for distribution events
-    ml.distribution.MSG_BUS_ADDRESSES=<host1>,<host2>
 
     # URL of the A&AI
     ml.aai.BASE_URL=https://<AAI-Hostname>:8443
index b2234d6..61448f1 100644 (file)
@@ -5,7 +5,6 @@
 # Model Loader Distribution Client Configuration
 ml.distribution.ACTIVE_SERVER_TLS_AUTH=false
 ml.distribution.ASDC_ADDRESS=<ASDC_HOST_NAME>:8443
-ml.distribution.MSG_BUS_ADDRESSES=localhost
 ml.distribution.CONSUMER_GROUP=<CONSUMER_GROUP>
 ml.distribution.CONSUMER_ID=<CONSUMER_ID>
 ml.distribution.ENVIRONMENT_NAME=<ENV>
diff --git a/pom.xml b/pom.xml
index 70428eb..bfa539b 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -33,7 +33,7 @@
        <groupId>org.onap.aai.model-loader</groupId>
        <artifactId>model-loader</artifactId>
        <name>aai-model-loader</name>
-       <version>1.11.0-SNAPSHOT</version>
+       <version>1.12.0-SNAPSHOT</version>
 
        <dependencyManagement>
                <dependencies>
@@ -57,7 +57,7 @@
                <hamcrest-all.version>1.3</hamcrest-all.version>
                <babel.version>1.11.0</babel.version>
                <aai.rest.client.version>1.2.1</aai.rest.client.version>
-               <sdc-distribution-client.version>1.4.1</sdc-distribution-client.version>
+               <sdc-distribution-client.version>2.0.0</sdc-distribution-client.version>
                <logback.version>1.2.3</logback.version>
                <!-- docker related properties -->
                <docker.fabric.version>0.39.0</docker.fabric.version>
                        </build>
                </profile>
        </profiles>
-
        <dependencies>
                <dependency>
                        <groupId>org.springframework.boot</groupId>
                                </exclusion>
                        </exclusions>
                </dependency>
+               <dependency>
+                       <groupId>org.apache.kafka</groupId>
+                       <artifactId>kafka-clients</artifactId>
+                       <version>3.3.1</version>
+               </dependency>
                <dependency>
                        <groupId>org.onap.aai</groupId>
                        <artifactId>babel</artifactId>
index f8c5d23..77693bc 100644 (file)
@@ -31,6 +31,7 @@ import java.util.Properties;
 import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jetty.util.security.Password;
 import org.onap.sdc.api.consumer.IConfiguration;
+import org.springframework.core.env.Environment;
 
 /**
  * Properties for the Model Loader
@@ -72,11 +73,10 @@ public class ModelLoaderConfig implements IConfiguration {
     protected static final String PROP_ML_DISTRIBUTION_POLLING_TIMEOUT = PREFIX_DISTRIBUTION_CLIENT + "POLLING_TIMEOUT";
     protected static final String PROP_ML_DISTRIBUTION_USER = PREFIX_DISTRIBUTION_CLIENT + "USER";
     protected static final String PROP_ML_DISTRIBUTION_ARTIFACT_TYPES = PREFIX_DISTRIBUTION_CLIENT + "ARTIFACT_TYPES";
-    protected static final String PROP_ML_DISTRIBUTION_MSG_BUS_ADDRESSES =
-            PREFIX_DISTRIBUTION_CLIENT + "MSG_BUS_ADDRESSES";
-    protected static final String PROP_ML_DISTRIBUTION_HTTPS_WITH_DMAAP =
-            PREFIX_DISTRIBUTION_CLIENT + "USE_HTTPS_WITH_DMAAP";
-
+    protected static final String PROP_ML_DISTRIBUTION_HTTP_PROXY_HOST = PREFIX_DISTRIBUTION_CLIENT + "HTTP_PROXY_HOST";
+    protected static final String PROP_ML_DISTRIBUTION_HTTP_PROXY_PORT = PREFIX_DISTRIBUTION_CLIENT + "HTTP_PROXY_PORT";
+    protected static final String PROP_ML_DISTRIBUTION_HTTPS_PROXY_HOST = PREFIX_DISTRIBUTION_CLIENT + "HTTPS_PROXY_HOST";
+    protected static final String PROP_ML_DISTRIBUTION_HTTPS_PROXY_PORT = PREFIX_DISTRIBUTION_CLIENT + "HTTPS_PROXY_PORT";
     protected static final String PROP_AAI_BASE_URL = PREFIX_AAI + "BASE_URL";
     protected static final String PROP_AAI_KEYSTORE_FILE = PREFIX_AAI + SUFFIX_KEYSTORE_FILE;
     protected static final String PROP_AAI_KEYSTORE_PASSWORD = PREFIX_AAI + SUFFIX_KEYSTORE_PASS;
@@ -101,8 +101,7 @@ public class ModelLoaderConfig implements IConfiguration {
     private static String configHome;
     private Properties modelLoaderProperties = null;
     private String certLocation = ".";
-    private List<String> artifactTypes = new ArrayList<>();
-    private List<String> msgBusAddrs = new ArrayList<>();
+    private final List<String> artifactTypes = new ArrayList<>();
     private String modelVersion = null;
 
     public ModelLoaderConfig(Properties configProperties) {
@@ -126,12 +125,6 @@ public class ModelLoaderConfig implements IConfiguration {
         if (types != null) {
             artifactTypes.addAll(Arrays.asList(types.split(",")));
         }
-
-        // Get list of message bus addresses
-        String addresses = get(PROP_ML_DISTRIBUTION_MSG_BUS_ADDRESSES);
-        if (addresses != null) {
-            msgBusAddrs.addAll(Arrays.asList(addresses.split(",")));
-        }
     }
 
     public static void setConfigHome(String configHome) {
@@ -149,7 +142,7 @@ public class ModelLoaderConfig implements IConfiguration {
     }
 
     @Override
-    public String getAsdcAddress() {
+    public String getSdcAddress() {
         return get(PROP_ML_DISTRIBUTION_ASDC_ADDRESS);
     }
 
@@ -219,14 +212,23 @@ public class ModelLoaderConfig implements IConfiguration {
     }
 
     @Override
-    public Boolean isUseHttpsWithDmaap() {
-        String useHTTPS = get(PROP_ML_DISTRIBUTION_HTTPS_WITH_DMAAP);
-        return useHTTPS != null && Boolean.valueOf(useHTTPS);
+    public String getHttpProxyHost() {
+        return getPropertyOrNull(PROP_ML_DISTRIBUTION_HTTP_PROXY_HOST);
+    }
+
+    @Override
+    public int getHttpProxyPort() {
+        return getIntegerPropertyOrZero(PROP_ML_DISTRIBUTION_HTTP_PROXY_PORT);
     }
 
     @Override
-    public List<String> getMsgBusAddress() {
-        return msgBusAddrs;
+    public String getHttpsProxyHost() {
+        return getPropertyOrNull(PROP_ML_DISTRIBUTION_HTTPS_PROXY_HOST);
+    }
+
+    @Override
+    public int getHttpsProxyPort() {
+        return getIntegerPropertyOrZero(PROP_ML_DISTRIBUTION_HTTPS_PROXY_PORT);
     }
 
     public String getAaiKeyStorePath() {
@@ -376,4 +378,27 @@ public class ModelLoaderConfig implements IConfiguration {
         }
         return value;
     }
+
+    public String getPropertyOrNull(String propertyName) {
+        String value = modelLoaderProperties.getProperty(propertyName);
+        if (value == null || "NULL".equals(value) || value.isEmpty()) {
+            return null;
+        } else {
+            return value;
+        }
+    }
+
+    public int getIntegerPropertyOrZero(String propertyName) {
+        String property = modelLoaderProperties.getProperty(propertyName);
+        if (property == null || "NULL".equals(property) || property.isEmpty()) {
+            return 0;
+        } else {
+            try {
+                return Integer.parseInt(property);
+            } catch (NumberFormatException e) {
+                return 0;
+            }
+        }
+    }
+
 }
index 22f7671..dc17dfe 100644 (file)
@@ -63,7 +63,7 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/services/model-loader/v1/model-service")
 public class ModelLoaderService implements ModelLoaderInterface {
 
-    private static Logger logger = LoggerFactory.getInstance().getLogger(ModelLoaderService.class.getName());
+    private static final Logger logger = LoggerFactory.getInstance().getLogger(ModelLoaderService.class.getName());
 
     @Value("${CONFIG_HOME}")
     private String configDir;
@@ -84,21 +84,6 @@ public class ModelLoaderService implements ModelLoaderInterface {
         try (InputStream configInputStream = Files.newInputStream(Paths.get(configDir, "model-loader.properties"))) {
             configProperties.load(configInputStream);
             config = new ModelLoaderConfig(configProperties);
-            
-            // Set the truststore for SDC Client to connect to Dmaap central bus if applicable (as in case of TI)
-            if (Boolean.TRUE.equals(config.isUseHttpsWithDmaap())) {
-                String trustStorePath = config.getKeyStorePath();
-                String trustStorePassword = config.getKeyStorePassword();
-                if (trustStorePath != null && Paths.get(trustStorePath).toFile().isFile() && trustStorePassword != null
-                        && !trustStorePassword.isEmpty()) {
-                    System.setProperty("javax.net.ssl.trustStore", trustStorePath);
-                    System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
-                } else {
-                    throw new IllegalArgumentException("Model Loader property ml.distribution.KEYSTORE_FILE "
-                               + "or ml.distribution.KEYSTORE_PASSWORD not set or invalid");
-                }
-            }
-            
             if (!config.getASDCConnectionDisabled()) {
                 initSdcClient();
             }
index 5243ac5..e19b1e2 100644 (file)
@@ -59,19 +59,6 @@ public class TestModelLoaderConfig {
         assertEquals(3, types.size());
     }
 
-    @Test
-    public void testMsgBusAddrs() {
-        Properties props = new Properties();
-        props.setProperty("ml.distribution.MSG_BUS_ADDRESSES", "host1.onap.com:3904,host2.onap.com:3904");
-        ModelLoaderConfig config = new ModelLoaderConfig(props, null);
-
-        List<String> addrs = config.getMsgBusAddress();
-
-        assertEquals(2, addrs.size());
-        assertEquals(0, addrs.get(0).compareToIgnoreCase("host1.onap.com:3904"));
-        assertEquals(0, addrs.get(1).compareToIgnoreCase("host2.onap.com:3904"));
-    }
-
     @Test
     public void testDecryptPassword() {
         String password = "youshallnotpass";
index ff0614b..d23b3ef 100644 (file)
@@ -41,7 +41,7 @@ import org.springframework.test.context.junit4.SpringRunner;
  */
 @RunWith(SpringRunner.class)
 @SpringBootTest(classes = {ModelLoaderService.class, HttpsBabelServiceClientFactory.class})
-@TestPropertySource(properties = {"CONFIG_HOME=src/test/resources/sdc_test",})
+@TestPropertySource(properties = {"CONFIG_HOME=src/test/resources",})
 public class TestModelLoaderServiceWithSdc {
 
     @Autowired
index fabd855..0724a13 100644 (file)
@@ -1,7 +1,6 @@
 # Model Loader Distribution Client Configuration
 ml.distribution.ACTIVE_SERVER_TLS_AUTH=false
 ml.distribution.ASDC_ADDRESS=localhost:8443
-ml.distribution.MSG_BUS_ADDRESSES=localhost
 ml.distribution.CONSUMER_GROUP=aai-ml-group-test
 ml.distribution.CONSUMER_ID=aai-ml-id-test
 ml.distribution.ENVIRONMENT_NAME=env
index 96b24c8..b0ecf2b 100644 (file)
@@ -1,7 +1,6 @@
 # Model Loader Distribution Client Configuration
 ml.distribution.ACTIVE_SERVER_TLS_AUTH=false
 ml.distribution.ASDC_ADDRESS=localhost:8443
-ml.distribution.MSG_BUS_ADDRESSES=localhost
 ml.distribution.CONSUMER_GROUP=aai-ml-group-test
 ml.distribution.CONSUMER_ID=aai-ml-id-test
 ml.distribution.ENVIRONMENT_NAME=env
index 3ba1519..51a38c5 100644 (file)
@@ -1,7 +1,6 @@
 # Model Loader Distribution Client Configuration
 ml.distribution.ACTIVE_SERVER_TLS_AUTH=false
 ml.distribution.ASDC_ADDRESS=localhost:8443
-ml.distribution.MSG_BUS_ADDRESSES=localhost
 ml.distribution.CONSUMER_GROUP=aai-ml-group-test
 ml.distribution.CONSUMER_ID=aai-ml-id-test
 ml.distribution.ENVIRONMENT_NAME=env
index ee5c0ed..958931f 100644 (file)
@@ -1,7 +1,6 @@
 # Model Loader Distribution Client Configuration
 ml.distribution.ACTIVE_SERVER_TLS_AUTH=false
 ml.distribution.ASDC_ADDRESS=localhost:8443
-ml.distribution.MSG_BUS_ADDRESSES=localhost
 ml.distribution.CONSUMER_GROUP=aai-ml-group-test
 ml.distribution.CONSUMER_ID=aai-ml-id-test
 ml.distribution.ENVIRONMENT_NAME=env
index c287a8c..78f179d 100644 (file)
@@ -24,7 +24,7 @@
 # because they are used in Jenkins, whose plug-in doesn't support
 
 major=1
-minor=11
+minor=12
 patch=0
 
 base_version=${major}.${minor}.${patch}