Merge "DMAAP Consumer logic"
diff --git a/policy-agent/pom.xml b/policy-agent/pom.xml
index 860fae1..52c69d5 100644
--- a/policy-agent/pom.xml
+++ b/policy-agent/pom.xml
@@ -1,294 +1,295 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * ========================LICENSE_START=================================
- * O-RAN-SC
- * %%
- * Copyright (C) 2019 Nordix Foundation
- * %%
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ========================LICENSE_END===================================
- -->
-<project
- xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-parent</artifactId>
- <version>2.1.6.RELEASE</version>
- <relativePath />
- </parent>
- <groupId>org.o-ran-sc.nonrtric</groupId>
- <artifactId>policy-agent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- </license>
- </licenses>
- <repositories>
- <repository>
- <id>onap-releases</id>
- <name>onap-releases</name>
- <url>https://nexus.onap.org/content/repositories/releases/</url>
- </repository>
- </repositories>
- <properties>
- <java.version>11</java.version>
- <springfox.version>2.8.0</springfox.version>
- <immutable.version>2.7.1</immutable.version>
- <sdk.version>1.1.6</sdk.version>
- <swagger.version>2.0.0</swagger.version>
- <json.version>20180130</json.version>
- <awaitility.version>4.0.1</awaitility.version>
- <maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
- <formatter-maven-plugin.version>2.8.1</formatter-maven-plugin.version>
- <spotless-maven-plugin.version>1.18.0</spotless-maven-plugin.version>
- <docker-maven-plugin>0.30.0</docker-maven-plugin>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-thymeleaf</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-webflux</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-devtools</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-webflux</artifactId>
- </dependency>
- <dependency>
- <groupId>io.swagger.core.v3</groupId>
- <artifactId>swagger-jaxrs2</artifactId>
- <version>${swagger.version}</version>
- </dependency>
- <dependency>
- <groupId>io.swagger.core.v3</groupId>
- <artifactId>swagger-jaxrs2-servlet-initializer</artifactId>
- <version>${swagger.version}</version>
- </dependency>
- <dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.immutables</groupId>
- <artifactId>value</artifactId>
- <version>${immutable.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.immutables</groupId>
- <artifactId>gson</artifactId>
- <version>${immutable.version}</version>
- </dependency>
- <dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>${json.version}</version>
- </dependency>
- <!--TEST -->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-configuration-processor</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId>
- <artifactId>cbs-client</artifactId>
- <version>${sdk.version}</version>
- </dependency>
- <!--REQUIRED TO GENERATE DOCUMENTATION -->
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger2</artifactId>
- <version>${springfox.version}</version>
- </dependency>
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger-ui</artifactId>
- <version>${springfox.version}</version>
- </dependency>
- <!-- TEST -->
- <dependency>
- <groupId>org.awaitility</groupId>
- <artifactId>awaitility</artifactId>
- <version>${awaitility.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.projectreactor</groupId>
- <artifactId>reactor-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-junit-jupiter</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>net.revelc.code.formatter</groupId>
- <artifactId>formatter-maven-plugin</artifactId>
- <version>${formatter-maven-plugin.version}</version>
- <configuration>
- <configFile>${project.basedir}/eclipse-formatter.xml</configFile>
- </configuration>
- <!-- https://code.revelc.net/formatter-maven-plugin/ use
- mvn formatter:format spotless:apply process-sources -->
- </plugin>
- <plugin>
- <groupId>com.diffplug.spotless</groupId>
- <artifactId>spotless-maven-plugin</artifactId>
- <version>${spotless-maven-plugin.version}</version>
- <configuration>
- <java>
- <removeUnusedImports />
- <importOrder>
- <order>com,java,javax,org</order>
- </importOrder>
- </java>
- </configuration>
- <!-- https://github.com/diffplug/spotless/tree/master/plugin-maven
- use mvn spotless:apply to rewrite source files use mvn spotless:check to
- validate source files -->
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skipTests>false</skipTests>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-failsafe-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>add-source</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>${project.build.directory}/generated-sources/annotations/</source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>io.fabric8</groupId>
- <artifactId>docker-maven-plugin</artifactId>
- <version>${docker-maven-plugin}</version>
- <inherited>false</inherited>
- <executions>
- <execution>
- <id>generate-policy-agent-image</id>
- <phase>package</phase>
- <goals>
- <goal>build</goal>
- </goals>
- <configuration>
- <pullRegistry>${env.CONTAINER_PULL_REGISTRY}</pullRegistry>
- <images>
- <image>
- <name>o-ran-sc/nonrtric-policy-agent:${project.version}</name>
- <build>
- <cleanup>try</cleanup>
- <contextDir>${basedir}</contextDir>
- <dockerFile>Dockerfile</dockerFile>
- <args>
- <JAR>${project.build.finalName}.jar</JAR>
- </args>
- <tags>
- <tag>${project.version}</tag>
- </tags>
- </build>
- </image>
- </images>
- </configuration>
- </execution>
- <execution>
- <id>push-policy-agent-image</id>
- <goals>
- <goal>build</goal>
- <goal>push</goal>
- </goals>
- <configuration>
- <pullRegistry>${env.CONTAINER_PULL_REGISTRY}</pullRegistry>
- <pushRegistry>${env.CONTAINER_PUSH_REGISTRY}</pushRegistry>
- <images>
- <image>
- <name>o-ran-sc/nonrtric-policy-agent:${project.version}</name>
- <build>
- <contextDir>${basedir}</contextDir>
- <dockerFile>Dockerfile</dockerFile>
- <args>
- <JAR>${project.build.finalName}.jar</JAR>
- </args>
- <tags>
- <tag>${project.version}</tag>
- </tags>
- </build>
- </image>
- </images>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <issueManagement>
- <system>JIRA</system>
- <url>https://jira.o-ran-sc.org/</url>
- </issueManagement>
+<!-- * ========================LICENSE_START=================================
+ * O-RAN-SC * %% * Copyright (C) 2019 Nordix Foundation * %% * 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. * See the License for the specific
+ language governing permissions and * limitations under the License. * ========================LICENSE_END=================================== -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-parent</artifactId>
+ <version>2.1.6.RELEASE</version>
+ <relativePath />
+ </parent>
+ <groupId>org.o-ran-sc.nonrtric</groupId>
+ <artifactId>policy-agent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <licenses>
+ <license>
+ <name>The Apache Software License, Version 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ </license>
+ </licenses>
+ <repositories>
+ <repository>
+ <id>onap-releases</id>
+ <name>onap-releases</name>
+ <url>https://nexus.onap.org/content/repositories/releases/</url>
+ </repository>
+ </repositories>
+ <properties>
+ <java.version>11</java.version>
+ <springfox.version>2.8.0</springfox.version>
+ <immutable.version>2.7.1</immutable.version>
+ <sdk.version>1.1.6</sdk.version>
+ <swagger.version>2.0.0</swagger.version>
+ <json.version>20180130</json.version>
+ <awaitility.version>4.0.1</awaitility.version>
+ <maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
+ <formatter-maven-plugin.version>2.8.1</formatter-maven-plugin.version>
+ <spotless-maven-plugin.version>1.18.0</spotless-maven-plugin.version>
+ <docker-maven-plugin>0.30.0</docker-maven-plugin>
+ <version.dmaap>1.1.9</version.dmaap>
+ <version.lombok>1.18.4</version.lombok>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-thymeleaf</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-webflux</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-devtools</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webflux</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger.core.v3</groupId>
+ <artifactId>swagger-jaxrs2</artifactId>
+ <version>${swagger.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger.core.v3</groupId>
+ <artifactId>swagger-jaxrs2-servlet-initializer</artifactId>
+ <version>${swagger.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.immutables</groupId>
+ <artifactId>value</artifactId>
+ <version>${immutable.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.immutables</groupId>
+ <artifactId>gson</artifactId>
+ <version>${immutable.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <version>${json.version}</version>
+ </dependency>
+ <!--TEST -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-configuration-processor</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId>
+ <artifactId>cbs-client</artifactId>
+ <version>${sdk.version}</version>
+ </dependency>
+ <!--REQUIRED TO GENERATE DOCUMENTATION -->
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger2</artifactId>
+ <version>${springfox.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.springfox</groupId>
+ <artifactId>springfox-swagger-ui</artifactId>
+ <version>${springfox.version}</version>
+ </dependency>
+ <!-- TEST -->
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <version>${awaitility.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.projectreactor</groupId>
+ <artifactId>reactor-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.dmaap.messagerouter.dmaapclient</groupId>
+ <artifactId>dmaapClient</artifactId>
+ <version>${version.dmaap}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>net.revelc.code.formatter</groupId>
+ <artifactId>formatter-maven-plugin</artifactId>
+ <version>${formatter-maven-plugin.version}</version>
+ <configuration>
+ <configFile>${project.basedir}/eclipse-formatter.xml</configFile>
+ </configuration>
+ <!-- https://code.revelc.net/formatter-maven-plugin/ use mvn formatter:format
+ spotless:apply process-sources -->
+ </plugin>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <removeUnusedImports />
+ <importOrder>
+ <order>com,java,javax,org</order>
+ </importOrder>
+ </java>
+ </configuration>
+ <!-- https://github.com/diffplug/spotless/tree/master/plugin-maven use
+ mvn spotless:apply to rewrite source files use mvn spotless:check to validate
+ source files -->
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>false</skipTests>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${project.build.directory}/generated-sources/annotations/</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>io.fabric8</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <version>${docker-maven-plugin}</version>
+ <inherited>false</inherited>
+ <executions>
+ <execution>
+ <id>generate-policy-agent-image</id>
+ <phase>package</phase>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ <configuration>
+ <pullRegistry>${env.CONTAINER_PULL_REGISTRY}</pullRegistry>
+ <images>
+ <image>
+ <name>o-ran-sc/nonrtric-policy-agent:${project.version}</name>
+ <build>
+ <cleanup>try</cleanup>
+ <contextDir>${basedir}</contextDir>
+ <dockerFile>Dockerfile</dockerFile>
+ <args>
+ <JAR>${project.build.finalName}.jar</JAR>
+ </args>
+ <tags>
+ <tag>${project.version}</tag>
+ </tags>
+ </build>
+ </image>
+ </images>
+ </configuration>
+ </execution>
+ <execution>
+ <id>push-policy-agent-image</id>
+ <goals>
+ <goal>build</goal>
+ <goal>push</goal>
+ </goals>
+ <configuration>
+ <pullRegistry>${env.CONTAINER_PULL_REGISTRY}</pullRegistry>
+ <pushRegistry>${env.CONTAINER_PUSH_REGISTRY}</pushRegistry>
+ <images>
+ <image>
+ <name>o-ran-sc/nonrtric-policy-agent:${project.version}</name>
+ <build>
+ <contextDir>${basedir}</contextDir>
+ <dockerFile>Dockerfile</dockerFile>
+ <args>
+ <JAR>${project.build.finalName}.jar</JAR>
+ </args>
+ <tags>
+ <tag>${project.version}</tag>
+ </tags>
+ </build>
+ </image>
+ </images>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <issueManagement>
+ <system>JIRA</system>
+ <url>https://jira.o-ran-sc.org/</url>
+ </issueManagement>
</project>
diff --git a/policy-agent/src/main/java/org/oransc/policyagent/dmaap/BusTopicParams.java b/policy-agent/src/main/java/org/oransc/policyagent/dmaap/BusTopicParams.java
new file mode 100644
index 0000000..47ab592
--- /dev/null
+++ b/policy-agent/src/main/java/org/oransc/policyagent/dmaap/BusTopicParams.java
@@ -0,0 +1,17 @@
+package org.oransc.policyagent.dmaap;
+
+import org.springframework.context.annotation.Configuration;
+
+@Configuration("dmaap")
+public class BusTopicParams {
+
+ private int port;
+ private String server;
+ private String topic;
+ private String consumerGroup;
+ private String consumerInstance;
+ private int fetchTimeout;
+ private int fetchLimit;
+ private String userName;
+ private String password;
+}
\ No newline at end of file
diff --git a/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageConsumer.java b/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageConsumer.java
new file mode 100644
index 0000000..42be12d
--- /dev/null
+++ b/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageConsumer.java
@@ -0,0 +1,22 @@
+package org.oransc.policyagent.dmaap;
+
+import java.util.Properties;
+
+/**
+ * The Dmaap consumer which has the base methods to be implemented by any class
+ * which implements this interface
+ *
+ */
+public interface DmaapMessageConsumer extends Runnable {
+
+ public void init(Properties baseProperties);
+
+ public abstract void processMsg(String msg) throws Exception;
+
+ public boolean isReady();
+
+ public boolean isRunning();
+
+ public void stopConsumer();
+
+}
diff --git a/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageConsumerImpl.java b/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageConsumerImpl.java
new file mode 100644
index 0000000..b64a822
--- /dev/null
+++ b/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageConsumerImpl.java
@@ -0,0 +1,54 @@
+package org.oransc.policyagent.dmaap;
+
+import java.util.Properties;
+
+import org.onap.dmaap.mr.client.impl.MRConsumerImpl;
+
+public class DmaapMessageConsumerImpl implements DmaapMessageConsumer {
+
+ protected MRConsumerImpl consumer;
+
+ public DmaapMessageConsumerImpl() {
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void run() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void init(Properties baseProperties) {
+ // Initialize the DMAAP with the properties
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void processMsg(String msg) throws Exception {
+ // Call the Controller once you get the message from DMAAP
+ // Call the concurrent Task executor to handle the incoming request
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean isReady() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isRunning() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void stopConsumer() {
+ // TODO Auto-generated method stub
+
+ }
+
+}