Exemple #1
0
        /*
         * Tests that we unfreeze active transactions after commit and after apply of batch if batch length (in time)
         * is larger than safeZone time.
         */
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldUnfreezeKernelTransactionsAfterApplyIfBatchIsLarge() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldUnfreezeKernelTransactionsAfterApplyIfBatchIsLarge()
        {
            // GIVEN
            int          maxBatchSize                = 10;
            long         idReuseSafeZoneTime         = 100;
            Dependencies dependencies                = mock(typeof(Dependencies));
            TransactionObligationFulfiller fulfiller = mock(typeof(TransactionObligationFulfiller));

            when(dependencies.ObligationFulfiller()).thenReturn(fulfiller);
            when(dependencies.LogService()).thenReturn(NullLogService.Instance);
            when(dependencies.VersionContextSupplier()).thenReturn(EmptyVersionContextSupplier.EMPTY);
            KernelTransactions kernelTransactions = mock(typeof(KernelTransactions));

            when(dependencies.KernelTransactions()).thenReturn(kernelTransactions);
            TransactionCommitProcess commitProcess = mock(typeof(TransactionCommitProcess));

            when(dependencies.CommitProcess()).thenReturn(commitProcess);
            TransactionCommittingResponseUnpacker unpacker = Life.add(new TransactionCommittingResponseUnpacker(dependencies, maxBatchSize, idReuseSafeZoneTime));

            // WHEN
            int txCount       = maxBatchSize;
            int doesNotMatter = 1;

            unpacker.UnpackResponse(new DummyTransactionResponse(doesNotMatter, txCount, idReuseSafeZoneTime + 1), NO_OP_TX_HANDLER);

            // THEN
            InOrder inOrder = inOrder(commitProcess, kernelTransactions);

            inOrder.verify(commitProcess, times(1)).commit(any(), any(), any());
            inOrder.verify(kernelTransactions, times(1)).unblockNewTransactions();
        }
Exemple #2
0
        private static int ActiveTxCount(GraphDatabaseService db)
        {
            DependencyResolver resolver           = (( GraphDatabaseAPI )db).DependencyResolver;
            KernelTransactions kernelTransactions = resolver.ResolveDependency(typeof(KernelTransactions));

            return(kernelTransactions.ActiveTransactions().Count);
        }
Exemple #3
0
        internal TransactionBatchCommitter(KernelTransactions kernelTransactions, long idReuseSafeZoneTime, TransactionCommitProcess commitProcess, Log log)
        {
            Debug.Assert(log != null);

            this._kernelTransactions  = kernelTransactions;
            this._idReuseSafeZoneTime = idReuseSafeZoneTime;
            this._commitProcess       = commitProcess;
            this._log = log;
        }
Exemple #4
0
        public virtual Stream <QueryStatusResult> ListQueries()
        {
            SecurityContext.assertCredentialsNotExpired();

            EmbeddedProxySPI nodeManager = Resolver.resolveDependency(typeof(EmbeddedProxySPI));
            ZoneId           zoneId      = ConfiguredTimeZone;

            try
            {
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
                return(KernelTransactions.activeTransactions().stream().flatMap(KernelTransactionHandle::executingQueries).filter(query => IsAdminOrSelf(query.username())).map(catchThrown(typeof(InvalidArgumentsException), query => new QueryStatusResult(query, nodeManager, zoneId))));
            }
            catch (UncaughtCheckedException uncaught)
            {
                throwIfPresent(uncaught.GetCauseIfOfType(typeof(InvalidArgumentsException)));
                throw uncaught;
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldNotTimeoutSchemaTransactions()
        internal virtual void ShouldNotTimeoutSchemaTransactions()
        {
            // given
            KernelTransactions       kernelTransactions = mock(typeof(KernelTransactions));
            FakeClock                clock   = new FakeClock(100, MINUTES);
            KernelTransactionMonitor monitor = new KernelTransactionMonitor(kernelTransactions, clock, NullLogService.Instance);
            // a 2 minutes old schema transaction which has a timeout of 1 minute
            KernelTransactionHandle oldSchemaTransaction = mock(typeof(KernelTransactionHandle));

            when(oldSchemaTransaction.SchemaTransaction).thenReturn(true);
            when(oldSchemaTransaction.StartTime()).thenReturn(clock.Millis() - MINUTES.toMillis(2));
            when(oldSchemaTransaction.TimeoutMillis()).thenReturn(MINUTES.toMillis(1));
            when(kernelTransactions.ActiveTransactions()).thenReturn(Iterators.asSet(oldSchemaTransaction));

            // when
            monitor.Run();

            // then
            verify(oldSchemaTransaction, times(1)).SchemaTransaction;
            verify(oldSchemaTransaction, never()).markForTermination(any());
        }
Exemple #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCommitTransactionsInBatches() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCommitTransactionsInBatches()
        {
            // GIVEN
            Dependencies dependencies = mock(typeof(Dependencies));
            TransactionCountingTransactionCommitProcess commitProcess = new TransactionCountingTransactionCommitProcess(this);

            when(dependencies.CommitProcess()).thenReturn(commitProcess);
            when(dependencies.LogService()).thenReturn(NullLogService.Instance);
            when(dependencies.VersionContextSupplier()).thenReturn(EmptyVersionContextSupplier.EMPTY);
            KernelTransactions kernelTransactions = mock(typeof(KernelTransactions));

            when(dependencies.KernelTransactions()).thenReturn(kernelTransactions);
            TransactionCommittingResponseUnpacker unpacker = Life.add(new TransactionCommittingResponseUnpacker(dependencies, 5, 0));

            // WHEN
            unpacker.UnpackResponse(new DummyTransactionResponse(BASE_TX_ID + 1, 7), NO_OP_TX_HANDLER);

            // THEN
            commitProcess.AssertBatchSize(5);
            commitProcess.AssertBatchSize(2);
            commitProcess.AssertNoMoreBatches();
        }
Exemple #7
0
        public virtual Stream <TransactionStatusResult> ListTransactions()
        {
            SecurityContext.assertCredentialsNotExpired();
            try
            {
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
                ISet <KernelTransactionHandle> handles = KernelTransactions.activeTransactions().Where(transaction => IsAdminOrSelf(transaction.subject().username())).collect(toSet());

                IDictionary <KernelTransactionHandle, IList <QuerySnapshot> > handleQuerySnapshotsMap = handles.ToDictionary(identity(), TransactionQueries);

                TransactionDependenciesResolver transactionBlockerResolvers = new TransactionDependenciesResolver(handleQuerySnapshotsMap);

                ZoneId zoneId = ConfiguredTimeZone;

                return(handles.Select(catchThrown(typeof(InvalidArgumentsException), tx => new TransactionStatusResult(tx, transactionBlockerResolvers, handleQuerySnapshotsMap, zoneId))));
            }
            catch (UncaughtCheckedException uncaught)
            {
                throwIfPresent(uncaught.GetCauseIfOfType(typeof(InvalidArgumentsException)));
                throw uncaught;
            }
        }
Exemple #8
0
 public KernelTransactionMonitor(KernelTransactions kernelTransactions, SystemNanoClock clock, LogService logService)
 {
     this._kernelTransactions = kernelTransactions;
     this._clock = clock;
     this._log   = logService.GetInternalLog(typeof(KernelTransactionMonitor));
 }