graph.tx().onClose(Transaction.CLOSE_BEHAVIOR.COMMIT); try { latch.await();
@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")); }
@Test @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = FEATURE_TRANSACTIONS) public void shouldHaveExceptionConsistencyWhenOnCloseToNull() { try { g.tx().onClose(null); fail("An exception should be thrown when onClose behavior is set to null"); } catch (Exception ex) { validateException(Transaction.Exceptions.onCloseBehaviorCannotBeNull(), ex); } }
@Watched @Override public void clear(Graph graph, Configuration config) throws Exception { TestGraph testGraph = (TestGraph) graph; if (testGraph == null || !testGraph.initedBackend()) { return; } String graphName = config.getString(CoreOptions.STORE.name()); if (testGraph.closed()) { if (this.graphs.get(graphName) == testGraph) { this.graphs.remove(graphName); } return; } // Reset consumers graph.tx().onReadWrite(Transaction.READ_WRITE_BEHAVIOR.AUTO); graph.tx().onClose(Transaction.CLOSE_BEHAVIOR.ROLLBACK); // Ensure tx clean graph.tx().rollback(); // Clear all data Class<?> testClass = (Class<?>) config.getProperty(TEST_CLASS); testGraph.clearAll(testClass.getCanonicalName()); LOG.debug("Clear graph '{}'", graphName); }
@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(); } }
private synchronized TitanGraph newTitanGraph(String name, String address, String pathToConfig){ TitanGraph titanGraph = configureGraph(name, address, pathToConfig); buildTitanIndexes(titanGraph); titanGraph.tx().onClose(Transaction.CLOSE_BEHAVIOR.ROLLBACK); return titanGraph; }
private synchronized TitanGraph newTitanGraph(String name, String address, Properties properties, boolean batchLoading){ TitanGraph titanGraph = configureGraph(name, address, properties, batchLoading); buildTitanIndexes(titanGraph); titanGraph.tx().onClose(Transaction.CLOSE_BEHAVIOR.ROLLBACK); return titanGraph; }
graph.tx().onClose(Transaction.CLOSE_BEHAVIOR.COMMIT); try { latch.await();
@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")); }
@Test @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = FEATURE_TRANSACTIONS) public void shouldHaveExceptionConsistencyWhenOnCloseToNull() { try { g.tx().onClose(null); fail("An exception should be thrown when onClose behavior is set to null"); } catch (Exception ex) { validateException(Transaction.Exceptions.onCloseBehaviorCannotBeNull(), ex); } }
private synchronized JanusGraph newJanusGraph(boolean batchLoading){ JanusGraph JanusGraph = configureGraph(batchLoading); buildJanusIndexes(JanusGraph); JanusGraph.tx().onClose(Transaction.CLOSE_BEHAVIOR.ROLLBACK); if (!strategiesApplied.getAndSet(true)) { TraversalStrategies strategies = TraversalStrategies.GlobalCache.getStrategies(StandardJanusGraph.class); strategies = strategies.clone().addStrategies(new JanusPreviousPropertyStepStrategy()); //TODO: find out why Tinkerpop added these strategies. They result in many NoOpBarrier steps which slowed down our queries so we had to remove them. strategies.removeStrategies(PathRetractionStrategy.class, LazyBarrierStrategy.class); TraversalStrategies.GlobalCache.registerStrategies(StandardJanusGraph.class, strategies); TraversalStrategies.GlobalCache.registerStrategies(StandardJanusGraphTx.class, strategies); } return JanusGraph; }
@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(); } }