Skip to content

Commit

Permalink
Pure delegation from GBPTree.Monitor to SchemaIndex and LSS Monitors
Browse files Browse the repository at this point in the history
  • Loading branch information
burqen committed Jun 18, 2018
1 parent adff30b commit c46db9a
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 33 deletions.
Expand Up @@ -19,12 +19,12 @@
*/ */
package org.neo4j.kernel.api.index; package org.neo4j.kernel.api.index;


import java.util.Map; import java.util.StringJoiner;


import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.logging.Log; import org.neo4j.logging.Log;


import static java.lang.String.format; import static org.neo4j.helpers.Format.duration;


public class LoggingMonitor implements SchemaIndexProvider.Monitor public class LoggingMonitor implements SchemaIndexProvider.Monitor
{ {
Expand All @@ -42,12 +42,14 @@ public void failedToOpenIndex( long indexId, IndexDescriptor indexDescriptor, St
} }


@Override @Override
public void recoveryCompleted( long indexId, IndexDescriptor indexDescriptor, Map<String,Object> data ) public void recoveryCleanupFinished( long indexId, IndexDescriptor indexDescriptor,
long numberOfPagesVisited, long numberOfCleanedCrashPointers, long durationMillis )
{ {
StringBuilder builder = StringJoiner joiner =
new StringBuilder( new StringJoiner( ", ", "Schema index cleanup job finished: indexId: " + indexId + " descriptor: " + indexDescriptor.toString(), "" );
"Schema index recovery completed: indexId: " + indexId + " descriptor: " + indexDescriptor.toString() ); joiner.add( "Number of pages visited: " + numberOfPagesVisited );
data.forEach( ( key, value ) -> builder.append( format( " %s: %s", key, value ) ) ); joiner.add( "Number of cleaned crashed pointers: " + numberOfCleanedCrashPointers );
log.info( builder.toString() ); joiner.add( "Time spent: " + duration( durationMillis ) );
log.info( joiner.toString() );
} }
} }
Expand Up @@ -21,7 +21,6 @@


import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Map;


import org.neo4j.graphdb.ResourceIterator; import org.neo4j.graphdb.ResourceIterator;
import org.neo4j.helpers.collection.Iterators; import org.neo4j.helpers.collection.Iterators;
Expand Down Expand Up @@ -105,14 +104,16 @@ public void failedToOpenIndex( long indexId, IndexDescriptor indexDescriptor, St
} }


@Override @Override
public void recoveryCompleted( long indexId, IndexDescriptor indexDescriptor, Map<String,Object> data ) public void recoveryCleanupFinished( long indexId, IndexDescriptor indexDescriptor,
long numberOfPagesVisited, long numberOfCleanedCrashPointers, long durationMillis )
{ // no-op { // no-op
} }
} }


void failedToOpenIndex( long indexId, IndexDescriptor indexDescriptor, String action, Exception cause ); void failedToOpenIndex( long indexId, IndexDescriptor indexDescriptor, String action, Exception cause );


void recoveryCompleted( long indexId, IndexDescriptor indexDescriptor, Map<String,Object> data ); void recoveryCleanupFinished( long indexId, IndexDescriptor indexDescriptor,
long numberOfPagesVisited, long numberOfCleanedCrashPointers, long durationMillis );
} }


public static final SchemaIndexProvider NO_INDEX_PROVIDER = public static final SchemaIndexProvider NO_INDEX_PROVIDER =
Expand Down
Expand Up @@ -21,7 +21,6 @@


import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Map;


import org.neo4j.graphdb.ResourceIterator; import org.neo4j.graphdb.ResourceIterator;
import org.neo4j.io.pagecache.IOLimiter; import org.neo4j.io.pagecache.IOLimiter;
Expand Down Expand Up @@ -72,7 +71,7 @@ public void rebuilt( long roughNodeCount )
} }


@Override @Override
public void recoveryCompleted( Map<String,Object> data ) public void recoveryCleanupFinished( long numberOfPagesVisited, long numberOfCleanedCrashPointers, long durationMillis )
{ // empty { // empty
} }
} }
Expand All @@ -89,7 +88,7 @@ public void recoveryCompleted( Map<String,Object> data )


void rebuilt( long roughNodeCount ); void rebuilt( long roughNodeCount );


void recoveryCompleted( Map<String,Object> data ); void recoveryCleanupFinished( long numberOfPagesVisited, long numberOfCleanedCrashPointers, long durationMillis );
} }


/** /**
Expand Down
Expand Up @@ -19,12 +19,12 @@
*/ */
package org.neo4j.kernel.api.labelscan; package org.neo4j.kernel.api.labelscan;


import java.util.Map; import java.util.StringJoiner;


import org.neo4j.kernel.api.labelscan.LabelScanStore.Monitor; import org.neo4j.kernel.api.labelscan.LabelScanStore.Monitor;
import org.neo4j.logging.Log; import org.neo4j.logging.Log;


import static java.lang.String.format; import static org.neo4j.helpers.Format.duration;


/** /**
* Logs about important events about {@link LabelScanStore} {@link Monitor}. * Logs about important events about {@link LabelScanStore} {@link Monitor}.
Expand Down Expand Up @@ -69,10 +69,12 @@ public void rebuilt( long roughNodeCount )
} }


@Override @Override
public void recoveryCompleted( Map<String,Object> data ) public void recoveryCleanupFinished( long numberOfPagesVisited, long numberOfCleanedCrashPointers, long durationMillis )
{ {
StringBuilder builder = new StringBuilder( "Scan store recovery completed:" ); StringJoiner joiner = new StringJoiner( ", ", "Scan store recovery cleanup job finished:", "" );
data.forEach( ( key, value ) -> builder.append( format( " %s: %s", key, value ) ) ); joiner.add( "Number of pages visited: " + numberOfPagesVisited );
log.info( builder.toString() ); joiner.add( "Number of cleaned crashed pointers: " + numberOfCleanedCrashPointers );
joiner.add( "Time spent: " + duration( durationMillis ) );
log.info( joiner.toString() );
} }
} }
Expand Up @@ -48,10 +48,8 @@
import org.neo4j.kernel.monitoring.Monitors; import org.neo4j.kernel.monitoring.Monitors;
import org.neo4j.storageengine.api.schema.LabelScanReader; import org.neo4j.storageengine.api.schema.LabelScanReader;


import static org.neo4j.helpers.Format.duration;
import static org.neo4j.helpers.collection.Iterators.asResourceIterator; import static org.neo4j.helpers.collection.Iterators.asResourceIterator;
import static org.neo4j.helpers.collection.Iterators.iterator; import static org.neo4j.helpers.collection.Iterators.iterator;
import static org.neo4j.helpers.collection.MapUtil.map;
import static org.neo4j.kernel.impl.store.MetaDataStore.DEFAULT_NAME; import static org.neo4j.kernel.impl.store.MetaDataStore.DEFAULT_NAME;


/** /**
Expand Down Expand Up @@ -383,10 +381,7 @@ private GBPTree.Monitor treeMonitor()
public void cleanupFinished( long numberOfPagesVisited, long numberOfCleanedCrashPointers, public void cleanupFinished( long numberOfPagesVisited, long numberOfCleanedCrashPointers,
long durationMillis ) long durationMillis )
{ {
monitor.recoveryCompleted( map( monitor.recoveryCleanupFinished( numberOfPagesVisited, numberOfCleanedCrashPointers, durationMillis );
"Number of pages visited", numberOfPagesVisited,
"Number of cleaned crashed pointers", numberOfCleanedCrashPointers,
"Time spent", duration( durationMillis ) ) );
} }
}; };
} }
Expand Down
Expand Up @@ -34,8 +34,6 @@
import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.kernel.impl.index.GBPTreeFileUtil; import org.neo4j.kernel.impl.index.GBPTreeFileUtil;


import static org.neo4j.helpers.Format.duration;
import static org.neo4j.helpers.collection.MapUtil.map;
import static org.neo4j.index.internal.gbptree.GBPTree.NO_HEADER_READER; import static org.neo4j.index.internal.gbptree.GBPTree.NO_HEADER_READER;


class NativeSchemaNumberIndex<KEY extends SchemaNumberKey, VALUE extends SchemaNumberValue> class NativeSchemaNumberIndex<KEY extends SchemaNumberKey, VALUE extends SchemaNumberValue>
Expand Down Expand Up @@ -77,10 +75,7 @@ private GBPTree.Monitor treeMonitor( )
@Override @Override
public void cleanupFinished( long numberOfPagesVisited, long numberOfCleanedCrashPointers, long durationMillis ) public void cleanupFinished( long numberOfPagesVisited, long numberOfCleanedCrashPointers, long durationMillis )
{ {
monitor.recoveryCompleted( indexId, descriptor, map( monitor.recoveryCleanupFinished( indexId, descriptor, numberOfPagesVisited, numberOfCleanedCrashPointers, durationMillis );
"Number of pages visited", numberOfPagesVisited,
"Number of cleaned crashed pointers", numberOfCleanedCrashPointers,
"Time spent", duration( durationMillis ) ) );
} }
}; };
} }
Expand Down
Expand Up @@ -273,7 +273,7 @@ private class RecoveryBarrierMonitor extends LabelScanStore.Monitor.Adaptor
} }


@Override @Override
public void recoveryCompleted( Map<String,Object> data ) public void recoveryCleanupFinished( long numberOfPagesVisited, long numberOfCleanedCrashPointers, long durationMillis )
{ {
barrier.reached(); barrier.reached();
} }
Expand Down

0 comments on commit c46db9a

Please sign in to comment.