Search in sources :

Example 1 with RangeTable

use of ezdb.table.range.RangeTable in project invesdwin-context-persistence by subes.

the class ADelegateRangeTable method getTableWithReadLock.

private RangeTable<H, R, V> getTableWithReadLock(final boolean forUpdate) {
    maybePurgeTable();
    // directly return table with read lock if not null
    final ILock readLock = getReadLock(forUpdate);
    readLock.lock();
    if (tableFinalizer.table != null) {
        return tableFinalizer.table;
    }
    readLock.unlock();
    if (!initializing.compareAndSet(false, true)) {
        while (initializing.get()) {
            FTimeUnit.MILLISECONDS.sleepNoInterrupt(1);
        }
        return getTableWithReadLock(forUpdate);
    } else {
        try {
            return new ARetryCallable<RangeTable<H, R, V>>(new RetryOriginator(ADelegateRangeTable.class, "initializeTableInitLocked", getName())) {

                @Override
                protected RangeTable<H, R, V> callRetry() throws Exception {
                    return initializeTableInitLocked(readLock);
                }
            }.call();
        } finally {
            initializing.set(false);
        }
    }
}
Also used : RetryOriginator(de.invesdwin.context.integration.retry.task.RetryOriginator) ILock(de.invesdwin.util.concurrent.lock.ILock) RetryLaterRuntimeException(de.invesdwin.context.integration.retry.RetryLaterRuntimeException) UnknownArgumentException(de.invesdwin.util.error.UnknownArgumentException) IOException(java.io.IOException) RangeTable(ezdb.table.range.RangeTable)

Aggregations

RetryLaterRuntimeException (de.invesdwin.context.integration.retry.RetryLaterRuntimeException)1 RetryOriginator (de.invesdwin.context.integration.retry.task.RetryOriginator)1 ILock (de.invesdwin.util.concurrent.lock.ILock)1 UnknownArgumentException (de.invesdwin.util.error.UnknownArgumentException)1 RangeTable (ezdb.table.range.RangeTable)1 IOException (java.io.IOException)1