public TransactionCountingStateVisitor(TxStateVisitor next, StorageReader storageReader, ReadableTransactionState txState, CountsRecordState counts) : base(next)
 {
     this._storageReader = storageReader;
     this._txState       = txState;
     this._counts        = counts;
     this._nodeCursor    = storageReader.AllocateNodeCursor();
     this._groupCursor   = storageReader.AllocateRelationshipGroupCursor();
 }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expected = org.neo4j.graphdb.NotInTransactionException.class) public void assertStatementIsNotOpenWhileAcquireIsNotInvoked()
        public virtual void AssertStatementIsNotOpenWhileAcquireIsNotInvoked()
        {
            KernelTransactionImplementation transaction = mock(typeof(KernelTransactionImplementation));
            TxStateHolder   txStateHolder  = mock(typeof(TxStateHolder));
            StorageReader   storeStatement = mock(typeof(StorageReader));
            KernelStatement statement      = new KernelStatement(transaction, txStateHolder, storeStatement, LockTracer.NONE, mock(typeof(StatementOperationParts)), new ClockContext(), EmptyVersionContextSupplier.EMPTY);

            statement.AssertOpen();
        }
Exemple #3
0
 public override TxStateVisitor DecorateTxStateVisitor(StorageReader storageReader, Read read, CursorFactory cursorFactory, ReadableTransactionState txState, TxStateVisitor visitor)
 {
     if (!txState.HasDataChanges())
     {
         // If there are no data changes, there is no need to enforce constraints. Since there is no need to
         // enforce constraints, there is no need to build up the state required to be able to enforce constraints.
         // In fact, it might even be counter productive to build up that state, since if there are no data changes
         // there would be schema changes instead, and in that case we would throw away the schema-dependant state
         // we just built when the schema changing transaction commits.
         return(visitor);
     }
     return(getOrCreatePropertyExistenceEnforcerFrom(storageReader).decorate(visitor, read, cursorFactory));
 }
Exemple #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReleaseStoreStatementOnlyWhenReferenceCountDownToZero()
        public virtual void ShouldReleaseStoreStatementOnlyWhenReferenceCountDownToZero()
        {
            // given
            KernelTransactionImplementation transaction = mock(typeof(KernelTransactionImplementation));
            StorageReader   storageReader = mock(typeof(StorageReader));
            KernelStatement statement     = GetKernelStatement(transaction, storageReader);

            statement.Acquire();
            verify(storageReader).acquire();
            statement.Acquire();

            // when
            statement.Close();
            verifyNoMoreInteractions(storageReader);

            // then
            statement.Close();
            verify(storageReader).release();
        }
Exemple #5
0
        private static Instances KernelTransactionWithInternals(LoginContext loginContext)
        {
            TransactionHeaderInformation        headerInformation        = new TransactionHeaderInformation(-1, -1, new sbyte[0]);
            TransactionHeaderInformationFactory headerInformationFactory = mock(typeof(TransactionHeaderInformationFactory));

            when(headerInformationFactory.Create()).thenReturn(headerInformation);

            StorageEngine storageEngine = mock(typeof(StorageEngine));
            StorageReader storageReader = mock(typeof(StorageReader));

            when(storageEngine.NewReader()).thenReturn(storageReader);

            KernelTransactionImplementation transaction = new KernelTransactionImplementation(Config.defaults(), mock(typeof(StatementOperationParts)), mock(typeof(SchemaWriteGuard)), new TransactionHooks(), mock(typeof(ConstraintIndexCreator)), new Procedures(), headerInformationFactory, mock(typeof(TransactionRepresentationCommitProcess)), mock(typeof(TransactionMonitor)), mock(typeof(AuxiliaryTransactionStateManager)), mock(typeof(Pool)), Clocks.nanoClock(), new AtomicReference <CpuClock>(CpuClock.NOT_AVAILABLE), new AtomicReference <HeapAllocation>(HeapAllocation.NOT_AVAILABLE), NULL, LockTracer.NONE, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, storageEngine, new CanWrite(), AutoIndexing.UNSUPPORTED, mock(typeof(ExplicitIndexStore)), EmptyVersionContextSupplier.EMPTY, ON_HEAP, new StandardConstraintSemantics(), mock(typeof(SchemaState)), mock(typeof(IndexingService)), mockedTokenHolders(), new Dependencies());

            StatementLocks statementLocks = new SimpleStatementLocks(new NoOpClient());

            transaction.Initialize(0, 0, statementLocks, KernelTransaction.Type.@implicit, loginContext.Authorize(s => - 1, GraphDatabaseSettings.DEFAULT_DATABASE_NAME), 0L, 1L);

            return(new Instances(transaction));
        }
Exemple #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReleaseStorageReaderWhenForceClosed()
        public virtual void ShouldReleaseStorageReaderWhenForceClosed()
        {
            // given
            StorageReader   storeStatement = mock(typeof(StorageReader));
            KernelStatement statement      = new KernelStatement(mock(typeof(KernelTransactionImplementation)), null, storeStatement, LockTracer.NONE, mock(typeof(StatementOperationParts)), new ClockContext(), EmptyVersionContextSupplier.EMPTY);

            statement.Acquire();

            // when
            try
            {
                statement.ForceClose();
            }
            catch (KernelStatement.StatementNotClosedException)
            {
                // ignore
            }

            // then
            verify(storeStatement).release();
        }
Exemple #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual void Setup()
        {
            _dataSource = mock(typeof(NeoStoreDataSource));
            StorageEngine storageEngine = mock(typeof(StorageEngine));
            StorageReader storageReader = mock(typeof(StorageReader));

            when(storageEngine.NewReader()).thenReturn(storageReader);
            _indexingService = mock(typeof(IndexingService));
            TokenHolders tokenHolders = MockedTokenHolders();

            when(tokenHolders.LabelTokens().getIdByName(EXISTING_LABEL)).thenReturn(LABEL_ID);
            when(tokenHolders.PropertyKeyTokens().getIdByName(EXISTING_PROPERTY)).thenReturn(PROPERTY_ID);
            when(tokenHolders.PropertyKeyTokens().getIdByName(NON_EXISTING_PROPERTY)).thenReturn(-1);
            when(tokenHolders.LabelTokens().getIdByName(NON_EXISTING_LABEL)).thenReturn(NO_TOKEN);
            DependencyResolver resolver = mock(typeof(DependencyResolver));

            when(resolver.ResolveDependency(typeof(IndexingService))).thenReturn(_indexingService);
            when(resolver.ResolveDependency(typeof(StorageEngine))).thenReturn(storageEngine);
            when(resolver.ResolveDependency(typeof(TokenHolders))).thenReturn(tokenHolders);
            when(_dataSource.DependencyResolver).thenReturn(resolver);
        }
Exemple #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReleaseStoreStatementWhenForceClosingStatements()
        public virtual void ShouldReleaseStoreStatementWhenForceClosingStatements()
        {
            // given
            KernelTransactionImplementation transaction = mock(typeof(KernelTransactionImplementation));
            StorageReader   storageReader = mock(typeof(StorageReader));
            KernelStatement statement     = GetKernelStatement(transaction, storageReader);

            statement.Acquire();

            // when
            try
            {
                statement.ForceClose();
            }
            catch (KernelStatement.StatementNotClosedException)
            {
                //ignored
            }

            // then
            verify(storageReader).release();
        }
Exemple #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void reportQueryWaitingTimeToTransactionStatisticWhenFinishQueryExecution()
        public virtual void ReportQueryWaitingTimeToTransactionStatisticWhenFinishQueryExecution()
        {
            KernelTransactionImplementation transaction = mock(typeof(KernelTransactionImplementation));
            TxStateHolder txStateHolder  = mock(typeof(TxStateHolder));
            StorageReader storeStatement = mock(typeof(StorageReader));

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

            KernelStatement statement = new KernelStatement(transaction, txStateHolder, storeStatement, LockTracer.NONE, mock(typeof(StatementOperationParts)), new ClockContext(), EmptyVersionContextSupplier.EMPTY);

            statement.Acquire();

            ExecutingQuery query  = QueryWithWaitingTime;
            ExecutingQuery query2 = QueryWithWaitingTime;
            ExecutingQuery query3 = QueryWithWaitingTime;

            statement.StopQueryExecution(query);
            statement.StopQueryExecution(query2);
            statement.StopQueryExecution(query3);

            assertEquals(3, statistics.GetWaitingTimeNanos(1));
        }
Exemple #10
0
 private KernelStatement GetKernelStatement(KernelTransactionImplementation transaction, StorageReader storageReader)
 {
     return(new KernelStatement(transaction, null, storageReader, LockTracer.NONE, mock(typeof(StatementOperationParts)), new ClockContext(), EmptyVersionContextSupplier.EMPTY));
 }
 public abstract TxStateVisitor DecorateTxStateVisitor(StorageReader storageReader, Read read, CursorFactory cursorFactory, ReadableTransactionState state, TxStateVisitor visitor);
Exemple #12
0
 public override TxStateVisitor DecorateTxStateVisitor(StorageReader storageReader, Read read, CursorFactory cursorFactory, ReadableTransactionState state, TxStateVisitor visitor)
 {
     return(visitor);
 }