From ece674df14c8ecf818438c3bc6626a104cf9c305 Mon Sep 17 00:00:00 2001 From: efiacor Date: Fri, 21 Oct 2022 14:33:48 +0100 Subject: [SDC-DIST] Remove msgBusAddress config Update javadocs for specific interfaces Add javadoc build for maven storage Signed-off-by: efiacor Change-Id: I603c6162079e19b431e10c9489aef45c15ce181c Issue-ID: DMAAP-1745 --- pom.xml | 13 +++- .../test/core/config/DistributionClientConfig.java | 8 --- sdc-distribution-client/pom.xml | 2 +- .../java/org/onap/sdc/api/IDistributionClient.java | 46 ++++++++------ .../org/onap/sdc/api/consumer/IConfiguration.java | 54 ++++++++-------- .../main/java/org/onap/sdc/impl/Configuration.java | 74 +++++++++++----------- .../org/onap/sdc/utils/kafka/SdcKafkaConsumer.java | 4 ++ .../org/onap/sdc/utils/kafka/SdcKafkaProducer.java | 13 +++- .../java/org/onap/sdc/utils/TestConfiguration.java | 5 -- 9 files changed, 118 insertions(+), 101 deletions(-) diff --git a/pom.xml b/pom.xml index bb52ff0..694d402 100644 --- a/pom.xml +++ b/pom.xml @@ -136,6 +136,7 @@ + org.apache.maven.plugins maven-checkstyle-plugin @@ -196,7 +197,17 @@ org.apache.maven.plugins maven-javadoc-plugin ${maven-javadoc-plugin.version} - + + false + + + + attach-javadocs + + jar + + + org.sonarsource.scanner.maven diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/core/config/DistributionClientConfig.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/config/DistributionClientConfig.java index 5a902c8..3f002a3 100644 --- a/sdc-distribution-ci/src/main/java/org/onap/test/core/config/DistributionClientConfig.java +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/config/DistributionClientConfig.java @@ -95,14 +95,6 @@ public class DistributionClientConfig implements IConfiguration { return sdcAddress; } - public List getMsgBusAddress() { - return msgBusAddress; - } - - public void setMsgBusAddress(List msgBusAddress) { - this.msgBusAddress = msgBusAddress; - } - @Override public String getUser() { return user; diff --git a/sdc-distribution-client/pom.xml b/sdc-distribution-client/pom.xml index 3d1ebbd..a96f39f 100644 --- a/sdc-distribution-client/pom.xml +++ b/sdc-distribution-client/pom.xml @@ -19,7 +19,7 @@ 3.6.28 2.8.0 1.7.30 - 2.5.2 + 2.8.6 3.3.1 2.8.9 1.18.24 diff --git a/sdc-distribution-client/src/main/java/org/onap/sdc/api/IDistributionClient.java b/sdc-distribution-client/src/main/java/org/onap/sdc/api/IDistributionClient.java index ac48419..1115c91 100644 --- a/sdc-distribution-client/src/main/java/org/onap/sdc/api/IDistributionClient.java +++ b/sdc-distribution-client/src/main/java/org/onap/sdc/api/IDistributionClient.java @@ -76,16 +76,18 @@ public interface IDistributionClient { /** * Downloads an artifact from SDC Catalog
* - * @param artifactInfo + * @param artifactInfo - the info about the Artifact to be downloaded * @return IDistributionClientDownloadResult */ IDistributionClientDownloadResult download(IArtifactInfo artifactInfo); /** * Initialize the distribution client
- * - get MessageBus server list from configuration
+ * - validate the config
+ * - set up the SDC connector
* - validate artifact types against sdc server
* - set the notification callback
+ * - get and set up the Kafka endpoint and topics
* - set up notification sender
*

* Note: all configuration fields are mandatory.
@@ -93,17 +95,19 @@ public interface IDistributionClient { * ONAP-Component MUST store password as SHA-2 (256) hashed with * dynamically generated salt value
* - * @param conf - * @param callback + * @param conf - contains configuration + * @param callback - the NotificationCallback logic * @return IDistributionClientResult */ IDistributionClientResult init(IConfiguration conf, INotificationCallback callback); /** * Initialize the distribution client
- * - get MessageBus server list from configuration
+ * - validate the config
+ * - set up the SDC connector
* - validate artifact types against sdc server
* - set the notification callback
+ * - get and set up the Kafka endpoint and topics
* - set up notification sender
*

* Note: all configuration fields are mandatory.
@@ -111,9 +115,9 @@ public interface IDistributionClient { * ONAP-Component MUST store password as SHA-2 (256) hashed with * dynamically generated salt value
* - * @param conf - * @param notificationCallback - * @param statusCallback + * @param conf - contains configuration + * @param notificationCallback - the NotificationCallback logic + * @param statusCallback - the StatusCallback logic * @return IDistributionClientResult */ IDistributionClientResult init(IConfiguration conf, INotificationCallback notificationCallback, @@ -123,7 +127,7 @@ public interface IDistributionClient { * Build and publish Distribution Download Status event to Distribution * Status Topic * - * @param statusMessage + * @param statusMessage - the status message to be published * @return IDistributionClientResult */ IDistributionClientResult sendDownloadStatus(IDistributionStatusMessage statusMessage); @@ -132,8 +136,8 @@ public interface IDistributionClient { * Build and publish Distribution Download Status event to Distribution * Status Topic With Error Reason. * - * @param statusMessage - * @param errorReason + * @param statusMessage - the status message to be published + * @param errorReason - the error details * @return IDistributionClientResult */ IDistributionClientResult sendDownloadStatus(IDistributionStatusMessage statusMessage, String errorReason); @@ -142,7 +146,7 @@ public interface IDistributionClient { * Build and publish Distribution Deployment Status event to Distribution * Status Topic * - * @param statusMessage + * @param statusMessage - the status message to be published * @return IDistributionClientResult */ IDistributionClientResult sendDeploymentStatus(IDistributionStatusMessage statusMessage); @@ -151,8 +155,8 @@ public interface IDistributionClient { * Build and publish Distribution Deployment Status event to Distribution * Status Topic With Error Reason. * - * @param statusMessage - * @param errorReason + * @param statusMessage - the status message to be published + * @param errorReason - the error details * @return IDistributionClientResult */ IDistributionClientResult sendDeploymentStatus(IDistributionStatusMessage statusMessage, String errorReason); @@ -161,7 +165,7 @@ public interface IDistributionClient { * Build and publish Distribution Component Status event to Distribution * Status Topic * - * @param statusMessage + * @param statusMessage - the status message to be published * @return IDistributionClientResult */ IDistributionClientResult sendComponentDoneStatus(IComponentDoneStatusMessage statusMessage); @@ -170,8 +174,8 @@ public interface IDistributionClient { * Build and publish Distribution Component Status event to Distribution * Status Topic With Error Reason. * - * @param statusMessage - * @param errorReason + * @param statusMessage - the status message to be published + * @param errorReason - the error details * @return IDistributionClientResult */ IDistributionClientResult sendComponentDoneStatus(IComponentDoneStatusMessage statusMessage, String errorReason); @@ -181,7 +185,7 @@ public interface IDistributionClient { * Build and publish Distribution Final Status event to Distribution * Status Topic * - * @param statusMessage + * @param statusMessage - the status message to be published * @return IDistributionClientResult */ IDistributionClientResult sendFinalDistrStatus(IFinalDistrStatusMessage statusMessage); @@ -191,8 +195,8 @@ public interface IDistributionClient { * Build and publish Distribution Final Status event to Distribution * Status Topic With Error Reason. * - * @param statusMessage - * @param errorReason + * @param statusMessage - the status message to be published + * @param errorReason - the error details * @return IDistributionClientResult */ IDistributionClientResult sendFinalDistrStatus(IFinalDistrStatusMessage statusMessage, String errorReason); @@ -204,7 +208,7 @@ public interface IDistributionClient { * @deprecated Method is deprecated due to VF Module changes. Only backward * compatibility is supported.
* - * @param artifactPayload + * @param artifactPayload - the payload of artifact data * @return IVfModuleMetadata list */ @Deprecated diff --git a/sdc-distribution-client/src/main/java/org/onap/sdc/api/consumer/IConfiguration.java b/sdc-distribution-client/src/main/java/org/onap/sdc/api/consumer/IConfiguration.java index 84eb42b..184dca4 100644 --- a/sdc-distribution-client/src/main/java/org/onap/sdc/api/consumer/IConfiguration.java +++ b/sdc-distribution-client/src/main/java/org/onap/sdc/api/consumer/IConfiguration.java @@ -34,27 +34,28 @@ public interface IConfiguration { String getSdcAddress(); /** - * SDC Distribution Addresses from ONAP Component Values need to be set from - * impl - */ - List getMsgBusAddress(); - - /** - * Kafka security.protocol + * Kafka security protocol to be used by the client to Auth towards the kafka cluster + * + * @return Kafka security.protocol. Default is SASL_PLAINTEXT */ default String getKafkaSecurityProtocolConfig() { return System.getenv().getOrDefault("SECURITY_PROTOCOL", "SASL_PLAINTEXT"); } /** - * Kafka sasl.mechanism + * Kafka SASL mechanism to be used by the client to Auth towards the kafka cluster + * + * @return Kafka sasl.mechanism. Default is SCRAM-SHA-512 */ default String getKafkaSaslMechanism() { return System.getenv().getOrDefault("SASL_MECHANISM", "SCRAM-SHA-512"); } /** - * Kafka sasl.jaas.config + * Kafka JAAS config to be used by the client to Auth towards the kafka cluster. + * If overridden, must align with sasl.jaas.config convention set out by the sasl.mechanism being used + * otherwise, mandatory setting of the environment variable SASL_JAAS_CONFIG is required to provide default behaviour + * @return Kafka sasl.jaas.config */ default String getKafkaSaslJaasConfig() { String saslJaasConfFromEnv = System.getenv("SASL_JAAS_CONFIG"); @@ -77,7 +78,7 @@ public interface IConfiguration { * default (HTTPS) behavior will be applied. If set to false, distribution * client will use HTTP when connecting to SDC. * - * @return + * @return default is true */ default Boolean isUseHttpsWithSDC() { return true; @@ -116,8 +117,7 @@ public interface IConfiguration { List getRelevantArtifactTypes(); /** - * Returns the consumer group defined for this component, if no consumer - * group is defined return null. + * Returns the kafka consumer group defined for this component. * * @return SdcKafkaConsumer group. */ @@ -127,14 +127,14 @@ public interface IConfiguration { * Returns the environment name (testing, production etc...). Can Be * reconfigured in runtime. * - * @return + * @return Environment name */ String getEnvironmentName(); /** - * Unique ID of component instance (e.x INSTAR name). + * Returns the kafka consumer id defined for this component. * - * @return + * @return SdcKafkaConsumer id. */ String getConsumerID(); @@ -143,12 +143,14 @@ public interface IConfiguration { * the SDC's public key (e.g /etc/keystore/sdc-client.jks) file will be * deployed with sdc-distribution jar. * - * @return + * @return Client's Key store path */ String getKeyStorePath(); /** - * @return Returns client's Key Store password + * Return the password for the Client's Key Store + * + * @return Client's Key Store password */ String getKeyStorePassword(); @@ -156,7 +158,7 @@ public interface IConfiguration { * Sets whether SDC server TLS authentication is activated. If set to false, Key * Store path and password are not needed to be set. * - * @return + * @return true by default */ boolean activateServerTLSAuth(); @@ -169,12 +171,12 @@ public interface IConfiguration { * Setting the method to false will activate the legacy behavior, in which empty * resources are not part of the notification.
* - * @return + * @return true or false */ boolean isFilterInEmptyResources(); /** - * By default, (false value) Distribution Client will trigger the regular + * By default: false. Distribution Client will trigger the regular * registration towards SDC (register component as consumer to the * SDC-DISTR-NOTIF-TOPIC-[ENV] topic and register component as producer to the * SDC-DISTR-STATUS-TOPIC-[ENV]).
@@ -182,7 +184,7 @@ public interface IConfiguration { * this component request to be consumer and producer of the * SDC-DISTR-STATUS-TOPIC-[ENV] topic.
* - * @return + * @return false by default */ default boolean isConsumeProduceStatusTopic() { return false; @@ -193,7 +195,7 @@ public interface IConfiguration { * available proxies from JVM arguments. If set to false, distribution client * will use proxy parameters configured through properties file. * - * @return + * @return false by default */ default Boolean isUseSystemProxy() { return false; @@ -205,7 +207,7 @@ public interface IConfiguration { * Client will register the proxy configuration with the HttpClient instance * using HTTP and route requests through the proxy. * - * @return + * @return Hostname of the http proxy */ String getHttpProxyHost(); @@ -216,7 +218,7 @@ public interface IConfiguration { * register the proxy configuration with the HttpClient instance using HTTP and * route requests through the proxy. * - * @return + * @return Port of the http proxy */ int getHttpProxyPort(); @@ -226,7 +228,7 @@ public interface IConfiguration { * Client will register the proxy configuration with the HttpClient instance * using HTTPS and route requests through the proxy. * - * @return + * @return Hostname of the https proxy */ String getHttpsProxyHost(); @@ -237,7 +239,7 @@ public interface IConfiguration { * register the proxy configuration with the HttpClient instance using HTTPS and * route requests through the proxy. * - * @return + * @return Port of the https proxy */ int getHttpsProxyPort(); } diff --git a/sdc-distribution-client/src/main/java/org/onap/sdc/impl/Configuration.java b/sdc-distribution-client/src/main/java/org/onap/sdc/impl/Configuration.java index db4433b..24f3225 100644 --- a/sdc-distribution-client/src/main/java/org/onap/sdc/impl/Configuration.java +++ b/sdc-distribution-client/src/main/java/org/onap/sdc/impl/Configuration.java @@ -23,7 +23,6 @@ package org.onap.sdc.impl; import java.util.List; import org.onap.sdc.api.consumer.IConfiguration; -import org.onap.sdc.utils.DistributionClientConstants; public class Configuration implements IConfiguration { @@ -36,8 +35,8 @@ public class Configuration implements IConfiguration { private String sdcAddress; private String user; private String password; - private int pollingInterval = DistributionClientConstants.MIN_POLLING_INTERVAL_SEC; - private int pollingTimeout = DistributionClientConstants.POLLING_TIMEOUT_SEC; + private int pollingInterval; + private int pollingTimeout; private List relevantArtifactTypes; private String consumerGroup; private String environmentName; @@ -85,31 +84,6 @@ public class Configuration implements IConfiguration { return sdcAddress; } - public String getStatusTopicName() { - return sdcStatusTopicName; - } - - public void setStatusTopicName(String sdcStatusTopicName) { - this.sdcStatusTopicName = sdcStatusTopicName; - } - - public String getNotificationTopicName() { - return sdcNotificationTopicName; - } - - public void setNotificationTopicName(String sdcNotificationTopicName) { - this.sdcNotificationTopicName = sdcNotificationTopicName; - } - - @Override - public List getMsgBusAddress() { - return msgBusAddressList; - } - - public void setMsgBusAddress(List newMsgBusAddress) { - msgBusAddressList = newMsgBusAddress; - } - @Override public String getKafkaSecurityProtocolConfig() { return kafkaSecurityProtocolConfig; @@ -205,6 +179,40 @@ public class Configuration implements IConfiguration { return useSystemProxy; } + @Override + public boolean activateServerTLSAuth() { + return this.activateServerTLSAuth; + } + + @Override + public boolean isFilterInEmptyResources() { + return this.filterInEmptyResources; + } + + public String getStatusTopicName() { + return sdcStatusTopicName; + } + + public void setStatusTopicName(String sdcStatusTopicName) { + this.sdcStatusTopicName = sdcStatusTopicName; + } + + public String getNotificationTopicName() { + return sdcNotificationTopicName; + } + + public void setNotificationTopicName(String sdcNotificationTopicName) { + this.sdcNotificationTopicName = sdcNotificationTopicName; + } + + public List getMsgBusAddress() { + return msgBusAddressList; + } + + public void setMsgBusAddress(List newMsgBusAddress) { + msgBusAddressList = newMsgBusAddress; + } + public void setComsumerID(String comsumerID) { this.comsumerID = comsumerID; } @@ -273,16 +281,6 @@ public class Configuration implements IConfiguration { this.useSystemProxy = useSystemProxy; } - @Override - public boolean activateServerTLSAuth() { - return this.activateServerTLSAuth; - } - - @Override - public boolean isFilterInEmptyResources() { - return this.filterInEmptyResources; - } - public void setUseHttpsWithSDC(boolean useHttpsWithSDC) { this.useHttpsWithSDC = useHttpsWithSDC; } diff --git a/sdc-distribution-client/src/main/java/org/onap/sdc/utils/kafka/SdcKafkaConsumer.java b/sdc-distribution-client/src/main/java/org/onap/sdc/utils/kafka/SdcKafkaConsumer.java index 71f793d..91b41a9 100644 --- a/sdc-distribution-client/src/main/java/org/onap/sdc/utils/kafka/SdcKafkaConsumer.java +++ b/sdc-distribution-client/src/main/java/org/onap/sdc/utils/kafka/SdcKafkaConsumer.java @@ -94,6 +94,10 @@ public class SdcKafkaConsumer { return msgs; } + /** + * + * @return The topic being polled by the consumer + */ public String getTopicName() { return topicName; } diff --git a/sdc-distribution-client/src/main/java/org/onap/sdc/utils/kafka/SdcKafkaProducer.java b/sdc-distribution-client/src/main/java/org/onap/sdc/utils/kafka/SdcKafkaProducer.java index 9826f8b..19338fc 100644 --- a/sdc-distribution-client/src/main/java/org/onap/sdc/utils/kafka/SdcKafkaProducer.java +++ b/sdc-distribution-client/src/main/java/org/onap/sdc/utils/kafka/SdcKafkaProducer.java @@ -45,6 +45,10 @@ public class SdcKafkaProducer { private final List msgBusAddresses; private final String topicName; + /** + * + * @param configuration The config provided to the client + */ public SdcKafkaProducer(Configuration configuration) { Properties props = new Properties(); props.put(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, configuration.getMsgBusAddress()); @@ -76,8 +80,9 @@ public class SdcKafkaProducer { } return data; } + /** - * + * Flush accumulated records in producer */ public void flush() { try { @@ -88,10 +93,16 @@ public class SdcKafkaProducer { } } + /** + * @return The list kafka endpoints + */ public List getMsgBusAddresses() { return msgBusAddresses; } + /** + * @return The topic name being published to + */ public String getTopicName() { return topicName; } diff --git a/sdc-distribution-client/src/test/java/org/onap/sdc/utils/TestConfiguration.java b/sdc-distribution-client/src/test/java/org/onap/sdc/utils/TestConfiguration.java index c2fc536..86f29be 100644 --- a/sdc-distribution-client/src/test/java/org/onap/sdc/utils/TestConfiguration.java +++ b/sdc-distribution-client/src/test/java/org/onap/sdc/utils/TestConfiguration.java @@ -110,11 +110,6 @@ public class TestConfiguration implements IConfiguration { return sdcAddress; } - @Override - public List getMsgBusAddress() { - return msgBusAddress; - } - @Override public String getKafkaSecurityProtocolConfig() { return kafkaSecurityProtocolConfig; -- cgit 1.2.3-korg