aboutsummaryrefslogtreecommitdiffstats
path: root/jar/src/main/java/org/onap/music/lockingservice/MusicLockingService.java
diff options
context:
space:
mode:
authorVikram Potturi(apotturi) <vp9004@att.com>2018-05-21 20:06:08 -0400
committerVikram Potturi(apotturi) <vp9004@att.com>2018-05-21 20:06:08 -0400
commitb1dc42528a3e7e89187fac220a2f9be3e4151caf (patch)
treebc5a9caddf25006107f60f824e40f82f8d89ff6d /jar/src/main/java/org/onap/music/lockingservice/MusicLockingService.java
parent067e18e954ffd6bbf90416e6922c06e5a43b49df (diff)
Added changes for Zookeeper node healthcheckv2.5.5release-2.5.3
Change-Id: Ib25342cebfc95a217dedc2588f2fb1284b1ef03f Issue-ID: MUSIC-73 Signed-off-by: Vikram Potturi(apotturi) <vp9004@att.com>
Diffstat (limited to 'jar/src/main/java/org/onap/music/lockingservice/MusicLockingService.java')
-rw-r--r--jar/src/main/java/org/onap/music/lockingservice/MusicLockingService.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/jar/src/main/java/org/onap/music/lockingservice/MusicLockingService.java b/jar/src/main/java/org/onap/music/lockingservice/MusicLockingService.java
index ae026903..29f23158 100644
--- a/jar/src/main/java/org/onap/music/lockingservice/MusicLockingService.java
+++ b/jar/src/main/java/org/onap/music/lockingservice/MusicLockingService.java
@@ -34,6 +34,7 @@ import org.onap.music.eelf.logging.format.ErrorTypes;
import org.onap.music.exceptions.MusicLockingException;
import org.onap.music.exceptions.MusicServiceException;
import org.onap.music.main.MusicUtil;
+import java.util.concurrent.TimeUnit;
public class MusicLockingService implements Watcher {
@@ -76,6 +77,23 @@ public class MusicLockingService implements Watcher {
logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.UNKNOWNERROR, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
}
}
+
+ public MusicLockingService(int timeout) throws MusicServiceException {
+ CountDownLatch connectedSignal1 = new CountDownLatch(1);
+ try {
+ ZooKeeper zk1 = new ZooKeeper(MusicUtil.getMyZkHost(), SESSION_TIMEOUT, this);
+ connectedSignal1.await(timeout, TimeUnit.SECONDS);
+ if(!zk1.getState().isConnected()) {
+ throw new MusicServiceException("Unable to Connect. Some nodes are down.");
+ }
+ } catch (IOException e ) {
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.IOERROR, ErrorSeverity.ERROR, ErrorTypes.CONNECTIONERROR);
+ throw new MusicServiceException("IO Error has occured" + e.getMessage());
+ } catch (InterruptedException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
+ throw new MusicServiceException("Exception Occured " + e.getMessage());
+ }
+ }
public void createLockaIfItDoesNotExist(String lockName) {
if (!zkLockHandle.checkIfLockExists(lockName)) {