diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2018-08-10 14:45:45 -0400 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2018-08-13 10:17:19 -0400 |
commit | 269e543ba89dbf553fc66227f7123a302f56b5b4 (patch) | |
tree | b5ac0196770bc6669246953800dc832c6a1b3056 /policy-endpoints/src/main/java | |
parent | 637993a21e4826c36ac3dab256acf1510b824d82 (diff) |
Remove simple checkstyle
Mostly concentrated on the period at the end of summary.
But I did clear a few others for longer than 120 characters
and placement of methods next to each other. Possibly a few
others.
I did not clear everything, but will submit a few more
reviews to get the others.
Issue-ID: POLICY-881
Change-Id: I692a5349d686d52fee4040757cdc2ed8b5cc221b
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'policy-endpoints/src/main/java')
36 files changed, 514 insertions, 494 deletions
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/Topic.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/Topic.java index a6d70a1e..ff49a113 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/Topic.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/Topic.java @@ -27,60 +27,60 @@ import org.onap.policy.common.capabilities.Startable; /** - * Essential Topic Data + * Essential Topic Data. */ public interface Topic extends TopicRegisterable, Startable, Lockable { /** - * network logger + * network logger. */ public static final String NETWORK_LOGGER = "network"; /** - * Underlying Communication infrastructure Types + * Underlying Communication infrastructure Types. */ public enum CommInfrastructure { /** - * UEB Communication Infrastructure + * UEB Communication Infrastructure. */ UEB, /** - * DMAAP Communication Infrastructure + * DMAAP Communication Infrastructure. */ DMAAP, /** - * NOOP for internal use only + * NOOP for internal use only. */ NOOP, /** - * REST Communication Infrastructure + * REST Communication Infrastructure. */ REST } /** - * gets the topic name + * Gets the topic name. * * @return topic name */ public String getTopic(); /** - * gets the communication infrastructure type + * Gets the communication infrastructure type. * * @return */ public CommInfrastructure getTopicCommInfrastructure(); /** - * return list of servers + * Return list of servers. * * @return bus servers */ public List<String> getServers(); /** - * get the more recent events in this topic entity + * Get the more recent events in this topic entity. * * @return list of most recent events */ diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java index 4e2f4ecf..f4080b29 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java @@ -43,12 +43,12 @@ import org.slf4j.LoggerFactory; public interface TopicEndpoint extends Startable, Lockable { /** - * singleton for global access + * singleton for global access. */ public static final TopicEndpoint manager = new ProxyTopicEndpointManager(); /** - * Add Topic Sources to the communication infrastructure initialized per properties + * Add Topic Sources to the communication infrastructure initialized per properties. * * @param properties properties for Topic Source construction * @return a generic Topic Source @@ -57,7 +57,7 @@ public interface TopicEndpoint extends Startable, Lockable { public List<TopicSource> addTopicSources(Properties properties); /** - * Add Topic Sinks to the communication infrastructure initialized per properties + * Add Topic Sinks to the communication infrastructure initialized per properties. * * @param properties properties for Topic Sink construction * @return a generic Topic Sink @@ -66,14 +66,14 @@ public interface TopicEndpoint extends Startable, Lockable { public List<TopicSink> addTopicSinks(Properties properties); /** - * gets all Topic Sources + * Gets all Topic Sources. * * @return the Topic Source List */ List<TopicSource> getTopicSources(); /** - * get the Topic Sources for the given topic name + * Get the Topic Sources for the given topic name. * * @param topicNames the topic name * @@ -84,8 +84,8 @@ public interface TopicEndpoint extends Startable, Lockable { public List<TopicSource> getTopicSources(List<String> topicNames); /** - * gets the Topic Source for the given topic name and underlying communication infrastructure - * type + * Gets the Topic Source for the given topic name and underlying communication infrastructure + * type. * * @param commType communication infrastructure type * @param topicName the topic name @@ -99,7 +99,7 @@ public interface TopicEndpoint extends Startable, Lockable { public TopicSource getTopicSource(Topic.CommInfrastructure commType, String topicName); /** - * get the UEB Topic Source for the given topic name + * Get the UEB Topic Source for the given topic name. * * @param topicName the topic name * @@ -111,7 +111,7 @@ public interface TopicEndpoint extends Startable, Lockable { public UebTopicSource getUebTopicSource(String topicName); /** - * get the DMAAP Topic Source for the given topic name + * Get the DMAAP Topic Source for the given topic name. * * @param topicName the topic name * @@ -123,43 +123,48 @@ public interface TopicEndpoint extends Startable, Lockable { public DmaapTopicSource getDmaapTopicSource(String topicName); /** - * get the Topic Sinks for the given topic name + * Get the Topic Sinks for the given topic name. * * @param topicNames the topic names * @return the Topic Sink List - * @throws IllegalStateException - * @throws IllegalArgumentException */ public List<TopicSink> getTopicSinks(List<String> topicNames); /** - * get the Topic Sinks for the given topic name and underlying communication infrastructure type + * Get the Topic Sinks for the given topic name and all the underlying communication + * infrastructure type. * * @param topicName the topic name - * @param commType communication infrastructure type * * @return the Topic Sink List * @throws IllegalStateException if the entity is in an invalid state, for example multiple * TopicWriters for a topic name and communication infrastructure * @throws IllegalArgumentException if invalid parameters are present */ - public TopicSink getTopicSink(Topic.CommInfrastructure commType, String topicName); + public List<TopicSink> getTopicSinks(String topicName); + + /** + * Gets all Topic Sinks. + * + * @return the Topic Sink List + */ + public List<TopicSink> getTopicSinks(); /** - * get the Topic Sinks for the given topic name and all the underlying communication - * infrastructure type + * Get the Topic Sinks for the given topic name and underlying communication infrastructure type. * * @param topicName the topic name + * @param commType communication infrastructure type * * @return the Topic Sink List * @throws IllegalStateException if the entity is in an invalid state, for example multiple * TopicWriters for a topic name and communication infrastructure * @throws IllegalArgumentException if invalid parameters are present */ - public List<TopicSink> getTopicSinks(String topicName); + public TopicSink getTopicSink(Topic.CommInfrastructure commType, String topicName); /** - * get the UEB Topic Source for the given topic name + * Get the UEB Topic Source for the given topic name. * * @param topicName the topic name * @@ -171,7 +176,7 @@ public interface TopicEndpoint extends Startable, Lockable { public UebTopicSink getUebTopicSink(String topicName); /** - * get the no-op Topic Sink for the given topic name + * Get the no-op Topic Sink for the given topic name. * * @param topicName the topic name * @@ -183,7 +188,7 @@ public interface TopicEndpoint extends Startable, Lockable { public NoopTopicSink getNoopTopicSink(String topicName); /** - * get the DMAAP Topic Source for the given topic name + * Get the DMAAP Topic Source for the given topic name. * * @param topicName the topic name * @@ -195,42 +200,35 @@ public interface TopicEndpoint extends Startable, Lockable { public DmaapTopicSink getDmaapTopicSink(String topicName); /** - * gets only the UEB Topic Sources + * Gets only the UEB Topic Sources. * * @return the UEB Topic Source List */ public List<UebTopicSource> getUebTopicSources(); /** - * gets only the DMAAP Topic Sources + * Gets only the DMAAP Topic Sources. * * @return the DMAAP Topic Source List */ public List<DmaapTopicSource> getDmaapTopicSources(); /** - * gets all Topic Sinks - * - * @return the Topic Sink List - */ - public List<TopicSink> getTopicSinks(); - - /** - * gets only the UEB Topic Sinks + * Gets only the UEB Topic Sinks. * * @return the UEB Topic Sink List */ public List<UebTopicSink> getUebTopicSinks(); /** - * gets only the DMAAP Topic Sinks + * Gets only the DMAAP Topic Sinks. * * @return the DMAAP Topic Sink List */ public List<DmaapTopicSink> getDmaapTopicSinks(); /** - * gets only the NOOP Topic Sinks + * Gets only the NOOP Topic Sinks. * * @return the NOOP Topic Sinks List */ @@ -244,20 +242,20 @@ public interface TopicEndpoint extends Startable, Lockable { /** * This implementation of the Topic Endpoint Manager, proxies operations to appropriate - * implementations according to the communication infrastructure that are supported + * implementations according to the communication infrastructure that are supported. */ class ProxyTopicEndpointManager implements TopicEndpoint { /** - * Logger + * Logger. */ private static Logger logger = LoggerFactory.getLogger(ProxyTopicEndpointManager.class); /** - * Is this element locked? + * Is this element locked boolean. */ protected volatile boolean locked = false; /** - * Is this element alive? + * Is this element alive boolean. */ protected volatile boolean alive = false; @@ -311,6 +309,36 @@ class ProxyTopicEndpointManager implements TopicEndpoint { return sources; } + + @Override + public List<TopicSource> getTopicSources(List<String> topicNames) { + + if (topicNames == null) { + throw new IllegalArgumentException("must provide a list of topics"); + } + + final List<TopicSource> sources = new ArrayList<>(); + for (final String topic : topicNames) { + try { + final TopicSource uebSource = this.getUebTopicSource(topic); + if (uebSource != null) { + sources.add(uebSource); + } + } catch (final Exception e) { + logger.debug("No UEB source for topic: {}", topic, e); + } + + try { + final TopicSource dmaapSource = this.getDmaapTopicSource(topic); + if (dmaapSource != null) { + sources.add(dmaapSource); + } + } catch (final Exception e) { + logger.debug("No DMAAP source for topic: {}", topic, e); + } + } + return sources; + } @Override public List<TopicSink> getTopicSinks() { @@ -324,6 +352,74 @@ class ProxyTopicEndpointManager implements TopicEndpoint { return sinks; } + @Override + public List<TopicSink> getTopicSinks(List<String> topicNames) { + + if (topicNames == null) { + throw new IllegalArgumentException("must provide a list of topics"); + } + + final List<TopicSink> sinks = new ArrayList<>(); + for (final String topic : topicNames) { + try { + final TopicSink uebSink = this.getUebTopicSink(topic); + if (uebSink != null) { + sinks.add(uebSink); + } + } catch (final Exception e) { + logger.debug("No UEB sink for topic: {}", topic, e); + } + + try { + final TopicSink dmaapSink = this.getDmaapTopicSink(topic); + if (dmaapSink != null) { + sinks.add(dmaapSink); + } + } catch (final Exception e) { + logger.debug("No DMAAP sink for topic: {}", topic, e); + } + + try { + final TopicSink noopSink = this.getNoopTopicSink(topic); + if (noopSink != null) { + sinks.add(noopSink); + } + } catch (final Exception e) { + logger.debug("No NOOP sink for topic: {}", topic, e); + } + } + return sinks; + } + + @Override + public List<TopicSink> getTopicSinks(String topicName) { + if (topicName == null) { + throw parmException(topicName); + } + + final List<TopicSink> sinks = new ArrayList<>(); + + try { + sinks.add(this.getUebTopicSink(topicName)); + } catch (final Exception e) { + logNoSink(topicName, e); + } + + try { + sinks.add(this.getDmaapTopicSink(topicName)); + } catch (final Exception e) { + logNoSink(topicName, e); + } + + try { + sinks.add(this.getNoopTopicSink(topicName)); + } catch (final Exception e) { + logNoSink(topicName, e); + } + + return sinks; + } + @JsonIgnore @Override public List<UebTopicSource> getUebTopicSources() { @@ -412,6 +508,7 @@ class ProxyTopicEndpointManager implements TopicEndpoint { } /** + * Gets the endpoints. * * @return list of managed endpoints */ @@ -489,75 +586,6 @@ class ProxyTopicEndpointManager implements TopicEndpoint { } @Override - public List<TopicSource> getTopicSources(List<String> topicNames) { - - if (topicNames == null) { - throw new IllegalArgumentException("must provide a list of topics"); - } - - final List<TopicSource> sources = new ArrayList<>(); - for (final String topic : topicNames) { - try { - final TopicSource uebSource = this.getUebTopicSource(topic); - if (uebSource != null) { - sources.add(uebSource); - } - } catch (final Exception e) { - logger.debug("No UEB source for topic: {}", topic, e); - } - - try { - final TopicSource dmaapSource = this.getDmaapTopicSource(topic); - if (dmaapSource != null) { - sources.add(dmaapSource); - } - } catch (final Exception e) { - logger.debug("No DMAAP source for topic: {}", topic, e); - } - } - return sources; - } - - @Override - public List<TopicSink> getTopicSinks(List<String> topicNames) { - - if (topicNames == null) { - throw new IllegalArgumentException("must provide a list of topics"); - } - - final List<TopicSink> sinks = new ArrayList<>(); - for (final String topic : topicNames) { - try { - final TopicSink uebSink = this.getUebTopicSink(topic); - if (uebSink != null) { - sinks.add(uebSink); - } - } catch (final Exception e) { - logger.debug("No UEB sink for topic: {}", topic, e); - } - - try { - final TopicSink dmaapSink = this.getDmaapTopicSink(topic); - if (dmaapSink != null) { - sinks.add(dmaapSink); - } - } catch (final Exception e) { - logger.debug("No DMAAP sink for topic: {}", topic, e); - } - - try { - final TopicSink noopSink = this.getNoopTopicSink(topic); - if (noopSink != null) { - sinks.add(noopSink); - } - } catch (final Exception e) { - logger.debug("No NOOP sink for topic: {}", topic, e); - } - } - return sinks; - } - - @Override public TopicSource getTopicSource(Topic.CommInfrastructure commType, String topicName) { if (commType == null) { @@ -605,35 +633,6 @@ class ProxyTopicEndpointManager implements TopicEndpoint { } } - @Override - public List<TopicSink> getTopicSinks(String topicName) { - if (topicName == null) { - throw parmException(topicName); - } - - final List<TopicSink> sinks = new ArrayList<>(); - - try { - sinks.add(this.getUebTopicSink(topicName)); - } catch (final Exception e) { - logNoSink(topicName, e); - } - - try { - sinks.add(this.getDmaapTopicSink(topicName)); - } catch (final Exception e) { - logNoSink(topicName, e); - } - - try { - sinks.add(this.getNoopTopicSink(topicName)); - } catch (final Exception e) { - logNoSink(topicName, e); - } - - return sinks; - } - private void logNoSink(String topicName, Exception ex) { logger.debug("No sink for topic: {}", topicName, ex); } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicListener.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicListener.java index d1695d39..dd6eedd0 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicListener.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicListener.java @@ -21,18 +21,18 @@ package org.onap.policy.common.endpoints.event.comm; /** - * Listener for event messages entering the Policy Engine + * Listener for event messages entering the Policy Engine. */ @FunctionalInterface public interface TopicListener { - - /** - * Notification of a new Event over a given Topic - * - * @param commType communication infrastructure type - * @param topic topic name - * @param event event message as a string - */ - public void onTopicEvent(Topic.CommInfrastructure commType, String topic, String event); + + /** + * Notification of a new Event over a given Topic. + * + * @param commType communication infrastructure type + * @param topic topic name + * @param event event message as a string + */ + public void onTopicEvent(Topic.CommInfrastructure commType, String topic, String event); } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicRegisterable.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicRegisterable.java index c8bd0bd3..207ebc66 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicRegisterable.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicRegisterable.java @@ -21,22 +21,22 @@ package org.onap.policy.common.endpoints.event.comm; /** - * Marks a Topic entity as registerable + * Marks a Topic entity as registerable. */ public interface TopicRegisterable { - - /** - * Register for notification of events with this Topic Entity - * - * @param topicListener the listener of events - */ - public void register(TopicListener topicListener); - - /** - * Unregisters for notification of events with this Topic Entity - * - * @param topicListener the listener of events - */ - public void unregister(TopicListener topicListener); + + /** + * Register for notification of events with this Topic Entity. + * + * @param topicListener the listener of events + */ + public void register(TopicListener topicListener); + + /** + * Unregisters for notification of events with this Topic Entity. + * + * @param topicListener the listener of events + */ + public void unregister(TopicListener topicListener); } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicSink.java index 5127da9d..f36dfa31 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicSink.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicSink.java @@ -21,20 +21,20 @@ package org.onap.policy.common.endpoints.event.comm; /** - * Marks a given Topic Endpoint as able to send messages over a topic + * Marks a given Topic Endpoint as able to send messages over a topic. */ public interface TopicSink extends Topic { - - /** - * Sends a string message over this Topic Endpoint - * - * @param message message to send - * - * @return true if the send operation succeeded, false otherwise - * @throws IllegalArgumentException an invalid message has been provided - * @throws IllegalStateException the entity is in an state that prevents - * it from sending messages, for example, locked or stopped. - */ - public boolean send(String message); + + /** + * Sends a string message over this Topic Endpoint. + * + * @param message message to send + * + * @return true if the send operation succeeded, false otherwise + * @throws IllegalArgumentException an invalid message has been provided + * @throws IllegalStateException the entity is in an state that prevents + * it from sending messages, for example, locked or stopped. + */ + public boolean send(String message); } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicSource.java index fb39764a..c1d0829c 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicSource.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicSource.java @@ -22,16 +22,16 @@ package org.onap.policy.common.endpoints.event.comm; /** * Marker for a Topic Entity, indicating that the entity is able to read - * over a topic + * over a topic. */ public interface TopicSource extends Topic { - - /** - * pushes an event into the source programatically - * - * @param event the event in json format - * @return true if it can be processed correctly, false otherwise - */ - public boolean offer(String event); + + /** + * Pushes an event into the source programatically. + * + * @param event the event in json format + * @return true if it can be processed correctly, false otherwise + */ + public boolean offer(String event); }
\ No newline at end of file diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/ApiKeyEnabled.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/ApiKeyEnabled.java index 3a57d2be..42e01366 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/ApiKeyEnabled.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/ApiKeyEnabled.java @@ -21,16 +21,16 @@ package org.onap.policy.common.endpoints.event.comm.bus; /** - * API + * API. */ public interface ApiKeyEnabled { - /** - * @return api key - */ - public String getApiKey(); - - /** - * @return api secret - */ - public String getApiSecret(); + /** + * @return api key + */ + public String getApiKey(); + + /** + * @return api secret + */ + public String getApiSecret(); } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSink.java index d06983d8..ed796585 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSink.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSink.java @@ -23,23 +23,23 @@ package org.onap.policy.common.endpoints.event.comm.bus; import org.onap.policy.common.endpoints.event.comm.TopicSink; /** - * Topic Sink over Bus Infrastructure (DMAAP/UEB) + * Topic Sink over Bus Infrastructure (DMAAP/UEB). */ public interface BusTopicSink extends ApiKeyEnabled, TopicSink { /** - * Log Failures after X number of retries + * Log Failures after X number of retries. */ public static final int DEFAULT_LOG_SEND_FAILURES_AFTER = 1; /** - * Sets the UEB partition key for published messages + * Sets the UEB partition key for published messages. * * @param partitionKey the partition key */ public void setPartitionKey(String partitionKey); /** - * return the partition key in used by the system to publish messages + * Return the partition key in used by the system to publish messages. * * @return the partition key */ diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSource.java index 2891513d..5ab4d46f 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSource.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSource.java @@ -23,54 +23,54 @@ package org.onap.policy.common.endpoints.event.comm.bus; import org.onap.policy.common.endpoints.event.comm.TopicSource; /** - * Generic Topic Source for UEB/DMAAP Communication Infrastructure + * Generic Topic Source for UEB/DMAAP Communication Infrastructure. * */ public interface BusTopicSource extends ApiKeyEnabled, TopicSource { /** - * Default Timeout fetching in milliseconds + * Default Timeout fetching in milliseconds. */ public static int DEFAULT_TIMEOUT_MS_FETCH = 15000; /** - * Default maximum number of messages fetch at the time + * Default maximum number of messages fetch at the time. */ public static int DEFAULT_LIMIT_FETCH = 100; /** - * Definition of No Timeout fetching + * Definition of No Timeout fetching. */ public static int NO_TIMEOUT_MS_FETCH = -1; /** - * Definition of No limit fetching + * Definition of No limit fetching. */ public static int NO_LIMIT_FETCH = -1; /** - * gets the consumer group + * Gets the consumer group. * * @return consumer group */ public String getConsumerGroup(); /** - * gets the consumer instance + * Gets the consumer instance. * * @return consumer instance */ public String getConsumerInstance(); /** - * gets the fetch timeout + * Gets the fetch timeout. * * @return fetch timeout */ public int getFetchTimeout(); /** - * gets the fetch limit + * Gets the fetch limit. * * @return fetch limit */ diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSink.java index ba219322..fc1587e4 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSink.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSink.java @@ -23,7 +23,7 @@ package org.onap.policy.common.endpoints.event.comm.bus; public interface DmaapTopicSink extends BusTopicSink { /** - * Factory of UebTopicWriter for instantiation and management purposes + * Factory of UebTopicWriter for instantiation and management purposes. */ public static final DmaapTopicSinkFactory factory = new IndexedDmaapTopicSinkFactory(); diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java index 08a1db8f..206018a9 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java @@ -35,7 +35,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * DMAAP Topic Sink Factory + * DMAAP Topic Sink Factory. */ public interface DmaapTopicSinkFactory { public final String DME2_READ_TIMEOUT_PROPERTY = "AFT_DME2_EP_READ_TIMEOUT_MS"; @@ -48,7 +48,7 @@ public interface DmaapTopicSinkFactory { public final String DME2_SESSION_STICKINESS_REQUIRED_PROPERTY = "sessionstickinessrequired"; /** - * Instantiates a new DMAAP Topic Sink + * Instantiates a new DMAAP Topic Sink. * * @param servers list of servers * @param topic topic name @@ -68,12 +68,12 @@ public interface DmaapTopicSinkFactory { * @throws IllegalArgumentException if invalid parameters are present */ public DmaapTopicSink build(List<String> servers, String topic, String apiKey, String apiSecret, String userName, - String password, String partitionKey, String environment, String aftEnvironment, String partner, - String latitude, String longitude, Map<String, String> additionalProps, boolean managed, boolean useHttps, - boolean allowSelfSignedCerts); + String password, String partitionKey, String environment, String aftEnvironment, + String partner, String latitude, String longitude, Map<String, String> additionalProps, + boolean managed, boolean useHttps, boolean allowSelfSignedCerts); /** - * Instantiates a new DMAAP Topic Sink + * Instantiates a new DMAAP Topic Sink. * * @param servers list of servers * @param topic topic name @@ -87,10 +87,11 @@ public interface DmaapTopicSinkFactory { * @throws IllegalArgumentException if invalid parameters are present */ public DmaapTopicSink build(List<String> servers, String topic, String apiKey, String apiSecret, String userName, - String password, String partitionKey, boolean managed, boolean useHttps, boolean allowSelfSignedCerts); + String password, String partitionKey, boolean managed, + boolean useHttps, boolean allowSelfSignedCerts); /** - * Creates an DMAAP Topic Sink based on properties files + * Creates an DMAAP Topic Sink based on properties files. * * @param properties Properties containing initialization values * @return an DMAAP Topic Sink @@ -99,7 +100,7 @@ public interface DmaapTopicSinkFactory { public List<DmaapTopicSink> build(Properties properties); /** - * Instantiates a new DMAAP Topic Sink + * Instantiates a new DMAAP Topic Sink. * * @param servers list of servers * @param topic topic name @@ -109,7 +110,7 @@ public interface DmaapTopicSinkFactory { public DmaapTopicSink build(List<String> servers, String topic); /** - * Destroys an DMAAP Topic Sink based on a topic + * Destroys an DMAAP Topic Sink based on a topic. * * @param topic topic name * @throws IllegalArgumentException if invalid parameters are present @@ -117,7 +118,12 @@ public interface DmaapTopicSinkFactory { public void destroy(String topic); /** - * gets an DMAAP Topic Sink based on topic name + * Destroys all DMAAP Topic Sinks. + */ + public void destroy(); + + /** + * Gets an DMAAP Topic Sink based on topic name. * * @param topic the topic name * @return an DMAAP Topic Sink with topic name @@ -127,42 +133,37 @@ public interface DmaapTopicSinkFactory { public DmaapTopicSink get(String topic); /** - * Provides a snapshot of the DMAAP Topic Sinks + * Provides a snapshot of the DMAAP Topic Sinks. * * @return a list of the DMAAP Topic Sinks */ public List<DmaapTopicSink> inventory(); - - /** - * Destroys all DMAAP Topic Sinks - */ - public void destroy(); } /* ------------- implementation ----------------- */ /** - * Factory of DMAAP Reader Topics indexed by topic name + * Factory of DMAAP Reader Topics indexed by topic name. */ class IndexedDmaapTopicSinkFactory implements DmaapTopicSinkFactory { private static final String MISSING_TOPIC = "A topic must be provided"; /** - * Logger + * Logger. */ private static Logger logger = LoggerFactory.getLogger(IndexedDmaapTopicSinkFactory.class); /** - * DMAAP Topic Name Index + * DMAAP Topic Name Index. */ protected HashMap<String, DmaapTopicSink> dmaapTopicWriters = new HashMap<>(); @Override public DmaapTopicSink build(List<String> servers, String topic, String apiKey, String apiSecret, String userName, - String password, String partitionKey, String environment, String aftEnvironment, String partner, - String latitude, String longitude, Map<String, String> additionalProps, boolean managed, boolean useHttps, - boolean allowSelfSignedCerts) { + String password, String partitionKey, String environment, String aftEnvironment, + String partner, String latitude, String longitude, Map<String, String> additionalProps, + boolean managed, boolean useHttps, boolean allowSelfSignedCerts) { if (topic == null || topic.isEmpty()) { throw new IllegalArgumentException(MISSING_TOPIC); diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSource.java index ffed5bab..2cf07bda 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSource.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSource.java @@ -23,7 +23,7 @@ package org.onap.policy.common.endpoints.event.comm.bus; public interface DmaapTopicSource extends BusTopicSource { /** - * factory for managing and tracking DMAAP sources + * factory for managing and tracking DMAAP sources. */ public static DmaapTopicSourceFactory factory = new IndexedDmaapTopicSourceFactory(); } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java index 11dfd292..cc31c2a5 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java @@ -35,7 +35,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * DMAAP Topic Source Factory + * DMAAP Topic Source Factory. */ public interface DmaapTopicSourceFactory { public final String DME2_READ_TIMEOUT_PROPERTY = "AFT_DME2_EP_READ_TIMEOUT_MS"; @@ -48,7 +48,7 @@ public interface DmaapTopicSourceFactory { public final String DME2_SESSION_STICKINESS_REQUIRED_PROPERTY = "sessionstickinessrequired"; /** - * Creates an DMAAP Topic Source based on properties files + * Creates an DMAAP Topic Source based on properties files. * * @param properties Properties containing initialization values * @@ -58,7 +58,7 @@ public interface DmaapTopicSourceFactory { public List<DmaapTopicSource> build(Properties properties); /** - * Instantiates a new DMAAP Topic Source + * Instantiates a new DMAAP Topic Source. * * @param servers list of servers * @param topic topic name @@ -78,11 +78,12 @@ public interface DmaapTopicSourceFactory { * @throws IllegalArgumentException if invalid parameters are present */ public DmaapTopicSource build(List<String> servers, String topic, String apiKey, String apiSecret, String userName, - String password, String consumerGroup, String consumerInstance, int fetchTimeout, int fetchLimit, + String password, String consumerGroup, String consumerInstance, + int fetchTimeout, int fetchLimit, boolean managed, boolean useHttps, boolean allowSelfSignedCerts); /** - * Instantiates a new DMAAP Topic Source + * Instantiates a new DMAAP Topic Source. * * @param servers list of servers * @param topic topic name @@ -108,12 +109,13 @@ public interface DmaapTopicSourceFactory { * @throws IllegalArgumentException if invalid parameters are present */ public DmaapTopicSource build(List<String> servers, String topic, String apiKey, String apiSecret, String userName, - String password, String consumerGroup, String consumerInstance, int fetchTimeout, int fetchLimit, - String environment, String aftEnvironment, String partner, String latitude, String longitude, - Map<String, String> additionalProps, boolean managed, boolean useHttps, boolean allowSelfSignedCerts); + String password, String consumerGroup, String consumerInstance, int fetchTimeout, + int fetchLimit, String environment, String aftEnvironment, String partner, + String latitude, String longitude, Map<String, String> additionalProps, + boolean managed, boolean useHttps, boolean allowSelfSignedCerts); /** - * Instantiates a new DMAAP Topic Source + * Instantiates a new DMAAP Topic Source. * * @param servers list of servers * @param topic topic name @@ -126,7 +128,7 @@ public interface DmaapTopicSourceFactory { public DmaapTopicSource build(List<String> servers, String topic, String apiKey, String apiSecret); /** - * Instantiates a new DMAAP Topic Source + * Instantiates a new DMAAP Topic Source. * * @param servers list of servers * @param topic topic name @@ -137,7 +139,7 @@ public interface DmaapTopicSourceFactory { public DmaapTopicSource build(List<String> servers, String topic); /** - * Destroys an DMAAP Topic Source based on a topic + * Destroys an DMAAP Topic Source based on a topic. * * @param topic topic name * @throws IllegalArgumentException if invalid parameters are present @@ -145,12 +147,12 @@ public interface DmaapTopicSourceFactory { public void destroy(String topic); /** - * Destroys all DMAAP Topic Sources + * Destroys all DMAAP Topic Sources. */ public void destroy(); /** - * gets an DMAAP Topic Source based on topic name + * Gets an DMAAP Topic Source based on topic name. * * @param topic the topic name * @return an DMAAP Topic Source with topic name @@ -160,7 +162,7 @@ public interface DmaapTopicSourceFactory { public DmaapTopicSource get(String topic); /** - * Provides a snapshot of the DMAAP Topic Sources + * Provides a snapshot of the DMAAP Topic Sources. * * @return a list of the DMAAP Topic Sources */ @@ -171,19 +173,19 @@ public interface DmaapTopicSourceFactory { /* ------------- implementation ----------------- */ /** - * Factory of DMAAP Source Topics indexed by topic name + * Factory of DMAAP Source Topics indexed by topic name. */ class IndexedDmaapTopicSourceFactory implements DmaapTopicSourceFactory { private static final String MISSING_TOPIC = "A topic must be provided"; /** - * Logger + * Logger. */ private static Logger logger = LoggerFactory.getLogger(IndexedDmaapTopicSourceFactory.class); /** - * DMaaP Topic Name Index + * DMaaP Topic Name Index. */ protected HashMap<String, DmaapTopicSource> dmaapTopicSources = new HashMap<>(); @@ -507,6 +509,18 @@ class IndexedDmaapTopicSourceFactory implements DmaapTopicSourceFactory { uebTopicSource.shutdown(); } + @Override + public void destroy() { + List<DmaapTopicSource> readers = this.inventory(); + for (DmaapTopicSource reader : readers) { + reader.shutdown(); + } + + synchronized (this) { + this.dmaapTopicSources.clear(); + } + } + /** * {@inheritDoc} */ @@ -532,18 +546,6 @@ class IndexedDmaapTopicSourceFactory implements DmaapTopicSourceFactory { } @Override - public void destroy() { - List<DmaapTopicSource> readers = this.inventory(); - for (DmaapTopicSource reader : readers) { - reader.shutdown(); - } - - synchronized (this) { - this.dmaapTopicSources.clear(); - } - } - - @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("IndexedDmaapTopicSourceFactory []"); diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java index 6f9f0adc..5a5f8fbc 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java @@ -28,27 +28,27 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * NOOP topic sink + * NOOP topic sink. */ public class NoopTopicSink extends TopicBase implements TopicSink { /** - * factory + * factory. */ public static final NoopTopicSinkFactory factory = new IndexedNoopTopicSinkFactory(); /** - * logger + * logger. */ private static Logger logger = LoggerFactory.getLogger(NoopTopicSink.class); /** - * net logger + * net logger. */ private static final Logger netLogger = LoggerFactory.getLogger(NETWORK_LOGGER); /** - * constructor + * constructor. * * @param servers servers * @param topic topic diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSinkFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSinkFactory.java index ee1672d7..adf79706 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSinkFactory.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSinkFactory.java @@ -31,12 +31,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Noop Topic Sink Factory + * Noop Topic Sink Factory. */ public interface NoopTopicSinkFactory { /** - * Creates noop topic sinks based on properties files + * Creates noop topic sinks based on properties files. * * @param properties Properties containing initialization values * @@ -46,7 +46,7 @@ public interface NoopTopicSinkFactory { public List<NoopTopicSink> build(Properties properties); /** - * builds a noop sink + * builds a noop sink. * * @param servers list of servers * @param topic topic name @@ -57,7 +57,7 @@ public interface NoopTopicSinkFactory { public NoopTopicSink build(List<String> servers, String topic, boolean managed); /** - * Destroys a sink based on the topic + * Destroys a sink based on the topic. * * @param topic topic name * @throws IllegalArgumentException if invalid parameters are present @@ -65,7 +65,12 @@ public interface NoopTopicSinkFactory { public void destroy(String topic); /** - * gets a sink based on topic name + * Destroys all sinks. + */ + public void destroy(); + + /** + * gets a sink based on topic name. * * @param topic the topic name * @@ -76,34 +81,30 @@ public interface NoopTopicSinkFactory { public NoopTopicSink get(String topic); /** - * Provides a snapshot of the UEB Topic Writers + * Provides a snapshot of the UEB Topic Writers. * * @return a list of the UEB Topic Writers */ public List<NoopTopicSink> inventory(); - /** - * Destroys all sinks - */ - public void destroy(); } /* ------------- implementation ----------------- */ /** - * Factory of noop sinks + * Factory of noop sinks. */ class IndexedNoopTopicSinkFactory implements NoopTopicSinkFactory { private static final String MISSING_TOPIC = "A topic must be provided"; /** - * Logger + * Logger. */ private static Logger logger = LoggerFactory.getLogger(IndexedUebTopicSinkFactory.class); /** - * noop topic sinks map + * noop topic sinks map. */ protected HashMap<String, NoopTopicSink> noopTopicSinks = new HashMap<>(); diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSink.java index b6e4acbe..bc1251d5 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSink.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSink.java @@ -21,12 +21,12 @@ package org.onap.policy.common.endpoints.event.comm.bus; /** - * Topic Writer over UEB Infrastructure + * Topic Writer over UEB Infrastructure. */ public interface UebTopicSink extends BusTopicSink { /** - * Factory of UEB Topic Sinks for instantiation and management purposes + * Factory of UEB Topic Sinks for instantiation and management purposes. */ public static final UebTopicSinkFactory factory = new IndexedUebTopicSinkFactory(); } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSinkFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSinkFactory.java index 9d1bd8ad..2d2e1369 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSinkFactory.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSinkFactory.java @@ -34,12 +34,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * UEB Topic Sink Factory + * UEB Topic Sink Factory. */ public interface UebTopicSinkFactory { /** - * Instantiates a new UEB Topic Writer + * Instantiates a new UEB Topic Writer. * * @param servers list of servers * @param topic topic name @@ -55,7 +55,7 @@ public interface UebTopicSinkFactory { boolean managed, boolean useHttps, boolean allowSelfSignedCerts); /** - * Creates an UEB Topic Writer based on properties files + * Creates an UEB Topic Writer based on properties files. * * @param properties Properties containing initialization values * @@ -65,7 +65,7 @@ public interface UebTopicSinkFactory { public List<UebTopicSink> build(Properties properties); /** - * Instantiates a new UEB Topic Writer + * Instantiates a new UEB Topic Writer. * * @param servers list of servers * @param topic topic name @@ -76,7 +76,7 @@ public interface UebTopicSinkFactory { public UebTopicSink build(List<String> servers, String topic); /** - * Destroys an UEB Topic Writer based on a topic + * Destroys an UEB Topic Writer based on a topic. * * @param topic topic name * @throws IllegalArgumentException if invalid parameters are present @@ -84,7 +84,12 @@ public interface UebTopicSinkFactory { public void destroy(String topic); /** - * gets an UEB Topic Writer based on topic name + * Destroys all UEB Topic Writers. + */ + public void destroy(); + + /** + * gets an UEB Topic Writer based on topic name. * * @param topic the topic name * @@ -95,34 +100,29 @@ public interface UebTopicSinkFactory { public UebTopicSink get(String topic); /** - * Provides a snapshot of the UEB Topic Writers + * Provides a snapshot of the UEB Topic Writers. * * @return a list of the UEB Topic Writers */ public List<UebTopicSink> inventory(); - - /** - * Destroys all UEB Topic Writers - */ - public void destroy(); } /* ------------- implementation ----------------- */ /** - * Factory of UEB Reader Topics indexed by topic name + * Factory of UEB Reader Topics indexed by topic name. */ class IndexedUebTopicSinkFactory implements UebTopicSinkFactory { private static final String MISSING_TOPIC = "A topic must be provided"; /** - * Logger + * Logger. */ private static Logger logger = LoggerFactory.getLogger(IndexedUebTopicSinkFactory.class); /** - * UEB Topic Name Index + * UEB Topic Name Index. */ protected HashMap<String, UebTopicSink> uebTopicSinks = new HashMap<>(); diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSource.java index 25bbce62..ee4f013b 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSource.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSource.java @@ -21,13 +21,13 @@ package org.onap.policy.common.endpoints.event.comm.bus; /** - * Topic Source for UEB Communication Infrastructure + * Topic Source for UEB Communication Infrastructure. * */ public interface UebTopicSource extends BusTopicSource { /** - * factory for managing and tracking UEB readers + * factory for managing and tracking UEB readers. */ public static UebTopicSourceFactory factory = new IndexedUebTopicSourceFactory(); } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceFactory.java index 8d3f28e9..c4a69831 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceFactory.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceFactory.java @@ -34,12 +34,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * UEB Topic Source Factory + * UEB Topic Source Factory. */ public interface UebTopicSourceFactory { /** - * Creates an UEB Topic Source based on properties files + * Creates an UEB Topic Source based on properties files. * * @param properties Properties containing initialization values * @@ -49,7 +49,7 @@ public interface UebTopicSourceFactory { public List<UebTopicSource> build(Properties properties); /** - * Instantiates a new UEB Topic Source + * Instantiates a new UEB Topic Source. * * @param servers list of servers * @param topic topic name @@ -65,11 +65,12 @@ public interface UebTopicSourceFactory { * @throws IllegalArgumentException if invalid parameters are present */ public UebTopicSource build(List<String> servers, String topic, String apiKey, String apiSecret, - String consumerGroup, String consumerInstance, int fetchTimeout, int fetchLimit, boolean managed, + String consumerGroup, String consumerInstance, + int fetchTimeout, int fetchLimit, boolean managed, boolean useHttps, boolean allowSelfSignedCerts); /** - * Instantiates a new UEB Topic Source + * Instantiates a new UEB Topic Source. * * @param servers list of servers * @param topic topic name @@ -82,7 +83,7 @@ public interface UebTopicSourceFactory { public UebTopicSource build(List<String> servers, String topic, String apiKey, String apiSecret); /** - * Instantiates a new UEB Topic Source + * Instantiates a new UEB Topic Source. * * @param servers list of servers * @param topic topic name @@ -93,7 +94,7 @@ public interface UebTopicSourceFactory { public UebTopicSource build(List<String> servers, String topic); /** - * Destroys an UEB Topic Source based on a topic + * Destroys an UEB Topic Source based on a topic. * * @param topic topic name * @throws IllegalArgumentException if invalid parameters are present @@ -101,12 +102,12 @@ public interface UebTopicSourceFactory { public void destroy(String topic); /** - * Destroys all UEB Topic Sources + * Destroys all UEB Topic Sources. */ public void destroy(); /** - * gets an UEB Topic Source based on topic name + * Gets an UEB Topic Source based on topic name. * * @param topic the topic name * @return an UEB Topic Source with topic name @@ -116,7 +117,7 @@ public interface UebTopicSourceFactory { public UebTopicSource get(String topic); /** - * Provides a snapshot of the UEB Topic Sources + * Provides a snapshot of the UEB Topic Sources. * * @return a list of the UEB Topic Sources */ @@ -127,18 +128,18 @@ public interface UebTopicSourceFactory { /* ------------- implementation ----------------- */ /** - * Factory of UEB Source Topics indexed by topic name + * Factory of UEB Source Topics indexed by topic name. */ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory { private static final String MISSING_TOPIC = "A topic must be provided"; /** - * Logger + * Logger. */ private static Logger logger = LoggerFactory.getLogger(IndexedUebTopicSourceFactory.class); /** - * UEB Topic Name Index + * UEB Topic Name Index. */ protected HashMap<String, UebTopicSource> uebTopicSources = new HashMap<>(); @@ -325,6 +326,18 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory { uebTopicSource.shutdown(); } + @Override + public void destroy() { + List<UebTopicSource> readers = this.inventory(); + for (UebTopicSource reader : readers) { + reader.shutdown(); + } + + synchronized (this) { + this.uebTopicSources.clear(); + } + } + /** * {@inheritDoc} */ @@ -350,18 +363,6 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory { } @Override - public void destroy() { - List<UebTopicSource> readers = this.inventory(); - for (UebTopicSource reader : readers) { - reader.shutdown(); - } - - synchronized (this) { - this.uebTopicSources.clear(); - } - } - - @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("IndexedUebTopicSourceFactory []"); diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java index 6d34d32b..034ac66e 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java @@ -42,12 +42,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Wrapper around libraries to consume from message bus + * Wrapper around libraries to consume from message bus. */ public interface BusConsumer { /** - * fetch messages + * fetch messages. * * @return list of messages * @throws Exception when error encountered by underlying libraries @@ -55,7 +55,7 @@ public interface BusConsumer { public Iterable<String> fetch() throws InterruptedException, IOException; /** - * close underlying library consumer + * close underlying library consumer. */ public void close(); @@ -74,12 +74,12 @@ public interface BusConsumer { } /** - * Cambria based consumer + * Cambria based consumer. */ public static class CambriaConsumerWrapper implements FilterableBusConsumer { /** - * logger + * logger. */ private static Logger logger = LoggerFactory.getLogger(CambriaConsumerWrapper.class); @@ -94,29 +94,29 @@ public interface BusConsumer { private final Object consLocker = new Object(); /** - * Cambria client + * Cambria client. */ private CambriaConsumer consumer; /** - * Cambria client to use for next fetch + * Cambria client to use for next fetch. */ private CambriaConsumer newConsumer = null; /** - * fetch timeout + * fetch timeout. */ protected int fetchTimeout; /** - * close condition + * close condition. */ protected Object closeCondition = new Object(); /** - * Cambria Consumer Wrapper + * Cambria Consumer Wrapper. * BusTopicParam object contains the following parameters - * servers messaging bus hosts + * servers messaging bus hosts. * topic topic * apiKey API Key * apiSecret API Secret @@ -125,9 +125,9 @@ public interface BusConsumer { * fetchTimeout Fetch Timeout * fetchLimit Fetch Limit * - * @param busTopicParams - * @throws GeneralSecurityException - * @throws MalformedURLException + * @param busTopicParams - The parameters for the bus topic + * @throws GeneralSecurityException - Security exception + * @throws MalformedURLException - Malformed URL exception */ public CambriaConsumerWrapper(BusTopicParams busTopicParams) { @@ -244,12 +244,12 @@ public interface BusConsumer { } /** - * MR based consumer + * MR based consumer. */ public abstract class DmaapConsumerWrapper implements BusConsumer { /** - * logger + * logger. */ private static Logger logger = LoggerFactory.getLogger(DmaapConsumerWrapper.class); @@ -259,24 +259,24 @@ public interface BusConsumer { protected static final String PROTOCOL_PROP = "Protocol"; /** - * fetch timeout + * fetch timeout. */ protected int fetchTimeout; /** - * close condition + * close condition. */ protected Object closeCondition = new Object(); /** - * MR Consumer + * MR Consumer. */ protected MRConsumerImpl consumer; /** - * MR Consumer Wrapper - * <p> - * servers messaging bus hosts + * MR Consumer Wrapper. + * + * <p>servers messaging bus hosts * topic topic * apiKey API Key * apiSecret API Secret @@ -288,7 +288,7 @@ public interface BusConsumer { * fetchLimit Fetch Limit * * @param busTopicParams contains above listed attributes - * @throws MalformedURLException + * @throws MalformedURLException URL should be valid */ public DmaapConsumerWrapper(BusTopicParams busTopicParams) throws MalformedURLException { @@ -360,7 +360,7 @@ public interface BusConsumer { } /** - * MR based consumer + * MR based consumer. */ public static class DmaapAafConsumerWrapper extends DmaapConsumerWrapper { @@ -369,10 +369,10 @@ public interface BusConsumer { private final Properties props; /** - * BusTopicParams contain the following parameters - * MR Consumer Wrapper - * <p> - * servers messaging bus hosts + * BusTopicParams contain the following parameters. + * MR Consumer Wrapper. + * + * <p>servers messaging bus hosts * topic topic * apiKey API Key * apiSecret API Secret @@ -384,7 +384,7 @@ public interface BusConsumer { * fetchLimit Fetch Limit * * @param busTopicParams contains above listed params - * @throws MalformedURLException + * @throws MalformedURLException URL should be valid */ public DmaapAafConsumerWrapper(BusTopicParams busTopicParams) throws MalformedURLException { diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java index 348100ab..05e92638 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java @@ -46,7 +46,7 @@ import org.slf4j.LoggerFactory; public interface BusPublisher { /** - * sends a message + * sends a message. * * @param partitionId id * @param message the message @@ -56,19 +56,19 @@ public interface BusPublisher { public boolean send(String partitionId, String message); /** - * closes the publisher + * closes the publisher. */ public void close(); /** - * Cambria based library publisher + * Cambria based library publisher. */ public static class CambriaPublisherWrapper implements BusPublisher { private static Logger logger = LoggerFactory.getLogger(CambriaPublisherWrapper.class); /** - * The actual Cambria publisher + * The actual Cambria publisher. */ @JsonIgnore protected volatile CambriaBatchingPublisher publisher; @@ -147,20 +147,20 @@ public interface BusPublisher { } /** - * DmaapClient library wrapper + * DmaapClient library wrapper. */ public abstract class DmaapPublisherWrapper implements BusPublisher { private static Logger logger = LoggerFactory.getLogger(DmaapPublisherWrapper.class); /** - * MR based Publisher + * MR based Publisher. */ protected MRSimplerBatchPublisher publisher; protected Properties props; /** - * MR Publisher Wrapper + * MR Publisher Wrapper. * * @param servers messaging bus hosts * @param topic topic @@ -278,11 +278,11 @@ public interface BusPublisher { } /** - * DmaapClient library wrapper + * DmaapClient library wrapper. */ public static class DmaapAafPublisherWrapper extends DmaapPublisherWrapper { /** - * MR based Publisher + * MR based Publisher. */ public DmaapAafPublisherWrapper(List<String> servers, String topic, String aafLogin, String aafPassword, boolean useHttps) { diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBase.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBase.java index 08993126..3e112f90 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBase.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBase.java @@ -25,41 +25,40 @@ import java.util.List; import org.onap.policy.common.endpoints.event.comm.bus.ApiKeyEnabled; /** - * Bus Topic Base + * Bus Topic Base. */ public abstract class BusTopicBase extends TopicBase implements ApiKeyEnabled { /** - * API Key + * API Key. */ protected String apiKey; /** - * API Secret + * API Secret. */ protected String apiSecret; /** - * Use https + * Use https. */ protected boolean useHttps; /** - * allow self signed certificates + * allow self signed certificates. */ protected boolean allowSelfSignedCerts; /** - * Instantiates a new Bus Topic Base + * Instantiates a new Bus Topic Base. * - * servers list of servers + * <p>servers list of servers * topic topic name * apiKey API Key * apiSecret API Secret * useHttps does connection use HTTPS? * allowSelfSignedCerts are self-signed certificates allow - * @param busTopicParams - * @return a Bus Topic Base + * @param busTopicParams holds all our parameters * @throws IllegalArgumentException if invalid parameters are present */ public BusTopicBase(BusTopicParams busTopicParams) { @@ -81,6 +80,8 @@ public abstract class BusTopicBase extends TopicBase implements ApiKeyEnabled { } /** + * Is using HTTPS. + * * @return if using https */ public boolean isUseHttps() { @@ -88,6 +89,8 @@ public abstract class BusTopicBase extends TopicBase implements ApiKeyEnabled { } /** + * Is self signed certificates allowed. + * * @return if self signed certificates are allowed */ public boolean isAllowSelfSignedCerts() { diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java index ffefcbf2..f9eca081 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java @@ -24,8 +24,9 @@ import java.util.List; import java.util.Map; /** - * Member variables of this Params class are as follows - * servers DMaaP servers + * Member variables of this Params class are as follows. + * + * <p>servers DMaaP servers * topic DMaaP Topic to be monitored * apiKey DMaaP API Key (optional) * apiSecret DMaaP API Secret (optional) diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java index 5493468a..043b8673 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java @@ -21,7 +21,6 @@ package org.onap.policy.common.endpoints.event.comm.bus.internal; -import java.util.List; import java.util.UUID; import org.onap.policy.common.endpoints.event.comm.bus.BusTopicSink; @@ -36,31 +35,31 @@ import org.slf4j.LoggerFactory; public abstract class InlineBusTopicSink extends BusTopicBase implements BusTopicSink { /** - * loggers + * Loggers. */ private static Logger logger = LoggerFactory.getLogger(InlineBusTopicSink.class); private static final Logger netLogger = LoggerFactory.getLogger(NETWORK_LOGGER); /** - * The partition key to publish to + * The partition key to publish to. */ protected String partitionId; /** - * message bus publisher + * Message bus publisher. */ protected BusPublisher publisher; /** - * constructor for abstract sink + * Constructor for abstract sink. * @param busTopicParams contains below listed attributes - * servers servers - * topic topic - * apiKey api secret - * apiSecret api secret - * partitionId partition id - * useHttps does connection use HTTPS? - * allowSelfSignedCerts are self-signed certificates allow * + * servers servers + * topic topic + * apiKey api secret + * apiSecret api secret + * partitionId partition id + * useHttps does connection use HTTPS? + * allowSelfSignedCerts are self-signed certificates allow * * @throws IllegalArgumentException in invalid parameters are passed in */ public InlineBusTopicSink(BusTopicParams busTopicParams) { @@ -75,7 +74,7 @@ public abstract class InlineBusTopicSink extends BusTopicBase implements BusTopi } /** - * Initialize the Bus publisher + * Initialize the Bus publisher. */ public abstract void init(); diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSink.java index 3dd40312..5c18fb3f 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSink.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSink.java @@ -49,7 +49,7 @@ public class InlineDmaapTopicSink extends InlineBusTopicSink implements DmaapTop protected Map<String, String> additionalProps = null; /** - * BusTopicParams contains the below mentioned attributes + * BusTopicParams contains the below mentioned attributes. * servers DMaaP servers * topic DMaaP Topic to be monitored * apiKey DMaaP API Key (optional) diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSink.java index 218e44b4..b07a1966 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSink.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSink.java @@ -21,8 +21,6 @@ package org.onap.policy.common.endpoints.event.comm.bus.internal; -import java.util.List; - import org.onap.policy.common.endpoints.event.comm.Topic; import org.onap.policy.common.endpoints.event.comm.bus.UebTopicSink; import org.slf4j.Logger; @@ -35,15 +33,15 @@ import org.slf4j.LoggerFactory; public class InlineUebTopicSink extends InlineBusTopicSink implements UebTopicSink { /** - * logger + * Logger. */ private static Logger logger = LoggerFactory.getLogger(InlineUebTopicSink.class); /** * Argument-based UEB Topic Writer instantiation. BusTopicParams contains below mentioned - * attributes + * attributes. * - * servers list of UEB servers available for publishing + * <p>servers list of UEB servers available for publishing * topic the topic to publish to * apiKey the api key (optional) * apiSecret the api secret (optional) @@ -58,7 +56,7 @@ public class InlineUebTopicSink extends InlineBusTopicSink implements UebTopicSi } /** - * Instantiation of internal resources + * Instantiation of internal resources. */ @Override public void init() { diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java index 400cbfe2..e4b335c3 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; /** * This topic source implementation specializes in reading messages over a bus topic source and - * notifying its listeners + * notifying its listeners. */ public abstract class SingleThreadedBusTopicSource extends BusTopicBase implements Runnable, BusTopicSource, FilterableTopicSource { @@ -47,32 +47,32 @@ public abstract class SingleThreadedBusTopicSource extends BusTopicBase private static final Logger netLogger = LoggerFactory.getLogger(NETWORK_LOGGER); /** - * Bus consumer group + * Bus consumer group. */ protected final String consumerGroup; /** - * Bus consumer instance + * Bus consumer instance. */ protected final String consumerInstance; /** - * Bus fetch timeout + * Bus fetch timeout. */ protected final int fetchTimeout; /** - * Bus fetch limit + * Bus fetch limit. */ protected final int fetchLimit; /** - * Message Bus Consumer + * Message Bus Consumer. */ protected BusConsumer consumer; /** - * Independent thread reading message over my topic + * Independent thread reading message over my topic. */ protected Thread busPollerThread; @@ -113,7 +113,7 @@ public abstract class SingleThreadedBusTopicSource extends BusTopicBase } /** - * Initialize the Bus client + * Initialize the Bus client. */ public abstract void init() throws MalformedURLException; @@ -204,7 +204,7 @@ public abstract class SingleThreadedBusTopicSource extends BusTopicBase } /** - * Run thread method for the Bus Reader + * Run thread method for the Bus Reader. */ @Override public void run() { diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java index 65f75aa5..0fcb86b4 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java @@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory; /** * This topic reader implementation specializes in reading messages over DMAAP topic and notifying - * its listeners + * its listeners. */ public class SingleThreadedDmaapTopicSource extends SingleThreadedBusTopicSource implements DmaapTopicSource, Runnable { @@ -73,14 +73,15 @@ public class SingleThreadedDmaapTopicSource extends SingleThreadedBusTopicSource try { this.init(); } catch (Exception e) { - logger.error("ERROR during init in dmaap-source: cannot create topic {} because of {}", topic, e.getMessage(), e); + logger.error("ERROR during init in dmaap-source: cannot create topic {} because of {}", + topic, e.getMessage(), e); throw new IllegalArgumentException(e); } } /** - * Initialize the Cambria or MR Client + * Initialize the Cambria or MR Client. */ @Override public void init() throws MalformedURLException { diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSource.java index fb20ccc4..23d3edca 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSource.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSource.java @@ -26,11 +26,13 @@ import org.onap.policy.common.endpoints.event.comm.bus.UebTopicSource; /** * This topic source implementation specializes in reading messages over an UEB Bus topic source and - * notifying its listeners + * notifying its listeners. */ public class SingleThreadedUebTopicSource extends SingleThreadedBusTopicSource implements UebTopicSource { /** + * Constructor. + * * @param busTopicParams Parameters object containing all the required inputs * @throws IllegalArgumentException An invalid parameter passed in */ @@ -46,7 +48,7 @@ public class SingleThreadedUebTopicSource extends SingleThreadedBusTopicSource i } /** - * Initialize the Cambria client + * Initialize the Cambria client. */ @Override public void init() { diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBase.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBase.java index ed15ddf7..80664554 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBase.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBase.java @@ -32,50 +32,49 @@ import org.slf4j.LoggerFactory; public abstract class TopicBase implements Topic { /** - * logger + * Logger. */ private static Logger logger = LoggerFactory.getLogger(TopicBase.class); /** - * list of servers + * List of servers. */ protected List<String> servers; /** - * Topic + * Topic. */ protected String topic; /** - * event cache + * Event cache. */ protected CircularFifoQueue<String> recentEvents = new CircularFifoQueue<>(10); /** * Am I running? reflects invocation of start()/stop() !locked & start() => alive stop() => - * !alive + * !alive. */ protected volatile boolean alive = false; /** * Am I locked? reflects invocation of lock()/unlock() operations locked => !alive (but not in * the other direction necessarily) locked => !offer, !run, !start, !stop (but this last one is - * obvious since locked => !alive) + * obvious since locked => !alive). */ protected volatile boolean locked = false; /** - * All my subscribers for new message notifications + * All my subscribers for new message notifications. */ protected final ArrayList<TopicListener> topicListeners = new ArrayList<>(); /** - * Instantiates a new Topic Base + * Instantiates a new Topic Base. * * @param servers list of servers * @param topic topic name * - * @return a Topic Base * @throws IllegalArgumentException if invalid parameters are present */ public TopicBase(List<String> servers, String topic) { @@ -127,7 +126,7 @@ public abstract class TopicBase implements Topic { } /** - * broadcast event to all listeners + * Broadcast event to all listeners. * * @param message the event * @return true if all notifications are performed with no error, false otherwise @@ -148,7 +147,7 @@ public abstract class TopicBase implements Topic { } /** - * take a snapshot of current topic listeners + * Take a snapshot of current topic listeners. * * @return the topic listeners */ diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java index ee07d129..c002402d 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-endpoints * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,24 +34,24 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Http Client Factory + * Http Client Factory. */ public interface HttpClientFactory { /** - * build and http client with the following parameters + * Build and http client with the following parameters. */ public HttpClient build(String name, boolean https, boolean selfSignedCerts, String hostname, int port, String baseUrl, String userName, String password, boolean managed) throws KeyManagementException, NoSuchAlgorithmException; /** - * build http client from properties + * Build http client from properties. */ public List<HttpClient> build(Properties properties) throws KeyManagementException, NoSuchAlgorithmException; /** - * get http client + * Get http client. * * @param name the name * @return the http client @@ -59,14 +59,14 @@ public interface HttpClientFactory { public HttpClient get(String name); /** - * list of http clients + * List of http clients. * * @return http clients */ public List<HttpClient> inventory(); /** - * destroy by name + * Destroy by name. * * @param name name */ @@ -77,12 +77,12 @@ public interface HttpClientFactory { /** - * http client factory implementation indexed by name + * HTTP client factory implementation indexed by name. */ class IndexedHttpClientFactory implements HttpClientFactory { /** - * Logger + * Logger. */ private static Logger logger = LoggerFactory.getLogger(IndexedHttpClientFactory.class); diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java index d5e16117..0454e54b 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java @@ -43,7 +43,7 @@ import org.slf4j.LoggerFactory; public class JerseyClient implements HttpClient { /** - * Logger + * Logger. */ private static Logger logger = LoggerFactory.getLogger(JerseyClient.class); diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java index a2dd948a..1f008a8b 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java @@ -23,24 +23,25 @@ package org.onap.policy.common.endpoints.http.server; import org.onap.policy.common.capabilities.Startable; /** - * Http Servlet Server interface + * Http Servlet Server interface. */ public interface HttpServletServer extends Startable { /** - * Factory of Http Servlet Servers + * Factory of Http Servlet Servers. */ HttpServletServerFactory factory = new IndexedHttpServletServerFactory(); /** + * Get the port. * * @return port */ int getPort(); /** - * enables basic authentication with user and password on the the relative path relativeUriPath + * Enables basic authentication with user and password on the the relative path relativeUriPath. * * @param user user * @param password password @@ -49,7 +50,7 @@ public interface HttpServletServer extends Startable { void setBasicAuthentication(String user, String password, String relativeUriPath); /** - * adds a filter at the specified path + * Adds a filter at the specified path. * * @param filterPath filter path * @param filterClass filter class @@ -57,7 +58,7 @@ public interface HttpServletServer extends Startable { void addFilterClass(String filterPath, String filterClass); /** - * adds a JAX-RS servlet class to serve REST requests + * Adds a JAX-RS servlet class to serve REST requests. * * @param servletPath servlet path * @param restClass JAX-RS API Class @@ -68,7 +69,7 @@ public interface HttpServletServer extends Startable { void addServletClass(String servletPath, String restClass); /** - * adds a package containing JAX-RS classes to serve REST requests + * Adds a package containing JAX-RS classes to serve REST requests. * * @param servletPath servlet path * @param restPackage JAX-RS package to scan @@ -79,7 +80,7 @@ public interface HttpServletServer extends Startable { void addServletPackage(String servletPath, String restPackage); /** - * blocking start of the http server + * Blocking start of the http server. * * @param maxWaitTime max time to wait for the start to take place * @return true if start was successful diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactory.java index 4a430b20..8d2953b6 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactory.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactory.java @@ -33,12 +33,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Factory of HTTP Servlet-Enabled Servlets + * Factory of HTTP Servlet-Enabled Servlets. */ public interface HttpServletServerFactory { /** - * builds an http or https server with support for servlets + * Builds an http or https server with support for servlets. * * @param name name * @param https use secured http over tls connection @@ -54,7 +54,7 @@ public interface HttpServletServerFactory { boolean managed); /** - * builds an http server with support for servlets + * Builds an http server with support for servlets. * * @param name name * @param host binding host @@ -69,7 +69,7 @@ public interface HttpServletServerFactory { boolean managed); /** - * list of http servers per properties + * Build a list of http servers per properties. * * @param properties properties based configuration * @return list of http servers @@ -78,7 +78,7 @@ public interface HttpServletServerFactory { List<HttpServletServer> build(Properties properties); /** - * gets a server based on the port + * Gets a server based on the port. * * @param port port * @return http server @@ -86,45 +86,46 @@ public interface HttpServletServerFactory { HttpServletServer get(int port); /** - * provides an inventory of servers + * Provides an inventory of servers. * * @return inventory of servers */ List<HttpServletServer> inventory(); /** - * destroys server bound to a port + * Destroys server bound to a port. * - * @param port + * @param port the port the server is bound to */ void destroy(int port); /** - * destroys the factory and therefore all servers + * Destroys the factory and therefore all servers. */ void destroy(); } /** - * Indexed factory implementation + * Indexed factory implementation. */ class IndexedHttpServletServerFactory implements HttpServletServerFactory { private static final String SPACES_COMMA_SPACES = "\\s*,\\s*"; /** - * logger + * logger. */ protected static Logger logger = LoggerFactory.getLogger(IndexedHttpServletServerFactory.class); /** - * servers index + * servers index. */ protected HashMap<Integer, HttpServletServer> servers = new HashMap<>(); @Override - public synchronized HttpServletServer build(String name, boolean https, String host, int port, String contextPath, boolean swagger, + public synchronized HttpServletServer build(String name, boolean https, + String host, int port, String contextPath, boolean swagger, boolean managed) { if (servers.containsKey(port)) { diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java index 9932d094..72013395 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java @@ -30,78 +30,78 @@ import org.slf4j.LoggerFactory; import io.swagger.jersey.config.JerseyJaxrsConfig; /** - * REST Jetty Server that uses Jersey Servlets to support JAX-RS Web Services + * REST Jetty Server that uses Jersey Servlets to support JAX-RS Web Services. */ public class JettyJerseyServer extends JettyServletServer { /** - * Swagger API Base Path + * Swagger API Base Path. */ protected static final String SWAGGER_API_BASEPATH = "swagger.api.basepath"; /** - * Swagger Context ID + * Swagger Context ID. */ protected static final String SWAGGER_CONTEXT_ID = "swagger.context.id"; /** - * Swagger Scanner ID + * Swagger Scanner ID. */ protected static final String SWAGGER_SCANNER_ID = "swagger.scanner.id"; /** - * Swagger Pretty Print + * Swagger Pretty Print. */ protected static final String SWAGGER_PRETTY_PRINT = "swagger.pretty.print"; /** - * Swagger Packages + * Swagger Packages. */ protected static final String SWAGGER_INIT_PACKAGES_PARAM_VALUE = "io.swagger.jaxrs.listing"; /** - * Jersey Packages Init Param Name + * Jersey Packages Init Param Name. */ protected static final String JERSEY_INIT_PACKAGES_PARAM_NAME = "jersey.config.server.provider.packages"; /** - * Jersey Packages Init Param Value + * Jersey Packages Init Param Value. */ protected static final String JERSEY_INIT_PACKAGES_PARAM_VALUE = "com.fasterxml.jackson.jaxrs.json"; /** - * Jersey Classes Init Param Name + * Jersey Classes Init Param Name. */ protected static final String JERSEY_INIT_CLASSNAMES_PARAM_NAME = "jersey.config.server.provider.classnames"; /** - * Jersey Jackson Classes Init Param Value + * Jersey Jackson Classes Init Param Value. */ protected static final String JERSEY_JACKSON_INIT_CLASSNAMES_PARAM_VALUE = "com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider"; /** - * Jersey Swagger Classes Init Param Value + * Jersey Swagger Classes Init Param Value. */ protected static final String SWAGGER_INIT_CLASSNAMES_PARAM_VALUE = "io.swagger.jaxrs.listing.ApiListingResource," + "io.swagger.jaxrs.listing.SwaggerSerializers"; /** - * Logger + * Logger. */ protected static Logger logger = LoggerFactory.getLogger(JettyJerseyServer.class); /** - * Container for servlets + * Container for servlets. */ protected HashMap<String, ServletHolder> servlets = new HashMap<>(); /** - * Swagger ID + * Swagger ID. */ protected String swaggerId = null; /** - * Constructor + * Constructor. * * @param name name * @param https enable https? @@ -122,7 +122,7 @@ public class JettyJerseyServer extends JettyServletServer { } /** - * attaches a swagger initialization servlet + * Attaches a swagger initialization servlet. */ protected void attachSwaggerServlet(boolean https) { @@ -146,7 +146,7 @@ public class JettyJerseyServer extends JettyServletServer { } /** - * retrieves cached server based on servlet path + * Retrieves cached server based on servlet path. * * @param servletPath servlet path * @return the jetty servlet holder diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java index b22a9401..b866a81e 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java @@ -43,12 +43,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Http Server implementation using Embedded Jetty + * Http Server implementation using Embedded Jetty. */ public abstract class JettyServletServer implements HttpServletServer, Runnable { /** - * Keystore/Truststore system property names + * Keystore/Truststore system property names. */ public static final String SYSTEM_KEYSTORE_PROPERTY_NAME = "javax.net.ssl.keyStore"; public static final String SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME = "javax.net.ssl.keyStorePassword"; @@ -56,67 +56,67 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable public static final String SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME = "javax.net.ssl.trustStorePassword"; /** - * Logger + * Logger. */ private static Logger logger = LoggerFactory.getLogger(JettyServletServer.class); /** - * server name + * Server name. */ protected final String name; /** - * server host address + * Server host address. */ protected final String host; /** - * server port to bind + * Server port to bind. */ protected final int port; /** - * server auth user name + * Server auth user name. */ protected String user; /** - * server auth password name + * Server auth password name. */ protected String password; /** - * server base context path + * Server base context path. */ protected final String contextPath; /** - * embedded jetty server + * Embedded jetty server. */ protected final Server jettyServer; /** - * servlet context + * Servlet context. */ protected final ServletContextHandler context; /** - * jetty connector + * Jetty connector. */ protected final ServerConnector connector; /** - * jetty thread + * Jetty thread. */ protected volatile Thread jettyThread; /** - * start condition + * Start condition. */ protected Object startCondition = new Object(); /** - * constructor + * Constructor. * * @param name server name * @param host server host @@ -159,11 +159,12 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable this.jettyServer = new Server(); this.jettyServer.setRequestLog(new Slf4jRequestLog()); - if (https) + if (https) { this.connector = httpsConnector(); - else + } else { this.connector = httpConnector(); - + } + this.connector.setName(srvName); this.connector.setReuseAddress(true); this.connector.setPort(port); @@ -200,8 +201,9 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable sslContextFactory.setKeyStorePath(keyStore); String ksPassword = System.getProperty(SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME); - if (ksPassword != null) + if (ksPassword != null) { sslContextFactory.setKeyStorePassword(ksPassword); + } } String trustStore = System.getProperty(SYSTEM_TRUSTSTORE_PROPERTY_NAME); @@ -209,8 +211,9 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable sslContextFactory.setTrustStorePath(trustStore); String tsPassword = System.getProperty(SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME); - if (tsPassword != null) + if (tsPassword != null) { sslContextFactory.setTrustStorePassword(tsPassword); + } } HttpConfiguration https = new HttpConfiguration(); @@ -261,7 +264,7 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable } /** - * jetty server execution + * jetty server execution. */ @Override public void run() { @@ -425,6 +428,8 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable } /** + * Get name. + * * @return the name */ public String getName() { @@ -432,6 +437,8 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable } /** + * Get host. + * * @return the host */ public String getHost() { @@ -439,6 +446,8 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable } /** + * Get user. + * * @return the user */ public String getUser() { @@ -446,6 +455,8 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable } /** + * Get password. + * * @return the password */ @JsonIgnore |