aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/music/main
diff options
context:
space:
mode:
authorThomas Nelson Jr <tn1381@att.com>2018-08-08 00:17:33 +0000
committerThomas Nelson Jr <tn1381@att.com>2018-08-08 00:17:33 +0000
commit64b04604921670862993fb2a72a895a6209947d5 (patch)
tree9e98c091e30c7c7fd2708588d40af56e7d38733e /src/main/java/org/onap/music/main
parent9b6efbd93a12c858a0d2643013217ec3d6c3a46d (diff)
Updates to Callback Api and Connection
Change-Id: I6a3f0537a616ae4d54b47fa2c70ba5128e39f123 Issue-ID: MUSIC-92 Signed-off-by: Thomas Nelson Jr <tn1381@att.com>
Diffstat (limited to 'src/main/java/org/onap/music/main')
-rwxr-xr-xsrc/main/java/org/onap/music/main/MusicUtil.java56
-rwxr-xr-xsrc/main/java/org/onap/music/main/PropertiesListener.java3
2 files changed, 55 insertions, 4 deletions
diff --git a/src/main/java/org/onap/music/main/MusicUtil.java b/src/main/java/org/onap/music/main/MusicUtil.java
index a161fd56..2dd2f231 100755
--- a/src/main/java/org/onap/music/main/MusicUtil.java
+++ b/src/main/java/org/onap/music/main/MusicUtil.java
@@ -23,12 +23,15 @@ package org.onap.music.main;
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.UUID;
@@ -69,7 +72,8 @@ public class MusicUtil {
public static final String UPSERT = "upsert";
public static final String USERID = "userId";
public static final String PASSWORD = "password";
- public static final String AUTHORIZATION = "Authorization";
+
+ public static final String AUTHORIZATION = "Authorization";
private static final String LOCALHOST = "localhost";
private static final String PROPERTIES_FILE = "/opt/app/music/etc/music.properties";
@@ -81,6 +85,8 @@ public class MusicUtil {
private static String myZkHost = LOCALHOST;
private static String myCassaHost = LOCALHOST;
private static String defaultMusicIp = LOCALHOST;
+ private static int cassandraPort = 9042;
+
private static boolean debug = true;
private static String version = "2.3.0";
private static String musicRestIp = LOCALHOST;
@@ -88,7 +94,7 @@ public class MusicUtil {
private static long defaultLockLeasePeriod = 6000;
private static final String[] propKeys = new String[] { "zookeeper.host", "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" };
+ "all.pubic.ips", "cassandra.user", "cassandra.password", "aaf.endpoint.url","cassandra.port" };
private static String cassName = "cassandra";
private static String cassPwd;
@@ -98,8 +104,21 @@ public class MusicUtil {
private MusicUtil() {
throw new IllegalStateException("Utility Class");
}
-
-
+ /**
+ *
+ * @return cassandra port
+ */
+ public static int getCassandraPort() {
+ return cassandraPort;
+ }
+
+ /**
+ * set cassandra port
+ * @param cassandraPort
+ */
+ public static void setCassandraPort(int cassandraPort) {
+ MusicUtil.cassandraPort = cassandraPort;
+ }
/**
* @return the cassName
*/
@@ -562,5 +581,34 @@ public class MusicUtil {
return authValues;
}
+
+ public static void loadProperties() throws Exception {
+ Properties prop = new Properties();
+ InputStream input = null;
+ try {
+ // load the properties file
+ input = MusicUtil.class.getClassLoader().getResourceAsStream("music.properties");
+ prop.load(input);
+ } catch (Exception ex) {
+ logger.error(EELFLoggerDelegate.errorLogger, "Unable to find properties file.");
+ throw new Exception();
+ } finally {
+ if (input != null) {
+ try {
+ input.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ // 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
index 8b00e473..0619cd41 100755
--- a/src/main/java/org/onap/music/main/PropertiesListener.java
+++ b/src/main/java/org/onap/music/main/PropertiesListener.java
@@ -119,6 +119,9 @@ public class PropertiesListener implements ServletContextListener {
case "aaf.endpoint.url":
MusicUtil.setAafEndpointUrl(prop.getProperty(key));
break;
+ case "cassandra.port":
+ MusicUtil.setCassandraPort(Integer.parseInt(prop.getProperty(key)));
+ break;
default:
logger.error(EELFLoggerDelegate.errorLogger,
"No case found for " + key);