/** * Insert an extremely simple graph and start * TASK_COUNT simultaneous readers in an executor with * THREAD_COUNT threads. * * @throws Exception */ @Test public void concurrentReadsOnSingleTransaction() throws Exception { initializeGraph(); PropertyKey id = tx.getPropertyKey("uid"); // Tail many concurrent readers on a single transaction CountDownLatch startLatch = new CountDownLatch(TASK_COUNT); CountDownLatch stopLatch = new CountDownLatch(TASK_COUNT); for (int i = 0; i < TASK_COUNT; i++) { int vertexId = RandomGenerator.randomInt(0, VERTEX_COUNT); EdgeLabel edgeLabel = tx.getEdgeLabel("rel" + RandomGenerator.randomInt(0, REL_COUNT)); executor.execute(new SimpleReader(tx, startLatch, stopLatch, vertexId, edgeLabel.name(), EDGE_COUNT * 2, id.name())); startLatch.countDown(); } stopLatch.await(); }
for (int i = 0; i < TASK_COUNT; i++) { int vertexId = RandomGenerator.randomInt(0, VERTEX_COUNT); EdgeLabel edgeLabel = tx.getEdgeLabel("rel" + RandomGenerator.randomInt(0, REL_COUNT)); executor.execute(new SimpleReader(tx, startLatch, stopLatch, vertexId, edgeLabel.name(), EDGE_COUNT * 2, id.name())); startLatch.countDown();
final EdgeLabel knows1 = tx.getEdgeLabel("knows"); final PropertyKey weight1 = tx.getPropertyKey("weight");
connect = tx.getEdgeLabel("connect"); related = tx.getEdgeLabel("related");
assertTrue(tx.containsVertexLabel("person")); PropertyKey name = tx.getPropertyKey("name"); EdgeLabel knows = tx.getEdgeLabel("knows"); VertexLabel person = tx.getVertexLabel("person"); PropertyKey uid = tx.getPropertyKey("uid");
vs[i] = tx.addVertex("name", "v" + i); EdgeLabel[] labelsV = {tx.getEdgeLabel("connect"), tx.getEdgeLabel("friend"), tx.getEdgeLabel("knows")}; EdgeLabel[] labelsU = {tx.getEdgeLabel("connectDesc"), tx.getEdgeLabel("friendDesc"), tx.getEdgeLabel("knows")}; for (int i = 1; i < noVertices; i++) { for (final JanusGraphVertex vertex : new JanusGraphVertex[]{v, u}) {
Edge e = v.addEdge("knows", v); assertTrue(tx.containsRelationType("knows")); assertNotNull(tx.getEdgeLabel(e.label()));