//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = 60_000) public void possibleToShutdownDbWhenItIsNotHealthyAndNotAllTransactionsAreApplied() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PossibleToShutdownDbWhenItIsNotHealthyAndNotAllTransactionsAreApplied()
        {
            // adversary that makes page cache throw exception when node store is used
            ClassGuardedAdversary adversary = new ClassGuardedAdversary(new CountingAdversary(1, true), typeof(NodeStore));

            adversary.Disable();

            GraphDatabaseService db = AdversarialPageCacheGraphDatabaseFactory.create(_fs, adversary).newEmbeddedDatabaseBuilder(_testDir.databaseDir()).newGraphDatabase();

            System.Threading.CountdownEvent txStartLatch  = new System.Threading.CountdownEvent(1);
            System.Threading.CountdownEvent txCommitLatch = new System.Threading.CountdownEvent(1);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.concurrent.Future<?> result = java.util.concurrent.ForkJoinPool.commonPool().submit(() ->
            Future <object> result = ForkJoinPool.commonPool().submit(() =>
            {
                using (Transaction tx = Db.beginTx())
                {
                    txStartLatch.Signal();
                    Db.createNode();
                    Await(txCommitLatch);
                    tx.success();
                }
            });

            Await(txStartLatch);

            adversary.Enable();

            txCommitLatch.Signal();

            try
            {
                result.get();
                fail("Exception expected");
            }
            catch (ExecutionException ee)
            {
                // transaction is expected to fail because write through the page cache fails
                assertThat(ee.InnerException, instanceOf(typeof(TransactionFailureException)));
            }
            adversary.Disable();

            // shutdown should complete without any problems
            Db.shutdown();
        }
 private void InitializeInstanceFields()
 {
     _logService      = new SimpleLogService(_logProvider, _logProvider);
     _executorFactory = new NotifyingThreadPoolFactory(this);
     _boltScheduler   = new ExecutorBoltScheduler(CONNECTOR_KEY, _executorFactory, _jobScheduler, _logService, MAX_POOL_SIZE, MAX_POOL_SIZE, Duration.ofMinutes(1), 0, ForkJoinPool.commonPool());
 }
Exemple #3
0
 internal ShiroCaffeineCache(Ticker ticker, long ttl, int maxCapacity, bool useTTL) : this(ticker, ForkJoinPool.commonPool(), ttl, maxCapacity, useTTL)
 {
 }
 private void InitializeInstanceFields()
 {
     _logService    = new SimpleLogService(_logProvider);
     _boltScheduler = new ExecutorBoltScheduler(CONNECTOR_KEY, _executorFactory, _jobScheduler, _logService, 0, 10, Duration.ofMinutes(1), 0, ForkJoinPool.commonPool());
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shutdownShouldTerminateThreadPool() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShutdownShouldTerminateThreadPool()
        {
            ExecutorService cachedThreadPool    = Executors.newCachedThreadPool();
            ExecutorFactory mockExecutorFactory = mock(typeof(ExecutorFactory));

            when(mockExecutorFactory.Create(anyInt(), anyInt(), any(), anyInt(), anyBoolean(), any())).thenReturn(cachedThreadPool);
            ExecutorBoltScheduler scheduler = new ExecutorBoltScheduler(CONNECTOR_KEY, mockExecutorFactory, _jobScheduler, _logService, 0, 10, Duration.ofMinutes(1), 0, ForkJoinPool.commonPool());

            scheduler.Start();
            scheduler.Stop();

            assertTrue(cachedThreadPool.Shutdown);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void initShouldCreateThreadPool() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void InitShouldCreateThreadPool()
        {
            ExecutorFactory mockExecutorFactory = mock(typeof(ExecutorFactory));

            when(mockExecutorFactory.Create(anyInt(), anyInt(), any(), anyInt(), anyBoolean(), any())).thenReturn(Executors.newCachedThreadPool());
            ExecutorBoltScheduler scheduler = new ExecutorBoltScheduler(CONNECTOR_KEY, mockExecutorFactory, _jobScheduler, _logService, 0, 10, Duration.ofMinutes(1), 0, ForkJoinPool.commonPool());

            scheduler.Start();

            verify(_jobScheduler).threadFactory(Group.BOLT_WORKER);
            verify(mockExecutorFactory, times(1)).create(anyInt(), anyInt(), any(typeof(Duration)), anyInt(), anyBoolean(), any(typeof(ThreadFactory)));
        }