public override void Setup(File storeDir, System.Action <GraphDatabaseService> create) { GraphDatabaseBuilder graphDatabaseBuilder = (new TestGraphDatabaseFactory()).newImpermanentDatabaseBuilder(storeDir); _settings.forEach(graphDatabaseBuilder.setConfig); _db = graphDatabaseBuilder.NewGraphDatabase(); create(_db); }
private GraphDatabaseService getGraphDatabaseService(File storeDir, params string[] settings) { GraphDatabaseBuilder builder = (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(storeDir); builder.Config = settings(settings); return(builder.NewGraphDatabase()); }
public virtual GraphDatabaseService NewImpermanentDatabase(File storeDir) { File absoluteDirectory = storeDir.AbsoluteFile; GraphDatabaseBuilder databaseBuilder = NewImpermanentDatabaseBuilder(absoluteDirectory); databaseBuilder.setConfig(GraphDatabaseSettings.active_database, absoluteDirectory.Name); databaseBuilder.setConfig(GraphDatabaseSettings.databases_root_path, absoluteDirectory.ParentFile.AbsolutePath); return(databaseBuilder.NewGraphDatabase()); }
private GraphDatabaseService CreateDb2(int?backupPort) { File storeDir = _testDirectory.databaseDir("graph-db-2"); GraphDatabaseFactory factory = new GraphDatabaseFactory(); GraphDatabaseBuilder builder = factory.NewEmbeddedDatabaseBuilder(storeDir); builder.SetConfig(OnlineBackupSettings.online_backup_server, "0.0.0.0:" + backupPort); return(builder.NewGraphDatabase()); }
private GraphDatabaseService StartDatabase(bool allowUpgrade) { GraphDatabaseFactory factory = new TestGraphDatabaseFactory(); GraphDatabaseBuilder builder = factory.NewEmbeddedDatabaseBuilder(TestDir.databaseDir()); builder.SetConfig(GraphDatabaseSettings.allow_upgrade, Convert.ToString(allowUpgrade)); builder.SetConfig(GraphDatabaseSettings.pagecache_memory, "8m"); builder.SetConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE); return(builder.NewGraphDatabase()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setUpPorts() public virtual void SetUpPorts() { _backupPort = PortAuthority.allocatePort(); GraphDatabaseFactory factory = new EnterpriseGraphDatabaseFactory(); GraphDatabaseBuilder builder = factory.NewEmbeddedDatabaseBuilder(_dir.storeDir()); builder.setConfig(online_backup_enabled, "true"); builder.setConfig(online_backup_server, "127.0.0.1:" + _backupPort); _db = ( GraphDatabaseAPI )builder.NewGraphDatabase(); _cleanup.add(_db); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void migratingOlderDataAndThanStartAClusterUsingTheNewerDataShouldWork() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void MigratingOlderDataAndThanStartAClusterUsingTheNewerDataShouldWork() { // migrate the store using a single instance File storeDir = TestDir.storeDir("initialData"); File databaseDirectory = Store.prepareDirectory(TestDir.databaseDir(storeDir)); GraphDatabaseFactory factory = new TestGraphDatabaseFactory(); GraphDatabaseBuilder builder = factory.NewEmbeddedDatabaseBuilder(databaseDirectory); builder.SetConfig(GraphDatabaseSettings.allow_upgrade, "true"); builder.SetConfig(GraphDatabaseSettings.pagecache_memory, "8m"); builder.setConfig(GraphDatabaseSettings.logs_directory, TestDir.directory("logs").AbsolutePath); builder.SetConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE); GraphDatabaseService db = builder.NewGraphDatabase(); try { CheckInstance(Store, ( GraphDatabaseAPI )db); } finally { Db.shutdown(); } assertConsistentStore(DatabaseLayout.of(databaseDirectory)); // start the cluster with the db migrated from the old instance File haDir = TestDir.storeDir("ha-stuff"); ClusterManager clusterManager = (new ClusterManager.Builder(haDir)).withSeedDir(databaseDirectory).withCluster(clusterOfSize(2)).build(); HighlyAvailableGraphDatabase master; HighlyAvailableGraphDatabase slave; try { clusterManager.Start(); ClusterManager.ManagedCluster cluster = clusterManager.Cluster; cluster.Await(allSeesAllAsAvailable()); master = cluster.Master; CheckInstance(Store, master); slave = cluster.AnySlave; CheckInstance(Store, slave); clusterManager.SafeShutdown(); assertConsistentStore(master.DatabaseLayout()); assertConsistentStore(slave.DatabaseLayout()); } finally { clusterManager.SafeShutdown(); } }
private GraphDatabaseService CreateDatabase(File storeDir, IDictionary <string, string> config) { TestEnterpriseGraphDatabaseFactory factory = new TestEnterpriseGraphDatabaseFactory(); GraphDatabaseBuilder graphDatabaseBuilder = (storeDir != null) ? factory.NewImpermanentDatabaseBuilder(storeDir) : factory.NewImpermanentDatabaseBuilder(); if (config != null) { graphDatabaseBuilder.Config = config; } return(graphDatabaseBuilder.NewGraphDatabase()); }
private GraphDatabaseService StartGraphDatabase(File storeDir, bool withOnlineBackup, int?backupPort, string logLocation) { GraphDatabaseFactory dbFactory = new TestGraphDatabaseFactoryAnonymousInnerClass(this, storeDir); GraphDatabaseBuilder graphDatabaseBuilder = dbFactory.NewEmbeddedDatabaseBuilder(storeDir).setConfig(OnlineBackupSettings.online_backup_enabled, withOnlineBackup.ToString()).setConfig(GraphDatabaseSettings.keep_logical_logs, Settings.TRUE).setConfig(GraphDatabaseSettings.record_format, RecordFormatName).setConfig(GraphDatabaseSettings.logical_logs_location, logLocation); if (backupPort != null) { graphDatabaseBuilder.SetConfig(OnlineBackupSettings.online_backup_server, "127.0.0.1:" + backupPort); } return(graphDatabaseBuilder.NewGraphDatabase()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testConflictingIdDoesNotSilentlyFail() public virtual void TestConflictingIdDoesNotSilentlyFail() { HighlyAvailableGraphDatabase master = null; HighlyAvailableGraphDatabase dbWithId21 = null; HighlyAvailableGraphDatabase dbWithId22 = null; try { int masterClusterPort = PortAuthority.allocatePort(); GraphDatabaseBuilder masterBuilder = (new TestHighlyAvailableGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(Path(1)).setConfig(ClusterSettings.initial_hosts, "127.0.0.1:" + masterClusterPort).setConfig(ClusterSettings.cluster_server, "127.0.0.1:" + masterClusterPort).setConfig(ClusterSettings.server_id, "" + 1).setConfig(HaSettings.HaServer, ":" + PortAuthority.allocatePort()).setConfig(HaSettings.TxPushFactor, "0").setConfig(OnlineBackupSettings.online_backup_enabled, false.ToString()); master = ( HighlyAvailableGraphDatabase )masterBuilder.NewGraphDatabase(); GraphDatabaseBuilder db21Builder = (new TestHighlyAvailableGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(Path(2)).setConfig(ClusterSettings.initial_hosts, "127.0.0.1:" + masterClusterPort).setConfig(ClusterSettings.cluster_server, "127.0.0.1:" + PortAuthority.allocatePort()).setConfig(ClusterSettings.server_id, "" + 2).setConfig(HaSettings.HaServer, ":" + PortAuthority.allocatePort()).setConfig(HaSettings.TxPushFactor, "0").setConfig(OnlineBackupSettings.online_backup_enabled, false.ToString()); dbWithId21 = ( HighlyAvailableGraphDatabase )db21Builder.NewGraphDatabase(); GraphDatabaseBuilder db22Builder = (new TestHighlyAvailableGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(Path(3)).setConfig(ClusterSettings.initial_hosts, "127.0.0.1:" + masterClusterPort).setConfig(ClusterSettings.cluster_server, "127.0.0.1:" + PortAuthority.allocatePort()).setConfig(ClusterSettings.server_id, "" + 2).setConfig(HaSettings.HaServer, ":" + PortAuthority.allocatePort()).setConfig(HaSettings.TxPushFactor, "0").setConfig(OnlineBackupSettings.online_backup_enabled, false.ToString()); try { dbWithId22 = ( HighlyAvailableGraphDatabase )db22Builder.NewGraphDatabase(); fail("Should not be able to startup when a cluster already has my id"); } catch (Exception) { // awesome } assertTrue(master.Master); assertTrue(!dbWithId21.Master); using (Transaction transaction = dbWithId21.BeginTx()) { transaction.Success(); } } finally { if (dbWithId21 != null) { dbWithId21.Shutdown(); } if (dbWithId22 != null) { dbWithId22.Shutdown(); } if (master != null) { master.Shutdown(); } } }
public static DbRepresentation Of(File storeDir, bool includeIndexes, Config config) { GraphDatabaseBuilder builder = (new TestGraphDatabaseFactory()).NewEmbeddedDatabaseBuilder(storeDir); builder.Config = config.Raw; GraphDatabaseService db = builder.NewGraphDatabase(); try { return(of(db, includeIndexes)); } finally { Db.shutdown(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void migrationShouldFail() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void MigrationShouldFail() { // migrate the store using a single instance File databaseDirectory = Unzip.unzip(this.GetType(), DbFileName, TestDir.databaseDir()); (new File(databaseDirectory, "debug.log")).delete(); // clear the log GraphDatabaseFactory factory = new TestGraphDatabaseFactory(); GraphDatabaseBuilder builder = factory.NewEmbeddedDatabaseBuilder(TestDir.databaseDir()); builder.SetConfig(GraphDatabaseSettings.allow_upgrade, "true"); builder.SetConfig(GraphDatabaseSettings.pagecache_memory, "8m"); try { builder.NewGraphDatabase(); fail("It should have failed."); } catch (Exception ex) { assertTrue(ex.InnerException is LifecycleException); Exception realException = ex.InnerException.InnerException; assertTrue("Unexpected exception", Exceptions.contains(realException, typeof(StoreUpgrader.UnexpectedUpgradingStoreVersionException))); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void embeddedDatabaseShouldStartOnOlderStoreWhenUpgradeIsEnabled() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void EmbeddedDatabaseShouldStartOnOlderStoreWhenUpgradeIsEnabled() { File databaseDirectory = Store.prepareDirectory(TestDir.databaseDir()); GraphDatabaseFactory factory = new TestGraphDatabaseFactory(); GraphDatabaseBuilder builder = factory.NewEmbeddedDatabaseBuilder(TestDir.databaseDir()); builder.SetConfig(GraphDatabaseSettings.allow_upgrade, "true"); builder.SetConfig(GraphDatabaseSettings.pagecache_memory, "8m"); builder.setConfig(GraphDatabaseSettings.logs_directory, TestDir.directory("logs").AbsolutePath); builder.SetConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE); GraphDatabaseService db = builder.NewGraphDatabase(); try { CheckInstance(Store, ( GraphDatabaseAPI )db); } finally { Db.shutdown(); } assertConsistentStore(DatabaseLayout.of(databaseDirectory)); }
private HighlyAvailableGraphDatabase StartDbAtBase(int i, string initialHosts, int clusterPort) { GraphDatabaseBuilder masterBuilder = (new TestHighlyAvailableGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(Path(i).AbsoluteFile).setConfig(ClusterSettings.initial_hosts, initialHosts).setConfig(ClusterSettings.cluster_server, "127.0.0.1:" + clusterPort).setConfig(ClusterSettings.server_id, "" + i).setConfig(HaSettings.HaServer, ":" + PortAuthority.allocatePort()).setConfig(HaSettings.TxPushFactor, "0").setConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE); return(( HighlyAvailableGraphDatabase )masterBuilder.NewGraphDatabase()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBehaveCorrectlyUnderStress() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBehaveCorrectlyUnderStress() { string directory = fromEnv("BACKUP_SERVICE_STRESS_WORKING_DIRECTORY", _defaultWorkingDir); string backupHostname = fromEnv("BACKUP_SERVICE_STRESS_BACKUP_HOSTNAME", DEFAULT_HOSTNAME); int backupPort = parseInt(fromEnv("BACKUP_SERVICE_STRESS_BACKUP_PORT", DEFAULT_PORT)); string txPrune = fromEnv("BACKUP_SERVICE_STRESS_TX_PRUNE", DEFAULT_TX_PRUNE); bool enableIndexes = parseBoolean(fromEnv("BACKUP_SERVICE_STRESS_ENABLE_INDEXES", DEFAULT_ENABLE_INDEXES)); File store = new File(directory, "db/store"); File work = new File(directory, "backup/work"); FileUtils.deleteRecursively(store); FileUtils.deleteRecursively(work); File storeDirectory = ensureExistsAndEmpty(store); Path workDirectory = ensureExistsAndEmpty(work).toPath(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.Map<String,String> config = configureBackup(configureTxLogRotationAndPruning(new java.util.HashMap<>(), txPrune), backupHostname, backupPort); IDictionary <string, string> config = configureBackup(configureTxLogRotationAndPruning(new Dictionary <string, string>(), txPrune), backupHostname, backupPort); GraphDatabaseBuilder graphDatabaseBuilder = (new GraphDatabaseFactory()).newEmbeddedDatabaseBuilder(storeDirectory.AbsoluteFile).setConfig(config); Control control = new Control(new Config()); AtomicReference <GraphDatabaseService> dbRef = new AtomicReference <GraphDatabaseService>(); ExecutorService service = Executors.newFixedThreadPool(3); try { dbRef.set(graphDatabaseBuilder.NewGraphDatabase()); if (enableIndexes) { TransactionalWorkload.SetupIndexes(dbRef.get()); } //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.concurrent.Future<?> workload = service.submit(new TransactionalWorkload(control, dbRef::get)); Future <object> workload = service.submit(new TransactionalWorkload(control, dbRef.get)); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.concurrent.Future<?> backupWorker = service.submit(new BackupLoad(control, backupHostname, backupPort, workDirectory)); Future <object> backupWorker = service.submit(new BackupLoad(control, backupHostname, backupPort, workDirectory)); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.concurrent.Future<?> startStopWorker = service.submit(new StartStop(control, graphDatabaseBuilder::newGraphDatabase, dbRef)); Future <object> startStopWorker = service.submit(new StartStop(control, graphDatabaseBuilder.newGraphDatabase, dbRef)); control.AwaitEnd(asList(workload, backupWorker, startStopWorker)); control.AssertNoFailure(); service.shutdown(); if (!service.awaitTermination(30, SECONDS)) { PrintThreadDump(); fail("Didn't manage to shut down the workers correctly, dumped threads for forensic purposes"); } } catch (TimeoutException t) { Console.Error.WriteLine(format("Timeout waiting task completion. Dumping all threads.")); PrintThreadDump(); throw t; } finally { dbRef.get().shutdown(); service.shutdown(); } // let's cleanup disk space when everything went well FileUtils.deleteRecursively(storeDirectory); FileUtils.deletePathRecursively(workDirectory); }