//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void readAndWrite(int nReaders, int time, java.util.concurrent.TimeUnit unit) throws Throwable private void ReadAndWrite(int nReaders, int time, TimeUnit unit) { using (DefaultFileSystemAbstraction fsa = new DefaultFileSystemAbstraction()) { LifeSupport lifeSupport = new LifeSupport(); T raftLog = CreateRaftLog(fsa, Dir.directory()); lifeSupport.Add(raftLog); lifeSupport.Start(); try { ExecutorService es = Executors.newCachedThreadPool(); ICollection <Future <long> > futures = new List <Future <long> >(); futures.Add(es.submit(new TimedTask(this, () => write(raftLog), time, unit))); for (int i = 0; i < nReaders; i++) { futures.Add(es.submit(new TimedTask(this, () => read(raftLog), time, unit))); } foreach (Future <long> f in futures) { long iterations = f.get(); } es.shutdown(); } finally { lifeSupport.Shutdown(); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void detectObsoleteCountStoresToRebuildDuringMigration() public virtual void DetectObsoleteCountStoresToRebuildDuringMigration() { FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(); PageCache pageCache = mock(typeof(PageCache)); Config config = Config.defaults(); CountsMigrator storeMigrator = new CountsMigrator(fileSystem, pageCache, config); ISet <string> actualVersions = new HashSet <string>(); //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: //JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter: ISet <string> expectedVersions = java.util.org.neo4j.kernel.impl.store.format.StoreVersion.values().Select(StoreVersion::versionString).collect(Collectors.toSet()); assertTrue(CountsMigrator.CountStoreRebuildRequired(StoreVersion.STANDARD_V2_3.versionString())); actualVersions.Add(StoreVersion.STANDARD_V2_3.versionString()); assertTrue(CountsMigrator.CountStoreRebuildRequired(StoreVersion.STANDARD_V3_0.versionString())); actualVersions.Add(StoreVersion.STANDARD_V3_0.versionString()); assertFalse(CountsMigrator.CountStoreRebuildRequired(StoreVersion.STANDARD_V3_2.versionString())); actualVersions.Add(StoreVersion.STANDARD_V3_2.versionString()); assertFalse(CountsMigrator.CountStoreRebuildRequired(StoreVersion.STANDARD_V3_4.versionString())); actualVersions.Add(StoreVersion.STANDARD_V3_4.versionString()); assertTrue(CountsMigrator.CountStoreRebuildRequired(StoreVersion.HIGH_LIMIT_V3_0_0.versionString())); actualVersions.Add(StoreVersion.HIGH_LIMIT_V3_0_0.versionString()); assertTrue(CountsMigrator.CountStoreRebuildRequired(StoreVersion.HIGH_LIMIT_V3_0_6.versionString())); actualVersions.Add(StoreVersion.HIGH_LIMIT_V3_0_6.versionString()); assertTrue(CountsMigrator.CountStoreRebuildRequired(StoreVersion.HIGH_LIMIT_V3_1_0.versionString())); actualVersions.Add(StoreVersion.HIGH_LIMIT_V3_1_0.versionString()); assertFalse(CountsMigrator.CountStoreRebuildRequired(StoreVersion.HIGH_LIMIT_V3_2_0.versionString())); actualVersions.Add(StoreVersion.HIGH_LIMIT_V3_2_0.versionString()); assertFalse(CountsMigrator.CountStoreRebuildRequired(StoreVersion.HIGH_LIMIT_V3_4_0.versionString())); actualVersions.Add(StoreVersion.HIGH_LIMIT_V3_4_0.versionString()); assertEquals(expectedVersions, actualVersions); }
//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()); } }
public override int Start(File homeDir, Optional <File> configFile, IDictionary <string, string> configOverrides) { Config config = GetConfig(configFile, configOverrides); try { DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(); _life.add(new FileSystemLifecycleAdapter(fileSystem)); _life.add(createScheduler()); new ClusterClientModule(_life, new Dependencies(), new Monitors(), config, LogService(fileSystem, config), new NotElectableElectionCredentialsProvider()); } catch (LifecycleException e) { //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "unchecked"}) Throwable cause = peel(e, org.neo4j.function.Predicates.instanceOf(org.neo4j.kernel.lifecycle.LifecycleException.class)); Exception cause = peel(e, Predicates.instanceOf(typeof(LifecycleException))); if (cause is ChannelException) { Console.Error.WriteLine("ERROR: " + cause.Message + (cause.InnerException != null ? ", caused by:" + cause.InnerException.Message : "")); } else { Console.Error.WriteLine("ERROR: Unknown error"); throw e; } } AddShutdownHook(); _life.start(); return(0); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static BatchInserter inserter(java.io.File databaseDirectory, java.util.Map<String, String> config, Iterable<org.neo4j.kernel.extension.KernelExtensionFactory<?>> kernelExtensions) throws java.io.IOException public static BatchInserter Inserter <T1>(File databaseDirectory, IDictionary <string, string> config, IEnumerable <T1> kernelExtensions) { DefaultFileSystemAbstraction fileSystem = CreateFileSystem(); BatchInserterImpl inserter = new BatchInserterImpl(databaseDirectory, fileSystem, config, kernelExtensions); return(new FileSystemClosingBatchInserter(inserter, inserter, fileSystem)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static BatchInserter inserter(java.io.File databaseDirectory, java.util.Map<String,String> config) throws java.io.IOException public static BatchInserter Inserter(File databaseDirectory, IDictionary <string, string> config) { DefaultFileSystemAbstraction fileSystem = CreateFileSystem(); BatchInserter inserter = inserter(databaseDirectory, fileSystem, config, LoadKernelExtension()); return(new FileSystemClosingBatchInserter(inserter, ( IndexConfigStoreProvider )inserter, fileSystem)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void rotationShouldNotDeadlockOnListener() internal virtual void RotationShouldNotDeadlockOnListener() { assertTimeout(ofMillis(TEST_TIMEOUT_MILLIS), () => { string logContent = "Output file created"; AtomicReference <Exception> listenerException = new AtomicReference <Exception>(null); System.Threading.CountdownEvent latch = new System.Threading.CountdownEvent(1); RotationListener listener = new RotationListenerAnonymousInnerClass(this, listenerException, latch); ExecutorService executor = Executors.newSingleThreadExecutor(); DefaultFileSystemAbstraction defaultFileSystemAbstraction = new DefaultFileSystemAbstraction(); RotatingFileOutputStreamSupplier supplier = new RotatingFileOutputStreamSupplier(defaultFileSystemAbstraction, _logFile, 0, 0, 10, executor, listener); Stream outputStream = supplier.Get(); LockingPrintWriter lockingPrintWriter = new LockingPrintWriter(this, outputStream); lockingPrintWriter.WithLock(() => { supplier.Rotate(); latch.await(); return(Void.TYPE); }); ShutDownExecutor(executor); IList <string> strings = Files.readAllLines(_logFile.toPath()); string actual = string.join("", strings); assertEquals(logContent, actual); assertNull(listenerException.get()); }); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private java.io.File createNeoStore(java.io.File dbDir, int classicNodeCount) throws java.io.IOException private File CreateNeoStore(File dbDir, int classicNodeCount) { using (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) { return(ClassicNeo4jStore.builder(dbDir, fileSystem).amountOfNodes(classicNodeCount).recordFormats(RecordFormat).build().StoreDir); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static void main(String[] args) throws java.io.IOException public static void Main(string[] args) { using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) { _console.printf("Neo4j Raw Store Diagnostics Reader%n"); if (args.Length != 1 || !fileSystem.IsDirectory(new File(args[0]))) { _console.printf("Usage: rsdr <store directory>%n"); return; } File databaseDirectory = new File(args[0]); DatabaseLayout databaseLayout = DatabaseLayout.of(databaseDirectory); Config config = BuildConfig(); JobScheduler jobScheduler = createInitialisedScheduler(); using (PageCache pageCache = createPageCache(fileSystem, config, jobScheduler)) { File neoStore = databaseLayout.MetadataStore(); StoreFactory factory = OpenStore(fileSystem, neoStore, config, pageCache); NeoStores neoStores = factory.OpenAllNeoStores(); Interact(fileSystem, neoStores, databaseLayout); } } }
/// <summary> /// Get a <seealso cref="BatchInserter"/> given a store directory. /// </summary> /// <param name="databaseDirectory"> directory where particular neo4j database is located </param> /// <returns> a new <seealso cref="BatchInserter"/> </returns> /// <exception cref="IOException"> if there is an IO error </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static BatchInserter inserter(java.io.File databaseDirectory) throws java.io.IOException public static BatchInserter Inserter(File databaseDirectory) { DefaultFileSystemAbstraction fileSystem = CreateFileSystem(); BatchInserter batchInserter = Inserter(databaseDirectory, fileSystem, stringMap()); return(new FileSystemClosingBatchInserter(batchInserter, ( IndexConfigStoreProvider )batchInserter, fileSystem)); }
//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); }
/// <summary> /// Dumps a label scan write log as plain text. Arguments: /// <ul> /// <li>{@value #ARG_TOFILE}: dumps to a .txt file next to the writelog</li> /// <li>{@value #ARG_TXFILTER}: filter for which tx ids to include in the dump. /// <para> /// Consists of one or more groups separated by comma. /// </para> /// <para> /// Each group is either a txId, or a txId range, e.g. 123-456 /// </li> /// </ul> /// </para> /// <para> /// How to interpret the dump, e.g: /// <pre> /// === ..../neostore.labelscanstore.db.writelog === /// [1,1]+tx:6,node:0,label:0 /// [1,1]+tx:3,node:20,label:0 /// [1,1]+tx:4,node:40,label:0 /// [1,1]+tx:5,node:60,label:0 /// [2,1]+tx:8,node:80,label:1 /// [3,1]+tx:10,node:41,label:1 /// [4,1]+tx:9,node:21,label:1 /// [4,1]+tx:11,node:61,label:1 /// [4,1]+range:0,labelId:1 /// [00000000 00000000 00000010 00000000 00000000 00000000 00000000 00000000] /// [00100000 00000000 00000000 00000000 00000000 00100000 00000000 00000000] /// [5,1]+tx:12,node:81,label:1 /// [5,1]+range:1,labelId:1 /// [00000000 00000000 00000000 00000000 00000000 00000001 00000000 00000000] /// [00000000 00000000 00000000 00000000 00000000 00000010 00000000 00000000] /// [6,1]+tx:13,node:1,label:1 /// [6,1]+range:0,labelId:1 /// [00100000 00000000 00000010 00000000 00000000 00100000 00000000 00000000] /// [00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000010] /// [7,1]+tx:14,node:62,label:1 /// [7,1]+range:0,labelId:1 /// </pre> /// How to interpret a message like: /// <pre> /// [1,1]+tx:6,node:0,label:0 /// ▲ ▲ ▲ ▲ ▲ ▲ /// │ │ │ │ │ └──── label id of the change /// │ │ │ │ └──────────── node id of the change /// │ │ │ └─────────────────── id of transaction making this particular change /// │ │ └─────────────────────── addition, a minus means removal /// │ └───────────────────────── flush, local to each write session, incremented when a batch of changes is flushed internally in a writer session /// └─────────────────────────── write session, incremented for each <seealso cref="LabelScanStore.newWriter()"/> /// </pre> /// How to interpret a message like: /// <pre> /// [4,1]+range:0,labelId:1 /// [00000000 00000000 00000010 00000000 00000000 00000000 00000000 00000000] /// [00100000 00000000 00000000 00000000 00000000 00100000 00000000 00000000] /// </pre> /// First the first line (parts within bracket same as above): /// <pre> /// [4,1]+range:0,labelId:1 /// ▲ ▲ /// │ └── label id of the changed bitset to apply /// └──────────── range, i.e. which bitset to apply this change for /// </pre> /// Then the bitsets are printed /// <pre> /// [00000000 00000000 00000010 00000000 00000000 00000000 00000000 00000000] : state of the bitset for this label id before the change /// [00100000 00000000 00000000 00000000 00000000 00100000 00000000 00000000] : bits that applied to this bitset /// for addition the 1-bits denotes bits to be added /// for removal the 1-bits denotes bits to be removed /// </pre> /// </para> /// </summary> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static void main(String[] args) throws java.io.IOException public static void Main(string[] args) { Args arguments = Args.withFlags(ARG_TOFILE).parse(args); if (arguments.Orphans().Count == 0) { Console.Error.WriteLine("Please supply database directory"); return; } DatabaseLayout databaseLayout = DatabaseLayout.of(new File(arguments.Orphans()[0])); FileSystemAbstraction fs = new DefaultFileSystemAbstraction(); TxFilter txFilter = ParseTxFilter(arguments.Get(ARG_TXFILTER, null)); PrintStream @out = System.out; bool redirectsToFile = arguments.GetBoolean(ARG_TOFILE); if (redirectsToFile) { File outFile = new File(WriteLogBaseFile(databaseLayout).AbsolutePath + ".txt"); Console.WriteLine("Redirecting output to " + outFile); @out = new PrintStream(new BufferedOutputStream(new FileStream(outFile, FileMode.Create, FileAccess.Write))); } Dumper dumper = new PrintStreamDumper(@out); Dump(fs, databaseLayout, dumper, txFilter); if (redirectsToFile) { @out.close(); } }
//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); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void runConsistencyCheckToolWith(ConsistencyCheckService consistencyCheckService, java.io.PrintStream printStream, String... args) throws org.neo4j.consistency.ConsistencyCheckTool.ToolFailureException, java.io.IOException private static void RunConsistencyCheckToolWith(ConsistencyCheckService consistencyCheckService, PrintStream printStream, params string[] args) { using (FileSystemAbstraction fileSystemAbstraction = new DefaultFileSystemAbstraction()) { (new ConsistencyCheckTool(consistencyCheckService, fileSystemAbstraction, printStream, printStream)).Run(args); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void assertCanLockStore(java.nio.file.Path databaseDirectory) throws java.io.IOException private static void AssertCanLockStore(Path databaseDirectory) { using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), StoreLocker storeLocker = new StoreLocker(fileSystem, DatabaseLayout.of(databaseDirectory.toFile()).StoreLayout)) { storeLocker.CheckLock(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void clearLastTransactionCommitTimestampField(org.neo4j.io.layout.DatabaseLayout databaseLayout) throws Exception private static void ClearLastTransactionCommitTimestampField(DatabaseLayout databaseLayout) { using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), JobScheduler jobScheduler = createInitialisedScheduler(), PageCache pageCache = createPageCache(fileSystem, jobScheduler)) { File neoStore = databaseLayout.MetadataStore(); MetaDataStore.setRecord(pageCache, neoStore, LAST_TRANSACTION_COMMIT_TIMESTAMP, MetaDataStore.BASE_TX_COMMIT_TIMESTAMP); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static long versionBy(java.io.File raftLogDir, System.Func<long, long, long> operator) throws java.io.IOException private static long VersionBy(File raftLogDir, System.Func <long, long, long> @operator) { using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) { SortedDictionary <long, File> logs = (new FileNames(raftLogDir)).getAllFiles(fileSystem, mock(typeof(Log))); //JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter: return(logs.Keys.Aggregate(@operator).orElseThrow(System.InvalidOperationException::new)); } }
public override ServerControls NewServer() { try { using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) { File userLogFile = new File(_serverFolder, "neo4j.log"); File internalLogFile = new File(_serverFolder, "debug.log"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.io.OutputStream logOutputStream; Stream logOutputStream; try { logOutputStream = createOrOpenAsOutputStream(fileSystem, userLogFile, true); } catch (IOException e) { throw new Exception("Unable to create log file", e); } _config[ServerSettings.third_party_packages.name()] = ToStringForThirdPartyPackageProperty(_extensions.toList()); _config[GraphDatabaseSettings.store_internal_log_path.name()] = internalLogFile.AbsolutePath; LogProvider userLogProvider = FormattedLogProvider.withZoneId(LogZoneIdFrom(_config)).toOutputStream(logOutputStream); GraphDatabaseDependencies dependencies = GraphDatabaseDependencies.newDependencies().userLogProvider(userLogProvider); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: Iterable<org.neo4j.kernel.extension.KernelExtensionFactory<?>> kernelExtensions = append(new Neo4jHarnessExtensions(procedures), dependencies.kernelExtensions()); IEnumerable <KernelExtensionFactory <object> > kernelExtensions = append(new Neo4jHarnessExtensions(_procedures), dependencies.KernelExtensions()); dependencies = dependencies.KernelExtensions(kernelExtensions); Config dbConfig = Config.defaults(_config); GraphFactory graphFactory = CreateGraphFactory(dbConfig); bool httpAndHttpsDisabled = dbConfig.EnabledHttpConnectors().Count == 0; NeoServer server = httpAndHttpsDisabled ? new DisabledNeoServer(graphFactory, dependencies, dbConfig) : CreateNeoServer(graphFactory, dbConfig, dependencies); InProcessServerControls controls = new InProcessServerControls(_serverFolder, userLogFile, internalLogFile, server, logOutputStream); controls.Start(); try { _fixtures.applyTo(controls); } catch (Exception e) { controls.Close(); throw e; } return(controls); } } catch (IOException e) { throw new Exception(e); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.consistency.ConsistencyCheckService.Result fullConsistencyCheck() throws org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException, java.io.IOException private ConsistencyCheckService.Result FullConsistencyCheck() { using (FileSystemAbstraction fsa = new DefaultFileSystemAbstraction()) { ConsistencyCheckService service = new ConsistencyCheckService(); Config config = Config.defaults(); return(service.runFullConsistencyCheck(Db.databaseLayout(), config, NONE, _log, fsa, true, new ConsistencyFlags(config))); } }
internal static PageCache PageCache(JobScheduler jobScheduler) { SingleFilePageSwapperFactory swapper = new SingleFilePageSwapperFactory(); DefaultFileSystemAbstraction fs = new DefaultFileSystemAbstraction(); swapper.Open(fs, EMPTY); PageCursorTracerSupplier cursorTracerSupplier = Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null; return(new MuninnPageCache(swapper, 100, NULL, cursorTracerSupplier, EmptyVersionContextSupplier.EMPTY, jobScheduler)); }
//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 static void deleteLogs(org.neo4j.io.layout.DatabaseLayout databaseLayout) throws java.io.IOException private static void DeleteLogs(DatabaseLayout databaseLayout) { using (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) { LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(databaseLayout.DatabaseDirectory(), fileSystem).build(); foreach (File file in logFiles.LogFilesConflict()) { fileSystem.DeleteFile(file); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void deleteAllLogsOn(java.io.File storeDirectory) throws java.io.IOException private static void DeleteAllLogsOn(File storeDirectory) { using (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) { LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(storeDirectory, fileSystem).build(); foreach (File file in logFiles.LogFilesConflict()) { fileSystem.DeleteFile(file); } } }
//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(params string[] args) { if (args.Length != 1) { Console.Error.WriteLine("Expecting exactly one argument describing the path to the store"); Environment.Exit(1); } using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) { DumpCountsStoreConflict(fileSystem, new File(args[0]), System.out); } }
//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 TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldRespectTheStoreLock() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldRespectTheStoreLock() { Path databaseDirectory = _homeDir.resolve("data/databases/foo.db"); StoreLayout storeLayout = DatabaseLayout.of(databaseDirectory.toFile()).StoreLayout; using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), StoreLocker storeLocker = new StoreLocker(fileSystem, storeLayout)) { storeLocker.CheckLock(); CommandFailed commandFailed = assertThrows(typeof(CommandFailed), () => execute("foo.db")); assertEquals("the database is in use -- stop Neo4j and try again", commandFailed.Message); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReplicateTransactionToCoreMembers() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReplicateTransactionToCoreMembers() { // given TestDirectory testDirectory = ClusterRule.testDirectory(); File dbDir = testDirectory.CleanDirectory("classic-db-" + RecordFormat); int classicNodeCount = 1024; File classicNeo4jStore = CreateNeoStore(dbDir, classicNodeCount); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.neo4j.causalclustering.discovery.Cluster<?> cluster = this.clusterRule.withRecordFormat(recordFormat).createCluster(); Cluster <object> cluster = this.ClusterRule.withRecordFormat(RecordFormat).createCluster(); using (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) { foreach (CoreClusterMember core in cluster.CoreMembers()) { (new RestoreDatabaseCommand(fileSystem, classicNeo4jStore, core.Config(), core.SettingValue(GraphDatabaseSettings.active_database.name()), true)).execute(); } } cluster.Start(); // when cluster.CoreTx((coreDB, tx) => { Node node = coreDB.createNode(label("boo")); node.setProperty("foobar", "baz_bat"); tx.success(); }); cluster.AddReadReplicaWithIdAndRecordFormat(4, RecordFormat).start(); // then foreach (CoreClusterMember server in cluster.CoreMembers()) { CoreGraphDatabase db = server.database(); using (Transaction tx = Db.beginTx()) { ThrowingSupplier <long, Exception> nodeCount = () => count(Db.AllNodes); Config config = Db.DependencyResolver.resolveDependency(typeof(Config)); assertEventually("node to appear on core server " + config.Get(raft_advertised_address), nodeCount, greaterThan(( long )classicNodeCount), 15, SECONDS); assertEquals(classicNodeCount + 1, count(Db.AllNodes)); tx.Success(); } } }
private static long LastAppliedTx(DatabaseLayout databaseLayout) { try { using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), JobScheduler scheduler = createInitialisedScheduler(), PageCache pageCache = createPageCache(fileSystem, scheduler)) { return(MetaDataStore.getRecord(pageCache, databaseLayout.MetadataStore(), MetaDataStore.Position.LAST_TRANSACTION_ID)); } } catch (Exception e) { throw new Exception(e); } }
//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() { DefaultFileSystemAbstraction fs = this._fs.get(); PageCache pc = _pageCacheRule.getPageCache(fs); File file = _directory.file("index"); GenericLayout layout = new GenericLayout(1, _indexSettings); RecoveryCleanupWorkCollector collector = RecoveryCleanupWorkCollector.ignore(); _descriptor = TestIndexDescriptorFactory.forLabel(1, 1).withId(1); IndexDirectoryStructure.Factory factory = IndexDirectoryStructure.directoriesByProvider(_directory.storeDir()); IndexDirectoryStructure structure = factory.ForProvider(GenericNativeIndexProvider.Descriptor); IndexDropAction dropAction = new FileSystemIndexDropAction(fs, structure); _accessor = new GenericNativeIndexAccessor(pc, fs, file, layout, collector, EMPTY, _descriptor, _indexSettings, new StandardConfiguration(), dropAction, false); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test @DisabledOnOs(org.junit.jupiter.api.condition.OS.WINDOWS) void shouldReportAHelpfulErrorIfWeDontHaveWritePermissionsForLock() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldReportAHelpfulErrorIfWeDontHaveWritePermissionsForLock() { StoreLayout storeLayout = DatabaseLayout.of(_databaseDirectory.toFile()).StoreLayout; using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), StoreLocker storeLocker = new StoreLocker(fileSystem, storeLayout)) { storeLocker.CheckLock(); using (System.IDisposable ignored = withPermissions(storeLayout.StoreLockFile().toPath(), emptySet())) { CommandFailed commandFailed = assertThrows(typeof(CommandFailed), () => execute("foo.db")); assertEquals(commandFailed.Message, "you do not have permission to dump the database -- is Neo4j running as a different user?"); } } }