Exemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected <T> org.neo4j.graphdb.Result executeWithRetries(String query, T parameters, org.neo4j.kernel.impl.query.TransactionalContext context, ParametrizedQueryExecutor<T> executor) throws org.neo4j.kernel.impl.query.QueryExecutionKernelException
        protected internal virtual Result ExecuteWithRetries <T>(string query, T parameters, TransactionalContext context, ParametrizedQueryExecutor <T> executor)
        {
            VersionContext versionContext = GetCursorContext(context);
            EagerResult    eagerResult;
            int            attempt = 0;
            bool           dirtySnapshot;

            do
            {
                if (attempt == _maxQueryExecutionAttempts)
                {
                    return(ThrowQueryExecutionException("Unable to get clean data snapshot for query '%s' after %d attempts.", query, attempt));
                }
                attempt++;
                versionContext.InitRead();
                Result result = executor(query, parameters, context);
                eagerResult = new EagerResult(result, versionContext);
                eagerResult.Consume();
                dirtySnapshot = versionContext.Dirty;
                if (dirtySnapshot && result.QueryStatistics.containsUpdates())
                {
                    return(ThrowQueryExecutionException("Unable to get clean data snapshot for query '%s' that perform updates.", query, attempt));
                }
            } while (dirtySnapshot);
            return(eagerResult);
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void markDirtyVersionLookupOnKeyReset() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MarkDirtyVersionLookupOnKeyReset()
        {
            long updaterVersionTxId = 25;
            long lastClosedTxId     = 20;

            when(_store.version()).thenReturn(updaterVersionTxId);
            TransactionVersionContextSupplier versionContextSupplier = new TransactionVersionContextSupplier();

            versionContextSupplier.Init(() => lastClosedTxId);
            VersionContext versionContext = versionContextSupplier.VersionContext;

            ConcurrentMapState <string> mapState = CreateMapState(versionContextSupplier);

            versionContext.InitRead();
            mapState.ResettingUpdater(@lock, Runnables.EMPTY_RUNNABLE).apply("a", new SimpleValueUpdate(1));
            mapState.Lookup("a", new EmptyValueSink());
            assertTrue(versionContext.Dirty);
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void doNotMarkVersionAsDirtyOnAnotherKeyUpdate() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void DoNotMarkVersionAsDirtyOnAnotherKeyUpdate()
        {
            long updaterVersionTxId = 25;
            long lastClosedTxId     = 20;
            TransactionVersionContextSupplier versionContextSupplier = new TransactionVersionContextSupplier();

            versionContextSupplier.Init(() => lastClosedTxId);
            ConcurrentMapState <string> mapState = CreateMapState(versionContextSupplier);
            VersionContext versionContext        = versionContextSupplier.VersionContext;

            using (EntryUpdater <string> updater = mapState.Updater(updaterVersionTxId, @lock))
            {
                updater.Apply("b", new SimpleValueUpdate(2));
            }

            assertEquals(updaterVersionTxId, mapState.Version());
            versionContext.InitRead();
            mapState.Lookup("a", new EmptyValueSink());
            assertFalse(versionContext.Dirty);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SetUp()
        {
            GraphDatabaseQueryService cypherService = new GraphDatabaseCypherService(this.Database.GraphDatabaseAPI);

            _compilerFactory      = mock(typeof(CompilerFactory));
            _transactionalContext = mock(typeof(TransactionalContext));
            KernelStatement kernelStatement = mock(typeof(KernelStatement));

            _executor       = mock(typeof(SnapshotExecutionEngine.ParametrizedQueryExecutor));
            _versionContext = mock(typeof(VersionContext));

            _executionEngine = CreateExecutionEngine(cypherService);
            when(kernelStatement.VersionContext).thenReturn(_versionContext);
            when(_transactionalContext.statement()).thenReturn(kernelStatement);
            Result          result     = mock(typeof(Result));
            QueryStatistics statistics = mock(typeof(QueryStatistics));

            when(result.QueryStatistics).thenReturn(statistics);
            when(_executor.execute(any(), anyMap(), any())).thenReturn(result);
        }
Exemplo n.º 5
0
 public TransactionToApplyAnonymousInnerClass(BatchingResponseHandler outerInstance, Org.Neo4j.Kernel.impl.transaction.TransactionRepresentation getTransactionRepresentation, Org.Neo4j.Io.pagecache.tracing.cursor.context.VersionContext getVersionContext) : base(getTransactionRepresentation, transaction.CommitEntry.TxId, getVersionContext)
 {
     this.outerInstance = outerInstance;
 }