Ejemplo n.º 1
0
        public override void HandleSchedulingError(Exception t)
        {
            // if the connection is closing, don't output any logs
            if (!WillClose())
            {
                string     message;
                Neo4jError error;
                if (ExceptionUtils.hasCause(t, typeof(RejectedExecutionException)))
                {
                    error   = Neo4jError.From(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.NoThreadsAvailable, Org.Neo4j.Kernel.Api.Exceptions.Status_Request.NoThreadsAvailable.code().description());
                    message = string.Format("Unable to schedule bolt session '{0}' for execution since there are no available threads to " + "serve it at the moment. You can retry at a later time or consider increasing max thread pool size for bolt connector(s).", Id());
                }
                else
                {
                    error   = Neo4jError.FatalFrom(t);
                    message = string.Format("Unexpected error during scheduling of bolt session '{0}'.", Id());
                }

                _log.error(message, t);
                _userLog.error(message);
                _machine.markFailed(error);
            }

            // this will ensure that the scheduled job will be executed on this thread (fork-join pool)
            // and it will either send a failure response to the client or close the connection and its
            // related resources (if closing)
            ProcessNextBatch(1, true);
            // we close the connection directly to enforce the client to stop waiting for
            // any more messages responses besides the failure message.
            Close();
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldNotProcessMessageWithPendingError()
        internal virtual void ShouldNotProcessMessageWithPendingError()
        {
            _state.ResponseHandler = null;

            _state.markFailed(Neo4jError.From(new Exception()));

            assertFalse(_state.canProcessMessage());
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldConvertDeadlockException()
        public virtual void ShouldConvertDeadlockException()
        {
            // When
            Neo4jError error = Neo4jError.From(new DeadlockDetectedException(null));

            // Then
            assertEquals(Org.Neo4j.Kernel.Api.Exceptions.Status_Transaction.DeadlockDetected, error.Status());
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAssignUnknownStatusToUnpredictedException()
        public virtual void ShouldAssignUnknownStatusToUnpredictedException()
        {
            // Given
            Exception  cause = new Exception("This is not an error we know how to handle.");
            Neo4jError error = Neo4jError.From(cause);

            // Then
            assertThat(error.Status(), equalTo(Org.Neo4j.Kernel.Api.Exceptions.Status_General.UnknownError));
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldHandleMarkFailedWithoutResponseHandler()
        internal virtual void ShouldHandleMarkFailedWithoutResponseHandler()
        {
            _state.ResponseHandler = null;

            Neo4jError error = Neo4jError.From(new Exception());

            _state.markFailed(error);

            assertEquals(error, _state.PendingError);
            assertFalse(_state.hasPendingIgnore());
        }
Ejemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldHandleMarkFailedWitResponseHandler()
        internal virtual void ShouldHandleMarkFailedWitResponseHandler()
        {
            _state.ResponseHandler = _responseHandler;

            Neo4jError error = Neo4jError.From(new Exception());

            _state.markFailed(error);

            verify(_responseHandler).markFailed(error);
            assertNull(_state.PendingError);
            assertFalse(_state.hasPendingIgnore());
        }
Ejemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSetStatusToDatabaseUnavailableOnDatabaseShutdownException()
        public virtual void ShouldSetStatusToDatabaseUnavailableOnDatabaseShutdownException()
        {
            // Given
            DatabaseShutdownException ex = new DatabaseShutdownException();

            // When
            Neo4jError error = Neo4jError.From(ex);

            // Then
            assertThat(error.Status(), equalTo(Org.Neo4j.Kernel.Api.Exceptions.Status_General.DatabaseUnavailable));
            assertThat(error.Cause(), equalTo(ex));
        }
Ejemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldResetPendingFailureAndIgnored()
        internal virtual void ShouldResetPendingFailureAndIgnored()
        {
            _state.ResponseHandler = null;

            Neo4jError error = Neo4jError.From(new Exception());

            _state.markIgnored();
            _state.markFailed(error);

            assertEquals(error, _state.PendingError);
            assertTrue(_state.hasPendingIgnore());

            _state.resetPendingFailedAndIgnored();

            assertNull(_state.PendingError);
            assertFalse(_state.hasPendingIgnore());
        }