Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = 30_000) public void shutdownRecordStorageEngineAfterFailedTransaction() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShutdownRecordStorageEngineAfterFailedTransaction()
        {
            RecordStorageEngine engine           = BuildRecordStorageEngine();
            Exception           applicationError = ExecuteFailingTransaction(engine);

            assertNotNull(applicationError);
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCloseLockGroupAfterAppliers() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCloseLockGroupAfterAppliers()
        {
            // given
            long        nodeId      = 5;
            LockService lockService = mock(typeof(LockService));
            Lock        nodeLock    = mock(typeof(Lock));

            when(lockService.AcquireNodeLock(nodeId, Org.Neo4j.Kernel.impl.locking.LockService_LockType.WriteLock)).thenReturn(nodeLock);
            System.Action <bool> applierCloseCall          = mock(typeof(System.Action));         // <-- simply so that we can use InOrder mockito construct
            CapturingBatchTransactionApplierFacade applier = new CapturingBatchTransactionApplierFacade(this, applierCloseCall);
            RecordStorageEngine engine          = RecordStorageEngineBuilder().lockService(lockService).transactionApplierTransformer(applier.wrapAroundActualApplier).build();
            CommandsToApply     commandsToApply = mock(typeof(CommandsToApply));

            when(commandsToApply.Accept(any())).thenAnswer(invocationOnMock =>
            {
                // Visit one node command
                Visitor <StorageCommand, IOException> visitor = invocationOnMock.getArgument(0);
                NodeRecord after = new NodeRecord(nodeId);
                after.InUse      = true;
                visitor.visit(new Command.NodeCommand(new NodeRecord(nodeId), after));
                return(null);
            });

            // when
            engine.Apply(commandsToApply, TransactionApplicationMode.INTERNAL);

            // then
            InOrder inOrder = inOrder(lockService, applierCloseCall, nodeLock);

            inOrder.verify(lockService).acquireNodeLock(nodeId, Org.Neo4j.Kernel.impl.locking.LockService_LockType.WriteLock);
            inOrder.verify(applierCloseCall).accept(true);
            inOrder.verify(nodeLock, times(1)).release();
            inOrder.verifyNoMoreInteractions();
        }
Пример #3
0
        private NeoStores ResolveNeoStores()
        {
            DependencyResolver  resolver      = Db.DependencyResolver;
            RecordStorageEngine storageEngine = resolver.ResolveDependency(typeof(RecordStorageEngine));

            return(storageEngine.TestAccessNeoStores());
        }
Пример #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustFlushStoresWithGivenIOLimiter()
        public virtual void MustFlushStoresWithGivenIOLimiter()
        {
            IOLimiter                   limiter         = Org.Neo4j.Io.pagecache.IOLimiter_Fields.Unlimited;
            FileSystemAbstraction       fs              = _fsRule.get();
            AtomicReference <IOLimiter> observedLimiter = new AtomicReference <IOLimiter>();
            PageCache                   pageCache       = new DelegatingPageCacheAnonymousInnerClass(this, _pageCacheRule.getPageCache(fs), limiter, observedLimiter);

            RecordStorageEngine engine = _storageEngineRule.getWith(fs, pageCache, _testDirectory.databaseLayout()).build();

            engine.FlushAndForce(limiter);

            assertThat(observedLimiter.get(), sameInstance(limiter));
        }
Пример #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = 30_000) public void obtainCountsStoreResetterAfterFailedTransaction() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ObtainCountsStoreResetterAfterFailedTransaction()
        {
            RecordStorageEngine engine           = BuildRecordStorageEngine();
            Exception           applicationError = ExecuteFailingTransaction(engine);

            assertNotNull(applicationError);

            CountsTracker countsStore = engine.TestAccessNeoStores().Counts;

            // possible to obtain a resetting updater that internally has a write lock on the counts store
            using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater updater = countsStore.Reset(0))
            {
                assertNotNull(updater);
            }
        }
Пример #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static Exception executeFailingTransaction(RecordStorageEngine engine) throws java.io.IOException
        private static Exception ExecuteFailingTransaction(RecordStorageEngine engine)
        {
            Exception          applicationError = new UnderlyingStorageException("No space left on device");
            TransactionToApply txToApply        = NewTransactionThatFailsWith(applicationError);

            try
            {
                engine.Apply(txToApply, TransactionApplicationMode.INTERNAL);
                fail("Exception expected");
            }
            catch (Exception e)
            {
                assertSame(applicationError, Exceptions.rootCause(e));
            }
            return(applicationError);
        }
Пример #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void databasePanicIsRaisedWhenTxApplicationFails() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void DatabasePanicIsRaisedWhenTxApplicationFails()
        {
            RecordStorageEngine        engine           = BuildRecordStorageEngine();
            Exception                  applicationError = ExecuteFailingTransaction(engine);
            ArgumentCaptor <Exception> captor           = ArgumentCaptor.forClass(typeof(Exception));

            verify(_databaseHealth).panic(captor.capture());
            Exception exception = captor.Value;

            if (exception is KernelException)
            {
                assertThat((( KernelException )exception).status(), @is(Org.Neo4j.Kernel.Api.Exceptions.Status_General.UnknownError));
                exception = exception.InnerException;
            }
            assertThat(exception, @is(applicationError));
        }
Пример #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldListAllStoreFiles()
        public virtual void ShouldListAllStoreFiles()
        {
            RecordStorageEngine engine = BuildRecordStorageEngine();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.Collection<org.neo4j.storageengine.api.StoreFileMetadata> files = engine.listStorageFiles();
            ICollection <StoreFileMetadata> files = engine.ListStorageFiles();
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            ISet <File> currentFiles = Files.Select(StoreFileMetadata::file).collect(Collectors.toSet());
            // current engine files should contain everything except another count store file and label scan store
            DatabaseLayout databaseLayout   = _testDirectory.databaseLayout();
            ISet <File>    allPossibleFiles = databaseLayout.StoreFiles();

            allPossibleFiles.remove(databaseLayout.CountStoreB());
            allPossibleFiles.remove(databaseLayout.LabelScanStore());

            assertEquals(currentFiles, allPossibleFiles);
        }
Пример #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void panicOnExceptionDuringCommandsApply()
        public virtual void PanicOnExceptionDuringCommandsApply()
        {
            System.InvalidOperationException failure = new System.InvalidOperationException("Too many open files");
            RecordStorageEngine engine          = _storageEngineRule.getWith(_fsRule.get(), _pageCacheRule.getPageCache(_fsRule.get()), _testDirectory.databaseLayout()).databaseHealth(_databaseHealth).transactionApplierTransformer(facade => TransactionApplierFacadeTransformer(facade, failure)).build();
            CommandsToApply     commandsToApply = mock(typeof(CommandsToApply));

            try
            {
                engine.Apply(commandsToApply, TransactionApplicationMode.INTERNAL);
                fail("Exception expected");
            }
            catch (Exception exception)
            {
                assertSame(failure, Exceptions.rootCause(exception));
            }

            verify(_databaseHealth).panic(any(typeof(Exception)));
        }
Пример #10
0
 public LifecycleAdapterAnonymousInnerClass(RecordStorageEngine outerInstance)
 {
     this.outerInstance = outerInstance;
 }