//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void stop() throws Throwable public override void Stop() { _msgLog.debug("Shutting down NetworkSender"); foreach (ExecutorService executorService in _senderExecutors.Values) { executorService.shutdown(); } long totalWaitTime = 0; long maxWaitTime = SECONDS.toMillis(5); foreach (KeyValuePair <URI, ExecutorService> entry in _senderExecutors.SetOfKeyValuePairs()) { URI targetAddress = entry.Key; ExecutorService executorService = entry.Value; long start = currentTimeMillis(); if (!executorService.awaitTermination(maxWaitTime - totalWaitTime, MILLISECONDS)) { _msgLog.warn("Could not shut down send executor towards: " + targetAddress); break; } totalWaitTime += currentTimeMillis() - start; } _senderExecutors.Clear(); _channels.close().awaitUninterruptibly(); _clientBootstrap.releaseExternalResources(); _msgLog.debug("Shutting down NetworkSender for " + ToString(_config) + " complete"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCheckPointBasedOnTime() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCheckPointBasedOnTime() { // given long millis = 200; GraphDatabaseService db = _builder.setConfig(GraphDatabaseSettings.check_point_interval_time, millis + "ms").setConfig(GraphDatabaseSettings.check_point_interval_tx, "10000").setConfig(GraphDatabaseSettings.logical_log_rotation_threshold, "1g").newGraphDatabase(); // when using (Transaction tx = Db.beginTx()) { Db.createNode(); tx.Success(); } // The scheduled job checking whether or not checkpoints are needed runs more frequently // now that we've set the time interval so low, so we can simply wait for it here long endTime = currentTimeMillis() + SECONDS.toMillis(30); while (!CheckPointInTxLog(db)) { Thread.Sleep(millis); assertTrue("Took too long to produce a checkpoint", currentTimeMillis() < endTime); } Db.shutdown(); // then - 2 check points have been written in the log IList <CheckPoint> checkPoints = (new CheckPointCollector(TestDirectory.databaseDir(), _fs)).find(0); assertTrue("Expected at least two (at least one for time interval and one for shutdown), was " + checkPoints.ToString(), checkPoints.Count >= 2); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldNotRotateLogWhenSizeExceededButNotDelay() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldNotRotateLogWhenSizeExceededButNotDelay() { UpdatableLongSupplier clock = new UpdatableLongSupplier(DateTimeHelper.CurrentUnixTimeMillis()); RotatingFileOutputStreamSupplier supplier = new RotatingFileOutputStreamSupplier(clock, _fileSystem, _logFile, 10, SECONDS.toMillis(60), 10, _directExecutor, new RotationListener()); Write(supplier, "A string longer than 10 bytes"); assertThat(_fileSystem.fileExists(_logFile), @is(true)); assertThat(_fileSystem.fileExists(_archiveLogFile1), @is(false)); Write(supplier, "A string longer than 10 bytes"); assertThat(_fileSystem.fileExists(_logFile), @is(true)); assertThat(_fileSystem.fileExists(_archiveLogFile1), @is(true)); assertThat(_fileSystem.fileExists(_archiveLogFile2), @is(false)); Write(supplier, "A string longer than 10 bytes"); clock.Value = clock.AsLong + SECONDS.toMillis(59); Write(supplier, "A string longer than 10 bytes"); clock.Value = clock.AsLong + SECONDS.toMillis(1); Write(supplier, "A string longer than 10 bytes"); assertThat(_fileSystem.fileExists(_logFile), @is(true)); assertThat(_fileSystem.fileExists(_archiveLogFile1), @is(true)); assertThat(_fileSystem.fileExists(_archiveLogFile2), @is(true)); assertThat(_fileSystem.fileExists(_archiveLogFile3), @is(false)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void thoroughlyTestIt() internal virtual void ThoroughlyTestIt() { long endTime = currentTimeMillis() + SECONDS.toMillis(5); while (currentTimeMillis() < endTime) { long seed = currentTimeMillis(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.Random random = new java.util.Random(seed); Random random = new Random(seed); int max = random.Next(10_000) + 100; RandomizedTester <Maps, string> actions = new RandomizedTester <Maps, string>(MapFactory(), ActionFactory(random)); Result <Maps, string> result = actions.Run(max); if (result.Failure) { Console.WriteLine("Found failure at " + result); actions.TestCaseWriter("shouldOnlyContainAddedValues", Given()).print(System.out); Console.WriteLine("Actually, minimal reproducible test of that is..."); actions.FindMinimalReproducible().testCaseWriter("shouldOnlyContainAddedValues", Given()).print(System.out); fail("Failed, see printed test case for how to reproduce. Seed:" + seed); } FullVerification(result.Target, random); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldInterpretAUnitlessTimeoutAsSeconds() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldInterpretAUnitlessTimeoutAsSeconds() { OnlineBackupContextFactory handler = new OnlineBackupContextFactory(_homeDir, _configDir); OnlineBackupContext context = handler.CreateContext("--timeout=10", "--backup-dir=/", "--name=mybackup"); OnlineBackupRequiredArguments requiredArguments = context.RequiredArguments; assertEquals(SECONDS.toMillis(10), requiredArguments.Timeout); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void waitForFileToAppear(java.io.File file) throws InterruptedException private void WaitForFileToAppear(File file) { long end = currentTimeMillis() + SECONDS.toMillis(10); while (!file.exists()) { Thread.Sleep(10); if (currentTimeMillis() > end) { fail(file + " didn't appear"); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldDoProcessingInitializationInOrder() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldDoProcessingInitializationInOrder() { // GIVEN //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.test.Race race = new org.neo4j.test.Race(); Race race = new Race(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicInteger coordination = new java.util.concurrent.atomic.AtomicInteger(-1); AtomicInteger coordination = new AtomicInteger(-1); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicInteger expected = new java.util.concurrent.atomic.AtomicInteger(); AtomicInteger expected = new AtomicInteger(); const int threads = 30; //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") final RecordCheckWorker<int>[] workers = new RecordCheckWorker[threads]; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': RecordCheckWorker <int>[] workers = new RecordCheckWorker[threads]; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final RecordProcessor<int> processor = new RecordProcessor_Adapter<int>() RecordProcessor <int> processor = new RecordProcessor_AdapterAnonymousInnerClass(this, expected); for (int id = 0; id < threads; id++) { ArrayBlockingQueue <int> queue = new ArrayBlockingQueue <int>(10); race.AddContestant(workers[id] = new RecordCheckWorker <int>(id, coordination, queue, processor)); } race.AddContestant(() => { try { long end = currentTimeMillis() + SECONDS.toMillis(100); while (currentTimeMillis() < end && expected.get() < threads) { parkNanos(MILLISECONDS.toNanos(10)); } assertEquals(threads, expected.get()); } finally { foreach (RecordCheckWorker <int> worker in workers) { worker.Done(); } } }); // WHEN race.Go(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void setUpgradeTransactionMustBeAtomic() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SetUpgradeTransactionMustBeAtomic() { using (MetaDataStore store = NewMetaDataStore()) { PagedFile pf = store.PagedFile; store.SetUpgradeTransaction(0, 0, 0); AtomicLong writeCount = new AtomicLong(); AtomicLong fileReadCount = new AtomicLong(); AtomicLong apiReadCount = new AtomicLong(); int upperLimit = 10_000; int lowerLimit = 100; long endTime = currentTimeMillis() + SECONDS.toMillis(10); Race race = new Race(); race.WithEndCondition(() => writeCount.get() >= upperLimit && fileReadCount.get() >= upperLimit && apiReadCount.get() >= upperLimit); race.WithEndCondition(() => writeCount.get() >= lowerLimit && fileReadCount.get() >= lowerLimit && apiReadCount.get() >= lowerLimit && currentTimeMillis() >= endTime); // writers race.AddContestants(3, () => { long count = writeCount.incrementAndGet(); store.SetUpgradeTransaction(count, count, count); }); // file readers race.AddContestants(3, throwing(() => { using (PageCursor cursor = pf.Io(0, PagedFile.PF_SHARED_READ_LOCK)) { assertTrue(cursor.next()); long id; long checksum; do { id = store.GetRecordValue(cursor, MetaDataStore.Position.UpgradeTransactionId); checksum = store.GetRecordValue(cursor, MetaDataStore.Position.UpgradeTransactionChecksum); } while (cursor.shouldRetry()); AssertIdEqualsChecksum(id, checksum, "file"); fileReadCount.incrementAndGet(); } })); race.AddContestants(3, () => { TransactionId transaction = store.UpgradeTransaction; AssertIdEqualsChecksum(transaction.TransactionIdConflict(), transaction.Checksum(), "API"); apiReadCount.incrementAndGet(); }); race.Go(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void transactionClosedMustBeAtomic() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TransactionClosedMustBeAtomic() { using (MetaDataStore store = NewMetaDataStore()) { PagedFile pf = store.PagedFile; int initialValue = 2; store.TransactionClosed(initialValue, initialValue, initialValue); AtomicLong writeCount = new AtomicLong(); AtomicLong fileReadCount = new AtomicLong(); AtomicLong apiReadCount = new AtomicLong(); int upperLimit = 10_000; int lowerLimit = 100; long endTime = currentTimeMillis() + SECONDS.toMillis(10); Race race = new Race(); race.WithEndCondition(() => writeCount.get() >= upperLimit && fileReadCount.get() >= upperLimit && apiReadCount.get() >= upperLimit); race.WithEndCondition(() => writeCount.get() >= lowerLimit && fileReadCount.get() >= lowerLimit && apiReadCount.get() >= lowerLimit && currentTimeMillis() >= endTime); race.AddContestants(3, () => { long count = writeCount.incrementAndGet(); store.TransactionCommitted(count, count, count); }); race.AddContestants(3, throwing(() => { using (PageCursor cursor = pf.Io(0, PagedFile.PF_SHARED_READ_LOCK)) { assertTrue(cursor.next()); long logVersion; long byteOffset; do { logVersion = store.GetRecordValue(cursor, MetaDataStore.Position.LastClosedTransactionLogVersion); byteOffset = store.GetRecordValue(cursor, MetaDataStore.Position.LastClosedTransactionLogByteOffset); } while (cursor.shouldRetry()); AssertLogVersionEqualsByteOffset(logVersion, byteOffset, "file"); fileReadCount.incrementAndGet(); } })); race.AddContestants(3, () => { long[] transaction = store.LastClosedTransaction; AssertLogVersionEqualsByteOffset(transaction[0], transaction[1], "API"); apiReadCount.incrementAndGet(); }); race.Go(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void waitUntilAllProperlyAvailable(HighlyAvailableGraphDatabase db, Object... expected) throws InterruptedException private static void WaitUntilAllProperlyAvailable(HighlyAvailableGraphDatabase db, params object[] expected) { ClusterMembers members = Db.DependencyResolver.resolveDependency(typeof(ClusterMembers)); long endTime = currentTimeMillis() + SECONDS.toMillis(120); IDictionary <int, string> expectedStates = ToExpectedStatesMap(expected); while (currentTimeMillis() < endTime && !AllMembersAreAsExpected(members, expectedStates)) { Thread.Sleep(100); } if (!AllMembersAreAsExpected(members, expectedStates)) { throw new System.InvalidOperationException("Not all members available, according to " + db); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldWriteOutThePropertyRecordBeforeReferencingItFromANodeRecord() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldWriteOutThePropertyRecordBeforeReferencingItFromANodeRecord() { Race race = new Race(); long[] latestNodeId = new long[1]; AtomicLong writes = new AtomicLong(); AtomicLong reads = new AtomicLong(); long endTime = currentTimeMillis() + SECONDS.toMillis(2); race.WithEndCondition(() => (writes.get() > 100 && reads.get() > 10_000) || currentTimeMillis() > endTime); race.AddContestant(() => { using (Transaction tx = Db.beginTx()) { Node node = Db.createNode(); latestNodeId[0] = node.Id; node.setProperty("largeProperty", LONG_STRING_VALUE); tx.success(); } writes.incrementAndGet(); }); race.AddContestant(() => { try { using (Transaction tx = Db.GraphDatabaseAPI.beginTx()) { Node node = Db.GraphDatabaseAPI.getNodeById(latestNodeId[0]); foreach (string propertyKey in node.PropertyKeys) { node.getProperty(propertyKey); } tx.success(); } } catch (NotFoundException e) { if (Exceptions.contains(e, typeof(InvalidRecordException))) { throw e; } } reads.incrementAndGet(); }); race.Go(); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: static String formatInterval(final long l) internal static string FormatInterval(long l) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long hr = MILLISECONDS.toHours(l); long hr = MILLISECONDS.toHours(l); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long min = MILLISECONDS.toMinutes(l - HOURS.toMillis(hr)); long min = MILLISECONDS.toMinutes(l - HOURS.toMillis(hr)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long sec = MILLISECONDS.toSeconds(l - HOURS.toMillis(hr) - MINUTES.toMillis(min)); long sec = MILLISECONDS.toSeconds(l - HOURS.toMillis(hr) - MINUTES.toMillis(min)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long ms = l - HOURS.toMillis(hr) - MINUTES.toMillis(min) - SECONDS.toMillis(sec); long ms = l - HOURS.toMillis(hr) - MINUTES.toMillis(min) - SECONDS.toMillis(sec); return(string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}", hr, min, sec, ms)); }
public override void Run() { if (!DbHealthSupplier.get().Healthy) { CatchUpFuture.completeExceptionally(DbHealthSupplier.get().cause()); } else if (IAmAVotingMember() && CaughtUpWithLeader()) { CatchUpFuture.complete(true); outerInstance.monitor.JoinedRaftGroup(); } else { outerInstance.currentCatchupDelayInMs += SECONDS.toMillis(1); long longerDelay = outerInstance.currentCatchupDelayInMs < outerInstance.maxCatchupLag ? outerInstance.currentCatchupDelayInMs : outerInstance.maxCatchupLag; outerInstance.jobScheduler.Schedule(Group.MEMBERSHIP_WAITER, this, longerDelay, MILLISECONDS); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void tryToTriggerRelationshipLoadingStoppingMidWay(int denseNodeThreshold) throws Throwable private void TryToTriggerRelationshipLoadingStoppingMidWay(int denseNodeThreshold) { GraphDatabaseAPI db = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).newImpermanentDatabaseBuilder().setConfig(dense_node_threshold, "" + denseNodeThreshold).newGraphDatabase(); Node node = CreateNodeWithRelationships(db); CheckStateToHelpDiagnoseFlakyTest(db, node); long end = currentTimeMillis() + SECONDS.toMillis(5); int iterations = 0; while (currentTimeMillis() < end && iterations < 100) { TryOnce(db, node); iterations++; } Db.shutdown(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldWriteOutTheDynamicChainBeforeUpdatingThePropertyRecord() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldWriteOutTheDynamicChainBeforeUpdatingThePropertyRecord() { Race race = new Race(); long[] latestNodeId = new long[1]; AtomicLong writes = new AtomicLong(); AtomicLong reads = new AtomicLong(); long endTime = currentTimeMillis() + SECONDS.toMillis(2); race.WithEndCondition(() => (writes.get() > 100 && reads.get() > 10_000) || currentTimeMillis() > endTime); race.AddContestant(() => { using (Transaction tx = Db.beginTx()) { Node node = Db.createNode(); latestNodeId[0] = node.Id; node.setProperty("largeProperty", LONG_STRING_VALUE); tx.success(); } writes.incrementAndGet(); }); race.AddContestant(() => { try { using (Transaction tx = Db.GraphDatabaseAPI.beginTx()) { Node node = Db.GraphDatabaseAPI.getNodeById(latestNodeId[0]); foreach (string propertyKey in node.PropertyKeys) { node.getProperty(propertyKey); } tx.success(); } } catch (NotFoundException) { // This will catch nodes not found (expected) and also PropertyRecords not found (shouldn't happen // but handled in shouldWriteOutThePropertyRecordBeforeReferencingItFromANodeRecord) } reads.incrementAndGet(); }); race.Go(); }
/// <summary> /// Do the actual transfer of the source (a Neo4j database dump) to the target. /// </summary> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void copy(boolean verbose, String consoleURL, java.nio.file.Path source, String bearerToken) throws org.neo4j.commandline.admin.CommandFailed public override void Copy(bool verbose, string consoleURL, Path source, string bearerToken) { try { string bearerTokenHeader = "Bearer " + bearerToken; long crc32Sum = CalculateCrc32HashOfFile(source); URL signedURL = InitiateCopy(verbose, SafeUrl(consoleURL + "/import"), crc32Sum, bearerTokenHeader); URL uploadLocation = InitiateResumableUpload(verbose, signedURL); long sourceLength = _outsideWorld.fileSystem().getFileSize(source.toFile()); // Enter the resume:able upload loop long position = 0; int retries = 0; ThreadLocalRandom random = ThreadLocalRandom.current(); ProgressTrackingOutputStream.Progress uploadProgress = new ProgressTrackingOutputStream.Progress(_progressListenerFactory.create("Upload", sourceLength), position); while (!ResumeUpload(verbose, source, sourceLength, position, uploadLocation, uploadProgress)) { position = GetResumablePosition(verbose, sourceLength, uploadLocation); if (position == POSITION_UPLOAD_COMPLETED) { // This is somewhat unexpected, we didn't get an OK from the upload, but when we asked about how far the upload // got it responded that it was fully uploaded. I'd guess we're fine here. break; } // Truncated exponential backoff if (retries > 50) { throw new CommandFailed("Upload failed after numerous attempts. The upload can be resumed with this command: TODO"); } long backoffFromRetryCount = SECONDS.toMillis(1 << retries++) + random.Next(1_000); _sleeper.sleep(min(backoffFromRetryCount, _maximumRetryBackoff)); } uploadProgress.Done(); TriggerImportProtocol(verbose, SafeUrl(consoleURL + "/import/upload-complete"), crc32Sum, bearerTokenHeader); DoStatusPolling(verbose, consoleURL, bearerToken); } catch (Exception e) when(e is InterruptedException || e is IOException) { throw new CommandFailed(e.Message, e); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testStressMultipleThreads() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TestStressMultipleThreads() { long r1 = 1L; StressThread[] stressThreads = new StressThread[100]; System.Threading.CountdownEvent startSignal = new System.Threading.CountdownEvent(1); for (int i = 0; i < 100; i++) { stressThreads[i] = new StressThread(this, "Thread" + i, 100, 9, 0.50f, r1, startSignal); } for (int i = 0; i < 100; i++) { stressThreads[i].Start(); } startSignal.Signal(); long end = currentTimeMillis() + SECONDS.toMillis(2000); bool anyAlive; while ((anyAlive = AnyAliveAndAllWell(stressThreads)) && currentTimeMillis() < end) { SleepALittle(); } foreach (StressThread stressThread in stressThreads) { if (stressThread.Error != null) { throw stressThread.Error; } else if (stressThread.IsAlive) { foreach (StackTraceElement stackTraceElement in stressThread.StackTrace) { Console.WriteLine(stackTraceElement); } } } if (anyAlive) { throw new Exception("Expected all threads to complete."); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void awaitIndexOnline(org.neo4j.graphdb.schema.IndexDefinition requestedIndex, org.neo4j.graphdb.GraphDatabaseService db, java.util.Map<Object,org.neo4j.graphdb.Node> expectedData) throws InterruptedException private static void AwaitIndexOnline(IndexDefinition requestedIndex, GraphDatabaseService db, IDictionary <object, Node> expectedData) { using (Transaction tx = Db.beginTx()) { IndexDefinition index = ReHomedIndexDefinition(db, requestedIndex); long timeout = DateTimeHelper.CurrentUnixTimeMillis() + SECONDS.toMillis(120); while (!IndexOnline(index, db)) { Thread.Sleep(1); if (DateTimeHelper.CurrentUnixTimeMillis() > timeout) { fail("Expected index to come online within a reasonable time."); } } AssertIndexContents(index, db, expectedData); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldWithstandHighStressAndStillKeepOrder() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldWithstandHighStressAndStillKeepOrder() { // GIVEN an ordering queue w/ low initial size as to also exercise resize under stress VerifyingIdOrderingQueue queue = new VerifyingIdOrderingQueue(new SynchronizedArrayIdOrderingQueue()); Committer[] committers = new Committer[20]; System.Threading.CountdownEvent readySignal = new System.Threading.CountdownEvent(committers.Length); AtomicBoolean end = new AtomicBoolean(); System.Threading.CountdownEvent startSignal = new System.Threading.CountdownEvent(1); LongIterator idSource = NeverEndingIdStream(); for (int i = 0; i < committers.Length; i++) { committers[i] = new Committer(queue, idSource, end, readySignal, startSignal); } // WHEN GO! readySignal.await(); startSignal.Signal(); long startTime = currentTimeMillis(); long endTime = startTime + SECONDS.toMillis(20); // worst-case while (currentTimeMillis() < endTime && queue.NumberOfOrderlyRemovedIds < THRESHOLD) { Thread.Sleep(100); } end.set(true); foreach (Committer committer in committers) { committer.AwaitFinish(); } // THEN there should have been at least a few ids processed. The order of those // are verified as they go, by the VerifyingIdOrderingQueue assertTrue("Would have wanted at least a few ids to be processed, but only saw " + queue.NumberOfOrderlyRemovedIds, queue.NumberOfOrderlyRemovedIds >= THRESHOLD); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(timeout = 15000) public void commitDuringContinuousCheckpointing() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CommitDuringContinuousCheckpointing() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.index.Index<org.neo4j.graphdb.Node> index; Index <Node> index; using (Transaction tx = Db.beginTx()) { index = Db.index().forNodes(INDEX_NAME, stringMap(Org.Neo4j.Graphdb.index.IndexManager_Fields.PROVIDER, DummyIndexExtensionFactory.IDENTIFIER)); tx.Success(); } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicBoolean done = new java.util.concurrent.atomic.AtomicBoolean(); AtomicBoolean done = new AtomicBoolean(); Workers <ThreadStart> workers = new Workers <ThreadStart>(this.GetType().Name); for (int i = 0; i < TOTAL_ACTIVE_THREADS; i++) { workers.Start(new RunnableAnonymousInnerClass(this, index, tx, done)); } Thread.Sleep(SECONDS.toMillis(2)); done.set(true); workers.AwaitAndThrowOnError(); NeoStores neoStores = GetDependency(typeof(RecordStorageEngine)).testAccessNeoStores(); assertThat("Count store should be rotated once at least", neoStores.Counts.txId(), greaterThan(0L)); long lastRotationTx = GetDependency(typeof(CheckPointer)).forceCheckPoint(new SimpleTriggerInfo("test")); TransactionIdStore txIdStore = GetDependency(typeof(TransactionIdStore)); assertEquals("NeoStore last closed transaction id should be equal last count store rotation transaction id.", txIdStore.LastClosedTransactionId, lastRotationTx); assertEquals("Last closed transaction should be last rotated tx in count store", txIdStore.LastClosedTransactionId, neoStores.Counts.txId()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldWriteOutThePropertyRecordBeforeReferencingItFromARelationshipRecord() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldWriteOutThePropertyRecordBeforeReferencingItFromARelationshipRecord() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long node1Id; long node1Id; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long node2Id; long node2Id; using (Transaction tx = Db.beginTx()) { Node node1 = Db.createNode(); node1Id = node1.Id; Node node2 = Db.createNode(); node2Id = node2.Id; tx.Success(); } Race race = new Race(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long[] latestRelationshipId = new long[1]; long[] latestRelationshipId = new long[1]; AtomicLong writes = new AtomicLong(); AtomicLong reads = new AtomicLong(); long endTime = currentTimeMillis() + SECONDS.toMillis(2); race.WithEndCondition(() => (writes.get() > 100 && reads.get() > 10_000) || currentTimeMillis() > endTime); race.AddContestant(() => { using (Transaction tx = Db.beginTx()) { Node node1 = Db.GraphDatabaseAPI.getNodeById(node1Id); Node node2 = Db.GraphDatabaseAPI.getNodeById(node2Id); Relationship rel = node1.createRelationshipTo(node2, _friend); latestRelationshipId[0] = rel.Id; rel.setProperty("largeProperty", LONG_STRING_VALUE); tx.Success(); } writes.incrementAndGet(); }); race.AddContestant(() => { try { using (Transaction tx = Db.GraphDatabaseAPI.beginTx()) { Relationship rel = Db.GraphDatabaseAPI.getRelationshipById(latestRelationshipId[0]); foreach (string propertyKey in rel.PropertyKeys) { rel.getProperty(propertyKey); } tx.Success(); } } catch (NotFoundException e) { if (Exceptions.contains(e, typeof(InvalidRecordException))) { throw e; } } reads.incrementAndGet(); }); race.Go(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void displayDuration() internal virtual void DisplayDuration() { assertThat(duration(MINUTES.toMillis(1) + SECONDS.toMillis(2)), @is("1m 2s")); assertThat(duration(42), @is("42ms")); assertThat(duration(0), @is("0ms")); }