Example #1
0
 private long getLabelId(HighlyAvailableGraphDatabase db, Label label)
     throws LabelNotFoundKernelException {
   try (Transaction ignore = db.beginTx()) {
     ThreadToStatementContextBridge bridge =
         db.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class);
     return bridge.instance().readOperations().labelGetForName(label.name());
   }
 }
 public void accept(DbStructureVisitor visitor) {
   try (Transaction tx = db.beginTx()) {
     try (Statement statement = bridge.get()) {
       showStructure(statement, visitor);
     }
     tx.success();
   }
 }
Example #3
0
  @Override
  protected ExtendedExecutionResult getResult(String query, Map<String, Object> parameters)
      throws ShellException, RemoteException {
    GraphDatabaseAPI graphDatabaseAPI = getServer().getDb();
    ServerExecutionEngine engine = getEngine();
    if (engine.isPeriodicCommit(query)) {
      ThreadToStatementContextBridge manager =
          graphDatabaseAPI
              .getDependencyResolver()
              .resolveDependency(ThreadToStatementContextBridge.class);
      TopLevelTransaction tx = manager.getTopLevelTransactionBoundToThisThread(true);
      manager.unbindTransactionFromCurrentThread();

      try {
        return super.getResult(query, parameters);
      } finally {
        manager.bindTransactionToCurrentThread(tx);
      }
    } else {
      return super.getResult(query, parameters);
    }
  }
Example #4
0
 public void resume() throws Exception {
   bridge.bindTransactionToCurrentThread(graphDbTx);
 }
Example #5
0
 public void suspend() {
   graphDbTx = bridge.getTopLevelTransactionBoundToThisThread(true);
   bridge.unbindTransactionFromCurrentThread();
 }
Example #6
0
 private org.neo4j.kernel.TopLevelTransaction activeTransaction() {
   ThreadToStatementContextBridge bridge =
       db.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class);
   return bridge.getTopLevelTransactionBoundToThisThread(false);
 }
 @Before
 public void setup() {
   when(bridge.get()).thenReturn(stmt);
 }