@@ -668,7 +668,7 @@ public void onCommitTxn(CommitTxnEvent commitTxnEvent, Connection dbConn, SQLGen
668668 return ;
669669 }
670670 CommitTxnMessage msg =
671- MessageBuilder .getInstance ().buildCommitTxnMessage (commitTxnEvent .getTxnId (), commitTxnEvent .getDatabases (), commitTxnEvent .getWriteId ());
671+ MessageBuilder .getInstance ().buildCommitTxnMessage (commitTxnEvent .getTxnId (), commitTxnEvent .getCatalogs (), commitTxnEvent . getDatabases (), commitTxnEvent .getWriteId ());
672672
673673 NotificationEvent event =
674674 new NotificationEvent (0 , now (), EventType .COMMIT_TXN .toString (),
@@ -840,11 +840,12 @@ public void onAddCheckConstraint(AddCheckConstraintEvent addCheckConstraintEvent
840840 */
841841 @ Override
842842 public void onDropConstraint (DropConstraintEvent dropConstraintEvent ) throws MetaException {
843+ String catName = dropConstraintEvent .getCatName ();
843844 String dbName = dropConstraintEvent .getDbName ();
844845 String tableName = dropConstraintEvent .getTableName ();
845846 String constraintName = dropConstraintEvent .getConstraintName ();
846847 DropConstraintMessage msg = MessageBuilder .getInstance ()
847- .buildDropConstraintMessage (dbName , tableName , constraintName );
848+ .buildDropConstraintMessage (catName , dbName , tableName , constraintName );
848849 NotificationEvent event =
849850 new NotificationEvent (0 , now (), EventType .DROP_CONSTRAINT .toString (),
850851 msgEncoder .getSerializer ().serialize (msg ));
@@ -863,8 +864,9 @@ public void onAllocWriteId(AllocWriteIdEvent allocWriteIdEvent, Connection dbCon
863864 throws MetaException {
864865 String tableName = allocWriteIdEvent .getTableName ();
865866 String dbName = allocWriteIdEvent .getDbName ();
867+ String catName = allocWriteIdEvent .getCatName ();
866868 AllocWriteIdMessage msg = MessageBuilder .getInstance ()
867- .buildAllocWriteIdMessage (allocWriteIdEvent .getTxnToWriteIdList (), dbName , tableName );
869+ .buildAllocWriteIdMessage (allocWriteIdEvent .getTxnToWriteIdList (), catName , dbName , tableName );
868870 NotificationEvent event =
869871 new NotificationEvent (0 , now (), EventType .ALLOC_WRITE_ID .toString (),
870872 msgEncoder .getSerializer ().serialize (msg )
@@ -914,6 +916,7 @@ public void onBatchAcidWrite(BatchAcidWriteEvent batchAcidWriteEvent, Connection
914916 NotificationEvent event = new NotificationEvent (0 , now (), EventType .ACID_WRITE .toString (),
915917 msgEncoder .getSerializer ().serialize (msg ));
916918 event .setMessageFormat (msgEncoder .getMessageFormat ());
919+ event .setCatName (batchAcidWriteEvent .getCatalog (i ));
917920 event .setDbName (batchAcidWriteEvent .getDatabase (i ));
918921 event .setTableName (batchAcidWriteEvent .getTable (i ));
919922 eventBatch .add (event );
@@ -946,8 +949,8 @@ public void onUpdateTableColumnStat(UpdateTableColumnStatEvent updateTableColumn
946949 @ Override
947950 public void onDeleteTableColumnStat (DeleteTableColumnStatEvent deleteTableColumnStatEvent ) throws MetaException {
948951 DeleteTableColumnStatMessage msg = MessageBuilder .getInstance ()
949- .buildDeleteTableColumnStatMessage (deleteTableColumnStatEvent .getDBName (),
950- deleteTableColumnStatEvent .getColName ());
952+ .buildDeleteTableColumnStatMessage (deleteTableColumnStatEvent .getCatName (),
953+ deleteTableColumnStatEvent . getDBName (), deleteTableColumnStatEvent .getColName ());
951954 NotificationEvent event = new NotificationEvent (0 , now (), EventType .DELETE_TABLE_COLUMN_STAT .toString (),
952955 msgEncoder .getSerializer ().serialize (msg ));
953956 event .setCatName (deleteTableColumnStatEvent .getCatName ());
@@ -1008,9 +1011,9 @@ public void onUpdatePartitionColumnStatInBatch(UpdatePartitionColumnStatEventBat
10081011 @ Override
10091012 public void onDeletePartitionColumnStat (DeletePartitionColumnStatEvent deletePartColStatEvent ) throws MetaException {
10101013 DeletePartitionColumnStatMessage msg = MessageBuilder .getInstance ()
1011- .buildDeletePartitionColumnStatMessage (deletePartColStatEvent .getDBName (),
1012- deletePartColStatEvent .getColName (), deletePartColStatEvent .getPartName (),
1013- deletePartColStatEvent .getPartVals ());
1014+ .buildDeletePartitionColumnStatMessage (deletePartColStatEvent .getCatName (),
1015+ deletePartColStatEvent .getDBName (), deletePartColStatEvent .getColName (),
1016+ deletePartColStatEvent . getPartName (), deletePartColStatEvent .getPartVals ());
10141017 NotificationEvent event = new NotificationEvent (0 , now (), EventType .DELETE_PARTITION_COLUMN_STAT .toString (),
10151018 msgEncoder .getSerializer ().serialize (msg ));
10161019 event .setCatName (deletePartColStatEvent .getCatName ());
@@ -1205,25 +1208,28 @@ private void addWriteNotificationLog(List<NotificationEvent> eventBatch, List<Ac
12051208 ResultSet rs = null ;
12061209 String select = sqlGenerator .addForUpdateClause ("select \" WNL_ID\" , \" WNL_FILES\" from" +
12071210 " \" TXN_WRITE_NOTIFICATION_LOG\" " +
1208- "where \" WNL_DATABASE\" = ? " +
1211+ "where \" WNL_CATALOG\" = ? " +
1212+ "and \" WNL_DATABASE\" = ? " +
12091213 "and \" WNL_TABLE\" = ? " + " and (\" WNL_PARTITION\" = ? OR (? IS NULL AND \" WNL_PARTITION\" IS NULL)) " +
12101214 "and \" WNL_TXNID\" = ? " );
12111215 List <Integer > insertList = new ArrayList <>();
12121216 Map <Integer , Pair <Long , String >> updateMap = new HashMap <>();
12131217 try (PreparedStatement pst = dbConn .prepareStatement (select )) {
12141218 for (int i = 0 ; i < acidWriteEventList .size (); i ++) {
1219+ String catName = acidWriteEventList .get (i ).getCatalog ();
12151220 String dbName = acidWriteEventList .get (i ).getDatabase ();
12161221 String tblName = acidWriteEventList .get (i ).getTable ();
12171222 String partition = acidWriteEventList .get (i ).getPartition ();
12181223 Long txnId = acidWriteEventList .get (i ).getTxnId ();
12191224
12201225 LOG .debug ("Going to execute query <" + select .replaceAll ("\\ ?" , "{}" ) + ">" ,
1221- quoteString (dbName ), quoteString (tblName ), quoteString (partition ));
1222- pst .setString (1 , dbName );
1223- pst .setString (2 , tblName );
1224- pst .setString (3 , partition );
1226+ quoteString (catName ), quoteString ( dbName ), quoteString (tblName ), quoteString (partition ));
1227+ pst .setString (1 , catName );
1228+ pst .setString (2 , dbName );
1229+ pst .setString (3 , tblName );
12251230 pst .setString (4 , partition );
1226- pst .setLong (5 , txnId );
1231+ pst .setString (5 , partition );
1232+ pst .setLong (6 , txnId );
12271233 rs = pst .executeQuery ();
12281234 if (!rs .next ()) {
12291235 insertList .add (i );
@@ -1244,15 +1250,16 @@ private void addWriteNotificationLog(List<NotificationEvent> eventBatch, List<Ac
12441250 "org.apache.hadoop.hive.metastore.model.MTxnWriteNotificationLog" , insertList .size ());
12451251
12461252 String insert = "insert into \" TXN_WRITE_NOTIFICATION_LOG\" " +
1247- "(\" WNL_ID\" , \" WNL_TXNID\" , \" WNL_WRITEID\" , \" WNL_DATABASE\" , \" WNL_TABLE\" , " +
1253+ "(\" WNL_ID\" , \" WNL_TXNID\" , \" WNL_WRITEID\" , \" WNL_CATALOG \" , \" WNL_DATABASE\" , \" WNL_TABLE\" , " +
12481254 "\" WNL_PARTITION\" , \" WNL_TABLE_OBJ\" , \" WNL_PARTITION_OBJ\" , " +
1249- "\" WNL_FILES\" , \" WNL_EVENT_TIME\" ) VALUES (?,?,?,?,?,?,?,?,?,?)" ;
1255+ "\" WNL_FILES\" , \" WNL_EVENT_TIME\" ) VALUES (?,?,?,?,?,?,?,?,?,?,? )" ;
12501256 try (PreparedStatement pst = dbConn .prepareStatement (sqlGenerator .addEscapeCharacters (insert ))) {
12511257 numRows = 0 ;
12521258 for (int idx : insertList ) {
12531259 String tableObj = msgBatch .get (idx ).getTableObjStr ();
12541260 String partitionObj = msgBatch .get (idx ).getPartitionObjStr ();
12551261 String files = ReplChangeManager .joinWithSeparator (msgBatch .get (idx ).getFiles ());
1262+ String catName = acidWriteEventList .get (idx ).getCatalog ();
12561263 String dbName = acidWriteEventList .get (idx ).getDatabase ();
12571264 String tblName = acidWriteEventList .get (idx ).getTable ();
12581265 String partition = acidWriteEventList .get (idx ).getPartition ();
@@ -1261,16 +1268,17 @@ private void addWriteNotificationLog(List<NotificationEvent> eventBatch, List<Ac
12611268 pst .setLong (1 , nextNLId ++);
12621269 pst .setLong (2 , acidWriteEventList .get (idx ).getTxnId ());
12631270 pst .setLong (3 , acidWriteEventList .get (idx ).getWriteId ());
1264- pst .setString (4 , dbName );
1265- pst .setString (5 , tblName );
1266- pst .setString (6 , partition );
1267- pst .setString (7 , tableObj );
1268- pst .setString (8 , partitionObj );
1269- pst .setString (9 , files );
1270- pst .setInt (10 , currentTime );
1271+ pst .setString (4 , catName );
1272+ pst .setString (5 , dbName );
1273+ pst .setString (6 , tblName );
1274+ pst .setString (7 , partition );
1275+ pst .setString (8 , tableObj );
1276+ pst .setString (9 , partitionObj );
1277+ pst .setString (10 , files );
1278+ pst .setInt (11 , currentTime );
12711279 LOG .debug ("Going to execute insert <" + insert .replaceAll ("\\ ?" , "{}" ) + ">" , nextNLId
12721280 , acidWriteEventList .get (idx ).getTxnId (), acidWriteEventList .get (idx ).getWriteId ()
1273- , quoteString (dbName ), quoteString (tblName ),
1281+ , quoteString (catName ), quoteString ( dbName ), quoteString (tblName ),
12741282 quoteString (partition ), quoteString (tableObj ), quoteString (partitionObj ), quoteString (files ), currentTime );
12751283 pst .addBatch ();
12761284 numRows ++;
0 commit comments