Search in sources :

Example 1 with ProposeCallback

use of org.apache.cassandra.service.paxos.ProposeCallback in project cassandra by apache.

the class StorageProxy method proposePaxos.

private static boolean proposePaxos(Commit proposal, List<InetAddress> endpoints, int requiredParticipants, boolean timeoutIfPartial, ConsistencyLevel consistencyLevel, long queryStartNanoTime) throws WriteTimeoutException {
    ProposeCallback callback = new ProposeCallback(endpoints.size(), requiredParticipants, !timeoutIfPartial, consistencyLevel, queryStartNanoTime);
    MessageOut<Commit> message = new MessageOut<Commit>(MessagingService.Verb.PAXOS_PROPOSE, proposal, Commit.serializer);
    for (InetAddress target : endpoints) MessagingService.instance().sendRR(message, target, callback);
    callback.await();
    if (callback.isSuccessful())
        return true;
    if (timeoutIfPartial && !callback.isFullyRefused())
        throw new WriteTimeoutException(WriteType.CAS, consistencyLevel, callback.getAcceptCount(), requiredParticipants);
    return false;
}
Also used : Commit(org.apache.cassandra.service.paxos.Commit) ProposeCallback(org.apache.cassandra.service.paxos.ProposeCallback) InetAddress(java.net.InetAddress)

Aggregations

InetAddress (java.net.InetAddress)1 Commit (org.apache.cassandra.service.paxos.Commit)1 ProposeCallback (org.apache.cassandra.service.paxos.ProposeCallback)1