Search in sources :

Example 1 with SqlTimer

use of com.palantir.nexus.db.monitoring.timer.SqlTimer in project atlasdb by palantir.

the class SQL method fromResultSet.

public AgnosticLightResultSet fromResultSet(PreparedStatement preparedStatement, ResultSet resultSet, DBType dbType, String queryString) {
    FinalSQLString sqlString = SQLString.getUnregisteredQuery(queryString);
    String timingModule = "visitResultSet";
    ResultSetMetaData metaData = ResultSets.getMetaData(resultSet);
    SqlTimer sqlTimer = getSqlTimer();
    // $NON-NLS-1$
    ResourceCreationLocation creationException = new ResourceCreationLocation("This is where the ResultsSet was created");
    return new AgnosticLightResultSetImpl(resultSet, dbType, metaData, preparedStatement, timingModule, sqlString, sqlTimer, creationException);
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) FinalSQLString(com.palantir.nexus.db.sql.BasicSQLString.FinalSQLString) ResourceCreationLocation(com.palantir.nexus.db.ResourceCreationLocation) SqlTimer(com.palantir.nexus.db.monitoring.timer.SqlTimer) FinalSQLString(com.palantir.nexus.db.sql.BasicSQLString.FinalSQLString)

Example 2 with SqlTimer

use of com.palantir.nexus.db.monitoring.timer.SqlTimer in project atlasdb by palantir.

the class ConnectionManagerAwareDbKvs method getSimpleTimedSqlConnectionSupplier.

private static SqlConnectionSupplier getSimpleTimedSqlConnectionSupplier(ReentrantManagedConnectionSupplier connectionSupplier) {
    Supplier<Connection> supplier = () -> connectionSupplier.get();
    SQL sql = new SQL() {

        @Override
        protected SqlConfig getSqlConfig() {
            return new SqlConfig() {

                @Override
                public boolean isSqlCancellationDisabled() {
                    return false;
                }

                protected Iterable<SqlTimer> getSqlTimers() {
                    return ImmutableList.of(SqlTimers.createDurationSqlTimer(), SqlTimers.createSqlStatsSqlTimer());
                }

                @Override
                public SqlTimer getSqlTimer() {
                    return SqlTimers.createCombinedSqlTimer(getSqlTimers());
                }
            };
        }
    };
    return new SqlConnectionSupplier() {

        @Override
        public SqlConnection get() {
            return new ConnectionBackedSqlConnectionImpl(supplier.get(), () -> {
                throw new UnsupportedOperationException("This SQL connection does not provide reliable timestamp.");
            }, new SqlConnectionHelper(sql));
        }

        @Override
        public void close() {
            connectionSupplier.close();
        }
    };
}
Also used : Connection(java.sql.Connection) SqlConnection(com.palantir.nexus.db.sql.SqlConnection) SqlTimer(com.palantir.nexus.db.monitoring.timer.SqlTimer) ConnectionBackedSqlConnectionImpl(com.palantir.nexus.db.sql.ConnectionBackedSqlConnectionImpl) SqlConnectionHelper(com.palantir.nexus.db.sql.SqlConnectionHelper) SQL(com.palantir.nexus.db.sql.SQL)

Aggregations

SqlTimer (com.palantir.nexus.db.monitoring.timer.SqlTimer)2 ResourceCreationLocation (com.palantir.nexus.db.ResourceCreationLocation)1 FinalSQLString (com.palantir.nexus.db.sql.BasicSQLString.FinalSQLString)1 ConnectionBackedSqlConnectionImpl (com.palantir.nexus.db.sql.ConnectionBackedSqlConnectionImpl)1 SQL (com.palantir.nexus.db.sql.SQL)1 SqlConnection (com.palantir.nexus.db.sql.SqlConnection)1 SqlConnectionHelper (com.palantir.nexus.db.sql.SqlConnectionHelper)1 Connection (java.sql.Connection)1 ResultSetMetaData (java.sql.ResultSetMetaData)1