private static ConsistencyLevel downgrade ( ConsistencyLevel current , int acknowledgements , DriverException original ) { if ( acknowledgements >= 3 ) { return DefaultConsistencyLevel . THREE ; } if ( acknowledgements == 2 ) { return DefaultConsistencyLevel . TWO ; } if ( acknowledgements == 1 ) { return DefaultConsistencyLevel . ONE ; } // Edge case: EACH_QUORUM does not report a global number of alive replicas // so even if we get 0 alive replicas, there might be // a node up in some other datacenter, so retry at ONE. if ( current == DefaultConsistencyLevel . EACH_QUORUM ) { return DefaultConsistencyLevel . ONE ; } throw original ; }
Downgrades the current consistency level to the highest level that is likely to succeed given the number of acknowledgements received . Rethrows the original exception if the current consistency level cannot be downgraded any further .