Configurable "write only locks" 26/92926/1
authorTschaen, Brendan <ctschaen@att.com>
Wed, 7 Aug 2019 16:36:06 +0000 (12:36 -0400)
committerTschaen, Brendan <ctschaen@att.com>
Wed, 7 Aug 2019 16:36:06 +0000 (12:36 -0400)
Issue-ID: MUSIC-466
Signed-off-by: Tschaen, Brendan <ctschaen@att.com>
Change-Id: I29c9e0fab3432d152824080ac197a57e0eaf0eff

mdbc-server/src/main/java/org/onap/music/mdbc/Configuration.java
mdbc-server/src/main/java/org/onap/music/mdbc/MDBCUtils.java
mdbc-server/src/main/java/org/onap/music/mdbc/StateManager.java
mdbc-server/src/main/resources/mdbc.properties

index 91b13f3..efe4c21 100755 (executable)
@@ -48,4 +48,8 @@ public class Configuration {
     public static final String KEY_WARMUPRANGES = "warmupranges";
        /** Default async staging table update o ption*/
        public static final String ASYNC_STAGING_TABLE_UPDATE = "false";
+       /** The property name to determine if only write locks are allowed */
+       public static final String KEY_WRITE_LOCKS_ONLY = "write_locks_only";
+       /** Default if only write locks are allowed */
+       public static final Boolean WRITE_LOCK_ONLY_DEFAULT = false;
 }
index b60062e..ee742f8 100755 (executable)
@@ -49,6 +49,7 @@ import org.apache.commons.lang3.tuple.Pair;
 import org.json.JSONObject;
 
 public class MDBCUtils {
+    public static boolean writeLocksOnly = false;
 
     public static void saveToFile(String serializedContent, String filename, EELFLoggerDelegate logger) throws IOException {
         try (PrintWriter fout = new PrintWriter(filename)) {
@@ -129,6 +130,10 @@ public class MDBCUtils {
      * @return write if any table has a write query. Read otherwise
      */
     public static SQLOperationType getOperationType(Map<String, List<SQLOperation>> tableToQueryType) {
+        if (writeLocksOnly) {
+            return SQLOperationType.WRITE;
+        }
+
         for (List<org.onap.music.mdbc.query.SQLOperation> tablesOps : tableToQueryType.values()) {
             for (org.onap.music.mdbc.query.SQLOperation op : tablesOps) {
                 if (op.getOperationType() != SQLOperationType.READ) {
index 8d42370..f8a18d9 100644 (file)
@@ -122,6 +122,9 @@ public class StateManager {
         cassandraUrl = info.getProperty(Configuration.KEY_CASSANDRA_URL, Configuration.CASSANDRA_URL_DEFAULT);
         musicmixin = info.getProperty(Configuration.KEY_MUSIC_MIXIN_NAME, Configuration.MUSIC_MIXIN_DEFAULT);
         
+        String writeLocksOnly = info.getProperty(Configuration.KEY_WRITE_LOCKS_ONLY);
+        MDBCUtils.writeLocksOnly = (writeLocksOnly==null) ? Configuration.WRITE_LOCK_ONLY_DEFAULT : Boolean.parseBoolean(writeLocksOnly);
+        
         initMusic();
         initSqlDatabase();
         initTxDaemonThread();
index 4d69da6..60adfae 100755 (executable)
@@ -18,5 +18,7 @@ DEFAULT_DRIVERS=\
 # whether or not to split the partitions
 partition_splitting=true
 
+write_locks_only=true
+
 #time, in seconds, between when the daemon catches up
 txdaemonsleeps=15
\ No newline at end of file