Search in sources :

Example 6 with CorruptedDataStructureException

use of org.apache.ignite.internal.processors.cache.persistence.CorruptedDataStructureException in project ignite by apache.

the class BPlusTree method findLast.

/**
 * Returns a value mapped to the greatest key, or {@code null} if tree is empty or no entry matches the passed filter.
 * @param c Filter closure.
 * @return Value.
 * @throws IgniteCheckedException If failed.
 */
public T findLast(final TreeRowClosure<L, T> c) throws IgniteCheckedException {
    checkDestroyed();
    Get g = null;
    try {
        if (c == null) {
            g = new GetOne(null, null, null, true);
            doFind(g);
            return (T) g.row;
        } else {
            GetLast gLast = new GetLast(c);
            g = gLast;
            return gLast.find();
        }
    } catch (CorruptedDataStructureException e) {
        throw e;
    } catch (IgniteCheckedException e) {
        throw new IgniteCheckedException("Runtime failure on last row lookup", e);
    } catch (RuntimeException | AssertionError e) {
        Get g0 = g;
        long[] pageIds = pages(g == null, () -> new long[] { g0.pageId });
        throw corruptedTreeException("Runtime failure on last row lookup", e, grpId, pageIds);
    } finally {
        checkDestroyed();
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) RETRY_ROOT(org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree.Result.RETRY_ROOT) CorruptedDataStructureException(org.apache.ignite.internal.processors.cache.persistence.CorruptedDataStructureException)

Example 7 with CorruptedDataStructureException

use of org.apache.ignite.internal.processors.cache.persistence.CorruptedDataStructureException in project ignite by apache.

the class BPlusTree method doRemove.

/**
 * @param row Lookup row.
 * @param needOld {@code True} if need return removed row.
 * @return Removed row.
 * @throws IgniteCheckedException If failed.
 */
private T doRemove(L row, boolean needOld) throws IgniteCheckedException {
    assert !sequentialWriteOptsEnabled;
    checkDestroyed();
    Remove r = new Remove(row, needOld);
    try {
        for (; ; ) {
            r.init();
            Result res = removeDown(r, r.rootId, 0L, 0L, r.rootLvl);
            switch(res) {
                case RETRY:
                case RETRY_ROOT:
                    checkInterrupted();
                    continue;
                default:
                    if (!r.isFinished()) {
                        res = r.finishTail();
                        // If not found, then the tree grew beyond our call stack -> retry from the actual root.
                        if (res == RETRY || res == NOT_FOUND) {
                            assert r.checkTailLevel(getRootLevel()) : "tail=" + r.tail + ", res=" + res;
                            checkInterrupted();
                            continue;
                        }
                        assert res == FOUND : res;
                    }
                    assert r.isFinished();
                    return r.rmvd;
            }
        }
    } catch (CorruptedDataStructureException e) {
        throw e;
    } catch (IgniteCheckedException e) {
        throw new IgniteCheckedException("Runtime failure on search row: " + row, e);
    } catch (RuntimeException | AssertionError e) {
        throw corruptedTreeException("Runtime failure on search row: " + row, e, grpId, r.pageId);
    } finally {
        r.releaseAll();
        checkDestroyed();
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) CorruptedDataStructureException(org.apache.ignite.internal.processors.cache.persistence.CorruptedDataStructureException)

Example 8 with CorruptedDataStructureException

use of org.apache.ignite.internal.processors.cache.persistence.CorruptedDataStructureException in project ignite by apache.

the class BPlusTree method iterate.

/**
 * @param lower Lower bound inclusive.
 * @param upper Upper bound inclusive.
 * @param c Closure applied for all found items, iteration is stopped if closure returns {@code false}.
 * @throws IgniteCheckedException If failed.
 */
public void iterate(L lower, L upper, TreeRowClosure<L, T> c) throws IgniteCheckedException {
    checkDestroyed();
    ClosureCursor cursor = new ClosureCursor(lower, upper, c);
    try {
        cursor.iterate();
    } catch (CorruptedDataStructureException e) {
        throw e;
    } catch (IgniteCheckedException e) {
        throw new IgniteCheckedException("Runtime failure on bounds: [lower=" + lower + ", upper=" + upper + "]", e);
    } catch (RuntimeException | AssertionError e) {
        throw corruptedTreeException("Runtime failure on bounds: [lower=" + lower + ", upper=" + upper + "]", e, grpId, pages(cursor.getCursor != null, () -> new long[] { cursor.getCursor.pageId }));
    } finally {
        checkDestroyed();
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) CorruptedDataStructureException(org.apache.ignite.internal.processors.cache.persistence.CorruptedDataStructureException)

Example 9 with CorruptedDataStructureException

use of org.apache.ignite.internal.processors.cache.persistence.CorruptedDataStructureException in project ignite by apache.

the class BPlusTree method find.

/**
 * @param lower Lower bound or {@code null} if unbounded.
 * @param upper Upper bound or {@code null} if unbounded.
 * @param lowIncl {@code true} if lower bound is inclusive.
 * @param upIncl {@code true} if upper bound is inclusive.
 * @param c Filter closure.
 * @param x Implementation specific argument, {@code null} always means that we need to return full detached data row.
 * @return Cursor.
 * @throws IgniteCheckedException If failed.
 */
public GridCursor<T> find(L lower, L upper, boolean lowIncl, boolean upIncl, TreeRowClosure<L, T> c, Object x) throws IgniteCheckedException {
    checkDestroyed();
    ForwardCursor cursor = new ForwardCursor(lower, upper, lowIncl, upIncl, c, x);
    try {
        if (lower == null)
            return findLowerUnbounded(upper, upIncl, c, x);
        cursor.find();
        return cursor;
    } catch (CorruptedDataStructureException e) {
        throw e;
    } catch (IgniteCheckedException e) {
        throw new IgniteCheckedException("Runtime failure on bounds: [lower=" + lower + ", upper=" + upper + "]", e);
    } catch (RuntimeException | AssertionError e) {
        long[] pageIds = pages(lower == null || cursor == null || cursor.getCursor == null, () -> new long[] { cursor.getCursor.pageId });
        throw corruptedTreeException("Runtime failure on bounds: [lower=" + lower + ", upper=" + upper + "]", e, grpId, pageIds);
    } finally {
        checkDestroyed();
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) CorruptedDataStructureException(org.apache.ignite.internal.processors.cache.persistence.CorruptedDataStructureException)

Example 10 with CorruptedDataStructureException

use of org.apache.ignite.internal.processors.cache.persistence.CorruptedDataStructureException in project ignite by apache.

the class BPlusTree method invoke.

/**
 * {@inheritDoc}
 */
@Override
public void invoke(L row, Object z, InvokeClosure<T> c) throws IgniteCheckedException {
    checkDestroyed();
    Invoke x = new Invoke(row, z, c);
    try {
        for (; ; ) {
            x.init();
            Result res = invokeDown(x, x.rootId, 0L, 0L, x.rootLvl);
            switch(res) {
                case RETRY:
                case RETRY_ROOT:
                    checkInterrupted();
                    continue;
                default:
                    if (!x.isFinished()) {
                        res = x.tryFinish();
                        if (res == RETRY || res == RETRY_ROOT) {
                            checkInterrupted();
                            continue;
                        }
                        assert x.isFinished() : res;
                    }
                    return;
            }
        }
    } catch (UnregisteredClassException | UnregisteredBinaryTypeException | CorruptedDataStructureException e) {
        throw e;
    } catch (IgniteCheckedException e) {
        throw new IgniteCheckedException("Runtime failure on search row: " + row, e);
    } catch (RuntimeException | AssertionError e) {
        throw corruptedTreeException("Runtime failure on search row: " + row, e, grpId, x.pageId);
    } finally {
        x.releaseAll();
        checkDestroyed();
    }
}
Also used : UnregisteredClassException(org.apache.ignite.internal.UnregisteredClassException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) UnregisteredBinaryTypeException(org.apache.ignite.internal.UnregisteredBinaryTypeException) CorruptedDataStructureException(org.apache.ignite.internal.processors.cache.persistence.CorruptedDataStructureException)

Aggregations

CorruptedDataStructureException (org.apache.ignite.internal.processors.cache.persistence.CorruptedDataStructureException)10 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)8 File (java.io.File)1 UnregisteredBinaryTypeException (org.apache.ignite.internal.UnregisteredBinaryTypeException)1 UnregisteredClassException (org.apache.ignite.internal.UnregisteredClassException)1 CacheGroupContext (org.apache.ignite.internal.processors.cache.CacheGroupContext)1 RETRY_ROOT (org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree.Result.RETRY_ROOT)1 DEFAULT_PAGE_IO_RESOLVER (org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIoResolver.DEFAULT_PAGE_IO_RESOLVER)1 DiagnosticProcessor (org.apache.ignite.internal.processors.diagnostic.DiagnosticProcessor)1