From: Thomas Nelson Date: Wed, 29 Jan 2020 19:48:03 +0000 (+0000) Subject: Merge "Further MusicCassaCore Testing" X-Git-Tag: 3.2.38~28 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=3e7717442eceb670bfa69ddb27c9abe68e99a920;hp=-c;p=music.git Merge "Further MusicCassaCore Testing" --- 3e7717442eceb670bfa69ddb27c9abe68e99a920 diff --combined music-core/src/main/java/org/onap/music/service/impl/MusicCassaCore.java index e1416f86,1f3f4a32..d29ba32b --- a/music-core/src/main/java/org/onap/music/service/impl/MusicCassaCore.java +++ b/music-core/src/main/java/org/onap/music/service/impl/MusicCassaCore.java @@@ -27,13 -27,12 +27,13 @@@ package org.onap.music.service.impl import java.io.StringWriter; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; - +import java.util.concurrent.atomic.AtomicInteger; import javax.ws.rs.core.MultivaluedMap; import org.onap.music.datastore.Condition; @@@ -76,9 -75,7 +76,9 @@@ public class MusicCassaCore implements private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicCassaCore.class); private static MusicCassaCore musicCassaCoreInstance = null; private static Set set = Collections.synchronizedSet(new HashSet()); - + HashMap map = new HashMap<>(); + AtomicInteger wait = new AtomicInteger(0); + private MusicCassaCore() { // not going to happen } @@@ -87,7 -84,8 +87,8 @@@ return mLockHandle; } - public static void setmLockHandle(CassaLockStore mLockHandle) { + //for unit testing purposes + static void setmLockHandle(CassaLockStore mLockHandle) { MusicCassaCore.mLockHandle = mLockHandle; } @@@ -122,11 -120,10 +123,11 @@@ public String createLockReference(String fullyQualifiedKey, String owner) throws MusicLockingException { return createLockReference(fullyQualifiedKey, LockType.WRITE, owner); } - + + /** * This will be called for Atomic calls - * + * it ensures that only one thread tries to create a lock on each key at a time */ public String createLockReferenceAtomic(String fullyQualifiedKey, LockType locktype) throws MusicLockingException { String[] splitString = fullyQualifiedKey.split("\\."); @@@ -352,7 -349,6 +353,6 @@@ * @return Boolean Indicates success or failure * @throws MusicServiceException * - * */ public ResultType createTable(String keyspace, String table, PreparedQueryObject tableQueryObject, String consistency) throws MusicServiceException { @@@ -361,9 -357,9 +361,9 @@@ try { // create shadow locking table result = getLockingServiceHandle().createLockQueue(keyspace, table); - if (result == false) + if (result == false) { return ResultType.FAILURE; - + } result = false; // create table to track unsynced_keys @@@ -374,8 -370,11 +374,11 @@@ PreparedQueryObject queryObject = new PreparedQueryObject(); queryObject.appendQueryString(tabQuery); - result = false; result = MusicDataStoreHandle.getDSHandle().executePut(queryObject, "eventual"); + if (result == false) { + return ResultType.FAILURE; + } + result = false; // create actual table result = MusicDataStoreHandle.getDSHandle().executePut(tableQueryObject, consistency);