private static void closeInstance(PhoenixDriver instance) { try { instance.close(); } catch (SQLException e) { logger.warn("Unable to close PhoenixDriver on shutdown", e); } finally { driverShutdownMsg = "Phoenix driver closed because server is shutting down"; } }
@Override public Connection connect(String url, Properties info) throws SQLException { if (!acceptsURL(url)) { return null; } try { lockInterruptibly(LockMode.READ); checkClosed(); return createConnection(url, info); } finally { unlock(LockMode.READ); } }
@Override public QueryServices getQueryServices() throws SQLException { try { lockInterruptibly(LockMode.READ); checkClosed(); // Lazy initialize QueryServices so that we only attempt to create an HBase Configuration // object upon the first attempt to connect to any cluster. Otherwise, an attempt will be // made at driver initialization time which is too early for some systems. QueryServices result = services; if (result == null) { synchronized(this) { result = services; if(result == null) { services = result = new QueryServicesImpl(getDefaultProps()); } } } return result; } finally { unlock(LockMode.READ); } }
@Override public synchronized void close() throws SQLException { try { lockInterruptibly(LockMode.WRITE); if (closed) { return; } closed = true; } finally { unlock(LockMode.WRITE); } if (services != null) { try { services.close(); } finally { services = null; } } }
@Override protected ConnectionQueryServices getConnectionQueryServices(String url, final Properties info) throws SQLException { try { lockInterruptibly(LockMode.READ); checkClosed(); ConnectionInfo connInfo = ConnectionInfo.create(url); SQLException sqlE = null; boolean success = false; final QueryServices services = getQueryServices(); ConnectionQueryServices connectionQueryServices = null; unlock(LockMode.READ);
@GuardedBy("closeLock") private void checkClosed() { if (closed) { throwDriverClosedException(); } }
@Override public boolean acceptsURL(String url) throws SQLException { // Accept the url only if test=true attribute not set return super.acceptsURL(url) && !isTestUrl(url); }
@Override protected ConnectionQueryServices getConnectionQueryServices(String url, final Properties info) throws SQLException { try { lockInterruptibly(LockMode.READ); checkClosed(); ConnectionInfo connInfo = ConnectionInfo.create(url); SQLException sqlE = null; boolean success = false; final QueryServices services = getQueryServices(); ConnectionQueryServices connectionQueryServices = null; unlock(LockMode.READ);
@Override public synchronized void close() throws SQLException { try { lockInterruptibly(LockMode.WRITE); if (closed) { return; } closed = true; } finally { unlock(LockMode.WRITE); } if (services != null) { try { services.close(); } finally { services = null; } } }
@GuardedBy("closeLock") private void checkClosed() { if (closed) { throwDriverClosedException(); } }
@Override public boolean acceptsURL(String url) throws SQLException { // Accept the url only if test=true attribute not set return super.acceptsURL(url) && !isTestUrl(url); }
@Override public Connection connect(String url, Properties info) throws SQLException { if (!acceptsURL(url)) { return null; } try { lockInterruptibly(LockMode.READ); checkClosed(); return createConnection(url, info); } finally { unlock(LockMode.READ); } }
@Override public QueryServices getQueryServices() throws SQLException { try { lockInterruptibly(LockMode.READ); checkClosed(); // Lazy initialize QueryServices so that we only attempt to create an HBase Configuration // object upon the first attempt to connect to any cluster. Otherwise, an attempt will be // made at driver initialization time which is too early for some systems. QueryServices result = services; if (result == null) { synchronized(this) { result = services; if(result == null) { services = result = new QueryServicesImpl(getDefaultProps()); } } } return result; } finally { unlock(LockMode.READ); } }
@Override protected ConnectionQueryServices getConnectionQueryServices(String url, final Properties info) throws SQLException { try { lockInterruptibly(LockMode.READ); checkClosed(); ConnectionInfo connInfo = ConnectionInfo.create(url); SQLException sqlE = null; boolean success = false; final QueryServices services = getQueryServices(); ConnectionQueryServices connectionQueryServices = null; unlock(LockMode.READ);
@Override public synchronized void close() throws SQLException { try { lockInterruptibly(LockMode.WRITE); if (closed) { return; } closed = true; } finally { unlock(LockMode.WRITE); } if (services != null) { try { services.close(); } finally { services = null; } } }
@AfterClass public static void tearDownAfterClass() throws Exception { try { conn.close(); } finally { try { PhoenixDriver.INSTANCE.close(); } finally { try { DriverManager.deregisterDriver(PhoenixDriver.INSTANCE); } finally { hbaseTestUtil.shutdownMiniCluster(); } } } // Shutdowns down the filesystem -- do this after stopping HBase. if (qt != null) { try { qt.shutdown(); } catch (Exception e) { LOG.error("Unexpected exception in setup", e); //fail("Unexpected exception in tearDown"); } } } }
@GuardedBy("closeLock") private void checkClosed() { if (closed) { throwDriverClosedException(); } }
@Override public boolean acceptsURL(String url) throws SQLException { // Accept the url only if test=true attribute not set return super.acceptsURL(url) && !isTestUrl(url); }
@Override public Connection connect(String url, Properties info) throws SQLException { if (!acceptsURL(url)) { return null; } try { lockInterruptibly(LockMode.READ); checkClosed(); return createConnection(url, info); } finally { unlock(LockMode.READ); } }
@Override public QueryServices getQueryServices() throws SQLException { try { lockInterruptibly(LockMode.READ); checkClosed(); // Lazy initialize QueryServices so that we only attempt to create an HBase Configuration // object upon the first attempt to connect to any cluster. Otherwise, an attempt will be // made at driver initialization time which is too early for some systems. QueryServices result = services; if (result == null) { synchronized(this) { result = services; if(result == null) { services = result = new QueryServicesImpl(getDefaultProps()); } } } return result; } finally { unlock(LockMode.READ); } }