From 117237ac7b65395e0f29b6cead9f6ffec2e7dc0f Mon Sep 17 00:00:00 2001 From: efiacor Date: Tue, 8 Nov 2022 10:26:11 +0000 Subject: [PATCH] [SDC-DIST] Upgrade sdc-distro-client to v 2.0.0 Signed-off-by: efiacor Issue-ID: DMAAP-1800 Change-Id: Idcfa147dd07a18953972b85f38ec2d46ba3fc009 --- Readme.md | 11 ++-- appconfig-local/model-loader.properties | 1 - pom.xml | 10 ++-- .../aai/modelloader/config/ModelLoaderConfig.java | 63 +++++++++++++++------- .../modelloader/service/ModelLoaderService.java | 17 +----- .../modelloader/config/TestModelLoaderConfig.java | 13 ----- .../service/TestModelLoaderServiceWithSdc.java | 2 +- .../model-loader-empty-auth-password.properties | 1 - .../model-loader-no-auth-password.properties | 1 - src/test/resources/model-loader.properties | 1 - .../resources/sdc_test/model-loader.properties | 1 - version.properties | 2 +- 12 files changed, 58 insertions(+), 65 deletions(-) diff --git a/Readme.md b/Readme.md index 3d7aaae..5aa1733 100644 --- a/Readme.md +++ b/Readme.md @@ -54,10 +54,10 @@ _model-loader.properties_ # Address/port of the SDC ml.distribution.ASDC_ADDRESS=: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: - # 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= - # 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= # 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=, # URL of the A&AI ml.aai.BASE_URL=https://:8443 diff --git a/appconfig-local/model-loader.properties b/appconfig-local/model-loader.properties index b2234d6..61448f1 100644 --- a/appconfig-local/model-loader.properties +++ b/appconfig-local/model-loader.properties @@ -5,7 +5,6 @@ # Model Loader Distribution Client Configuration ml.distribution.ACTIVE_SERVER_TLS_AUTH=false ml.distribution.ASDC_ADDRESS=:8443 -ml.distribution.MSG_BUS_ADDRESSES=localhost ml.distribution.CONSUMER_GROUP= ml.distribution.CONSUMER_ID= ml.distribution.ENVIRONMENT_NAME= diff --git a/pom.xml b/pom.xml index 70428eb..bfa539b 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ org.onap.aai.model-loader model-loader aai-model-loader - 1.11.0-SNAPSHOT + 1.12.0-SNAPSHOT @@ -57,7 +57,7 @@ 1.3 1.11.0 1.2.1 - 1.4.1 + 2.0.0 1.2.3 0.39.0 @@ -214,7 +214,6 @@ - org.springframework.boot @@ -230,6 +229,11 @@ + + org.apache.kafka + kafka-clients + 3.3.1 + org.onap.aai babel diff --git a/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java b/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java index f8c5d23..77693bc 100644 --- a/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java +++ b/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java @@ -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 artifactTypes = new ArrayList<>(); - private List msgBusAddrs = new ArrayList<>(); + private final List 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 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; + } + } + } + } diff --git a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java index 22f7671..dc17dfe 100644 --- a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java +++ b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java @@ -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(); } diff --git a/src/test/java/org/onap/aai/modelloader/config/TestModelLoaderConfig.java b/src/test/java/org/onap/aai/modelloader/config/TestModelLoaderConfig.java index 5243ac5..e19b1e2 100644 --- a/src/test/java/org/onap/aai/modelloader/config/TestModelLoaderConfig.java +++ b/src/test/java/org/onap/aai/modelloader/config/TestModelLoaderConfig.java @@ -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 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"; diff --git a/src/test/java/org/onap/aai/modelloader/service/TestModelLoaderServiceWithSdc.java b/src/test/java/org/onap/aai/modelloader/service/TestModelLoaderServiceWithSdc.java index ff0614b..d23b3ef 100644 --- a/src/test/java/org/onap/aai/modelloader/service/TestModelLoaderServiceWithSdc.java +++ b/src/test/java/org/onap/aai/modelloader/service/TestModelLoaderServiceWithSdc.java @@ -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 diff --git a/src/test/resources/model-loader-empty-auth-password.properties b/src/test/resources/model-loader-empty-auth-password.properties index fabd855..0724a13 100644 --- a/src/test/resources/model-loader-empty-auth-password.properties +++ b/src/test/resources/model-loader-empty-auth-password.properties @@ -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 diff --git a/src/test/resources/model-loader-no-auth-password.properties b/src/test/resources/model-loader-no-auth-password.properties index 96b24c8..b0ecf2b 100644 --- a/src/test/resources/model-loader-no-auth-password.properties +++ b/src/test/resources/model-loader-no-auth-password.properties @@ -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 diff --git a/src/test/resources/model-loader.properties b/src/test/resources/model-loader.properties index 3ba1519..51a38c5 100644 --- a/src/test/resources/model-loader.properties +++ b/src/test/resources/model-loader.properties @@ -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 diff --git a/src/test/resources/sdc_test/model-loader.properties b/src/test/resources/sdc_test/model-loader.properties index ee5c0ed..958931f 100644 --- a/src/test/resources/sdc_test/model-loader.properties +++ b/src/test/resources/sdc_test/model-loader.properties @@ -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 diff --git a/version.properties b/version.properties index c287a8c..78f179d 100644 --- a/version.properties +++ b/version.properties @@ -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} -- 2.16.6