use of org.apache.cassandra.db.ReadResponse in project eiger by wlloyd.
the class AbstractRowResolver method preprocess.
public void preprocess(Message message) {
byte[] body = message.getMessageBody();
FastByteArrayInputStream bufIn = new FastByteArrayInputStream(body);
try {
ReadResponse result = ReadResponse.serializer().deserialize(new DataInputStream(bufIn), message.getVersion());
if (logger.isDebugEnabled())
logger.debug("Preprocessed {} response", result.isDigestQuery() ? "digest" : "data");
replies.put(message, result);
} catch (IOException e) {
throw new IOError(e);
}
}
use of org.apache.cassandra.db.ReadResponse in project eiger by wlloyd.
the class RowDigestResolver method resolve.
/*
* This method handles two different scenarios:
*
* a) we're handling the initial read, of data from the closest replica + digests
* from the rest. In this case we check the digests against each other,
* throw an exception if there is a mismatch, otherwise return the data row.
*
* b) we're checking additional digests that arrived after the minimum to handle
* the requested ConsistencyLevel, i.e. asynchronous read repair check
*/
public Row resolve() throws DigestMismatchException, IOException {
if (logger.isDebugEnabled())
logger.debug("resolving " + replies.size() + " responses");
long startTime = System.currentTimeMillis();
// validate digests against each other; throw immediately on mismatch.
// also extract the data reply, if any.
ColumnFamily data = null;
ByteBuffer digest = null;
for (Map.Entry<Message, ReadResponse> entry : replies.entrySet()) {
ReadResponse response = entry.getValue();
if (response.isDigestQuery()) {
if (digest == null) {
digest = response.digest();
} else {
ByteBuffer digest2 = response.digest();
if (!digest.equals(digest2))
throw new DigestMismatchException(key, digest, digest2);
}
} else {
data = response.row().cf;
}
}
// that can only happen when we're doing the repair post-mismatch, and will be handled by RowRepairResolver.
if (digest != null) {
ByteBuffer digest2 = ColumnFamily.digest(data);
if (!digest.equals(digest2))
throw new DigestMismatchException(key, digest, digest2);
if (logger.isDebugEnabled())
logger.debug("digests verified");
}
if (logger.isDebugEnabled())
logger.debug("resolve: " + (System.currentTimeMillis() - startTime) + " ms.");
return new Row(key, data);
}
Aggregations