//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCorrectlyDecideToAwaitMergeDependingOnProgress() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCorrectlyDecideToAwaitMergeDependingOnProgress() { // given BlockBasedIndexPopulator <GenericKey, NativeIndexValue> populator = InstantiatePopulator(NO_MONITOR); bool closed = false; try { populator.Add(BatchOfUpdates()); // when Race race = new Race(); race.AddContestant(throwing(() => populator.scanCompleted(nullInstance))); race.AddContestant(throwing(() => populator.close(false))); race.Go(); closed = true; // then regardless of who wins (close/merge) after close call returns no files should still be mapped EphemeralFileSystemAbstraction ephemeralFileSystem = ( EphemeralFileSystemAbstraction )_fs; ephemeralFileSystem.AssertNoOpenFiles(); } finally { if (!closed) { populator.Close(true); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setUp() public virtual void SetUp() { EphemeralFileSystemAbstraction fileSystem = FileSystemRule.get(); _database = (new TestGraphDatabaseFactory()).setFileSystem(fileSystem).newImpermanentDatabaseBuilder().setConfig(GraphDatabaseSettings.default_schema_provider, SchemaIndex.providerName()).newGraphDatabase(); CreateData(_database, 100); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRecoverAfterCrashUnderLoad() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRecoverAfterCrashUnderLoad() { EphemeralFileSystemAbstraction @delegate = _fileSystemRule.get(); AdversarialFileSystemAbstraction fsa = new AdversarialFileSystemAbstraction(new MethodGuardedAdversary(new CountingAdversary(100, true), typeof(StoreChannel).GetMethod("writeAll", typeof(ByteBuffer))), @delegate); long lastValue = 0; try { using (LongState persistedState = new LongState(fsa, _testDir.directory(), 14)) { while (true) // it will break from the Exception that AFS will throw { long tempValue = lastValue + 1; persistedState.TheState = tempValue; lastValue = tempValue; } } } catch (Exception expected) { EnsureStackTraceContainsExpectedMethod(expected.StackTrace, "writeAll"); } using (LongState restoredState = new LongState(@delegate, _testDir.directory(), 4)) { assertEquals(lastValue, restoredState.TheState); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setUp() public virtual void SetUp() { _fs = _fsRule.get(); _pageCache = _pageCacheRule.getPageCache(_fs); _fakePageCursorOverflow = false; _pageCacheWithFakeOverflow = new DelegatingPageCacheAnonymousInnerClass(this, _pageCache); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldProperlyRecoveryAfterCloseOnActiveFileDuringRotation() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldProperlyRecoveryAfterCloseOnActiveFileDuringRotation() { EphemeralFileSystemAbstraction normalFSA = _fileSystemRule.get(); AdversarialFileSystemAbstraction breakingFSA = new AdversarialFileSystemAbstraction(new MethodGuardedAdversary(new CountingAdversary(5, true), typeof(StoreChannel).GetMethod("close")), normalFSA); SelectiveFileSystemAbstraction combinedFSA = new SelectiveFileSystemAbstraction(new File(new File(_testDir.directory(), "long-state"), "long.a"), breakingFSA, normalFSA); long lastValue = 0; try { using (LongState persistedState = new LongState(combinedFSA, _testDir.directory(), 14)) { while (true) // it will break from the Exception that AFS will throw { long tempValue = lastValue + 1; persistedState.TheState = tempValue; lastValue = tempValue; } } } catch (Exception expected) { // this stack trace should contain close() EnsureStackTraceContainsExpectedMethod(expected.StackTrace, "close"); } using (LongState restoredState = new LongState(normalFSA, _testDir.directory(), 14)) { assertThat(restoredState.TheState, greaterThanOrEqualTo(lastValue)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldProperlyRecoveryAfterCrashingDuringRecovery() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldProperlyRecoveryAfterCrashingDuringRecovery() { EphemeralFileSystemAbstraction normalFSA = _fileSystemRule.get(); long lastValue = 0; using (LongState persistedState = new LongState(normalFSA, _testDir.directory(), 14)) { for (int i = 0; i < 100; i++) { long tempValue = lastValue + 1; persistedState.TheState = tempValue; lastValue = tempValue; } } try { // We create a new state that will attempt recovery. The AFS will make it fail on open() of one of the files new LongState(new AdversarialFileSystemAbstraction(new MethodGuardedAdversary(new CountingAdversary(1, true), typeof(FileSystemAbstraction).GetMethod("open", typeof(File), typeof(OpenMode))), normalFSA), _testDir.directory(), 14); fail("Should have failed recovery"); } catch (Exception expected) { // this stack trace should contain open() EnsureStackTraceContainsExpectedMethod(expected.InnerException.StackTrace, "open"); } // Recovery over the normal filesystem after a failed recovery should proceed correctly using (LongState recoveredState = new LongState(normalFSA, _testDir.directory(), 14)) { assertThat(recoveredState.TheState, greaterThanOrEqualTo(lastValue)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCombineProperFiveByteLabelField() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCombineProperFiveByteLabelField() { // GIVEN // -- a store EphemeralFileSystemAbstraction fs = _efs.get(); _nodeStore = NewNodeStore(fs); // -- a record with the msb carrying a negative value long nodeId = 0; long labels = 0x8000000001L; NodeRecord record = new NodeRecord(nodeId, false, NO_NEXT_RELATIONSHIP.intValue(), NO_NEXT_PROPERTY.intValue()); record.InUse = true; record.SetLabelField(labels, Collections.emptyList()); _nodeStore.updateRecord(record); // WHEN // -- reading that record back NodeRecord readRecord = _nodeStore.getRecord(nodeId, _nodeStore.newRecord(), NORMAL); // THEN // -- the label field must be the same assertEquals(labels, readRecord.LabelField); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() throws org.neo4j.kernel.api.security.exception.InvalidAuthTokenException, java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void Setup() { _fs = new EphemeralFileSystemAbstraction(); Db = ( GraphDatabaseAPI )CreateGraphDatabase(_fs); _authManager = Db.DependencyResolver.resolveDependency(typeof(BasicAuthManager)); _admin = Login("neo4j", "neo4j"); _admin.subject().setPasswordChangeNoLongerRequired(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void providedFileSystemNotClosedAfterShutdown() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ProvidedFileSystemNotClosedAfterShutdown() { EphemeralFileSystemAbstraction fs = FileSystemRule.get(); VerifyProvidedFileSystemOpenAfterShutdown(inserter(StoreDir, fs), fs); VerifyProvidedFileSystemOpenAfterShutdown(inserter(StoreDir, fs, Config), fs); VerifyProvidedFileSystemOpenAfterShutdown(inserter(StoreDir, fs, Config, KernelExtensions), fs); }
/* * There was an issue where if multiple concurrent appending threads did append and they moved on * to await a force, where the force would fail and the one doing the force would raise a panic... * the other threads may not notice the panic and move on to mark those transactions as committed * and notice the panic later (which would be too late). */ //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHaveAllConcurrentAppendersSeePanic() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHaveAllConcurrentAppendersSeePanic() { // GIVEN Adversary adversary = new ClassGuardedAdversary(new CountingAdversary(1, true), FailMethod(typeof(BatchingTransactionAppender), "force")); EphemeralFileSystemAbstraction efs = new EphemeralFileSystemAbstraction(); FileSystemAbstraction fs = new AdversarialFileSystemAbstraction(adversary, efs); _life.add(new FileSystemLifecycleAdapter(fs)); DatabaseHealth databaseHealth = new DatabaseHealth(mock(typeof(DatabasePanicEventGenerator)), NullLog.Instance); LogFiles logFiles = LogFilesBuilder.builder(_testDirectory.databaseLayout(), fs).withLogVersionRepository(_logVersionRepository).withTransactionIdStore(_transactionIdStore).build(); _life.add(logFiles); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final BatchingTransactionAppender appender = life.add(new BatchingTransactionAppender(logFiles, logRotation, transactionMetadataCache, transactionIdStore, explicitIndexTransactionOrdering, databaseHealth)); BatchingTransactionAppender appender = _life.add(new BatchingTransactionAppender(logFiles, _logRotation, _transactionMetadataCache, _transactionIdStore, _explicitIndexTransactionOrdering, databaseHealth)); _life.start(); // WHEN int numberOfAppenders = 10; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.CountDownLatch trap = new java.util.concurrent.CountDownLatch(numberOfAppenders); System.Threading.CountdownEvent trap = new System.Threading.CountdownEvent(numberOfAppenders); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.tracing.LogAppendEvent beforeForceTrappingEvent = new org.neo4j.kernel.impl.transaction.tracing.LogAppendEvent_Empty() LogAppendEvent beforeForceTrappingEvent = new LogAppendEvent_EmptyAnonymousInnerClass(this, trap); Race race = new Race(); for (int i = 0; i < numberOfAppenders; i++) { race.AddContestant(() => { try { // Append to the log, the LogAppenderEvent will have all of the appending threads // do wait for all of the other threads to start the force thing appender.Append(Tx(), beforeForceTrappingEvent); fail("No transaction should be considered appended"); } catch (IOException) { // Good, we know that this test uses an adversarial file system which will throw // an exception in BatchingTransactionAppender#force, and since all these transactions // will append and be forced in the same batch, where the force will fail then // all these transactions should fail. If there's any transaction not failing then // it just didn't notice the panic, which would be potentially hazardous. } }); } // THEN perform the race. The relevant assertions are made inside the contestants. race.Go(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldBeConsistentAfterConcurrentWritesAndForces() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldBeConsistentAfterConcurrentWritesAndForces() { ExecutorService executorService = Executors.newCachedThreadPool(); try { for (int attempt = 0; attempt < 100; attempt++) { using (EphemeralFileSystemAbstraction fs = new EphemeralFileSystemAbstraction()) { File aFile = new File("contendedFile"); ICollection <Callable <Void> > workers = new List <Callable <Void> >(); for (int i = 0; i < 100; i++) { workers.Add(() => { try { StoreChannel channel = fs.Open(aFile, OpenMode.READ_WRITE); channel.position(channel.size()); WriteLong(channel, 1); } catch (IOException e) { throw new Exception(e); } return(null); }); workers.Add(() => { StoreChannel channel = fs.Open(aFile, OpenMode.READ_WRITE); channel.force(true); return(null); }); } IList <Future <Void> > futures = executorService.invokeAll(workers); foreach (Future <Void> future in futures) { future.get(); } fs.Crash(); VerifyFileIsFullOfLongIntegerOnes(fs.Open(aFile, OpenMode.READ_WRITE)); } } } finally { executorService.shutdown(); } }
/* * Starts a JVM, executes a tx that fails on prepare and rollbacks, * triggering a bug where an extra start entry for that tx is written * in the xa log. */ //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testStartEntryWrittenOnceOnRollback() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TestStartEntryWrittenOnceOnRollback() { File storeDir = _testDirectory.databaseDir(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.GraphDatabaseService db = new org.neo4j.test.TestGraphDatabaseFactory().setFileSystem(fs.get()).newImpermanentDatabase(storeDir); GraphDatabaseService db = (new TestGraphDatabaseFactory()).setFileSystem(_fs.get()).newImpermanentDatabase(storeDir); CreateSomeTransactions(db); EphemeralFileSystemAbstraction snapshot = _fs.snapshot(Db.shutdown); (new TestGraphDatabaseFactory()).setFileSystem(snapshot).newImpermanentDatabase(storeDir).shutdown(); }
//---------- utility ----------- //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.graphdb.GraphDatabaseService createGraphDatabase(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction fs) throws java.io.IOException private GraphDatabaseService CreateGraphDatabase(EphemeralFileSystemAbstraction fs) { RemovePreviousAuthFile(); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Map<org.neo4j.graphdb.config.Setting<?>, String> settings = new java.util.HashMap<>(); IDictionary <Setting <object>, string> settings = new Dictionary <Setting <object>, string>(); settings[GraphDatabaseSettings.auth_enabled] = "true"; TestGraphDatabaseBuilder graphDatabaseFactory = ( TestGraphDatabaseBuilder )(new TestGraphDatabaseFactory()).setFileSystem(fs).newImpermanentDatabaseBuilder().setConfig(GraphDatabaseSettings.auth_enabled, "true"); return(graphDatabaseFactory.NewGraphDatabase()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void scanningRecordsShouldVisitEachInUseRecordOnce() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ScanningRecordsShouldVisitEachInUseRecordOnce() { // GIVEN we have a NodeStore with data that spans several pages... EphemeralFileSystemAbstraction fs = _efs.get(); _nodeStore = NewNodeStore(fs); ThreadLocalRandom rng = ThreadLocalRandom.current(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.MutableLongSet nextRelSet = new org.eclipse.collections.impl.set.mutable.primitive.LongHashSet(); MutableLongSet nextRelSet = new LongHashSet(); for (int i = 0; i < 10_000; i++) { // Enough records to span several pages int nextRelCandidate = rng.Next(0, int.MaxValue); if (nextRelSet.add(nextRelCandidate)) { long nodeId = _nodeStore.nextId(); NodeRecord record = new NodeRecord(nodeId, false, nextRelCandidate, 20, true); _nodeStore.updateRecord(record); if (rng.Next(0, 10) < 3) { nextRelSet.remove(nextRelCandidate); record.InUse = false; _nodeStore.updateRecord(record); } } } // ...WHEN we now have an interesting set of node records, and we // visit each and remove that node from our nextRelSet... Visitor <NodeRecord, IOException> scanner = record => { // ...THEN we should observe that no nextRel is ever removed twice... assertTrue(nextRelSet.remove(record.NextRel)); return(false); }; _nodeStore.scanAllRecords(scanner); // ...NOR do we have anything left in the set afterwards. assertTrue(nextRelSet.Empty); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void releaseResourcesOnClose() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ReleaseResourcesOnClose() { using (EphemeralFileSystemAbstraction fileSystemAbstraction = new EphemeralFileSystemAbstraction()) { File testDir = new File("testDir"); File testFile = new File("testFile"); fileSystemAbstraction.Mkdir(testDir); fileSystemAbstraction.Create(testFile); assertTrue(fileSystemAbstraction.FileExists(testFile)); assertTrue(fileSystemAbstraction.FileExists(testFile)); fileSystemAbstraction.Dispose(); assertTrue(fileSystemAbstraction.Closed); assertFalse(fileSystemAbstraction.FileExists(testFile)); assertFalse(fileSystemAbstraction.FileExists(testFile)); } }
//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 shouldProperlyRecoveryAfterCrashOnFileForceDuringWrite() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldProperlyRecoveryAfterCrashOnFileForceDuringWrite() { EphemeralFileSystemAbstraction normalFSA = _fileSystemRule.get(); /* * Magic number warning. For a rotation threshold of 14, 990 operations on file A falls on a force() of the * current active file. This has been discovered via experimentation. The end result is that there is a * flush (but not write) a value. This should be recoverable. Interestingly, the failure semantics are a bit * unclear on what should happen to that value. We assume that exception during persistence requires recovery * to discover if the last argument made it to disk or not. Since we use an EFSA, force is not necessary and * the value that caused the failure is actually "persisted" and recovered. */ AdversarialFileSystemAbstraction breakingFSA = new AdversarialFileSystemAbstraction(new MethodGuardedAdversary(new CountingAdversary(40, true), typeof(StoreChannel).GetMethod("force", typeof(bool))), normalFSA); SelectiveFileSystemAbstraction combinedFSA = new SelectiveFileSystemAbstraction(new File(new File(_testDir.directory(), "long-state"), "long.a"), breakingFSA, normalFSA); long lastValue = 0; try { using (LongState persistedState = new LongState(combinedFSA, _testDir.directory(), 14)) { while (true) // it will break from the Exception that AFS will throw { long tempValue = lastValue + 1; persistedState.TheState = tempValue; lastValue = tempValue; } } } catch (Exception expected) { // this stack trace should contain force() EnsureStackTraceContainsExpectedMethod(expected.StackTrace, "force"); } using (LongState restoredState = new LongState(normalFSA, _testDir.directory(), 14)) { assertThat(restoredState.TheState, greaterThanOrEqualTo(lastValue)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldProperlyRecoveryAfterCrashOnFileCreationDuringRotation() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldProperlyRecoveryAfterCrashOnFileCreationDuringRotation() { EphemeralFileSystemAbstraction normalFSA = _fileSystemRule.get(); /* * Magic number warning. For a rotation threshold of 14, 998 operations on file A falls on truncation of the * file during rotation. This has been discovered via experimentation. The end result is that there is a * failure to create the file to rotate to. This should be recoverable. */ AdversarialFileSystemAbstraction breakingFSA = new AdversarialFileSystemAbstraction(new MethodGuardedAdversary(new CountingAdversary(20, true), typeof(FileSystemAbstraction).GetMethod("truncate", typeof(File), typeof(long))), normalFSA); SelectiveFileSystemAbstraction combinedFSA = new SelectiveFileSystemAbstraction(new File(new File(_testDir.directory(), "long-state"), "long.a"), breakingFSA, normalFSA); long lastValue = 0; try { using (LongState persistedState = new LongState(combinedFSA, _testDir.directory(), 14)) { while (true) // it will break from the Exception that AFS will throw { long tempValue = lastValue + 1; persistedState.TheState = tempValue; lastValue = tempValue; } } } catch (Exception expected) { // this stack trace should contain FSA.truncate() EnsureStackTraceContainsExpectedMethod(expected.StackTrace, "truncate"); } using (LongState restoredState = new LongState(normalFSA, _testDir.directory(), 14)) { assertEquals(lastValue, restoredState.TheState); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldNotLoseDataForcedBeforeFileSystemCrashes() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldNotLoseDataForcedBeforeFileSystemCrashes() { using (EphemeralFileSystemAbstraction fs = new EphemeralFileSystemAbstraction()) { // given int numberOfBytesForced = 8; File aFile = new File("yo"); StoreChannel channel = fs.Open(aFile, OpenMode.READ_WRITE); WriteLong(channel, 1111); // when channel.Force(true); WriteLong(channel, 2222); fs.Crash(); // then StoreChannel readChannel = fs.Open(aFile, OpenMode.READ); assertEquals(numberOfBytesForced, readChannel.size()); assertEquals(1111, ReadLong(readChannel).Long); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFreeSecondaryUnitIdOfShrunkRecord() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldFreeSecondaryUnitIdOfShrunkRecord() { // GIVEN EphemeralFileSystemAbstraction fs = _efs.get(); _nodeStore = NewNodeStore(fs); NodeRecord record = new NodeRecord(5L); record.RequiresSecondaryUnit = true; record.SecondaryUnitId = 10L; record.InUse = true; _nodeStore.updateRecord(record); _nodeStore.HighestPossibleIdInUse = 10L; // WHEN record.RequiresSecondaryUnit = false; _nodeStore.updateRecord(record); // THEN IdGenerator idGenerator = _idGeneratorFactory.get(IdType.NODE); verify(idGenerator, never()).freeId(5L); verify(idGenerator).freeId(10L); }
private static void VerifyProvidedFileSystemOpenAfterShutdown(BatchInserter inserter, EphemeralFileSystemAbstraction fileSystemAbstraction) { inserter.Shutdown(); assertFalse(fileSystemAbstraction.Closed); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void crashAndRebuildSlowWithDynamicStringDeletions() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CrashAndRebuildSlowWithDynamicStringDeletions() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.internal.GraphDatabaseAPI db = (org.neo4j.kernel.internal.GraphDatabaseAPI) new org.neo4j.test.TestGraphDatabaseFactory().setFileSystem(fs.get()).newImpermanentDatabaseBuilder(testDir.databaseDir()).setConfig(org.neo4j.graphdb.factory.GraphDatabaseSettings.record_id_batch_size, "1").newGraphDatabase(); GraphDatabaseAPI db = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).setFileSystem(Fs.get()).newImpermanentDatabaseBuilder(TestDir.databaseDir()).setConfig(GraphDatabaseSettings.record_id_batch_size, "1").newGraphDatabase(); IList <long> deletedNodeIds = ProduceNonCleanDefraggedStringStore(db); IDictionary <IdType, long> highIdsBeforeCrash = GetHighIds(db); // Make sure all of our changes are actually written to the files, since any background flushing could // mess up the check-sums in non-deterministic ways Db.DependencyResolver.resolveDependency(typeof(PageCache)).flushAndForce(); long checksumBefore = Fs.get().checksum(); long checksumBefore2 = Fs.get().checksum(); assertThat(checksumBefore, Matchers.equalTo(checksumBefore2)); EphemeralFileSystemAbstraction snapshot = Fs.snapshot(Db.shutdown); long snapshotChecksum = snapshot.Checksum(); if (snapshotChecksum != checksumBefore) { using (Stream @out = new FileStream(TestDir.file("snapshot.zip"), FileMode.Create, FileAccess.Write)) { snapshot.DumpZip(@out); } using (Stream @out = new FileStream(TestDir.file("fs.zip"), FileMode.Create, FileAccess.Write)) { Fs.get().dumpZip(@out); } } assertThat(snapshotChecksum, equalTo(checksumBefore)); // Recover with unsupported.dbms.id_generator_fast_rebuild_enabled=false AssertNumberOfFreeIdsEquals(TestDir.databaseDir(), snapshot, 0); GraphDatabaseAPI newDb = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).setFileSystem(snapshot).newImpermanentDatabaseBuilder(TestDir.databaseDir()).setConfig(GraphDatabaseSettings.rebuild_idgenerators_fast, FALSE).newGraphDatabase(); IDictionary <IdType, long> highIdsAfterCrash = GetHighIds(newDb); assertEquals(highIdsBeforeCrash, highIdsAfterCrash); try { using (Transaction tx = newDb.BeginTx()) { // Verify that the data we didn't delete is still around int nameCount = 0; int relCount = 0; foreach (Node node in newDb.AllNodes) { nameCount++; assertThat(node, inTx(newDb, hasProperty("name"), true)); relCount += ( int )Iterables.count(node.GetRelationships(Direction.OUTGOING)); } assertEquals(16, nameCount); assertEquals(12, relCount); // Verify that the ids of the nodes we deleted are reused IList <long> newIds = new List <long>(); newIds.Add(newDb.CreateNode().Id); newIds.Add(newDb.CreateNode().Id); newIds.Add(newDb.CreateNode().Id); newIds.Add(newDb.CreateNode().Id); assertThat(newIds, @is(deletedNodeIds)); tx.Success(); } } finally { newDb.Shutdown(); snapshot.Dispose(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void doBefore() public virtual void DoBefore() { _fs = _fsRule.get(); }
private EphemeralFileSystemAbstraction RuleFs() { return(_ruleFs = new EphemeralFileSystemAbstraction()); }
public LuceneIndexProviderAnonymousInnerClass(LuceneSchemaIndexCorruptionTest outerInstance, EphemeralFileSystemAbstraction fs, DirectoryFactory directoryFactory, UnknownType defaultDirectoryStructure, IndexProvider.Monitor monitor, Config defaults, long faultyIndexId, Exception error, AtomicReference <FaultyIndexStorageFactory> reference) : base(fs, directoryFactory, defaultDirectoryStructure, monitor, defaults, OperationalMode.single) { this.outerInstance = outerInstance; this._faultyIndexId = faultyIndexId; this._error = error; this._directoryFactory = directoryFactory; this._reference = reference; }
private JumpingFileSystemAbstraction(EphemeralFileSystemAbstraction ephemeralFileSystem, int sizePerJump) : base(ephemeralFileSystem) { this._sizePerJump = sizePerJump; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @BeforeEach void setUp() internal virtual void SetUp() { _fs = new EphemeralFileSystemAbstraction(); }
public DelegatingFileSystemAbstractionAnonymousInnerClass3(RotatingFileOutputStreamSupplierTest outerInstance, EphemeralFileSystemAbstraction fileSystem, IList <Stream> mockStreams) : base(fileSystem) { this.outerInstance = outerInstance; this._mockStreams = mockStreams; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @BeforeEach void setUp() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void SetUp() { _file = (new File("file")).CanonicalFile; _ephemeralFileSystem = new EphemeralFileSystemAbstraction(); _fileSystem = new DefaultFileSystemAbstraction(); }