aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexis de Talhouët <adetalhouet89@gmail.com>2019-05-17 13:50:31 -0400
committerAlexis de Talhouët <adetalhouet89@gmail.com>2019-06-21 01:15:05 +0000
commit056b4e088e4d8df0e642ea9603f7a82fc98ab58c (patch)
tree85daa84b50d1f37d8f54e3cb2b6234b48551ab4d
parentfaaa1a75d85a522847acf4c7250b8da5f076cfa0 (diff)
Delete grpc client to CDS
Change-Id: I82dc77cbc28d68b06634a67708d29f750cfec2e9 Issue-ID: CCSDK-1340 Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
-rw-r--r--features/ccsdk-sli-adaptors-all/pom.xml7
-rw-r--r--grpc-resource/features/ccsdk-grpc-client/pom.xml63
-rwxr-xr-xgrpc-resource/features/features-grpc-client/pom.xml48
-rwxr-xr-xgrpc-resource/features/pom.xml38
-rwxr-xr-xgrpc-resource/installer/pom.xml168
-rw-r--r--grpc-resource/installer/src/assembly/assemble_installer_zip.xml53
-rw-r--r--grpc-resource/installer/src/assembly/assemble_mvnrepo_zip.xml43
-rw-r--r--grpc-resource/installer/src/main/resources/scripts/install-feature.sh34
-rw-r--r--grpc-resource/pom.xml40
-rw-r--r--grpc-resource/provider/pom.xml158
-rw-r--r--grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/GrpcClient.java32
-rw-r--r--grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/GrpcProperties.java81
-rw-r--r--grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/JsonFormat.java668
-rw-r--r--grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/Utils.java34
-rw-r--r--grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/cds/BasicAuthClientInterceptor.java54
-rw-r--r--grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/cds/BlueprintProcessingClient.java86
-rw-r--r--grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/cds/BlueprintProcessingHandler.java187
-rw-r--r--grpc-resource/provider/src/main/resources/grpc.properties18
-rw-r--r--grpc-resource/provider/src/main/resources/org/opendaylight/blueprint/grpc-client.xml30
-rw-r--r--grpc-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/grpc/cds/BlueprintProcessingClientTest.java171
-rw-r--r--grpc-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/grpc/cds/GrpcClientTest.java84
-rwxr-xr-xpom.xml1
22 files changed, 0 insertions, 2098 deletions
diff --git a/features/ccsdk-sli-adaptors-all/pom.xml b/features/ccsdk-sli-adaptors-all/pom.xml
index d9eec43e..9eac035b 100644
--- a/features/ccsdk-sli-adaptors-all/pom.xml
+++ b/features/ccsdk-sli-adaptors-all/pom.xml
@@ -44,13 +44,6 @@
<classifier>features</classifier>
</dependency>
-->
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ccsdk-grpc-client</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
diff --git a/grpc-resource/features/ccsdk-grpc-client/pom.xml b/grpc-resource/features/ccsdk-grpc-client/pom.xml
deleted file mode 100644
index c81e94ba..00000000
--- a/grpc-resource/features/ccsdk-grpc-client/pom.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (C) 2019 Bell Canada
-
- 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.
- -->
-<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>single-feature-parent</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.onap.ccsdk.sli.adaptors</groupId>
- <artifactId>ccsdk-grpc-client</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- <packaging>feature</packaging>
-
- <name>ccsdk-sli-adaptors :: grpc-client :: ${project.artifactId}</name>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-mdsal-broker</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
-
- <dependency>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <artifactId>ccsdk-sli</artifactId>
- <version>${ccsdk.sli.core.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>grpc-client-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <!--overwrite protobuf jave version-->
- <dependency>
- <groupId>com.google.protobuf</groupId>
- <artifactId>protobuf-java</artifactId>
- <version>3.6.1</version>
- </dependency>
- </dependencies>
-</project>
diff --git a/grpc-resource/features/features-grpc-client/pom.xml b/grpc-resource/features/features-grpc-client/pom.xml
deleted file mode 100755
index ffe6e9a1..00000000
--- a/grpc-resource/features/features-grpc-client/pom.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (C) 2019 Bell Canada
-
- 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.
- -->
-<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>feature-repo-parent</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.onap.ccsdk.sli.adaptors</groupId>
- <artifactId>features-grpc-client</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- <packaging>feature</packaging>
-
- <name>ccsdk-sli-adaptors :: grpc-client :: ${project.artifactId}</name>
-
- <properties>
- <ccsdk.sli.adaptors.version>${project.version}</ccsdk.sli.adaptors.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>ccsdk-grpc-client</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
-
- </dependencies>
-</project>
diff --git a/grpc-resource/features/pom.xml b/grpc-resource/features/pom.xml
deleted file mode 100755
index 233d8cda..00000000
--- a/grpc-resource/features/pom.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (C) 2019 Bell Canada
-
- 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.
- -->
-<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>odlparent-lite</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.onap.ccsdk.sli.adaptors</groupId>
- <artifactId>grpc-client-features</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <name>ccsdk-sli-adaptors :: grpc-client :: ${project.artifactId}</name>
-
- <modules>
- <module>ccsdk-grpc-client</module>
- <module>features-grpc-client</module>
- </modules>
-</project>
diff --git a/grpc-resource/installer/pom.xml b/grpc-resource/installer/pom.xml
deleted file mode 100755
index a57e7251..00000000
--- a/grpc-resource/installer/pom.xml
+++ /dev/null
@@ -1,168 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (C) 2019 Bell Canada
-
- 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.
- -->
-<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>odlparent-lite</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.onap.ccsdk.sli.adaptors</groupId>
- <artifactId>grpc-client-installer</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <name>ccsdk-sli-adaptors :: grpc-client :: ${project.artifactId}</name>
-
- <properties>
- <application.name>ccsdk-grpc-client</application.name>
- <features.boot>${application.name}</features.boot>
- <features.repositories>mvn:org.onap.ccsdk.sli.adaptors/${features.boot}/${project.version}/xml/features
- </features.repositories>
- <include.transitive.dependencies>false</include.transitive.dependencies>
- </properties>
-
- <dependencies>
-
- <dependency>
- <groupId>org.onap.ccsdk.sli.adaptors</groupId>
- <artifactId>ccsdk-grpc-client</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>features</classifier>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.onap.ccsdk.sli.adaptors</groupId>
- <artifactId>grpc-client-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.6</version>
- <executions>
- <execution>
- <id>maven-repo-zip</id>
- <goals>
- <goal>single</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <attach>true</attach>
- <finalName>stage/${application.name}-${project.version}</finalName>
- <descriptors>
- <descriptor>src/assembly/assemble_mvnrepo_zip.xml</descriptor>
- </descriptors>
- <appendAssemblyId>true</appendAssemblyId>
- </configuration>
- </execution>
- <execution>
- <id>installer-zip</id>
- <goals>
- <goal>single</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <attach>true</attach>
- <finalName>${application.name}-${project.version}-installer</finalName>
- <descriptors>
- <descriptor>src/assembly/assemble_installer_zip.xml</descriptor>
- </descriptors>
- <appendAssemblyId>false</appendAssemblyId>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <phase>prepare-package</phase>
- <configuration>
- <transitive>false</transitive>
- <outputDirectory>${project.build.directory}/assembly/system</outputDirectory>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>true</overWriteSnapshots>
- <overWriteIfNewer>true</overWriteIfNewer>
- <useRepositoryLayout>true</useRepositoryLayout>
- <addParentPoms>false</addParentPoms>
- <copyPom>false</copyPom>
- <includeGroupIds>
- org.onap.ccsdk.sli.adaptors,
- org.onap.ccsdk.cds.components,
- io.grpc,
- io.netty,
- com.google.protobuf,
- io.opencensus,
- com.google.api.grpc,
- com.google.errorprone,
- org.codehaus.mojo
- </includeGroupIds>
- <scope>provided</scope>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <version>2.6</version>
- <executions>
- <execution>
- <id>copy-version</id>
- <goals>
- <goal>copy-resources</goal>
- </goals><!-- here the phase you need -->
- <phase>validate</phase>
- <configuration>
- <outputDirectory>${basedir}/target/stage</outputDirectory>
- <resources>
- <resource>
- <directory>src/main/resources/scripts</directory>
- <includes>
- <include>install-feature.sh</include>
- </includes>
- <filtering>true</filtering>
- </resource>
- </resources>
- </configuration>
- </execution>
-
- </executions>
- </plugin>
-
- </plugins>
- </build>
-</project>
diff --git a/grpc-resource/installer/src/assembly/assemble_installer_zip.xml b/grpc-resource/installer/src/assembly/assemble_installer_zip.xml
deleted file mode 100644
index 1a05df9c..00000000
--- a/grpc-resource/installer/src/assembly/assemble_installer_zip.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<!--
- Copyright (C) 2019 Bell Canada
-
- 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.
- -->
-
-<!-- Defines how we build the .zip file which is our distribution. -->
-
-<assembly
- xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
- <id>installer_zip</id>
- <formats>
- <format>zip</format>
- </formats>
-
- <!-- we want "system" and related files right at the root level
- as this file is suppose to be unzip on top of a karaf
- distro. -->
- <includeBaseDirectory>false</includeBaseDirectory>
-
- <fileSets>
- <fileSet>
- <directory>target/stage/</directory>
- <outputDirectory>${application.name}</outputDirectory>
- <fileMode>755</fileMode>
- <includes>
- <include>*.sh</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>target/stage/</directory>
- <outputDirectory>${application.name}</outputDirectory>
- <fileMode>644</fileMode>
- <excludes>
- <exclude>*.sh</exclude>
- </excludes>
- </fileSet>
- </fileSets>
-
-
-</assembly>
diff --git a/grpc-resource/installer/src/assembly/assemble_mvnrepo_zip.xml b/grpc-resource/installer/src/assembly/assemble_mvnrepo_zip.xml
deleted file mode 100644
index ae6765f4..00000000
--- a/grpc-resource/installer/src/assembly/assemble_mvnrepo_zip.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<!--
- Copyright (C) 2019 Bell Canada
-
- 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.
- -->
-
-<!-- Defines how we build the .zip file which is our distribution. -->
-
-<assembly
- xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
- <id>repo</id>
- <formats>
- <format>zip</format>
- </formats>
-
- <!-- we want "system" and related files right at the root level
- as this file is suppose to be unzip on top of a karaf
- distro. -->
- <includeBaseDirectory>false</includeBaseDirectory>
-
- <fileSets>
- <fileSet>
- <directory>target/assembly/</directory>
- <outputDirectory>.</outputDirectory>
- <excludes>
- </excludes>
- </fileSet>
- </fileSets>
-
-
-</assembly>
diff --git a/grpc-resource/installer/src/main/resources/scripts/install-feature.sh b/grpc-resource/installer/src/main/resources/scripts/install-feature.sh
deleted file mode 100644
index 7e022e84..00000000
--- a/grpc-resource/installer/src/main/resources/scripts/install-feature.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/bash
-
-#
-# Copyright (C) 2019 Bell Canada
-#
-# 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.
-#
-
-ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}
-ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client}
-INSTALLERDIR=$(dirname $0)
-
-REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip
-
-if [ -f ${REPOZIP} ]
-then
- unzip -nd ${ODL_HOME} ${REPOZIP}
-else
- echo "ERROR : repo zip ($REPOZIP) not found"
- exit 1
-fi
-
-${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories}
-${ODL_KARAF_CLIENT} feature:install ${features.boot}
diff --git a/grpc-resource/pom.xml b/grpc-resource/pom.xml
deleted file mode 100644
index edb83076..00000000
--- a/grpc-resource/pom.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (C) 2019 Bell Canada
-
- 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.
- -->
-<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>odlparent-lite</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.onap.ccsdk.sli.adaptors</groupId>
- <artifactId>grpc-client</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <name>ccsdk-sli-adaptors :: grpc-client</name>
- <description>The CCSDK Adaptors for gRPC as an OSGi service</description>
-
- <modules>
- <module>provider</module>
- <module>features</module>
- <module>installer</module>
- </modules>
-</project>
diff --git a/grpc-resource/provider/pom.xml b/grpc-resource/provider/pom.xml
deleted file mode 100644
index bb1239f9..00000000
--- a/grpc-resource/provider/pom.xml
+++ /dev/null
@@ -1,158 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (C) 2019 Bell Canada
-
- 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.
- -->
-<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>binding-parent</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- <relativePath/>
- </parent>
-
- <groupId>org.onap.ccsdk.sli.adaptors</groupId>
- <artifactId>grpc-client-provider</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
- <modelVersion>4.0.0</modelVersion>
-
- <name>ccsdk-sli-adaptors :: grpc-client :: ${project.artifactId}</name>
-
- <properties>
- <grpc.version>1.17.1</grpc.version>
- <protobuf.version>3.6.1</protobuf.version>
- <grpc.netty.version>4.1.30.Final</grpc.netty.version>
- <ccsdk.sli.cds.version>${project.version}</ccsdk.sli.cds.version>
- </properties>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <artifactId>sli-core-artifacts</artifactId>
- <version>${ccsdk.sli.core.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <dependencies>
-
- <!-- SLI dependencies -->
- <dependency>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <artifactId>sliPluginUtils-provider</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <!-- CDS dependencies -->
- <dependency>
- <groupId>org.onap.ccsdk.cds.components</groupId>
- <artifactId>proto-definition</artifactId>
- <version>${ccsdk.sli.cds.version}</version>
- <exclusions>
- <exclusion>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>jsr305</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.google.protobuf</groupId>
- <artifactId>protobuf-java-util</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <!-- protobuf dependencies -->
- <dependency>
- <groupId>com.google.protobuf</groupId>
- <artifactId>protobuf-java</artifactId>
- <version>${protobuf.version}</version>
- </dependency>
-
- <!-- gRPC dependencies -->
- <dependency>
- <groupId>io.grpc</groupId>
- <artifactId>grpc-protobuf</artifactId>
- <version>${grpc.version}</version>
- <exclusions>
- <exclusion>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>jsr305</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>io.grpc</groupId>
- <artifactId>grpc-stub</artifactId>
- <version>${grpc.version}</version>
- </dependency>
- <dependency>
- <groupId>io.grpc</groupId>
- <artifactId>grpc-netty</artifactId>
- <version>${grpc.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <!-- Testing -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>${mockito.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.grpc</groupId>
- <artifactId>grpc-testing</artifactId>
- <version>${grpc.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- io.grpc,
- io.grpc.inprocess,
- io.grpc.internal,
- io.grpc.util
- </Export-Package>
- <Import-Package>!com.google.errorprone.annotations,*</Import-Package>
- <Embed-Dependency>*;inline=META-INF/services/**</Embed-Dependency>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
diff --git a/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/GrpcClient.java b/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/GrpcClient.java
deleted file mode 100644
index 91788274..00000000
--- a/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/GrpcClient.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2019 Bell Canada.
- *
- * 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.
- */
-package org.onap.ccsdk.sli.adaptors.grpc;
-
-import java.util.Map;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
-
-public interface GrpcClient extends SvcLogicJavaPlugin {
-
- /**
- * Send a request to process to a gRPC server.
- *
- * @param parameters HashMap<String,String> of parameters passed by the DG to this function.
- * Required parameters are defined in implemention.
- */
- QueryStatus sendRequest(Map<String, String> parameters, SvcLogicContext ctx);
-}
diff --git a/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/GrpcProperties.java b/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/GrpcProperties.java
deleted file mode 100644
index ff158c2e..00000000
--- a/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/GrpcProperties.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2018 Bell Canada.
- *
- * 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.
- */
-package org.onap.ccsdk.sli.adaptors.grpc;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Properties;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class GrpcProperties {
-
- private static final Logger LOG = LoggerFactory.getLogger(GrpcProperties.class);
-
- private static final String GRPC_PROPERTY_FILE_NAME = "grpc.properties";
- private static final String DEFAULT_PROPERTIES_DIR = "/opt/onap/ccsdk/data/properties";
- private static final String PROPERTIES_DIR_KEY = "SDNC_CONFIG_DIR";
-
- private static final String BLUEPRINT_PROCESSOR_URL_PROP = "org.onap.ccsdk.sli.adaptors.grpc.blueprint.processor.url";
- private static final String BLUEPRINT_PROCESSOR_PORT_PROP = "org.onap.ccsdk.sli.adaptors.grpc.blueprint.processor.port";
- private static final String BLUEPRINT_PROCESSOR_AUTH_PROP = "org.onap.ccsdk.sli.adaptors.grpc.blueprint.processor.auth";
-
- private Properties properties;
-
- public GrpcProperties() {
- loadProps();
- }
-
- public String getUrl() {
- return properties.getProperty(BLUEPRINT_PROCESSOR_URL_PROP);
- }
-
- public String getAuth() {
- return properties.getProperty(BLUEPRINT_PROCESSOR_AUTH_PROP);
- }
-
- public int getPort() {
- return Integer.parseInt(properties.getProperty(BLUEPRINT_PROCESSOR_PORT_PROP));
- }
-
- private void loadProps() {
- properties = new Properties();
- // Try to load config from dir
- final String ccsdkConfigDir =
- System.getProperty(PROPERTIES_DIR_KEY, DEFAULT_PROPERTIES_DIR) + "/" + GRPC_PROPERTY_FILE_NAME;
- try (FileInputStream in = new FileInputStream(ccsdkConfigDir)) {
- properties.load(in);
- LOG.info("Loaded {} properties from file {}", properties.size(), ccsdkConfigDir);
- } catch (Exception e) {
- // Try to load config from jar
- final Bundle bundle = FrameworkUtil.getBundle(GrpcProperties.class);
- final BundleContext ctx = bundle.getBundleContext();
- final URL url = ctx.getBundle().getResource(GRPC_PROPERTY_FILE_NAME);
-
- try (InputStream inputStream = url.openStream()) {
- properties.load(inputStream);
- LOG.info("Loaded {} properties from file {}", properties.size(), GRPC_PROPERTY_FILE_NAME);
- } catch (IOException e1) {
- LOG.error("Failed to load properties for file: {} " + GRPC_PROPERTY_FILE_NAME, e1);
- }
- }
- }
-}
diff --git a/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/JsonFormat.java b/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/JsonFormat.java
deleted file mode 100644
index d169f14c..00000000
--- a/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/JsonFormat.java
+++ /dev/null
@@ -1,668 +0,0 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-package org.onap.ccsdk.sli.adaptors.grpc;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonNull;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonPrimitive;
-import com.google.gson.stream.JsonReader;
-import com.google.protobuf.Any;
-import com.google.protobuf.BoolValue;
-import com.google.protobuf.BytesValue;
-import com.google.protobuf.Descriptors.Descriptor;
-import com.google.protobuf.Descriptors.FieldDescriptor;
-import com.google.protobuf.Descriptors.FieldDescriptor.JavaType;
-import com.google.protobuf.DoubleValue;
-import com.google.protobuf.FloatValue;
-import com.google.protobuf.Int32Value;
-import com.google.protobuf.Int64Value;
-import com.google.protobuf.InvalidProtocolBufferException;
-import com.google.protobuf.ListValue;
-import com.google.protobuf.Message;
-import com.google.protobuf.MessageOrBuilder;
-import com.google.protobuf.NullValue;
-import com.google.protobuf.StringValue;
-import com.google.protobuf.Struct;
-import com.google.protobuf.UInt32Value;
-import com.google.protobuf.UInt64Value;
-import com.google.protobuf.Value;
-import java.io.IOException;
-import java.io.StringReader;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-//Fork from :
-//
-//<dependency>
-//<groupId>com.google.protobuf</groupId>
-//<artifactId>protobuf-java-util</artifactId>
-//<version>3.6.1</version>
-//</dependency>
-
-public class JsonFormat {
-
- private JsonFormat() {
- }
-
- public static JsonFormat.Printer printer() {
- return new JsonFormat.Printer(JsonFormat.TypeRegistry.getEmptyTypeRegistry(), false, Collections.emptySet(),
- false, false, false);
- }
-
- public static JsonFormat.Parser parser() {
- return new JsonFormat.Parser(JsonFormat.TypeRegistry.getEmptyTypeRegistry(), false, 100);
- }
-
- private static class ParserImpl {
-
- private final JsonFormat.TypeRegistry registry;
- private final JsonParser jsonParser;
- private final boolean ignoringUnknownFields;
- private final int recursionLimit;
- private int currentDepth;
- private static final Map<String, JsonFormat.ParserImpl.WellKnownTypeParser> wellKnownTypeParsers = buildWellKnownTypeParsers();
- private final Map<Descriptor, Map<String, FieldDescriptor>> fieldNameMaps = new HashMap();
- private static final BigInteger MAX_UINT64 = new BigInteger("FFFFFFFFFFFFFFFF", 16);
- private static final double EPSILON = 1.0E-6D;
- private static final BigDecimal MORE_THAN_ONE = new BigDecimal(String.valueOf(1.000001D));
- private static final BigDecimal MAX_DOUBLE;
- private static final BigDecimal MIN_DOUBLE;
-
- ParserImpl(JsonFormat.TypeRegistry registry, boolean ignoreUnknownFields, int recursionLimit) {
- this.registry = registry;
- this.ignoringUnknownFields = ignoreUnknownFields;
- this.jsonParser = new JsonParser();
- this.recursionLimit = recursionLimit;
- this.currentDepth = 0;
- }
-
- void merge(String json, com.google.protobuf.Message.Builder builder) throws InvalidProtocolBufferException {
- try {
- JsonReader reader = new JsonReader(new StringReader(json));
- reader.setLenient(false);
- this.merge(this.jsonParser.parse(reader), builder);
- } catch (InvalidProtocolBufferException var4) {
- throw var4;
- } catch (Exception var5) {
- throw new InvalidProtocolBufferException(var5.getMessage());
- }
- }
-
- private static Map<String, JsonFormat.ParserImpl.WellKnownTypeParser> buildWellKnownTypeParsers() {
- Map<String, JsonFormat.ParserImpl.WellKnownTypeParser> parsers = new HashMap();
- parsers.put(Any.getDescriptor().getFullName(), new JsonFormat.ParserImpl.WellKnownTypeParser() {
- public void merge(JsonFormat.ParserImpl parser, JsonElement json,
- com.google.protobuf.Message.Builder builder) throws InvalidProtocolBufferException {
- }
- });
- JsonFormat.ParserImpl.WellKnownTypeParser wrappersPrinter = new JsonFormat.ParserImpl.WellKnownTypeParser() {
- public void merge(JsonFormat.ParserImpl parser, JsonElement json,
- com.google.protobuf.Message.Builder builder) throws InvalidProtocolBufferException {
- }
- };
- parsers.put(BoolValue.getDescriptor().getFullName(), wrappersPrinter);
- parsers.put(Int32Value.getDescriptor().getFullName(), wrappersPrinter);
- parsers.put(UInt32Value.getDescriptor().getFullName(), wrappersPrinter);
- parsers.put(Int64Value.getDescriptor().getFullName(), wrappersPrinter);
- parsers.put(UInt64Value.getDescriptor().getFullName(), wrappersPrinter);
- parsers.put(StringValue.getDescriptor().getFullName(), wrappersPrinter);
- parsers.put(BytesValue.getDescriptor().getFullName(), wrappersPrinter);
- parsers.put(FloatValue.getDescriptor().getFullName(), wrappersPrinter);
- parsers.put(DoubleValue.getDescriptor().getFullName(), wrappersPrinter);
- parsers.put(Struct.getDescriptor().getFullName(), new JsonFormat.ParserImpl.WellKnownTypeParser() {
- public void merge(JsonFormat.ParserImpl parser, JsonElement json,
- com.google.protobuf.Message.Builder builder) throws InvalidProtocolBufferException {
- parser.mergeStruct(json, builder);
- }
- });
- parsers.put(ListValue.getDescriptor().getFullName(), new JsonFormat.ParserImpl.WellKnownTypeParser() {
- public void merge(JsonFormat.ParserImpl parser, JsonElement json,
- com.google.protobuf.Message.Builder builder) throws InvalidProtocolBufferException {
- }
- });
- parsers.put(Value.getDescriptor().getFullName(), new JsonFormat.ParserImpl.WellKnownTypeParser() {
- public void merge(JsonFormat.ParserImpl parser, JsonElement json,
- com.google.protobuf.Message.Builder builder) throws InvalidProtocolBufferException {
- parser.mergeValue(json, builder);
- }
- });
- return parsers;
- }
-
- private void merge(JsonElement json, com.google.protobuf.Message.Builder builder)
- throws InvalidProtocolBufferException {
- JsonFormat.ParserImpl.WellKnownTypeParser specialParser = (JsonFormat.ParserImpl.WellKnownTypeParser) wellKnownTypeParsers
- .get(builder.getDescriptorForType().getFullName());
- if (specialParser != null) {
- specialParser.merge(this, json, builder);
- }
- }
-
-
- private void mergeStruct(JsonElement json, com.google.protobuf.Message.Builder builder)
- throws InvalidProtocolBufferException {
- Descriptor descriptor = builder.getDescriptorForType();
- FieldDescriptor field = descriptor.findFieldByName("fields");
- if (field == null) {
- throw new InvalidProtocolBufferException("Invalid Struct type.");
- } else {
- this.mergeMapField(field, json, builder);
- }
- }
-
- private void mergeValue(JsonElement json, com.google.protobuf.Message.Builder builder)
- throws InvalidProtocolBufferException {
- Descriptor type = builder.getDescriptorForType();
- if (json instanceof JsonPrimitive) {
- JsonPrimitive primitive = (JsonPrimitive) json;
- if (primitive.isBoolean()) {
- builder.setField(type.findFieldByName("bool_value"), primitive.getAsBoolean());
- } else if (primitive.isNumber()) {
- builder.setField(type.findFieldByName("number_value"), primitive.getAsDouble());
- } else {
- builder.setField(type.findFieldByName("string_value"), primitive.getAsString());
- }
- } else {
- com.google.protobuf.Message.Builder listBuilder;
- FieldDescriptor field;
- if (json instanceof JsonObject) {
- field = type.findFieldByName("struct_value");
- listBuilder = builder.newBuilderForField(field);
- this.merge(json, listBuilder);
- builder.setField(field, listBuilder.build());
- } else if (json instanceof JsonArray) {
- field = type.findFieldByName("list_value");
- listBuilder = builder.newBuilderForField(field);
- this.merge(json, listBuilder);
- builder.setField(field, listBuilder.build());
- } else {
- if (!(json instanceof JsonNull)) {
- throw new IllegalStateException("Unexpected json data: " + json);
- }
-
- builder.setField(type.findFieldByName("null_value"), NullValue.NULL_VALUE.getValueDescriptor());
- }
- }
-
- }
-
- private void mergeMapField(FieldDescriptor field, JsonElement json, com.google.protobuf.Message.Builder builder)
- throws InvalidProtocolBufferException {
- if (!(json instanceof JsonObject)) {
- throw new InvalidProtocolBufferException("Expect a map object but found: " + json);
- } else {
- Descriptor type = field.getMessageType();
- FieldDescriptor keyField = type.findFieldByName("key");
- FieldDescriptor valueField = type.findFieldByName("value");
- if (keyField != null && valueField != null) {
- JsonObject object = (JsonObject) json;
- Iterator var8 = object.entrySet().iterator();
-
- while (var8.hasNext()) {
- Entry<String, JsonElement> entry = (Entry) var8.next();
- com.google.protobuf.Message.Builder entryBuilder = builder.newBuilderForField(field);
- Object key = this
- .parseFieldValue(keyField, new JsonPrimitive((String) entry.getKey()), entryBuilder);
- Object value = this.parseFieldValue(valueField, (JsonElement) entry.getValue(), entryBuilder);
- if (value == null) {
- throw new InvalidProtocolBufferException("Map value cannot be null.");
- }
-
- entryBuilder.setField(keyField, key);
- entryBuilder.setField(valueField, value);
- builder.addRepeatedField(field, entryBuilder.build());
- }
-
- } else {
- throw new InvalidProtocolBufferException("Invalid map field: " + field.getFullName());
- }
- }
- }
-
- private String parseString(JsonElement json) {
- return json.getAsString();
- }
-
- private Object parseFieldValue(FieldDescriptor field, JsonElement json,
- com.google.protobuf.Message.Builder builder) throws InvalidProtocolBufferException {
- if (json instanceof JsonNull) {
- if (field.getJavaType() == JavaType.MESSAGE && field.getMessageType().getFullName()
- .equals(Value.getDescriptor().getFullName())) {
- Value value = Value.newBuilder().setNullValueValue(0).build();
- return builder.newBuilderForField(field).mergeFrom(value.toByteString()).build();
- } else {
- return field.getJavaType() == JavaType.ENUM && field.getEnumType().getFullName()
- .equals(NullValue.getDescriptor().getFullName()) ? field.getEnumType().findValueByNumber(0)
- : null;
- }
- } else {
- switch (field.getType()) {
- case STRING:
- return this.parseString(json);
- case MESSAGE:
- case GROUP:
- if (this.currentDepth >= this.recursionLimit) {
- throw new InvalidProtocolBufferException("Hit recursion limit.");
- }
-
- ++this.currentDepth;
- com.google.protobuf.Message.Builder subBuilder = builder.newBuilderForField(field);
- this.merge(json, subBuilder);
- --this.currentDepth;
- return subBuilder.build();
- default:
- throw new InvalidProtocolBufferException("Invalid field type: " + field.getType());
- }
- }
- }
-
- static {
- MAX_DOUBLE = (new BigDecimal(String.valueOf(1.7976931348623157E308D))).multiply(MORE_THAN_ONE);
- MIN_DOUBLE = (new BigDecimal(String.valueOf(-1.7976931348623157E308D))).multiply(MORE_THAN_ONE);
- }
-
- private interface WellKnownTypeParser {
-
- void merge(JsonFormat.ParserImpl var1, JsonElement var2, com.google.protobuf.Message.Builder var3)
- throws InvalidProtocolBufferException;
- }
- }
-
- private static final class PrinterImpl {
-
- private final JsonFormat.TypeRegistry registry;
- private final boolean alwaysOutputDefaultValueFields;
- private final Set<FieldDescriptor> includingDefaultValueFields;
- private final boolean preservingProtoFieldNames;
- private final boolean printingEnumsAsInts;
- private final JsonFormat.TextGenerator generator;
- private final Gson gson;
- private final CharSequence blankOrSpace;
- private final CharSequence blankOrNewLine;
- private static final Map<String, JsonFormat.PrinterImpl.WellKnownTypePrinter> wellKnownTypePrinters = buildWellKnownTypePrinters();
-
- PrinterImpl(JsonFormat.TypeRegistry registry, boolean alwaysOutputDefaultValueFields,
- Set<FieldDescriptor> includingDefaultValueFields, boolean preservingProtoFieldNames, Appendable jsonOutput,
- boolean omittingInsignificantWhitespace, boolean printingEnumsAsInts) {
- this.registry = registry;
- this.alwaysOutputDefaultValueFields = alwaysOutputDefaultValueFields;
- this.includingDefaultValueFields = includingDefaultValueFields;
- this.preservingProtoFieldNames = preservingProtoFieldNames;
- this.printingEnumsAsInts = printingEnumsAsInts;
- this.gson = JsonFormat.PrinterImpl.GsonHolder.DEFAULT_GSON;
- if (omittingInsignificantWhitespace) {
- this.generator = new JsonFormat.CompactTextGenerator(jsonOutput);
- this.blankOrSpace = "";
- this.blankOrNewLine = "";
- } else {
- this.generator = new JsonFormat.PrettyTextGenerator(jsonOutput);
- this.blankOrSpace = " ";
- this.blankOrNewLine = "\n";
- }
-
- }
-
- void print(MessageOrBuilder message) throws IOException {
- JsonFormat.PrinterImpl.WellKnownTypePrinter specialPrinter = (JsonFormat.PrinterImpl.WellKnownTypePrinter) wellKnownTypePrinters
- .get(message.getDescriptorForType().getFullName());
- if (specialPrinter != null) {
- specialPrinter.print(this, message);
- }
- }
-
- private static Map<String, JsonFormat.PrinterImpl.WellKnownTypePrinter> buildWellKnownTypePrinters() {
- Map<String, JsonFormat.PrinterImpl.WellKnownTypePrinter> printers = new HashMap();
- printers.put(Any.getDescriptor().getFullName(), new JsonFormat.PrinterImpl.WellKnownTypePrinter() {
- public void print(JsonFormat.PrinterImpl printer, MessageOrBuilder message) throws IOException {
- }
- });
- JsonFormat.PrinterImpl.WellKnownTypePrinter wrappersPrinter = new JsonFormat.PrinterImpl.WellKnownTypePrinter() {
- public void print(JsonFormat.PrinterImpl printer, MessageOrBuilder message) throws IOException {
- }
- };
- printers.put(BoolValue.getDescriptor().getFullName(), wrappersPrinter);
- printers.put(Int32Value.getDescriptor().getFullName(), wrappersPrinter);
- printers.put(UInt32Value.getDescriptor().getFullName(), wrappersPrinter);
- printers.put(Int64Value.getDescriptor().getFullName(), wrappersPrinter);
- printers.put(UInt64Value.getDescriptor().getFullName(), wrappersPrinter);
- printers.put(StringValue.getDescriptor().getFullName(), wrappersPrinter);
- printers.put(BytesValue.getDescriptor().getFullName(), wrappersPrinter);
- printers.put(FloatValue.getDescriptor().getFullName(), wrappersPrinter);
- printers.put(DoubleValue.getDescriptor().getFullName(), wrappersPrinter);
- printers.put(Struct.getDescriptor().getFullName(), new JsonFormat.PrinterImpl.WellKnownTypePrinter() {
- public void print(JsonFormat.PrinterImpl printer, MessageOrBuilder message) throws IOException {
- printer.printStruct(message);
- }
- });
- printers.put(Value.getDescriptor().getFullName(), new JsonFormat.PrinterImpl.WellKnownTypePrinter() {
- public void print(JsonFormat.PrinterImpl printer, MessageOrBuilder message) throws IOException {
- printer.printValue(message);
- }
- });
- printers.put(ListValue.getDescriptor().getFullName(), new JsonFormat.PrinterImpl.WellKnownTypePrinter() {
- public void print(JsonFormat.PrinterImpl printer, MessageOrBuilder message) throws IOException {
- }
- });
- return printers;
- }
-
- private void printStruct(MessageOrBuilder message) throws IOException {
- Descriptor descriptor = message.getDescriptorForType();
- FieldDescriptor field = descriptor.findFieldByName("fields");
- if (field == null) {
- throw new InvalidProtocolBufferException("Invalid Struct type.");
- } else {
- this.printMapFieldValue(field, message.getField(field));
- }
- }
-
- private void printValue(MessageOrBuilder message) throws IOException {
- Map<FieldDescriptor, Object> fields = message.getAllFields();
- if (fields.isEmpty()) {
- this.generator.print("null");
- } else if (fields.size() != 1) {
- throw new InvalidProtocolBufferException("Invalid Value type.");
- } else {
- Iterator var3 = fields.entrySet().iterator();
-
- while (var3.hasNext()) {
- Entry<FieldDescriptor, Object> entry = (Entry) var3.next();
- this.printSingleFieldValue((FieldDescriptor) entry.getKey(), entry.getValue());
- }
-
- }
- }
-
- private void printMapFieldValue(FieldDescriptor field, Object value) throws IOException {
- Descriptor type = field.getMessageType();
- FieldDescriptor keyField = type.findFieldByName("key");
- FieldDescriptor valueField = type.findFieldByName("value");
- if (keyField != null && valueField != null) {
- this.generator.print("{" + this.blankOrNewLine);
- this.generator.indent();
- boolean printedElement = false;
- Iterator var7 = ((List) value).iterator();
-
- while (var7.hasNext()) {
- Object element = var7.next();
- Message entry = (Message) element;
- Object entryKey = entry.getField(keyField);
- Object entryValue = entry.getField(valueField);
- if (printedElement) {
- this.generator.print("," + this.blankOrNewLine);
- } else {
- printedElement = true;
- }
-
- this.printSingleFieldValue(keyField, entryKey, true);
- this.generator.print(":" + this.blankOrSpace);
- this.printSingleFieldValue(valueField, entryValue);
- }
-
- if (printedElement) {
- this.generator.print(this.blankOrNewLine);
- }
-
- this.generator.outdent();
- this.generator.print("}");
- } else {
- throw new InvalidProtocolBufferException("Invalid map field.");
- }
- }
-
- private void printSingleFieldValue(FieldDescriptor field, Object value) throws IOException {
- this.printSingleFieldValue(field, value, false);
- }
-
- private void printSingleFieldValue(FieldDescriptor field, Object value, boolean alwaysWithQuotes)
- throws IOException {
- switch (field.getType()) {
- case DOUBLE:
- Double doubleValue = (Double) value;
- if (doubleValue.isNaN()) {
- this.generator.print("\"NaN\"");
- } else if (doubleValue.isInfinite()) {
- if (doubleValue < 0.0D) {
- this.generator.print("\"-Infinity\"");
- } else {
- this.generator.print("\"Infinity\"");
- }
- } else {
- if (alwaysWithQuotes) {
- this.generator.print("\"");
- }
-
- this.generator.print(doubleValue.toString());
- if (alwaysWithQuotes) {
- this.generator.print("\"");
- }
- }
- break;
- case STRING:
- this.generator.print(this.gson.toJson(value));
- break;
- case MESSAGE:
- case GROUP:
- this.print((Message) value);
- }
-
- }
-
- private interface WellKnownTypePrinter {
-
- void print(JsonFormat.PrinterImpl var1, MessageOrBuilder var2) throws IOException;
- }
-
- private static class GsonHolder {
-
- private static final Gson DEFAULT_GSON = (new GsonBuilder()).disableHtmlEscaping().create();
-
- private GsonHolder() {
- }
- }
- }
-
- private static final class PrettyTextGenerator implements JsonFormat.TextGenerator {
-
- private final Appendable output;
- private final StringBuilder indent;
- private boolean atStartOfLine;
-
- private PrettyTextGenerator(Appendable output) {
- this.indent = new StringBuilder();
- this.atStartOfLine = true;
- this.output = output;
- }
-
- public void indent() {
- this.indent.append(" ");
- }
-
- public void outdent() {
- int length = this.indent.length();
- if (length < 2) {
- throw new IllegalArgumentException(" Outdent() without matching Indent().");
- } else {
- this.indent.delete(length - 2, length);
- }
- }
-
- public void print(CharSequence text) throws IOException {
- int size = text.length();
- int pos = 0;
-
- for (int i = 0; i < size; ++i) {
- if (text.charAt(i) == '\n') {
- this.write(text.subSequence(pos, i + 1));
- pos = i + 1;
- this.atStartOfLine = true;
- }
- }
-
- this.write(text.subSequence(pos, size));
- }
-
- private void write(CharSequence data) throws IOException {
- if (data.length() != 0) {
- if (this.atStartOfLine) {
- this.atStartOfLine = false;
- this.output.append(this.indent);
- }
-
- this.output.append(data);
- }
- }
- }
-
- private static final class CompactTextGenerator implements JsonFormat.TextGenerator {
-
- private final Appendable output;
-
- private CompactTextGenerator(Appendable output) {
- this.output = output;
- }
-
- public void indent() {
- }
-
- public void outdent() {
- }
-
- public void print(CharSequence text) throws IOException {
- this.output.append(text);
- }
- }
-
- interface TextGenerator {
-
- void indent();
-
- void outdent();
-
- void print(CharSequence var1) throws IOException;
- }
-
- public static class TypeRegistry {
-
- private final Map<String, Descriptor> types;
-
- public static JsonFormat.TypeRegistry getEmptyTypeRegistry() {
- return JsonFormat.TypeRegistry.EmptyTypeRegistryHolder.EMPTY;
- }
-
- public Descriptor find(String name) {
- return (Descriptor) this.types.get(name);
- }
-
- private TypeRegistry(Map<String, Descriptor> types) {
- this.types = types;
- }
-
- private static class EmptyTypeRegistryHolder {
-
- private static final JsonFormat.TypeRegistry EMPTY = new JsonFormat.TypeRegistry(Collections.emptyMap());
-
- private EmptyTypeRegistryHolder() {
- }
- }
- }
-
- public static class Parser {
-
- private final JsonFormat.TypeRegistry registry;
- private final boolean ignoringUnknownFields;
- private final int recursionLimit;
- private static final int DEFAULT_RECURSION_LIMIT = 100;
-
- private Parser(JsonFormat.TypeRegistry registry, boolean ignoreUnknownFields, int recursionLimit) {
- this.registry = registry;
- this.ignoringUnknownFields = ignoreUnknownFields;
- this.recursionLimit = recursionLimit;
- }
-
- public void merge(String json, com.google.protobuf.Message.Builder builder)
- throws InvalidProtocolBufferException {
- (new JsonFormat.ParserImpl(this.registry, this.ignoringUnknownFields, this.recursionLimit))
- .merge(json, builder);
- }
- }
-
- public static class Printer {
-
- private final JsonFormat.TypeRegistry registry;
- private boolean alwaysOutputDefaultValueFields;
- private Set<FieldDescriptor> includingDefaultValueFields;
- private final boolean preservingProtoFieldNames;
- private final boolean omittingInsignificantWhitespace;
- private final boolean printingEnumsAsInts;
-
- private Printer(JsonFormat.TypeRegistry registry, boolean alwaysOutputDefaultValueFields,
- Set<FieldDescriptor> includingDefaultValueFields, boolean preservingProtoFieldNames,
- boolean omittingInsignificantWhitespace, boolean printingEnumsAsInts) {
- this.registry = registry;
- this.alwaysOutputDefaultValueFields = alwaysOutputDefaultValueFields;
- this.includingDefaultValueFields = includingDefaultValueFields;
- this.preservingProtoFieldNames = preservingProtoFieldNames;
- this.omittingInsignificantWhitespace = omittingInsignificantWhitespace;
- this.printingEnumsAsInts = printingEnumsAsInts;
- }
-
- public void appendTo(MessageOrBuilder message, Appendable output) throws IOException {
- (new JsonFormat.PrinterImpl(this.registry, this.alwaysOutputDefaultValueFields,
- this.includingDefaultValueFields, this.preservingProtoFieldNames, output,
- this.omittingInsignificantWhitespace, this.printingEnumsAsInts)).print(message);
- }
-
- public String print(MessageOrBuilder message) throws InvalidProtocolBufferException {
- try {
- StringBuilder builder = new StringBuilder();
- this.appendTo(message, builder);
- return builder.toString();
- } catch (InvalidProtocolBufferException var3) {
- throw var3;
- } catch (IOException var4) {
- throw new IllegalStateException(var4);
- }
- }
- }
-}
diff --git a/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/Utils.java b/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/Utils.java
deleted file mode 100644
index 831f09ea..00000000
--- a/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/Utils.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2019 Bell Canada.
- *
- * 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.
- */
-package org.onap.ccsdk.sli.adaptors.grpc;
-
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.format.DateTimeFormatter;
-
-public final class Utils {
-
- private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
-
- private Utils() {
- throw new AssertionError("Utility class");
- }
-
- public static String timestamp() {
- LocalDateTime now = LocalDateTime.now(ZoneId.systemDefault());
- return formatter.format(now);
- }
-}
diff --git a/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/cds/BasicAuthClientInterceptor.java b/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/cds/BasicAuthClientInterceptor.java
deleted file mode 100644
index 5d2e848c..00000000
--- a/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/cds/BasicAuthClientInterceptor.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2019 Bell Canada.
- *
- * 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.
- */
-package org.onap.ccsdk.sli.adaptors.grpc.cds;
-
-import io.grpc.CallOptions;
-import io.grpc.Channel;
-import io.grpc.ClientCall;
-import io.grpc.ClientInterceptor;
-import io.grpc.ForwardingClientCall;
-import io.grpc.Metadata;
-import io.grpc.Metadata.Key;
-import io.grpc.MethodDescriptor;
-import org.apache.http.HttpHeaders;
-import org.onap.ccsdk.sli.adaptors.grpc.GrpcProperties;
-
-public class BasicAuthClientInterceptor implements ClientInterceptor {
-
- private GrpcProperties props;
-
- public BasicAuthClientInterceptor(GrpcProperties props) {
- this.props = props;
- }
-
- @Override
- public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
- MethodDescriptor<ReqT, RespT> method,
- CallOptions callOptions,
- Channel channel) {
-
- Key<String> authHeader = Key.of(HttpHeaders.AUTHORIZATION, Metadata.ASCII_STRING_MARSHALLER);
-
- return new ForwardingClientCall.SimpleForwardingClientCall<ReqT, RespT>(
- channel.newCall(method, callOptions)) {
- @Override
- public void start(Listener<RespT> responseListener, Metadata headers) {
- headers.put(authHeader, props.getAuth());
- super.start(responseListener, headers);
- }
- };
- }
-}
diff --git a/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/cds/BlueprintProcessingClient.java b/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/cds/BlueprintProcessingClient.java
deleted file mode 100644
index f922f9ec..00000000
--- a/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/cds/BlueprintProcessingClient.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2019 Bell Canada.
- *
- * 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.
- */
-package org.onap.ccsdk.sli.adaptors.grpc.cds;
-
-import io.grpc.ManagedChannel;
-import io.grpc.internal.DnsNameResolverProvider;
-import io.grpc.internal.PickFirstLoadBalancerProvider;
-import io.grpc.netty.NettyChannelBuilder;
-import java.util.Map;
-import org.onap.ccsdk.sli.adaptors.grpc.GrpcClient;
-import org.onap.ccsdk.sli.adaptors.grpc.GrpcProperties;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class BlueprintProcessingClient implements GrpcClient {
-
- private static final Logger log = LoggerFactory.getLogger(BlueprintProcessingClient.class);
-
- private ManagedChannel channel;
- private BlueprintProcessingHandler handler;
-
- public BlueprintProcessingClient(GrpcProperties props) {
- this.channel = NettyChannelBuilder
- .forAddress(props.getUrl(), props.getPort())
- .nameResolverFactory(new DnsNameResolverProvider())
- .loadBalancerFactory(new PickFirstLoadBalancerProvider())
- .intercept(new BasicAuthClientInterceptor(props))
- .usePlaintext()
- .build();
- this.handler = new BlueprintProcessingHandler();
- }
-
- public BlueprintProcessingClient(ManagedChannel channel, BlueprintProcessingHandler handler) {
- this.channel = channel;
- this.handler = handler;
- }
-
- // Used by blueprint
- public void start() {
- log.info("BlueprintProcessingClient started");
- }
-
- // Used by blueprint
- public void stop() {
- if (channel != null) {
- channel.shutdown();
- }
- log.info("BlueprintProcessingClient stopped");
- }
-
- /*
- * @param parameters HashMap<String,String> of parameters passed by the DG to this function.
- * <table border="1">
- * <thead><th>parameter</th><th>Mandatory/Optional</th><th>description</th></thead>
- * <tbody>
- * <tr><td>is_force</td><td>Optional</td><td>Whether to force or not the request.</td></tr>
- * <tr><td>ttl</td><td>Optional</td><td>Duration of the request.</td></tr>
- * <tr><td>blueprint_name</td><td>Mandatory</td><td>Name of the blueprint to process.</td></tr>
- * <tr><td>blueprint_version</td><td>Mandatory</td><td>Version of the blueprint to process.</td></tr>
- * <tr><td>action</td><td>Mandatory</td><td>Action of the blueprint to process.</td></tr>
- * <tr><td>mode</td><td>Mandatory</td><td>Mode to operate the transaction.</td></tr>
- * <tr><td>payload</td><td>Mandatory</td><td>Payload.</td></tr>
- * <tr><td>prefix</td><td>Mandatory</td><td>Prefix string to put response in context.</td></tr>
- * </tbody>
- * </table>
- */
- @Override
- public QueryStatus sendRequest(Map<String, String> parameters, SvcLogicContext ctx) {
- return handler.process(parameters, channel, ctx);
- }
-} \ No newline at end of file
diff --git a/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/cds/BlueprintProcessingHandler.java b/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/cds/BlueprintProcessingHandler.java
deleted file mode 100644
index 5f4fad42..00000000
--- a/grpc-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/grpc/cds/BlueprintProcessingHandler.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (C) 2019 Bell Canada.
- *
- * 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.
- */
-package org.onap.ccsdk.sli.adaptors.grpc.cds;
-
-import com.google.common.collect.Maps;
-import com.google.protobuf.InvalidProtocolBufferException;
-import com.google.protobuf.Struct;
-import com.google.protobuf.Struct.Builder;
-import io.grpc.ManagedChannel;
-import io.grpc.Status;
-import io.grpc.stub.StreamObserver;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
-import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers;
-import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader;
-import org.onap.ccsdk.cds.controllerblueprints.common.api.Flag;
-import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc;
-import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceStub;
-import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
-import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
-import org.onap.ccsdk.sli.adaptors.grpc.JsonFormat;
-import org.onap.ccsdk.sli.adaptors.grpc.Utils;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
-import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-class BlueprintProcessingHandler {
-
- private static final Logger log = LoggerFactory.getLogger(BlueprintProcessingHandler.class);
-
- private static final int DEFAULT_TTL = 180;
- private static final String CCSDK_ORIGINATOR = "CCSDK";
- private static final String IS_FORCE_PROP = "is_force";
- private static final String TTL_PROP = "ttl";
- private static final String BLUEPRINT_NAME_PROP = "blueprint_name";
- private static final String BLUEPRINT_VERSION_PROP = "blueprint_version";
- private static final String ACTION_PROP = "action";
- private static final String MODE_PROP = "mode";
- private static final String PAYLOAD_PROP = "payload";
- private static final String PREFIX_PROP = "prefix";
-
- QueryStatus process(final Map<String, String> parameters, final ManagedChannel channel, final SvcLogicContext ctx) {
- try {
- SliPluginUtils.checkParameters(parameters,
- new String[]{BLUEPRINT_NAME_PROP, BLUEPRINT_VERSION_PROP, ACTION_PROP, MODE_PROP, PREFIX_PROP}, log);
- } catch (SvcLogicException e) {
- return QueryStatus.FAILURE;
- }
-
- final boolean isForce = Boolean.getBoolean(parameters.get(IS_FORCE_PROP));
- int ttl = Integer.parseInt(parameters.get(TTL_PROP));
- if (ttl == 0) {
- ttl = DEFAULT_TTL;
- }
- final String blueprintName = parameters.get(BLUEPRINT_NAME_PROP);
- final String blueprintVersion = parameters.get(BLUEPRINT_VERSION_PROP);
- final String action = parameters.get(ACTION_PROP);
- final String mode = parameters.get(MODE_PROP);
- final String payload = parameters.get(PAYLOAD_PROP);
- final String prefix = parameters.get(PREFIX_PROP);
-
- log.info("Processing blueprint({}:{}) for action({})", blueprintVersion, blueprintName, action);
-
- final AtomicReference<QueryStatus> responseStatus = new AtomicReference<>();
- final CountDownLatch finishLatch = new CountDownLatch(1);
-
- final BluePrintProcessingServiceStub asyncStub = BluePrintProcessingServiceGrpc.newStub(channel);
-
- final StreamObserver<ExecutionServiceOutput> responseObserver = new StreamObserver<ExecutionServiceOutput>() {
- @Override
- public void onNext(ExecutionServiceOutput output) {
- log.info("onNext: {}", output);
-
- Map<String, String> jsonToCtx = Maps.newHashMap();
- String json = "";
- try {
- json = JsonFormat.printer().print(output);
- } catch (InvalidProtocolBufferException e) {
- log.error("Failed to parse received message. blueprint({}:{}) for action({}). {}", blueprintVersion,
- blueprintName, action, output, e);
- responseStatus.compareAndSet(null, QueryStatus.FAILURE);
- finishLatch.countDown();
- }
-
- ctx.setAttribute("BlueprintProcessingHandler_process", json);
- jsonToCtx.put("source", "BlueprintProcessingHandler_process");
- jsonToCtx.put("outputPath", prefix);
- jsonToCtx.put("isEscaped", Boolean.FALSE.toString());
-
- try {
- SliPluginUtils.jsonStringToCtx(jsonToCtx, ctx);
- } catch (SvcLogicException e) {
- log.error("Failed to put jsonStringToCtx. blueprint({}:{}) for action({}). {}", blueprintVersion,
- blueprintName, action, output, e);
- responseStatus.compareAndSet(null, QueryStatus.FAILURE);
- finishLatch.countDown();
- }
- }
-
- @Override
- public void onError(Throwable t) {
- Status status = Status.fromThrowable(t);
- log.error("Failed processing blueprint({}:{}) for action({}). {}", blueprintVersion, blueprintName,
- action, status);
- responseStatus.compareAndSet(null, QueryStatus.FAILURE);
- finishLatch.countDown();
- }
-
- @Override
- public void onCompleted() {
- log.info("Completed blueprint({}:{}) for action({})", blueprintVersion, blueprintName, action);
- responseStatus.compareAndSet(null, QueryStatus.SUCCESS);
- finishLatch.countDown();
- }
- };
-
- final CommonHeader commonHeader = CommonHeader.newBuilder()
- .setOriginatorId(CCSDK_ORIGINATOR)
- .setRequestId(UUID.randomUUID().toString())
- .setTimestamp(Utils.timestamp())
- .setFlag(Flag.newBuilder()
- .setIsForce(isForce)
- .setTtl(ttl)
- .build())
- .build();
- final ActionIdentifiers actionIdentifiers = ActionIdentifiers.newBuilder()
- .setActionName(action)
- .setBlueprintName(blueprintName)
- .setBlueprintVersion(blueprintVersion)
- .setMode(mode)
- .build();
-
- Builder struct = Struct.newBuilder();
- try {
- JsonFormat.parser().merge(payload, struct);
- } catch (InvalidProtocolBufferException e) {
- log.error("Failed converting payload for blueprint({}:{}) for action({}). {}", blueprintVersion,
- blueprintName, action, e);
- return QueryStatus.FAILURE;
- }
-
- final ExecutionServiceInput request = ExecutionServiceInput.newBuilder()
- .setActionIdentifiers(actionIdentifiers)
- .setPayload(struct.build())
- .setCommonHeader(commonHeader).build();
-
- final StreamObserver<ExecutionServiceInput> requestObserver = asyncStub.process(responseObserver);
-
- try {
- requestObserver.onNext(request);
- } catch (RuntimeException e) {
- requestObserver.onError(e);
- return QueryStatus.FAILURE;
- }
-
- requestObserver.onCompleted();
- try {
- finishLatch.await(ttl, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- log.error("Failed processing blueprint({}:{}) for action({}). {}", blueprintVersion, blueprintName, action,
- e);
- Thread.currentThread().interrupt();
- return QueryStatus.FAILURE;
- }
-
- return responseStatus.get();
- }
-} \ No newline at end of file
diff --git a/grpc-resource/provider/src/main/resources/grpc.properties b/grpc-resource/provider/src/main/resources/grpc.properties
deleted file mode 100644
index 797c67e2..00000000
--- a/grpc-resource/provider/src/main/resources/grpc.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Copyright (C) 2019 Bell Canada.
-#
-# 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.
-#
-org.onap.ccsdk.sli.adaptors.grpc.blueprint.processor.url=cds-blueprints-processor-grpc
-org.onap.ccsdk.sli.adaptors.grpc.blueprint.processor.port=9111
-org.onap.ccsdk.sli.adaptors.grpc.blueprint.processor.auth=Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==
diff --git a/grpc-resource/provider/src/main/resources/org/opendaylight/blueprint/grpc-client.xml b/grpc-resource/provider/src/main/resources/org/opendaylight/blueprint/grpc-client.xml
deleted file mode 100644
index 9febe484..00000000
--- a/grpc-resource/provider/src/main/resources/org/opendaylight/blueprint/grpc-client.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (C) 2019 Bell Canada
-
- 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.
- -->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
- odl:use-default-for-reference-types="true" odl:restart-dependents-on-updates="true">
-
- <bean id="grpcProperty" class="org.onap.ccsdk.sli.adaptors.grpc.GrpcProperties"/>
-
- <!--CDS-->
- <bean id="grpcClient" class="org.onap.ccsdk.sli.adaptors.grpc.cds.BlueprintProcessingClient"
- init-method="start" destroy-method="stop">
- <argument ref="grpcProperty"/>
- </bean>
- <service ref="grpcClient" interface="org.onap.ccsdk.sli.adaptors.grpc.GrpcClient"
- odl:type="default"/>
-
-</blueprint>
diff --git a/grpc-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/grpc/cds/BlueprintProcessingClientTest.java b/grpc-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/grpc/cds/BlueprintProcessingClientTest.java
deleted file mode 100644
index ea012d3d..00000000
--- a/grpc-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/grpc/cds/BlueprintProcessingClientTest.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2019 Bell Canada.
- *
- * 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.
- */
-package org.onap.ccsdk.sli.adaptors.grpc.cds;
-
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.doReturn;
-
-import com.google.common.collect.Maps;
-import io.grpc.inprocess.InProcessChannelBuilder;
-import io.grpc.inprocess.InProcessServerBuilder;
-import io.grpc.stub.StreamObserver;
-import io.grpc.testing.GrpcCleanupRule;
-import io.grpc.util.MutableHandlerRegistry;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-import org.mockito.Mockito;
-import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers;
-import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase;
-import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
-import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
-import org.onap.ccsdk.sli.adaptors.grpc.GrpcProperties;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
-
-@RunWith(JUnit4.class)
-public class BlueprintProcessingClientTest {
-
- @Rule
- public final GrpcCleanupRule grpcCleanup = new GrpcCleanupRule();
-
- private BlueprintProcessingClient client;
-
- private final SvcLogicContext svcLogicContext = new SvcLogicContext();
- private final MutableHandlerRegistry serviceRegistry = new MutableHandlerRegistry();
- private final List<String> messagesDelivered = new ArrayList<>();
- private final CountDownLatch allRequestsDelivered = new CountDownLatch(1);
- private final AtomicReference<StreamObserver<ExecutionServiceOutput>> responseObserverRef = new AtomicReference<>();
-
- @Before
- public void setUp() throws Exception {
-
- String serverName = InProcessServerBuilder.generateName();
- grpcCleanup.register(InProcessServerBuilder.forName(serverName)
- .fallbackHandlerRegistry(serviceRegistry).directExecutor().build().start());
-
- BlueprintProcessingHandler handler = new BlueprintProcessingHandler();
-
- client =
- new BlueprintProcessingClient(InProcessChannelBuilder.forName(serverName).directExecutor().build(),
- handler);
-
- final BluePrintProcessingServiceImplBase routeChatImpl =
- new BluePrintProcessingServiceImplBase() {
- @Override
- public StreamObserver<ExecutionServiceInput> process(
- StreamObserver<ExecutionServiceOutput> responseObserver) {
-
- responseObserverRef.set(responseObserver);
-
- StreamObserver<ExecutionServiceInput> requestObserver = new StreamObserver<ExecutionServiceInput>() {
- @Override
- public void onNext(ExecutionServiceInput message) {
- messagesDelivered.add(message.getActionIdentifiers().getActionName());
- }
-
- @Override
- public void onError(Throwable t) {
-
- }
-
- @Override
- public void onCompleted() {
- allRequestsDelivered.countDown();
- }
- };
-
- return requestObserver;
- }
- };
-
- serviceRegistry.addService(routeChatImpl);
- }
-
- @After
- public void tearDown() {
- client.stop();
- }
-
- @Test
- public void testClientCst() {
- GrpcProperties props = Mockito.mock(GrpcProperties.class);
- doReturn(999).when(props).getPort();
- doReturn("localhost").when(props).getUrl();
- new BlueprintProcessingClient(props).stop();
- }
-
-
- @Test
- public void testSendMessageFail() throws Exception {
- Map<String, String> input = Maps.newHashMap();
- input.put("is_force", "true");
- input.put("ttl", "1");
- input.put("blueprint_name", "test");
- input.put("blueprint_version", "1.0.0");
- input.put("action", "test-action");
- input.put("mode", "sync");
- input.put("payload", "");
- input.put("prefix", "res");
-
- QueryStatus status = client.sendRequest(input, svcLogicContext);
-
- Assert.assertEquals(QueryStatus.FAILURE, status);
-
- }
-
- @Test
- public void testSendMessage() throws Exception {
- ExecutionServiceOutput fakeResponse1 = ExecutionServiceOutput.newBuilder().setActionIdentifiers(
- ActionIdentifiers.newBuilder().setActionName("response1").build()).build();
-
- ExecutionServiceOutput fakeResponse2 = ExecutionServiceOutput.newBuilder().setActionIdentifiers(
- ActionIdentifiers.newBuilder().setActionName("response2").build()).build();
-
- Map<String, String> input = Maps.newHashMap();
- input.put("is_force", "true");
- input.put("ttl", "1");
- input.put("blueprint_name", "test");
- input.put("blueprint_version", "1.0.0");
- input.put("action", "test-action");
- input.put("mode", "sync");
- input.put("payload", "{}");
- input.put("prefix", "res");
-
- client.sendRequest(input, svcLogicContext);
-
- // request message sent and delivered for one time
- assertTrue(allRequestsDelivered.await(1, TimeUnit.SECONDS));
- assertEquals(Collections.singletonList("test-action"), messagesDelivered);
-
- // let server complete.
- responseObserverRef.get().onCompleted();
- }
-
-} \ No newline at end of file
diff --git a/grpc-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/grpc/cds/GrpcClientTest.java b/grpc-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/grpc/cds/GrpcClientTest.java
deleted file mode 100644
index 2ad49d79..00000000
--- a/grpc-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/grpc/cds/GrpcClientTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2019 Bell Canada.
- *
- * 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.
- */
-package org.onap.ccsdk.sli.adaptors.grpc.cds;
-
-import com.google.common.collect.Maps;
-import com.google.protobuf.InvalidProtocolBufferException;
-import com.google.protobuf.Struct;
-import com.google.protobuf.Struct.Builder;
-import java.util.Map;
-import org.junit.Test;
-import org.onap.ccsdk.sli.adaptors.grpc.JsonFormat;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils;
-
-public class GrpcClientTest {
-
- @Test
- public void testPayload() throws InvalidProtocolBufferException {
-
- String payload = "{\n"
- + " \"commonHeader\": {\n"
- + " \"timestamp\": \"2019-02-27T22:08:39.587Z\",\n"
- + " \"originatorId\": \"System\",\n"
- + " \"requestId\": \"1234\",\n"
- + " \"subRequestId\": \"1234-12234\"\n"
- + " },\n"
- + " \"actionIdentifiers\": {\n"
- + " \"blueprintName\": \"test\",\n"
- + " \"blueprintVersion\": \"1.0.0\",\n"
- + " \"actionName\": \"resource-assignment\",\n"
- + " \"mode\": \"sync\"\n"
- + " },\n"
- + " \"status\": {\n"
- + " \"code\": 200,\n"
- + " \"eventType\": \"EVENT-COMPONENT-EXECUTED\",\n"
- + " \"timestamp\": \"2019-02-27T22:08:39.981Z\",\n"
- + " \"message\": \"success\"\n"
- + " },\n"
- + " \"payload\": {\n"
- + " \"resource-assignment-params\": {\n"
- + " \"test\": \"THIS IS A TEST: service-capability-resolved-status-test\"\n"
- + " },\n"
- + " \"status\": \"success\"\n"
- + " }\n"
- + "}";
-
- Map<String, String> jsonToCtx = Maps.newHashMap();
- jsonToCtx.put("source", "blueprint_processing_result");
- jsonToCtx.put("outputPath", "t");
- jsonToCtx.put("isEscaped", Boolean.FALSE.toString());
-
- SvcLogicContext svcLogicContext = new SvcLogicContext();
- svcLogicContext.setAttribute("blueprint_processing_result", payload);
-
- try {
- SliPluginUtils.jsonStringToCtx(jsonToCtx, svcLogicContext);
- } catch (SvcLogicException e) {
- e.printStackTrace();
- }
-
- Builder t = Struct.newBuilder();
-
- JsonFormat.parser().merge(payload, t);
-
- System.out.println(((Builder) t).build().toString());
-
- System.out.println(JsonFormat.printer().print(t));
- }
-
-} \ No newline at end of file
diff --git a/pom.xml b/pom.xml
index ea7c0822..9f26ce4f 100755
--- a/pom.xml
+++ b/pom.xml
@@ -100,7 +100,6 @@
<module>ansible-adapter</module>
<module>saltstack-adapter</module>
<module>netbox-client</module>
- <module>grpc-resource</module>
<module>mdsal-resource</module>
<module>resource-assignment</module>
<module>sql-resource</module>