use of com.palantir.nexus.db.sql.SQL 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();
}
};
}
Aggregations