X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fmusic%2Fmain%2FMusicUtil.java;h=da5da23954484ca87b9113741b1b0f5e5cedec49;hb=d6e7b63cc580e7b3822be61fe92a493ad5e222a3;hp=b737377d3175717d55398f1dc6705afbc925b3a9;hpb=97ea0b21eebad043a17cdc4224f8eb44bc2d8b29;p=music.git diff --git a/src/main/java/org/onap/music/main/MusicUtil.java b/src/main/java/org/onap/music/main/MusicUtil.java index b737377d..da5da239 100755 --- a/src/main/java/org/onap/music/main/MusicUtil.java +++ b/src/main/java/org/onap/music/main/MusicUtil.java @@ -112,19 +112,25 @@ public class MusicUtil { private static int cacheObjectMaxLife = -1; private static String lockUsing = MusicUtil.CASSANDRA; private static boolean isCadi = false; + private static boolean isKeyspaceActive = false; private static boolean debug = true; - private static String version = "2.3.0"; + private static String version = "0.0.0"; + private static String build = ""; private static String musicRestIp = LOCALHOST; private static String musicPropertiesFilePath = PROPERTIES_FILE; private static long defaultLockLeasePeriod = 6000; + private static int retryCount = 3; 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"}; + "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","retry.count"}; private static final String[] cosistencyLevel = new String[] { - "ALL","EACH_QUORUM","QUORUM","LOCAL_QUORUM","ONE","TWO","THREE","LOCAL_ONE","ANY","SERIAL","LOCAL_SERIAL"}; + "ALL","EACH_QUORUM","QUORUM","LOCAL_QUORUM","ONE","TWO", + "THREE","LOCAL_ONE","ANY","SERIAL","LOCAL_SERIAL"}; private static final Map consistencyName = new HashMap<>(); + static { consistencyName.put("ONE",ConsistencyLevel.ONE); consistencyName.put("TWO",ConsistencyLevel.TWO); @@ -145,8 +151,8 @@ public class MusicUtil { private static String adminId = "username"; private static String adminPass= "password"; private static String aafAdminUrl= null; - private static String musicNamespace= "com.att.music.api"; - private static String adminAafRole= "com.att.music.api.admin_api"; + private static String musicNamespace= "org.onap.music.api"; + private static String adminAafRole= "org.onap.music.api.admin_api"; public static final long MusicEternityEpochMillis = 1533081600000L; // Wednesday, August 1, 2018 12:00:00 AM @@ -213,7 +219,6 @@ public class MusicUtil { MusicUtil.adminPass = adminPass; } - private MusicUtil() { throw new IllegalStateException("Utility Class"); } @@ -419,7 +424,7 @@ public class MusicUtil { } /** - * Return the version property file value - version + * Return the version property file value - version. * * @return */ @@ -427,6 +432,23 @@ public class MusicUtil { return version; } + /** + * Set the build of project which is a combination of the + * version and the date. + * + * @param build - version-date. + */ + public static void setBuild(String build) { + MusicUtil.build = build; + } + + /** + * Return the build version-date. + */ + public static String getBuild() { + return build; + } + /** * Get MyCassHost - Cassandra Hostname - Default = localhost property file * value - cassandra.host @@ -440,7 +462,7 @@ public class MusicUtil { /** * Set MyCassHost - Cassandra Hostname * - * @param myCassaHost + * @param myCassaHost . */ public static void setMyCassaHost(String myCassaHost) { MusicUtil.myCassaHost = myCassaHost; @@ -458,27 +480,59 @@ public class MusicUtil { /** * Set DefaultMusicIp * - * @param defaultMusicIp + * @param defaultMusicIp . */ public static void setDefaultMusicIp(String defaultMusicIp) { MusicUtil.defaultMusicIp = defaultMusicIp; } - + /** - * + * Gey default retry count * @return */ + public static int getRetryCount() { + return retryCount; + } + + /** + * Set retry count + * @param retryCount . + */ + public static void setRetryCount(int retryCount) { + MusicUtil.retryCount = retryCount; + } + + + /** + * This is used to turn keyspace creation api on/off. + * + */ + public static void setKeyspaceActive(Boolean keyspaceActive) { + MusicUtil.isKeyspaceActive = keyspaceActive; + } + + /** + * This is used to turn keyspace creation api on/off. + * @return boolean isKeyspaceActive + */ + public static boolean isKeyspaceActive() { + return isKeyspaceActive; + } + + /** + * . + * @return String + */ public static String getTestType() { String testType = ""; try { Scanner fileScanner = new Scanner(new File("")); testType = fileScanner.next();// ignore the my id line @SuppressWarnings("unused") - String batchSize = fileScanner.next();// ignore the my public ip - // line + String batchSize = fileScanner.next();// ignore the my public ip line fileScanner.close(); } catch (FileNotFoundException e) { - logger.error(EELFLoggerDelegate.errorLogger, e.getMessage()); + logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), e); } return testType; @@ -492,7 +546,7 @@ public class MusicUtil { try { Thread.sleep(time); } catch (InterruptedException e) { - logger.error(EELFLoggerDelegate.errorLogger, e.getMessage()); + logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), e); Thread.currentThread().interrupt(); } } @@ -592,8 +646,8 @@ public class MusicUtil { } public static ByteBuffer convertToActualDataType(DataType colType, byte[] valueObj) { - ByteBuffer buffer = ByteBuffer.wrap(valueObj); - return buffer; + ByteBuffer buffer = ByteBuffer.wrap(valueObj); + return buffer; } /** @@ -702,7 +756,7 @@ public class MusicUtil { input = MusicUtil.class.getClassLoader().getResourceAsStream("music.properties"); prop.load(input); } catch (Exception ex) { - logger.error(EELFLoggerDelegate.errorLogger, "Unable to find properties file."); + logger.error(EELFLoggerDelegate.errorLogger, "Unable to find properties file.", ex); throw new Exception(); } finally { if (input != null) { @@ -710,6 +764,7 @@ public class MusicUtil { input.close(); } catch (IOException e) { e.printStackTrace(); + logger.error(EELFLoggerDelegate.errorLogger, e); } } } @@ -824,7 +879,7 @@ public class MusicUtil { MusicDataStoreHandle.getDSHandle().executePut(updateQuery, "critical"); } catch (MusicServiceException | MusicQueryException e) { logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.QUERYERROR +""+updateQuery , - ErrorSeverity.MAJOR, ErrorTypes.QUERYERROR); + ErrorSeverity.MAJOR, ErrorTypes.QUERYERROR, e); } }