diff options
author | Mohammad Salehe <salehe@cs.toronto.edu> | 2019-02-08 11:33:35 -0500 |
---|---|---|
committer | Mohammad Salehe <salehe@cs.toronto.edu> | 2019-02-24 22:23:39 -0500 |
commit | 017a7bbadc5464bb49a481c0a903bc879e441ccf (patch) | |
tree | c4fded4c7d29ac7cf88ddc09de5950049830057d | |
parent | 764787d0e3a4682ac8345f925d83d002dc577386 (diff) |
Use executePut lock ordinal parameter
Use executePut lock ordinal instead of directly setting
timestamp in query string
Change-Id: Ide09e983f7a8cb363568c4123ebce57b9bb0c6d9
Issue-ID: MUSIC-148
Signed-off-by: Mohammad Salehe <salehe@cs.toronto.edu>
-rw-r--r-- | src/main/java/org/onap/music/service/impl/MusicCassaCore.java | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/main/java/org/onap/music/service/impl/MusicCassaCore.java b/src/main/java/org/onap/music/service/impl/MusicCassaCore.java index 824dc0c4..7eebf65a 100644 --- a/src/main/java/org/onap/music/service/impl/MusicCassaCore.java +++ b/src/main/java/org/onap/music/service/impl/MusicCassaCore.java @@ -89,7 +89,7 @@ public class MusicCassaCore implements MusicCoreService { mLockHandle = new CassaLockStore(MusicDataStoreHandle.getDSHandle()); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.LOCKHANDLE,ErrorSeverity.CRITICAL, ErrorTypes.LOCKINGERROR); - throw new MusicLockingException("Failed to aquire Locl store handle " + e); + throw new MusicLockingException("Failed to acquire Local store handle " + e); } } long end = System.currentTimeMillis(); @@ -116,11 +116,11 @@ public class MusicCassaCore implements MusicCoreService { try { lockReference = "" + getLockingServiceHandle().genLockRefandEnQueue(keyspace, table, lockName, isWriteLock); } catch (MusicLockingException | MusicServiceException | MusicQueryException e) { - logger.info(EELFLoggerDelegate.applicationLogger, "Failed to create lock reference"); + logger.info(EELFLoggerDelegate.applicationLogger, "Failed to create lock reference for" + lockName); return null; } long end = System.currentTimeMillis(); - logger.info(EELFLoggerDelegate.applicationLogger, "Time taken to create lock reference:" + (end - start) + " ms"); + logger.info(EELFLoggerDelegate.applicationLogger, "Time taken to create lock reference " + lockName + " " + lockReference + " :" + (end - start) + " ms"); return lockReference; } finally { @@ -487,7 +487,7 @@ public class MusicCassaCore implements MusicCoreService { */ public ReturnType criticalPut(String keyspace, String table, String primaryKeyValue, PreparedQueryObject queryObject, String lockReference, Condition conditionInfo) { - TimeMeasureInstance.instance().enter("executePut"); + TimeMeasureInstance.instance().enter("criticalPut"); try { long start = System.currentTimeMillis(); try { @@ -506,17 +506,17 @@ public class MusicCassaCore implements MusicCoreService { + e.getMessage()); } - String query = queryObject.getQuery(); long timeOfWrite = System.currentTimeMillis(); long lockOrdinal = Long.parseLong(lockReference); long ts = MusicUtil.v2sTimeStampInMicroseconds(lockOrdinal, timeOfWrite); // TODO: use Statement instead of modifying query - query = query.replaceFirst("SET", "USING TIMESTAMP " + ts + " SET"); - queryObject.replaceQueryString(query); +// String query = queryObject.getQuery(); +// query = query.replaceFirst("SET", "USING TIMESTAMP " + ts + " SET"); +// queryObject.replaceQueryString(query); MusicDataStore dsHandle = MusicDataStoreHandle.getDSHandle(); - dsHandle.executePut(queryObject, MusicUtil.CRITICAL); + dsHandle.executePut(queryObject, MusicUtil.CRITICAL, lockOrdinal); long end = System.currentTimeMillis(); - logger.info(EELFLoggerDelegate.applicationLogger, "Time taken for the critical put:" + (end - start) + " ms"); + logger.info(EELFLoggerDelegate.applicationLogger, "Time taken for the critical put " + primaryKeyValue + " " + lockReference + " :" + (end - start) + " ms"); } catch (MusicQueryException | MusicServiceException | MusicLockingException e) { logger.error(EELFLoggerDelegate.errorLogger, e.getMessage()); return new ReturnType(ResultType.FAILURE, @@ -664,7 +664,7 @@ public class MusicCassaCore implements MusicCoreService { // } logger.info(EELFLoggerDelegate.applicationLogger, - "acquired lock with id " + lockReference + " after " + acquireLockTries + " tries"); + "acquired lock with id " + primaryKey + " " + lockReference + " after " + acquireLockTries + " tries"); ReturnType criticalPutResult = criticalPut(keyspaceName, tableName, primaryKey, queryObject, lockReference, conditionInfo); long criticalPutTime = System.currentTimeMillis(); |