Search in sources :

Example 16 with NonceKey

use of org.apache.hadoop.hbase.util.NonceKey in project hbase by apache.

the class ServerNonceManager method endOperation.

/**
 * Ends the operation started by startOperation.
 * @param group Nonce group.
 * @param nonce Nonce.
 * @param success Whether the operation has succeeded.
 */
public void endOperation(long group, long nonce, boolean success) {
    if (nonce == HConstants.NO_NONCE)
        return;
    NonceKey nk = new NonceKey(group, nonce);
    OperationContext newResult = nonces.get(nk);
    assert newResult != null;
    synchronized (newResult) {
        assert newResult.getState() == OperationContext.WAIT;
        // If we failed, other retries can proceed.
        newResult.setState(success ? OperationContext.DONT_PROCEED : OperationContext.PROCEED);
        if (success) {
            // Set time to use for cleanup.
            newResult.reportActivity();
        } else {
            OperationContext val = nonces.remove(nk);
            assert val == newResult;
        }
        if (newResult.hasWait()) {
            LOG.debug("Conflict with running op ended: " + nk + ", " + newResult);
            newResult.notifyAll();
        }
    }
}
Also used : NonceKey(org.apache.hadoop.hbase.util.NonceKey)

Aggregations

NonceKey (org.apache.hadoop.hbase.util.NonceKey)16 Test (org.junit.Test)4 IOException (java.io.IOException)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 InputStream (java.io.InputStream)1 UncheckedIOException (java.io.UncheckedIOException)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)1 InvalidFamilyOperationException (org.apache.hadoop.hbase.InvalidFamilyOperationException)1 ProcedureInfo (org.apache.hadoop.hbase.ProcedureInfo)1 TableName (org.apache.hadoop.hbase.TableName)1 Append (org.apache.hadoop.hbase.client.Append)1 Increment (org.apache.hadoop.hbase.client.Increment)1 Mutation (org.apache.hadoop.hbase.client.Mutation)1 PerClientRandomNonceGenerator (org.apache.hadoop.hbase.client.PerClientRandomNonceGenerator)1 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)1