From 14d46d99cb31f20da0bcfbdd559703cb97bf0baa Mon Sep 17 00:00:00 2001 From: "Tschaen, Brendan" Date: Wed, 7 Aug 2019 12:36:06 -0400 Subject: Configurable "write only locks" Issue-ID: MUSIC-466 Signed-off-by: Tschaen, Brendan Change-Id: I29c9e0fab3432d152824080ac197a57e0eaf0eff --- mdbc-server/src/main/java/org/onap/music/mdbc/Configuration.java | 4 ++++ mdbc-server/src/main/java/org/onap/music/mdbc/MDBCUtils.java | 5 +++++ mdbc-server/src/main/java/org/onap/music/mdbc/StateManager.java | 3 +++ mdbc-server/src/main/resources/mdbc.properties | 2 ++ 4 files changed, 14 insertions(+) diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/Configuration.java b/mdbc-server/src/main/java/org/onap/music/mdbc/Configuration.java index 91b13f3..efe4c21 100755 --- a/mdbc-server/src/main/java/org/onap/music/mdbc/Configuration.java +++ b/mdbc-server/src/main/java/org/onap/music/mdbc/Configuration.java @@ -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; } diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/MDBCUtils.java b/mdbc-server/src/main/java/org/onap/music/mdbc/MDBCUtils.java index b60062e..ee742f8 100755 --- a/mdbc-server/src/main/java/org/onap/music/mdbc/MDBCUtils.java +++ b/mdbc-server/src/main/java/org/onap/music/mdbc/MDBCUtils.java @@ -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> tableToQueryType) { + if (writeLocksOnly) { + return SQLOperationType.WRITE; + } + for (List tablesOps : tableToQueryType.values()) { for (org.onap.music.mdbc.query.SQLOperation op : tablesOps) { if (op.getOperationType() != SQLOperationType.READ) { diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/StateManager.java b/mdbc-server/src/main/java/org/onap/music/mdbc/StateManager.java index 8d42370..f8a18d9 100644 --- a/mdbc-server/src/main/java/org/onap/music/mdbc/StateManager.java +++ b/mdbc-server/src/main/java/org/onap/music/mdbc/StateManager.java @@ -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(); diff --git a/mdbc-server/src/main/resources/mdbc.properties b/mdbc-server/src/main/resources/mdbc.properties index 4d69da6..60adfae 100755 --- a/mdbc-server/src/main/resources/mdbc.properties +++ b/mdbc-server/src/main/resources/mdbc.properties @@ -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 -- cgit 1.2.3-korg