Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldRunDeferredExecutors() throws InterruptedException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldRunDeferredExecutors()
        {
            AtomicInteger counter = new AtomicInteger(0);
            Semaphore     @lock   = new Semaphore(1);

            BufferingExecutor later = new BufferingExecutor();

            // add our later executor to the external dependencies
            GraphDatabaseDependencies externalDependencies = newDependencies().withDeferredExecutor(later, Group.LOG_ROTATION);

            // Take the lock, we're going to use this to synchronize with tasks that run in the executor
            @lock.acquire(1);

            // add an increment task to the deferred executor
            later.Execute(counter.incrementAndGet);
            later.Execute(@lock.release);

            // if I try and get the lock it should fail because the deferred executor is still waiting for a real executor implementation.
            // n.b. this will take the whole timeout time. So don't set this high, even if it means that this test might get lucky and pass
            assertFalse(@lock.tryAcquire(1, 1, TimeUnit.SECONDS));
            // my counter is still unincremented as well
            assertThat(counter.get(), equalTo(0));

            // When I construct a PlatformModule...
            PlatformModule pm = new PlatformModule(_testDirectory.storeDir(), Config.defaults(), DatabaseInfo.UNKNOWN, externalDependencies);

            // then the tasks that I queued up earlier should be run...
            // the timeout here is really high to ensure that this test does not become flaky because of a slow running JVM
            // e.g. due to lots of CPU contention or garbage collection.
            assertTrue(@lock.tryAcquire(1, 60, TimeUnit.SECONDS));
            assertThat(counter.get(), equalTo(1));
        }
Ejemplo n.º 2
0
        public override GraphDatabaseFacade NewGraphDatabase(Config config, GraphDatabaseFacadeFactory.Dependencies dependencies)
        {
            File storeDir = config.Get(GraphDatabaseSettings.database_path);

            config.Augment(stringMap(GraphDatabaseSettings.ephemeral.name(), "true", (new BoltConnector("bolt")).listen_address.name(), "localhost:0"));
            return(new ImpermanentGraphDatabase(storeDir, config, GraphDatabaseDependencies.newDependencies(dependencies)));
        }
Ejemplo n.º 3
0
            public GraphDatabaseService newDatabase(Config config)
            {
                File absoluteStoreDir = _storeDir.AbsoluteFile;
                File databasesRoot    = absoluteStoreDir.ParentFile;

                if (!config.IsConfigured(GraphDatabaseSettings.shutdown_transaction_end_timeout))
                {
                    config.Augment(GraphDatabaseSettings.shutdown_transaction_end_timeout, "0s");
                }
                config.Augment(GraphDatabaseSettings.ephemeral, Settings.FALSE);
                config.augment(GraphDatabaseSettings.active_database, absoluteStoreDir.Name);
                config.augment(GraphDatabaseSettings.databases_root_path, databasesRoot.AbsolutePath);
                return(new GraphDatabaseFacadeFactoryAnonymousInnerClass(this, DatabaseInfo.ENTERPRISE, config)
                       .newFacade(databasesRoot, config, GraphDatabaseDependencies.newDependencies(_state.databaseDependencies())));
            }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void checkExpectedDatabaseDirectory()
        internal virtual void CheckExpectedDatabaseDirectory()
        {
            Config config = Config.builder().withServerDefaults().withSetting(mode, Mode.SINGLE.name()).withSetting(GraphDatabaseSettings.neo4j_home, _testDirectory.storeDir().AbsolutePath).withSetting((new BoltConnector("bolt")).listen_address.name(), "localhost:0").withSetting((new BoltConnector("http")).listen_address.name(), "localhost:0").withSetting((new BoltConnector("https")).listen_address.name(), "localhost:0").build();
            GraphDatabaseDependencies dependencies = GraphDatabaseDependencies.newDependencies().userLogProvider(NullLogProvider.Instance);
            OpenEnterpriseNeoServer   server       = new OpenEnterpriseNeoServer(config, dependencies);

            server.Start();
            try
            {
                Path expectedPath         = Paths.get(_testDirectory.storeDir().Path, "data", "databases", "graph.db");
                GraphDatabaseFacade graph = server.Database.Graph;
                assertEquals(expectedPath, graph.DatabaseLayout().databaseDirectory().toPath());
            }
            finally
            {
                server.Stop();
            }
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustIgnoreExceptionsFromPreLoadingCypherQuery()
        public virtual void MustIgnoreExceptionsFromPreLoadingCypherQuery()
        {
            // Given a lifecycled database that'll try to warm up Cypher when it starts
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.factory.GraphDatabaseFacade mockDb = mock(org.neo4j.kernel.impl.factory.GraphDatabaseFacade.class);
            GraphDatabaseFacade mockDb = mock(typeof(GraphDatabaseFacade));
            Config config = Config.defaults();

            GraphDatabaseFacadeFactory.Dependencies deps = GraphDatabaseDependencies.newDependencies().userLogProvider(NullLogProvider.Instance);
            GraphFactory factory         = new SimpleGraphFactory(mockDb);
            LifecycleManagingDatabase db = new LifecycleManagingDatabaseAnonymousInnerClass(this, config, factory, deps);

            // When the execution of the query fails (for instance when this is a slave that just joined a cluster and is
            // working on catching up to the master)
            when(mockDb.Execute(LifecycleManagingDatabase.CYPHER_WARMUP_QUERY)).thenThrow(new TransactionFailureException("Boo"));

            // Then the database should still start up as normal, without bubbling the exception up
            Db.init();
            Db.start();
            assertTrue("the database should be running", Db.Running);
            Db.stop();
            Db.shutdown();
        }
Ejemplo n.º 6
0
 public GraphDatabaseService newDatabase(Config config)
 {
     return(_outerInstance.customFacadeFactory.newFacade(_storeDir, config, GraphDatabaseDependencies.newDependencies(_state.databaseDependencies())));
 }
Ejemplo n.º 7
0
 protected internal override NeoServer CreateNeoServer(GraphFactory graphFactory, Config config, GraphDatabaseDependencies dependencies)
 {
     return(new CommunityNeoServer(config, graphFactory, dependencies));
 }
Ejemplo n.º 8
0
 private static GraphDatabaseDependencies GraphDbDependencies()
 {
     return(GraphDatabaseDependencies.newDependencies().userLogProvider(NullLogProvider.Instance));
 }