Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Killing Tez Submitted Queries
public class ClosingPoolableConnectionsDataSource extends BasicDataSource implements ConnectionRegister {
private Set<PoolableConnection> connections = new HashSet<>();
@Override
public synchronized void register(Connection conn) {
if (PoolableConnection.class.isAssignableFrom(conn.getClass())) {
connections.add((PoolableConnection) conn);
}
}
@Override
public synchronized void unregister(Connection conn) {
if (PoolableConnection.class.isAssignableFrom(conn.getClass())) {
connections.remove(conn);
}
}
@Override
public synchronized void close() throws java.sql.SQLException {
for (PoolableConnection conn : connections) {
conn.reallyClose();
}
connections.clear();
super.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.