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

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

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

Transaction.isOpen介绍

[英]Determines if a transaction is currently open.
[中]确定事务当前是否打开。

代码示例

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

void close(Transaction tx) {
  closeConsumer.accept(tx);
  Preconditions.checkState(!tx.isOpen(),"Invalid close behavior configured: Should close transaction. [%s]",closeConsumer);
}

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

void close(Transaction tx) {
  closeConsumerInternal.get().accept(tx);
  Preconditions.checkState(!tx.isOpen(),"Invalid close behavior configured: Should close transaction. [%s]", closeConsumerInternal);
}

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

@Override
public void commitAll() {
  graphs.forEach((key, graph) -> {
    if (graph.tx().isOpen())
      graph.tx().commit();
  });
}

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

@Override
public void rollbackAll() {
  graphs.forEach((key, graph) -> {
    if (graph.tx().isOpen()) {
      graph.tx().rollback();
    }
  });
}

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

public void closeTx(Graph graph, Boolean commit) {
  if (graph.tx().isOpen()) {
    if (commit) {
      graph.tx().commit();
    } else {
      graph.tx().rollback();
    }
  }
}

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

public void clopen(Object... settings) {
  config = getConfiguration();
  if (mgmt!=null && mgmt.isOpen()) mgmt.rollback();
  if (null != tx && tx.isOpen()) tx.commit();
  if (settings!=null && settings.length>0) {
    final Map<TestConfigOption,Object> options = validateConfigOptions(settings);
    JanusGraphManagement janusGraphManagement = null;
    final ModifiableConfiguration modifiableConfiguration = new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS,config, BasicConfiguration.Restriction.LOCAL);
    for (final Map.Entry<TestConfigOption,Object> option : options.entrySet()) {
      if (option.getKey().option.isLocal()) {
        modifiableConfiguration.set(option.getKey().option,option.getValue(),option.getKey().umbrella);
      } else {
        if (janusGraphManagement==null) janusGraphManagement = graph.openManagement();
        janusGraphManagement.set(ConfigElement.getPath(option.getKey().option,option.getKey().umbrella),option.getValue());
      }
    }
    if (janusGraphManagement!=null) janusGraphManagement.commit();
    modifiableConfiguration.close();
  }
  if (null != graph && null != graph.tx() && graph.tx().isOpen())
    graph.tx().commit();
  if (null != graph && graph.isOpen())
    graph.close();
  Preconditions.checkNotNull(config);
  open(config);
}

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

@Override
public void clear(Graph g, final Configuration configuration) throws Exception {
  if (null != g) {
    while (g instanceof WrappedGraph) g = ((WrappedGraph<? extends Graph>) g).getBaseGraph();
    JanusGraph graph = (JanusGraph) g;
    if (graph.isOpen()) {
      if (g.tx().isOpen()) g.tx().rollback();
      try {
        g.close();
      } catch (IOException | IllegalStateException e) {
        logger.warn("Titan graph may not have closed cleanly", e);
      }
    }
  }
  WriteConfiguration config = new CommonsConfiguration(configuration);
  BasicConfiguration readConfig = new BasicConfiguration(GraphDatabaseConfiguration.ROOT_NS, config,
    BasicConfiguration.Restriction.NONE);
  if (readConfig.has(GraphDatabaseConfiguration.STORAGE_BACKEND)) {
    JanusGraphBaseTest.clearGraph(config);
  }
}

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

@Override
public void clear(Graph g, final Configuration configuration) throws Exception {
  if (null != g) {
    while (g instanceof WrappedGraph) g = ((WrappedGraph<? extends Graph>) g).getBaseGraph();
    TitanGraph graph = (TitanGraph) g;
    if (graph.isOpen()) {
      if (g.tx().isOpen()) g.tx().rollback();
      g.close();
    }
  }
  WriteConfiguration config = new CommonsConfiguration(configuration);
  BasicConfiguration readConfig = new BasicConfiguration(GraphDatabaseConfiguration.ROOT_NS, config, BasicConfiguration.Restriction.NONE);
  if (readConfig.has(GraphDatabaseConfiguration.STORAGE_BACKEND)) {
    TitanGraphBaseTest.clearGraph(config);
  }
}

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

@Override
  public void accept(final Transaction transaction) {
    if (!transaction.isOpen()) throw Exceptions.transactionMustBeOpenToReadWrite();
  }
}

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

@Override
  public void accept(final Transaction transaction) {
    if (transaction.isOpen()) throw Exceptions.openTransactionsOnClose();
  }
}

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

@Override
  public void accept(final Transaction transaction) {
    if (transaction.isOpen()) transaction.commit();
  }
},

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

@Override
  public void accept(final Transaction transaction) {
    if (transaction.isOpen()) transaction.rollback();
  }
},

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

@Override
  public void accept(final Transaction transaction) {
    if (!transaction.isOpen()) transaction.open();
  }
},

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

/**
 * Rollback transactions across all {@link Graph} objects.
 */
public final void rollbackAll() {
  graphs.entrySet().forEach(e -> {
    final Graph graph = e.getValue();
    if (graph.features().graph().supportsTransactions() && graph.tx().isOpen())
      graph.tx().rollback();
  });
}

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

/**
 * Commit transactions across all {@link Graph} objects.
 */
public final void commitAll() {
  graphs.entrySet().forEach(e -> {
    final Graph graph = e.getValue();
    if (graph.features().graph().supportsTransactions() && graph.tx().isOpen())
      graph.tx().commit();
  });
}

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

@Test
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
public void shouldAllowAutoTransactionToWorkWithoutMutationByDefault() {
  // expecting no exceptions to be thrown here
  g.tx().commit();
  assertThat(g.tx().isOpen(), is(false));
  g.tx().rollback();
  assertThat(g.tx().isOpen(), is(false));
  g.tx().commit();
  assertThat(g.tx().isOpen(), is(false));
}

代码示例来源:origin: hugegraph/hugegraph

public void rollbackAll() {
  this.graphs.values().forEach(graph -> {
    if (graph.features().graph().supportsTransactions() &&
      graph.tx().isOpen()) {
      graph.tx().rollback();
    }
  });
}

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

@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_THREADED_TRANSACTIONS)
public void shouldOpenTxWhenThreadedTransactionIsCreated() throws Exception {
  // threaded transactions should be immediately open on creation
  final Graph threadedG = g.tx().createThreadedTx();
  assertThat(threadedG.tx().isOpen(), is(true));
  threadedG.tx().rollback();
  assertThat(threadedG.tx().isOpen(), is(false));
}

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

protected void onSideEffectSuccess(final Graph graph, final Context ctx) {
  // there was no "writing" here, just side-effect retrieval, so if a transaction was opened then
  // just close with rollback
  if (graph.features().graph().supportsTransactions() && graph.tx().isOpen()) graph.tx().rollback();
}

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

@Test
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = FEATURE_TRANSACTIONS)
public void shouldHaveExceptionConsistencyWhenTransactionAlreadyOpen() {
  if (!g.tx().isOpen())
    g.tx().open();
  try {
    g.tx().open();
    fail("An exception should be thrown when a transaction is opened twice");
  } catch (Exception ex) {
    validateException(Transaction.Exceptions.transactionAlreadyOpen(), ex);
  }
}

相关文章