From cbdf44bf0a8e2a4f06c72a126a63ed2c59e1ba32 Mon Sep 17 00:00:00 2001 From: Enrique Saurez Date: Fri, 26 Oct 2018 12:34:16 -0400 Subject: Change code structure to match pseudocode Issue-ID: MUSIC-149 Change-Id: Icc8967636192132133066f836614f7bee2ba6265 Signed-off-by: Enrique Saurez --- .../java/com/att/research/mdbc/ArchiveProcess.java | 11 +- .../com/att/research/mdbc/DatabaseOperations.java | 126 ++++++++++----------- .../com/att/research/mdbc/DatabasePartition.java | 51 ++++----- .../com/att/research/mdbc/MusicSqlManager.java | 21 +++- .../java/com/att/research/mdbc/StateManager.java | 22 ++-- .../mdbc/configurations/NodeConfiguration.java | 4 +- .../mdbc/configurations/TablesConfiguration.java | 43 ++++--- .../att/research/mdbc/configurations/ranges.json | 4 +- .../mdbc/configurations/tableConfiguration.json | 4 +- .../att/research/mdbc/mixins/CassandraMixin.java | 41 ++++--- .../att/research/mdbc/mixins/MusicInterface.java | 2 +- .../com/att/research/mdbc/mixins/MusicMixin.java | 2 +- .../att/research/mdbc/tools/CreatePartition.java | 27 ++--- 13 files changed, 180 insertions(+), 178 deletions(-) (limited to 'src') diff --git a/src/main/java/com/att/research/mdbc/ArchiveProcess.java b/src/main/java/com/att/research/mdbc/ArchiveProcess.java index f192430..8290d66 100644 --- a/src/main/java/com/att/research/mdbc/ArchiveProcess.java +++ b/src/main/java/com/att/research/mdbc/ArchiveProcess.java @@ -12,10 +12,9 @@ public class ArchiveProcess { //TODO: This is a place holder for taking snapshots and moving data from redo record into actual tables /** - * This method is called whenever there is a DELETE on a local SQL table, and should be called by the underlying databases - * triggering mechanism. It updates the MUSIC/Cassandra tables (both dirty bits and actual data) corresponding to the SQL DELETE. - * Music propagates it to the other replicas. If the local database is in the middle of a transaction, the DELETEs to MUSIC are - * delayed until the transaction is either committed or rolled back. + * This method is called whenever there is a DELETE on the transaction digest and should be called when ownership changes, if required + * It updates the MUSIC/Cassandra tables (both dirty bits and actual data) corresponding to the SQL DELETE. + * Music propagates it to the other replicas. * @param tableName This is the table on which the select is being performed * @param oldRow This is information about the row that is being deleted */ @@ -26,8 +25,8 @@ public class ArchiveProcess { } /** - * This method is called whenever there is an INSERT or UPDATE to a local SQL table, and should be called by the underlying databases - * triggering mechanism. It updates the MUSIC/Cassandra tables (both dirty bits and actual data) corresponding to the SQL write. + * This method is called whenever there is an INSERT or UPDATE to a the transaction digest, and should be called by an + * ownership chance. It updates the MUSIC/Cassandra tables (both dirty bits and actual data) corresponding to the SQL write. * Music propagates it to the other replicas. If the local database is in the middle of a transaction, the updates to MUSIC are * delayed until the transaction is either committed or rolled back. * diff --git a/src/main/java/com/att/research/mdbc/DatabaseOperations.java b/src/main/java/com/att/research/mdbc/DatabaseOperations.java index 750e918..c896b84 100644 --- a/src/main/java/com/att/research/mdbc/DatabaseOperations.java +++ b/src/main/java/com/att/research/mdbc/DatabaseOperations.java @@ -272,69 +272,6 @@ public class DatabaseOperations { return id; } - /** - * This function creates the TransactionInformation table. It contain information related - * to the transactions happening in a given partition. - * * The schema of the table is - * * Id, uiid. - * * Partition, uuid id of the partition - * * LatestApplied, int indicates which values from the redologtable wast the last to be applied to the data tables - * * Applied: boolean, indicates if all the values in this redo log table where already applied to data tables - * * Redo: list of uiids associated to the Redo Records Table - * - */ - public static void CreateTransactionInformationTable( String musicNamespace, - String transactionInformationTableName) throws MDBCServiceException { - String tableName = transactionInformationTableName; - String priKey = "id"; - StringBuilder fields = new StringBuilder(); - fields.append("id uuid, "); - fields.append("partition uuid, "); - fields.append("latestapplied int, "); - fields.append("applied boolean, "); - //TODO: Frozen is only needed for old versions of cassandra, please update correspondingly - fields.append("redo list>>> "); - String cql = String.format("CREATE TABLE IF NOT EXISTS %s.%s (%s, PRIMARY KEY (%s));", - musicNamespace, tableName, fields, priKey); - try { - executeMusicWriteQuery(musicNamespace,tableName,cql); - } catch (MDBCServiceException e) { - logger.error("Initialization error: Failure to create transaction information table"); - throw(e); - } - } - - /** - * This function creates the RedoRecords table. It contain information related to each transaction committed - * * LeaseId: id associated with the lease, text - * * LeaseCounter: transaction number under this lease, bigint \TODO this may need to be a varint later - * * TransactionDigest: text that contains all the changes in the transaction - */ - public static void CreateRedoRecordsTable(int redoTableNumber, String musicNamespace, - String redoRecordTableName) throws MDBCServiceException { - String tableName = redoRecordTableName; - if(redoTableNumber >= 0) { - StringBuilder table = new StringBuilder(); - table.append(tableName); - table.append("-"); - table.append(Integer.toString(redoTableNumber)); - tableName=table.toString(); - } - String priKey = "leaseid,leasecounter"; - StringBuilder fields = new StringBuilder(); - fields.append("leaseid text, "); - fields.append("leasecounter varint, "); - fields.append("transactiondigest text ");//notice lack of ',' - String cql = String.format("CREATE TABLE IF NOT EXISTS %s.%s (%s, PRIMARY KEY (%s));", - musicNamespace, tableName, fields, priKey); - try { - executeMusicWriteQuery(musicNamespace,tableName,cql); - } catch (MDBCServiceException e) { - logger.error("Initialization error: Failure to create redo records table"); - throw(e); - } - } - /** * This function creates the Table To Partition table. It contain information related to */ @@ -462,4 +399,67 @@ public class DatabaseOperations { } } } + + + /** + * This function creates the MusicTxDigest table. It contain information related to each transaction committed + * * LeaseId: id associated with the lease, text + * * LeaseCounter: transaction number under this lease, bigint \TODO this may need to be a varint later + * * TransactionDigest: text that contains all the changes in the transaction + */ + public static void CreateMusicTxDigest(int musicTxDigestTableNumber, String musicNamespace, String musicTxDigestTableName) throws MDBCServiceException { + String tableName = musicTxDigestTableName; + if(musicTxDigestTableNumber >= 0) { + StringBuilder table = new StringBuilder(); + table.append(tableName); + table.append("-"); + table.append(Integer.toString(musicTxDigestTableNumber)); + tableName=table.toString(); + } + String priKey = "leaseid,leasecounter"; + StringBuilder fields = new StringBuilder(); + fields.append("leaseid text, "); + fields.append("leasecounter varint, "); + fields.append("transactiondigest text ");//notice lack of ',' + String cql = String.format("CREATE TABLE IF NOT EXISTS %s.%s (%s, PRIMARY KEY (%s));", musicNamespace, tableName, fields, priKey); + try { + executeMusicWriteQuery(musicNamespace,tableName,cql); + } catch (MDBCServiceException e) { + logger.error("Initialization error: Failure to create redo records table"); + throw(e); + } + } + + /** + * This function creates the TransactionInformation table. It contain information related + * to the transactions happening in a given partition. + * * The schema of the table is + * * Id, uiid. + * * Partition, uuid id of the partition + * * LatestApplied, int indicates which values from the redologtable wast the last to be applied to the data tables + * * Applied: boolean, indicates if all the values in this redo log table where already applied to data tables + * * Redo: list of uiids associated to the Redo Records Table + * + */ + public static void CreateMusicRangeInformationTable(String musicNamespace, String musicRangeInformationTableName) throws MDBCServiceException { + String tableName = musicRangeInformationTableName; + String priKey = "id"; + StringBuilder fields = new StringBuilder(); + fields.append("id uuid, "); + fields.append("partition uuid, "); + fields.append("latestapplied int, "); + fields.append("applied boolean, "); + //TODO: Frozen is only needed for old versions of cassandra, please update correspondingly + fields.append("redo list>>> "); + String cql = String.format("CREATE TABLE IF NOT EXISTS %s.%s (%s, PRIMARY KEY (%s));", musicNamespace, tableName, fields, priKey); + try { + executeMusicWriteQuery(musicNamespace,tableName,cql); + } catch (MDBCServiceException e) { + logger.error("Initialization error: Failure to create transaction information table"); + throw(e); + } + } + + + } diff --git a/src/main/java/com/att/research/mdbc/DatabasePartition.java b/src/main/java/com/att/research/mdbc/DatabasePartition.java index 6046801..a9b4f3e 100644 --- a/src/main/java/com/att/research/mdbc/DatabasePartition.java +++ b/src/main/java/com/att/research/mdbc/DatabasePartition.java @@ -7,7 +7,6 @@ import java.util.HashSet; import java.util.Set; import com.att.research.logging.EELFLoggerDelegate; -import com.att.research.mdbc.mixins.CassandraMixin; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -19,9 +18,9 @@ import com.google.gson.GsonBuilder; public class DatabasePartition { private transient static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(DatabasePartition.class); - private String transactionInformationTable;//Table that currently contains the REDO log for this partition - private String transactionInformationIndex;//Index that can be obtained either from - private String redoRecordsTable; + private String musicRangeInformationTable;//Table that currently contains the REDO log for this partition + private String musicRangeInformationIndex;//Index that can be obtained either from + private String musicTxDigestTable; private String partitionId; private String lockId; protected Set ranges; @@ -35,7 +34,7 @@ public class DatabasePartition { ranges = new HashSet<>(); } - public DatabasePartition(Set knownRanges, String titIndex, String titTable, String partitionId, String lockId, String redoRecordsTable) { + public DatabasePartition(Set knownRanges, String mriIndex, String mriTable, String partitionId, String lockId, String musicTxDigestTable) { if(knownRanges != null) { ranges = knownRanges; } @@ -43,25 +42,25 @@ public class DatabasePartition { ranges = new HashSet<>(); } - if(redoRecordsTable != null) { - this.setRedoRecordsTable(redoRecordsTable); + if(musicTxDigestTable != null) { + this.setMusicTxDigestTable(musicTxDigestTable); } else{ - this.setRedoRecordsTable(""); + this.setMusicTxDigestTable(""); } - if(titIndex != null) { - this.setTransactionInformationIndex(titIndex); + if(mriIndex != null) { + this.setMusicRangeInformationIndex(mriIndex); } else { - this.setTransactionInformationIndex(""); + this.setMusicRangeInformationIndex(""); } - if(titTable != null) { - this.setTransactionInformationTable(titTable); + if(mriTable != null) { + this.setMusicRangeInformationTable(mriTable); } else { - this.setTransactionInformationTable(""); + this.setMusicRangeInformationTable(""); } if(partitionId != null) { @@ -79,20 +78,20 @@ public class DatabasePartition { } } - public String getTransactionInformationTable() { - return transactionInformationTable; + public String getMusicRangeInformationTable() { + return musicRangeInformationTable; } - public void setTransactionInformationTable(String transactionInformationTable) { - this.transactionInformationTable = transactionInformationTable; + public void setMusicRangeInformationTable(String musicRangeInformationTable) { + this.musicRangeInformationTable = musicRangeInformationTable; } - public String getTransactionInformationIndex() { - return transactionInformationIndex; + public String getMusicRangeInformationIndex() { + return musicRangeInformationIndex; } - public void setTransactionInformationIndex(String transactionInformationIndex) { - this.transactionInformationIndex = transactionInformationIndex; + public void setMusicRangeInformationIndex(String musicRangeInformationIndex) { + this.musicRangeInformationIndex = musicRangeInformationIndex; } /** @@ -180,11 +179,11 @@ public class DatabasePartition { this.lockId = lockId; } - public String getRedoRecordsTable() { - return redoRecordsTable; + public String getMusicTxDigestTable() { + return musicTxDigestTable; } - public void setRedoRecordsTable(String redoRecordsTable) { - this.redoRecordsTable = redoRecordsTable; + public void setMusicTxDigestTable(String musicTxDigestTable) { + this.musicTxDigestTable = musicTxDigestTable; } } diff --git a/src/main/java/com/att/research/mdbc/MusicSqlManager.java b/src/main/java/com/att/research/mdbc/MusicSqlManager.java index 1d7bf9e..f73bdb6 100755 --- a/src/main/java/com/att/research/mdbc/MusicSqlManager.java +++ b/src/main/java/com/att/research/mdbc/MusicSqlManager.java @@ -1,12 +1,7 @@ package com.att.research.mdbc; import java.sql.Connection; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Properties; -import java.util.Set; +import java.util.*; import org.json.JSONObject; @@ -296,4 +291,18 @@ public class MusicSqlManager { */ return musicKeys; } + + public void own(List ranges) { + throw new java.lang.UnsupportedOperationException("function not implemented yet"); + } + + public void appendRange(String rangeId, List ranges) { + throw new java.lang.UnsupportedOperationException("function not implemented yet"); + } + + public void relinquish(String ownerId, String rangeId) { + throw new java.lang.UnsupportedOperationException("function not implemented yet"); + } + + } diff --git a/src/main/java/com/att/research/mdbc/StateManager.java b/src/main/java/com/att/research/mdbc/StateManager.java index 1656f4b..0a4a409 100644 --- a/src/main/java/com/att/research/mdbc/StateManager.java +++ b/src/main/java/com/att/research/mdbc/StateManager.java @@ -53,18 +53,22 @@ public class StateManager { private DatabasePartition ranges; public StateManager(String url, Properties info, DatabasePartition ranges, String sqlDatabase) throws MDBCServiceException { - this.sqlDatabase=sqlDatabase; - this.ranges=ranges; - this.url = url; - this.info = info; - this.transactionInfo = new TxCommitProgress(); - //\fixme this is not really used, delete! - String cassandraUrl = info.getProperty(Configuration.KEY_CASSANDRA_URL, Configuration.CASSANDRA_URL_DEFAULT); - String mixin = info.getProperty(Configuration.KEY_MUSIC_MIXIN_NAME, Configuration.MUSIC_MIXIN_DEFAULT); + this.sqlDatabase = sqlDatabase; + this.ranges = ranges; + this.url = url; + this.info = info; + this.transactionInfo = new TxCommitProgress(); + //\fixme this is not really used, delete! + String cassandraUrl = info.getProperty(Configuration.KEY_CASSANDRA_URL, Configuration.CASSANDRA_URL_DEFAULT); + String mixin = info.getProperty(Configuration.KEY_MUSIC_MIXIN_NAME, Configuration.MUSIC_MIXIN_DEFAULT); + init(mixin, cassandraUrl); + } + + protected void init(String mixin, String cassandraUrl) throws MDBCServiceException { this.musicManager = MixinFactory.createMusicInterface(mixin, cassandraUrl, info,ranges); this.musicManager.createKeyspace(); try { - this.musicManager.initializeMdbcDataStructures(); + this.musicManager.initializeMetricDataStructures(); } catch (MDBCServiceException e) { logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.UNKNOWNERROR, ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR); throw(e); diff --git a/src/main/java/com/att/research/mdbc/configurations/NodeConfiguration.java b/src/main/java/com/att/research/mdbc/configurations/NodeConfiguration.java index 78850e3..d74dafb 100644 --- a/src/main/java/com/att/research/mdbc/configurations/NodeConfiguration.java +++ b/src/main/java/com/att/research/mdbc/configurations/NodeConfiguration.java @@ -22,8 +22,8 @@ public class NodeConfiguration { public DatabasePartition partition; public String nodeName; - public NodeConfiguration(String tables, String titIndex, String titTableName, String partitionId, String sqlDatabaseName, String node, String redoRecordsTable){ - partition = new DatabasePartition(toRanges(tables), titIndex, titTableName, partitionId, null, redoRecordsTable) ; + public NodeConfiguration(String tables, String mriIndex, String mriTableName, String partitionId, String sqlDatabaseName, String node, String redoRecordsTable){ + partition = new DatabasePartition(toRanges(tables), mriIndex, mriTableName, partitionId, null, redoRecordsTable) ; this.sqlDatabaseName = sqlDatabaseName; this.nodeName = node; } diff --git a/src/main/java/com/att/research/mdbc/configurations/TablesConfiguration.java b/src/main/java/com/att/research/mdbc/configurations/TablesConfiguration.java index 664520f..b86d058 100644 --- a/src/main/java/com/att/research/mdbc/configurations/TablesConfiguration.java +++ b/src/main/java/com/att/research/mdbc/configurations/TablesConfiguration.java @@ -19,7 +19,7 @@ import java.util.List; public class TablesConfiguration { private final String TIT_TABLE_NAME = "transactioninformation"; - private final String REDO_RECORDS_NAME = "redorecords"; + private final String MUSIC_TX_DIGEST_TABLE_NAME = "musictxdigest"; private transient static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(TablesConfiguration.class); private List partitions; @@ -54,14 +54,13 @@ public class TablesConfiguration { throw new MDBCServiceException("Partition was not correctly initialized"); } for(PartitionInformation partitionInfo : partitions){ - String titTableName = partitionInfo.titTableName; - titTableName = (titTableName==null || titTableName.isEmpty())?TIT_TABLE_NAME:titTableName; - //0) Create the corresponding TIT table - DatabaseOperations.CreateTransactionInformationTable(musicNamespace,titTableName); - String redoRecordsName = partitionInfo.rrtTableName; - redoRecordsName = (redoRecordsName==null || redoRecordsName.isEmpty())?REDO_RECORDS_NAME:redoRecordsName; - DatabaseOperations.CreateRedoRecordsTable(-1,musicNamespace,redoRecordsName); - //0) Create the corresponding TIT table + String mriTableName = partitionInfo.mriTableName; + mriTableName = (mriTableName==null || mriTableName.isEmpty())?TIT_TABLE_NAME:mriTableName; + //0) Create the corresponding Music Range Information table + DatabaseOperations.CreateMusicRangeInformationTable(musicNamespace,mriTableName); + String musicTxDigestTableName = partitionInfo.mtxdTableName; + musicTxDigestTableName = (musicTxDigestTableName==null || musicTxDigestTableName.isEmpty())? MUSIC_TX_DIGEST_TABLE_NAME :musicTxDigestTableName; + DatabaseOperations.CreateMusicTxDigest(-1,musicNamespace,musicTxDigestTableName); String partitionId; if(partitionInfo.partitionId==null || partitionInfo.partitionId.isEmpty()){ if(partitionInfo.replicationFactor==0){ @@ -76,9 +75,9 @@ public class TablesConfiguration { partitionId = partitionInfo.partitionId; } //2) Create a row in the transaction information table - String titIndex = DatabaseOperations.CreateEmptyTitRow(musicNamespace,titTableName,partitionId,null); + String mriTableIndex = DatabaseOperations.CreateEmptyTitRow(musicNamespace,mriTableName,partitionId,null); //3) Add owner and tit information to partition info table - RedoRow newRedoRow = new RedoRow(titTableName,titIndex); + RedoRow newRedoRow = new RedoRow(mriTableName,mriTableIndex); DatabaseOperations.updateRedoRow(musicNamespace,pitName,partitionId,newRedoRow,partitionInfo.owner,null); //4) Update ttp with the new partition for(String table: partitionInfo.tables) { @@ -87,7 +86,7 @@ public class TablesConfiguration { //5) Add it to the redo history table DatabaseOperations.createRedoHistoryBeginRow(musicNamespace,rhName,newRedoRow,partitionId,null); //6) Create config for this node - nodeConfigs.add(new NodeConfiguration(String.join(",",partitionInfo.tables),titIndex,titTableName,partitionId,sqlDatabaseName,partitionInfo.owner,redoRecordsName)); + nodeConfigs.add(new NodeConfiguration(String.join(",",partitionInfo.tables),mriTableIndex,mriTableName,partitionId,sqlDatabaseName,partitionInfo.owner,musicTxDigestTableName)); } return nodeConfigs; } @@ -124,8 +123,8 @@ public class TablesConfiguration { public class PartitionInformation{ private List tables; private String owner; - private String titTableName; - private String rrtTableName; + private String mriTableName; + private String mtxdTableName; private String partitionId; private int replicationFactor; @@ -145,12 +144,12 @@ public class TablesConfiguration { this.owner = owner; } - public String getTitTableName() { - return titTableName; + public String getMriTableName() { + return mriTableName; } - public void setTitTableName(String titTableName) { - this.titTableName = titTableName; + public void setMriTableName(String mriTableName) { + this.mriTableName = mriTableName; } public String getPartitionId() { @@ -169,12 +168,12 @@ public class TablesConfiguration { this.replicationFactor = replicationFactor; } - public String getRrtTableName(){ - return rrtTableName; + public String getMtxdTableName(){ + return mtxdTableName; } - public void setRrtTableName(String rrtTableName) { - this.rrtTableName = rrtTableName; + public void setMtxdTableName(String mtxdTableName) { + this.mtxdTableName = mtxdTableName; } } } diff --git a/src/main/java/com/att/research/mdbc/configurations/ranges.json b/src/main/java/com/att/research/mdbc/configurations/ranges.json index afa343b..2a792e8 100644 --- a/src/main/java/com/att/research/mdbc/configurations/ranges.json +++ b/src/main/java/com/att/research/mdbc/configurations/ranges.json @@ -1,6 +1,6 @@ { - "transactionInformationTable": "transactioninformation", - "transactionInformationIndex": "d0e8ef2e-aeca-4261-8d9d-1679f560b85b", + "musicRangeInformationTable": "transactioninformation", + "musicRangeInformationIndex": "d0e8ef2e-aeca-4261-8d9d-1679f560b85b", "partitionId": "798110cf-9c61-4db2-9446-cb2dbab5a143", "lockId": "", "ranges": [ diff --git a/src/main/java/com/att/research/mdbc/configurations/tableConfiguration.json b/src/main/java/com/att/research/mdbc/configurations/tableConfiguration.json index b3c6224..e67dd0b 100644 --- a/src/main/java/com/att/research/mdbc/configurations/tableConfiguration.json +++ b/src/main/java/com/att/research/mdbc/configurations/tableConfiguration.json @@ -3,8 +3,8 @@ { "tables":["table11"], "owner":"", - "titTableName":"transactioninformation", - "rrtTableName":"redorecords", + "mriTableName":"musicrangeinformation", + "mtxdTableName":"musictxdigest", "partitionId":"", "replicationFactor":1 } diff --git a/src/main/java/com/att/research/mdbc/mixins/CassandraMixin.java b/src/main/java/com/att/research/mdbc/mixins/CassandraMixin.java index 033179a..5293682 100755 --- a/src/main/java/com/att/research/mdbc/mixins/CassandraMixin.java +++ b/src/main/java/com/att/research/mdbc/mixins/CassandraMixin.java @@ -27,7 +27,6 @@ import com.att.research.mdbc.tables.TxCommitProgress; import org.json.JSONObject; import org.onap.music.datastore.CassaLockStore; -import org.onap.music.datastore.CassaLockStore.LockObject; import org.onap.music.datastore.PreparedQueryObject; import org.onap.music.exceptions.MusicLockingException; import org.onap.music.exceptions.MusicQueryException; @@ -94,8 +93,8 @@ public class CassandraMixin implements MusicInterface { public static final String PARTITION_INFORMATION_TABLE_NAME = "partitioninfo"; public static final String REDO_HISTORY_TABLE_NAME= "redohistory"; //\TODO Add logic to change the names when required and create the tables when necessary - private String redoRecordTableName = "redorecords"; - private String transactionInformationTableName = "transactioninformation"; + private String musicTxDigestTableName = "musictxdigest"; + private String musicRangeInformationTableName = "musicrangeinformation"; private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(CassandraMixin.class); @@ -162,7 +161,7 @@ public class CassandraMixin implements MusicInterface { this.music_ns = info.getProperty(KEY_MUSIC_NAMESPACE,DEFAULT_MUSIC_NAMESPACE); logger.info(EELFLoggerDelegate.applicationLogger,"MusicSqlManager: music_ns="+music_ns); - transactionInformationTableName = "transactioninformation"; + musicRangeInformationTableName = "musicrangeinformation"; createMusicKeyspace(); } @@ -221,10 +220,10 @@ public class CassandraMixin implements MusicInterface { } } @Override - public void initializeMdbcDataStructures() throws MDBCServiceException { + public void initializeMetricDataStructures() throws MDBCServiceException { try { - DatabaseOperations.CreateRedoRecordsTable(-1, music_ns, redoRecordTableName);//\TODO If we start partitioning the data base, we would need to use the redotable number - DatabaseOperations.CreateTransactionInformationTable(music_ns, transactionInformationTableName); + DatabaseOperations.CreateMusicTxDigest(-1, music_ns, musicTxDigestTableName);//\TODO If we start partitioning the data base, we would need to use the redotable number + DatabaseOperations.CreateMusicRangeInformationTable(music_ns, musicRangeInformationTableName); DatabaseOperations.CreateTableToPartitionTable(music_ns, TABLE_TO_PARTITION_TABLE_NAME); DatabaseOperations.CreatePartitionInfoTable(music_ns, PARTITION_INFORMATION_TABLE_NAME); DatabaseOperations.CreateRedoHistoryTable(music_ns, REDO_HISTORY_TABLE_NAME); @@ -1026,7 +1025,7 @@ public class CassandraMixin implements MusicInterface { } - private PreparedQueryObject createAppendRRTIndexToTitQuery(String titTable, String uuid, String table, String redoUuid){ + private PreparedQueryObject createAppendMtxdIndexToMriQuery(String titTable, String uuid, String table, String redoUuid){ PreparedQueryObject query = new PreparedQueryObject(); StringBuilder appendBuilder = new StringBuilder(); appendBuilder.append("UPDATE ") @@ -1065,7 +1064,7 @@ public class CassandraMixin implements MusicInterface { try { MusicCore.forciblyReleaseLock(fullyQualifiedKey,lockId); CassaLockStore lockingServiceHandle = MusicCore.getLockingServiceHandle(); - LockObject lockOwner = lockingServiceHandle.peekLockQueue(keyspace, table, key); + CassaLockStore.LockObject lockOwner = lockingServiceHandle.peekLockQueue(keyspace, table, key); while(lockOwner.lockRef != lockId) { MusicCore.forciblyReleaseLock(fullyQualifiedKey, lockOwner.lockRef); try { @@ -1096,12 +1095,12 @@ public class CassandraMixin implements MusicInterface { return lockId; } - protected void pushRowToRRT(String lockId, String commitId, HashMap transactionDigest) throws MDBCServiceException{ + protected void pushRowToMtxd(String lockId, String commitId, HashMap transactionDigest) throws MDBCServiceException{ PreparedQueryObject query = new PreparedQueryObject(); StringBuilder cqlQuery = new StringBuilder("INSERT INTO ") .append(music_ns) .append('.') - .append(redoRecordTableName) + .append(musicTxDigestTableName) .append(" (leaseid,leasecounter,transactiondigest) ") .append("VALUES ('") .append( lockId ).append("',") @@ -1123,15 +1122,15 @@ public class CassandraMixin implements MusicInterface { } } - protected void appendIndexToTit(String lockId, String commitId, String TITIndex) throws MDBCServiceException{ + protected void appendIndexToMri(String lockId, String commitId, String MriIndex) throws MDBCServiceException{ StringBuilder redoUuidBuilder = new StringBuilder(); redoUuidBuilder.append("('") .append(lockId) .append("',") .append(commitId) .append(")"); - PreparedQueryObject appendQuery = createAppendRRTIndexToTitQuery(transactionInformationTableName, TITIndex, redoRecordTableName, redoUuidBuilder.toString()); - ReturnType returnType = MusicCore.criticalPut(music_ns, transactionInformationTableName, TITIndex, appendQuery, lockId, null); + PreparedQueryObject appendQuery = createAppendMtxdIndexToMriQuery(musicRangeInformationTableName, MriIndex, musicTxDigestTableName, redoUuidBuilder.toString()); + ReturnType returnType = MusicCore.criticalPut(music_ns, musicRangeInformationTableName, MriIndex, appendQuery, lockId, null); if(returnType.getResult().compareTo(ResultType.SUCCESS) != 0 ){ logger.error(EELFLoggerDelegate.errorLogger, "Error when executing append operation with return type: "+returnType.getMessage()); throw new MDBCServiceException("Error when executing append operation with return type: "+returnType.getMessage()); @@ -1140,16 +1139,16 @@ public class CassandraMixin implements MusicInterface { @Override public void commitLog(DBInterface dbi, DatabasePartition partition, HashMap transactionDigest, String txId ,TxCommitProgress progressKeeper) throws MDBCServiceException{ - String TITIndex = partition.getTransactionInformationIndex(); - if(TITIndex.isEmpty()) { - //\TODO Fetch TITIndex from the Range Information Table + String MriIndex = partition.getMusicRangeInformationIndex(); + if(MriIndex.isEmpty()) { + //\TODO Fetch MriIndex from the Range Information Table throw new MDBCServiceException("TIT Index retrieval not yet implemented"); } - String fullyQualifiedTitKey = music_ns+"."+ transactionInformationTableName +"."+TITIndex; + String fullyQualifiedTitKey = music_ns+"."+ musicRangeInformationTableName +"."+MriIndex; //0. See if reference to lock was already created String lockId = partition.getLockId(); if(lockId == null || lockId.isEmpty()) { - lockId = createAndAssignLock(fullyQualifiedTitKey,partition,music_ns,transactionInformationTableName,TITIndex); + lockId = createAndAssignLock(fullyQualifiedTitKey,partition,music_ns, musicRangeInformationTableName,MriIndex); } String commitId; @@ -1164,14 +1163,14 @@ public class CassandraMixin implements MusicInterface { //Add creation type of transaction digest //1. Push new row to RRT and obtain its index - pushRowToRRT(lockId, commitId, transactionDigest); + pushRowToMtxd(lockId, commitId, transactionDigest); //2. Save RRT index to RQ if(progressKeeper!= null) { progressKeeper.setRecordId(txId,new RedoRecordId(lockId, commitId)); } //3. Append RRT index into the corresponding TIT row array - appendIndexToTit(lockId,commitId,TITIndex); + appendIndexToMri(lockId,commitId,MriIndex); } /** diff --git a/src/main/java/com/att/research/mdbc/mixins/MusicInterface.java b/src/main/java/com/att/research/mdbc/mixins/MusicInterface.java index 9051ab6..6e2e0ca 100755 --- a/src/main/java/com/att/research/mdbc/mixins/MusicInterface.java +++ b/src/main/java/com/att/research/mdbc/mixins/MusicInterface.java @@ -31,7 +31,7 @@ public interface MusicInterface { * This function is used to created all the required data structures, both local * \TODO Check if this function is required in the MUSIC interface or could be just created on the constructor */ - void initializeMdbcDataStructures() throws MDBCServiceException; + void initializeMetricDataStructures() throws MDBCServiceException; /** * Get the name of this MusicInterface mixin object. * @return the name diff --git a/src/main/java/com/att/research/mdbc/mixins/MusicMixin.java b/src/main/java/com/att/research/mdbc/mixins/MusicMixin.java index bf865b2..43f36e3 100644 --- a/src/main/java/com/att/research/mdbc/mixins/MusicMixin.java +++ b/src/main/java/com/att/research/mdbc/mixins/MusicMixin.java @@ -181,7 +181,7 @@ public class MusicMixin implements MusicInterface { } @Override - public void initializeMdbcDataStructures() { + public void initializeMetricDataStructures() { // } diff --git a/src/main/java/com/att/research/mdbc/tools/CreatePartition.java b/src/main/java/com/att/research/mdbc/tools/CreatePartition.java index 09524cb..a38274b 100644 --- a/src/main/java/com/att/research/mdbc/tools/CreatePartition.java +++ b/src/main/java/com/att/research/mdbc/tools/CreatePartition.java @@ -1,17 +1,10 @@ package com.att.research.mdbc.tools; import com.att.research.logging.EELFLoggerDelegate; -import com.att.research.mdbc.DatabasePartition; -import com.att.research.mdbc.MDBCUtils; -import com.att.research.mdbc.Range; import com.att.research.mdbc.configurations.NodeConfiguration; import com.beust.jcommander.JCommander; import com.beust.jcommander.Parameter; -import java.io.IOException; -import java.util.HashSet; -import java.util.Set; - public class CreatePartition { public static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(CreatePartition.class); @@ -21,15 +14,15 @@ public class CreatePartition { @Parameter(names = { "-f", "--file" }, required = true, description = "This is the output file that is going to have the configuration for the ranges") private String file; - @Parameter(names = { "-i", "--tit-index" }, required = true, - description = "Index in the TiT Table") - private String titIndex; - @Parameter(names = { "-n", "--tit-table-name" }, required = true, - description = "Tit Table name") - private String titTable; - @Parameter(names = { "-r", "--redorecords-table-name" }, required = true, - description = "Redo Records Table name") - private String rrTable; + @Parameter(names = { "-i", "--mri-index" }, required = true, + description = "Index in the Mri Table") + private String mriIndex; + @Parameter(names = { "-m", "--mri-table-name" }, required = true, + description = "Mri Table name") + private String mriTable; + @Parameter(names = { "-r", "--music-tx-digest-table-name" }, required = true, + description = "Music Transaction Digest Table name") + private String mtxdTable; @Parameter(names = { "-p", "--partition-id" }, required = true, description = "Partition Id") private String partitionId; @@ -43,7 +36,7 @@ public class CreatePartition { } public void convert(){ - config = new NodeConfiguration(tables,titIndex,titTable,partitionId,"test","",rrTable); + config = new NodeConfiguration(tables, mriIndex,mriTable,partitionId,"test","", mtxdTable); } public void saveToFile(){ -- cgit 1.2.3-korg