Java Code Examples for com.tinkerpop.blueprints.Graph#shutdown()
The following examples show how to use
com.tinkerpop.blueprints.Graph#shutdown() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ElementPropertyCachingTest.java From AccumuloGraph with Apache License 2.0 | 6 votes |
@Test public void testPreloadAllProperties() { AccumuloGraphConfiguration cfg = AccumuloGraphTestUtils.generateGraphConfig("preloadAllProperties"); cfg.setPropertyCacheTimeout(null, TIMEOUT); cfg.setPreloadAllProperties(true); Graph graph = open(cfg); AccumuloVertex v = (AccumuloVertex) graph.addVertex("V"); v.setProperty(NON_CACHED, true); v.setProperty(CACHED, true); v = (AccumuloVertex) graph.getVertex("V"); assertEquals(true, v.getPropertyInMemory(NON_CACHED)); assertEquals(true, v.getPropertyInMemory(CACHED)); graph.shutdown(); }
Example 2
Source File: ElementPropertyCachingTest.java From AccumuloGraph with Apache License 2.0 | 6 votes |
@Test public void testPreloadSomeProperties() { AccumuloGraphConfiguration cfg = AccumuloGraphTestUtils.generateGraphConfig("preloadSomeProperties"); cfg.setPropertyCacheTimeout(null, TIMEOUT); cfg.setPreloadedProperties(new String[]{CACHED}); Graph graph = open(cfg); AccumuloVertex v = (AccumuloVertex) graph.addVertex("V"); v.setProperty(NON_CACHED, true); v.setProperty(CACHED, true); v = (AccumuloVertex) graph.getVertex("V"); assertEquals(null, v.getPropertyInMemory(NON_CACHED)); assertEquals(true, v.getPropertyInMemory(CACHED)); graph.shutdown(); }
Example 3
Source File: InputFormatsTest.java From AccumuloGraph with Apache License 2.0 | 6 votes |
@Test public void testVertexInputMap() throws Exception { final String INSTANCE_NAME = "_mapreduce_instance"; final String TEST_TABLE_NAME = "_mapreduce_table_vertexInputMap"; if (!System.getProperty("os.name").startsWith("Windows")) { Graph g = GraphFactory.open(new AccumuloGraphConfiguration().setInstanceName(INSTANCE_NAME) .setUser("root").setPassword("".getBytes()) .setGraphName(TEST_TABLE_NAME).setInstanceType(InstanceType.Mock) .setCreate(true).getConfiguration()); for (int i = 0; i < 100; i++) { g.addVertex(i + ""); } assertEquals(0, MRTester.main(new String[]{"root", "", TEST_TABLE_NAME, INSTANCE_NAME, "false"})); assertNull(e1); assertNull(e2); g.shutdown(); } }
Example 4
Source File: InputFormatsTest.java From AccumuloGraph with Apache License 2.0 | 6 votes |
@Test public void testEdgeInputMap() throws Exception { final String INSTANCE_NAME = "_mapreduce_instance"; final String TEST_TABLE_NAME = "_mapreduce_table_edgeInputMap"; if (!System.getProperty("os.name").startsWith("Windows")) { Graph g = GraphFactory.open(new AccumuloGraphConfiguration().setInstanceName(INSTANCE_NAME) .setUser("root").setPassword("".getBytes()) .setGraphName(TEST_TABLE_NAME).setInstanceType(InstanceType.Mock) .setAutoFlush(true).setCreate(true).getConfiguration()); for (int i = 0; i < 100; i++) { Vertex v1 = g.addVertex(i+""); Vertex v2 = g.addVertex(i+"a"); g.addEdge(null, v1, v2, "knows"); } assertEquals(0, MRTester.main(new String[]{"root", "", TEST_TABLE_NAME, INSTANCE_NAME, "true"})); assertNull(e1); assertNull(e2); g.shutdown(); } }
Example 5
Source File: ElementCacheTest.java From AccumuloGraph with Apache License 2.0 | 6 votes |
@Test public void testElementCacheSize() throws Exception { AccumuloGraphConfiguration cfg = AccumuloGraphTestUtils .generateGraphConfig("elementCacheSize"); Graph graph = GraphFactory.open(cfg.getConfiguration()); Vertex[] verts = new Vertex[10]; for (int i = 0; i < verts.length; i++) { verts[i] = graph.addVertex(i); } Edge[] edges = new Edge[9]; for (int i = 0; i < edges.length; i++) { edges[i] = graph.addEdge(null, verts[0], verts[i+1], "edge"); } sizeTests(verts); sizeTests(edges); graph.shutdown(); }
Example 6
Source File: AccumuloElementTest.java From AccumuloGraph with Apache License 2.0 | 5 votes |
@Test public void testNonStringIds() throws Exception { Graph graph = AccumuloGraphTestUtils.makeGraph("nonStringIds"); Object[] ids = new Object[] { 10, 20, 30L, 40L, 50.0f, 60.0f, 70.0d, 80.0d, (byte) 'a', (byte) 'b', 'c', 'd', "str1", "str2", new GenericObject("str3"), new GenericObject("str4"), }; Object[] edgeIds = new Object[] { 100, 200, 300L, 400L, 500.0f, 600.0f, 700.0d, 800.0d, (byte) 'e', (byte) 'f', 'g', 'h', "str5", "str6", new GenericObject("str7"), new GenericObject("str8"), }; for (int i = 0; i < ids.length; i++) { assertNull(graph.getVertex(ids[i])); Vertex v = graph.addVertex(ids[i]); assertNotNull(v); assertNotNull(graph.getVertex(ids[i])); } assertEquals(ids.length, count(graph.getVertices())); for (int i = 1; i < edgeIds.length; i++) { assertNull(graph.getEdge(edgeIds[i-1])); Edge e = graph.addEdge(edgeIds[i-1], graph.getVertex(ids[i-1]), graph.getVertex(ids[i]), "label"); assertNotNull(e); assertNotNull(graph.getEdge(edgeIds[i-1])); } assertEquals(edgeIds.length-1, count(graph.getEdges())); graph.shutdown(); }
Example 7
Source File: ExtendedElementTest.java From AccumuloGraph with Apache License 2.0 | 5 votes |
@Test public void testSkipExistenceChecks() throws Exception { AccumuloGraphConfiguration cfg = AccumuloGraphTestUtils.generateGraphConfig("skipExistenceChecks"); cfg.setSkipExistenceChecks(true); Graph graph = makeGraph(cfg); String id; id = "doubleAdd"; assertNotNull(graph.addVertex(id)); assertNotNull(graph.addVertex(id)); Vertex vAdd = graph.getVertex(id); assertNotNull(vAdd); graph.removeVertex(vAdd); assertNotNull(graph.getVertex(id)); id = "doubleRemove"; Vertex vRemove = graph.addVertex(id); assertNotNull(vRemove); graph.removeVertex(vRemove); assertNotNull(graph.getVertex(id)); // MDL 24 Dec 2014: removeVertex still does checks. //graph.removeVertex(vRemove); //assertNotNull(graph.getVertex(id)); id = "notExist"; assertNotNull(graph.getVertex(id)); graph.shutdown(); }
Example 8
Source File: ElementCacheTest.java From AccumuloGraph with Apache License 2.0 | 5 votes |
@Test public void testElementCacheTimeout() throws Exception { AccumuloGraphConfiguration cfg = AccumuloGraphTestUtils .generateGraphConfig("elementCacheTimeout"); Graph graph = GraphFactory.open(cfg.getConfiguration()); ElementCache<Element> cache = new ElementCache<Element>(10, 1000); Vertex v1 = graph.addVertex(1); Vertex v2 = graph.addVertex(2); assertNull(cache.retrieve(1)); assertNull(cache.retrieve(2)); cache.cache(v1); assertNotNull(cache.retrieve(v1.getId())); Thread.sleep(1500); assertNull(cache.retrieve(v1.getId())); Edge e = graph.addEdge(null, v1, v2, "label"); assertNull(cache.retrieve(e.getId())); cache.cache(e); assertNotNull(cache.retrieve(e.getId())); Thread.sleep(1500); assertNull(cache.retrieve(e.getId())); graph.shutdown(); }
Example 9
Source File: ElementPropertyCachingTest.java From AccumuloGraph with Apache License 2.0 | 4 votes |
@Test public void testCachingDisabled() { AccumuloGraphConfiguration cfg = AccumuloGraphTestUtils.generateGraphConfig("cachingDisabled"); assertTrue(cfg.getPropertyCacheTimeout(null) <= 0); assertTrue(cfg.getPropertyCacheTimeout(NON_CACHED) <= 0); assertTrue(cfg.getPropertyCacheTimeout(CACHED) <= 0); Graph graph = open(cfg); load(graph); AccumuloVertex a = (AccumuloVertex) graph.getVertex("A"); AccumuloVertex b = (AccumuloVertex) graph.getVertex("B"); AccumuloVertex c = (AccumuloVertex) graph.getVertex("C"); assertEquals(null, a.getProperty(NON_CACHED)); assertEquals(true, b.getProperty(NON_CACHED)); assertEquals(null, c.getProperty(NON_CACHED)); assertEquals(null, a.getProperty(CACHED)); assertEquals(null, b.getProperty(CACHED)); assertEquals(true, c.getProperty(CACHED)); assertEquals(null, a.getPropertyCache().get(NON_CACHED)); assertEquals(null, b.getPropertyCache().get(NON_CACHED)); assertEquals(null, c.getPropertyCache().get(NON_CACHED)); assertEquals(null, a.getPropertyCache().get(CACHED)); assertEquals(null, b.getPropertyCache().get(CACHED)); assertEquals(null, c.getPropertyCache().get(CACHED)); assertEquals(Sets.newHashSet(), a.getPropertyCache().keySet()); assertEquals(Sets.newHashSet(), b.getPropertyCache().keySet()); assertEquals(Sets.newHashSet(), c.getPropertyCache().keySet()); a.removeProperty(NON_CACHED); b.removeProperty(NON_CACHED); c.removeProperty(NON_CACHED); a.removeProperty(CACHED); b.removeProperty(CACHED); c.removeProperty(CACHED); assertEquals(null, a.getProperty(NON_CACHED)); assertEquals(null, b.getProperty(NON_CACHED)); assertEquals(null, c.getProperty(NON_CACHED)); assertEquals(null, a.getProperty(CACHED)); assertEquals(null, b.getProperty(CACHED)); assertEquals(null, c.getProperty(CACHED)); assertEquals(null, a.getPropertyCache().get(NON_CACHED)); assertEquals(null, b.getPropertyCache().get(NON_CACHED)); assertEquals(null, c.getPropertyCache().get(NON_CACHED)); assertEquals(null, a.getPropertyCache().get(CACHED)); assertEquals(null, b.getPropertyCache().get(CACHED)); assertEquals(null, c.getPropertyCache().get(CACHED)); assertEquals(Sets.newHashSet(), a.getPropertyCache().keySet()); assertEquals(Sets.newHashSet(), b.getPropertyCache().keySet()); assertEquals(Sets.newHashSet(), c.getPropertyCache().keySet()); graph.shutdown(); }
Example 10
Source File: ElementPropertyCachingTest.java From AccumuloGraph with Apache License 2.0 | 4 votes |
@Test public void testSpecificCaching() { AccumuloGraphConfiguration cfg = AccumuloGraphTestUtils.generateGraphConfig("getProperty"); cfg.setPropertyCacheTimeout(CACHED, TIMEOUT); assertTrue(cfg.getPropertyCacheTimeout(null) <= 0); assertTrue(cfg.getPropertyCacheTimeout(NON_CACHED) <= 0); assertEquals(TIMEOUT, cfg.getPropertyCacheTimeout(CACHED)); Graph graph = open(cfg); load(graph); AccumuloVertex a = (AccumuloVertex) graph.getVertex("A"); AccumuloVertex b = (AccumuloVertex) graph.getVertex("B"); AccumuloVertex c = (AccumuloVertex) graph.getVertex("C"); assertEquals(null, a.getProperty(NON_CACHED)); assertEquals(true, b.getProperty(NON_CACHED)); assertEquals(null, c.getProperty(NON_CACHED)); assertEquals(null, a.getProperty(CACHED)); assertEquals(null, b.getProperty(CACHED)); assertEquals(true, c.getProperty(CACHED)); assertEquals(null, a.getPropertyCache().get(NON_CACHED)); assertEquals(null, b.getPropertyCache().get(NON_CACHED)); assertEquals(null, c.getPropertyCache().get(NON_CACHED)); assertEquals(null, a.getPropertyCache().get(CACHED)); assertEquals(null, b.getPropertyCache().get(CACHED)); assertEquals(true, c.getPropertyCache().get(CACHED)); assertEquals(Sets.newHashSet(), a.getPropertyCache().keySet()); assertEquals(Sets.newHashSet(), b.getPropertyCache().keySet()); assertEquals(Sets.newHashSet(CACHED), c.getPropertyCache().keySet()); a.removeProperty(NON_CACHED); b.removeProperty(NON_CACHED); c.removeProperty(NON_CACHED); a.removeProperty(CACHED); b.removeProperty(CACHED); c.removeProperty(CACHED); assertEquals(null, a.getProperty(NON_CACHED)); assertEquals(null, b.getProperty(NON_CACHED)); assertEquals(null, c.getProperty(NON_CACHED)); assertEquals(null, a.getProperty(CACHED)); assertEquals(null, b.getProperty(CACHED)); assertEquals(null, c.getProperty(CACHED)); assertEquals(null, a.getPropertyCache().get(NON_CACHED)); assertEquals(null, b.getPropertyCache().get(NON_CACHED)); assertEquals(null, c.getPropertyCache().get(NON_CACHED)); assertEquals(null, a.getPropertyCache().get(CACHED)); assertEquals(null, b.getPropertyCache().get(CACHED)); assertEquals(null, c.getPropertyCache().get(CACHED)); assertEquals(Sets.newHashSet(), a.getPropertyCache().keySet()); assertEquals(Sets.newHashSet(), b.getPropertyCache().keySet()); assertEquals(Sets.newHashSet(), c.getPropertyCache().keySet()); graph.shutdown(); }
Example 11
Source File: ElementPropertyCachingTest.java From AccumuloGraph with Apache License 2.0 | 4 votes |
@Test public void testAllCaching() { AccumuloGraphConfiguration cfg = AccumuloGraphTestUtils.generateGraphConfig("setProperty"); cfg.setPropertyCacheTimeout(null, TIMEOUT); cfg.setPropertyCacheTimeout(CACHED, TIMEOUT); assertEquals(TIMEOUT, cfg.getPropertyCacheTimeout(null)); assertEquals(TIMEOUT, cfg.getPropertyCacheTimeout(NON_CACHED)); assertEquals(TIMEOUT, cfg.getPropertyCacheTimeout(CACHED)); Graph graph = open(cfg); load(graph); AccumuloVertex a = (AccumuloVertex) graph.getVertex("A"); AccumuloVertex b = (AccumuloVertex) graph.getVertex("B"); AccumuloVertex c = (AccumuloVertex) graph.getVertex("C"); assertEquals(null, a.getProperty(NON_CACHED)); assertEquals(true, b.getProperty(NON_CACHED)); assertEquals(null, c.getProperty(NON_CACHED)); assertEquals(null, a.getProperty(CACHED)); assertEquals(null, b.getProperty(CACHED)); assertEquals(true, c.getProperty(CACHED)); assertEquals(null, a.getPropertyCache().get(NON_CACHED)); assertEquals(true, b.getPropertyCache().get(NON_CACHED)); assertEquals(null, c.getPropertyCache().get(NON_CACHED)); assertEquals(null, a.getPropertyCache().get(CACHED)); assertEquals(null, b.getPropertyCache().get(CACHED)); assertEquals(true, c.getPropertyCache().get(CACHED)); assertEquals(Sets.newHashSet(), a.getPropertyCache().keySet()); assertEquals(Sets.newHashSet(NON_CACHED), b.getPropertyCache().keySet()); assertEquals(Sets.newHashSet(CACHED), c.getPropertyCache().keySet()); a.removeProperty(NON_CACHED); b.removeProperty(NON_CACHED); c.removeProperty(NON_CACHED); a.removeProperty(CACHED); b.removeProperty(CACHED); c.removeProperty(CACHED); assertEquals(null, a.getProperty(NON_CACHED)); assertEquals(null, b.getProperty(NON_CACHED)); assertEquals(null, c.getProperty(NON_CACHED)); assertEquals(null, a.getProperty(CACHED)); assertEquals(null, b.getProperty(CACHED)); assertEquals(null, c.getProperty(CACHED)); assertEquals(null, a.getPropertyCache().get(NON_CACHED)); assertEquals(null, b.getPropertyCache().get(NON_CACHED)); assertEquals(null, c.getPropertyCache().get(NON_CACHED)); assertEquals(null, a.getPropertyCache().get(CACHED)); assertEquals(null, b.getPropertyCache().get(CACHED)); assertEquals(null, c.getPropertyCache().get(CACHED)); assertEquals(Sets.newHashSet(), a.getPropertyCache().keySet()); assertEquals(Sets.newHashSet(), b.getPropertyCache().keySet()); assertEquals(Sets.newHashSet(), c.getPropertyCache().keySet()); graph.shutdown(); }