use of org.apache.phoenix.query.ConnectionQueryServicesImpl in project phoenix by apache.
the class UpgradeIT method testAcquiringAndReleasingUpgradeMutex.
@Test
public void testAcquiringAndReleasingUpgradeMutex() throws Exception {
ConnectionQueryServices services = null;
byte[] mutexRowKey = SchemaUtil.getTableKey(null, PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA, generateUniqueName());
try (Connection conn = getConnection(false, null)) {
services = conn.unwrap(PhoenixConnection.class).getQueryServices();
putUnlockKVInSysMutex(mutexRowKey);
assertTrue(((ConnectionQueryServicesImpl) services).acquireUpgradeMutex(MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0, mutexRowKey));
try {
((ConnectionQueryServicesImpl) services).acquireUpgradeMutex(MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0, mutexRowKey);
fail();
} catch (UpgradeInProgressException expected) {
}
assertTrue(((ConnectionQueryServicesImpl) services).releaseUpgradeMutex(mutexRowKey));
assertFalse(((ConnectionQueryServicesImpl) services).releaseUpgradeMutex(mutexRowKey));
}
}
use of org.apache.phoenix.query.ConnectionQueryServicesImpl in project phoenix by apache.
the class PhoenixDriver method getConnectionQueryServices.
@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;
// Also performs the Kerberos login if the URL/properties request this
final ConnectionInfo normalizedConnInfo = connInfo.normalize(services.getProps(), info);
try {
connectionQueryServices = connectionQueryServicesCache.get(normalizedConnInfo, new Callable<ConnectionQueryServices>() {
@Override
public ConnectionQueryServices call() throws Exception {
ConnectionQueryServices connectionQueryServices;
if (normalizedConnInfo.isConnectionless()) {
connectionQueryServices = new ConnectionlessQueryServicesImpl(services, normalizedConnInfo, info);
} else {
connectionQueryServices = new ConnectionQueryServicesImpl(services, normalizedConnInfo, info);
}
return connectionQueryServices;
}
});
connectionQueryServices.init(url, info);
success = true;
} catch (ExecutionException ee) {
if (ee.getCause() instanceof SQLException) {
sqlE = (SQLException) ee.getCause();
} else {
throw new SQLException(ee);
}
} catch (SQLException e) {
sqlE = e;
} finally {
if (!success) {
// Remove from map, as initialization failed
connectionQueryServicesCache.invalidate(normalizedConnInfo);
if (sqlE != null) {
throw sqlE;
}
}
}
return connectionQueryServices;
} finally {
unlock(LockMode.READ);
}
}
Aggregations