Skip to content

Commit

Permalink
Rename PageCacheMonitor to PageCacheCounters
Browse files Browse the repository at this point in the history
This change will remove confusions since the "PageCacheMonitor" wasn't
really a monitor in the sense of the Monitors framework.
  • Loading branch information
davidegrohmann committed Jan 18, 2016
1 parent 27efdf4 commit f24af6d
Show file tree
Hide file tree
Showing 14 changed files with 129 additions and 129 deletions.
Expand Up @@ -22,7 +22,7 @@
import javax.management.NotCompliantMBeanException; import javax.management.NotCompliantMBeanException;


import org.neo4j.helpers.Service; import org.neo4j.helpers.Service;
import org.neo4j.io.pagecache.monitoring.PageCacheMonitor; import org.neo4j.io.pagecache.monitoring.PageCacheCounters;
import org.neo4j.jmx.impl.ManagementBeanProvider; import org.neo4j.jmx.impl.ManagementBeanProvider;
import org.neo4j.jmx.impl.ManagementData; import org.neo4j.jmx.impl.ManagementData;
import org.neo4j.jmx.impl.Neo4jMBean; import org.neo4j.jmx.impl.Neo4jMBean;
Expand All @@ -44,72 +44,72 @@ protected Neo4jMBean createMBean( ManagementData management ) throws NotComplian


private static class PageCacheImpl extends Neo4jMBean implements PageCache private static class PageCacheImpl extends Neo4jMBean implements PageCache
{ {
private final PageCacheMonitor pageCacheMonitor; private final PageCacheCounters pageCacheCounters;


PageCacheImpl( ManagementData management ) throws NotCompliantMBeanException PageCacheImpl( ManagementData management ) throws NotCompliantMBeanException
{ {
super( management ); super( management );
this.pageCacheMonitor = management.resolveDependency( PageCacheMonitor.class ); this.pageCacheCounters = management.resolveDependency( PageCacheCounters.class );
} }


@Override @Override
public long getFaults() public long getFaults()
{ {
return pageCacheMonitor.countFaults(); return pageCacheCounters.faults();
} }


@Override @Override
public long getEvictions() public long getEvictions()
{ {
return pageCacheMonitor.countEvictions(); return pageCacheCounters.evictions();
} }


@Override @Override
public long getPins() public long getPins()
{ {
return pageCacheMonitor.countPins(); return pageCacheCounters.pins();
} }


@Override @Override
public long getUnpins() public long getUnpins()
{ {
return pageCacheMonitor.countUnpins(); return pageCacheCounters.unpins();
} }


@Override @Override
public long getFlushes() public long getFlushes()
{ {
return pageCacheMonitor.countFlushes(); return pageCacheCounters.flushes();
} }


@Override @Override
public long getBytesRead() public long getBytesRead()
{ {
return pageCacheMonitor.countBytesRead(); return pageCacheCounters.bytesRead();
} }


@Override @Override
public long getBytesWritten() public long getBytesWritten()
{ {
return pageCacheMonitor.countBytesWritten(); return pageCacheCounters.bytesWritten();
} }


@Override @Override
public long getFileMappings() public long getFileMappings()
{ {
return pageCacheMonitor.countFilesMapped(); return pageCacheCounters.filesMapped();
} }


@Override @Override
public long getFileUnmappings() public long getFileUnmappings()
{ {
return pageCacheMonitor.countFilesUnmapped(); return pageCacheCounters.filesUnmapped();
} }


@Override @Override
public long getEvictionExceptions() public long getEvictionExceptions()
{ {
return pageCacheMonitor.countEvictionExceptions(); return pageCacheCounters.evictionExceptions();
} }
} }
} }
Expand Up @@ -20,58 +20,58 @@
package org.neo4j.io.pagecache.monitoring; package org.neo4j.io.pagecache.monitoring;


/** /**
* The PageCacheMonitor exposes internal counters from the page cache. * The PageCacheCounters exposes internal counters from the page cache.
* The data for these counters is sourced through the PageCacheTracer API. * The data for these counters is sourced through the PageCacheTracer API.
*/ */
public interface PageCacheMonitor public interface PageCacheCounters
{ {
/** /**
* @return The number of page faults observed thus far. * @return The number of page faults observed thus far.
*/ */
public long countFaults(); long faults();


/** /**
* @return The number of page evictions observed thus far. * @return The number of page evictions observed thus far.
*/ */
public long countEvictions(); long evictions();


/** /**
* @return The number of page pins observed thus far. * @return The number of page pins observed thus far.
*/ */
public long countPins(); long pins();


/** /**
* @return The number of page unpins observed thus far. * @return The number of page unpins observed thus far.
*/ */
public long countUnpins(); long unpins();


/** /**
* @return The number of page flushes observed thus far. * @return The number of page flushes observed thus far.
*/ */
public long countFlushes(); long flushes();


/** /**
* @return The sum total of bytes read in through page faults thus far. * @return The sum total of bytes read in through page faults thus far.
*/ */
public long countBytesRead(); long bytesRead();


/** /**
* @return The sum total of bytes written through flushes thus far. * @return The sum total of bytes written through flushes thus far.
*/ */
public long countBytesWritten(); long bytesWritten();


/** /**
* @return The number of file mappings observed thus far. * @return The number of file mappings observed thus far.
*/ */
public long countFilesMapped(); long filesMapped();


/** /**
* @return The number of file unmappings observed thus far. * @return The number of file unmappings observed thus far.
*/ */
public long countFilesUnmapped(); long filesUnmapped();


/** /**
* @return The number of page evictions that have thrown exceptions thus far. * @return The number of page evictions that have thrown exceptions thus far.
*/ */
public long countEvictionExceptions(); long evictionExceptions();
} }
Expand Up @@ -325,61 +325,61 @@ public MajorFlushEvent beginCacheFlush()
} }


@Override @Override
public long countFaults() public long faults()
{ {
return faults.get(); return faults.get();
} }


@Override @Override
public long countEvictions() public long evictions()
{ {
return evictions.get(); return evictions.get();
} }


@Override @Override
public long countPins() public long pins()
{ {
return pins.get(); return pins.get();
} }


@Override @Override
public long countUnpins() public long unpins()
{ {
return unpins.get(); return unpins.get();
} }


@Override @Override
public long countFlushes() public long flushes()
{ {
return flushes.get(); return flushes.get();
} }


@Override @Override
public long countBytesRead() public long bytesRead()
{ {
return bytesRead.get(); return bytesRead.get();
} }


@Override @Override
public long countBytesWritten() public long bytesWritten()
{ {
return bytesWritten.get(); return bytesWritten.get();
} }


@Override @Override
public long countFilesMapped() public long filesMapped()
{ {
return filesMapped.get(); return filesMapped.get();
} }


@Override @Override
public long countFilesUnmapped() public long filesUnmapped()
{ {
return filesUnmapped.get(); return filesUnmapped.get();
} }


@Override @Override
public long countEvictionExceptions() public long evictionExceptions()
{ {
return evictionExceptions.get(); return evictionExceptions.get();
} }
Expand Down
Expand Up @@ -22,14 +22,14 @@
import java.io.File; import java.io.File;


import org.neo4j.io.pagecache.PageSwapper; import org.neo4j.io.pagecache.PageSwapper;
import org.neo4j.io.pagecache.monitoring.PageCacheMonitor; import org.neo4j.io.pagecache.monitoring.PageCacheCounters;


/** /**
* A PageCacheTracer receives a steady stream of events and data about what * A PageCacheTracer receives a steady stream of events and data about what
* the page cache is doing. Implementations of this interface should be as * the page cache is doing. Implementations of this interface should be as
* efficient as possible, lest they severely slow down the page cache. * efficient as possible, lest they severely slow down the page cache.
*/ */
public interface PageCacheTracer extends PageCacheMonitor public interface PageCacheTracer extends PageCacheCounters
{ {
/** /**
* A PageCacheTracer that does nothing other than return the NULL variants of the companion interfaces. * A PageCacheTracer that does nothing other than return the NULL variants of the companion interfaces.
Expand Down Expand Up @@ -71,61 +71,61 @@ public MajorFlushEvent beginCacheFlush()
} }


@Override @Override
public long countFaults() public long faults()
{ {
return 0; return 0;
} }


@Override @Override
public long countEvictions() public long evictions()
{ {
return 0; return 0;
} }


@Override @Override
public long countPins() public long pins()
{ {
return 0; return 0;
} }


@Override @Override
public long countUnpins() public long unpins()
{ {
return 0; return 0;
} }


@Override @Override
public long countFlushes() public long flushes()
{ {
return 0; return 0;
} }


@Override @Override
public long countBytesRead() public long bytesRead()
{ {
return 0; return 0;
} }


@Override @Override
public long countBytesWritten() public long bytesWritten()
{ {
return 0; return 0;
} }


@Override @Override
public long countFilesMapped() public long filesMapped()
{ {
return 0; return 0;
} }


@Override @Override
public long countFilesUnmapped() public long filesUnmapped()
{ {
return 0; return 0;
} }


@Override @Override
public long countEvictionExceptions() public long evictionExceptions()
{ {
return 0; return 0;
} }
Expand All @@ -149,7 +149,7 @@ public String toString()


/** /**
* A background eviction has begun. Called from the background eviction thread. * A background eviction has begun. Called from the background eviction thread.
* *
* This call will be paired with a following PageCacheTracer#endPageEviction call. * This call will be paired with a following PageCacheTracer#endPageEviction call.
* *
* The method returns an EvictionRunEvent to represent the event of this eviction run. * The method returns an EvictionRunEvent to represent the event of this eviction run.
Expand Down
Expand Up @@ -1929,14 +1929,14 @@ public void tracerMustBeNotifiedAboutPinUnpinFaultAndEvictEventsWhenReading() th
} }
} }


assertThat( "wrong count of pins", tracer.countPins(), is( countedPages * 2 ) ); assertThat( "wrong count of pins", tracer.pins(), is( countedPages * 2 ) );
assertThat( "wrong count of unpins", tracer.countUnpins(), is( countedPages * 2 ) ); assertThat( "wrong count of unpins", tracer.unpins(), is( countedPages * 2 ) );


// We might be unlucky and fault in the second next call, on the page // We might be unlucky and fault in the second next call, on the page
// we brought up in the first next call. That's why we assert that we // we brought up in the first next call. That's why we assert that we
// have observed *at least* the countedPages number of faults. // have observed *at least* the countedPages number of faults.
long faults = tracer.countFaults(); long faults = tracer.faults();
long bytesRead = tracer.countBytesRead(); long bytesRead = tracer.bytesRead();
assertThat( "wrong count of faults", faults, greaterThanOrEqualTo( countedPages ) ); assertThat( "wrong count of faults", faults, greaterThanOrEqualTo( countedPages ) );
assertThat( "wrong number of bytes read", assertThat( "wrong number of bytes read",
bytesRead, greaterThanOrEqualTo( countedPages * filePageSize ) ); bytesRead, greaterThanOrEqualTo( countedPages * filePageSize ) );
Expand All @@ -1945,7 +1945,7 @@ public void tracerMustBeNotifiedAboutPinUnpinFaultAndEvictEventsWhenReading() th
// block and get a page directly transferred to it, and these kinds of // block and get a page directly transferred to it, and these kinds of
// evictions can count in addition to the evictions we do when the // evictions can count in addition to the evictions we do when the
// cache is behind on keeping the freelist full. // cache is behind on keeping the freelist full.
assertThat( "wrong count of evictions", tracer.countEvictions(), assertThat( "wrong count of evictions", tracer.evictions(),
both( greaterThanOrEqualTo( countedPages - maxPages ) ) both( greaterThanOrEqualTo( countedPages - maxPages ) )
.and( lessThanOrEqualTo( countedPages + faults ) ) ); .and( lessThanOrEqualTo( countedPages + faults ) ) );
} }
Expand All @@ -1972,20 +1972,20 @@ public void tracerMustBeNotifiedAboutPinUnpinFaultFlushAndEvictionEventsWhenWrit
} }
} }


assertThat( "wrong count of pins", tracer.countPins(), is( pagesToGenerate * 2 ) ); assertThat( "wrong count of pins", tracer.pins(), is( pagesToGenerate * 2 ) );
assertThat( "wrong count of unpins", tracer.countUnpins(), is( pagesToGenerate * 2 ) ); assertThat( "wrong count of unpins", tracer.unpins(), is( pagesToGenerate * 2 ) );


// We might be unlucky and fault in the second next call, on the page // We might be unlucky and fault in the second next call, on the page
// we brought up in the first next call. That's why we assert that we // we brought up in the first next call. That's why we assert that we
// have observed *at least* the countedPages number of faults. // have observed *at least* the countedPages number of faults.
long faults = tracer.countFaults(); long faults = tracer.faults();
assertThat( "wrong count of faults", faults, greaterThanOrEqualTo( pagesToGenerate ) ); assertThat( "wrong count of faults", faults, greaterThanOrEqualTo( pagesToGenerate ) );
// Every page we move forward can put the freelist behind so the cache // Every page we move forward can put the freelist behind so the cache
// wants to evict more pages. Plus, every page fault we do could also // wants to evict more pages. Plus, every page fault we do could also
// block and get a page directly transferred to it, and these kinds of // block and get a page directly transferred to it, and these kinds of
// evictions can count in addition to the evictions we do when the // evictions can count in addition to the evictions we do when the
// cache is behind on keeping the freelist full. // cache is behind on keeping the freelist full.
assertThat( "wrong count of evictions", tracer.countEvictions(), assertThat( "wrong count of evictions", tracer.evictions(),
both( greaterThanOrEqualTo( pagesToGenerate - maxPages ) ) both( greaterThanOrEqualTo( pagesToGenerate - maxPages ) )
.and( lessThanOrEqualTo( pagesToGenerate + faults ) ) ); .and( lessThanOrEqualTo( pagesToGenerate + faults ) ) );


Expand All @@ -1996,8 +1996,8 @@ public void tracerMustBeNotifiedAboutPinUnpinFaultFlushAndEvictionEventsWhenWrit
// We also subtract 'maxPages' from the expected flush count, because // We also subtract 'maxPages' from the expected flush count, because
// vectored IO may coalesce all the flushes we do as part of unmapping // vectored IO may coalesce all the flushes we do as part of unmapping
// the file, into a single flush. // the file, into a single flush.
long flushes = tracer.countFlushes(); long flushes = tracer.flushes();
long bytesWritten = tracer.countBytesWritten(); long bytesWritten = tracer.bytesWritten();
assertThat( "wrong count of flushes", assertThat( "wrong count of flushes",
flushes, greaterThanOrEqualTo( pagesToGenerate - maxPages ) ); flushes, greaterThanOrEqualTo( pagesToGenerate - maxPages ) );
assertThat( "wrong count of bytes written", assertThat( "wrong count of bytes written",
Expand Down

0 comments on commit f24af6d

Please sign in to comment.