//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public Result runFullConsistencyCheck(org.neo4j.io.layout.DatabaseLayout databaseLayout, org.neo4j.kernel.configuration.Config config, org.neo4j.helpers.progress.ProgressMonitorFactory progressFactory, org.neo4j.logging.LogProvider logProvider, org.neo4j.io.fs.FileSystemAbstraction fileSystem, boolean verbose, java.io.File reportDir, org.neo4j.consistency.checking.full.ConsistencyFlags consistencyFlags) throws org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException public virtual Result RunFullConsistencyCheck(DatabaseLayout databaseLayout, Config config, ProgressMonitorFactory progressFactory, LogProvider logProvider, FileSystemAbstraction fileSystem, bool verbose, File reportDir, ConsistencyFlags consistencyFlags) { Log log = logProvider.getLog(this.GetType()); JobScheduler jobScheduler = JobSchedulerFactory.createInitialisedScheduler(); ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(fileSystem, config, PageCacheTracer.NULL, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, logProvider.GetLog(typeof(PageCache)), EmptyVersionContextSupplier.EMPTY, jobScheduler); PageCache pageCache = pageCacheFactory.OrCreatePageCache; try { return(RunFullConsistencyCheck(databaseLayout, config, progressFactory, logProvider, fileSystem, pageCache, verbose, reportDir, consistencyFlags)); } finally { try { pageCache.Close(); } catch (Exception e) { log.Error("Failure during shutdown of the page cache", e); } try { jobScheduler.close(); } catch (Exception e) { log.Error("Failure during shutdown of the job scheduler", e); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMovingFiles() throws java.io.IOException, org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMovingFiles() { MigrationTestUtils.prepareSampleLegacyDatabase(Version, _fs, _workingDatabaseLayout.databaseDirectory(), _prepareDirectory); PageCache pageCache = _pageCacheRule.getPageCache(_fs); StoreVersionCheck check = new StoreVersionCheck(pageCache); UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(check); SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor(); LogService logService = NullLogService.Instance; StoreMigrator failingStoreMigrator = new StoreMigratorAnonymousInnerClass2(this, _fs, pageCache, _config, logService, _jobScheduler); try { NewUpgrader(upgradableDatabase, pageCache, progressMonitor, CreateIndexMigrator(), failingStoreMigrator).migrateIfNeeded(_workingDatabaseLayout); fail("Should throw exception"); } catch (Exception e) { assertEquals("This upgrade is failing", e.Message); } assertTrue(checkNeoStoreHasDefaultFormatVersion(check, _workingDatabaseLayout)); progressMonitor = new SilentMigrationProgressMonitor(); StoreMigrator migrator = new StoreMigrator(_fs, pageCache, _config, logService, _jobScheduler); NewUpgrader(upgradableDatabase, pageCache, progressMonitor, CreateIndexMigrator(), migrator).migrateIfNeeded(_workingDatabaseLayout); assertTrue(checkNeoStoreHasDefaultFormatVersion(check, _workingDatabaseLayout)); pageCache.Close(); // Since consistency checker is in read only mode we need to start/stop db to generate label scan store. StartStopDatabase(_workingDatabaseLayout.databaseDirectory()); assertConsistentStore(_workingDatabaseLayout); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void mustCloseAllStoresIfNeoStoresFailToOpen() public virtual void MustCloseAllStoresIfNeoStoresFailToOpen() { PageCache pageCache = Rules.pageCache(); DatabaseLayout databaseLayout = Rules.directory().databaseLayout(); Config config = Config.defaults(); FileSystemAbstraction fs = Rules.fileSystem(); IdGeneratorFactory idGenFactory = new DefaultIdGeneratorFactory(fs); LogProvider logProvider = NullLogProvider.Instance; VersionContextSupplier versions = EmptyVersionContextSupplier.EMPTY; RecordFormats formats = Standard.LATEST_RECORD_FORMATS; (new RecordFormatPropertyConfigurator(formats, config)).configure(); bool create = true; StoreType[] storeTypes = StoreType.values(); OpenOption[] openOptions = new OpenOption[0]; NeoStores neoStores = new NeoStores(databaseLayout, config, idGenFactory, pageCache, logProvider, fs, versions, formats, create, storeTypes, openOptions); File schemaStore = neoStores.SchemaStore.StorageFile; neoStores.Close(); // Make the schema store inaccessible, to sabotage the next initialisation we'll do. assumeTrue(schemaStore.setReadable(false)); assumeTrue(schemaStore.setWritable(false)); try { // This should fail due to the permissions we changed above. // And when it fails, the already-opened stores should be closed. new NeoStores(databaseLayout, config, idGenFactory, pageCache, logProvider, fs, versions, formats, create, storeTypes, openOptions); fail("Opening NeoStores should have thrown."); } catch (Exception) { } // We verify that the successfully opened stores were closed again by the failed NeoStores open, // by closing the page cache, which will throw if not all files have been unmapped. pageCache.Close(); }
public override void Close() { _adversary.injectFailure(typeof(System.InvalidOperationException)); @delegate.Close(); }
public override void Close() { @delegate.Close(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void doShouldRecoverFromAnything(boolean replayRecoveryExactlyFromCheckpoint) throws Exception private void DoShouldRecoverFromAnything(bool replayRecoveryExactlyFromCheckpoint) { AssertInitialized(); // GIVEN // a tree which has had random updates and checkpoints in it, load generated with specific seed File file = _directory.file("index"); IList <Action> load = GenerateLoad(); IList <Action> shuffledLoad = RandomCausalAwareShuffle(load); int lastCheckPointIndex = IndexOfLastCheckpoint(load); { // _,_,_,_,_,_,_,c,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,c,_,_,_,_,_,_,_,_,_,_,_ // ^ ^ // | |------------ crash flush index // |-------------------------- last checkpoint index // PageCache pageCache = CreatePageCache(); GBPTree <KEY, VALUE> index = CreateIndex(pageCache, file); // Execute all actions up to and including last checkpoint ... Execute(shuffledLoad.subList(0, lastCheckPointIndex + 1), index); // ... a random amount of the remaining "unsafe" actions ... int numberOfRemainingActions = shuffledLoad.Count - lastCheckPointIndex - 1; int crashFlushIndex = lastCheckPointIndex + _random.Next(numberOfRemainingActions) + 1; Execute(shuffledLoad.subList(lastCheckPointIndex + 1, crashFlushIndex), index); // ... flush ... pageCache.FlushAndForce(); // ... execute the remaining actions Execute(shuffledLoad.subList(crashFlushIndex, shuffledLoad.Count), index); // ... and finally crash _fs.snapshot(throwing(() => { index.Dispose(); pageCache.Close(); })); } // WHEN doing recovery IList <Action> recoveryActions; if (replayRecoveryExactlyFromCheckpoint) { recoveryActions = recoveryActions(load, lastCheckPointIndex + 1); } else { recoveryActions = recoveryActions(load, _random.Next(lastCheckPointIndex + 1)); } // first crashing during recovery int numberOfCrashesDuringRecovery = _random.intBetween(0, 3); for (int i = 0; i < numberOfCrashesDuringRecovery; i++) { using (PageCache pageCache = CreatePageCache(), GBPTree <KEY, VALUE> index = CreateIndex(pageCache, file)) { int numberOfActionsToRecoverBeforeCrashing = _random.intBetween(1, recoveryActions.Count); Recover(recoveryActions.subList(0, numberOfActionsToRecoverBeforeCrashing), index); // ... crash } } // to finally apply all actions after last checkpoint and verify tree using (PageCache pageCache = CreatePageCache(), GBPTree <KEY, VALUE> index = CreateIndex(pageCache, file)) { Recover(recoveryActions, index); // THEN // we should end up with a consistent index containing all the stuff load says index.ConsistencyCheck(); long[] aggregate = ExpectedSortedAggregatedDataFromGeneratedLoad(load); using (RawCursor <Hit <KEY, VALUE>, IOException> cursor = index.Seek(Key(long.MinValue), Key(long.MaxValue))) { for (int i = 0; i < aggregate.Length;) { assertTrue(cursor.Next()); Hit <KEY, VALUE> hit = cursor.get(); AssertEqualsKey(Key(aggregate[i++]), hit.Key()); AssertEqualsValue(Value(aggregate[i++]), hit.Value()); } assertFalse(cursor.Next()); } } }