/// <summary> /// An throwable-swallowing execution of an action. Used in last-resort exception handlers. /// </summary> private void Swallow(ThrowingAction <Exception> action) { try { action.Apply(); } catch (Exception) { } }
/// <summary> /// We do not expect the interrupt system to be used here, /// so we ignore them and log a warning. /// </summary> private void IgnoringInterrupts(ThrowingAction <InterruptedException> action) { try { action.Apply(); } catch (InterruptedException e) { _log.warn("Unexpected interrupt", e); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void assertThrowsUnderlyingStorageException(org.neo4j.function.ThrowingAction<Exception> action) throws Exception private void AssertThrowsUnderlyingStorageException(ThrowingAction <Exception> action) { try { action.Apply(); fail("expected an UnderlyingStorageException exception"); } catch (UnderlyingStorageException) { // Good! } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void assertThrowsInvalidRecordException(org.neo4j.function.ThrowingAction<Exception> action) throws Exception private void AssertThrowsInvalidRecordException(ThrowingAction <Exception> action) { try { action.Apply(); fail("expected an InvalidRecordException exception"); } catch (InvalidRecordException) { // Good! } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.neo4j.graphdb.Resource storeCopy(org.neo4j.function.ThrowingAction<java.io.IOException> beforeFirstConcurrentStoreCopy) throws java.io.IOException public virtual Resource StoreCopy(ThrowingAction <IOException> beforeFirstConcurrentStoreCopy) { Lock readLock = @lock.readLock(); bool firstConcurrentRead = IncrementCount() == 0; bool success = false; try { if (firstConcurrentRead) { try { beforeFirstConcurrentStoreCopy.Apply(); } catch (IOException e) { _storeCopyActionError = e; throw e; } catch (Exception e) { _storeCopyActionError = e; throw new IOException(e); } _storeCopyActionCompleted = true; } else { // Wait for the "before" first store copy to complete WaitForFirstStoreCopyActionToComplete(); } success = true; } finally { if (success) { readLock.@lock(); } else { DecrementCount(); } } return(() => { // Decrement concurrent store-copy count DecrementCount(); readLock.unlock(); }); }
public ClusterBinder(SimpleStorage <ClusterId> clusterIdStorage, SimpleStorage <DatabaseName> dbNameStorage, CoreTopologyService topologyService, Clock clock, ThrowingAction <InterruptedException> retryWaiter, Duration timeout, CoreBootstrapper coreBootstrapper, string dbName, int minCoreHosts, Monitors monitors) { this._monitor = monitors.NewMonitor(typeof(Monitor)); this._clusterIdStorage = clusterIdStorage; this._dbNameStorage = dbNameStorage; this._topologyService = topologyService; this._coreBootstrapper = coreBootstrapper; this._clock = clock; this._retryWaiter = retryWaiter; this._timeout = timeout; this._dbName = dbName; this._minCoreHosts = minCoreHosts; }
/// <summary> /// Trigger store flush (checkpoint) and write <seealso cref="NeoStoreDataSource.listStoreFiles(bool) store files"/> to the /// given <seealso cref="StoreWriter"/>. /// </summary> /// <param name="triggerName"> name of the component asks for store files. </param> /// <param name="writer"> store writer to write files to. </param> /// <param name="includeLogs"> <code>true</code> if transaction logs should be copied, <code>false</code> otherwise. </param> /// <returns> a <seealso cref="RequestContext"/> specifying at which point the store copy started. </returns> public virtual RequestContext FlushStoresAndStreamStoreFiles(string triggerName, StoreWriter writer, bool includeLogs) { try { string storeCopyIdentifier = Thread.CurrentThread.Name; ThrowingAction <IOException> checkPointAction = () => { _monitor.startTryCheckPoint(storeCopyIdentifier); _checkPointer.tryCheckPoint(new SimpleTriggerInfo(triggerName)); _monitor.finishTryCheckPoint(storeCopyIdentifier); }; // Copy the store files long lastAppliedTransaction; StoreCopyCheckPointMutex mutex = _dataSource.StoreCopyCheckPointMutex; try { using (Resource @lock = mutex.StoreCopy(checkPointAction), ResourceIterator <StoreFileMetadata> files = _dataSource.listStoreFiles(includeLogs)) { lastAppliedTransaction = _checkPointer.lastCheckPointedTransactionId(); _monitor.startStreamingStoreFiles(storeCopyIdentifier); ByteBuffer temporaryBuffer = ByteBuffer.allocateDirect(( int )ByteUnit.mebiBytes(1)); while (Files.MoveNext()) { StoreFileMetadata meta = Files.Current; File file = meta.File(); bool isLogFile = meta.LogFile; int recordSize = meta.RecordSize(); using (ReadableByteChannel fileChannel = _fileSystem.open(file, OpenMode.READ)) { long fileSize = _fileSystem.getFileSize(file); DoWrite(writer, temporaryBuffer, file, recordSize, fileChannel, fileSize, storeCopyIdentifier, isLogFile); } } } } finally { _monitor.finishStreamingStoreFiles(storeCopyIdentifier); } return(anonymous(lastAppliedTransaction)); } catch (IOException e) { throw new ServerFailureException(e); } }
public static void ShouldBeThrownBy(this Type exceptionType, ThrowingAction expressionThatThrows) { Exception e = null; try { expressionThatThrows.Invoke(); } catch (Exception ex) { e = ex; } e.ShouldNotBeNull(); e.ShouldBeInstanceOfType(exceptionType); }
/// <summary> /// Last line of defense error handling. /// </summary> private void WithErrorHandling(ThrowingAction <Exception> action) { try { action.Apply(); } catch (Exception e) { _log.warn("Uncaught exception", e); } catch (Exception t) { _log.error("Uncaught error rethrown", t); throw t; } }
public static void ShouldBeThrownBy(this Type exceptionType, ThrowingAction action) { Exception e = null; try { action.Invoke(); } catch (Exception ex) { e = ex; } e.ShouldNotBeNull(); e.ShouldBeType(exceptionType); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void storeCopyShouldAllowAnotherStoreCopyButOnlyFirstShouldPerformBeforeAction() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void StoreCopyShouldAllowAnotherStoreCopyButOnlyFirstShouldPerformBeforeAction() { // GIVEN //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") org.neo4j.function.ThrowingAction<java.io.IOException> action = mock(org.neo4j.function.ThrowingAction.class); ThrowingAction <IOException> action = mock(typeof(ThrowingAction)); using (Resource @lock = _mutex.storeCopy(action)) { verify(action, times(1)).apply(); // WHEN using (Resource otherLock = _mutex.storeCopy(action)) { // THEN good verify(action, times(1)).apply(); } } }
private ThreadStart Work(int iterations, ThrowingAction <Exception> work) { return(() => { try { for (int i = 0; i < iterations; i++) { Thread.yield(); using (Transaction tx = Db.beginTx()) { Thread.yield(); work.Apply(); Thread.yield(); tx.success(); } } } catch (Exception e) { throw new AssertionError(e); } }); }
public FulltextIndexPopulator(FulltextIndexDescriptor descriptor, DatabaseIndex <FulltextIndexReader> luceneFulltext, ThrowingAction <IOException> descriptorCreateAction) : base(luceneFulltext) { this._descriptor = descriptor; this._descriptorCreateAction = descriptorCreateAction; }
public static void ShouldBeThrownBy(this Type exceptionType, ThrowingAction action) { Assert.Throws(exceptionType, action.Invoke); }
internal BlockedCallable(BinaryLatch startLatch, ThrowingAction <Exception> @delegate) { this.StartLatch = startLatch; this.Delegate = @delegate; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldPropagateStoreCopyActionFailureToOtherStoreCopyRequests() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldPropagateStoreCopyActionFailureToOtherStoreCopyRequests() { // GIVEN Org.Neo4j.Test.Barrier_Control barrier = new Org.Neo4j.Test.Barrier_Control(); IOException controlledFailure = new IOException("My own fault"); AtomicReference <Future <object> > secondRequest = new AtomicReference <Future <object> >(); ThrowingAction <IOException> controllableAndFailingAction = () => { // Now that we know we're first, start the second request... secondRequest.set(T3.execute(state => _mutex.storeCopy(_assertNotCalled))); // ...and wait for it to reach its destination barrier.AwaitUninterruptibly(); try { // OK, second request has made progress into the request, so we can now produce our failure throw controlledFailure; } finally { barrier.Release(); } }; Future <object> firstRequest = T2.execute(state => _mutex.storeCopy(controllableAndFailingAction)); while (secondRequest.get() == null) { ParkARandomWhile(); } T3.get().waitUntilWaiting(details => details.isAt(typeof(StoreCopyCheckPointMutex), "waitForFirstStoreCopyActionToComplete")); // WHEN barrier.Reached(); // THEN try { firstRequest.get(); } catch (ExecutionException e) { assertSame(controlledFailure, e.InnerException); } try { secondRequest.get().get(); } catch (ExecutionException e) { Exception cooperativeActionFailure = e.InnerException; assertThat(cooperativeActionFailure.Message, containsString("Co-operative")); assertSame(controlledFailure, cooperativeActionFailure.InnerException); } // WHEN afterwards trying another store-copy CountingAction action = new CountingAction(); using (Resource @lock = _mutex.storeCopy(action)) { // THEN assertEquals(1, action.Count()); } }
public virtual JobHandle ScheduleRecurring(Group group, long periodMillis, ThrowingAction <Exception> action) { return(@delegate.ScheduleRecurring(group, () => withErrorHandling(action), periodMillis, MILLISECONDS)); }
public LifecycleAdapterAnonymousInnerClass(ThrowingAction action) { this._action = action; }
private void CatchAuthorizationViolation(ThrowingAction <Exception> f) { assertException(f, typeof(AuthorizationViolationException)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void verifyExceptionOnCursorError(org.neo4j.function.ThrowingAction<Exception> access) throws Exception private void VerifyExceptionOnCursorError(ThrowingAction <Exception> access) { PrepareStoreForCursorError(); AssertThrowsInvalidRecordException(access); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void verifyExceptionOnOutOfBoundsAccess(org.neo4j.function.ThrowingAction<Exception> access) throws Exception private void VerifyExceptionOnOutOfBoundsAccess(ThrowingAction <Exception> access) { PrepareStoreForOutOfBoundsAccess(); AssertThrowsUnderlyingStorageException(access); }
public static Lifecycle OnShutdown(ThrowingAction action) { return(new LifecycleAdapterAnonymousInnerClass(action)); }
private void CatchInvalidArguments(ThrowingAction <Exception> f) { assertException(f, typeof(InvalidArgumentsException)); }