trigger read repair correctly forLOCAL_QUORUM reads

patch by jbellis; reviewed by slebresne for CASSANDRA-2556

git-svn-id: https://svn.apache.org/repos/asf/cassandra/branches/cassandra-0.7@1097455 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Ellis 2011-04-28 13:36:07 +00:00
parent 5e6539addb
commit 0251a8f0f6
3 changed files with 34 additions and 24 deletions

View File

@ -3,6 +3,7 @@
* move gossip heartbeat back to its own thread (CASSANDRA-2554)
* fix incorrect use of NBHM.size in ReadCallback that could cause
reads to time out even when responses were received (CASSAMDRA-2552)
* trigger read repair correctly for LOCAL_QUORUM reads (CASSANDRA-2556)
0.7.5

View File

@ -48,31 +48,17 @@ public class DatacenterReadCallback<T> extends ReadCallback<T>
}
@Override
public void response(Message message)
protected boolean waitingFor(Message message)
{
resolver.preprocess(message);
int n = localdc.equals(snitch.getDatacenter(message.getFrom()))
? received.incrementAndGet()
: received.get();
if (n == blockfor && resolver.isDataPresent())
{
condition.signal();
maybeResolveForRepair();
}
return localdc.equals(snitch.getDatacenter(message.getFrom()));
}
@Override
public void response(ReadResponse result)
{
((RowDigestResolver) resolver).injectPreProcessed(result);
if (received.incrementAndGet() == blockfor && resolver.isDataPresent())
{
condition.signal();
maybeResolveForRepair();
}
@Override
protected boolean waitingFor(ReadResponse response)
{
// cheat and leverage our knowledge that a local read is the only way the ReadResponse
// version of this method gets called
return true;
}
@Override

View File

@ -128,17 +128,40 @@ public class ReadCallback<T> implements IAsyncCallback
public void response(Message message)
{
resolver.preprocess(message);
if (received.incrementAndGet() >= blockfor && resolver.isDataPresent())
int n = waitingFor(message)
? received.incrementAndGet()
: received.get();
if (n >= blockfor && resolver.isDataPresent())
{
condition.signal();
maybeResolveForRepair();
}
}
/**
* @return true if the message counts towards the blockfor threshold
* TODO turn the Message into a response so we don't need two versions of this method
*/
protected boolean waitingFor(Message message)
{
return true;
}
/**
* @return true if the response counts towards the blockfor threshold
*/
protected boolean waitingFor(ReadResponse response)
{
return true;
}
public void response(ReadResponse result)
{
((RowDigestResolver) resolver).injectPreProcessed(result);
if (received.incrementAndGet() >= blockfor && resolver.isDataPresent())
int n = waitingFor(result)
? received.incrementAndGet()
: received.get();
if (n >= blockfor && resolver.isDataPresent())
{
condition.signal();
maybeResolveForRepair();