@Test public void testVLabelOnOrderedStorage() { final String label = "pl"; mgmt.makeVertexLabel(label).partition().make(); mgmt.commit(); graph.tx().rollback(); graph.addVertex(label); graph.tx().commit(); mgmt = graph.openManagement(); VertexLabel vl = mgmt.getVertexLabel(label); assertTrue(vl.isPartitioned()); mgmt.rollback(); }
@Test public void testPartitionedVertexScan() throws Exception { tearDown(); clearGraph(getConfiguration()); WriteConfiguration partConf = getConfiguration(); open(partConf); mgmt.makeVertexLabel("part").partition().make(); finishSchema(); TitanVertex supernode = graph.addVertex("part"); for (int i = 0; i < 128; i++) { TitanVertex v = graph.addVertex("part"); v.addEdge("default", supernode); if (0 < i && 0 == i % 4) graph.tx().commit(); } graph.tx().commit(); org.apache.hadoop.conf.Configuration c = new org.apache.hadoop.conf.Configuration(); c.set(ConfigElement.getPath(TitanHadoopConfiguration.GRAPH_CONFIG_KEYS, true) + "." + "storage.cassandra.keyspace", getClass().getSimpleName()); c.set(ConfigElement.getPath(TitanHadoopConfiguration.GRAPH_CONFIG_KEYS, true) + "." + "storage.backend", "cassandrathrift"); c.set("cassandra.input.partitioner.class", "org.apache.cassandra.dht.Murmur3Partitioner"); Job job = getVertexJobWithDefaultMapper(c); // Should throw an exception since filter-partitioned-vertices wasn't enabled assertFalse(job.waitForCompletion(true)); }
@Test public void testPartitionedVertexFilteredScan() throws Exception { tearDown(); clearGraph(getConfiguration()); WriteConfiguration partConf = getConfiguration(); open(partConf); mgmt.makeVertexLabel("part").partition().make(); finishSchema(); TitanVertex supernode = graph.addVertex("part"); for (int i = 0; i < 128; i++) { TitanVertex v = graph.addVertex("part"); v.addEdge("default", supernode); if (0 < i && 0 == i % 4) graph.tx().commit(); } graph.tx().commit(); org.apache.hadoop.conf.Configuration c = new org.apache.hadoop.conf.Configuration(); c.set(ConfigElement.getPath(TitanHadoopConfiguration.GRAPH_CONFIG_KEYS, true) + "." + "storage.cassandra.keyspace", getClass().getSimpleName()); c.set(ConfigElement.getPath(TitanHadoopConfiguration.GRAPH_CONFIG_KEYS, true) + "." + "storage.backend", "cassandrathrift"); c.set(ConfigElement.getPath(TitanHadoopConfiguration.FILTER_PARTITIONED_VERTICES), "true"); c.set("cassandra.input.partitioner.class", "org.apache.cassandra.dht.Murmur3Partitioner"); Job job = getVertexJobWithDefaultMapper(c); // Should succeed assertTrue(job.waitForCompletion(true)); }
private int setupGroupClusters(int[] groupDegrees, CommitMode commitMode) { mgmt.makeVertexLabel("person").make(); mgmt.makeVertexLabel("group").partition().make(); makeVertexIndexedKey("groupid", String.class); makeKey("name", String.class); makeKey("clusterId",String.class); makeLabel("member"); makeLabel("contain"); finishSchema(); int numVertices = 0; TitanVertex[] groups = new TitanVertex[groupDegrees.length]; for (int i = 0; i < groupDegrees.length; i++) { groups[i]=tx.addVertex("group"); groups[i].property("groupid","group"+i); numVertices++; if (commitMode==CommitMode.PER_VERTEX) newTx(); for (int noEdges = 0; noEdges < groupDegrees[i]; noEdges++) { TitanVertex g = vInTx(groups[i],tx); TitanVertex p = tx.addVertex("name","person"+i+":"+noEdges,"clusterId","group"+i); numVertices++; p.addEdge("member",g); g.addEdge("contain", p); if (commitMode==CommitMode.PER_VERTEX) newTx(); } if (commitMode==CommitMode.PER_CLUSTER) newTx(); } newTx(); return numVertices; }
VertexLabel group = mgmt.makeVertexLabel("group").partition().make();
@Test @Category({ UnorderedKeyStoreTests.class }) public void testVLabelOnUnorderedStorage() { final String label = "pl"; VertexLabelMaker maker = mgmt.makeVertexLabel(label); try { // Exception should be thrown in one of these two methods maker.partition().make(); fail("Partitioned label must be rejected on unordered key stores"); } catch (IllegalArgumentException e) { log.debug("Caught expected exception", e); } }
@Test @Category({ OrderedKeyStoreTests.class }) public void testVLabelOnOrderedStorage() { final String label = "pl"; mgmt.makeVertexLabel(label).partition().make(); mgmt.commit(); graph.rollback(); graph.addVertexWithLabel(label); graph.commit(); mgmt = graph.getManagementSystem(); VertexLabel vl = mgmt.getVertexLabel(label); assertTrue(vl.isPartitioned()); mgmt.rollback(); }
VertexLabel group = mgmt.makeVertexLabel("group").partition().make();