logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), AppMessages.QUERYERROR, ErrorTypes.QUERYERROR, ErrorSeverity.CRITICAL);
}
- // Verify the tables in MUSIC match the tables in the database
- // and create triggers on any tables that need them
- try {
- this.synchronizeTables();
- } catch (QueryException e) {
- logger.error("Error syncrhonizing tables");
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), AppMessages.QUERYERROR, ErrorTypes.QUERYERROR, ErrorSeverity.CRITICAL);
- }
this.progressKeeper = progressKeeper;
this.partition = partition;
this.statemanager = statemanager;
* proxy first starts, and whenever there is the possibility that tables were created or dropped. It is synchronized
* in order to prevent multiple threads from running this code in parallel.
*/
- public void synchronizeTables() throws QueryException {
+ public void createTriggers() throws QueryException {
Set<String> set1 = dbi.getSQLTableSet(); // set of tables in the database
logger.debug(EELFLoggerDelegate.applicationLogger, "synchronizing tables:" + set1);
for (String tableName : set1) {
if (!table_set.contains(tableName.toUpperCase()) && !dbi.getReservedTblNames().contains(tableName.toUpperCase())) {
logger.info(EELFLoggerDelegate.applicationLogger, "New table discovered: "+tableName);
try {
- TableInfo ti = dbi.getTableInfo(tableName);
- //mi.initializeMusicForTable(ti,tableName);
- //mi.createDirtyRowTable(ti,tableName);
dbi.createSQLTriggers(tableName);
table_set.add(tableName.toUpperCase());
- //dbi.synchronizeData(tableName);
- logger.debug(EELFLoggerDelegate.applicationLogger, "synchronized tables:" +
- table_set.size() + "/" + set1.size() + "tables uploaded");
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.UNKNOWNERROR, ErrorSeverity.CRITICAL, ErrorTypes.QUERYERROR);
//logger.error(EELFLoggerDelegate.errorLogger, "Exception synchronizeTables: "+e);
mConn.preStatementHook(sql);
r = stmt.executeQuery(sql);
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger, "executeQuery: exception "+nm);
mConn.preStatementHook(sql);
n = stmt.executeUpdate(sql);
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger, "executeUpdate: exception "+nm+" "+e);
mConn.preStatementHook(sql);
b = stmt.execute(sql);
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger, "execute: exception "+nm+" "+e);
try {
logger.debug(EELFLoggerDelegate.applicationLogger,"executeBatch() is not supported by MDBC; your results may be incorrect as a result.");
n = stmt.executeBatch();
- synchronizeTables(null);
} catch (Exception e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger,"executeBatch: exception "+nm);
mConn.preStatementHook(sql);
n = stmt.executeUpdate(sql, autoGeneratedKeys);
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger,"executeUpdate: exception "+nm);
mConn.preStatementHook(sql);
n = stmt.executeUpdate(sql, columnIndexes);
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger,"executeUpdate: exception "+nm);
mConn.preStatementHook(sql);
n = stmt.executeUpdate(sql, columnNames);
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger,"executeUpdate: exception "+nm);
mConn.preStatementHook(sql);
b = stmt.execute(sql, autoGeneratedKeys);
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger,"execute: exception "+nm);
mConn.preStatementHook(sql);
b = stmt.execute(sql, columnIndexes);
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger,"execute: exception "+nm);
mConn.preStatementHook(sql);
b = stmt.execute(sql, columnNames);
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger,"execute: exception "+nm);
mConn.preStatementHook(sql);
r = ((PreparedStatement)stmt).executeQuery();;
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
e.printStackTrace();
String nm = e.getClass().getName();
mConn.preStatementHook(sql);
n = ((PreparedStatement)stmt).executeUpdate();
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
e.printStackTrace();
String nm = e.getClass().getName();
mConn.preStatementHook(sql);
b = ((PreparedStatement)stmt).execute();
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
e.printStackTrace();
String nm = e.getClass().getName();
mConn.preStatementHook(sql);
r = stmt.executeQuery(sql);
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger, "executeQuery: exception "+nm);
mConn.preStatementHook(sql);
n = stmt.executeUpdate(sql);
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger, "executeUpdate: exception "+nm+" "+e);
mConn.preStatementHook(sql);
b = stmt.execute(sql);
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger, "execute: exception "+nm+" "+e);
try {
logger.debug(EELFLoggerDelegate.applicationLogger,"executeBatch() is not supported by MDBC; your results may be incorrect as a result.");
n = stmt.executeBatch();
- synchronizeTables(null);
} catch (Exception e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger,"executeBatch: exception "+nm);
mConn.preStatementHook(sql);
n = stmt.executeUpdate(sql, autoGeneratedKeys);
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger,"executeUpdate: exception "+nm);
mConn.preStatementHook(sql);
n = stmt.executeUpdate(sql, columnIndexes);
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger,"executeUpdate: exception "+nm);
mConn.preStatementHook(sql);
n = stmt.executeUpdate(sql, columnNames);
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger,"executeUpdate: exception "+nm);
mConn.preStatementHook(sql);
b = stmt.execute(sql, autoGeneratedKeys);
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger,"execute: exception "+nm);
mConn.preStatementHook(sql);
b = stmt.execute(sql, columnIndexes);
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger,"execute: exception "+nm);
mConn.preStatementHook(sql);
b = stmt.execute(sql, columnNames);
mConn.postStatementHook(sql);
- synchronizeTables(sql);
} catch (SQLException e) {
String nm = e.getClass().getName();
logger.error(EELFLoggerDelegate.errorLogger,"execute: exception "+nm);
return stmt.isCloseOnCompletion();
}
- protected void synchronizeTables(String sql) {
- if (sql == null || sql.trim().toLowerCase().startsWith("create")) {
- if (mConn != null) {
- try {
- mConn.synchronizeTables();
- } catch (QueryException e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.UNKNOWNERROR, ErrorSeverity.CRITICAL, ErrorTypes.QUERYERROR);
- }
- }
- }
- }
+
}
import org.apache.commons.lang3.tuple.Pair;
import org.onap.music.exceptions.MDBCServiceException;
+import org.onap.music.exceptions.QueryException;
import org.onap.music.logging.EELFLoggerDelegate;
import org.onap.music.logging.format.AppMessages;
import org.onap.music.logging.format.ErrorSeverity;
throw new MDBCServiceException(e.getMessage(), e);
}
}
+
+ // Verify the tables in MUSIC match the tables in the database
+ // and create triggers on any tables that need them
+ try {
+ MdbcConnection mdbcConn = (MdbcConnection) openConnection("init");
+ mdbcConn.createTriggers();
+ closeConnection("init");
+ } catch (QueryException e) {
+ logger.error("Error syncrhonizing tables");
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), AppMessages.QUERYERROR, ErrorTypes.QUERYERROR, ErrorSeverity.CRITICAL);
+ }
}
/**
void close();
/**
* Get a set of the table names in the database. The table names should be returned in UPPER CASE.
+ * @see #getSQLRangeSet()
* @return the set
*/
@Deprecated
this.tables = new HashMap<String, TableInfo>();
useAsyncStagingUpdate = Boolean.parseBoolean(info.getProperty(Configuration.KEY_ASYNC_STAGING_TABLE_UPDATE,
Configuration.ASYNC_STAGING_TABLE_UPDATE));
+ this.deleteStagingStatement = getStagingDeletePreparedStatement();
}
class StagingTableUpdateRunnable implements Runnable{
@Override
public String getSchema() {return this.dbName;}
- /**
- * Get a set of the table names in the database.
- * @return the set
- */
+
@Override
public Set<String> getSQLTableSet() {
Set<String> set = new TreeSet<String>();
Statement stmt = jdbcConn.createStatement();
stmt.execute(CREATE_TBL_SQL);
stmt.close();
- this.deleteStagingStatement = getStagingDeletePreparedStatement();
+
logger.info(EELFLoggerDelegate.applicationLogger,"createSQLTriggers: Server side dirty table created.");
server_tbl_created = true;
} catch (SQLException e) {