Search in sources :

Example 1 with FlushEvent

use of org.neo4j.io.pagecache.tracing.FlushEvent in project neo4j by neo4j.

the class PageList method flushModifiedPage.

private static void flushModifiedPage(long pageRef, EvictionEvent evictionEvent, long filePageId, PageSwapper swapper, PageList pageReferenceTranslator) throws IOException {
    FlushEvent flushEvent = evictionEvent.beginFlush(pageRef, swapper, pageReferenceTranslator);
    try {
        long address = getAddress(pageRef);
        long bytesWritten = swapper.write(filePageId, address);
        explicitlyMarkPageUnmodifiedUnderExclusiveLock(pageRef);
        flushEvent.addBytesWritten(bytesWritten);
        flushEvent.addPagesFlushed(1);
        flushEvent.done();
    } catch (IOException e) {
        unlockExclusive(pageRef);
        flushEvent.done(e);
        evictionEvent.threwException(e);
        throw e;
    }
}
Also used : FlushEvent(org.neo4j.io.pagecache.tracing.FlushEvent) IOException(java.io.IOException)

Example 2 with FlushEvent

use of org.neo4j.io.pagecache.tracing.FlushEvent in project neo4j by neo4j.

the class MuninnPagedFile method vectoredFlush.

private void vectoredFlush(MuninnPage[] pages, int pagesGrabbed, FlushEventOpportunity flushOpportunity, boolean forClosing) throws IOException {
    FlushEvent flush = null;
    try {
        // Write the pages vector
        MuninnPage firstPage = pages[0];
        long startFilePageId = firstPage.getFilePageId();
        // we'll be able to write those changes out on the next flush.
        for (int j = 0; j < pagesGrabbed; j++) {
            // If the flush fails, we'll undo this
            pages[j].markAsClean();
        }
        flush = flushOpportunity.beginFlush(startFilePageId, firstPage.getCachePageId(), swapper);
        long bytesWritten = swapper.write(startFilePageId, pages, 0, pagesGrabbed);
        // Update the flush event
        flush.addBytesWritten(bytesWritten);
        flush.addPagesFlushed(pagesGrabbed);
        flush.done();
    // There are now 0 'grabbed' pages
    } catch (IOException ioe) {
        // Undo marking the pages as clean
        for (int j = 0; j < pagesGrabbed; j++) {
            pages[j].markAsDirty();
        }
        if (flush != null) {
            flush.done(ioe);
        }
        throw ioe;
    } finally {
        // Always unlock all the pages in the vector
        for (int j = 0; j < pagesGrabbed; j++) {
            if (forClosing) {
                pages[j].unlockExclusive();
            } else {
                pages[j].unlockFlush();
            }
        }
    }
}
Also used : MajorFlushEvent(org.neo4j.io.pagecache.tracing.MajorFlushEvent) FlushEvent(org.neo4j.io.pagecache.tracing.FlushEvent) IOException(java.io.IOException)

Example 3 with FlushEvent

use of org.neo4j.io.pagecache.tracing.FlushEvent in project neo4j by neo4j.

the class MuninnPage method doFlush.

private void doFlush(PageSwapper swapper, long filePageId, FlushEventOpportunity flushOpportunity) throws IOException {
    FlushEvent event = flushOpportunity.beginFlush(filePageId, getCachePageId(), swapper);
    try {
        long bytesWritten = swapper.write(filePageId, this);
        markAsClean();
        event.addBytesWritten(bytesWritten);
        event.done();
    } catch (IOException e) {
        event.done(e);
        throw e;
    }
}
Also used : FlushEvent(org.neo4j.io.pagecache.tracing.FlushEvent) IOException(java.io.IOException)

Example 4 with FlushEvent

use of org.neo4j.io.pagecache.tracing.FlushEvent in project neo4j by neo4j.

the class MuninnPagedFile method flushLockedPage.

boolean flushLockedPage(long pageRef, long filePageId) {
    boolean success = false;
    try (MajorFlushEvent flushEvent = pageCacheTracer.beginFileFlush(swapper)) {
        FlushEvent flush = flushEvent.beginFlush(pageRef, swapper, this);
        long address = getAddress(pageRef);
        try {
            long bytesWritten = swapper.write(filePageId, address);
            flush.addBytesWritten(bytesWritten);
            flush.addPagesFlushed(1);
            flush.done();
            success = true;
        } catch (IOException e) {
            flush.done(e);
        }
    }
    return success;
}
Also used : MajorFlushEvent(org.neo4j.io.pagecache.tracing.MajorFlushEvent) MajorFlushEvent(org.neo4j.io.pagecache.tracing.MajorFlushEvent) FlushEvent(org.neo4j.io.pagecache.tracing.FlushEvent) IOException(java.io.IOException)

Example 5 with FlushEvent

use of org.neo4j.io.pagecache.tracing.FlushEvent in project neo4j by neo4j.

the class MuninnPagedFile method vectoredFlush.

private void vectoredFlush(long[] pages, long[] bufferAddresses, long[] flushStamps, int[] bufferLengths, int numberOfBuffers, int pagesToFlush, int pagesMerged, MajorFlushEvent flushEvent, boolean forClosing) throws IOException {
    FlushEvent flush = null;
    boolean successful = false;
    try {
        // Write the pages vector
        long firstPageRef = pages[0];
        long startFilePageId = getFilePageId(firstPageRef);
        flush = flushEvent.beginFlush(pages, swapper, this, pagesToFlush, pagesMerged);
        long bytesWritten = swapper.write(startFilePageId, bufferAddresses, bufferLengths, numberOfBuffers, pagesToFlush);
        // Update the flush event
        flush.addBytesWritten(bytesWritten);
        flush.addPagesFlushed(pagesToFlush);
        flush.addPagesMerged(pagesMerged);
        flush.done();
        successful = true;
    // There are now 0 'grabbed' pages
    } catch (IOException ioe) {
        if (flush != null) {
            flush.done(ioe);
        }
        throw ioe;
    } finally {
        // Always unlock all the pages in the vector
        if (forClosing) {
            for (int i = 0; i < pagesToFlush; i++) {
                long pageRef = pages[i];
                if (successful) {
                    explicitlyMarkPageUnmodifiedUnderExclusiveLock(pageRef);
                }
                unlockExclusive(pageRef);
            }
        } else {
            for (int i = 0; i < pagesToFlush; i++) {
                unlockFlush(pages[i], flushStamps[i], successful);
            }
        }
    }
}
Also used : MajorFlushEvent(org.neo4j.io.pagecache.tracing.MajorFlushEvent) FlushEvent(org.neo4j.io.pagecache.tracing.FlushEvent) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)5 FlushEvent (org.neo4j.io.pagecache.tracing.FlushEvent)5 MajorFlushEvent (org.neo4j.io.pagecache.tracing.MajorFlushEvent)3