From d4430c99a0d11f37ff4ba845c6b563b2f8e836e9 Mon Sep 17 00:00:00 2001 From: "Tschaen, Brendan" Date: Mon, 28 Jan 2019 11:29:51 -0500 Subject: Remove dependency on random lock Change-Id: I9ffabe0e3da2d1fa1ed8ba40e216c2a989b07188 Issue-ID: MUSIC-278 Signed-off-by: Tschaen, Brendan --- pom.xml | 2 +- src/main/java/org/onap/music/prom/main/PromDaemon.java | 9 +++++---- .../java/org/onap/music/prom/musicinterface/MusicHandle.java | 2 +- src/test/java/org/onap/music/prom/main/PromDaemonTest.java | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index cc1f07b..7b4aeb2 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ stated inside of the file. org.onap.music.prom prom music-prom - 1.0.5 + 1.0.6 org.onap.oparent oparent diff --git a/src/main/java/org/onap/music/prom/main/PromDaemon.java b/src/main/java/org/onap/music/prom/main/PromDaemon.java index f39228b..cf9ab01 100644 --- a/src/main/java/org/onap/music/prom/main/PromDaemon.java +++ b/src/main/java/org/onap/music/prom/main/PromDaemon.java @@ -76,14 +76,15 @@ public class PromDaemon { MusicHandle.createIndexInTable(keyspaceName, tableName, "lockref"); Map values = new HashMap(); - values.put("id",this.id); + values.put("id","PROM_ADMIN"); // need dummy for lock values.put("isactive","false"); values.put("timeoflastupdate", "0"); - //values.put("lockref", ""); MusicHandle.insertIntoTableEventual(keyspaceName, tableName, values); - //MusicHandle.insertIntoTableEventual(keyspaceName, tableName, values); - lockName = keyspaceName+".active.lock"; + values.put("id",this.id); + MusicHandle.insertIntoTableEventual(keyspaceName, tableName, values); + + lockName = keyspaceName+".Replicas.PROM_ADMIN"; } /** diff --git a/src/main/java/org/onap/music/prom/musicinterface/MusicHandle.java b/src/main/java/org/onap/music/prom/musicinterface/MusicHandle.java index 83d148b..cc7a875 100644 --- a/src/main/java/org/onap/music/prom/musicinterface/MusicHandle.java +++ b/src/main/java/org/onap/music/prom/musicinterface/MusicHandle.java @@ -579,7 +579,7 @@ public class MusicHandle { ClientResponse response = addMusicHeaders(webResource).get(ClientResponse.class); - if (response.getStatus() != 200) { + if (response.getStatus() != 200 && response.getStatus() != 400) { logger.error(EELFLoggerDelegate.errorLogger, "Failed to acquireLock : Status Code "+response.getStatus()); throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } diff --git a/src/test/java/org/onap/music/prom/main/PromDaemonTest.java b/src/test/java/org/onap/music/prom/main/PromDaemonTest.java index be2d798..f8199b0 100644 --- a/src/test/java/org/onap/music/prom/main/PromDaemonTest.java +++ b/src/test/java/org/onap/music/prom/main/PromDaemonTest.java @@ -80,7 +80,7 @@ public class PromDaemonTest { Whitebox.invokeMethod(promDaemon, "bootStrap"); assertEquals("prom_testing", promDaemon.keyspaceName); - assertEquals("prom_testing.active.lock", promDaemon.lockName); + assertEquals("prom_testing.Replicas.PROM_ADMIN", promDaemon.lockName); } @Test -- cgit 1.2.3-korg