Beispiel #1
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();
        }
Beispiel #2
0
        public override ExecutingQuery StartQueryExecution(KernelStatement statement, ClientConnectionInfo clientConnection, string queryText, MapValue queryParameters)
        {
            long           queryId        = _lastQueryId.incrementAndGet();
            Thread         thread         = Thread.CurrentThread;
            long           threadId       = thread.Id;
            string         threadName     = thread.Name;
            ExecutingQuery executingQuery = new ExecutingQuery(queryId, clientConnection, statement.Username(), queryText, queryParameters, statement.Transaction.MetaData, () => statement.Locks().activeLockCount(), statement.PageCursorTracer, threadId, threadName, _clock, _cpuClockRef.get(), _heapAllocationRef.get());

            RegisterExecutingQuery(statement, executingQuery);
            return(executingQuery);
        }
Beispiel #3
0
        public string Ignored;          // to make JUnit happy...

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Parameterized.Parameters(name = "{2}") public static java.util.Collection<Object[]> parameters()
        public static ICollection <object[]> Parameters()
        {
            System.Action <KernelTransaction> readTxInitializer = tx =>
            {
            };
            System.Action <KernelTransaction> writeTxInitializer = tx =>
            {
                using (KernelStatement statement = ( KernelStatement )tx.acquireStatement())
                {
                    statement.TxState().nodeDoCreate(42);
                }
            };
            return(Arrays.asList(new object[] { readTxInitializer, false, "readOperationsInNewTransaction" }, new object[] { writeTxInitializer, true, "write" }));
        }
Beispiel #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();
        }
Beispiel #5
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();
        }
Beispiel #6
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();
        }
Beispiel #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") @Test public void shouldUseStartTimeAndTxIdFromWhenStartingTxAsHeader() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldUseStartTimeAndTxIdFromWhenStartingTxAsHeader()
        {
            // GIVEN a transaction starting at one point in time
            long startingTime = Clock.millis();
            ExplicitIndexTransactionState explicitIndexState = mock(typeof(ExplicitIndexTransactionState));

            AuxTxStateManager.registerProvider(new ExplicitIndexTransactionStateProviderAnonymousInnerClass(this, explicitIndexState));
            when(explicitIndexState.hasChanges()).thenReturn(true);
            doAnswer(invocation =>
            {
                ICollection <StorageCommand> commands = invocation.getArgument(0);
                commands.add(mock(typeof(Command)));
                return(null);
            }).when(StorageEngine).createCommands(any(typeof(System.Collections.ICollection)), any(typeof(TransactionState)), any(typeof(StorageReader)), any(typeof(ResourceLocker)), anyLong(), any(typeof(TxStateVisitor.Decorator)));

            using (KernelTransactionImplementation transaction = NewTransaction(LoginContext()))
            {
                SimpleStatementLocks statementLocks = new SimpleStatementLocks(mock(typeof(Org.Neo4j.Kernel.impl.locking.Locks_Client)));
                transaction.Initialize(5L, BASE_TX_COMMIT_TIMESTAMP, statementLocks, KernelTransaction.Type.@implicit, SecurityContext.AUTH_DISABLED, 0L, 1L);
                transaction.TxState();
                using (KernelStatement statement = transaction.AcquireStatement())
                {
                    statement.ExplicitIndexTxState();                              // which will pull it from the supplier and the mocking above
                    // will have it say that it has changes.
                }
                // WHEN committing it at a later point
                Clock.forward(5, MILLISECONDS);
                // ...and simulating some other transaction being committed
                when(MetaDataStore.LastCommittedTransactionId).thenReturn(7L);
                transaction.Success();
            }

            // THEN start time and last tx when started should have been taken from when the transaction started
            assertEquals(5L, CommitProcess.transaction.LatestCommittedTxWhenStarted);
            assertEquals(startingTime, CommitProcess.transaction.TimeStarted);
            assertEquals(startingTime + 5, CommitProcess.transaction.TimeCommitted);
        }
Beispiel #8
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));
        }
Beispiel #9
0
 public override void UnregisterExecutingQuery(KernelStatement statement, ExecutingQuery executingQuery)
 {
     statement.StopQueryExecution(executingQuery);
 }
Beispiel #10
0
 public override Stream <ExecutingQuery> ExecutingQueries(KernelStatement statement)
 {
     return(statement.ExecutingQueryList().queries());
 }
Beispiel #11
0
 internal OperationsFacade(KernelStatement statement, StatementOperationParts operationParts)
 {
     this._statement  = statement;
     this._operations = operationParts;
 }