check for enough endpoints before starting a quorum wait.

patch by jbellis; reviewed by Jun Rao and Sandeep Tata for CASSANDRA-180

git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@775361 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Ellis 2009-05-15 21:37:45 +00:00
parent 784d968db9
commit d52a110974
1 changed files with 5 additions and 2 deletions

View File

@ -149,12 +149,15 @@ public class StorageProxy implements StorageProxyMBean
}
try
{
EndPoint[] endpoints = StorageService.instance().getNStorageEndPoint(rm.key());
if (endpoints.length < (DatabaseDescriptor.getReplicationFactor() / 2) + 1)
{
throw new UnavailableException();
}
QuorumResponseHandler<Boolean> quorumResponseHandler = new QuorumResponseHandler<Boolean>(
DatabaseDescriptor.getReplicationFactor(),
new WriteResponseResolver());
EndPoint[] endpoints = StorageService.instance().getNStorageEndPoint(rm.key());
logger.debug("insertBlocking writing key " + rm.key() + " to " + message.getMessageId() + "@[" + StringUtils.join(endpoints, ", ") + "]");
// TODO: throw a thrift exception if we do not have N nodes
MessagingService.getMessagingInstance().sendRR(message, endpoints, quorumResponseHandler);
if (!quorumResponseHandler.get())