setFinalResult(connection, response);
break;
case ERROR:
ErrorMessage err = (ErrorMessage)response;
RetryPolicy.RetryDecision retry = null;
RetryPolicy retryPolicy = query.getRetryPolicy() == null
? manager.configuration().getPolicies().getRetryPolicy()
: query.getRetryPolicy();
switch (err.error.code()) {
case READ_TIMEOUT:
assert err.error instanceof ReadTimeoutException;
if (manager.configuration().isMetricsEnabled())
metrics().getErrorMetrics().getReadTimeouts().inc();
ReadTimeoutException rte = (ReadTimeoutException)err.error;
ConsistencyLevel rcl = ConsistencyLevel.from(rte.consistency);
retry = retryPolicy.onReadTimeout(query, rcl, rte.blockFor, rte.received, rte.dataPresent, queryRetries);
break;
case WRITE_TIMEOUT:
assert err.error instanceof WriteTimeoutException;
if (manager.configuration().isMetricsEnabled())
metrics().getErrorMetrics().getWriteTimeouts().inc();
WriteTimeoutException wte = (WriteTimeoutException)err.error;
ConsistencyLevel wcl = ConsistencyLevel.from(wte.consistency);
retry = retryPolicy.onWriteTimeout(query, wcl, WriteType.from(wte.writeType), wte.blockFor, wte.received, queryRetries);
break;
case UNAVAILABLE:
assert err.error instanceof UnavailableException;
if (manager.configuration().isMetricsEnabled())
metrics().getErrorMetrics().getUnavailables().inc();
UnavailableException ue = (UnavailableException)err.error;
ConsistencyLevel ucl = ConsistencyLevel.from(ue.consistency);
retry = retryPolicy.onUnavailable(query, ucl, ue.required, ue.alive, queryRetries);
break;
case OVERLOADED:
// Try another node
logger.warn("Host {} is overloaded, trying next host.", connection.address);
logError(connection.address, "Host overloaded");