@Test public void testaddTxComplete() { final StatementLog log = insert1Log(); final TxCompleteLog txCompleteLog = new TxCompleteLog(log.getConnectionUuid(), System.currentTimeMillis(), TxCompletionType.SET_SAVE_POINT, 12, "mythread", "mySavePoint"); repositoryUpdate.addTxCompletionLog(txCompleteLog); assertEquals(2, countRowsInTable("statement_log")); final DetailedViewStatementLog readTxLog = repositoryRead.getStatementLog(2); assertEquals(StatementType.TRANSACTION, readTxLog.getStatementType()); assertEquals("SET_SAVE_POINT mySavePoint", readTxLog.getRawSql()); assertEquals(txCompleteLog.getThreadName(), readTxLog.getThreadName()); assertEquals(txCompleteLog.getTimestamp(), readTxLog.getTimestamp()); }
@Override public synchronized void addTxCompletionLog(final TxCompleteLog log) { LOGGER.debug("addTxCompletionLog:{}", log); try { int i = 1; addTxCompletionLog.setObject(i++, UUID.randomUUID()); addTxCompletionLog.setTimestamp(i++, new Timestamp(log.getTimestamp())); addTxCompletionLog.setInt(i++, StatementType.TRANSACTION.getId()); String rawSql = log.getCompletionType().name(); if (log.getSavePointDescription() != null) { rawSql += " " + log.getSavePointDescription(); } addTxCompletionLog.setString(i++, rawSql); addTxCompletionLog.setString(i++, ""); addTxCompletionLog.setLong(i++, log.getExecutionTimeNanos()); addTxCompletionLog.setString(i++, log.getThreadName()); addTxCompletionLog.setObject(i++, log.getConnectionUuid()); addTxCompletionLog.execute(); } catch (final SQLException e) { throw new RuntimeException(e); } lastModificationTime = System.currentTimeMillis(); }
LogRepositoryUpdateJdbc implements LogRepositoryUpdate { @Override public synchronized void addTxCompletionLog(final TxCompleteLog log) { LOGGER.debug("addTxCompletionLog:{}", log); try { int i = 1; addTxCompletionLog.setObject(i++, UUID.randomUUID()); addTxCompletionLog.setTimestamp(i++, new Timestamp(log.getTimestamp())); addTxCompletionLog.setInt(i++, StatementType.TRANSACTION.getId()); String rawSql = log.getCompletionType().name(); if (log.getSavePointDescription() != null) { rawSql += " " + log.getSavePointDescription(); } addTxCompletionLog.setString(i++, rawSql); addTxCompletionLog.setString(i++, ""); addTxCompletionLog.setLong(i++, log.getExecutionTimeNanos()); addTxCompletionLog.setString(i++, log.getThreadName()); addTxCompletionLog.setObject(i++, log.getConnectionUuid()); addTxCompletionLog.execute(); } catch (final SQLException e) { throw new RuntimeException(e); } lastModificationTime = System.currentTimeMillis(); } }
LogRepositoryUpdateJdbc implements LogRepositoryUpdate { @Override public synchronized void addTxCompletionLog(final TxCompleteLog log) { LOGGER.debug("addTxCompletionLog:{}", log); try { int i = 1; addTxCompletionLog.setObject(i++, UUID.randomUUID()); addTxCompletionLog.setTimestamp(i++, new Timestamp(log.getTimestamp())); addTxCompletionLog.setInt(i++, StatementType.TRANSACTION.getId()); String rawSql = log.getCompletionType().name(); if (log.getSavePointDescription() != null) { rawSql += " " + log.getSavePointDescription(); } addTxCompletionLog.setString(i++, rawSql); addTxCompletionLog.setString(i++, ""); addTxCompletionLog.setLong(i++, log.getExecutionTimeNanos()); addTxCompletionLog.setString(i++, log.getThreadName()); addTxCompletionLog.setObject(i++, log.getConnectionUuid()); addTxCompletionLog.execute(); } catch (final SQLException e) { throw new RuntimeException(e); } lastModificationTime = System.currentTimeMillis(); } LogRepositoryUpdateJdbc(final String name); }
LogRepositoryUpdateJdbc implements LogRepositoryUpdate { @Override public synchronized void addTxCompletionLog(final TxCompleteLog log) { LOGGER.debug("addTxCompletionLog:{}", log); try { int i = 1; addTxCompletionLog.setObject(i++, UUID.randomUUID()); addTxCompletionLog.setTimestamp(i++, new Timestamp(log.getTimestamp())); addTxCompletionLog.setInt(i++, StatementType.TRANSACTION.getId()); String rawSql = log.getCompletionType().name(); if (log.getSavePointDescription() != null) { rawSql += " " + log.getSavePointDescription(); } addTxCompletionLog.setString(i++, rawSql); addTxCompletionLog.setString(i++, ""); addTxCompletionLog.setLong(i++, log.getExecutionTimeNanos()); addTxCompletionLog.setString(i++, log.getThreadName()); addTxCompletionLog.setObject(i++, log.getConnectionUuid()); addTxCompletionLog.execute(); } catch (final SQLException e) { throw new RuntimeException(e); } lastModificationTime = System.currentTimeMillis(); } LogRepositoryUpdateJdbc(final String name); @Override void dispose(); @Override synchronized void addStatementLog(final StatementLog log); @Override synchronized void addStatementFullyExecutedLog(final Collection<StatementFullyExecutedLog> logs); @Override synchronized void updateLogAfterExecution(final StatementExecutedLog log); @Override synchronized void updateLogWithResultSetLog(final ResultSetLog log); @Override synchronized void addBatchedPreparedStatementsLog(final BatchedPreparedStatementsLog log); @Override synchronized void addBatchedNonPreparedStatementsLog(final BatchedNonPreparedStatementsLog log); @Override synchronized void addConnection(final ConnectionInfo connectionInfo); @Override synchronized void addTxCompletionLog(final TxCompleteLog log); @Override void clear(); @Override void deleteStatementLog(final long... logIds); void deleteOldRowsIfTooMany(); @Override synchronized long getLastModificationTime(); @Override void setLastLostMessageTime(@Nullable final Long timestamp); @Override @Nullable Long getLastLostMessageTime(); }
LogRepositoryUpdateJdbc implements LogRepositoryUpdate { @Override public synchronized void addTxCompletionLog(final TxCompleteLog log) { LOGGER.debug("addTxCompletionLog:{}", log); try { int i = 1; addTxCompletionLog.setObject(i++, UUID.randomUUID()); addTxCompletionLog.setTimestamp(i++, new Timestamp(log.getTimestamp())); addTxCompletionLog.setInt(i++, StatementType.TRANSACTION.getId()); String rawSql = log.getCompletionType().name(); if (log.getSavePointDescription() != null) { rawSql += " " + log.getSavePointDescription(); } addTxCompletionLog.setString(i++, rawSql); addTxCompletionLog.setString(i++, ""); addTxCompletionLog.setLong(i++, log.getExecutionTimeNanos()); addTxCompletionLog.setString(i++, log.getThreadName()); addTxCompletionLog.setObject(i++, log.getConnectionUuid()); addTxCompletionLog.execute(); } catch (final SQLException e) { throw new RuntimeException(e); } lastModificationTime = System.currentTimeMillis(); } LogRepositoryUpdateJdbc(final String name); @Override void dispose(); @Override synchronized void addStatementLog(final StatementLog log); @Override synchronized void addStatementFullyExecutedLog(final Collection<StatementFullyExecutedLog> logs); @Override synchronized void updateLogAfterExecution(final StatementExecutedLog log); @Override synchronized void updateLogWithResultSetLog(final ResultSetLog log); @Override synchronized void addBatchedPreparedStatementsLog(final BatchedPreparedStatementsLog log); @Override synchronized void addBatchedNonPreparedStatementsLog(final BatchedNonPreparedStatementsLog log); @Override synchronized void addConnection(final ConnectionInfo connectionInfo); @Override synchronized void addTxCompletionLog(final TxCompleteLog log); @Override void clear(); @Override void deleteStatementLog(final long... logIds); void deleteOldRowsIfTooMany(); @Override synchronized long getLastModificationTime(); @Override void setLastLostMessageTime(@Nullable final Long timestamp); @Override @Nullable Long getLastLostMessageTime(); static final int SCHEMA_VERSION; }