Last active
December 2, 2019 15:23
-
-
Save kazabubu/5ff8d6f5faddb01dce9f93fd98f19458 to your computer and use it in GitHub Desktop.
Killing Tez Submitted Queries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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