/// <summary> /// Tests an issue where loading all relationship types and property indexes after /// the neostore data source had been started internally. The db would be in a /// state where it would need recovery for the neostore data source, as well as some /// other data source. This would fail since eventually TxManager#getTransaction() /// would be called, which would fail since it hadn't as of yet recovered fully. /// Whereas that failure would happen in a listener and merely be logged, one effect /// of it would be that there would seem to be no relationship types in the database. /// </summary> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void recoverNeoAndIndexHavingAllRelationshipTypesAfterRecovery() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void RecoverNeoAndIndexHavingAllRelationshipTypesAfterRecovery() { // Given (create transactions and kill process, leaving it needing for recovery) File storeDir = TestDirectory.storeDir(); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: assertEquals(0, Runtime.exec(new string[] { JavaExecutable.ToString(), "-Djava.awt.headless=true", "-cp", ClassPath, this.GetType().FullName, storeDir.AbsolutePath }).waitFor()); // When GraphDatabaseService db = (new TestGraphDatabaseFactory()).newEmbeddedDatabase(storeDir); // Then try { using (Transaction ignored = Db.beginTx(), ResourceIterator <RelationshipType> typeResourceIterator = Db.AllRelationshipTypes.GetEnumerator()) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertEquals(MyRelTypes.TEST.name(), typeResourceIterator.next().name()); } } finally { Db.shutdown(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDumpProcessInformation() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldDumpProcessInformation() { // GIVEN File directory = TestDirectory.directory("dump"); // a process spawned from this test which pauses at a specific point of execution string java = JavaExecutable.ToString(); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: Process process = Runtime.exec(new string[] { java,"-cp",ClassPath,typeof(DumpableProcess).FullName,SIGNAL }); AwaitSignal(process); // WHEN // dumping process information for that spawned process (knowing it's in the expected position) DumpProcessInformation dumper = new DumpProcessInformation(NullLogProvider.Instance,directory); ICollection <Pair <long,string> > pids = dumper.GetJPids(containsString(typeof(DumpableProcess).Name)); // bail if our Java installation is wonky and `jps` doesn't work assumeThat(pids.Count,greaterThan(0)); Pair <long,string> pid = Iterables.single(pids); File threaddumpFile = dumper.DoThreadDump(pid); process.destroy(); // THEN // the produced thread dump should contain that expected method at least //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: assertTrue(FileContains(threaddumpFile,"traceableMethod",typeof(DumpableProcess).FullName)); }
public virtual T Start(P parameter) { DispatcherTrapImpl callback; try { callback = new DispatcherTrapImpl(this, parameter); } catch (RemoteException e) { throw new Exception("Failed to create local RMI endpoint.", e); } Process process; string pid; Dispatcher dispatcher; try { string java = JavaExecutable.ToString(); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: process = Start(_inheritOutput, java, "-ea", "-Xmx1G", "-Djava.awt.headless=true", "-cp", ClassPath(), typeof(SubProcess).FullName, Serialize(callback)); pid = GetPid(process); // if IO was not inherited by current process we need to pipe error and input stream to corresponding // target streams if (!_inheritOutput) { Pipe("[" + ToString() + ":" + pid + "] ", process.ErrorStream, ErrorStreamTarget()); Pipe("[" + ToString() + ":" + pid + "] ", process.InputStream, InputStreamTarget()); } dispatcher = callback.Get(process); } catch (Exception t) { throw new Exception("Failed to start sub process", t); } finally { try { UnicastRemoteObject.unexportObject(callback, true); } catch (RemoteException e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } } requireNonNull(dispatcher); Handler handler = new Handler(t, dispatcher, process, "<" + ToString() + ":" + pid + ">"); return(t.cast(Proxy.newProxyInstance(t.ClassLoader, new Type[] { t }, Live(handler)))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ParameterizedTest @ValueSource(ints = {0, 1}) @DisabledOnOs(org.junit.jupiter.api.condition.OS.WINDOWS) void creatingSwapperForExternallyLockedFileMustThrow(int noChannelStriping) throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void CreatingSwapperForExternallyLockedFileMustThrow(int noChannelStriping) { PageSwapperFactory factory = CreateSwapperFactory(); factory.Open(_fileSystem, Configuration.EMPTY); File file = TestDir.file("file"); _fileSystem.create(file).close(); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: ProcessBuilder pb = new ProcessBuilder(JavaExecutable.ToString(), "-cp", ClassPath, typeof(LockThisFileProgram).FullName, file.AbsolutePath); File wd = (new File("target/test-classes")).AbsoluteFile; pb.directory(wd); Process process = pb.start(); StreamReader stdout = new StreamReader(process.InputStream); Stream stderr = process.ErrorStream; try { assumeThat(stdout.ReadLine(), @is(LockThisFileProgram.LOCKED_OUTPUT)); } catch (Exception e) { int b = stderr.Read(); while (b != -1) { System.err.write(b); b = stderr.Read(); } System.err.flush(); int exitCode = process.waitFor(); Console.WriteLine("exitCode = " + exitCode); throw e; } try { assertThrows(typeof(FileLockException), () => CreateSwapper(factory, file, 4, NoCallback, true, Bool(noChannelStriping))); } finally { process.OutputStream.write(0); process.OutputStream.flush(); process.waitFor(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static java.util.concurrent.Future<int> startSubProcess(Class mainClass, String... arguments) throws java.io.IOException public static Future <int> StartSubProcess(Type mainClass, params string[] arguments) { IList <string> args = new List <string>(); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: ((IList <string>)args).AddRange(asList(JavaExecutable.ToString(), "-cp", ClassPath, mainClass.FullName)); ((IList <string>)args).AddRange(asList(arguments)); Process process = Runtime.Runtime.exec(args.ToArray()); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final ProcessStreamHandler processOutput = new ProcessStreamHandler(process, false); ProcessStreamHandler processOutput = new ProcessStreamHandler(process, false); processOutput.Launch(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.Future<int> realFuture = org.neo4j.helpers.FutureAdapter.processFuture(process); Future <int> realFuture = FutureAdapter.processFuture(process); return(new FutureAnonymousInnerClass(processOutput, realFuture)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static int runBackupToolFromOtherJvmToGetExitCode(java.io.File neo4jHome, java.io.PrintStream outPrintStream, java.io.PrintStream errPrintStream, boolean debug, String... args) throws Exception public static int RunBackupToolFromOtherJvmToGetExitCode(File neo4jHome, PrintStream outPrintStream, PrintStream errPrintStream, bool debug, params string[] args) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: IList <string> allArgs = new List <string>(Arrays.asList(JavaExecutable.ToString(), "-cp", ClassPath, typeof(AdminTool).FullName)); allArgs.Add("backup"); ((IList <string>)allArgs).AddRange(Arrays.asList(args)); ProcessBuilder processBuilder = (new ProcessBuilder()).command(allArgs.ToArray()); processBuilder.environment().put("NEO4J_HOME", neo4jHome.AbsolutePath); if (debug) { processBuilder.environment().put("NEO4J_DEBUG", "anything_works"); } Process process = processBuilder.start(); ProcessStreamHandler processStreamHandler = new ProcessStreamHandler(process, false, "", StreamConsumer.IGNORE_FAILURES, outPrintStream, errPrintStream); return(processStreamHandler.WaitForResult()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testHardCoreRecovery() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TestHardCoreRecovery() { string path = TestDirectory.storeDir().Path; //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: Process process = Runtime.Runtime.exec(new string[] { JavaExecutable.ToString(), "-cp", ProcessUtil.ClassPath, typeof(Inserter).FullName, path }); // Let it run for a while and then kill it, and wait for it to die AwaitFile(new File(path, "started")); Thread.Sleep(5000); process.destroy(); process.waitFor(); GraphDatabaseService db = null; try { db = (new TestGraphDatabaseFactory()).newEmbeddedDatabase(TestDirectory.storeDir()); try { using (Transaction transaction = Db.beginTx()) { assertTrue(Db.index().existsForNodes("myIndex")); Index <Node> index = Db.index().forNodes("myIndex"); foreach (Node node in Db.AllNodes) { foreach (string key in node.PropertyKeys) { string value = ( string )node.GetProperty(key); bool found = false; using (IndexHits <Node> indexHits = index.get(key, value)) { foreach (Node indexedNode in indexHits) { if (indexedNode.Equals(node)) { found = true; break; } } } if (!found) { throw new System.InvalidOperationException(node + " has property '" + key + "'='" + value + "', but not in index"); } } } } } catch (Exception e) { if (Exceptions.contains(e, typeof(CorruptIndexException)) || ExceptionContainsStackTraceElementFromPackage(e, "org.apache.lucene")) { // On some machines and during some circumstances a lucene index may become // corrupted during a crash. This is out of our control and since this test // is about an explicit (a.k.a. legacy/manual) index the db cannot just re-populate the // index automatically. We have to consider this an OK scenario and we cannot // verify the index any further if it happens. Console.Error.WriteLine("Lucene exception happened during recovery after a real crash. " + "It may be that the index is corrupt somehow and this is out of control and not " + "something this test can really improve on right now. Printing the exception for reference"); Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); return; } // This was another unknown exception, throw it so that the test fails with it throw e; } // Added due to a recovery issue where the lucene data source write wasn't released properly after recovery. NodeCreator nodeCreator = new NodeCreator(db); Thread t = new Thread(nodeCreator); t.Start(); t.Join(); } finally { if (db != null) { Db.shutdown(); } } }