private void HandleCompletion(BoltConnection connection, bool?shouldContinueScheduling, Exception error) { try { if (error != null && ExceptionUtils.hasCause(error, typeof(RejectedExecutionException))) { connection.HandleSchedulingError(error); return; } } finally { // we need to ensure that the entry is removed only after any possible handleSchedulingError // call is completed. Otherwise, we can end up having different threads executing against // bolt state machine. _activeWorkItems.Remove(connection.Id()); } if (error != null) { _log.error(string.Format("Unexpected error during job scheduling for session '{0}'.", connection.Id()), error); StopConnection(connection); } else { if (shouldContinueScheduling && connection.HasPendingJobs()) { HandleSubmission(connection); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFlushErrorAndCloseConnectionIfFailedToSchedule() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldFlushErrorAndCloseConnectionIfFailedToSchedule() { // Given BoltConnection connection = NewConnection(); // When RejectedExecutionException error = new RejectedExecutionException("Failed to schedule"); connection.HandleSchedulingError(error); // Then verify(_stateMachine).markFailed(argThat(e => e.status().Equals(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.NoThreadsAvailable))); verify(_stateMachine).close(); verify(_output).flush(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void stopShouldCloseStateMachineIfEnqueueEndsWithRejectedExecutionException() public virtual void StopShouldCloseStateMachineIfEnqueueEndsWithRejectedExecutionException() { BoltConnection connection = NewConnection(); doAnswer(i => { connection.HandleSchedulingError(new RejectedExecutionException()); return(null); }).when(_queueMonitor).enqueued(ArgumentMatchers.eq(connection), any(typeof(Job))); connection.Stop(); verify(_stateMachine).markForTermination(); verify(_stateMachine).close(); }