summaryrefslogtreecommitdiffstats
path: root/feature-pooling-dmaap/src
diff options
context:
space:
mode:
Diffstat (limited to 'feature-pooling-dmaap/src')
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/DmaapManager.java33
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java41
-rw-r--r--feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/EndToEndFeatureTest.java12
3 files changed, 44 insertions, 42 deletions
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/DmaapManager.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/DmaapManager.java
index eb258b8c..674dc402 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/DmaapManager.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/DmaapManager.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,6 +24,7 @@ import java.util.List;
import org.onap.policy.common.endpoints.event.comm.FilterableTopicSource;
import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
+import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
@@ -65,7 +66,7 @@ public class DmaapManager {
/**
* Constructs the manager, but does not start the source or sink.
- *
+ *
* @param topic name of the internal DMaaP topic
* @throws PoolingFeatureException if an error occurs
*/
@@ -94,7 +95,7 @@ public class DmaapManager {
/**
* Finds the topic source associated with the internal DMaaP topic.
- *
+ *
* @return the topic source
* @throws PoolingFeatureException if the source doesn't exist or is not filterable
*/
@@ -115,7 +116,7 @@ public class DmaapManager {
/**
* Finds the topic sink associated with the internal DMaaP topic.
- *
+ *
* @return the topic sink
* @throws PoolingFeatureException if the sink doesn't exist
*/
@@ -143,7 +144,7 @@ public class DmaapManager {
/**
* Stops the publisher.
- *
+ *
* @param waitMs time, in milliseconds, to wait for the sink to transmit any queued messages and
* close
*/
@@ -170,7 +171,7 @@ public class DmaapManager {
/**
* Starts the consumer, if it isn't already running.
- *
+ *
* @param listener listener to register with the source
*/
public void startConsumer(TopicListener listener) {
@@ -185,7 +186,7 @@ public class DmaapManager {
/**
* Stops the consumer.
- *
+ *
* @param listener listener to unregister with the source
*/
public void stopConsumer(TopicListener listener) {
@@ -200,7 +201,7 @@ public class DmaapManager {
/**
* Sets the server-side filter to be used by the consumer.
- *
+ *
* @param filter the filter string, or {@code null} if no filter is to be used
* @throws PoolingFeatureException if the topic is not filterable
*/
@@ -216,7 +217,7 @@ public class DmaapManager {
/**
* Publishes a message to the sink.
- *
+ *
* @param msg message to be published
* @throws PoolingFeatureException if an error occurs or the publisher isn't running
*/
@@ -234,26 +235,26 @@ public class DmaapManager {
throw new PoolingFeatureException("cannot send to topic sink " + topic, e);
}
}
-
+
/*
* The remaining methods may be overridden by junit tests.
*/
/**
* Get topic source.
- *
+ *
* @return the topic sources
*/
protected List<TopicSource> getTopicSources() {
- return TopicEndpoint.manager.getTopicSources();
+ return TopicEndpointManager.getManager().getTopicSources();
}
/**
* Get topic sinks.
- *
+ *
* @return the topic sinks
*/
protected List<TopicSink> getTopicSinks() {
- return TopicEndpoint.manager.getTopicSinks();
+ return TopicEndpointManager.getManager().getTopicSinks();
}
}
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java
index 60a6f293..b45aed8d 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,9 +25,8 @@ import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
-
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
+import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
import org.onap.policy.common.utils.properties.SpecProperties;
@@ -46,8 +45,8 @@ import org.slf4j.LoggerFactory;
/**
* Controller/session pooling. Multiple hosts may be launched, all servicing the same
* controllers/sessions. When this feature is enabled, the requests are divided across the different
- * hosts, instead of all running on a single, active host.
- *
+ * hosts, instead of all running on a single, active host.
+ *
* <p>With each controller, there is an
* associated DMaaP topic that is used for internal communication between the different hosts
* serving the controller.
@@ -98,7 +97,7 @@ public class PoolingFeature implements PolicyEngineFeatureAPI, PolicyControllerF
/**
* Get active latch.
- *
+ *
* @return a latch that will be decremented when a manager enters the active state
*/
protected CountDownLatch getActiveLatch() {
@@ -134,7 +133,7 @@ public class PoolingFeature implements PolicyEngineFeatureAPI, PolicyControllerF
/**
* Adds the controller and a new pooling manager to {@link #ctlr2pool}.
- *
+ *
* @throws PoolingFeatureRtException if an error occurs
*/
@Override
@@ -292,7 +291,7 @@ public class PoolingFeature implements PolicyEngineFeatureAPI, PolicyControllerF
/**
* Executes a function using the manager associated with the controller. Catches any exceptions
* from the function and re-throws it as a runtime exception.
- *
+ *
* @param controller controller
* @param func function to be executed
* @return {@code true} if the function handled the request, {@code false} otherwise
@@ -314,7 +313,7 @@ public class PoolingFeature implements PolicyEngineFeatureAPI, PolicyControllerF
/**
* Deletes the manager associated with a controller.
- *
+ *
* @param controller controller
* @throws PoolingFeatureRtException if an error occurs
*/
@@ -334,7 +333,7 @@ public class PoolingFeature implements PolicyEngineFeatureAPI, PolicyControllerF
/**
* Apply.
- *
+ *
* @param mgr manager
* @return {@code true} if the request was handled by the manager, {@code false} otherwise
* @throws PoolingFeatureException feature exception
@@ -364,7 +363,7 @@ public class PoolingFeature implements PolicyEngineFeatureAPI, PolicyControllerF
/**
* Constructor.
- *
+ *
* @param protocol protocol
* @param topic topic
* @param event the actual event data received on the topic
@@ -375,14 +374,14 @@ public class PoolingFeature implements PolicyEngineFeatureAPI, PolicyControllerF
this.event = event;
}
}
-
+
/*
* The remaining methods may be overridden by junit tests.
*/
/**
* Get properties.
- *
+ *
* @param featName feature name
* @return the properties for the specified feature
*/
@@ -392,7 +391,7 @@ public class PoolingFeature implements PolicyEngineFeatureAPI, PolicyControllerF
/**
* Makes a pooling manager for a controller.
- *
+ *
* @param host name/uuid of this host
* @param controller controller
* @param props properties to use to configure the manager
@@ -406,7 +405,7 @@ public class PoolingFeature implements PolicyEngineFeatureAPI, PolicyControllerF
/**
* Gets the policy controller associated with a drools controller.
- *
+ *
* @param droolsController drools controller
* @return the policy controller associated with a drools controller
*/
@@ -416,21 +415,21 @@ public class PoolingFeature implements PolicyEngineFeatureAPI, PolicyControllerF
/**
* Initializes the topic sources.
- *
+ *
* @param props properties used to configure the topics
* @return the topic sources
*/
protected List<TopicSource> initTopicSources(Properties props) {
- return TopicEndpoint.manager.addTopicSources(props);
+ return TopicEndpointManager.getManager().addTopicSources(props);
}
/**
* Initializes the topic sinks.
- *
+ *
* @param props properties used to configure the topics
* @return the topic sinks
*/
protected List<TopicSink> initTopicSinks(Properties props) {
- return TopicEndpoint.manager.addTopicSinks(props);
+ return TopicEndpointManager.getManager().addTopicSinks(props);
}
}
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/EndToEndFeatureTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/EndToEndFeatureTest.java
index 0cbc0e00..bee25ff3 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/EndToEndFeatureTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/EndToEndFeatureTest.java
@@ -50,7 +50,7 @@ import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
+import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
@@ -143,10 +143,10 @@ public class EndToEndFeatureTest {
*/
@BeforeClass
public static void setUpBeforeClass() {
- externalSink = TopicEndpoint.manager.addTopicSinks(makeSinkProperties(EXTERNAL_TOPIC)).get(0);
+ externalSink = TopicEndpointManager.getManager().addTopicSinks(makeSinkProperties(EXTERNAL_TOPIC)).get(0);
externalSink.start();
- internalSink = TopicEndpoint.manager.addTopicSinks(makeSinkProperties(INTERNAL_TOPIC)).get(0);
+ internalSink = TopicEndpointManager.getManager().addTopicSinks(makeSinkProperties(INTERNAL_TOPIC)).get(0);
internalSink.start();
}
@@ -476,8 +476,10 @@ public class EndToEndFeatureTest {
when(controller.getName()).thenReturn(CONTROLLER1);
when(controller.getDrools()).thenReturn(drools);
- externalSource = TopicEndpoint.manager.addTopicSources(makeSourceProperties(EXTERNAL_TOPIC)).get(0);
- internalSource = TopicEndpoint.manager.addTopicSources(makeSourceProperties(INTERNAL_TOPIC)).get(0);
+ externalSource = TopicEndpointManager.getManager().addTopicSources(makeSourceProperties(EXTERNAL_TOPIC))
+ .get(0);
+ internalSource = TopicEndpointManager.getManager().addTopicSources(makeSourceProperties(INTERNAL_TOPIC))
+ .get(0);
// stop consuming events if the controller stops
when(controller.stop()).thenAnswer(args -> {