From: Bharath Balasubramanian Date: Wed, 13 Feb 2019 13:47:17 +0000 (+0000) Subject: Merge "Sonar code duplicates moved to MusicUtil.java" X-Git-Tag: 2.5.8~28 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=3b8e0a333bb754117f41e7206a6706bad66829fb;p=music.git Merge "Sonar code duplicates moved to MusicUtil.java" --- 3b8e0a333bb754117f41e7206a6706bad66829fb diff --cc src/main/java/org/onap/music/service/impl/MusicCassaCore.java index 36d756bb,f351789e..21b4874b --- a/src/main/java/org/onap/music/service/impl/MusicCassaCore.java +++ b/src/main/java/org/onap/music/service/impl/MusicCassaCore.java @@@ -3,8 -3,9 +3,10 @@@ * org.onap.music * =================================================================== * Copyright (c) 2017 AT&T Intellectual Property + * Modifications Copyright (c) 2018 IBM. * =================================================================== + * Modifications Copyright (c) 2019 Samsung + * =================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@@ -166,20 -163,20 +164,20 @@@ public class MusicCassaCore implements String keyspace = splitString[0].substring(1);//remove '$' String table = splitString[1]; String primaryKeyValue = splitString[2].substring(0, splitString[2].lastIndexOf("$")); - fullyQualifiedKey = lockId.substring(1, lockId.lastIndexOf("$")); + String localFullyQualifiedKey = lockId.substring(1, lockId.lastIndexOf("$")); String lockRef = lockId.substring(lockId.lastIndexOf("$")+1); //lockRef is "$" to end - + ReturnType result = isTopOfLockStore(keyspace, table, primaryKeyValue, lockRef); - + if(result.getResult().equals(ResultType.FAILURE)) return result;//not top of the lock store q - + //check to see if the value of the key has to be synced in case there was a forceful release String syncTable = keyspace+".unsyncedKeys_"+table; - String query = "select * from "+syncTable+" where key='"+fullyQualifiedKey+"';"; + String query = "select * from "+syncTable+" where key='"+localFullyQualifiedKey+"';"; PreparedQueryObject readQueryObject = new PreparedQueryObject(); readQueryObject.appendQueryString(query); - ResultSet results = MusicDataStoreHandle.getDSHandle().executeQuorumConsistencyGet(readQueryObject); + ResultSet results = MusicDataStoreHandle.getDSHandle().executeQuorumConsistencyGet(readQueryObject); if (results.all().size() != 0) { logger.info("In acquire lock: Since there was a forcible release, need to sync quorum!"); try { @@@ -188,9 -185,9 +186,9 @@@ StringWriter sw = new StringWriter(); logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), "[ERR506E] Failed to aquire lock ",ErrorSeverity.CRITICAL, ErrorTypes.LOCKINGERROR); String exceptionAsString = sw.toString(); - return new ReturnType(ResultType.FAILURE, "Exception thrown while syncing key:\n" + exceptionAsString); + return new ReturnType(ResultType.FAILURE, "Exception thrown while syncing key:\n" + exceptionAsString); } - String cleanQuery = "delete from music_internal.unsynced_keys where key='"+fullyQualifiedKey+"';"; + String cleanQuery = "delete from music_internal.unsynced_keys where key='"+localFullyQualifiedKey+"';"; PreparedQueryObject deleteQueryObject = new PreparedQueryObject(); deleteQueryObject.appendQueryString(cleanQuery); MusicDataStoreHandle.getDSHandle().executePut(deleteQueryObject, "critical");