//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRespectThreshold() public virtual void ShouldRespectThreshold() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.logging.AssertableLogProvider logProvider = new org.neo4j.logging.AssertableLogProvider(); AssertableLogProvider logProvider = new AssertableLogProvider(); ExecutingQuery query = query(_session_1, "TestUser", QUERY_1); ConfiguredQueryLogger queryLogger = queryLogger(logProvider); // when _clock.forward(9, TimeUnit.MILLISECONDS); queryLogger.Success(query); // then logProvider.AssertNoLoggingOccurred(); // and when ExecutingQuery query2 = query(_session_2, "TestUser2", QUERY_2); _thresholdInMillis = 5; queryLogger = queryLogger(logProvider); // Rebuild queryLogger, like the DynamicQueryLogger would. _clock.forward(9, TimeUnit.MILLISECONDS); queryLogger.Success(query2); // then string expectedSessionString = SessionConnectionDetails(_session_2, "TestUser2"); logProvider.AssertExactly(inLog(this.GetType()).info(format("%d ms: %s - %s - {}", 9L, expectedSessionString, QUERY_2))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldKeepTrackOfDifferentSessions() public virtual void ShouldKeepTrackOfDifferentSessions() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.logging.AssertableLogProvider logProvider = new org.neo4j.logging.AssertableLogProvider(); AssertableLogProvider logProvider = new AssertableLogProvider(); ExecutingQuery query1 = Query(_session_1, "TestUser1", QUERY_1); _clock.forward(1, TimeUnit.MILLISECONDS); ExecutingQuery query2 = Query(_session_2, "TestUser2", QUERY_2); _clock.forward(1, TimeUnit.MILLISECONDS); ExecutingQuery query3 = Query(_session_3, "TestUser3", QUERY_3); ConfiguredQueryLogger queryLogger = queryLogger(logProvider); // when _clock.forward(1, TimeUnit.MILLISECONDS); _clock.forward(1, TimeUnit.MILLISECONDS); _clock.forward(7, TimeUnit.MILLISECONDS); queryLogger.Success(query3); _clock.forward(7, TimeUnit.MILLISECONDS); queryLogger.Success(query2); _clock.forward(7, TimeUnit.MILLISECONDS); queryLogger.Success(query1); // then string expectedSession1String = SessionConnectionDetails(_session_1, "TestUser1"); string expectedSession2String = SessionConnectionDetails(_session_2, "TestUser2"); logProvider.AssertExactly(inLog(this.GetType()).info(format("%d ms: %s - %s - {}", 17L, expectedSession2String, QUERY_2)), inLog(this.GetType()).info(format("%d ms: %s - %s - {}", 25L, expectedSession1String, QUERY_1))); }
private QuerySnapshot CreateQuerySnapshotWaitingForLock(long queryId, bool exclusive, ResourceType resourceType, long id) { ExecutingQuery executingQuery = CreateExecutingQuery(queryId); executingQuery.LockTracer().waitForLock(exclusive, resourceType, id); return(executingQuery.Snapshot()); }
public override Neo4jTransactionalContext NewContext(ClientConnectionInfo clientConnection, InternalTransaction tx, string queryText, MapValue queryParameters) { Statement initialStatement = _statementSupplier.get(); ClientConnectionInfo connectionWithUserName = clientConnection.WithUsername(tx.SecurityContext().subject().username()); ExecutingQuery executingQuery = initialStatement.QueryRegistration().startQueryExecution(connectionWithUserName, queryText, queryParameters); return(_contextCreator.create(tx, initialStatement, executingQuery)); }
public override void EndSuccess(ExecutingQuery query) { if (_isCollecting) { QuerySnapshot snapshot = query.Snapshot(); _queries.produce(new TruncatedQuerySnapshot(snapshot.QueryText(), snapshot.QueryPlanSupplier(), snapshot.QueryParameters(), snapshot.ElapsedTimeMicros(), snapshot.CompilationTimeMicros(), snapshot.StartTimestampMillis(), _maxQueryTextSize)); } }
public override void Success(ExecutingQuery query) { if (NANOSECONDS.toMillis(query.ElapsedNanos()) >= _thresholdMillis) { QuerySnapshot snapshot = query.Snapshot(); _log.info(LogEntry(snapshot)); } }
public override ExecutingQuery StartQueryExecution(KernelStatement statement, ClientConnectionInfo clientConnection, string queryText, MapValue queryParameters) { long queryId = _lastQueryId.incrementAndGet(); Thread thread = Thread.CurrentThread; long threadId = thread.Id; string threadName = thread.Name; ExecutingQuery executingQuery = new ExecutingQuery(queryId, clientConnection, statement.Username(), queryText, queryParameters, statement.Transaction.MetaData, () => statement.Locks().activeLockCount(), statement.PageCursorTracer, threadId, threadName, _clock, _cpuClockRef.get(), _heapAllocationRef.get()); RegisterExecutingQuery(statement, executingQuery); return(executingQuery); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void removingTheLastQueryReturnsAnEmptyList() public virtual void RemovingTheLastQueryReturnsAnEmptyList() { // Given ExecutingQuery aQuery = CreateExecutingQuery(1, "query"); ExecutingQueryList list = ExecutingQueryList.EMPTY.push(aQuery); // When ExecutingQueryList result = list.Remove(aQuery); // Then assertThat(result, equalTo(ExecutingQueryList.EMPTY)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotChangeAListWhenRemovingAQueryThatIsNotInTheList() public virtual void ShouldNotChangeAListWhenRemovingAQueryThatIsNotInTheList() { // given ExecutingQuery query1 = CreateExecutingQuery(1, "query1"); ExecutingQuery query2 = CreateExecutingQuery(2, "query2"); ExecutingQueryList list = ExecutingQueryList.EMPTY.push(query1); // when ExecutingQueryList result = list.Remove(query2); // then assertThat(result, equalTo(list)); }
private Stream <ActiveLocksResult> GetActiveLocksForQuery(Pair <KernelTransactionHandle, ExecutingQuery> pair) { ExecutingQuery query = pair.Other(); if (IsAdminOrSelf(query.Username())) { //JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter: return(pair.First().activeLocks().map(ActiveLocksResult::new)); } else { throw new AuthorizationViolationException(PERMISSION_DENIED); } }
public Neo4jTransactionalContext(GraphDatabaseQueryService graph, ThreadToStatementContextBridge txBridge, PropertyContainerLocker locker, InternalTransaction initialTransaction, Statement initialStatement, ExecutingQuery executingQuery, Kernel kernel) { this._graph = graph; this._txBridge = txBridge; this._locker = locker; this.TransactionType = initialTransaction.TransactionType(); this.SecurityContextConflict = initialTransaction.SecurityContext(); this._executingQuery = executingQuery; this._transaction = initialTransaction; this._kernelTransaction = txBridge.GetKernelTransactionBoundToThisThread(true); this._statement = initialStatement; this._kernel = kernel; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private QueryTerminationResult killQueryTransaction(org.neo4j.helpers.collection.Pair<org.neo4j.kernel.api.KernelTransactionHandle, org.neo4j.kernel.api.query.ExecutingQuery> pair) throws org.neo4j.kernel.api.exceptions.InvalidArgumentsException private QueryTerminationResult KillQueryTransaction(Pair <KernelTransactionHandle, ExecutingQuery> pair) { ExecutingQuery query = pair.Other(); if (IsAdminOrSelf(query.Username())) { pair.First().markForTermination(Org.Neo4j.Kernel.Api.Exceptions.Status_Transaction.Terminated); return(new QueryTerminationResult(ofInternalId(query.InternalQueryId()), query.Username())); } else { throw new AuthorizationViolationException(PERMISSION_DENIED); } }
private void RunAndCheck(string inputQuery, string outputQuery, IDictionary <string, object> @params, string paramsString) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.logging.AssertableLogProvider logProvider = new org.neo4j.logging.AssertableLogProvider(); AssertableLogProvider logProvider = new AssertableLogProvider(); ConfiguredQueryLogger queryLogger = queryLogger(logProvider, Config.defaults(GraphDatabaseSettings.log_queries_parameter_logging_enabled, "true")); // when ExecutingQuery query = query(_session_1, "neo", inputQuery, @params, emptyMap()); _clock.forward(10, TimeUnit.MILLISECONDS); queryLogger.Success(query); // then logProvider.AssertExactly(inLog(this.GetType()).info(format("%d ms: %s - %s - {%s} - {}", 10L, SessionConnectionDetails(_session_1, "neo"), outputQuery, paramsString))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToLogAllocatedBytes() public virtual void ShouldBeAbleToLogAllocatedBytes() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.logging.AssertableLogProvider logProvider = new org.neo4j.logging.AssertableLogProvider(); AssertableLogProvider logProvider = new AssertableLogProvider(); ConfiguredQueryLogger queryLogger = queryLogger(logProvider, Config.defaults(GraphDatabaseSettings.log_queries_allocation_logging_enabled, "true")); ExecutingQuery query = query(_session_1, "TestUser", QUERY_1); // when _clock.forward(17, TimeUnit.MILLISECONDS); HeapAllocation.add(4096); queryLogger.Success(query); // then logProvider.AssertExactly(inLog(this.GetType()).info(containsString("ms: 4096 B - "))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void removingQueryInTheMiddleKeepsOrder() public virtual void RemovingQueryInTheMiddleKeepsOrder() { // Given ExecutingQuery query1 = CreateExecutingQuery(1, "query1"); ExecutingQuery query2 = CreateExecutingQuery(2, "query2"); ExecutingQuery query3 = CreateExecutingQuery(3, "query3"); ExecutingQuery query4 = CreateExecutingQuery(4, "query4"); ExecutingQuery query5 = CreateExecutingQuery(5, "query5"); ExecutingQueryList list = ExecutingQueryList.EMPTY.push(query1).push(query2).push(query3).push(query4).push(query5); // When IList <ExecutingQuery> result = list.Remove(query3).queries().collect(Collectors.toList()); // Then assertThat(result, equalTo(asList(query5, query4, query2, query1))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLogQueryOnFailureEvenIfFasterThanThreshold() public virtual void ShouldLogQueryOnFailureEvenIfFasterThanThreshold() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.logging.AssertableLogProvider logProvider = new org.neo4j.logging.AssertableLogProvider(); AssertableLogProvider logProvider = new AssertableLogProvider(); ExecutingQuery query = query(_session_1, "TestUser", QUERY_1); ConfiguredQueryLogger queryLogger = queryLogger(logProvider); Exception failure = new Exception(); // when _clock.forward(1, TimeUnit.MILLISECONDS); queryLogger.Failure(query, failure); // then logProvider.AssertExactly(inLog(this.GetType()).error(@is("1 ms: " + SessionConnectionDetails(_session_1, "TestUser") + " - MATCH (n) RETURN n - {}"), sameInstance(failure))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLogQuerySlowerThanThreshold() public virtual void ShouldLogQuerySlowerThanThreshold() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.logging.AssertableLogProvider logProvider = new org.neo4j.logging.AssertableLogProvider(); AssertableLogProvider logProvider = new AssertableLogProvider(); ExecutingQuery query = query(_session_1, "TestUser", QUERY_1); ConfiguredQueryLogger queryLogger = queryLogger(logProvider); // when _clock.forward(11, TimeUnit.MILLISECONDS); queryLogger.Success(query); // then string expectedSessionString = SessionConnectionDetails(_session_1, "TestUser"); logProvider.AssertExactly(inLog(this.GetType()).info(format("%d ms: %s - %s - {}", 11L, expectedSessionString, QUERY_1))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLogQueryParametersOnFailure() public virtual void ShouldLogQueryParametersOnFailure() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.logging.AssertableLogProvider logProvider = new org.neo4j.logging.AssertableLogProvider(); AssertableLogProvider logProvider = new AssertableLogProvider(); IDictionary <string, object> @params = new Dictionary <string, object>(); @params["ages"] = Arrays.asList(41, 42, 43); ExecutingQuery query = query(_session_1, "TestUser", QUERY_4, @params, emptyMap()); ConfiguredQueryLogger queryLogger = queryLogger(logProvider, Config.defaults(GraphDatabaseSettings.log_queries_parameter_logging_enabled, "true")); Exception failure = new Exception(); // when _clock.forward(1, TimeUnit.MILLISECONDS); queryLogger.Failure(query, failure); // then logProvider.AssertExactly(inLog(this.GetType()).error(@is("1 ms: " + SessionConnectionDetails(_session_1, "TestUser") + " - MATCH (n) WHERE n.age IN {ages} RETURN n - {ages: [41, 42, 43]} - {}"), sameInstance(failure))); }
internal override ExecutingQueryList Remove(ExecutingQuery parent, ExecutingQuery target) { if (target.Equals(Query)) { Next.waitsFor(parent); return(Next); } else { ExecutingQueryList removed = Next.remove(parent, target); if (removed == Next) { return(this); } else { return(new Entry(Query, removed)); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLogQueryParameters() public virtual void ShouldLogQueryParameters() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.logging.AssertableLogProvider logProvider = new org.neo4j.logging.AssertableLogProvider(); AssertableLogProvider logProvider = new AssertableLogProvider(); IDictionary <string, object> @params = new Dictionary <string, object>(); @params["ages"] = Arrays.asList(41, 42, 43); ExecutingQuery query = query(_session_1, "TestUser", QUERY_4, @params, emptyMap()); ConfiguredQueryLogger queryLogger = queryLogger(logProvider, Config.defaults(GraphDatabaseSettings.log_queries_parameter_logging_enabled, "true")); // when _clock.forward(11, TimeUnit.MILLISECONDS); queryLogger.Success(query); // then string expectedSessionString = SessionConnectionDetails(_session_1, "TestUser"); logProvider.AssertExactly(inLog(this.GetType()).info(format("%d ms: %s - %s - %s - {}", 11L, expectedSessionString, QUERY_4, "{ages: " + "[41, 42, 43]}"))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLogUserName() public virtual void ShouldLogUserName() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.logging.AssertableLogProvider logProvider = new org.neo4j.logging.AssertableLogProvider(); AssertableLogProvider logProvider = new AssertableLogProvider(); ConfiguredQueryLogger queryLogger = queryLogger(logProvider); // when ExecutingQuery query = query(_session_1, "TestUser", QUERY_1); _clock.forward(10, TimeUnit.MILLISECONDS); queryLogger.Success(query); ExecutingQuery anotherQuery = query(_session_1, "AnotherUser", QUERY_1); _clock.forward(10, TimeUnit.MILLISECONDS); queryLogger.Success(anotherQuery); // then logProvider.AssertExactly(inLog(this.GetType()).info(format("%d ms: %s - %s - {}", 10L, SessionConnectionDetails(_session_1, "TestUser"), QUERY_1)), inLog(this.GetType()).info(format("%d ms: %s - %s - {}", 10L, SessionConnectionDetails(_session_1, "AnotherUser"), QUERY_1))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLogMetaData() public virtual void ShouldLogMetaData() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.logging.AssertableLogProvider logProvider = new org.neo4j.logging.AssertableLogProvider(); AssertableLogProvider logProvider = new AssertableLogProvider(); ConfiguredQueryLogger queryLogger = queryLogger(logProvider); // when ExecutingQuery query = query(_session_1, "TestUser", QUERY_1, emptyMap(), map("User", "UltiMate")); _clock.forward(10, TimeUnit.MILLISECONDS); queryLogger.Success(query); ExecutingQuery anotherQuery = query(_session_1, "AnotherUser", QUERY_1, emptyMap(), map("Place", "Town")); _clock.forward(10, TimeUnit.MILLISECONDS); Exception error = new Exception(); queryLogger.Failure(anotherQuery, error); // then logProvider.AssertExactly(inLog(this.GetType()).info(format("%d ms: %s - %s - {User: '******'}", 10L, SessionConnectionDetails(_session_1, "TestUser"), QUERY_1)), inLog(this.GetType()).error(equalTo(format("%d ms: %s - %s - {Place: 'Town'}", 10L, SessionConnectionDetails(_session_1, "AnotherUser"), QUERY_1)), sameInstance(error))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLogRuntime() public virtual void ShouldLogRuntime() { // given AssertableLogProvider logProvider = new AssertableLogProvider(); IDictionary <string, object> @params = new Dictionary <string, object>(); @params["ages"] = Arrays.asList(41, 42, 43); ExecutingQuery query = query(_session_1, "TestUser", QUERY_4, @params, emptyMap()); Config config = Config.defaults(); config.Augment(GraphDatabaseSettings.log_queries_parameter_logging_enabled, "true"); config.Augment(GraphDatabaseSettings.log_queries_runtime_logging_enabled, "true"); QueryLogger queryLogger = queryLogger(logProvider, config); // when _clock.forward(11, TimeUnit.MILLISECONDS); query.CompilationCompleted(new CompilerInfo("magic", "quantum", Collections.emptyList()), null); queryLogger.Success(query); // then string expectedSessionString = SessionConnectionDetails(_session_1, "TestUser"); logProvider.AssertExactly(inLog(this.GetType()).info(format("%d ms: %s - %s - %s - {}", 11L, expectedSessionString, QUERY_4, "{ages: [41, 42, 43]} - runtime=quantum"))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("ConstantConditions") @Test public void neverStopsExecutingQueryDuringCommitAndRestartTx() public virtual void NeverStopsExecutingQueryDuringCommitAndRestartTx() { // Given KernelTransaction initialKTX = MockTransaction(_initialStatement); InternalTransaction initialTransaction = mock(typeof(InternalTransaction), new ReturnsDeepStubs()); KernelTransaction.Type transactionType = KernelTransaction.Type.@implicit; SecurityContext securityContext = SecurityContext.AUTH_DISABLED; when(initialTransaction.TransactionType()).thenReturn(transactionType); when(initialTransaction.SecurityContext()).thenReturn(securityContext); when(initialTransaction.TerminationReason()).thenReturn(null); QueryRegistryOperations initialQueryRegistry = mock(typeof(QueryRegistryOperations)); ExecutingQuery executingQuery = mock(typeof(ExecutingQuery)); PropertyContainerLocker locker = null; ThreadToStatementContextBridge txBridge = mock(typeof(ThreadToStatementContextBridge)); Statement secondStatement = mock(typeof(Statement)); KernelTransaction secondKTX = MockTransaction(secondStatement); InternalTransaction secondTransaction = mock(typeof(InternalTransaction)); when(secondTransaction.TerminationReason()).thenReturn(null); QueryRegistryOperations secondQueryRegistry = mock(typeof(QueryRegistryOperations)); when(executingQuery.QueryText()).thenReturn("X"); when(executingQuery.QueryParameters()).thenReturn(EMPTY_MAP); when(_initialStatement.queryRegistration()).thenReturn(initialQueryRegistry); when(_queryService.beginTransaction(transactionType, securityContext)).thenReturn(secondTransaction); when(txBridge.GetKernelTransactionBoundToThisThread(true)).thenReturn(initialKTX, initialKTX, secondKTX); when(secondStatement.QueryRegistration()).thenReturn(secondQueryRegistry); Kernel kernel = mock(typeof(Kernel)); Neo4jTransactionalContext context = new Neo4jTransactionalContext(_queryService, txBridge, locker, initialTransaction, _initialStatement, executingQuery, kernel); // When context.CommitAndRestartTx(); // Then object[] mocks = new object[] { txBridge, initialTransaction, initialKTX, initialQueryRegistry, secondQueryRegistry, secondKTX }; InOrder order = Mockito.inOrder(mocks); // (0) Constructor order.verify(initialTransaction).transactionType(); order.verify(initialTransaction).securityContext(); order.verify(txBridge).getKernelTransactionBoundToThisThread(true); order.verify(initialTransaction).terminationReason(); // not terminated check // (1) Collect stats order.verify(initialKTX).executionStatistics(); // (2) Unbind old order.verify(txBridge).getKernelTransactionBoundToThisThread(true); order.verify(txBridge).unbindTransactionFromCurrentThread(); // (3) Register and unbind new order.verify(txBridge).getKernelTransactionBoundToThisThread(true); order.verify(secondKTX).acquireStatement(); order.verify(secondQueryRegistry).registerExecutingQuery(executingQuery); order.verify(txBridge).unbindTransactionFromCurrentThread(); // (4) Rebind, unregister, and close old order.verify(txBridge).bindTransactionToCurrentThread(initialKTX); order.verify(initialQueryRegistry).unregisterExecutingQuery(executingQuery); order.verify(initialTransaction).success(); order.verify(initialTransaction).close(); order.verify(txBridge).unbindTransactionFromCurrentThread(); // (5) Rebind new order.verify(txBridge).bindTransactionToCurrentThread(secondKTX); verifyNoMoreInteractions(mocks); }
// QueryExecutionMonitor public override void EndFailure(ExecutingQuery query, Exception failure) { }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: QueryStatusResult(org.neo4j.kernel.api.query.ExecutingQuery query, org.neo4j.kernel.impl.core.EmbeddedProxySPI manager, java.time.ZoneId zoneId) throws org.neo4j.kernel.api.exceptions.InvalidArgumentsException internal QueryStatusResult(ExecutingQuery query, EmbeddedProxySPI manager, ZoneId zoneId) : this(query.Snapshot(), manager, zoneId) { }
internal void StopQueryExecution(ExecutingQuery executingQuery) { this._executingQueryList = _executingQueryList.remove(executingQuery); _transaction.getStatistics().addWaitingTime(executingQuery.ReportedWaitingTimeNanos()); }
internal void StartQueryExecution(ExecutingQuery query) { this._executingQueryList = _executingQueryList.push(query); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("ConstantConditions") @Test public void rollsBackNewlyCreatedTransactionIfTerminationDetectedOnCloseDuringPeriodicCommit() public virtual void RollsBackNewlyCreatedTransactionIfTerminationDetectedOnCloseDuringPeriodicCommit() { // Given InternalTransaction initialTransaction = mock(typeof(InternalTransaction), new ReturnsDeepStubs()); KernelTransaction.Type transactionType = KernelTransaction.Type.@implicit; SecurityContext securityContext = SecurityContext.AUTH_DISABLED; when(initialTransaction.TransactionType()).thenReturn(transactionType); when(initialTransaction.SecurityContext()).thenReturn(securityContext); when(initialTransaction.TerminationReason()).thenReturn(null); GraphDatabaseQueryService queryService = mock(typeof(GraphDatabaseQueryService)); Statement initialStatement = mock(typeof(Statement)); KernelTransaction initialKTX = MockTransaction(initialStatement); QueryRegistryOperations initialQueryRegistry = mock(typeof(QueryRegistryOperations)); ExecutingQuery executingQuery = mock(typeof(ExecutingQuery)); PropertyContainerLocker locker = new PropertyContainerLocker(); ThreadToStatementContextBridge txBridge = mock(typeof(ThreadToStatementContextBridge)); Statement secondStatement = mock(typeof(Statement)); KernelTransaction secondKTX = MockTransaction(secondStatement); InternalTransaction secondTransaction = mock(typeof(InternalTransaction)); when(secondTransaction.TerminationReason()).thenReturn(null); QueryRegistryOperations secondQueryRegistry = mock(typeof(QueryRegistryOperations)); when(executingQuery.QueryText()).thenReturn("X"); when(executingQuery.QueryParameters()).thenReturn(EMPTY_MAP); Mockito.doThrow(typeof(Exception)).when(initialTransaction).close(); when(initialStatement.QueryRegistration()).thenReturn(initialQueryRegistry); when(queryService.BeginTransaction(transactionType, securityContext)).thenReturn(secondTransaction); when(txBridge.GetKernelTransactionBoundToThisThread(true)).thenReturn(initialKTX, initialKTX, secondKTX); when(txBridge.Get()).thenReturn(secondStatement); when(secondStatement.QueryRegistration()).thenReturn(secondQueryRegistry); Kernel kernel = mock(typeof(Kernel)); Neo4jTransactionalContext context = new Neo4jTransactionalContext(queryService, txBridge, locker, initialTransaction, initialStatement, executingQuery, kernel); // When try { context.CommitAndRestartTx(); throw new AssertionError("Expected RuntimeException to be thrown"); } catch (Exception) { // Then object[] mocks = new object[] { txBridge, initialTransaction, initialQueryRegistry, initialKTX, secondQueryRegistry, secondKTX, secondTransaction }; InOrder order = Mockito.inOrder(mocks); // (0) Constructor order.verify(initialTransaction).transactionType(); order.verify(initialTransaction).securityContext(); order.verify(txBridge).getKernelTransactionBoundToThisThread(true); order.verify(initialTransaction).terminationReason(); // not terminated check // (1) Collect statistics order.verify(initialKTX).executionStatistics(); // (2) Unbind old order.verify(txBridge).getKernelTransactionBoundToThisThread(true); order.verify(txBridge).unbindTransactionFromCurrentThread(); // (3) Register and unbind new order.verify(txBridge).getKernelTransactionBoundToThisThread(true); order.verify(secondKTX).acquireStatement(); order.verify(secondQueryRegistry).registerExecutingQuery(executingQuery); order.verify(txBridge).unbindTransactionFromCurrentThread(); // (4) Rebind, unregister, and close old order.verify(txBridge).bindTransactionToCurrentThread(initialKTX); order.verify(initialQueryRegistry).unregisterExecutingQuery(executingQuery); order.verify(initialTransaction).success(); order.verify(initialTransaction).close(); order.verify(txBridge).bindTransactionToCurrentThread(secondKTX); order.verify(secondTransaction).failure(); order.verify(secondTransaction).close(); order.verify(txBridge).unbindTransactionFromCurrentThread(); verifyNoMoreInteractions(mocks); } }
public override void Failure(ExecutingQuery query, Exception failure) { _log.error(LogEntry(query.Snapshot()), failure); }