//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCompleteInitializationOfStoresWithIncompleteHeaders() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCompleteInitializationOfStoresWithIncompleteHeaders() { StoreFactory storeFactory = storeFactory(Config.defaults()); storeFactory.OpenAllNeoStores(true).close(); FileSystemAbstraction fs = _fsRule.get(); foreach (File f in fs.ListFiles(_testDirectory.databaseDir())) { fs.Truncate(f, 0); } storeFactory.OpenAllNeoStores(true).close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void firstRecordOtherThanZeroIfNotFirst() public virtual void FirstRecordOtherThanZeroIfNotFirst() { File storeDir = TestDirectory.databaseDir(); GraphDatabaseAPI db = ( GraphDatabaseAPI )_factory.newImpermanentDatabase(storeDir); Transaction tx = Db.beginTx(); Node node = Db.createNode(); node.SetProperty("name", "Yo"); tx.Success(); tx.Close(); Db.shutdown(); db = ( GraphDatabaseAPI )_factory.newImpermanentDatabase(storeDir); tx = Db.beginTx(); Properties(db).setProperty("test", "something"); tx.Success(); tx.Close(); Db.shutdown(); Config config = Config.defaults(); StoreFactory storeFactory = new StoreFactory(TestDirectory.databaseLayout(), config, new DefaultIdGeneratorFactory(Fs.get()), PageCacheRule.getPageCache(Fs.get()), Fs.get(), NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY); NeoStores neoStores = storeFactory.OpenAllNeoStores(); long prop = neoStores.MetaDataStore.GraphNextProp; assertTrue(prop != 0); neoStores.Close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleStoreConsistingOfOneEmptyFile() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHandleStoreConsistingOfOneEmptyFile() { StoreFactory storeFactory = storeFactory(Config.defaults()); FileSystemAbstraction fs = _fsRule.get(); fs.Create(_testDirectory.databaseLayout().file("neostore.nodestore.db.labels")); storeFactory.OpenAllNeoStores(true).close(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private NodeStore newNodeStore(org.neo4j.io.fs.FileSystemAbstraction fs, org.neo4j.io.pagecache.PageCache pageCache) throws java.io.IOException private NodeStore NewNodeStore(FileSystemAbstraction fs, PageCache pageCache) { _idGeneratorFactory = spy(new DefaultIdGeneratorFactoryAnonymousInnerClass(this, fs)); StoreFactory factory = new StoreFactory(_testDirectory.databaseLayout("new"), Config.defaults(), _idGeneratorFactory, pageCache, fs, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY); _neoStores = factory.OpenAllNeoStores(true); _nodeStore = _neoStores.NodeStore; return(_nodeStore); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void before() public virtual void Before() { FileSystemAbstraction fs = FileSystemRule.get(); DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs); PageCache pageCache = PageCacheRule.getPageCache(fs); StoreFactory factory = new StoreFactory(TestDirectory.databaseLayout(), Config.defaults(), idGeneratorFactory, pageCache, fs, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY); _neoStores = factory.OpenAllNeoStores(true); _arrayStore = _neoStores.PropertyStore.ArrayStore; }
//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()); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHaveSpecificCountsTrackerForReadOnlyDatabase() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHaveSpecificCountsTrackerForReadOnlyDatabase() { // when StoreFactory readOnlyStoreFactory = StoreFactory(Config.defaults(GraphDatabaseSettings.read_only, Settings.TRUE)); _neoStores = readOnlyStoreFactory.OpenAllNeoStores(true); long lastClosedTransactionId = _neoStores.MetaDataStore.LastClosedTransactionId; // then assertEquals(-1, _neoStores.Counts.rotate(lastClosedTransactionId)); }
private NeoStores StoreFixture() { PageCache pageCache = PageCacheRule.getPageCache(_fs, config().withInconsistentReads(_nextReadIsInconsistent)); StoreFactory factory = new StoreFactory(TestDirectory.databaseLayout(), Config.defaults(), new DefaultIdGeneratorFactory(_fs), pageCache, _fs, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY); NeoStores neoStores = factory.OpenAllNeoStores(true); S store = InitialiseStore(neoStores); CommonAbstractStore commonAbstractStore = ( CommonAbstractStore )store; commonAbstractStore.rebuildIdGenerator(); return(neoStores); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void verifyDynamicSizedStoresCanRebuildIdGeneratorSlowly() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void VerifyDynamicSizedStoresCanRebuildIdGeneratorSlowly() { // Given we have a store ... Config config = Config.defaults(GraphDatabaseSettings.rebuild_idgenerators_fast, "false"); StoreFactory storeFactory = new StoreFactory(_testDirectory.databaseLayout(), config, new DefaultIdGeneratorFactory(_fs), PageCacheRule.getPageCache(_fs), _fs, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY); NeoStores neoStores = storeFactory.OpenAllNeoStores(true); DynamicStringStore store = neoStores.PropertyStore.StringStore; // ... that contain a number of records ... DynamicRecord record = new DynamicRecord(1); record.SetInUse(true, PropertyType.String.intValue()); int highestId = 50; for (int i = 1; i <= highestId; i++) // id '0' is the dynamic store header { assertThat(store.NextId(), @is((long)i)); record.Id = i; StringBuilder sb = new StringBuilder(i); for (int j = 0; j < i; j++) { sb.Append('a'); } record.Data = sb.ToString().GetBytes(StandardCharsets.UTF_16); 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(); // 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, 51L)); neoStores.Close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDelegateDeletionOptionToStores() public virtual void ShouldDelegateDeletionOptionToStores() { // GIVEN StoreFactory storeFactory = storeFactory(Config.defaults(), DELETE_ON_CLOSE); // WHEN _neoStores = storeFactory.OpenAllNeoStores(true); assertTrue(_fsRule.get().listFiles(_testDirectory.databaseDir()).length >= StoreType.values().length); // THEN _neoStores.close(); assertEquals(0, _fsRule.get().listFiles(_testDirectory.databaseDir()).length); }
//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(); }