aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--INFO.yaml63
-rw-r--r--README.md64
-rw-r--r--WebContent/WEB-INF/music.properties.sample1
-rw-r--r--distribution/tomcat/Dockerfile3
-rw-r--r--distribution/zookeeper/Dockerfile3
-rw-r--r--docs/multi.rst57
-rw-r--r--docs/setup.rst11
-rw-r--r--docs/single.rst3
-rw-r--r--docs/swagger.json2
-rw-r--r--examples/VotingApp/src/main/java/main/VotingApp.java13
-rwxr-xr-xpom.xml47
-rw-r--r--src/main/java/org/onap/music/datastore/MusicDataStoreHandle.java3
-rw-r--r--src/main/java/org/onap/music/eelf/logging/format/AppMessages.java7
-rw-r--r--src/main/java/org/onap/music/lockingservice/cassandra/CassaLockStore.java10
-rw-r--r--src/main/java/org/onap/music/lockingservice/cassandra/MusicLockState.java2
-rwxr-xr-xsrc/main/java/org/onap/music/main/MusicUtil.java23
-rwxr-xr-xsrc/main/java/org/onap/music/main/PropertiesListener.java257
-rw-r--r--src/main/java/org/onap/music/main/PropertiesLoader.java5
-rw-r--r--src/main/java/org/onap/music/rest/RestMusicLocksAPI.java4
-rwxr-xr-xsrc/main/java/org/onap/music/rest/RestMusicQAPI.java22
-rw-r--r--src/main/resources/logback.xml2
-rw-r--r--src/test/java/org/onap/music/unittests/MusicUtilTest.java9
-rw-r--r--src/test/java/org/onap/music/unittests/TestRestMusicQAPI.java4
-rw-r--r--src/test/resources/LICENSE.txt24
-rw-r--r--src/test/resources/Resources.properties50
-rw-r--r--src/test/resources/application.properties2
-rw-r--r--src/test/resources/cache.ccf62
-rw-r--r--src/test/resources/logback.xml302
-rw-r--r--src/test/resources/project.properties4
29 files changed, 577 insertions, 482 deletions
diff --git a/INFO.yaml b/INFO.yaml
index e69de29b..12fca82f 100644
--- a/INFO.yaml
+++ b/INFO.yaml
@@ -0,0 +1,63 @@
+---
+project: 'music'
+project_creation_date: '2018-01-17'
+lifecycle_state: 'Incubation'
+project_category: ''
+project_lead: &onap_releng_ptl
+ name: 'Bharath Balasubramanian'
+ email: 'bharathb@research.att.com'
+ id: 'bharathb'
+ company: 'ATT'
+ timezone: 'America/New_York'
+primary_contact: *onap_releng_ptl
+issue_tracking:
+ type: 'jira'
+ url: 'https://jira.onap.org/projects/MUSIC'
+ key: 'MUSIC'
+mailing_list:
+ type: 'groups.io'
+ url: 'lists.onap.org'
+ tag: '<[sub-project_name]>'
+realtime_discussion: ''
+meetings:
+ - type: 'zoom'
+ agenda: 'https://wiki.onap.org/display/DW/MUSIC+Project'
+ url: 'https://wiki.onap.org/display/DW/MUSIC+Project'
+ server: 'n/a'
+ channel: 'n/a'
+ repeats: 'weekly'
+ time: '14:00 UTC'
+repositories:
+ - 'music'
+ - 'music-distributed-kv-store'
+ - 'music-mdbc'
+ - 'music-prom'
+committers:
+ - <<: *onap_releng_ptl
+ - name: 'Thomas Nelson'
+ email: 'tn1381@att.com'
+ company: 'ATT'
+ id: 'arthurdent3'
+ timezone: 'America/New_York'
+ - name: 'Brendan Tschaen'
+ email: 'bptschaen@gmail.com'
+ company: 'ATT'
+ id: 'bptschaen'
+ timezone: 'America/New_York'
+ - name: 'Greg Waines'
+ email: 'greg.waines@windriver.com'
+ company: 'Windriver'
+ id: 'gwaines'
+ timezone: 'America/Canada'
+ - name: 'Viswanath Kumar Skand Priya'
+ email: 'viswanath.kumarskandpriya@verizon.com'
+ company: 'Verizon'
+ id: 'kspviswa-vz'
+ timezone: 'Asia/Kolkata'
+ - name: 'Shashank Kumar Shankar'
+ email: 'shashank.kumar.shankar@intel.com'
+ company: 'Intel'
+ id: 'shashank.kumar....'
+ timezone: 'America/Los_Angeles'
+tsc:
+ approval: 'https://lists.onap.org/pipermail/onap-tsc'
diff --git a/README.md b/README.md
index 9d5c4cd1..e826f7c0 100644
--- a/README.md
+++ b/README.md
@@ -32,25 +32,19 @@ MUSIC is to be installed in a single Dir.
/opt/app/music/etc
/opt/app/music/logs
```
-When installing Tomcat, Cassandra and Zookeeper they should also be installed here.
+When installing Cassandra it should also be installed here.
```bash
/opt/app/music/apache-cassandra-n.n.n
-/opt/app/music/zookeeper-n.n.n
-/opt/app/music/apache-tomcat-n.n.n
```
Its suggested you create links from install dirs to a common name ie:
```bash
ln -s /opt/app/music/apache-cassandra-n.n.n cassandra
-ln -s /opt/app/music/zookeeper-n.n.n zookeeper
-ln -s /opt/app/music/apache-tomcat-n.n.n tomcat
```
-Cassandra and Zookeeper have data dirs.
+Cassandra has data dirs.
```bash
# For cassandra it should be (This is the default)
/opt/app/music/cassandra/data
-# For Zookeeper it should be
-/opt/app/music/var/zookeeper/
```
If you are using a VM make sure it has at least 8 GB of RAM (It may work with 4 GB, but with 2 GB it
@@ -69,7 +63,6 @@ does give issues).
- Ensure you have java jdk 8 or above working on your machine.
- Download apache Apache Cassandra 3.2, install into /opt/app/music and follow these instructions http://cassandra.apache.org/doc/latest/getting_started/installing.html till and including Step
- By the end of this you should have Cassandra working.
-- Download Apache Zookeeper 3.4.6, install into /opt/app/music and follow these instructions https://zookeeper.apache.org/doc/trunk/zookeeperStarted.html pertaining to the standalone operation. By the end of this you should have Zookeeper working.
- Create a music.properties file and place it in /opt/app/music/etc/. Here is a sample of the file:
```properties
@@ -80,7 +73,6 @@ all.public.ips=localhost
#######################################
# Optional current values are defaults
#######################################
-#zookeeper.host=localhost
#cassandra.host=localhost
#music.ip=localhost
#debug=true
@@ -92,10 +84,11 @@ aaf.endpoint.url=http://aafendpoint/proxy/authz/nss/
```
- Make a dir /opt/app/music/logs MUSIC dir with MUSIC logs will be created in this dir after MUSIC starts.
-- Download the latest Apache Tomcat and install it using these instructions http://tecadmin.net/install-tomcat-9-on-ubuntu/ (this is for version 9).
-- Build the MUSIC.war (or download it from https://github.com/att/music/blob/master/MUSIC.war) and place it within the webapps folder of the tomcat installation.
- Authentications/AAF Setup For Authentication setup.
-- Start tomcat and you should now have MUSIC running.
+- Start MUSIC using the jar built in distribution/music folder
+```bash
+java -jar music.jar
+```
Extra Cassandra information for Authentication:
@@ -207,50 +200,6 @@ cassandra.password=<new_password>
To access keyspace through cqlsh, login with credentials that are passed to MUSIC while creating the keyspace.
-#### Zookeeper:
-
-Once zookeeper has been installed on all the nodes, modify the zk_install_location/conf/zoo.cfg on all the nodes with the following lines:
-```properties
-tickTime=2000
-dataDir=/opt/app/music/var/zookeeper
-clientPort=2181
-initLimit=5
-syncLimit=2
-quorumListenOnAllIPs=true
-server.1=public IP of node 1:2888:3888
-server.2=public IP of node 2:2888:3888
-server.3=public IP of node 3:2888:3888
-```
-In /opt/app/music/var/zookeeper in all the machines, create a file called myid that contains the id of the machine. The machine running node.i will contain just the number i in the file myid.
-
-Start each of the nodes one by one from the zk_install_location/bin folder using the command:
-```bash
-./zkServer.sh start
-```
-On each node check the file zookeeper.out in the zk_install_location/ bin to make sure all the machines are talking to each other and there are no errors. Note that while the machines are yet to come up there maybe error messages saying that connection has not yet been established. Clearly, this is ok.
-
-If there are no errors, then from zk_install_location/bin simply run the following to get command line access to zookeeper. ./zkCli.sh
-
-Run these commands on different machines to make sure the zk nodes are syncing.
-```bash
-[zkshell] ls /
-[zookeeper]
-```
-Next, create a new znode by running
-```bash
-create /zk_test my_data.
-```
-This creates a new znode and associates the string "my_data" with the node. You should see:
-```bash
-[zkshell] create /zk_test my_data
-Created /zk_test
-```
-Issue another ls / command to see what the directory looks like:
-```bash
-[zkshell] ls /
-[zookeeper, zk_test]
-```
-
#### MUSIC
Create a music.properties file and place it in /opt/app/music/etc at each node. Here is a sample of the file: If this location is to be changed please update the file project.properties in the src/main/resources directory before compiling MUSIC to a war.
@@ -263,7 +212,6 @@ all.public.ips=public IP of node 0:public IP of node 1:public IP of node 2
#######################################
# Optional current values are defaults
#######################################
-#zookeeper.host=localhost
#cassandra.host=localhost
#music.ip=localhost
#debug=true
diff --git a/WebContent/WEB-INF/music.properties.sample b/WebContent/WEB-INF/music.properties.sample
index d562429b..871b0c3f 100644
--- a/WebContent/WEB-INF/music.properties.sample
+++ b/WebContent/WEB-INF/music.properties.sample
@@ -6,7 +6,6 @@ all.public.ips=12.13.14.45:12.13.14.46:12.13.14.47
#######################################
# Optional current values are defaults
#######################################
-#zookeeper.host=localhost
#cassandra.host=localhost
#music.ip=localhost
#debug=true
diff --git a/distribution/tomcat/Dockerfile b/distribution/tomcat/Dockerfile
deleted file mode 100644
index 7d4f2ad9..00000000
--- a/distribution/tomcat/Dockerfile
+++ /dev/null
@@ -1,3 +0,0 @@
-FROM library/tomcat:8.5
-LABEL purpose="Tomcat for MUSIC"
-
diff --git a/distribution/zookeeper/Dockerfile b/distribution/zookeeper/Dockerfile
deleted file mode 100644
index fdc89dc0..00000000
--- a/distribution/zookeeper/Dockerfile
+++ /dev/null
@@ -1,3 +0,0 @@
-FROM library/zookeeper:3.4
-LABEL purpose="For MUSIC"
-
diff --git a/docs/multi.rst b/docs/multi.rst
index bc26465f..380f4ea5 100644
--- a/docs/multi.rst
+++ b/docs/multi.rst
@@ -72,63 +72,6 @@ To access keyspace through cqlsh, login with credentials that are passed to MUSI
-Zookeeper:
-----------
-Once zookeeper has been installed on all the nodes, modify the **zk_install_location/conf/zoo.cfg** on all the nodes with the following lines:
-
-::
-
- tickTime=2000
- dataDir=/opt/app/music/var/zookeeper
- clientPort=2181
- initLimit=5
- syncLimit=2
- quorumListenOnAllIPs=true
- server.1=public IP of node 1:2888:3888
- server.2=public IP of node 2:2888:3888
- server.3=public IP of node 3:2888:3888
-
-Create the directory /var/zookeeper in all the machines and within that create a file called myid that contains the id of the machine. The machine running node.i will contain just the number i in the file myid.
-
-Start each of the nodes one by one from the zk_install_location/bin folder using the command:
-
-
-
- ./zkServer.sh start
-
-On each node check the file zookeeper.out in the zk_install_location/ bin to make sure all the machines are talking to each other and there are no errors. Note that while the machines are yet to come up there maybe error messages saying that connection has not yet been established. Clearly, this is ok.
-
-
-If there are no errors, then from zk_install_location/bin simply run the following to get command line access to zookeeper. ./zkCli.sh
-
-
-Run these commands on different machines to make sure the zk nodes are syncing.
-
-::
-
- [zkshell] ls /
- [zookeeper]
-
-Next, create a new znode by running
-
-::
-
- create /zk_test my_data.
-
-This creates a new znode and associates the string "my_data" with the node. You should see:
-
-::
-
- [zkshell] create /zk_test my_data
- Created /zk_test
-
-Issue another ls / command to see what the directory looks like:
-
-::
-
- [zkshell] ls /
- [zookeeper, zk_test]
-
MUSIC
Create a music.properties file and place it in /opt/app/music/etc at each node. Here is a sample of the file:
cassandra.yaml::
diff --git a/docs/setup.rst b/docs/setup.rst
index b12acd04..7fb5bf49 100644
--- a/docs/setup.rst
+++ b/docs/setup.rst
@@ -17,27 +17,20 @@ The main MUSIC dir should be::
# These also need to be set up
/opt/app/music/etc
/opt/app/music/logs
- /opt/app/music/lib/zookeeper
-When installing Tomcat, Cassandra and Zookeeper they should also be installed here.::
+When installing, Cassandra should also be installed here.::
/opt/app/music/apache-cassandra-n.n.n
- /opt/app/music/zookeeper-n.n.n
- /opt/app/music/apache-tomcat-n.n.n
You could also create links from install dirs to a common name ie\:::
ln -s /opt/app/music/apache-cassandra-n.n.n cassandra
- ln -s /opt/app/music/zookeeper-n.n.n zookeeper
- ln -s /opt/app/music/apache-tomcat-n.n.n tomcat
-Cassandra and Zookeeper have data dirs.::
+Cassandra has data dirs.::
# For cassandra it should be (This is the default)
/opt/app/music/cassandra/data
- # For Zookeeper it should be
- /opt/app/music/zookeeper/
Continue by selecting the link to the setup you are doing.
diff --git a/docs/single.rst b/docs/single.rst
index 060f02b4..632db5ac 100644
--- a/docs/single.rst
+++ b/docs/single.rst
@@ -15,8 +15,6 @@ Instructions
- Ensure you have OpenJDK 8 on your machine.
- Download Apache Cassandra 3.0, install into /opt/app/music and follow these instructions http://cassandra.apache.org/doc/latest/getting_started/installing.html till and including Step
- By the end of this you should have Cassandra working.
-- Download Apache Zookeeper 3.4.6, install into /opt/app/music and follow these instructions https://zookeeper.apache.org/doc/r3.4.6/zookeeperStarted.html pertaining to the standalone operation. By the end of this you should have Zookeeper working.
-- Download the Version 8.5 Apache Tomcat and install it using these instructions https://tomcat.apache.org/download-80.cgi (this is for version 8.5).
- Create a music.properties file and place it in /opt/app/music/etc/. Here is a sample of the file:
music.properties::
@@ -30,7 +28,6 @@ music.properties::
# Optional current values are defaults
######################################
# If using docker this would point to the specific docker name.
- #zookeeper.host=localhost
#cassandra.host=localhost
#music.ip=localhost
diff --git a/docs/swagger.json b/docs/swagger.json
index 534d2af4..3bc67050 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -964,7 +964,7 @@
"Lock Api"
],
"summary": "Create Lock",
- "description": "Puts the requesting process in the q for this lock. The corresponding node will be created in zookeeper if it did not already exist. Lock Name is the \"key\" of the form keyspaceName.tableName.rowId",
+ "description": "Puts the requesting process in the q for this lock. The corresponding lock will be created if it did not already exist. Lock Name is the \"key\" of the form keyspaceName.tableName.rowId",
"operationId": "createLockReference",
"produces": [
"application/json"
diff --git a/examples/VotingApp/src/main/java/main/VotingApp.java b/examples/VotingApp/src/main/java/main/VotingApp.java
index 8846ba22..653cef2e 100644
--- a/examples/VotingApp/src/main/java/main/VotingApp.java
+++ b/examples/VotingApp/src/main/java/main/VotingApp.java
@@ -29,6 +29,7 @@ import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
+import java.util.Base64;
import javax.ws.rs.core.MediaType;
@@ -66,13 +67,11 @@ public class VotingApp {
if (!namespace.equals("")) {
builder.header("ns", namespace);
}
- if (!userId.equals("")) {
- builder.header("userId", userId);
+ if (!userId.equals("") && !password.equals("")) {
+ String authString = Base64.getEncoder().encodeToString((userId + ":" + password).getBytes());
+ builder.header("Authorization", "Basic " + authString);
}
- if (!password.equals("")) {
- builder.header("password", password);
- }
-
+
return builder;
}
@@ -511,4 +510,4 @@ public class VotingApp {
}
-} \ No newline at end of file
+}
diff --git a/pom.xml b/pom.xml
index 68f835a8..93585831 100755
--- a/pom.xml
+++ b/pom.xml
@@ -133,6 +133,14 @@
</includes>
</resource>
</resources>
+ <testResources>
+ <testResource>
+ <directory>${project.basedir}/src/test/resources</directory>
+ </testResource>
+ <!-- <testResource>
+ <directory>${project.basedir}/src/main/resources</directory>
+ </testResource> -->
+ </testResources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
@@ -141,7 +149,7 @@
<mainClass>org.onap.music.MusicApplication</mainClass>
<outputDirectory>./distribution/music/</outputDirectory>
<addResources>true</addResources>
- </configuration>
+ </configuration>
<executions>
<execution>
<goals>
@@ -206,7 +214,7 @@
<dependencies>
<!-- Springboot -->
- <dependency>
+ <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
@@ -228,11 +236,11 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
- <dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<scope>compile</scope>
@@ -328,16 +336,16 @@
<artifactId>cassandra-driver-core</artifactId>
<version>3.6.0</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>${cassandra.version}</version>
- <exclusions>
+ <exclusions>
<!-- <exclusion>
<groupId>io.netty</groupId>
<artifactId>*</artifactId>
</exclusion> -->
- </exclusions>
+ </exclusions>
</dependency>
<!-- /Cassandra -->
<!-- Jersey -->
@@ -441,28 +449,19 @@
<version>3.1.0</version>
</dependency>
<dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-test</artifactId>
- <version>2.3.0</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- </exclusions>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.23.4</version>
<scope>test</scope>
</dependency>
<!-- /Testing -->
+ <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310 -->
+ <dependency>
+ <groupId>com.fasterxml.jackson.datatype</groupId>
+ <artifactId>jackson-datatype-jsr310</artifactId>
+ <version>2.9.8</version>
+ </dependency>
+
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
diff --git a/src/main/java/org/onap/music/datastore/MusicDataStoreHandle.java b/src/main/java/org/onap/music/datastore/MusicDataStoreHandle.java
index 194fdad1..dc1c43a8 100644
--- a/src/main/java/org/onap/music/datastore/MusicDataStoreHandle.java
+++ b/src/main/java/org/onap/music/datastore/MusicDataStoreHandle.java
@@ -3,6 +3,7 @@
* org.onap.music
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
+ * Modifications Copyright (C) 2019 IBM.
* ===================================================================
* Modifications Copyright (c) 2019 Samsung
* ===================================================================
@@ -69,7 +70,7 @@ public class MusicDataStoreHandle {
long start = System.currentTimeMillis();
if (mDstoreHandle == null) {
// Quick Fix - Best to put this into every call to getDSHandle?
- if (! MusicUtil.getMyCassaHost().equals("localhost") ) {
+ if (!"localhost".equals(MusicUtil.getMyCassaHost())) {
mDstoreHandle = new MusicDataStore(MusicUtil.getMyCassaHost());
} else {
mDstoreHandle = new MusicDataStore();
diff --git a/src/main/java/org/onap/music/eelf/logging/format/AppMessages.java b/src/main/java/org/onap/music/eelf/logging/format/AppMessages.java
index 40f69e36..5af3661c 100644
--- a/src/main/java/org/onap/music/eelf/logging/format/AppMessages.java
+++ b/src/main/java/org/onap/music/eelf/logging/format/AppMessages.java
@@ -55,10 +55,10 @@ public enum AppMessages {
* [ERR402E] Ill formed queryObject for the request
* [ERR403E] Error processing Prepared Query Object
*
- * 500-599 - Zookeepr/Locking Related
+ * 500-599 - Locking Related
* [ERR500E] Invalid lock
* [ERR501E] Locking Error has occured
- * [ERR502E] Zookeeper error has occured
+ * [ERR502E] Deprecated
* [ERR503E] Failed to aquire lock store handle
* [ERR504E] Failed to create Lock Reference
* [ERR505E] Lock does not exist
@@ -68,7 +68,7 @@ public enum AppMessages {
* [ERR509E] Lock not destroyed
* [ERR510E] Lock not released
* [ERR511E] Lock not deleted
- * [ERR512E] Failed to get ZK Lock Handle
+ * [ERR512E] Deprecated
*
*
* 600 - 699 - Music Service Errors
@@ -113,7 +113,6 @@ public enum AppMessages {
INVALIDLOCK("[ERR500E]"," Invalid lock or acquire failed",""," Lock is not valid to aquire"),
LOCKINGERROR("[ERR501E]"," Locking Error has occured",""," Locking Error has occured"),
- KEEPERERROR("[ERR502E]"," Zookeeper error has occured","","Please check zookeeper details"),
LOCKHANDLE("[ERR503E]","Failed to aquire lock store handle",""," Failed to aquire lock store handle"),
CREATELOCK("[ERR504E]","Failed to aquire lock store handle ","","Failed to aquire lock store handle "),
LOCKSTATE("[ERR508E]"," Lock state not set",""," Lock state not set"),
diff --git a/src/main/java/org/onap/music/lockingservice/cassandra/CassaLockStore.java b/src/main/java/org/onap/music/lockingservice/cassandra/CassaLockStore.java
index 237b9417..4ed63575 100644
--- a/src/main/java/org/onap/music/lockingservice/cassandra/CassaLockStore.java
+++ b/src/main/java/org/onap/music/lockingservice/cassandra/CassaLockStore.java
@@ -3,6 +3,7 @@
* org.onap.music
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
+ * Modifications Copyright (C) 2019 IBM.
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -115,14 +116,13 @@ public class CassaLockStore {
long prevGuard = 0;
long lockRef = 1;
- if (latestGuardRow.size() > 0) {
+ if (!latestGuardRow.isEmpty()) {
prevGuard = latestGuardRow.get(0).getLong(0);
lockRef = prevGuard + 1;
}
long lockEpochMillis = System.currentTimeMillis();
-// System.out.println("guard(" + lockName + "): " + prevGuard + "->" + lockRef);
logger.info(EELFLoggerDelegate.applicationLogger,
"Created lock reference for " + keyspace + "." + lockTable + "." + lockName + ":" + lockRef);
@@ -143,8 +143,8 @@ public class CassaLockStore {
queryObject.addValue(String.valueOf(lockEpochMillis));
queryObject.addValue("0");
queryObject.appendQueryString(insQuery);
- boolean pResult = dsHandle.executePut(queryObject, "critical");
- return "$"+keyspace+"."+table+"."+lockName+"$"+String.valueOf(lockRef);
+ dsHandle.executePut(queryObject, "critical");
+ return "$"+keyspace+"."+table+"."+lockName+"$"+ lockRef;
}
/**
@@ -233,7 +233,7 @@ public class CassaLockStore {
public void deQueueLockRef(String keyspace, String table, String key, String lockReference) throws MusicServiceException, MusicQueryException{
table = table_prepend_name+table;
PreparedQueryObject queryObject = new PreparedQueryObject();
- Long lockReferenceL = Long.parseLong(lockReference.substring(lockReference.lastIndexOf("$")+1));
+ Long lockReferenceL = Long.parseLong(lockReference.substring(lockReference.lastIndexOf('$')+1));
String deleteQuery = "delete from "+keyspace+"."+table+" where key='"+key+"' AND lockReference ="+lockReferenceL+" IF EXISTS;";
queryObject.appendQueryString(deleteQuery);
dsHandle.executePut(queryObject, "critical");
diff --git a/src/main/java/org/onap/music/lockingservice/cassandra/MusicLockState.java b/src/main/java/org/onap/music/lockingservice/cassandra/MusicLockState.java
index a8e5ac48..5128e2cd 100644
--- a/src/main/java/org/onap/music/lockingservice/cassandra/MusicLockState.java
+++ b/src/main/java/org/onap/music/lockingservice/cassandra/MusicLockState.java
@@ -35,7 +35,7 @@ import org.onap.music.eelf.logging.format.AppMessages;
import org.onap.music.eelf.logging.format.ErrorSeverity;
import org.onap.music.eelf.logging.format.ErrorTypes;
-// the state variable that will be stored in zookeeper, capturing the transitions of
+// the state variable that will be stored in the locking service, capturing the transitions of
public class MusicLockState implements Serializable {
public enum LockStatus {
UNLOCKED, BEING_LOCKED, LOCKED
diff --git a/src/main/java/org/onap/music/main/MusicUtil.java b/src/main/java/org/onap/music/main/MusicUtil.java
index aa82ea97..b737377d 100755
--- a/src/main/java/org/onap/music/main/MusicUtil.java
+++ b/src/main/java/org/onap/music/main/MusicUtil.java
@@ -118,7 +118,7 @@ public class MusicUtil {
private static String musicRestIp = LOCALHOST;
private static String musicPropertiesFilePath = PROPERTIES_FILE;
private static long defaultLockLeasePeriod = 6000;
- private static final String[] propKeys = new String[] { "zookeeper.host", "cassandra.host", "music.ip", "debug",
+ private static final String[] propKeys = new String[] { "cassandra.host", "music.ip", "debug",
"version", "music.rest.ip", "music.properties", "lock.lease.period", "id", "all.ids", "public.ip",
"all.pubic.ips", "cassandra.user", "cassandra.password", "aaf.endpoint.url","admin.username","admin.password","aaf.admin.url",
"music.namespace","admin.aaf.role","cassandra.port","lock.using"};
@@ -428,25 +428,6 @@ public class MusicUtil {
}
/**
- * Get MyZkHost - Zookeeper Hostname - Default = localhost property file
- * value - zookeeper.host
- *
- * @return
- */
- public static String getMyZkHost() {
- return myZkHost;
- }
-
- /**
- * Set MyZkHost - Zookeeper Hostname
- *
- * @param myZkHost
- */
- public static void setMyZkHost(String myZkHost) {
- MusicUtil.myZkHost = myZkHost;
- }
-
- /**
* Get MyCassHost - Cassandra Hostname - Default = localhost property file
* value - cassandra.host
*
@@ -734,8 +715,6 @@ public class MusicUtil {
}
// get the property value and return it
MusicUtil.setMyCassaHost(prop.getProperty("cassandra.host"));
- String zkHosts = prop.getProperty("zookeeper.host");
- MusicUtil.setMyZkHost(zkHosts);
MusicUtil.setCassName(prop.getProperty("cassandra.user"));
MusicUtil.setCassPwd(prop.getProperty("cassandra.password"));
MusicUtil.setCassandraPort(Integer.parseInt(prop.getProperty("cassandra.port")));
diff --git a/src/main/java/org/onap/music/main/PropertiesListener.java b/src/main/java/org/onap/music/main/PropertiesListener.java
deleted file mode 100755
index c5e8c37c..00000000
--- a/src/main/java/org/onap/music/main/PropertiesListener.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * ============LICENSE_START==========================================
- * org.onap.music
- * ===================================================================
- * Copyright (c) 2017 AT&T Intellectual Property
- * Modifications Copyright (C) 2018 IBM.
- * ===================================================================
- * 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=============================================
- * ====================================================================
- */
-
-package org.onap.music.main;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
-import org.onap.music.datastore.PreparedQueryObject;
-import org.onap.music.eelf.logging.EELFLoggerDelegate;
-import org.onap.music.eelf.logging.format.AppMessages;
-import org.onap.music.eelf.logging.format.ErrorSeverity;
-import org.onap.music.eelf.logging.format.ErrorTypes;
-
-import org.onap.music.exceptions.MusicLockingException;
-import org.onap.music.exceptions.MusicServiceException;
-
-import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.Row;
-
-public class PropertiesListener { // implements ServletContextListener {
- private Properties prop;
- private static final String MUSIC_PROPERTIES="music.properties";
-/* private Properties prop;
-
->>>>>>> c8db07f77a945bc22046ef50d773c3c3608b014a
- private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PropertiesListener.class);
-
- @Override
- public void contextInitialized(ServletContextEvent servletContextEvent) {
- prop = new Properties();
- Properties projectProp = new Properties();
- URL resource = getClass().getResource("/");
- String musicPropertiesFilePath = resource.getPath().replace("WEB-INF/classes/","WEB-INF/classes/project.properties");
-
- // Open the file
- try {
- InputStream musicProps = null;
- projectProp.load(new FileInputStream(musicPropertiesFilePath));
- if (projectProp.containsKey(MUSIC_PROPERTIES)) {
- musicProps = new FileInputStream(projectProp.getProperty(MUSIC_PROPERTIES));
- } else {
- musicProps = new FileInputStream(MusicUtil.getMusicPropertiesFilePath());
- }
- prop.load(musicProps);
- musicProps.close();
- prop.putAll(projectProp);
- String[] propKeys = MusicUtil.getPropkeys();
- for (int k = 0; k < propKeys.length; k++) {
- String key = propKeys[k];
- if (prop.containsKey(key) && prop.get(key) != null) {
- logger.info(key + " : " + prop.getProperty(key));
- switch (key) {
- case "zookeeper.host":
- MusicUtil.setMyZkHost(prop.getProperty(key));
- break;
- case "cassandra.host":
- MusicUtil.setMyCassaHost(prop.getProperty(key));
- break;
- case "music.ip":
- MusicUtil.setDefaultMusicIp(prop.getProperty(key));
- break;
- case "debug":
- MusicUtil.setDebug(Boolean
- .getBoolean(prop.getProperty(key).toLowerCase()));
- break;
- case "version":
- MusicUtil.setVersion(prop.getProperty(key));
- break;
- case "music.rest.ip":
- MusicUtil.setMusicRestIp(prop.getProperty(key));
- break;
- case MUSIC_PROPERTIES:
- MusicUtil.setMusicPropertiesFilePath(prop.getProperty(key));
- break;
- case "lock.lease.period":
- MusicUtil.setDefaultLockLeasePeriod(
- Long.parseLong(prop.getProperty(key)));
- break;
- case "my.id":
- MusicUtil.setMyId(Integer.parseInt(prop.getProperty(key)));
- break;
- case "all.ids":
- String[] ids = prop.getProperty(key).split(":");
- MusicUtil.setAllIds(new ArrayList<String>(Arrays.asList(ids)));
- break;
- case "public.ip":
- MusicUtil.setPublicIp(prop.getProperty(key));
- break;
- case "all.public.ips":
- String[] ips = prop.getProperty(key).split(":");
- if (ips.length == 1) {
- // Future use
- } else if (ips.length > 1) {
- MusicUtil.setAllPublicIps(
- new ArrayList<String>(Arrays.asList(ips)));
- }
- break;
- case "cassandra.user":
- MusicUtil.setCassName(prop.getProperty(key));
- break;
- case "cassandra.password":
- MusicUtil.setCassPwd(prop.getProperty(key));
- break;
- case "aaf.endpoint.url":
- MusicUtil.setAafEndpointUrl(prop.getProperty(key));
- break;
- case "admin.username":
- MusicUtil.setAdminId(prop.getProperty(key));
- break;
- case "admin.password":
- MusicUtil.setAdminPass(prop.getProperty(key));
- break;
- case "cassandra.port":
- MusicUtil.setCassandraPort(Integer.parseInt(prop.getProperty(key)));
- break;
- case "aaf.admin.url":
- MusicUtil.setAafAdminUrl(prop.getProperty(key));
- break;
- case "music.namespace":
- MusicUtil.setMusicNamespace(prop.getProperty(key));
- break;
- case "admin.aaf.role":
- MusicUtil.setAdminAafRole(prop.getProperty(key));
- break;
- case "notify.interval":
- MusicUtil.setNotifyInterval(Integer.parseInt(prop.getProperty(key)));
- break;
- case "notify.timeout":
- MusicUtil.setNotifyTimeOut(Integer.parseInt(prop.getProperty(key)));
- break;
- case "lock.using":
- MusicUtil.setLockUsing(prop.getProperty(key));
- break;
- case "cacheobject.maxlife":
- MusicUtil.setCacheObjectMaxLife(Integer.parseInt(prop.getProperty(key)));
- CachingUtil.setCacheEternalProps();
- break;
- default:
- logger.error(EELFLoggerDelegate.errorLogger,
- "No case found for " + key);
- }
- }
- }
- } catch (IOException e) {
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.IOERROR ,ErrorSeverity.CRITICAL, ErrorTypes.CONNECTIONERROR);
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage());
- }
-
- logger.info(EELFLoggerDelegate.applicationLogger,
- "Starting MUSIC " + MusicUtil.getVersion() + " on node with id "
- + MusicUtil.getMyId() + " and public ip "
- + MusicUtil.getPublicIp() + "...");
- logger.info(EELFLoggerDelegate.applicationLogger,
- "List of all MUSIC ids:" + MusicUtil.getAllIds().toString());
- logger.info(EELFLoggerDelegate.applicationLogger,
- "List of all MUSIC public ips:" + MusicUtil.getAllPublicIps().toString());
-
- scheduleCronJobForZKCleanup();
- }
-
- @Override
- public void contextDestroyed(ServletContextEvent servletContextEvent) {
- prop = null;
- }
-
-
- private ScheduledExecutorService scheduler;
- public void scheduleCronJobForZKCleanup() {
- scheduler = Executors.newSingleThreadScheduledExecutor();
- scheduler.scheduleAtFixedRate(new CachingUtil(), 0, 24, TimeUnit.HOURS);
- PreparedQueryObject pQuery = new PreparedQueryObject();
- String consistency = MusicUtil.EVENTUAL;
- pQuery.appendQueryString("CREATE TABLE IF NOT EXISTS admin.locks ( lock_id text PRIMARY KEY, ctime text)");
- try {
- ResultType result = MusicCore.nonKeyRelatedPut(pQuery, consistency);
- } catch (MusicServiceException e1) {
- logger.error(EELFLoggerDelegate.errorLogger, e1.getMessage(),ErrorSeverity.ERROR);
- }
-
- //Zookeeper cleanup
- scheduler.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- deleteLocksFromDB();
- }
- } , 0, 24, TimeUnit.HOURS);
- }
-
-
- public void deleteLocksFromDB() {
- PreparedQueryObject pQuery = new PreparedQueryObject();
- pQuery.appendQueryString(
- "select * from admin.locks");
- try {
- ResultSet rs = MusicCore.get(pQuery);
- Iterator<Row> it = rs.iterator();
- StringBuilder deleteKeys = new StringBuilder();
- Boolean expiredKeys = false;
- while (it.hasNext()) {
- Row row = (Row) it.next();
- String id = row.getString("lock_id");
- long ctime = Long.parseLong(row.getString("ctime"));
- if(System.currentTimeMillis() >= ctime + 24 * 60 * 60 * 1000) {
- expiredKeys = true;
- String new_id = id.substring(1);
- try {
- MusicCore.deleteLock(new_id);
- } catch (MusicLockingException e) {
- logger.info(EELFLoggerDelegate.applicationLogger,
- e.getMessage());
- }
- deleteKeys.append("'").append(id).append("'").append(",");
- }
- }
- if(expiredKeys) {
- deleteKeys.deleteCharAt(deleteKeys.length()-1);
- CachingUtil.deleteKeysFromDB(deleteKeys.toString());
- }
- } catch (MusicServiceException e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),ErrorSeverity.ERROR);
- }
- }
-*/
-}
diff --git a/src/main/java/org/onap/music/main/PropertiesLoader.java b/src/main/java/org/onap/music/main/PropertiesLoader.java
index ee10db42..db04ff4b 100644
--- a/src/main/java/org/onap/music/main/PropertiesLoader.java
+++ b/src/main/java/org/onap/music/main/PropertiesLoader.java
@@ -37,9 +37,6 @@ import org.springframework.stereotype.Component;
@Component
public class PropertiesLoader implements InitializingBean {
- @Value("${zookeeper.host}")
- private String zookeeperHost;
-
@Value("${cassandra.host}")
public String cassandraHost;
@@ -168,8 +165,6 @@ public class PropertiesLoader implements InitializingBean {
logger.info("#### Cassandra Host: " + MusicUtil.getMyCassaHost());
if(myId != null && !myId.equals("${my.id}"))
MusicUtil.setMyId(Integer.parseInt(myId));
- if(zookeeperHost != null && !zookeeperHost.equals("${zookeeper.host}"))
- MusicUtil.setMyZkHost(zookeeperHost);
if(notifyInterval != null && !notifyInterval.equals("${notify.interval}"))
MusicUtil.setNotifyInterval(Integer.parseInt(notifyInterval));
if(notifyTimeout != null && !notifyTimeout.equals("${notify.timeout}"))
diff --git a/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java b/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java
index b3e3b4d5..943f4ca8 100644
--- a/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java
@@ -70,7 +70,7 @@ public class RestMusicLocksAPI {
/**
* Puts the requesting process in the q for this lock. The corresponding
- * node will be created in zookeeper if it did not already exist
+ * node will be created if it did not already exist
*
* @param lockName
* @return
@@ -80,7 +80,7 @@ public class RestMusicLocksAPI {
@Path("/create/{lockname}")
@ApiOperation(value = "Create Lock",
notes = "Puts the requesting process in the q for this lock." +
- " The corresponding node will be created in zookeeper if it did not already exist." +
+ " The corresponding lock will be created if it did not already exist." +
" Lock Name is the \"key\" of the form keyspaceName.tableName.rowId",
response = Map.class)
@Produces(MediaType.APPLICATION_JSON)
diff --git a/src/main/java/org/onap/music/rest/RestMusicQAPI.java b/src/main/java/org/onap/music/rest/RestMusicQAPI.java
index 0865eafe..676730e0 100755
--- a/src/main/java/org/onap/music/rest/RestMusicQAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicQAPI.java
@@ -3,6 +3,7 @@
* org.onap.music
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
+ * Modifications Copyright (C) 2019 IBM.
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,6 +53,7 @@ import org.apache.commons.lang3.StringUtils;
import org.onap.music.datastore.MusicDataStoreHandle;
import org.onap.music.datastore.PreparedQueryObject;
import com.datastax.driver.core.ResultSet;
+import org.onap.music.exceptions.MusicQueryException;
import org.onap.music.exceptions.MusicServiceException;
import org.onap.music.main.MusicCore;
import org.onap.music.main.MusicUtil;
@@ -62,8 +64,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
-// import io.swagger.models.Response;
-// @Path("/v{version: [0-9]+}/priorityq/")
@Path("/v2/priorityq/")
@Api(value = "Q Api")
public class RestMusicQAPI {
@@ -95,14 +95,11 @@ public class RestMusicQAPI {
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
JsonTable tableObj,
@ApiParam(value = "Key Space", required = true) @PathParam("keyspace") String keyspace,
- @ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename)
- throws Exception {
- //logger.info(logger, "cjc before start in q 1** major version=" + version);
-
+ @ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename) throws Exception {
ResponseBuilder response = MusicUtil.buildVersionResponse(version, minorVersion, patchVersion);
Map<String, String> fields = tableObj.getFields();
- if (fields == null) { // || (!fields.containsKey("order")) ){
+ if (fields == null) {
logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
return response.status(Status.BAD_REQUEST)
@@ -240,7 +237,7 @@ public class RestMusicQAPI {
JsonInsert insObj,
@ApiParam(value = "Key Space", required = true) @PathParam("keyspace") String keyspace,
@ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename)
- throws Exception {
+ {
ResponseBuilder response = MusicUtil.buildVersionResponse(version, minorVersion, patchVersion);
if (insObj.getValues().isEmpty()) {
logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
@@ -278,7 +275,7 @@ public class RestMusicQAPI {
JsonUpdate updateObj,
@ApiParam(value = "Key Space", required = true) @PathParam("keyspace") String keyspace,
@ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename,
- @Context UriInfo info) throws Exception {
+ @Context UriInfo info) throws MusicServiceException, MusicQueryException {
ResponseBuilder response = MusicUtil.buildVersionResponse(version, minorVersion, patchVersion);
if (updateObj.getValues().isEmpty()) {
@@ -324,7 +321,7 @@ public class RestMusicQAPI {
JsonDelete delObj,
@ApiParam(value = "Key Space", required = true) @PathParam("keyspace") String keyspace,
@ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename,
- @Context UriInfo info) throws Exception {
+ @Context UriInfo info) throws MusicServiceException, MusicQueryException {
// added checking as per RestMusicDataAPI
ResponseBuilder response = MusicUtil.buildVersionResponse(version, minorVersion, patchVersion);
if (delObj == null) {
@@ -362,7 +359,7 @@ public class RestMusicQAPI {
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
@ApiParam(value = "Key Space", required = true) @PathParam("keyspace") String keyspace,
@ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename,
- @Context UriInfo info) throws Exception {
+ @Context UriInfo info) {
int limit =1; //peek must return just the top row
Map<String ,String> auth = new HashMap<>();
String userId =auth.get(MusicUtil.USERID);
@@ -448,8 +445,7 @@ public class RestMusicQAPI {
@ApiParam(value = "Application namespace", required = true) @HeaderParam("ns") String ns,
@ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
@ApiParam(value = "Key Space", required = true) @PathParam("keyspace") String keyspace,
- @ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename)
- throws Exception {
+ @ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename) throws Exception {
return new RestMusicDataAPI().dropTable(version, minorVersion, patchVersion, aid, ns, authorization, keyspace, tablename);
}
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml
index 6bc5fd5e..8d3164f0 100644
--- a/src/main/resources/logback.xml
+++ b/src/main/resources/logback.xml
@@ -292,7 +292,7 @@
<root level="INFO">
<appender-ref ref="asyncEELF" />
- <!-- <appender-ref ref="STDOUT" /> -->
+ <appender-ref ref="STDOUT" />
</root>
<!-- Conductor Specific additions to squash WARNING and INFO -->
diff --git a/src/test/java/org/onap/music/unittests/MusicUtilTest.java b/src/test/java/org/onap/music/unittests/MusicUtilTest.java
index 47f387cf..04149fc6 100644
--- a/src/test/java/org/onap/music/unittests/MusicUtilTest.java
+++ b/src/test/java/org/onap/music/unittests/MusicUtilTest.java
@@ -3,6 +3,7 @@
* org.onap.music
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
+ * Modifications Copyright (C) 2019 IBM.
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -92,7 +93,7 @@ public class MusicUtilTest {
@Test
public void testGetPropkeys() {
- assertEquals(MusicUtil.getPropkeys()[2],"music.ip");
+ assertEquals(MusicUtil.getPropkeys()[2],"debug");
}
@Test
@@ -215,4 +216,10 @@ public class MusicUtilTest {
}
+ @Test
+ public void testIsValidConsistency(){
+ assertTrue(MusicUtil.isValidConsistency("ALL"));
+ assertFalse(MusicUtil.isValidConsistency("TEST"));
+ }
+
}
diff --git a/src/test/java/org/onap/music/unittests/TestRestMusicQAPI.java b/src/test/java/org/onap/music/unittests/TestRestMusicQAPI.java
index c2666d22..4594ba2c 100644
--- a/src/test/java/org/onap/music/unittests/TestRestMusicQAPI.java
+++ b/src/test/java/org/onap/music/unittests/TestRestMusicQAPI.java
@@ -35,7 +35,6 @@ import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
-import org.apache.curator.test.TestingServer;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -85,7 +84,6 @@ public class TestRestMusicQAPI {
RestMusicLocksAPI lock = new RestMusicLocksAPI();
RestMusicQAPI qData = new RestMusicQAPI();
static PreparedQueryObject testObject;
- static TestingServer zkServer;
@Mock
static HttpServletResponse http;
@@ -216,8 +214,6 @@ public class TestRestMusicQAPI {
MusicCore.eventualPut(testObject);
if (MusicDataStoreHandle.mDstoreHandle!=null) {}
//MusicDataStoreHandle.mDstoreHandle.close();
- if (zkServer!=null)
- zkServer.stop();
}
diff --git a/src/test/resources/LICENSE.txt b/src/test/resources/LICENSE.txt
new file mode 100644
index 00000000..cc6cdea5
--- /dev/null
+++ b/src/test/resources/LICENSE.txt
@@ -0,0 +1,24 @@
+
+The following license applies to all files in this and sub-directories. Licenses
+are included in individual source files where appropriate, and if it differs
+from this text, it supersedes this. Any file that does not have license text
+defaults to being covered by this text; not all files support the addition of
+licenses.
+#
+# -------------------------------------------------------------------------
+# Copyright (c) 2017 AT&T Intellectual Property
+#
+# 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.
+#
+# -------------------------------------------------------------------------
+# \ No newline at end of file
diff --git a/src/test/resources/Resources.properties b/src/test/resources/Resources.properties
new file mode 100644
index 00000000..72269cb8
--- /dev/null
+++ b/src/test/resources/Resources.properties
@@ -0,0 +1,50 @@
+#============LICENSE_START==========================================
+#org.onap.music
+#===================================================================
+# Copyright (c) 2017 AT&T Intellectual Property
+#===================================================================
+# 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=============================================
+#====================================================================
+#Resource key=Error Code|Message text|Resolution text |Description text
+LOADING_DEFAULT_LOG_CONFIGURATION=\
+ EELF0001I|\
+ Loading default logging configuration from system resource file "{0}"|\
+ No external logging configurations were defined or found, So verify the default logging configuration from system resource file (../logback.xml). |\
+ Loading default logging configuration from system resource file
+LOADING_LOG_CONFIGURATION=EELF0002I|\
+ Loading logging configuration from file "{0}"|\
+ Verify the correct logging configuration file is loaded. |\
+ Loading logging configuration for specific file
+LOGGING_ALREADY_INITIALIZED=\
+ EELF0003W|\
+ Logging has already been initialized, check the container logging definitions to ensure they represent your desired logging configuration.|\
+ Verify the container logging definitions to ensure they represent your desired logging configuration. |\
+ Logging has already been initialized, check the container logging definitions to ensure they represent your desired logging configuration.
+NO_LOG_CONFIGURATION=\
+ EELF0004E|\
+ No log configuration could be found or defaulted!|\
+ No external and default logging configuration file. |\
+ No log configuration could be found or defaulted!
+SEARCHING_LOG_CONFIGURATION=\
+ EELF0005I|\
+ Searching path "{0}" for log configuration file "{1}"|\
+ Verify the correct Path({user.home};etc;../etc) and filename (eelf.logging.file).|\
+ Searching path for specific log configuration file.
+UNSUPPORTED_LOGGING_FRAMEWORK=\
+ EELF0006E|\
+ An unsupported logging framework is bound to SLF4J. |\
+ Verify your logging frameworks.|\
+ An unsupported logging framework is bound to SLF4J.
+
diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties
new file mode 100644
index 00000000..02e9c1a9
--- /dev/null
+++ b/src/test/resources/application.properties
@@ -0,0 +1,2 @@
+server.port=8080
+server.servlet.context-path=/MUSIC/rest \ No newline at end of file
diff --git a/src/test/resources/cache.ccf b/src/test/resources/cache.ccf
new file mode 100644
index 00000000..e152ee8b
--- /dev/null
+++ b/src/test/resources/cache.ccf
@@ -0,0 +1,62 @@
+# DEFAULT CACHE REGION
+jcs.default=DC
+jcs.default.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
+jcs.default.cacheattributes.MaxObjects=1000
+jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache
+jcs.default.elementattributes=org.apache.commons.jcs.engine.ElementAttributes
+jcs.default.elementattributes.IsEternal=true
+jcs.default.elementattributes.IsSpool=true
+
+# PRE-DEFINED CACHE REGIONS
+jcs.region.musicCache=
+jcs.region.musicCache.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
+jcs.region.musicCache.cacheattributes.MaxObjects=1000
+jcs.region.musicCache.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache
+jcs.region.musicCache.cacheattributes.UseMemoryShrinker=false
+jcs.region.musicCache.cacheattributes.MaxMemoryIdleTime=3600
+jcs.region.musicCache.cacheattributes.ShrinkerInterval=60
+jcs.region.musicCache.cacheattributes.MaxSpoolPerRun=500
+jcs.region.musicCache.elementattributes=org.apache.commons.jcs.engine.ElementAttributes
+jcs.region.musicCache.elementattributes.IsEternal=false
+
+
+# PRE-DEFINED CACHE REGIONS
+jcs.region.aafCache=
+jcs.region.aafCache.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
+jcs.region.aafCache.cacheattributes.MaxObjects=1000
+jcs.region.aafCache.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache
+jcs.region.aafCache.cacheattributes.UseMemoryShrinker=false
+jcs.region.aafCache.cacheattributes.MaxMemoryIdleTime=3600
+jcs.region.aafCache.cacheattributes.ShrinkerInterval=60
+jcs.region.aafCache.cacheattributes.MaxSpoolPerRun=500
+jcs.region.aafCache.elementattributes=org.apache.commons.jcs.engine.ElementAttributes
+jcs.region.aafCache.elementattributes.IsEternal=false
+
+# PRE-DEFINED CACHE REGIONS
+jcs.region.appNameCache=
+jcs.region.appNameCache.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
+jcs.region.appNameCache.cacheattributes.MaxObjects=1000
+jcs.region.appNameCache.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache
+jcs.region.appNameCache.cacheattributes.UseMemoryShrinker=false
+jcs.region.appNameCache.cacheattributes.MaxMemoryIdleTime=3600
+jcs.region.appNameCache.cacheattributes.ShrinkerInterval=60
+jcs.region.appNameCache.cacheattributes.MaxSpoolPerRun=500
+jcs.region.appNameCache.elementattributes=org.apache.commons.jcs.engine.ElementAttributes
+jcs.region.appNameCache.elementattributes.IsEternal=false
+
+jcs.default=DC
+jcs.default.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
+jcs.default.cacheattributes.MaxObjects=1000
+jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache
+jcs.default.elementattributes=org.apache.commons.jcs.engine.ElementAttributes
+jcs.default.elementattributes.IsEternal=true
+jcs.default.elementattributes.IsSpool=true
+
+jcs.region.eternalCache=DC
+jcs.region.eternalCache.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
+jcs.region.eternalCache.cacheattributes.MaxObjects=1000
+jcs.region.eternalCache.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache
+jcs.region.eternalCache.elementattributes=org.apache.commons.jcs.engine.ElementAttributes
+jcs.region.eternalCache.elementattributes.IsEternal=true
+jcs.region.eternalCache.elementattributes.IsSpool=true
+
diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml
new file mode 100644
index 00000000..6bc5fd5e
--- /dev/null
+++ b/src/test/resources/logback.xml
@@ -0,0 +1,302 @@
+<!--
+ ============LICENSE_START==========================================
+ org.onap.music
+ ===================================================================
+ Copyright (c) 2017 AT&T Intellectual Property
+ ===================================================================
+ 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=============================================
+ ====================================================================
+-->
+<configuration scan="true" scanPeriod="3 seconds">
+ <!--<jmxConfigurator /> -->
+ <!-- directory path for all other type logs -->
+ <property name="logDir" value="/opt/app/music/logs" />
+
+ <!-- directory path for debugging type logs -->
+ <property name="debugDir" value="debug-logs" />
+
+ <!-- specify the component name -->
+ <!-- <property name="componentName" value="EELF"></property> -->
+ <property name="componentName" value="MUSIC"></property>
+
+ <!-- log file names -->
+ <property name="generalLogName" value="music" />
+ <property name="securityLogName" value="security" />
+ <property name="errorLogName" value="error" />
+ <property name="metricsLogName" value="metrics" />
+ <property name="auditLogName" value="audit" />
+ <property name="debugLogName" value="debug" />
+ <property name="defaultPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n" />
+ <!-- <property name="applicationLoggerPattern" value="%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %msg%n" /> -->
+ <property name="applicationLoggerPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5level %X{keyspace} - %msg%n" />
+ <property name="auditLoggerPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{VirtualServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Unused}|%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}| %msg%n" />
+ <property name="metricsLoggerPattern" value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{VirtualServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Unused}|%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}| %msg%n" />
+ <!-- <property name="errorLoggerPattern" value= "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %msg%n " /> -->
+ <property name="errorLoggerPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5level %X{keyspace} - %msg%n" />
+ <property name="debugLoggerPattern" value="%date{ISO8601,UTC}|%X{RequestId}| %msg%n" ></property>
+ <property name="logDirectory" value="${logDir}/${componentName}" />
+ <property name="debugLogDirectory" value="${debugDir}/${componentName}" />
+ <!-- Example evaluator filter applied against console appender -->
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <!-- <encoder>
+ <pattern>${defaultPattern}</pattern>
+ </encoder> -->
+ <layout class="">
+ <pattern>
+ %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
+ </pattern>
+ </layout>
+ </appender>
+
+ <!-- ============================================================================ -->
+ <!-- EELF Appenders -->
+ <!-- ============================================================================ -->
+<!-- <appender name="EELF"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/${generalLogName}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${logDirectory}/${generalLogName}.%i.log.zip
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>9</maxIndex>
+ </rollingPolicy>
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>100MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <pattern>${applicationLoggerPattern}</pattern>
+ </encoder>
+ </appender> -->
+
+ <!-- <appender name="EELF" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/${generalLogName}.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ daily rollover
+ <fileNamePattern>${logDirectory}/${generalLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
+ <maxFileSize>1GB</maxFileSize>
+ <maxHistory>5</maxHistory>
+ <totalSizeCap>5GB</totalSizeCap>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${applicationLoggerPattern}</pattern>
+ </encoder>
+ </appender> -->
+
+
+ <appender name="EELF" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/${generalLogName}.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <!-- daily rollover -->
+ <fileNamePattern>${logDirectory}/${generalLogName}.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
+ <maxFileSize>1GB</maxFileSize>
+ <maxHistory>5</maxHistory>
+ <totalSizeCap>5GB</totalSizeCap>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${applicationLoggerPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="asyncEELF" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <includeCallerData>true</includeCallerData>
+ <appender-ref ref="EELF" />
+ </appender>
+
+ <!-- EELF Security Appender. This appender is used to record security events
+ to the security log file. Security events are separate from other loggers
+ in EELF so that security log records can be captured and managed in a secure
+ way separate from the other logs. This appender is set to never discard any
+ events. -->
+ <appender name="EELFSecurity"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/${securityLogName}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${logDirectory}/${securityLogName}.%i.log.zip
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>9</maxIndex>
+ </rollingPolicy>
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n </pattern>
+ </encoder>
+ </appender>
+
+ <appender name="asyncEELFSecurity" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <discardingThreshold>0</discardingThreshold>
+ <appender-ref ref="EELFSecurity" />
+ </appender>
+
+
+
+
+ <!-- EELF Audit Appender. This appender is used to record audit engine
+ related logging events. The audit logger and appender are specializations
+ of the EELF application root logger and appender. This can be used to segregate
+ Policy engine events from other components, or it can be eliminated to record
+ these events as part of the application root log. -->
+
+ <appender name="EELFAudit"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/${auditLogName}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${logDirectory}/${auditLogName}.%i.log.zip
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>9</maxIndex>
+ </rollingPolicy>
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <pattern>${auditLoggerPattern}</pattern>
+ </encoder>
+ </appender>
+ <appender name="asyncEELFAudit" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <appender-ref ref="EELFAudit" />
+ </appender>
+
+<appender name="EELFMetrics"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/${metricsLogName}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${logDirectory}/${metricsLogName}.%i.log.zip
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>9</maxIndex>
+ </rollingPolicy>
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <!-- <pattern>"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} -
+ %msg%n"</pattern> -->
+ <pattern>${metricsLoggerPattern}</pattern>
+ </encoder>
+ </appender>
+
+
+ <appender name="asyncEELFMetrics" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <appender-ref ref="EELFMetrics"/>
+ </appender>
+
+ <appender name="EELFError"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/${errorLogName}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${logDirectory}/${errorLogName}.%i.log.zip
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>9</maxIndex>
+ </rollingPolicy>
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <pattern>${errorLoggerPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="asyncEELFError" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <appender-ref ref="EELFError"/>
+ </appender>
+
+ <appender name="EELFDebug"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${debugLogDirectory}/${debugLogName}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${debugLogDirectory}/${debugLogName}.%i.log.zip
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>9</maxIndex>
+ </rollingPolicy>
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <pattern>${debugLoggerPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="asyncEELFDebug" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <appender-ref ref="EELFDebug" />
+ <includeCallerData>true</includeCallerData>
+ </appender>
+
+
+ <!-- ============================================================================ -->
+ <!-- EELF loggers -->
+ <!-- ============================================================================ -->
+ <logger name="com.att.eelf" level="info" additivity="false">
+ <appender-ref ref="asyncEELF" />
+
+ </logger>
+ <logger name="com.att.eelf.security" level="info" additivity="false">
+ <appender-ref ref="asyncEELFSecurity" />
+
+ </logger>
+
+
+ <logger name="com.att.eelf.audit" level="info" additivity="false">
+ <appender-ref ref="asyncEELFAudit" />
+
+ </logger>
+
+ <logger name="com.att.eelf.metrics" level="info" additivity="false">
+ <appender-ref ref="asyncEELFMetrics" />
+
+ </logger>
+
+
+ <logger name="com.att.eelf.error" level="error" additivity="false">
+ <appender-ref ref="asyncEELFError" />
+
+ </logger>
+
+ <logger name="com.att.eelf.debug" level="debug" additivity="false">
+ <appender-ref ref="asyncEELFDebug" />
+
+ </logger>
+
+ <root level="INFO">
+ <appender-ref ref="asyncEELF" />
+ <!-- <appender-ref ref="STDOUT" /> -->
+ </root>
+
+ <!-- Conductor Specific additions to squash WARNING and INFO -->
+ <logger name="com.datastax.driver.core.Cluster" level="ERROR"/>
+ <logger name="org.onap.music.main.MusicCore" level="ERROR"/>
+
+</configuration>
diff --git a/src/test/resources/project.properties b/src/test/resources/project.properties
new file mode 100644
index 00000000..199afa33
--- /dev/null
+++ b/src/test/resources/project.properties
@@ -0,0 +1,4 @@
+version=${project.version}
+artifactId=${project.artifactId}
+music.properties=/opt/app/music/etc/music.properties
+