Search in sources :

Example 6 with IgniteInternalCheckedException

use of org.apache.ignite.lang.IgniteInternalCheckedException in project ignite-3 by apache.

the class BplusTree method findOne.

/**
 * Returns found result or {@code null}.
 *
 * @param row Lookup row for exact match.
 * @param x Implementation specific argument, {@code null} always means that we need to return full detached data row.
 * @throws IgniteInternalCheckedException If failed.
 */
@Nullable
public final <R> R findOne(L row, @Nullable TreeRowClosure<L, T> c, Object x) throws IgniteInternalCheckedException {
    checkDestroyed();
    GetOne g = new GetOne(row, c, x, false);
    try {
        doFind(g);
        return (R) g.row;
    } catch (CorruptedDataStructureException e) {
        throw e;
    } catch (IgniteInternalCheckedException e) {
        throw new IgniteInternalCheckedException("Runtime failure on lookup row: " + row, e);
    } catch (RuntimeException | AssertionError e) {
        throw corruptedTreeException("Runtime failure on lookup row: " + row, e, grpId, g.pageId);
    } finally {
        checkDestroyed();
    }
}
Also used : IgniteInternalCheckedException(org.apache.ignite.lang.IgniteInternalCheckedException) CorruptedDataStructureException(org.apache.ignite.internal.pagememory.CorruptedDataStructureException) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with IgniteInternalCheckedException

use of org.apache.ignite.lang.IgniteInternalCheckedException in project ignite-3 by apache.

the class BplusTree method find.

/**
 * Getting the cursor through the rows of the tree.
 *
 * @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 IgniteInternalCheckedException If failed.
 */
public IgniteCursor<T> find(@Nullable L lower, @Nullable L upper, boolean lowIncl, boolean upIncl, TreeRowClosure<L, T> c, @Nullable Object x) throws IgniteInternalCheckedException {
    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 (IgniteInternalCheckedException e) {
        throw new IgniteInternalCheckedException("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 : IgniteInternalCheckedException(org.apache.ignite.lang.IgniteInternalCheckedException) CorruptedDataStructureException(org.apache.ignite.internal.pagememory.CorruptedDataStructureException)

Example 8 with IgniteInternalCheckedException

use of org.apache.ignite.lang.IgniteInternalCheckedException in project ignite-3 by apache.

the class RandomLruPageReplacementPolicy method isStoreMetadataPage.

/**
 * Return {@code true} if page is related to metadata.
 *
 * @param absPageAddr Absolute page address
 */
private boolean isStoreMetadataPage(long absPageAddr) {
    try {
        long dataAddr = absPageAddr + PAGE_OVERHEAD;
        PageIo io = seg.ioRegistry().resolve(dataAddr);
        return io instanceof PagesListMetaIo;
    } catch (IgniteInternalCheckedException ignored) {
        return false;
    }
}
Also used : IgniteInternalCheckedException(org.apache.ignite.lang.IgniteInternalCheckedException) PagesListMetaIo(org.apache.ignite.internal.pagememory.freelist.io.PagesListMetaIo) PageIo(org.apache.ignite.internal.pagememory.io.PageIo)

Example 9 with IgniteInternalCheckedException

use of org.apache.ignite.lang.IgniteInternalCheckedException in project ignite-3 by apache.

the class PageIo method printPage.

/**
 * Returns a string representation of pages content.
 *
 * @param pageIoRegistry Page IO Registry.
 * @param pageAddr Page address.
 * @param pageSize Page size.
 */
public static String printPage(PageIoRegistry pageIoRegistry, long pageAddr, int pageSize) {
    IgniteStringBuilder sb = new IgniteStringBuilder("Header [\n\ttype=");
    try {
        PageIo io = pageIoRegistry.resolve(pageAddr);
        sb.app(getType(pageAddr)).app(" (").app(io.getClass().getSimpleName()).app("),\n\tver=").app(getVersion(pageAddr)).app(",\n\tcrc=").app(getCrc(pageAddr)).app(",\n\t").app(PageIdUtils.toDetailString(getPageId(pageAddr))).app("\n],\n");
        if (getCompressionType(pageAddr) != 0) {
            sb.app("CompressedPage[\n\tcompressionType=").app(getCompressionType(pageAddr)).app(",\n\tcompressedSize=").app(getCompressedSize(pageAddr)).app(",\n\tcompactedSize=").app(getCompactedSize(pageAddr)).app("\n]");
        } else {
            io.printPage(pageAddr, pageSize, sb);
        }
    } catch (IgniteInternalCheckedException e) {
        sb.app("Failed to print page: ").app(e.getMessage());
    }
    return sb.toString();
}
Also used : IgniteInternalCheckedException(org.apache.ignite.lang.IgniteInternalCheckedException) IgniteStringBuilder(org.apache.ignite.lang.IgniteStringBuilder)

Example 10 with IgniteInternalCheckedException

use of org.apache.ignite.lang.IgniteInternalCheckedException in project ignite-3 by apache.

the class BplusTree method doPut.

/**
 * Does a put.
 *
 * @param row New value.
 * @param needOld {@code True} If need return old value.
 * @return Old row.
 * @throws IgniteInternalCheckedException If failed.
 */
private T doPut(T row, boolean needOld) throws IgniteInternalCheckedException {
    checkDestroyed();
    Put p = new Put(row, needOld);
    try {
        for (; ; ) {
            // Go down with retries.
            p.init();
            Result res = putDown(p, p.rootId, 0L, p.rootLvl);
            switch(res) {
                case RETRY:
                case RETRY_ROOT:
                    continue;
                case FOUND:
                    // We may need to perform an inner replace on the upper level.
                    if (!p.isFinished()) {
                        res = p.finishTail();
                        // If not found, then the root split has happened and operation should be retried from the actual root.
                        if (res == RETRY || res == NOT_FOUND) {
                            p.releaseTail();
                            assert p.checkTailLevel(getRootLevel()) : "tail=" + p.tail + ", res=" + res;
                            continue;
                        }
                    }
                    return p.oldRow;
                default:
                    throw new IllegalStateException("Result: " + res);
            }
        }
    } catch (CorruptedDataStructureException e) {
        throw e;
    } catch (IgniteInternalCheckedException e) {
        throw new IgniteInternalCheckedException("Runtime failure on row: " + row, e);
    } catch (RuntimeException | AssertionError e) {
        throw corruptedTreeException("Runtime failure on row: " + row, e, grpId, p.pageId);
    } finally {
        checkDestroyed();
    }
}
Also used : IgniteInternalCheckedException(org.apache.ignite.lang.IgniteInternalCheckedException) CorruptedDataStructureException(org.apache.ignite.internal.pagememory.CorruptedDataStructureException)

Aggregations

IgniteInternalCheckedException (org.apache.ignite.lang.IgniteInternalCheckedException)15 CorruptedDataStructureException (org.apache.ignite.internal.pagememory.CorruptedDataStructureException)8 Nullable (org.jetbrains.annotations.Nullable)3 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 Collections.emptyIterator (java.util.Collections.emptyIterator)2 Collections.shuffle (java.util.Collections.shuffle)2 Collections.singleton (java.util.Collections.singleton)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Map (java.util.Map)2 Queue (java.util.Queue)2 Random (java.util.Random)2 Set (java.util.Set)2 TreeMap (java.util.TreeMap)2 TreeSet (java.util.TreeSet)2 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)2 BlockingQueue (java.util.concurrent.BlockingQueue)2