private InternalTransaction beginTransaction( KernelTransaction.Type type, LoginContext loginContext, Duration txTimeout, Map<String, Object> txMetadata ) { InternalTransaction tx; if ( txTimeout == null ) { tx = db.beginTransaction( type, loginContext ); } else { tx = db.beginTransaction( type, loginContext, txTimeout.toMillis(), TimeUnit.MILLISECONDS ); } if ( txMetadata != null ) { tx.setMetaData( txMetadata ); } return tx; }
@Override public InternalTransaction beginTransaction( KernelTransaction.Type type, LoginContext loginContext ) { return getGraphDatabaseAPI().beginTransaction( type, loginContext ); }
@Override public InternalTransaction beginTransaction( KernelTransaction.Type type, LoginContext loginContext, long timeout, TimeUnit unit ) { return getGraphDatabaseAPI().beginTransaction( type, loginContext, timeout, unit ); }
private String execute( LoginContext subject, String query, Consumer<ResourceIterator<Map<String, Object>>> resultConsumer ) { try ( Transaction tx = db.beginTransaction( KernelTransaction.Type.implicit, subject ) ) { resultConsumer.accept( db.execute( query ) ); tx.success(); return ""; } catch ( Exception e ) { return e.getMessage(); } }
public long countNodes() { long result; try ( Transaction tx = graph.beginTransaction( KernelTransaction.Type.explicit, AnonymousContext.read() ) ) { KernelTransaction kernelTransaction = this.txBridge.getKernelTransactionBoundToThisThread(true ); result = kernelTransaction.dataRead().countsForNode( -1 ); tx.success(); } return result; } }
public long makeNode( String label ) throws ProcedureException { long result; try ( Transaction tx = graph.beginTransaction( KernelTransaction.Type.explicit, AnonymousContext.write() ) ) { KernelTransaction ktx = txBridge.getKernelTransactionBoundToThisThread( true ); long nodeId = ktx.dataWrite().nodeCreate(); int labelId = ktx.tokenWrite().labelGetOrCreateForName( label ); ktx.dataWrite().nodeAddLabel( nodeId, labelId ); result = nodeId; tx.success(); } catch ( Exception e ) { log.error( "Failed to create node: " + e.getMessage() ); throw new ProcedureException( Status.Procedure.ProcedureCallFailed, "Failed to create node: " + e.getMessage(), e ); } return result; }
@Override public InternalTransaction beginTransaction( KernelTransaction.Type type, LoginContext loginContext, long timeout, TimeUnit unit ) { return actual.beginTransaction( type, loginContext, timeout, unit ); }
@Override public InternalTransaction beginTransaction( KernelTransaction.Type type, LoginContext loginContext ) { return actual.beginTransaction( type, loginContext ); }
private InternalTransaction beginTransaction( KernelTransaction.Type type, LoginContext loginContext, Duration txTimeout, Map<String, Object> txMetadata ) { InternalTransaction tx; if ( txTimeout == null ) { tx = db.beginTransaction( type, loginContext ); } else { tx = db.beginTransaction( type, loginContext, txTimeout.toMillis(), TimeUnit.MILLISECONDS ); } if ( txMetadata != null ) { tx.setMetaData( txMetadata ); } return tx; }
@Override public InternalTransaction beginTransaction( KernelTransaction.Type type, LoginContext loginContext ) { return getGraphDatabaseAPI().beginTransaction( type, loginContext ); }
@Override public InternalTransaction beginTransaction( KernelTransaction.Type type, LoginContext loginContext, long timeout, TimeUnit unit ) { return getGraphDatabaseAPI().beginTransaction( type, loginContext, timeout, unit ); }
@Override public Continuation execute( AppCommandParser parser, Session session, Output out ) throws Exception { try ( Transaction tx = getServer().getDb().beginTransaction( implicit, AUTH_DISABLED ) ) { getServer().registerTopLevelTransactionInProgress( session.getId() ); Continuation result = this.exec( parser, session, out ); if ( result == Continuation.EXCEPTION_CAUGHT ) { tx.failure(); } else { tx.success(); } return result; } }
@Override public Continuation execute( AppCommandParser parser, Session session, Output out ) throws Exception { if ( parser.arguments().isEmpty() ) // Dump the whole graph { try ( Transaction tx = getServer().getDb().beginTransaction( implicit, AUTH_DISABLED ) ) { getServer().registerTopLevelTransactionInProgress( session.getId() ); final SubGraph graph = DatabaseSubGraph.from( getServer().getDb() ); export( graph, out ); tx.success(); return Continuation.INPUT_COMPLETE; } } else { AppCommandParser newParser = newParser( parser ); return super.execute( newParser, session, out ); } }