Skip to content

Commit

Permalink
Refactor linear page cache history tracer to have separate tracers fo…
Browse files Browse the repository at this point in the history
…r global and cursor local events.

Add support for cursor events tracers.
  • Loading branch information
MishaDemianenko committed Feb 27, 2017
1 parent ffdd85c commit 597773e
Show file tree
Hide file tree
Showing 10 changed files with 657 additions and 514 deletions.
Expand Up @@ -40,9 +40,9 @@
import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.io.pagecache.tracing.PageCacheTracer;
import org.neo4j.io.pagecache.tracing.cursor.PageCursorTracerSupplier;
import org.neo4j.test.LinearHistoryPageCacheTracer;
import org.neo4j.io.pagecache.tracing.linear.LinearHistoryTracerFactory;
import org.neo4j.io.pagecache.tracing.linear.LinearTracers;
import org.neo4j.test.rule.RepeatRule;
import org.neo4j.test.LinearHistoryPageCursorTracer;

import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
Expand Down Expand Up @@ -454,9 +454,9 @@ public void pageCacheMustRemainInternallyConsistentWhenGettingRandomFailures() t

// Because our test failures are non-deterministic, we use this tracer to capture a full history of the
// events leading up to any given failure.
LinearHistoryPageCacheTracer tracer = new LinearHistoryPageCacheTracer();
//TODO:sdfasdf
getPageCache( fs, maxPages, pageCachePageSize, tracer, LinearHistoryPageCursorTracer::new );
LinearTracers linearTracers = LinearHistoryTracerFactory.pageCacheTracer();
getPageCache( fs, maxPages, pageCachePageSize, linearTracers.getPageCacheTracer(),
linearTracers.getCursorTracerSupplier() );

PagedFile pfA = pageCache.map( existingFile( "a" ), filePageSize );
PagedFile pfB = pageCache.map( existingFile( "b" ), filePageSize / 2 + 1 );
Expand Down Expand Up @@ -525,7 +525,7 @@ public void pageCacheMustRemainInternallyConsistentWhenGettingRandomFailures() t
}
catch ( Throwable e )
{
tracer.printHistory( System.err );
linearTracers.printHistory( System.err );
throw e;
}
}
Expand Down
Expand Up @@ -44,7 +44,10 @@
import org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory;
import org.neo4j.io.pagecache.impl.muninn.MuninnPageCache;
import org.neo4j.io.pagecache.tracing.PageCacheTracer;
import org.neo4j.io.pagecache.tracing.cursor.DefaultPageCursorTracerSupplier;
import org.neo4j.io.pagecache.tracing.cursor.PageCursorTracerSupplier;
import org.neo4j.io.pagecache.tracing.linear.LinearHistoryPageCacheTracerTest;
import org.neo4j.io.pagecache.tracing.linear.LinearTracers;

/**
* The RandomPageCacheTestHarness can plan and run random page cache tests, repeatably if necessary, and verify that
Expand All @@ -54,7 +57,7 @@
* before and after executing the planned test respectively, and it can integrate with the adversarial file system
* for fault injection, and arbitrary PageCacheTracers.
*
* See {@link org.neo4j.test.LinearHistoryPageCacheTracerTest} for an example of how to configure and use the harness.
* See {@link LinearHistoryPageCacheTracerTest} for an example of how to configure and use the harness.
*/
public class RandomPageCacheTestHarness implements Closeable
{
Expand Down Expand Up @@ -92,7 +95,7 @@ public RandomPageCacheTestHarness()
filePageCount = cachePageCount * 10;
filePageSize = cachePageSize;
tracer = PageCacheTracer.NULL;
cursorTracerSupplier = PageCursorTracerSupplier.NULL;
cursorTracerSupplier = DefaultPageCursorTracerSupplier.INSTANCE;
commandCount = 1000;

Command[] commands = Command.values();
Expand Down Expand Up @@ -150,6 +153,14 @@ public void setTracer( PageCacheTracer tracer )
this.tracer = tracer;
}

/**
* Set the page cursor tracers supplier.
*/
public void setCursorTracerSupplier( PageCursorTracerSupplier cursorTracerSupplier )
{
this.cursorTracerSupplier = cursorTracerSupplier;
}

/**
* Set the mischief rate for the adversarial file system.
*/
Expand Down Expand Up @@ -227,7 +238,7 @@ public void setCommandCount( int commandCount )
/**
* Set the preparation phase to use. This phase is executed before all the planned commands. It can be used to
* prepare some file contents, or reset some external state, such as the
* {@link org.neo4j.test.LinearHistoryPageCacheTracer}.
* {@link LinearTracers}.
*
* The preparation phase is executed before each iteration.
*/
Expand Down

This file was deleted.

0 comments on commit 597773e

Please sign in to comment.