org.apache.tinkerpop.gremlin.structure.Transaction.close()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(85)

本文整理了Java中org.apache.tinkerpop.gremlin.structure.Transaction.close()方法的一些代码示例,展示了Transaction.close()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transaction.close()方法的具体详情如下:
包路径:org.apache.tinkerpop.gremlin.structure.Transaction
类名称:Transaction
方法名:close

Transaction.close介绍

[英]Closes the transaction where the default close behavior defined by { #onClose(Consumer)} will be executed.
[中]关闭将执行{#onClose(Consumer)}定义的默认关闭行为的事务。

代码示例

代码示例来源:origin: thinkaurelius/titan

@Override
public void close() {
  tx().close();
}

代码示例来源:origin: JanusGraph/janusgraph

@Override
public void close() {
  tx().close();
}

代码示例来源:origin: apache/tinkerpop

/**
 * This implementation of {@code close} will also close the current transaction on the thread, but it
 * is up to the caller to deal with dangling transactions in other threads prior to calling this method.
 */
@Override
public void close() throws Exception {
  this.tx().close();
  if (this.baseGraph != null) this.baseGraph.shutdown();
}

代码示例来源:origin: apache/tinkerpop

latch.countDown();
  graph.addVertex();
  graph.tx().close();
});

代码示例来源:origin: apache/tinkerpop

@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_PERSISTENCE)
public void shouldCommitOnCloseWhenConfigured() throws Exception {
  final AtomicReference<Object> oid = new AtomicReference<>();
  final Thread t = new Thread(() -> {
    final Vertex v1 = graph.addVertex("name", "marko");
    g.tx().onClose(Transaction.CLOSE_BEHAVIOR.COMMIT);
    oid.set(v1.id());
    graph.tx().close();
  });
  t.start();
  t.join();
  final Vertex v2 = graph.vertices(oid.get()).next();
  assertEquals("marko", v2.<String>value("name"));
}

代码示例来源:origin: apache/tinkerpop

@Test
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = FEATURE_TRANSACTIONS)
public void shouldHaveExceptionConsistencyWhenTransactionOpenOnClose() {
  g.tx().onClose(Transaction.CLOSE_BEHAVIOR.MANUAL);
  if (!g.tx().isOpen())
    g.tx().open();
  try {
    graph.tx().close();
    fail("An exception should be thrown when close behavior is manual and the graph is close with an open transaction");
  } catch (Exception ex) {
    validateException(Transaction.Exceptions.openTransactionsOnClose(), ex);
  } finally {
    // rollback manually to keep the test clean
    g.tx().rollback();
  }
}

代码示例来源:origin: Syncleus/Ferma

@Override
public void close() {
  this.getDelegate().close();
}

代码示例来源:origin: HuygensING/timbuctoo

@Override
 public void finishWriting() {
  tx.commit();
  tx.close();
  LOG.info("Finish writing");
 }
}

代码示例来源:origin: com.syncleus.ferma/ferma

@Override
public void close() {
  this.getDelegate().close();
}

代码示例来源:origin: apache/tinkerpop

@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
public void shouldAllowReferenceOfVertexOutsideOfOriginalTransactionalContextManual() {
  g.tx().onReadWrite(Transaction.READ_WRITE_BEHAVIOR.MANUAL);
  g.tx().open();
  final Vertex v1 = graph.addVertex("name", "stephen");
  g.tx().commit();
  g.tx().open();
  assertEquals("stephen", v1.value("name"));
  g.tx().rollback();
  g.tx().open();
  assertEquals("stephen", v1.value("name"));
  g.tx().close();
}

代码示例来源:origin: apache/tinkerpop

@Test
@FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
public void shouldAllowReferenceOfEdgeOutsideOfOriginalTransactionalContextManual() {
  g.tx().onReadWrite(Transaction.READ_WRITE_BEHAVIOR.MANUAL);
  g.tx().open();
  final Vertex v1 = graph.addVertex();
  final Edge e = v1.addEdge("self", v1, "weight", 0.5d);
  g.tx().commit();
  g.tx().open();
  assertEquals(0.5d, e.value("weight"), 0.00001d);
  g.tx().rollback();
  g.tx().open();
  assertEquals(0.5d, e.value("weight"), 0.00001d);
  g.tx().close();
}

代码示例来源:origin: com.puresoltechnologies.ductiledb/ductiledb-tinkerpop

@Override
public void close() throws IOException {
tx().close();
if (baseGraph != null) {
  baseGraph.close();
}
}

代码示例来源:origin: HuygensING/timbuctoo

private void commit() {
 if (++numberOfEntriesWithoutCommit >= 5000) {
  numberOfEntriesWithoutCommit = 0;
  tx.commit();
  tx.close();
  tx.open();
 }
}

代码示例来源:origin: org.apache.tinkerpop/neo4j-gremlin

/**
 * This implementation of {@code close} will also close the current transaction on the thread, but it
 * is up to the caller to deal with dangling transactions in other threads prior to calling this method.
 */
@Override
public void close() throws Exception {
  this.tx().close();
  if (this.baseGraph != null) this.baseGraph.shutdown();
}

代码示例来源:origin: io.mindmaps/mindmaps-titan-factory

@Override
  protected void closeGraphTransaction() throws Exception {
    getTinkerPopGraph().tx().close();
  }
}

代码示例来源:origin: ai.grakn/grakn-kb

private void closeTransaction(String closedReason) {
  try {
    graph.tx().close();
  } catch (UnsupportedOperationException e) {
    //Ignored for Tinker
  } finally {
    txCache().closeTx(closedReason);
    ruleCache().closeTx();
  }
}

代码示例来源:origin: Syncleus/Ferma

@Override
public void close() {
  Tx.setActive(null);
  if (isSuccess()) {
    commit();
  } else {
    rollback();
  }
  getDelegate().close();
}

代码示例来源:origin: HuygensING/timbuctoo

@Override
public void filter(final ContainerRequestContext requestContext, final ContainerResponseContext responseContext) {
 if (graphWrapper.getGraph().tx().isOpen()) {
  if (isSafeMethod(requestContext.getMethod())) {
   LOG.error("Dangling transaction, you might have lost data! (closing it, causing a rollback)");
  }
  graphWrapper.getGraph().tx().close();
 }
}

代码示例来源:origin: com.syncleus.ferma/ferma

@Override
public void close() {
  Tx.setActive(null);
  if (isSuccess()) {
    commit();
  } else {
    rollback();
  }
  getDelegate().close();
}

代码示例来源:origin: ai.grakn/grakn-titan-factory

private void closeTitan(){
    StandardTitanGraph graph = (StandardTitanGraph) getTinkerPopGraph();
    synchronized (graph) { //Have to block here because the list of open transactions in Titan is not thread safe.
      if(graph.tx().isOpen())
        graph.tx().close();

      if (graph.getOpenTxs() == 0) {
        closePermanent();
      }
    }
  }
}

相关文章