void resumeSinceTransactionsAreStillThreadBound() { assert suspendedTransaction != null : "Can't resume the transaction if it has not first been suspended."; bridge.bindTransactionToCurrentThread( suspendedTransaction ); suspendedTransaction = null; }
@Override public void bindTransactionToCurrentThread( KernelTransaction tx ) { txBridge.bindTransactionToCurrentThread( tx ); }
private void resume( Transaction tx ) { ThreadToStatementContextBridge txManager = getTransactionManager(); txManager.bindTransactionToCurrentThread( txMap.remove(tx) ); }
@Override public KernelTransaction beginTransaction( KernelTransaction.Type type, LoginContext ignored, long timeout ) { try { availability.assertDatabaseAvailable(); KernelTransaction kernelTx = sourceModule.kernelAPI.get().beginTransaction( type, this.securityContext, timeout ); kernelTx.registerCloseListener( txId -> threadToTransactionBridge.unbindTransactionFromCurrentThread() ); threadToTransactionBridge.bindTransactionToCurrentThread( kernelTx ); return kernelTx; } catch ( TransactionFailureException e ) { throw new org.neo4j.graphdb.TransactionFailureException( e.getMessage(), e ); } } }
@Override public KernelTransaction beginTransaction( KernelTransaction.Type type, LoginContext loginContext, long timeout ) { try { availability.assertDatabaseAvailable(); KernelTransaction kernelTx = dataSource.kernelAPI.get().beginTransaction( type, loginContext, timeout ); kernelTx.registerCloseListener( txId -> threadToTransactionBridge.unbindTransactionFromCurrentThread() ); threadToTransactionBridge.bindTransactionToCurrentThread( kernelTx ); return kernelTx; } catch ( TransactionFailureException e ) { throw new org.neo4j.graphdb.TransactionFailureException( e.getMessage(), e ); } } }
order.verify( txBridge ).bindTransactionToCurrentThread( initialKTX ); order.verify( initialQueryRegistry ).unregisterExecutingQuery( executingQuery ); order.verify( initialTransaction ).success(); order.verify( txBridge ).bindTransactionToCurrentThread( secondKTX ); verifyNoMoreInteractions( mocks );
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();
txBridge.bindTransactionToCurrentThread( oldKernelTx ); oldQueryRegistryOperations.unregisterExecutingQuery( executingQuery ); try txBridge.bindTransactionToCurrentThread( kernelTransaction ); transaction.failure(); transaction.close(); txBridge.bindTransactionToCurrentThread( kernelTransaction );
@Override public void bindTransactionToCurrentThread( KernelTransaction tx ) { txBridge.bindTransactionToCurrentThread( tx ); }
void resumeSinceTransactionsAreStillThreadBound() { assert suspendedTransaction != null : "Can't resume the transaction if it has not first been suspended."; bridge.bindTransactionToCurrentThread( suspendedTransaction ); suspendedTransaction = null; }
private void resumeTransaction(KernelTransaction tx) { if (tx == null) return; try { threadToStatementContextBridge.bindTransactionToCurrentThread(tx); } catch (Exception e) { throw new RuntimeException("Error resuming Transaction "+tx,e); } }
/** * Set the callback to receive the next response. This will receive one completion or one failure, and then be * detached again. This exists both to ensure that each callback only gets called once, as well as to avoid * repeating the callback and attachments in every method signature in the state machine. */ private void before( Object attachment, Callback cb ) { if ( hasTransaction() ) { txBridge.bindTransactionToCurrentThread( (TopLevelTransaction) currentTransaction ); } assert this.currentCallback == null; assert this.currentAttachment == null; this.currentCallback = cb; this.currentAttachment = attachment; }
/** * Set the callback to receive the next response. This will receive one completion or one failure, and then be * detached again. This exists both to ensure that each callback only gets called once, as well as to avoid * repeating the callback and attachments in every method signature in the state machine. */ private void before( Object attachment, Callback cb ) { if ( hasTransaction() ) { txBridge.bindTransactionToCurrentThread( (TopLevelTransaction) currentTransaction ); } assert this.currentCallback == null; assert this.currentAttachment == null; this.currentCallback = cb; this.currentAttachment = attachment; }
public boolean bindTransaction( Serializable clientId ) throws ShellException { KernelTransaction tx = clients.get( clientId ); if ( tx != null ) { try { ThreadToStatementContextBridge bridge = getThreadToStatementContextBridge(); if ( bridge.getKernelTransactionBoundToThisThread( false ) == tx ) { // This thread is already bound to this transaction. This can happen if a shell command // in turn calls out to other shell commands. In those cases the sub-commands should just // participate in the existing transaction. Neo4j already has support for nested // transactions, but in the shell server, we are managing the transaction context bridge // in this laborious and manual way, so it is easier for us to just avoid re-binding the // existing transaction. We return 'true' here to indicate that our transaction context // is nested, and that we therefor have to avoid unbinding this transaction later. return true; } bridge.bindTransactionToCurrentThread( tx ); } catch ( Exception e ) { throw wrapException( e ); } } return false; }
@Override public KernelTransaction beginTransaction( KernelTransaction.Type type, LoginContext loginContext, long timeout ) { try { availability.assertDatabaseAvailable(); KernelTransaction kernelTx = dataSource.kernelAPI.get().beginTransaction( type, loginContext, timeout ); kernelTx.registerCloseListener( txId -> threadToTransactionBridge.unbindTransactionFromCurrentThread() ); threadToTransactionBridge.bindTransactionToCurrentThread( kernelTx ); return kernelTx; } catch ( TransactionFailureException e ) { throw new org.neo4j.graphdb.TransactionFailureException( e.getMessage(), e ); } } }
@Override public KernelTransaction beginTransaction( KernelTransaction.Type type, LoginContext ignored, long timeout ) { try { availability.assertDatabaseAvailable(); KernelTransaction kernelTx = sourceModule.kernelAPI.get().beginTransaction( type, this.securityContext, timeout ); kernelTx.registerCloseListener( txId -> threadToTransactionBridge.unbindTransactionFromCurrentThread() ); threadToTransactionBridge.bindTransactionToCurrentThread( kernelTx ); return kernelTx; } catch ( TransactionFailureException e ) { throw new org.neo4j.graphdb.TransactionFailureException( e.getMessage(), e ); } } }
txBridge.bindTransactionToCurrentThread( oldKernelTx ); oldQueryRegistryOperations.unregisterExecutingQuery( executingQuery ); try txBridge.bindTransactionToCurrentThread( kernelTransaction ); transaction.failure(); transaction.close(); txBridge.bindTransactionToCurrentThread( kernelTransaction );