//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToUpgradeAStoreWithoutIdFilesAsBackups() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToUpgradeAStoreWithoutIdFilesAsBackups() { File databaseDirectory = Store.prepareDirectory(TestDir.databaseDir()); // remove id files File[] idFiles = databaseDirectory.listFiles((dir1, name) => name.EndsWith(".id")); foreach (File idFile in idFiles) { assertTrue(idFile.delete()); } GraphDatabaseFactory factory = new TestGraphDatabaseFactory(); GraphDatabaseBuilder builder = factory.NewEmbeddedDatabaseBuilder(TestDir.databaseDir()); builder.SetConfig(GraphDatabaseSettings.allow_upgrade, "true"); builder.SetConfig(GraphDatabaseSettings.record_format, Store.FormatFamily); builder.SetConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE); GraphDatabaseService db = builder.NewGraphDatabase(); try { CheckInstance(Store, ( GraphDatabaseAPI )db); } finally { Db.shutdown(); } assertConsistentStore(DatabaseLayout.of(databaseDirectory)); }
protected internal override void Configure(GraphDatabaseBuilder builder) { // Reduce the default page cache memory size to 8 mega-bytes for test databases. builder.SetConfig(GraphDatabaseSettings.pagecache_memory, "8m"); builder.setConfig((new BoltConnector("bolt")).type, BOLT.name()); builder.SetConfig((new BoltConnector("bolt")).enabled, "false"); }
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()); }
private GraphDatabaseAPI StartCustomDatabase<T1>( File storeDir, IDictionary<T1> configMap ) { CustomClockEnterpriseFacadeFactory customClockEnterpriseFacadeFactory = new CustomClockEnterpriseFacadeFactory( this ); GraphDatabaseBuilder databaseBuilder = ( new CustomGuardTestTestGraphDatabaseFactory( this, customClockEnterpriseFacadeFactory ) ).NewImpermanentDatabaseBuilder( storeDir ); configMap.forEach( databaseBuilder.setConfig ); databaseBuilder.SetConfig( GraphDatabaseSettings.record_id_batch_size, "1" ); GraphDatabaseAPI database = ( GraphDatabaseAPI ) databaseBuilder.SetConfig( OnlineBackupSettings.online_backup_enabled, Settings.FALSE ).newGraphDatabase(); CleanupRule.add( database ); return database; }
//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 void GenerateInitialData() { GraphDatabaseBuilder builder = (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(_directory.databaseDir()); GraphDatabaseAPI graphDb = ( GraphDatabaseAPI )builder.SetConfig(GraphDatabaseSettings.record_format, _formatName).setConfig(GraphDatabaseSettings.label_block_size, "60").setConfig("dbms.backup.enabled", "false").newGraphDatabase(); try { GenerateInitialData(graphDb); StoreAccess stores = (new StoreAccess(graphDb.DependencyResolver.resolveDependency(typeof(RecordStorageEngine)).testAccessNeoStores())).initialize(); _schemaId = stores.SchemaStore.HighId; _nodeId = stores.NodeStore.HighId; _labelId = ( int )stores.LabelTokenStore.HighId; _nodeLabelsId = stores.NodeDynamicLabelStore.HighId; _relId = stores.RelationshipStore.HighId; _relGroupId = stores.RelationshipGroupStore.HighId; _propId = ( int )stores.PropertyStore.HighId; _stringPropId = stores.StringStore.HighId; _arrayPropId = stores.ArrayStore.HighId; _relTypeId = ( int )stores.RelationshipTypeTokenStore.HighId; _propKeyId = ( int )stores.PropertyKeyNameStore.HighId; } finally { graphDb.Shutdown(); } }
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 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 shouldBehaveCorrectlyUnderStress() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBehaveCorrectlyUnderStress() { long durationInMinutes = parseLong(fromEnv("CHECK_POINT_LOG_ROTATION_STRESS_DURATION", DEFAULT_DURATION_IN_MINUTES)); File storeDir = new File(fromEnv("CHECK_POINT_LOG_ROTATION_STORE_DIRECTORY", _defaultStoreDir)); long nodeCount = parseLong(fromEnv("CHECK_POINT_LOG_ROTATION_NODE_COUNT", DEFAULT_NODE_COUNT)); int threads = parseInt(fromEnv("CHECK_POINT_LOG_ROTATION_WORKER_THREADS", DEFAULT_WORKER_THREADS)); string pageCacheMemory = fromEnv("CHECK_POINT_LOG_ROTATION_PAGE_CACHE_MEMORY", DEFAULT_PAGE_CACHE_MEMORY); Console.WriteLine("1/6\tBuilding initial store..."); using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), JobScheduler jobScheduler = new ThreadPoolJobScheduler()) { Config dbConfig = Config.defaults(); (new ParallelBatchImporter(DatabaseLayout.of(ensureExistsAndEmpty(storeDir)), fileSystem, null, DEFAULT, NullLogService.Instance, ExecutionMonitors.defaultVisible(jobScheduler), EMPTY, dbConfig, RecordFormatSelector.selectForConfig(dbConfig, NullLogProvider.Instance), NO_MONITOR, jobScheduler)).doImport(new NodeCountInputs(nodeCount)); } Console.WriteLine("2/6\tStarting database..."); GraphDatabaseBuilder builder = (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(storeDir); GraphDatabaseService db = builder.SetConfig(GraphDatabaseSettings.pagecache_memory, pageCacheMemory).setConfig(GraphDatabaseSettings.keep_logical_logs, Settings.FALSE).setConfig(GraphDatabaseSettings.check_point_interval_time, CHECK_POINT_INTERVAL_MINUTES + "m").setConfig(GraphDatabaseSettings.tracer, "timer").newGraphDatabase(); Console.WriteLine("3/6\tWarm up db..."); using (Workload workload = new Workload(db, defaultRandomMutation(nodeCount, db), threads)) { // make sure to run at least one checkpoint during warmup long warmUpTimeMillis = TimeUnit.SECONDS.toMillis(CHECK_POINT_INTERVAL_MINUTES * 2); workload.Run(warmUpTimeMillis, Workload.TransactionThroughput_Fields.NONE); } Console.WriteLine("4/6\tStarting workload..."); TransactionThroughputChecker throughput = new TransactionThroughputChecker(); using (Workload workload = new Workload(db, defaultRandomMutation(nodeCount, db), threads)) { workload.Run(TimeUnit.MINUTES.toMillis(durationInMinutes), throughput); } Console.WriteLine("5/6\tShutting down..."); Db.shutdown(); try { Console.WriteLine("6/6\tPrinting stats and recorded timings..."); TimerTransactionTracer.printStats(System.out); throughput.AssertThroughput(System.out); } finally { Console.WriteLine("Done."); } // let's cleanup disk space when everything went well FileUtils.deleteRecursively(storeDir); }
private void SetConfig <T1>(IDictionary <T1> config, GraphDatabaseBuilder builder) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: for (java.util.Map.Entry<org.neo4j.graphdb.config.Setting<?>,String> entry : config.entrySet()) foreach (KeyValuePair <Setting <object>, string> entry in config.SetOfKeyValuePairs()) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.neo4j.graphdb.config.Setting<?> key = entry.getKey(); Setting <object> key = entry.Key; string value = entry.Value; builder.SetConfig(key, value); } }
//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)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void mustBeAbleToStartWithNullTracer() public virtual void MustBeAbleToStartWithNullTracer() { // Start the database File disabledTracerDb = ClusterRule.directory("disabledTracerDb"); GraphDatabaseBuilder builder = (new EnterpriseGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(disabledTracerDb); GraphDatabaseService nullTracerDatabase = builder.SetConfig(MetricsSettings.NeoEnabled, Settings.TRUE).setConfig(csvEnabled, Settings.TRUE).setConfig(csvPath, _outputPath.AbsolutePath).setConfig(GraphDatabaseSettings.tracer, "null").setConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE).newGraphDatabase(); try { using (Transaction tx = nullTracerDatabase.BeginTx()) { Node node = nullTracerDatabase.CreateNode(); node.SetProperty("all", "is well"); tx.Success(); } } finally { nullTracerDatabase.Shutdown(); } // We assert that no exception is thrown during startup or the operation of the database. }