com.amazon.carbonado.spi
Class RepairExecutor

java.lang.Object
  extended by com.amazon.carbonado.spi.RepairExecutor

public class RepairExecutor
extends Object

A convenience class for repositories to run dynamic repairs in separate threads. When a repository detects a consistency error during a user operation, it should not perform the repair in the same thread.

If the repair was initiated by an exception, but the original exception is re-thrown, a transaction exit will rollback the repair! Executing the repair in a separate thread allows it to wait until the transaction has exited.

Other kinds of inconsistencies might be detected during cursor iteration. The repair will need to acquire write locks, but the open cursor might not allow that, resulting in deadlock. Executing the repair in a separate thread allows it to wait until the cursor has released locks.

This class keeps thread-local references to single-threaded executors. In other words, each user thread has at most one associated repair thread. Each repair thread has a fixed size queue, and they exit when they are idle. If the queue is full, newly added repair tasks are silently discarded.

The following system properties are supported:

Author:
Brian S O'Neill

Method Summary
static void execute(Runnable repair)
           
static boolean waitForRepairsToFinish(long timeoutMillis)
          Waits for repairs that were executed from the current thread to finish.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

execute

public static void execute(Runnable repair)

waitForRepairsToFinish

public static boolean waitForRepairsToFinish(long timeoutMillis)
                                      throws InterruptedException
Waits for repairs that were executed from the current thread to finish.

Returns:
true if all repairs are finished
Throws:
InterruptedException


Copyright © 2006-2009 Amazon Technologies, Inc.. All Rights Reserved.