use of com.ctrip.platform.dal.dao.datasource.cluster.ConnectionDelegate in project dal by ctripcorp.
the class MajorityHostValidator method validate.
@Override
public boolean validate(HostConnection connection) throws SQLException {
try {
HostSpec currentHost = connection.getHost();
if (connection.isWrapperFor(ConnectionDelegate.class)) {
ConnectionDelegate connectionDelegate = connection.unwrap(ConnectionDelegate.class);
if (connectionDelegate.getDelegated() == null) {
LOGGER.warn(CREATE_CONNECTION_FAILED + currentHost.toString());
LOGGER.logEvent(CAT_LOG_TYPE, CREATE_CONNECTION_FAILED, currentHost.toString());
asyncValidate(orderHosts);
return false;
}
}
ValidateResult validateResult = validateAndUpdate(connection, currentHost, configuredHosts.size());
LOGGER.info(VALIDATE_RESULT + currentHost.toString() + ":" + validateResult.validateResult);
LOGGER.logEvent(CAT_LOG_TYPE, currentHost.toString() + ":" + validateResult.validateResult, validateResult.toString());
if (!validateResult.validateResult) {
asyncValidate(orderHosts);
}
return validateResult.validateResult;
} catch (SQLException e) {
asyncValidate(orderHosts);
throw e;
}
}
Aggregations