Skip to content

Commit

Permalink
dbms.track_query_allocation and dbms.track_query_cpu_time are now dyn…
Browse files Browse the repository at this point in the history
…amic settings
  • Loading branch information
ragadeeshu committed Jan 8, 2018
1 parent 05fd9d8 commit b056480
Show file tree
Hide file tree
Showing 13 changed files with 203 additions and 67 deletions.
Expand Up @@ -299,8 +299,11 @@ public class GraphDatabaseSettings implements LoadableConfig
Boolean.toString( Configuration.DEFAULT_LEGACY_STYLE_QUOTING ) ); Boolean.toString( Configuration.DEFAULT_LEGACY_STYLE_QUOTING ) );


@Description( "Enables or disables tracking of how much time a query spends actively executing on the CPU." ) @Description( "Enables or disables tracking of how much time a query spends actively executing on the CPU." )
@Dynamic
public static Setting<Boolean> track_query_cpu_time = setting( "dbms.track_query_cpu_time", BOOLEAN, TRUE ); public static Setting<Boolean> track_query_cpu_time = setting( "dbms.track_query_cpu_time", BOOLEAN, TRUE );

@Description( "Enables or disables tracking of how many bytes are allocated by the execution of a query." ) @Description( "Enables or disables tracking of how many bytes are allocated by the execution of a query." )
@Dynamic
public static Setting<Boolean> track_query_allocation = setting( "dbms.track_query_allocation", BOOLEAN, TRUE ); public static Setting<Boolean> track_query_allocation = setting( "dbms.track_query_allocation", BOOLEAN, TRUE );


@Description( "The size of the morsels" ) @Description( "The size of the morsels" )
Expand Down
Expand Up @@ -25,14 +25,17 @@
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.LockSupport; import java.util.concurrent.locks.LockSupport;
import java.util.function.BiConsumer;
import java.util.function.Supplier; import java.util.function.Supplier;


import org.neo4j.graphdb.DependencyResolver; import org.neo4j.graphdb.DependencyResolver;
import org.neo4j.graphdb.ResourceIterator; import org.neo4j.graphdb.ResourceIterator;
import org.neo4j.graphdb.config.Setting; import org.neo4j.graphdb.config.Setting;
import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.helpers.Exceptions; import org.neo4j.helpers.Exceptions;
import org.neo4j.helpers.Reference;
import org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector; import org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector;
import org.neo4j.internal.kernel.api.TokenNameLookup; import org.neo4j.internal.kernel.api.TokenNameLookup;
import org.neo4j.internal.kernel.api.exceptions.KernelException; import org.neo4j.internal.kernel.api.exceptions.KernelException;
Expand Down Expand Up @@ -643,16 +646,8 @@ private NeoStoreKernelModule buildKernel( LogFiles logFiles, TransactionAppender
StorageEngine storageEngine, IndexConfigStore indexConfigStore, TransactionIdStore transactionIdStore, StorageEngine storageEngine, IndexConfigStore indexConfigStore, TransactionIdStore transactionIdStore,
AvailabilityGuard availabilityGuard, SystemNanoClock clock, PropertyAccessor propertyAccessor ) throws KernelException, IOException AvailabilityGuard availabilityGuard, SystemNanoClock clock, PropertyAccessor propertyAccessor ) throws KernelException, IOException
{ {
CpuClock cpuClock = CpuClock.NOT_AVAILABLE; AtomicReference<CpuClock> cpuClockRef = setupCpuClockAtomicReference();
if ( config.get( GraphDatabaseSettings.track_query_cpu_time ) ) AtomicReference<HeapAllocation> heapAllocationRef = setupHeapAllocationAtomicReference();
{
cpuClock = CpuClock.CPU_CLOCK;
}
HeapAllocation heapAllocation = HeapAllocation.NOT_AVAILABLE;
if ( config.get( GraphDatabaseSettings.track_query_allocation ) )
{
heapAllocation = HeapAllocation.HEAP_ALLOCATION;
}


TransactionCommitProcess transactionCommitProcess = commitProcessFactory.create( appender, storageEngine, TransactionCommitProcess transactionCommitProcess = commitProcessFactory.create( appender, storageEngine,
config ); config );
Expand All @@ -671,14 +666,14 @@ private NeoStoreKernelModule buildKernel( LogFiles logFiles, TransactionAppender


StatementOperationParts statementOperationParts = dependencies.satisfyDependency( StatementOperationParts statementOperationParts = dependencies.satisfyDependency(
buildStatementOperations( storeLayer, autoIndexing, buildStatementOperations( storeLayer, autoIndexing,
constraintIndexCreator, databaseSchemaState, explicitIndexStore, cpuClock, heapAllocation ) ); constraintIndexCreator, databaseSchemaState, explicitIndexStore, cpuClockRef, heapAllocationRef ) );


TransactionHooks hooks = new TransactionHooks(); TransactionHooks hooks = new TransactionHooks();
KernelTransactions kernelTransactions = life.add( new KernelTransactions( statementLocksFactory, KernelTransactions kernelTransactions = life.add( new KernelTransactions( statementLocksFactory,
constraintIndexCreator, statementOperationParts, schemaWriteGuard, transactionHeaderInformationFactory, constraintIndexCreator, statementOperationParts, schemaWriteGuard, transactionHeaderInformationFactory,
transactionCommitProcess, indexConfigStore, explicitIndexProviderLookup, hooks, transactionMonitor, transactionCommitProcess, indexConfigStore, explicitIndexProviderLookup, hooks, transactionMonitor,
availabilityGuard, tracers, storageEngine, procedures, transactionIdStore, clock, availabilityGuard, tracers, storageEngine, procedures, transactionIdStore, clock,
cpuClock, heapAllocation, accessCapability, new Cursors(), autoIndexing, explicitIndexStore ) ); cpuClockRef, heapAllocationRef, accessCapability, new Cursors(), autoIndexing, explicitIndexStore ) );


buildTransactionMonitor( kernelTransactions, clock, config ); buildTransactionMonitor( kernelTransactions, clock, config );


Expand All @@ -694,6 +689,50 @@ private NeoStoreKernelModule buildKernel( LogFiles logFiles, TransactionAppender
return new NeoStoreKernelModule( transactionCommitProcess, kernel, kernelTransactions, fileListing ); return new NeoStoreKernelModule( transactionCommitProcess, kernel, kernelTransactions, fileListing );
} }


private AtomicReference<CpuClock> setupCpuClockAtomicReference()
{
AtomicReference<CpuClock> cpuClock = new AtomicReference<>( CpuClock.NOT_AVAILABLE );
if ( config.get( GraphDatabaseSettings.track_query_cpu_time ) )
{
cpuClock.set( CpuClock.CPU_CLOCK );
}
BiConsumer<Boolean,Boolean> cpuClockUpdater = ( before, after ) ->
{
if ( after )
{
cpuClock.set( CpuClock.CPU_CLOCK );
}
else
{
cpuClock.set( CpuClock.NOT_AVAILABLE );
}
};
config.registerDynamicUpdateListener( GraphDatabaseSettings.track_query_cpu_time, cpuClockUpdater );
return cpuClock;
}

private AtomicReference<HeapAllocation> setupHeapAllocationAtomicReference()
{
AtomicReference<HeapAllocation> heapAllocation = new AtomicReference<>( HeapAllocation.NOT_AVAILABLE );
if ( config.get( GraphDatabaseSettings.track_query_allocation ) )
{
heapAllocation.set( HeapAllocation.HEAP_ALLOCATION );
}
BiConsumer<Boolean,Boolean> heapAllocationUpdater = ( before, after ) ->
{
if ( after )
{
heapAllocation.set( HeapAllocation.HEAP_ALLOCATION );
}
else
{
heapAllocation.set( HeapAllocation.NOT_AVAILABLE );
}
};
config.registerDynamicUpdateListener( GraphDatabaseSettings.track_query_allocation, heapAllocationUpdater );
return heapAllocation;
}

private void buildTransactionMonitor( KernelTransactions kernelTransactions, Clock clock, Config config ) private void buildTransactionMonitor( KernelTransactions kernelTransactions, Clock clock, Config config )
{ {
KernelTransactionTimeoutMonitor kernelTransactionTimeoutMonitor = KernelTransactionTimeoutMonitor kernelTransactionTimeoutMonitor =
Expand Down Expand Up @@ -801,7 +840,7 @@ public DependencyResolver getDependencyResolver()


private StatementOperationParts buildStatementOperations( StoreReadLayer storeReadLayer, AutoIndexing autoIndexing, private StatementOperationParts buildStatementOperations( StoreReadLayer storeReadLayer, AutoIndexing autoIndexing,
ConstraintIndexCreator constraintIndexCreator, DatabaseSchemaState databaseSchemaState, ConstraintIndexCreator constraintIndexCreator, DatabaseSchemaState databaseSchemaState,
ExplicitIndexStore explicitIndexStore, CpuClock cpuClock, HeapAllocation heapAllocation ) ExplicitIndexStore explicitIndexStore, AtomicReference<CpuClock> cpuClockRef, AtomicReference<HeapAllocation> heapAllocationRef )
{ {
// The passed in StoreReadLayer is the bottom most layer: Read-access to committed data. // The passed in StoreReadLayer is the bottom most layer: Read-access to committed data.
// To it we add: // To it we add:
Expand All @@ -810,7 +849,7 @@ private StatementOperationParts buildStatementOperations( StoreReadLayer storeRe
autoIndexing, constraintIndexCreator, explicitIndexStore ); autoIndexing, constraintIndexCreator, explicitIndexStore );


QueryRegistrationOperations queryRegistrationOperations = QueryRegistrationOperations queryRegistrationOperations =
new StackingQueryRegistrationOperations( clock, cpuClock, heapAllocation ); new StackingQueryRegistrationOperations( clock, cpuClockRef, heapAllocationRef );


StatementOperationParts parts = new StatementOperationParts( stateHandlingContext, stateHandlingContext, StatementOperationParts parts = new StatementOperationParts( stateHandlingContext, stateHandlingContext,
stateHandlingContext, stateHandlingContext, stateHandlingContext, stateHandlingContext, stateHandlingContext, stateHandlingContext, stateHandlingContext, stateHandlingContext,
Expand Down
Expand Up @@ -27,6 +27,7 @@
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Supplier; import java.util.function.Supplier;
Expand Down Expand Up @@ -176,7 +177,7 @@ public KernelTransactionImplementation( StatementOperationParts statementOperati
TransactionHooks hooks, ConstraintIndexCreator constraintIndexCreator, Procedures procedures, TransactionHooks hooks, ConstraintIndexCreator constraintIndexCreator, Procedures procedures,
TransactionHeaderInformationFactory headerInformationFactory, TransactionCommitProcess commitProcess, TransactionHeaderInformationFactory headerInformationFactory, TransactionCommitProcess commitProcess,
TransactionMonitor transactionMonitor, Supplier<ExplicitIndexTransactionState> explicitIndexTxStateSupplier, TransactionMonitor transactionMonitor, Supplier<ExplicitIndexTransactionState> explicitIndexTxStateSupplier,
Pool<KernelTransactionImplementation> pool, Clock clock, CpuClock cpuClock, HeapAllocation heapAllocation, Pool<KernelTransactionImplementation> pool, Clock clock, AtomicReference<CpuClock> cpuClockRef, AtomicReference<HeapAllocation> heapAllocationRef,
TransactionTracer transactionTracer, LockTracer lockTracer, PageCursorTracerSupplier cursorTracerSupplier, TransactionTracer transactionTracer, LockTracer lockTracer, PageCursorTracerSupplier cursorTracerSupplier,
StorageEngine storageEngine, AccessCapability accessCapability, Cursors cursors, AutoIndexing autoIndexing, StorageEngine storageEngine, AccessCapability accessCapability, Cursors cursors, AutoIndexing autoIndexing,
ExplicitIndexStore explicitIndexStore ) ExplicitIndexStore explicitIndexStore )
Expand All @@ -199,7 +200,7 @@ public KernelTransactionImplementation( StatementOperationParts statementOperati
this.currentStatement = new KernelStatement( this, this, storageStatement, this.currentStatement = new KernelStatement( this, this, storageStatement,
procedures, accessCapability, lockTracer, statementOperations ); procedures, accessCapability, lockTracer, statementOperations );
this.accessCapability = accessCapability; this.accessCapability = accessCapability;
this.statistics = new Statistics( this, cpuClock, heapAllocation ); this.statistics = new Statistics( this, cpuClockRef, heapAllocationRef );
this.userMetaData = new HashMap<>(); this.userMetaData = new HashMap<>();
AllStoreHolder allStoreHolder = AllStoreHolder allStoreHolder =
new AllStoreHolder( storageEngine, storageStatement, this, cursors, explicitIndexStore ); new AllStoreHolder( storageEngine, storageStatement, this, cursors, explicitIndexStore );
Expand Down Expand Up @@ -956,20 +957,25 @@ public static class Statistics
private volatile long heapAllocatedBytesWhenQueryStarted; private volatile long heapAllocatedBytesWhenQueryStarted;
private volatile long waitingTimeNanos; private volatile long waitingTimeNanos;
private volatile long transactionThreadId; private volatile long transactionThreadId;
private final KernelTransactionImplementation transaction;
private final CpuClock cpuClock;
private final HeapAllocation heapAllocation;
private volatile PageCursorTracer pageCursorTracer = PageCursorTracer.NULL; private volatile PageCursorTracer pageCursorTracer = PageCursorTracer.NULL;
private final KernelTransactionImplementation transaction;
private final AtomicReference<CpuClock> cpuClockRef;
private final AtomicReference<HeapAllocation> heapAllocationRef;
private CpuClock cpuClock;
private HeapAllocation heapAllocation;


public Statistics( KernelTransactionImplementation transaction, CpuClock cpuClock, HeapAllocation heapAllocation ) public Statistics( KernelTransactionImplementation transaction, AtomicReference<CpuClock> cpuClockRef,
AtomicReference<HeapAllocation> heapAllocationRef )
{ {
this.transaction = transaction; this.transaction = transaction;
this.cpuClock = cpuClock; this.cpuClockRef = cpuClockRef;
this.heapAllocation = heapAllocation; this.heapAllocationRef = heapAllocationRef;
} }


void init( long threadId, PageCursorTracer pageCursorTracer ) protected void init( long threadId, PageCursorTracer pageCursorTracer )
{ {
this.cpuClock = cpuClockRef.get();
this.heapAllocation = heapAllocationRef.get();
this.transactionThreadId = threadId; this.transactionThreadId = threadId;
this.pageCursorTracer = pageCursorTracer; this.pageCursorTracer = pageCursorTracer;
this.cpuTimeNanosWhenQueryStarted = cpuClock.cpuTimeNanos( transactionThreadId ); this.cpuTimeNanosWhenQueryStarted = cpuClock.cpuTimeNanos( transactionThreadId );
Expand Down
Expand Up @@ -22,6 +22,7 @@
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Supplier; import java.util.function.Supplier;


Expand All @@ -45,7 +46,6 @@
import org.neo4j.kernel.impl.locking.StatementLocks; import org.neo4j.kernel.impl.locking.StatementLocks;
import org.neo4j.kernel.impl.locking.StatementLocksFactory; import org.neo4j.kernel.impl.locking.StatementLocksFactory;
import org.neo4j.kernel.impl.newapi.Cursors; import org.neo4j.kernel.impl.newapi.Cursors;
import org.neo4j.kernel.impl.newapi.KernelToken;
import org.neo4j.kernel.impl.proc.Procedures; import org.neo4j.kernel.impl.proc.Procedures;
import org.neo4j.kernel.impl.store.TransactionId; import org.neo4j.kernel.impl.store.TransactionId;
import org.neo4j.kernel.impl.transaction.TransactionHeaderInformationFactory; import org.neo4j.kernel.impl.transaction.TransactionHeaderInformationFactory;
Expand Down Expand Up @@ -85,8 +85,8 @@ public class KernelTransactions extends LifecycleAdapter implements Supplier<Ker
private final StorageEngine storageEngine; private final StorageEngine storageEngine;
private final Procedures procedures; private final Procedures procedures;
private final TransactionIdStore transactionIdStore; private final TransactionIdStore transactionIdStore;
private final CpuClock cpuClock; private final AtomicReference<CpuClock> cpuClockRef;
private final HeapAllocation heapAllocation; private final AtomicReference<HeapAllocation> heapAllocationRef;
private final AccessCapability accessCapability; private final AccessCapability accessCapability;
private final Supplier<ExplicitIndexTransactionState> explicitIndexTxStateSupplier; private final Supplier<ExplicitIndexTransactionState> explicitIndexTxStateSupplier;
private final SystemNanoClock clock; private final SystemNanoClock clock;
Expand Down Expand Up @@ -132,7 +132,7 @@ public KernelTransactions( StatementLocksFactory statementLocksFactory,
TransactionMonitor transactionMonitor, AvailabilityGuard availabilityGuard, Tracers tracers, TransactionMonitor transactionMonitor, AvailabilityGuard availabilityGuard, Tracers tracers,
StorageEngine storageEngine, Procedures procedures, TransactionIdStore transactionIdStore, StorageEngine storageEngine, Procedures procedures, TransactionIdStore transactionIdStore,
SystemNanoClock clock, SystemNanoClock clock,
CpuClock cpuClock, HeapAllocation heapAllocation, AccessCapability accessCapability, Cursors cursors, AtomicReference<CpuClock> cpuClockRef, AtomicReference<HeapAllocation> heapAllocationRef, AccessCapability accessCapability, Cursors cursors,
AutoIndexing autoIndexing, AutoIndexing autoIndexing,
ExplicitIndexStore explicitIndexStore ) ExplicitIndexStore explicitIndexStore )
{ {
Expand All @@ -149,8 +149,8 @@ public KernelTransactions( StatementLocksFactory statementLocksFactory,
this.storageEngine = storageEngine; this.storageEngine = storageEngine;
this.procedures = procedures; this.procedures = procedures;
this.transactionIdStore = transactionIdStore; this.transactionIdStore = transactionIdStore;
this.cpuClock = cpuClock; this.cpuClockRef = cpuClockRef;
this.heapAllocation = heapAllocation; this.heapAllocationRef = heapAllocationRef;
this.accessCapability = accessCapability; this.accessCapability = accessCapability;
this.autoIndexing = autoIndexing; this.autoIndexing = autoIndexing;
this.explicitIndexStore = explicitIndexStore; this.explicitIndexStore = explicitIndexStore;
Expand Down Expand Up @@ -345,7 +345,7 @@ public KernelTransactionImplementation newInstance()
new KernelTransactionImplementation( statementOperations, schemaWriteGuard, hooks, new KernelTransactionImplementation( statementOperations, schemaWriteGuard, hooks,
constraintIndexCreator, procedures, transactionHeaderInformationFactory, constraintIndexCreator, procedures, transactionHeaderInformationFactory,
transactionCommitProcess, transactionMonitor, explicitIndexTxStateSupplier, localTxPool, transactionCommitProcess, transactionMonitor, explicitIndexTxStateSupplier, localTxPool,
clock, cpuClock, heapAllocation, tracers.transactionTracer, tracers.lockTracer, clock, cpuClockRef, heapAllocationRef, tracers.transactionTracer, tracers.lockTracer,
tracers.pageCursorTracerSupplier, storageEngine, accessCapability, cursors, autoIndexing, explicitIndexStore ); tracers.pageCursorTracerSupplier, storageEngine, accessCapability, cursors, autoIndexing, explicitIndexStore );
this.transactions.add( tx ); this.transactions.add( tx );
return tx; return tx;
Expand Down
Expand Up @@ -19,6 +19,7 @@
*/ */
package org.neo4j.kernel.impl.api; package org.neo4j.kernel.impl.api;


import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Stream; import java.util.stream.Stream;


import org.neo4j.kernel.api.query.ExecutingQuery; import org.neo4j.kernel.api.query.ExecutingQuery;
Expand All @@ -34,17 +35,17 @@ public class StackingQueryRegistrationOperations implements QueryRegistrationOpe
{ {
private final MonotonicCounter lastQueryId = MonotonicCounter.newAtomicMonotonicCounter(); private final MonotonicCounter lastQueryId = MonotonicCounter.newAtomicMonotonicCounter();
private final SystemNanoClock clock; private final SystemNanoClock clock;
private final CpuClock cpuClock; private final AtomicReference<CpuClock> cpuClockRef;
private final HeapAllocation heapAllocation; private final AtomicReference<HeapAllocation> heapAllocationRef;


public StackingQueryRegistrationOperations( public StackingQueryRegistrationOperations(
SystemNanoClock clock, SystemNanoClock clock,
CpuClock cpuClock, AtomicReference<CpuClock> cpuClockRef,
HeapAllocation heapAllocation ) AtomicReference<HeapAllocation> heapAllocationRef )
{ {
this.clock = clock; this.clock = clock;
this.cpuClock = cpuClock; this.cpuClockRef = cpuClockRef;
this.heapAllocation = heapAllocation; this.heapAllocationRef = heapAllocationRef;
} }


@Override @Override
Expand Down Expand Up @@ -75,7 +76,7 @@ public ExecutingQuery startQueryExecution(
new ExecutingQuery( queryId, clientConnection, statement.username(), queryText, queryParameters, new ExecutingQuery( queryId, clientConnection, statement.username(), queryText, queryParameters,
statement.getTransaction().getMetaData(), () -> statement.locks().activeLockCount(), statement.getTransaction().getMetaData(), () -> statement.locks().activeLockCount(),
statement.getPageCursorTracer(), statement.getPageCursorTracer(),
threadId, threadName, clock, cpuClock, heapAllocation ); threadId, threadName, clock, cpuClockRef.get(), heapAllocationRef.get() );
registerExecutingQuery( statement, executingQuery ); registerExecutingQuery( statement, executingQuery );
return executingQuery; return executingQuery;
} }
Expand Down
Expand Up @@ -19,6 +19,7 @@
*/ */
package org.neo4j.kernel.api; package org.neo4j.kernel.api;


import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier; import java.util.function.Supplier;


import org.neo4j.collection.pool.Pool; import org.neo4j.collection.pool.Pool;
Expand Down Expand Up @@ -96,7 +97,7 @@ static Instances kernelTransactionWithInternals( SecurityContext securityContext
mock( TransactionRepresentationCommitProcess.class ), mock( TransactionMonitor.class ), mock( TransactionRepresentationCommitProcess.class ), mock( TransactionMonitor.class ),
mock( Supplier.class ), mock( Supplier.class ),
mock( Pool.class ), mock( Pool.class ),
Clocks.systemClock(), CpuClock.NOT_AVAILABLE, HeapAllocation.NOT_AVAILABLE, NULL, Clocks.systemClock(), new AtomicReference<>( CpuClock.NOT_AVAILABLE ), new AtomicReference<>( HeapAllocation.NOT_AVAILABLE ), NULL,
LockTracer.NONE, LockTracer.NONE,
PageCursorTracerSupplier.NULL, PageCursorTracerSupplier.NULL,
storageEngine, new CanWrite(), new Cursors(), AutoIndexing.UNSUPPORTED, mock( storageEngine, new CanWrite(), new Cursors(), AutoIndexing.UNSUPPORTED, mock(
Expand Down
Expand Up @@ -22,6 +22,7 @@
import org.junit.Test; import org.junit.Test;


import java.util.Optional; import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;


import org.neo4j.graphdb.NotInTransactionException; import org.neo4j.graphdb.NotInTransactionException;
import org.neo4j.graphdb.TransactionTerminatedException; import org.neo4j.graphdb.TransactionTerminatedException;
Expand Down Expand Up @@ -106,7 +107,7 @@ public void reportQueryWaitingTimeToTransactionStatisticWhenFinishQueryExecution
Procedures procedures = mock( Procedures.class ); Procedures procedures = mock( Procedures.class );


KernelTransactionImplementation.Statistics statistics = new KernelTransactionImplementation.Statistics( transaction, KernelTransactionImplementation.Statistics statistics = new KernelTransactionImplementation.Statistics( transaction,
CpuClock.NOT_AVAILABLE, HeapAllocation.NOT_AVAILABLE ); new AtomicReference<>( CpuClock.NOT_AVAILABLE ), new AtomicReference<>( HeapAllocation.NOT_AVAILABLE ) );
when( transaction.getStatistics() ).thenReturn( statistics ); when( transaction.getStatistics() ).thenReturn( statistics );
when( transaction.executingQueries() ).thenReturn( ExecutingQueryList.EMPTY ); when( transaction.executingQueries() ).thenReturn( ExecutingQueryList.EMPTY );


Expand Down
Expand Up @@ -31,6 +31,7 @@
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer; import java.util.function.Consumer;


import org.neo4j.graphdb.TransactionTerminatedException; import org.neo4j.graphdb.TransactionTerminatedException;
Expand Down Expand Up @@ -721,8 +722,8 @@ public void reportTransactionStatistics()
{ {
KernelTransactionImplementation transaction = newTransaction( 100 ); KernelTransactionImplementation transaction = newTransaction( 100 );
KernelTransactionImplementation.Statistics statistics = KernelTransactionImplementation.Statistics statistics =
new KernelTransactionImplementation.Statistics( transaction, new ThreadBasedCpuClock(), new KernelTransactionImplementation.Statistics( transaction, new AtomicReference<>( new ThreadBasedCpuClock() ),
new ThreadBasedAllocation() ); new AtomicReference<>( new ThreadBasedAllocation() ) );
PredictablePageCursorTracer tracer = new PredictablePageCursorTracer(); PredictablePageCursorTracer tracer = new PredictablePageCursorTracer();
statistics.init( 2, tracer ); statistics.init( 2, tracer );


Expand Down
Expand Up @@ -26,6 +26,7 @@
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer; import java.util.function.Consumer;


import org.neo4j.collection.pool.Pool; import org.neo4j.collection.pool.Pool;
Expand Down Expand Up @@ -339,7 +340,8 @@ private static class TestKernelTransaction extends KernelTransactionImplementati
super( mock( StatementOperationParts.class ), mock( SchemaWriteGuard.class ), new TransactionHooks(), super( mock( StatementOperationParts.class ), mock( SchemaWriteGuard.class ), new TransactionHooks(),
mock( ConstraintIndexCreator.class ), new Procedures(), TransactionHeaderInformationFactory.DEFAULT, mock( ConstraintIndexCreator.class ), new Procedures(), TransactionHeaderInformationFactory.DEFAULT,
mock( TransactionCommitProcess.class ), monitor, () -> mock( ExplicitIndexTransactionState.class ), mock( TransactionCommitProcess.class ), monitor, () -> mock( ExplicitIndexTransactionState.class ),
mock( Pool.class ), Clocks.fakeClock(), CpuClock.NOT_AVAILABLE, HeapAllocation.NOT_AVAILABLE, mock( Pool.class ), Clocks.fakeClock(),
new AtomicReference<>( CpuClock.NOT_AVAILABLE ), new AtomicReference<>( HeapAllocation.NOT_AVAILABLE ),
TransactionTracer.NULL, TransactionTracer.NULL,
LockTracer.NONE, PageCursorTracerSupplier.NULL, LockTracer.NONE, PageCursorTracerSupplier.NULL,
mock( StorageEngine.class, RETURNS_MOCKS ), new CanWrite(), mock( Cursors.class ), mock( StorageEngine.class, RETURNS_MOCKS ), new CanWrite(), mock( Cursors.class ),
Expand Down

0 comments on commit b056480

Please sign in to comment.