public override void CommitAndRestartTx()
        {
            /*
             * This method is use by the Cypher runtime to cater for PERIODIC COMMIT, which allows a single query to
             * periodically, after x number of rows, to commit a transaction and spawn a new one.
             *
             * To still keep track of the running stream after switching transactions, we need to open the new transaction
             * before closing the old one. This way, a query will not disappear and appear when switching transactions.
             *
             * Since our transactions are thread bound, we must first unbind the old transaction from the thread before
             * creating a new one. And then we need to do that thread switching again to close the old transaction.
             */

            CheckNotTerminated();

            CollectTransactionExecutionStatistic();

            // (1) Unbind current transaction
            QueryRegistryOperations oldQueryRegistryOperations = _statement.queryRegistration();
            Statement           oldStatement   = _statement;
            InternalTransaction oldTransaction = _transaction;
            KernelTransaction   oldKernelTx    = _txBridge.getKernelTransactionBoundToThisThread(true);

            _txBridge.unbindTransactionFromCurrentThread();

            // (2) Create, bind, register, and unbind new transaction
            _transaction       = _graph.beginTransaction(TransactionType, SecurityContextConflict);
            _kernelTransaction = _txBridge.getKernelTransactionBoundToThisThread(true);
            _statement         = _kernelTransaction.acquireStatement();
            _statement.queryRegistration().registerExecutingQuery(_executingQuery);
            _txBridge.unbindTransactionFromCurrentThread();

            // (3) Rebind old transaction just to commit and close it (and unregister as a side effect of that)
            _txBridge.bindTransactionToCurrentThread(oldKernelTx);
            oldQueryRegistryOperations.UnregisterExecutingQuery(_executingQuery);
            try
            {
                oldStatement.Close();
                oldTransaction.Success();
                oldTransaction.Close();
            }
            catch (Exception t)
            {
                // Corner case: The old transaction might have been terminated by the user. Now we also need to
                // terminate the new transaction.
                _txBridge.bindTransactionToCurrentThread(_kernelTransaction);
                _transaction.failure();
                _transaction.close();
                _txBridge.unbindTransactionFromCurrentThread();
                throw t;
            }

            // (4) Unbind the now closed old transaction and rebind the new transaction for continued execution
            _txBridge.unbindTransactionFromCurrentThread();
            _txBridge.bindTransactionToCurrentThread(_kernelTransaction);
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWarnWhenUsingInternalAndOtherProvider() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWarnWhenUsingInternalAndOtherProvider()
        {
            ConfiguredSetup(stringMap(SecuritySettings.auth_providers.name(), InternalSecurityName() + " ,LDAP"));
            AssertSuccess(AdminSubject, "CALL dbms.security.listUsers", r => assertKeyIsMap(r, "username", "roles", ValueOf(_userList)));
            GraphDatabaseFacade localGraph  = Neo.LocalGraph;
            InternalTransaction transaction = localGraph.BeginTransaction(KernelTransaction.Type.@explicit, StandardEnterpriseLoginContext.AUTH_DISABLED);
            Result result      = localGraph.execute(transaction, "EXPLAIN CALL dbms.security.listUsers", EMPTY_MAP);
            string description = string.Format("{0} ({1})", Org.Neo4j.Kernel.Api.Exceptions.Status_Procedure.ProcedureWarning.code().description(), "dbms.security.listUsers only applies to native users.");

            assertThat(ContainsNotification(result, description), equalTo(true));
            transaction.Success();
            transaction.Close();
        }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void coreProceduresShouldBeAvailable()
        public virtual void CoreProceduresShouldBeAvailable()
        {
            string[] coreProcs = new string[] { "dbms.cluster.role", "dbms.cluster.routing.getServers", "dbms.cluster.overview", "dbms.procedures", "dbms.listQueries" };

            foreach (string procedure in coreProcs)
            {
                Optional <CoreClusterMember> firstCore = _cluster.coreMembers().First();
                Debug.Assert(firstCore.Present);
                CoreGraphDatabase   database = firstCore.get().database();
                InternalTransaction tx       = database.BeginTransaction(KernelTransaction.Type.@explicit, AUTH_DISABLED);
                Result coreResult            = database.Execute("CALL " + procedure + "()");
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                assertTrue("core with procedure " + procedure, coreResult.HasNext());
                coreResult.Close();
                tx.Close();
            }
        }
Beispiel #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void readReplicaProceduresShouldBeAvailable()
        public virtual void ReadReplicaProceduresShouldBeAvailable()
        {
            // given
            string[] readReplicaProcs = new string[] { "dbms.cluster.role", "dbms.procedures", "dbms.listQueries" };

            // when
            foreach (string procedure in readReplicaProcs)
            {
                Optional <ReadReplica> firstReadReplica = _cluster.readReplicas().First();
                Debug.Assert(firstReadReplica.Present);
                ReadReplicaGraphDatabase database = firstReadReplica.get().database();
                InternalTransaction      tx       = database.BeginTransaction(KernelTransaction.Type.@explicit, AUTH_DISABLED);
                Result readReplicaResult          = database.Execute("CALL " + procedure + "()");

                // then
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                assertTrue("read replica with procedure " + procedure, readReplicaResult.HasNext());
                readReplicaResult.Close();
                tx.Close();
            }
        }