use of com.ctrip.platform.dal.dao.datasource.cluster.HostConnection in project dal by ctripcorp.
the class DalConnectionPool method tryValidateClusterConnection.
private void tryValidateClusterConnection(PooledConnection conn) {
if (clusterConnValidator != null) {
boolean isValid = true;
try {
PoolConfiguration config = getPoolProperties();
HostConnection connection;
if (config instanceof DalExtendedPoolConfiguration)
connection = new DefaultHostConnection(getConnection(conn), ((DalExtendedPoolConfiguration) config).getHost());
else
connection = new DefaultHostConnection(getConnection(conn), null);
isValid = clusterConnValidator.validate(connection);
} catch (Throwable t) {
logger.warn("tryValidateClusterConnection exception", t);
}
if (!isValid) {
release(conn);
throw new InvalidConnectionException("Created connection is invalid");
}
}
}
use of com.ctrip.platform.dal.dao.datasource.cluster.HostConnection in project dal by ctripcorp.
the class DataSourceValidator method tryValidateClusterConnection.
private void tryValidateClusterConnection(Connection connection, int validateAction) {
if (clusterConnValidator != null) {
boolean isValid = true;
try {
HostConnection conn;
if (poolProperties instanceof DalExtendedPoolConfiguration)
conn = new DefaultHostConnection(connection, ((DalExtendedPoolConfiguration) poolProperties).getHost());
else
conn = new DefaultHostConnection(connection, null);
isValid = clusterConnValidator.validate(conn);
} catch (Throwable t) {
LOGGER.warn("tryValidateClusterConnection exception", t);
}
if (!isValid)
throw new InvalidConnectionException("Borrowed connection is invalid");
}
}
Aggregations