Esempio n. 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void enterStreaming(org.neo4j.bolt.v1.transport.socket.client.TransportConnection connection, int sleepSeconds) throws Exception
        private void EnterStreaming(TransportConnection connection, int sleepSeconds)
        {
            ConnectAndPerformBoltHandshake(connection);

            connection.Send(Util.chunk(new InitMessage("TestClient/1.1", emptyMap())));
            assertThat(connection, Util.eventuallyReceives(msgSuccess()));

            SECONDS.sleep(sleepSeconds);                 // sleep a bit to allow worker thread return back to the pool

            connection.Send(Util.chunk(new RunMessage("UNWIND RANGE (1, 100) AS x RETURN x")));
            assertThat(connection, Util.eventuallyReceives(msgSuccess()));
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @Resources.Life(STARTED) public void shouldBlockRotationUntilRequestedTransactionsAreApplied() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBlockRotationUntilRequestedTransactionsAreApplied()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Store store = resourceManager.managed(createTestStore());
            Store store = _resourceManager.managed(CreateTestStore());

            // when
            UpdateStore(store, 1);
            Future <long> rotation = _threading.executeAndAwait(store.Rotation, 3L, thread =>
            {
                switch (thread.State)
                {
                case BLOCKED:
                case WAITING:
                case TIMED_WAITING:
                case TERMINATED:
                    return(true);

                default:
                    return(false);
                }
            }, 100, SECONDS);

            // rotation should wait...
            assertFalse(rotation.Done);
            SECONDS.sleep(1);
            assertFalse(rotation.Done);
            // apply update
            UpdateStore(store, 3);
            // rotation should still wait...
            assertFalse(rotation.Done);
            SECONDS.sleep(1);
            assertFalse(rotation.Done);
            // apply update
            UpdateStore(store, 4);
            // rotation should still wait...
            assertFalse(rotation.Done);
            SECONDS.sleep(1);
            assertFalse(rotation.Done);
            // apply update
            UpdateStore(store, 2);

            // then
            assertEquals(3, rotation.get().longValue());
            assertEquals(3, store.Headers().get(TX_ID).longValue());
            store.Rotation.apply(4L);
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.bolt.v1.transport.socket.client.TransportConnection enterStreaming() throws Throwable
        private TransportConnection EnterStreaming()
        {
            TransportConnection connection = null;
            Exception           error      = null;

            // retry couple times because worker threads might seem busy
            for (int i = 1; i <= 7; i++)
            {
                try
                {
                    connection = NewConnection();
                    EnterStreaming(connection, i);
                    error = null;
                    return(connection);
                }
                catch (Exception t)
                {
                    // failed to enter the streaming state, record the error and retry
                    if (error == null)
                    {
                        error = t;
                    }
                    else
                    {
                        error.addSuppressed(t);
                    }

                    Close(connection);
                    SECONDS.sleep(i);
                }
            }

            if (error != null)
            {
                throw error;
            }

            throw new System.InvalidOperationException("Unable to enter the streaming state");
        }