internal Fixture(PageCache pageCache, FileSystemAbstraction fileSystem, File directory, ThreadPoolJobScheduler scheduler) { this.PageCache = pageCache; this.FileSystem = fileSystem; this.Directory = directory; this.Scheduler = scheduler; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCalculateCorrectEstimates() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCalculateCorrectEstimates() { // given a couple of input files of various layouts Input input = GenerateData(); RecordFormats format = LATEST_RECORD_FORMATS; [email protected]_Estimates estimates = input.CalculateEstimates(new PropertyValueRecordSizeCalculator(format.Property().getRecordSize(NO_STORE_HEADER), parseInt(GraphDatabaseSettings.string_block_size.DefaultValue), 0, parseInt(GraphDatabaseSettings.array_block_size.DefaultValue), 0)); // when DatabaseLayout databaseLayout = Directory.databaseLayout(); Config config = Config.defaults(); FileSystemAbstraction fs = new DefaultFileSystemAbstraction(); using (JobScheduler jobScheduler = new ThreadPoolJobScheduler()) { (new ParallelBatchImporter(databaseLayout, fs, null, Configuration.DEFAULT, NullLogService.Instance, ExecutionMonitors.invisible(), AdditionalInitialIds.EMPTY, config, format, NO_MONITOR, jobScheduler)).doImport(input); // then compare estimates with actual disk sizes VersionContextSupplier contextSupplier = EmptyVersionContextSupplier.EMPTY; using (PageCache pageCache = (new ConfiguringPageCacheFactory(fs, config, PageCacheTracer.NULL, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, NullLog.Instance, contextSupplier, jobScheduler)).OrCreatePageCache, NeoStores stores = (new StoreFactory(databaseLayout, config, new DefaultIdGeneratorFactory(fs), pageCache, fs, NullLogProvider.Instance, contextSupplier)).openAllNeoStores()) { AssertRoughlyEqual(estimates.NumberOfNodes(), stores.NodeStore.NumberOfIdsInUse); AssertRoughlyEqual(estimates.NumberOfRelationships(), stores.RelationshipStore.NumberOfIdsInUse); AssertRoughlyEqual(estimates.NumberOfNodeProperties() + estimates.NumberOfRelationshipProperties(), CalculateNumberOfProperties(stores)); } AssertRoughlyEqual(PropertyStorageSize(), estimates.SizeOfNodeProperties() + estimates.SizeOfRelationshipProperties()); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void changeStoreId(org.neo4j.io.layout.DatabaseLayout databaseLayout) throws Exception private void ChangeStoreId(DatabaseLayout databaseLayout) { File neoStoreFile = databaseLayout.MetadataStore(); using (JobScheduler jobScheduler = new ThreadPoolJobScheduler(), PageCache pageCache = StandalonePageCacheFactory.createPageCache(_fs, jobScheduler)) { MetaDataStore.setRecord(pageCache, neoStoreFile, RANDOM_NUMBER, DateTimeHelper.CurrentUnixTimeMillis()); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: static Fixture prepareDirectoryAndPageCache(Class testClass) throws java.io.IOException internal static Fixture PrepareDirectoryAndPageCache(Type testClass) { DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(); TestDirectory testDirectory = TestDirectory.testDirectory(testClass, fileSystem); File dir = testDirectory.PrepareDirectoryForTest("test"); ThreadPoolJobScheduler scheduler = new ThreadPoolJobScheduler(); PageCache pageCache = StandalonePageCacheFactory.createPageCache(fileSystem, scheduler); return(new Fixture(pageCache, fileSystem, dir, scheduler)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void assertStoreFormat(org.neo4j.kernel.impl.store.format.RecordFormats expected) throws Exception private void AssertStoreFormat(RecordFormats expected) { Config config = Config.defaults(GraphDatabaseSettings.pagecache_memory, "8m"); using (JobScheduler jobScheduler = new ThreadPoolJobScheduler(), PageCache pageCache = ConfigurableStandalonePageCacheFactory.createPageCache(_fileSystemRule.get(), config, jobScheduler)) { RecordFormats actual = RecordFormatSelector.selectForStoreOrConfig(config, _testDirectory.databaseLayout(), _fileSystemRule, pageCache, NullLogProvider.Instance); assertNotNull(actual); assertEquals(expected.StoreVersion(), actual.StoreVersion()); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @BeforeEach void createPageCache() internal virtual void CreatePageCache() { SingleFilePageSwapperFactory factory = new SingleFilePageSwapperFactory(); factory.Open(new DefaultFileSystemAbstraction(), Configuration.EMPTY); MemoryAllocator mman = MemoryAllocator.createAllocator("8 MiB", new LocalMemoryTracker()); _jobScheduler = new ThreadPoolJobScheduler(); _pageCache = new MuninnPageCache(factory, mman, 256, PageCacheTracer.NULL, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, EMPTY, _jobScheduler); _layout = SimpleLongLayout.LongLayout().withFixedSize(true).build(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static java.util.Set<org.neo4j.causalclustering.identity.StoreId> getStoreIds(java.util.List<java.io.File> coreStoreDirs, org.neo4j.io.fs.FileSystemAbstraction fs) throws Exception public static ISet <StoreId> GetStoreIds(IList <File> coreStoreDirs, FileSystemAbstraction fs) { ISet <StoreId> storeIds = new HashSet <StoreId>(); using (JobScheduler jobScheduler = new ThreadPoolJobScheduler(), PageCache pageCache = StandalonePageCacheFactory.createPageCache(fs, jobScheduler)) { foreach (File coreStoreDir in coreStoreDirs) { storeIds.Add(DoReadStoreId(coreStoreDir, pageCache)); } } return(storeIds); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReportProgressOfNodeImport() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReportProgressOfNodeImport() { // given CapturingMonitor progress = new CapturingMonitor(); HumanUnderstandableExecutionMonitor monitor = new HumanUnderstandableExecutionMonitor(progress, NO_EXTERNAL_MONITOR); IdType idType = INTEGER; Input input = new DataGeneratorInput(NODE_COUNT, RELATIONSHIP_COUNT, idType, Collector.EMPTY, Random.seed(), 0, bareboneNodeHeader(idType, new Extractors(';')), bareboneRelationshipHeader(idType, new Extractors(';')), 1, 1, 0, 0); // when using (JobScheduler jobScheduler = new ThreadPoolJobScheduler()) { (new ParallelBatchImporter(Storage.directory().databaseLayout(), Storage.fileSystem(), Storage.pageCache(), DEFAULT, NullLogService.Instance, monitor, EMPTY, defaults(), LATEST_RECORD_FORMATS, NO_MONITOR, jobScheduler)).doImport(input); // then progress.AssertAllProgressReachedEnd(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldImportDataComingFromCsvFiles() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldImportDataComingFromCsvFiles() { // GIVEN Config dbConfig = Config.builder().withSetting(db_timezone, LogTimeZone.SYSTEM.name()).build(); using (JobScheduler scheduler = new ThreadPoolJobScheduler()) { BatchImporter importer = new ParallelBatchImporter(Directory.databaseLayout(), FileSystemRule.get(), null, SmallBatchSizeConfig(), NullLogService.Instance, invisible(), AdditionalInitialIds.EMPTY, dbConfig, RecordFormatSelector.defaultFormat(), NO_MONITOR, scheduler); IList <InputEntity> nodeData = RandomNodeData(); IList <InputEntity> relationshipData = RandomRelationshipData(nodeData); // WHEN importer.DoImport(Csv(NodeDataAsFile(nodeData), RelationshipDataAsFile(relationshipData), IdType.String, LowBufferSize(COMMAS), silentBadCollector(0))); // THEN VerifyImportedData(nodeData, relationshipData); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: static void assertStoreConsistent(org.neo4j.io.fs.FileSystemAbstraction fs, java.io.File storeDir) throws Exception internal static void AssertStoreConsistent(FileSystemAbstraction fs, File storeDir) { File parent = storeDir.ParentFile; using (JobScheduler jobScheduler = new ThreadPoolJobScheduler(), PageCache pageCache = StandalonePageCacheFactory.createPageCache(fs, jobScheduler), TemporaryStoreDirectory tempStore = new TemporaryStoreDirectory(fs, pageCache, parent)) { fs.CopyRecursively(storeDir, tempStore.StoreDir()); (new CopiedStoreRecovery(Config.defaults(), newDependencies().kernelExtensions(), pageCache)).recoverCopiedStore(tempStore.DatabaseLayout()); ConsistencyCheckService.Result result = runConsistencyCheckTool(new string[] { storeDir.AbsolutePath }, new PrintStream(NULL_OUTPUT_STREAM), new PrintStream(NULL_OUTPUT_STREAM)); if (!result.Successful) { throw new Exception("Not consistent database in " + storeDir); } } }
/// <summary> /// There was this problem where some steps and in particular parallel CSV input parsing that /// paniced would hang the import entirely. /// </summary> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldExitAndThrowExceptionOnPanic() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldExitAndThrowExceptionOnPanic() { try { using (JobScheduler jobScheduler = new ThreadPoolJobScheduler()) { BatchImporter importer = new ParallelBatchImporter(_directory.databaseLayout(), _fs, null, Configuration.DEFAULT, NullLogService.Instance, ExecutionMonitors.invisible(), AdditionalInitialIds.EMPTY, Config.defaults(), StandardV3_0.RECORD_FORMATS, NO_MONITOR, jobScheduler); IEnumerable <DataFactory> nodeData = datas(data(NO_DECORATOR, FileAsCharReadable(NodeCsvFileWithBrokenEntries()))); Input brokenCsvInput = new CsvInput(nodeData, defaultFormatNodeFileHeader(), datas(), defaultFormatRelationshipFileHeader(), IdType.ACTUAL, CsvConfigurationWithLowBufferSize(), new BadCollector(NullOutputStream.NULL_OUTPUT_STREAM, 0, 0), CsvInput.NO_MONITOR); importer.DoImport(brokenCsvInput); fail("Should have failed properly"); } } catch (InputException e) { // THEN assertTrue(e.InnerException is DataAfterQuoteException); // and we managed to shut down properly } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void createRandomData(int count) throws Exception private void CreateRandomData(int count) { Config config = Config.defaults(); RecordFormats recordFormats = RecordFormatSelector.selectForConfig(config, NullLogProvider.Instance); using (RandomDataInput input = new RandomDataInput(this, count), JobScheduler jobScheduler = new ThreadPoolJobScheduler()) { BatchImporter importer = new ParallelBatchImporter(_directory.databaseLayout(), _fileSystemRule.get(), null, DEFAULT, NullLogService.Instance, ExecutionMonitors.invisible(), EMPTY, config, recordFormats, NO_MONITOR, jobScheduler); importer.DoImport(input); } }
//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); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static void main(String[] args) throws Exception public static void Main(string[] args) { // Just start and immediately close. The process spawning this subprocess will kill it in the middle of all this File file = new File(args[0]); using (FileSystemAbstraction fs = new DefaultFileSystemAbstraction(), JobScheduler jobScheduler = new ThreadPoolJobScheduler()) { SingleFilePageSwapperFactory swapper = new SingleFilePageSwapperFactory(); swapper.Open(fs, EMPTY); using (PageCache pageCache = new MuninnPageCache(swapper, 10, PageCacheTracer.NULL, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, EmptyVersionContextSupplier.EMPTY, jobScheduler)) { fs.DeleteFile(file); (new GBPTreeBuilder <>(pageCache, file, longLayout().build())).Build().Dispose(); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotDoActualStoreMigrationBetween3_0_5_and_next() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotDoActualStoreMigrationBetween3_0_5AndNext() { // GIVEN a store in vE.H.0 format DatabaseLayout databaseLayout = _directory.databaseLayout(); (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(databaseLayout.DatabaseDirectory()).setConfig(GraphDatabaseSettings.record_format, HighLimitV3_0_0.NAME).newGraphDatabase().shutdown(); Config config = Config.defaults(pagecache_memory, "8m"); try (FileSystemAbstraction fs = new DefaultFileSystemAbstraction(); JobScheduler _jobScheduler = new ThreadPoolJobScheduler(); PageCache _pageCache = new ConfiguringPageCacheFactory(fs, config, NULL, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, NullLog.Instance, EmptyVersionContextSupplier.EMPTY, _jobScheduler) .OrCreatePageCache) { // For test code sanity string fromStoreVersion = StoreVersion.HIGH_LIMIT_V3_0_0.versionString(); StoreVersionCheck.Result hasVersionResult = (new StoreVersionCheck(_pageCache)).hasVersion(databaseLayout.MetadataStore(), fromStoreVersion); assertTrue(hasVersionResult.ActualVersion, hasVersionResult.Outcome.Successful); // WHEN StoreMigrator migrator = new StoreMigrator(fs, _pageCache, config, NullLogService.Instance, _jobScheduler); ProgressReporter monitor = mock(typeof(ProgressReporter)); DatabaseLayout migrationLayout = _directory.databaseLayout("migration"); migrator.Migrate(_directory.databaseLayout(), migrationLayout, monitor, fromStoreVersion, StoreVersion.HIGH_LIMIT_V3_0_6.versionString()); // THEN verifyNoMoreInteractions(monitor); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void startTheDatabaseWithWrongVersionShouldFailAlsoWhenUpgradeIsAllowed() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void StartTheDatabaseWithWrongVersionShouldFailAlsoWhenUpgradeIsAllowed() { // given // create a store File databaseDirectory = _testDirectory.databaseDir(); GraphDatabaseService db = (new TestGraphDatabaseFactory()).newEmbeddedDatabase(databaseDirectory); using (Transaction tx = Db.beginTx()) { Db.createNode(); tx.Success(); } Db.shutdown(); // mess up the version in the metadatastore string badStoreVersion = "bad"; using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), ThreadPoolJobScheduler scheduler = new ThreadPoolJobScheduler(), PageCache pageCache = createPageCache(fileSystem, scheduler)) { MetaDataStore.setRecord(pageCache, _testDirectory.databaseLayout().metadataStore(), MetaDataStore.Position.STORE_VERSION, MetaDataStore.versionStringToLong(badStoreVersion)); } Exception exception = assertThrows(typeof(Exception), () => (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(databaseDirectory).setConfig(GraphDatabaseSettings.allow_upgrade, "true").newGraphDatabase()); assertTrue(exception.InnerException is LifecycleException); assertTrue(exception.InnerException.InnerException is StoreUpgrader.UnexpectedUpgradingStoreVersionException); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void startTheDatabaseWithWrongVersionShouldFailWithUpgradeNotAllowed() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void StartTheDatabaseWithWrongVersionShouldFailWithUpgradeNotAllowed() { // given // create a store File databaseDir = _testDirectory.databaseDir(); GraphDatabaseService db = (new TestGraphDatabaseFactory()).newEmbeddedDatabase(databaseDir); using (Transaction tx = Db.beginTx()) { Db.createNode(); tx.Success(); } Db.shutdown(); // mess up the version in the metadatastore using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), ThreadPoolJobScheduler scheduler = new ThreadPoolJobScheduler(), PageCache pageCache = createPageCache(fileSystem, scheduler)) { MetaDataStore.setRecord(pageCache, _testDirectory.databaseLayout().metadataStore(), MetaDataStore.Position.STORE_VERSION, MetaDataStore.versionStringToLong("bad")); } Exception exception = assertThrows(typeof(Exception), () => (new TestGraphDatabaseFactory()).newEmbeddedDatabase(databaseDir)); assertTrue(exception.InnerException is LifecycleException); assertTrue(exception.InnerException.InnerException is System.ArgumentException); assertEquals("Unknown store version 'bad'", exception.InnerException.InnerException.Message); }