//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void createdWorkerThreadsShouldContainConnectorNameAndRemoteAddressInTheirNamesWhenActive() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CreatedWorkerThreadsShouldContainConnectorNameAndRemoteAddressInTheirNamesWhenActive() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicReference<String> capturedThreadName = new java.util.concurrent.atomic.AtomicReference<>(); AtomicReference <string> capturedThreadName = new AtomicReference <string>(); AtomicInteger processNextBatchCount = new AtomicInteger(); string id = System.Guid.randomUUID().ToString(); BoltConnection connection = NewConnection(id); AtomicBoolean exitCondition = new AtomicBoolean(); when(connection.ProcessNextBatch()).thenAnswer(inv => { capturedThreadName.set(Thread.CurrentThread.Name); processNextBatchCount.incrementAndGet(); return(AwaitExit(exitCondition)); }); _boltScheduler.start(); _boltScheduler.created(connection); _boltScheduler.enqueued(connection, Jobs.noop()); Predicates.await(() => processNextBatchCount.get() > 0, 1, MINUTES); assertThat(capturedThreadName.get(), containsString(string.Format("[{0}]", CONNECTOR_KEY))); assertThat(capturedThreadName.get(), containsString(string.Format("[{0}]", connection.RemoteAddress()))); exitCondition.set(true); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void terminatedTransactionDoesNotForceUpdatePulling() public virtual void TerminatedTransactionDoesNotForceUpdatePulling() { int testTxsOnMaster = 42; ClusterManager.ManagedCluster cluster = ClusterRule.withSharedSetting(HaSettings.pull_interval, "0s").withSharedSetting(HaSettings.tx_push_factor, "0").startCluster(); HighlyAvailableGraphDatabase master = cluster.Master; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.ha.HighlyAvailableGraphDatabase slave = cluster.getAnySlave(); HighlyAvailableGraphDatabase slave = cluster.AnySlave; CreateNodeOn(master); cluster.Sync(); long lastClosedTxIdOnMaster = LastClosedTxIdOn(master); long lastClosedTxIdOnSlave = LastClosedTxIdOn(slave); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.CountDownLatch slaveTxStarted = new java.util.concurrent.CountDownLatch(1); System.Threading.CountdownEvent slaveTxStarted = new System.Threading.CountdownEvent(1); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.CountDownLatch slaveShouldCommit = new java.util.concurrent.CountDownLatch(1); System.Threading.CountdownEvent slaveShouldCommit = new System.Threading.CountdownEvent(1); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicReference<org.neo4j.graphdb.Transaction> slaveTx = new java.util.concurrent.atomic.AtomicReference<>(); AtomicReference <Transaction> slaveTx = new AtomicReference <Transaction>(); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.concurrent.Future<?> slaveCommit = java.util.concurrent.Executors.newSingleThreadExecutor().submit(() -> Future <object> slaveCommit = Executors.newSingleThreadExecutor().submit(() => { using (Transaction tx = slave.BeginTx()) { slaveTx.set(tx); slaveTxStarted.Signal(); Await(slaveShouldCommit); tx.success(); } }); Await(slaveTxStarted); CreateNodesOn(master, testTxsOnMaster); assertNotNull(slaveTx.get()); slaveTx.get().terminate(); slaveShouldCommit.Signal(); try { slaveCommit.get(); fail("Exception expected"); } catch (Exception e) { assertThat(e, instanceOf(typeof(ExecutionException))); assertThat(e.InnerException, instanceOf(typeof(TransientTransactionFailureException))); } assertEquals(lastClosedTxIdOnMaster + testTxsOnMaster, LastClosedTxIdOn(master)); assertEquals(lastClosedTxIdOnSlave, LastClosedTxIdOn(slave)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void createdWorkerThreadsShouldContainConnectorName() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CreatedWorkerThreadsShouldContainConnectorName() { AtomicInteger executeBatchCompletionCount = new AtomicInteger(); AtomicReference <Thread> poolThread = new AtomicReference <Thread>(); AtomicReference <string> poolThreadName = new AtomicReference <string>(); string id = System.Guid.randomUUID().ToString(); BoltConnection connection = NewConnection(id); when(connection.HasPendingJobs()).thenAnswer(inv => { executeBatchCompletionCount.incrementAndGet(); return(false); }); when(connection.ProcessNextBatch()).thenAnswer(inv => { poolThread.set(Thread.CurrentThread); poolThreadName.set(Thread.CurrentThread.Name); return(true); }); _boltScheduler.start(); _boltScheduler.created(connection); _boltScheduler.enqueued(connection, Jobs.noop()); Predicates.await(() => executeBatchCompletionCount.get() > 0, 1, MINUTES); assertThat(poolThread.get().Name, not(equalTo(poolThreadName.get()))); assertThat(poolThread.get().Name, containsString(string.Format("[{0}]", CONNECTOR_KEY))); assertThat(poolThread.get().Name, not(containsString(string.Format("[{0}]", connection.RemoteAddress())))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldIncludeStackTraceInUnexpectedCheckException() public virtual void ShouldIncludeStackTraceInUnexpectedCheckException() { // GIVEN ConsistencySummaryStatistics summary = mock(typeof(ConsistencySummaryStatistics)); RecordAccess records = mock(typeof(RecordAccess)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicReference<String> loggedError = new java.util.concurrent.atomic.AtomicReference<>(); AtomicReference <string> loggedError = new AtomicReference <string>(); InconsistencyLogger logger = new InconsistencyLoggerAnonymousInnerClass(this, loggedError); InconsistencyReport inconsistencyReport = new InconsistencyReport(logger, summary); ConsistencyReporter reporter = new ConsistencyReporter(records, inconsistencyReport); NodeRecord node = new NodeRecord(10); RecordCheck <NodeRecord, ConsistencyReport_NodeConsistencyReport> checker = mock(typeof(RecordCheck)); Exception exception = new Exception("My specific exception"); doThrow(exception).when(checker).check(any(typeof(NodeRecord)), any(typeof(CheckerEngine)), any(typeof(RecordAccess))); // WHEN reporter.ForNode(node, checker); // THEN assertNotNull(loggedError.get()); string error = loggedError.get(); assertThat(error, containsString("at ")); assertThat(error, containsString(TestName.MethodName)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void propertyAdded(org.neo4j.internal.kernel.api.ExplicitIndexWrite ops, long entityId, int propertyKeyId, org.neo4j.values.storable.Value value) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.AutoIndexingKernelException public override void PropertyAdded(ExplicitIndexWrite ops, long entityId, int propertyKeyId, Value value) { if (_enabled) { try { string name = _propertyKeyLookup.getTokenById(propertyKeyId).name(); if (_propertyKeysToInclude.get().contains(name)) { EnsureIndexExists(ops); _type.add(ops, entityId, name, value.AsObject()); } } catch (KernelException e) { throw new AutoIndexingKernelException(e); } catch (TokenNotFoundException e) { // TODO: TokenNotFoundException was added before there was a kernel. It should be converted to a // KernelException now throw new AutoIndexingKernelException(new PropertyKeyIdNotFoundKernelException(propertyKeyId, e)); } } }
/// <summary> /// Check a timecode which was reached by normal playback, trigger REACHED if necessary. </summary> /// <param name="timecode"> Timecode which was reached by normal playback. </param> public virtual void checkPlaybackTimecode(long timecode) { TrackMarker marker = current.get(); if (marker != null && timecode >= marker.timecode) { trigger(marker, REACHED); } }
/// <summary> /// Fully close all loaded alternates and clear the alternate list. /// </summary> public virtual void closeAlternates() { ObjectDatabase[] alt = _alternates.get(); if (alt != null) { _alternates.set(null); closeAlternates(alt); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(timeOut = 5000) public void interruptHangingResultsListener() throws InterruptedException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void interruptHangingResultsListener() { HangingFunction fn = new HangingFunction(); CalculationTaskCell cell = CalculationTaskCell.of(0, 0, TestingMeasures.PRESENT_VALUE, NATURAL); CalculationTask task = CalculationTask.of(TARGET, fn, cell); Column column = Column.of(TestingMeasures.PRESENT_VALUE); CalculationTasks tasks = CalculationTasks.of(ImmutableList.of(task), ImmutableList.of(column)); ExecutorService executor = Executors.newSingleThreadExecutor(); try { CalculationTaskRunner test = CalculationTaskRunner.of(executor); MarketData marketData = MarketData.empty(VAL_DATE); AtomicBoolean shouldNeverComplete = new AtomicBoolean(); AtomicBoolean interrupted = new AtomicBoolean(); AtomicReference <Exception> thrown = new AtomicReference <Exception>(); ResultsListener listener = new ResultsListener(); test.calculateAsync(tasks, marketData, REF_DATA, listener); System.Threading.CountdownEvent latch = new System.Threading.CountdownEvent(1); Thread thread = new Thread(() => { try { listener.result(); shouldNeverComplete.set(true); } catch (Exception ex) { interrupted.set(Thread.CurrentThread.Interrupted); thrown.set(ex); } latch.Signal(); }); // run the thread, wait until properly started, then interrupt, wait until properly handled thread.Start(); while (!fn.started) { } thread.Interrupt(); latch.await(); // asserts assertEquals(interrupted.get(), true); assertEquals(shouldNeverComplete.get(), false); assertEquals(thrown.get() is Exception, true); assertEquals(thrown.get().Cause is InterruptedException, true); } finally { executor.shutdownNow(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void startAndWait(Thread t1, Thread t2) throws Exception private void StartAndWait(Thread t1, Thread t2) { t1.Start(); t2.Start(); t1.Join(); t2.Join(); if (_ex.get() != null) { throw _ex.get(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void failedInstanceShouldReceiveCorrectCoordinatorIdUponRejoiningCluster() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void FailedInstanceShouldReceiveCorrectCoordinatorIdUponRejoiningCluster() { // Given HighlyAvailableGraphDatabase initialMaster = _cluster.Master; // When _cluster.shutdown(initialMaster); _cluster.await(masterAvailable(initialMaster)); _cluster.await(masterSeesSlavesAsAvailable(1)); // create node on new master to ensure that it has the greatest tx id CreateNodeOn(_cluster.Master); _cluster.sync(); LifeSupport life = new LifeSupport(); ClusterClientModule clusterClient = NewClusterClient(life, new InstanceId(1)); Cleanup.add(life); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicReference<org.neo4j.cluster.InstanceId> coordinatorIdWhenReJoined = new java.util.concurrent.atomic.AtomicReference<>(); AtomicReference <InstanceId> coordinatorIdWhenReJoined = new AtomicReference <InstanceId>(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.CountDownLatch latch = new java.util.concurrent.CountDownLatch(1); System.Threading.CountdownEvent latch = new System.Threading.CountdownEvent(1); clusterClient.ClusterClient.addClusterListener(new ClusterListener_AdapterAnonymousInnerClass(this, coordinatorIdWhenReJoined, latch)); life.Start(); // Then assertTrue(latch.await(20, SECONDS)); assertEquals(new InstanceId(2), coordinatorIdWhenReJoined.get()); }
private void Terminate(AtomicReference <Transaction> txReference) { Transaction tx = txReference.get(); assertNotNull(tx); tx.Terminate(); }
private void AwaitAllCompleted() { while (_head.get() != _tail.get()) { Park.park(_receiverThread = Thread.CurrentThread); } }
//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 TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGetSpecifiedUsernameAndMetaDataInTXData() public virtual void ShouldGetSpecifiedUsernameAndMetaDataInTXData() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicReference<String> usernameRef = new java.util.concurrent.atomic.AtomicReference<>(); AtomicReference <string> usernameRef = new AtomicReference <string>(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicReference<java.util.Map<String,Object>> metaDataRef = new java.util.concurrent.atomic.AtomicReference<>(); AtomicReference <IDictionary <string, object> > metaDataRef = new AtomicReference <IDictionary <string, object> >(); _db.registerTransactionEventHandler(GetBeforeCommitHandler(txData => { usernameRef.set(txData.username()); metaDataRef.set(txData.metaData()); })); AuthSubject subject = mock(typeof(AuthSubject)); when(subject.Username()).thenReturn("Christof"); LoginContext loginContext = new LoginContextAnonymousInnerClass(this, subject); IDictionary <string, object> metadata = genericMap("username", "joe"); RunTransaction(loginContext, metadata); assertThat("Should have specified username", usernameRef.get(), equalTo("Christof")); assertThat("Should have metadata with specified username", metaDataRef.get(), equalTo(metadata)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldTimeoutIfTheIndexTakesTooLongToComeOnline() throws InterruptedException, org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldTimeoutIfTheIndexTakesTooLongToComeOnline() { when(_tokenRead.nodeLabel(anyString())).thenReturn(0); when(_tokenRead.propertyKey(anyString())).thenReturn(0); when(_schemaRead.index(anyInt(), anyInt())).thenReturn(_anyIndex); when(_schemaRead.indexGetState(any(typeof(IndexReference)))).thenReturn(POPULATING); AtomicReference <ProcedureException> exception = new AtomicReference <ProcedureException>(); (new Thread(() => { try { // We wait here, because we expect timeout _procedure.awaitIndexByPattern(":Person(name)", 0, _timeUnit); } catch (ProcedureException e) { exception.set(e); } })).Start(); assertEventually("Procedure did not time out", exception.get, not(nullValue()), TIMEOUT, _timeUnit); //noinspection ThrowableResultOfMethodCallIgnored assertThat(exception.get().status(), @is(Org.Neo4j.Kernel.Api.Exceptions.Status_Procedure.ProcedureTimedOut)); }
private long ApplyProcessorCount(long @lock) { if (_numberOfForkedProcessors != _targetNumberOfProcessors) { _stripingLock.unlock(@lock); @lock = _stripingLock.writeLock(); AwaitAllCompleted(); int processors = _targetNumberOfProcessors; while (_numberOfForkedProcessors < processors) { if (_forkedProcessors[_numberOfForkedProcessors] == null) { _forkedProcessors[_numberOfForkedProcessors] = new ForkedProcessor(this, _numberOfForkedProcessors, _tail.get()); } _numberOfForkedProcessors++; } if (_numberOfForkedProcessors > processors) { _numberOfForkedProcessors = processors; // Excess processors will notice that they are not needed right now, and will park until they are. // The most important thing here is that future Units will have a lower number of processor as expected max. } } return(@lock); }
private static OffsetTime Write(TimeValue value) { AtomicReference <OffsetTime> result = new AtomicReference <OffsetTime>(); value.WriteTo(new AssertOnlyAnonymousInnerClass2(result)); return(result.get()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void shouldReadCorrectlyWithConcurrentUpdates(TestCoordinator testCoordinator) throws Throwable private void ShouldReadCorrectlyWithConcurrentUpdates(TestCoordinator testCoordinator) { // Readers config int readers = max(1, Runtime.Runtime.availableProcessors() - 1); // Thread communication System.Threading.CountdownEvent readerReadySignal = new System.Threading.CountdownEvent(readers); System.Threading.CountdownEvent readerStartSignal = new System.Threading.CountdownEvent(1); AtomicBoolean endSignal = testCoordinator.EndSignal(); AtomicBoolean failHalt = new AtomicBoolean(); // Readers signal to writer that there is a failure AtomicReference <Exception> readerError = new AtomicReference <Exception>(); // GIVEN _index = CreateIndex(); testCoordinator.Prepare(_index); // WHEN starting the readers RunnableReader readerTask = new RunnableReader(this, testCoordinator, readerReadySignal, readerStartSignal, endSignal, failHalt, readerError); for (int i = 0; i < readers; i++) { _threadPool.submit(readerTask); } // and starting the checkpointer _threadPool.submit(CheckpointThread(endSignal, readerError, failHalt)); // and starting the writer try { Write(testCoordinator, readerReadySignal, readerStartSignal, endSignal, failHalt); } finally { // THEN no reader should have failed by the time we have finished all the scheduled updates. // A successful read means that all results were ordered and we saw all inserted values and // none of the removed values at the point of making the seek call. endSignal.set(true); _threadPool.shutdown(); _threadPool.awaitTermination(10, TimeUnit.SECONDS); if (readerError.get() != null) { //noinspection ThrowFromFinallyBlock throw readerError.get(); } } }
public override void closeSelf() { PackList packs = _packList.get(); _packList.set(NoPacks); foreach (PackFile p in packs.packs) { p.Dispose(); } #if DEBUG GC.SuppressFinalize(this); // Disarm lock-release checker #endif }
private void AssertNoFailures() { Exception e = Reference.get(); if (e != null) { throw new AssertionError(e); } }
// Timeout as fallback safety if test deadlocks //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(timeout = 60_000) public void shouldWaitOnStopUntilTheRunningCheckpointIsDone() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldWaitOnStopUntilTheRunningCheckpointIsDone() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicReference<Throwable> ex = new java.util.concurrent.atomic.AtomicReference<>(); AtomicReference <Exception> ex = new AtomicReference <Exception>(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicBoolean stoppedCompleted = new java.util.concurrent.atomic.AtomicBoolean(); AtomicBoolean stoppedCompleted = new AtomicBoolean(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.test.DoubleLatch checkPointerLatch = new org.neo4j.test.DoubleLatch(1); DoubleLatch checkPointerLatch = new DoubleLatch(1); OtherThreadExecutor <Void> otherThreadExecutor = new OtherThreadExecutor <Void>("scheduler stopper", null); CheckPointer checkPointer = new CheckPointerAnonymousInnerClass(this, checkPointerLatch); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final CheckPointScheduler scheduler = new CheckPointScheduler(checkPointer, ioLimiter, jobScheduler, 20L, health); CheckPointScheduler scheduler = new CheckPointScheduler(checkPointer, _ioLimiter, _jobScheduler, 20L, _health); // when scheduler.Start(); Thread runCheckPointer = new Thread(_jobScheduler.runJob); runCheckPointer.Start(); checkPointerLatch.WaitForAllToStart(); otherThreadExecutor.ExecuteDontWait((OtherThreadExecutor.WorkerCommand <Void, Void>)state => { try { scheduler.Stop(); stoppedCompleted.set(true); } catch (Exception throwable) { ex.set(throwable); } return(null); }); otherThreadExecutor.WaitUntilWaiting(details => details.isAt(typeof(CheckPointScheduler), "waitOngoingCheckpointCompletion")); // then assertFalse(stoppedCompleted.get()); checkPointerLatch.Finish(); runCheckPointer.Join(); while (!stoppedCompleted.get()) { Thread.Sleep(1); } otherThreadExecutor.Dispose(); assertNull(ex.get()); }
protected internal override void DoWork() { GraphDatabaseService db = _dbRef.get(); Db.shutdown(); LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(5)); bool replaced = _dbRef.compareAndSet(db, _factory.newInstance()); assertTrue(replaced); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldAwaitCompletionOfAllTasks() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldAwaitCompletionOfAllTasks() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final TaskCoordinator coordinator = new TaskCoordinator(1, java.util.concurrent.TimeUnit.MILLISECONDS); TaskCoordinator coordinator = new TaskCoordinator(1, TimeUnit.MILLISECONDS); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicReference<String> state = new java.util.concurrent.atomic.AtomicReference<>(); AtomicReference <string> state = new AtomicReference <string>(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<String> states = new java.util.ArrayList<>(); IList <string> states = new List <string>(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.test.Barrier_Control phaseA = new org.neo4j.test.Barrier_Control(); Org.Neo4j.Test.Barrier_Control phaseA = new Org.Neo4j.Test.Barrier_Control(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.test.Barrier_Control phaseB = new org.neo4j.test.Barrier_Control(); Org.Neo4j.Test.Barrier_Control phaseB = new Org.Neo4j.Test.Barrier_Control(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.test.Barrier_Control phaseC = new org.neo4j.test.Barrier_Control(); Org.Neo4j.Test.Barrier_Control phaseC = new Org.Neo4j.Test.Barrier_Control(); state.set("A"); new Thread("awaitCompletion" () => { try { states.Add(state.get()); // expects A phaseA.Reached(); states.Add(state.get()); // expects B phaseB.Await(); phaseB.Release(); coordinator.AwaitCompletion(); states.Add(state.get()); // expects C phaseC.Reached(); } catch (InterruptedException e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } });
/// <summary> /// Called by user-facing progress monitor at arbitrary points to get information about whether or not there has been /// one or more <seealso cref="NumberArrayFactory"/> allocations backed by the <seealso cref="PageCache"/>, this because it severely affects /// performance. Calling this method clears the failure description, if any. /// </summary> /// <returns> if there have been <seealso cref="NumberArrayFactory"/> allocations backed by the <seealso cref="PageCache"/> since the last call to this method /// then a description of why it was chosen is returned, otherwise {@code null}. </returns> public virtual string PageCacheAllocationOrNull() { string failure = _failedFactoriesDescription.get(); if (!string.ReferenceEquals(failure, null)) { _failedFactoriesDescription.compareAndSet(failure, null); } return(failure); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: protected void verifyFormat(java.io.File storeFile) throws FormatViolationException, java.io.IOException protected internal override void VerifyFormat(File storeFile) { AtomicReference <FormatViolationException> exception = new AtomicReference <FormatViolationException>(); WithCursor(storeFile, false, c => { int major = c.Int; int minor = c.Int; GenericLayout layout = Layout; if (major != layout.MajorVersion() || minor != layout.MinorVersion()) { exception.set(new FormatViolationException(this, string.Format("Read format version {0:D}.{1:D}, but layout has version {2:D}.{3:D}", major, minor, layout.MajorVersion(), layout.MinorVersion()))); } }); if (exception.get() != null) { throw exception.get(); } }
public virtual void WaitForLatch() { try { TestLatchConflict.get().runBefore.run(); } finally { TestLatchConflict.get().doubleLatch.startAndWaitForAllToStart(); } try { TestLatchConflict.get().runAfter.run(); } finally { TestLatchConflict.get().doubleLatch.finishAndWaitForAllToFinish(); } }
public override void TransactionCommitted( long transactionId, long checksum, long commitTimestamp ) { lock ( this ) { TransactionId current = _committedTransactionId.get(); if ( current == null || transactionId > current.TransactionIdConflict() ) { _committedTransactionId.set( new TransactionId( transactionId, checksum, commitTimestamp ) ); } } }
public override void force(IOLimiter ioLimiter) { try { _actionThreadReference.get().start(); _latch.await(); } catch (Exception e) { throw new Exception(e); } }
public override void Drop() { if (_state.compareAndSet(State.Init, State.Closed)) { base.Drop(); return; } if (State.Starting == _state.get()) { throw new System.InvalidOperationException("Concurrent drop while creating index"); } if (_state.compareAndSet(State.Started, State.Closed)) { WaitOpenCallsToClose(); base.Drop(); return; } throw new System.InvalidOperationException("IndexProxy already closed"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void mustFlushStoresWithGivenIOLimiter() public virtual void MustFlushStoresWithGivenIOLimiter() { IOLimiter limiter = Org.Neo4j.Io.pagecache.IOLimiter_Fields.Unlimited; FileSystemAbstraction fs = _fsRule.get(); AtomicReference <IOLimiter> observedLimiter = new AtomicReference <IOLimiter>(); PageCache pageCache = new DelegatingPageCacheAnonymousInnerClass(this, _pageCacheRule.getPageCache(fs), limiter, observedLimiter); RecordStorageEngine engine = _storageEngineRule.getWith(fs, pageCache, _testDirectory.databaseLayout()).build(); engine.FlushAndForce(limiter); assertThat(observedLimiter.get(), sameInstance(limiter)); }