public void setGraph(TitanGraph graph) { Preconditions.checkArgument(graph!=null && graph.isOpen(),"Need to provide open graph"); this.graph = (StandardTitanGraph)graph; provided = true; }
private static void awaitIndexUpdate(TitanGraph g, String indexName, String relationTypeName, long time, TemporalUnit unit) { Preconditions.checkArgument(g!=null && g.isOpen(),"Need to provide valid, open graph instance"); Preconditions.checkArgument(time>0 && unit!=null,"Need to provide valid time interval"); Preconditions.checkArgument(StringUtils.isNotBlank(indexName),"Need to provide an index name");
@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); } }
@Test public void testTitanFactoryBuilder() { String baseDir = Joiner.on(File.separator).join("target", "es", "titanfactory_jvmlocal_ext"); TitanFactory.Builder builder = TitanFactory.build(); builder.set("storage.backend", "inmemory"); builder.set("index." + INDEX_NAME + ".elasticsearch.interface", "NODE"); builder.set("index." + INDEX_NAME + ".elasticsearch.ext.node.data", "true"); builder.set("index." + INDEX_NAME + ".elasticsearch.ext.node.client", "false"); builder.set("index." + INDEX_NAME + ".elasticsearch.ext.node.local", "true"); builder.set("index." + INDEX_NAME + ".elasticsearch.ext.path.data", baseDir + File.separator + "data"); builder.set("index." + INDEX_NAME + ".elasticsearch.ext.path.work", baseDir + File.separator + "work"); builder.set("index." + INDEX_NAME + ".elasticsearch.ext.path.logs", baseDir + File.separator + "logs"); TitanGraph graph = builder.open(); // Must not throw an exception assertTrue(graph.isOpen()); graph.close(); }
public void setGraph(TitanGraph graph) { Preconditions.checkArgument(graph!=null && graph.isOpen(),"Need to provide open graph"); this.graph = (StandardTitanGraph)graph; provided = true; }
public void cleanUp() throws BackendException { synchronized (openGraphs) { for (Map.Entry<String, TitanGraph> entry : openGraphs.entrySet()) { String uid = entry.getKey(); TitanGraph g = entry.getValue(); if (g.isOpen()) { log.warn("Detected possible graph[uid={}] leak in Blueprints GraphTest method {}, shutting down the leaked graph", uid, getMostRecentMethodName()); g.shutdown(); } extraCleanUp(uid); } openGraphs.clear(); } }
@Override public Graph generateGraph(String uid) { synchronized (openGraphs) { if (!openGraphs.containsKey(uid)) { beforeOpeningGraph(uid); } else if (openGraphs.get(uid).isOpen()) { log.warn("Detected possible graph[uid={}] leak in Blueprints GraphTest method {}, shutting down the leaked graph", uid, getMostRecentMethodName()); openGraphs.get(uid).shutdown(); } else { log.debug("Reopening previously-closed graph[uid={}]", uid); } } log.info("Opening graph with uid={}", uid); openGraphs.put(uid, openGraph(uid)); return openGraphs.get(uid); }
@Override public void clear() { TitanGraph graph = getGraph(); if (graph.isOpen()) { // only a shut down graph can be cleared graph.close(); } TitanCleanup.clear(graph); }
@Override public void clear() { TitanGraph graph = getGraph(); if (graph.isOpen()) { // only a shut down graph can be cleared graph.shutdown(); } TitanCleanup.clear(graph); }
private static void awaitIndexUpdate(TitanGraph g, String indexName, String relationTypeName, long time, TemporalUnit unit) { Preconditions.checkArgument(g!=null && g.isOpen(),"Need to provide valid, open graph instance"); Preconditions.checkArgument(time>0 && unit!=null,"Need to provide valid time interval"); Preconditions.checkArgument(StringUtils.isNotBlank(indexName),"Need to provide an index name");