//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void verifyFixedSizeStoresCanRebuildIdGeneratorSlowly() public virtual void VerifyFixedSizeStoresCanRebuildIdGeneratorSlowly() { // Given we have a store ... Config config = Config.defaults(GraphDatabaseSettings.rebuild_idgenerators_fast, "false"); File storeFile = _testDirectory.file("nodes"); File idFile = _testDirectory.file("idNodes"); DynamicArrayStore labelStore = mock(typeof(DynamicArrayStore)); NodeStore store = new NodeStore(storeFile, idFile, config, new DefaultIdGeneratorFactory(_fs), PageCacheRule.getPageCache(_fs), NullLogProvider.Instance, labelStore, RecordFormatSelector.defaultFormat()); store.Initialise(true); store.MakeStoreOk(); // ... that contain a number of records ... NodeRecord record = new NodeRecord(0); record.InUse = true; int highestId = 50; for (int i = 0; i < highestId; i++) { assertThat(store.NextId(), @is((long)i)); record.Id = i; store.UpdateRecord(record); } store.HighestPossibleIdInUse = highestId; // ... and some have been deleted long?[] idsToFree = new long?[] { 2L, 3L, 5L, 7L }; record.InUse = false; foreach (long toDelete in idsToFree) { record.Id = toDelete; store.UpdateRecord(record); } // Then when we rebuild the id generator store.RebuildIdGenerator(); store.CloseIdGenerator(); store.OpenIdGenerator(); // simulate a restart to allow id reuse // We should observe that the ids above got freed IList <long> nextIds = new List <long>(); nextIds.Add(store.NextId()); // 2 nextIds.Add(store.NextId()); // 3 nextIds.Add(store.NextId()); // 5 nextIds.Add(store.NextId()); // 7 nextIds.Add(store.NextId()); // 51 assertThat(nextIds, contains(2L, 3L, 5L, 7L, 50L)); store.Close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void rebuildingIdGeneratorMustNotMissOutOnFreeRecordsAtEndOfFilePage() public virtual void RebuildingIdGeneratorMustNotMissOutOnFreeRecordsAtEndOfFilePage() { // Given we have a store ... Config config = Config.defaults(GraphDatabaseSettings.rebuild_idgenerators_fast, "false"); File storeFile = _testDirectory.file("nodes"); File idFile = _testDirectory.file("idNodes"); DynamicArrayStore labelStore = mock(typeof(DynamicArrayStore)); NodeStore store = new NodeStore(storeFile, idFile, config, new DefaultIdGeneratorFactory(_fs), PageCacheRule.getPageCache(_fs), NullLogProvider.Instance, labelStore, RecordFormatSelector.defaultFormat()); store.Initialise(true); store.MakeStoreOk(); // ... that contain enough records to fill several file pages ... int recordsPerPage = store.RecordsPerPage; NodeRecord record = new NodeRecord(0); record.InUse = true; int highestId = recordsPerPage * 3; // 3 pages worth of records for (int i = 0; i < highestId; i++) { assertThat(store.NextId(), @is((long)i)); record.Id = i; store.UpdateRecord(record); } store.HighestPossibleIdInUse = highestId; // ... and some records at the end of a page have been deleted long?[] idsToFree = new long?[] { recordsPerPage - 2L, recordsPerPage - 1L }; // id's are zero based, hence -2 and -1 record.InUse = false; foreach (long toDelete in idsToFree) { record.Id = toDelete; store.UpdateRecord(record); } // Then when we rebuild the id generator store.RebuildIdGenerator(); store.CloseIdGenerator(); store.OpenIdGenerator(); // simulate a restart to allow id reuse // We should observe that the ids above got freed IList <long> nextIds = new List <long>(); nextIds.Add(store.NextId()); // recordsPerPage - 2 nextIds.Add(store.NextId()); // recordsPerPage - 1 nextIds.Add(store.NextId()); // recordsPerPage * 3 (we didn't use this id in the create-look above) assertThat(nextIds, contains(recordsPerPage - 2L, recordsPerPage - 1L, recordsPerPage * 3L)); store.Close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldTellNodeInUse() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldTellNodeInUse() { // Given EphemeralFileSystemAbstraction fs = _efs.get(); NodeStore store = NewNodeStore(fs); long exists = store.NextId(); store.UpdateRecord(new NodeRecord(exists, false, 10, 20, true)); long deleted = store.NextId(); store.UpdateRecord(new NodeRecord(deleted, false, 10, 20, true)); store.UpdateRecord(new NodeRecord(deleted, false, 10, 20, false)); // When & then assertTrue(store.IsInUse(exists)); assertFalse(store.IsInUse(deleted)); assertFalse(store.IsInUse(_nodeStore.recordFormat.MaxId)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGrowAFileWhileContinuingToMemoryMapNewRegions() public virtual void ShouldGrowAFileWhileContinuingToMemoryMapNewRegions() { // don't run on windows because memory mapping doesn't work properly there assumeTrue(!SystemUtils.IS_OS_WINDOWS); // given const int numberOfRecords = 1000000; Config config = Config.defaults(pagecache_memory, MmapSize(numberOfRecords, NodeRecordFormat.RECORD_SIZE)); FileSystemAbstraction fileSystemAbstraction = _fileSystemRule.get(); DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fileSystemAbstraction); PageCache pageCache = _pageCacheRule.getPageCache(fileSystemAbstraction, config); StoreFactory storeFactory = new StoreFactory(_testDirectory.databaseLayout(), config, idGeneratorFactory, pageCache, fileSystemAbstraction, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY); NeoStores neoStores = storeFactory.OpenAllNeoStores(true); NodeStore nodeStore = neoStores.NodeStore; // when int iterations = 2 * numberOfRecords; long startingId = nodeStore.NextId(); long nodeId = startingId; for (int i = 0; i < iterations; i++) { NodeRecord record = new NodeRecord(nodeId, false, i, 0); record.InUse = true; nodeStore.UpdateRecord(record); nodeId = nodeStore.NextId(); } // then NodeRecord record = new NodeRecord(0, false, 0, 0); for (int i = 0; i < iterations; i++) { record.Id = startingId + i; nodeStore.GetRecord(i, record, NORMAL); assertTrue("record[" + i + "] should be in use", record.InUse()); assertThat("record[" + i + "] should have nextRelId of " + i, record.NextRel, @is(( long )i)); } neoStores.Close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCompletelyRebuildIdGeneratorsAfterCrash() public virtual void ShouldCompletelyRebuildIdGeneratorsAfterCrash() { // GIVEN DatabaseLayout databaseLayout = _directory.databaseLayout(); StoreFactory storeFactory = new StoreFactory(databaseLayout, Config.defaults(), new DefaultIdGeneratorFactory(_fileSystemRule.get()), _pageCacheRule.getPageCache(_fileSystemRule.get()), _fileSystemRule.get(), NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY); long highId; using (NeoStores stores = storeFactory.OpenAllNeoStores(true)) { // a node store with a "high" node NodeStore nodeStore = stores.NodeStore; nodeStore.HighId = 20; nodeStore.UpdateRecord(Node(nodeStore.NextId())); highId = nodeStore.HighId; } // populating its .id file with a bunch of ids File nodeIdFile = databaseLayout.IdNodeStore(); using (IdGeneratorImpl idGenerator = new IdGeneratorImpl(_fileSystemRule.get(), nodeIdFile, 10, 10_000, false, IdType.NODE, () => highId)) { for (long id = 0; id < 15; id++) { idGenerator.FreeId(id); } // WHEN using (NeoStores stores = storeFactory.OpenAllNeoStores(true)) { NodeStore nodeStore = stores.NodeStore; assertFalse(nodeStore.StoreOk); // simulating what recovery does nodeStore.DeleteIdGenerator(); // recovery happens here... nodeStore.MakeStoreOk(); // THEN assertEquals(highId, nodeStore.NextId()); } } }