public void verifyStoreMetrics(String storeName, Map<String, Long> operationCounts) { verifyStoreMetrics(storeName, metricsPrefix, operationCounts); }
public void verifyStoreMetrics(String storeName) { verifyStoreMetrics(storeName, new HashMap<String, Long>(0)); }
private void verifyLockingOverwrite(String storeName, long num) { if (storeUsesConsistentKeyLocker()) { verifyStoreMetrics(storeName, ImmutableMap.of(M_GET_SLICE, 2*num)); verifyStoreMetrics(storeName+LOCK_STORE_SUFFIX, ImmutableMap.of(M_GET_SLICE, num, M_MUTATE, 2*num)); } else { verifyStoreMetrics(storeName, ImmutableMap.of(M_GET_SLICE, num, M_ACQUIRE_LOCK, num)); } }
@Test public void testIdCounts() { makeVertexIndexedUniqueKey("uid", Integer.class); mgmt.setConsistency(mgmt.getGraphIndex("uid"), ConsistencyModifier.LOCK); finishSchema(); //Schema and relation id pools are tapped, Schema id pool twice because the renew is triggered. Each id acquisition requires 1 mutations and 2 reads verifyStoreMetrics(ID_STORE_NAME, SYSTEM_METRICS, ImmutableMap.of(M_MUTATE, 3l, M_GET_SLICE, 6l)); }
public void checkFastProperty(boolean fastProperty) { makeKey("uid",String.class); makeKey("name", String.class); makeKey("age", String.class); finishSchema(); clopen(option(GraphDatabaseConfiguration.PROPERTY_PREFETCHING), fastProperty); metricsPrefix = "checkFastProperty"+fastProperty; TitanTransaction tx = graph.buildTransaction().groupName(metricsPrefix).start(); TitanVertex v = tx.addVertex("uid", "v1", "age", 25, "name", "john"); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME); verifyStoreMetrics(INDEXSTORE_NAME); verifyStoreMetrics(METRICS_STOREMANAGER_NAME, ImmutableMap.of(M_MUTATE, 1l)); tx = graph.buildTransaction().groupName(metricsPrefix).start(); v = getV(tx, v); assertEquals("v1",v.property("uid").value()); assertEquals("25",v.property("age").value()); assertEquals("john",v.property("name").value()); tx.commit(); if (fastProperty) verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 2l)); else verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 4l)); verifyStoreMetrics(INDEXSTORE_NAME); verifyStoreMetrics(METRICS_STOREMANAGER_NAME, ImmutableMap.of(M_MUTATE, 1l)); }
verifyStoreMetrics(EDGESTORE_NAME); verifyStoreMetrics(INDEXSTORE_NAME); verifyStoreMetrics(METRICS_STOREMANAGER_NAME, ImmutableMap.of(M_MUTATE, 1l)); assertEquals(1, Iterators.size(v.properties())); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 2l)); verifyStoreMetrics(INDEXSTORE_NAME); verifyStoreMetrics(METRICS_STOREMANAGER_NAME, ImmutableMap.of(M_MUTATE, 2l)); verifyStoreMetrics(ID_STORE_NAME);
@Test public void checkPropertyLockingAndIndex() { PropertyKey uid = makeKey("uid",String.class); TitanGraphIndex index = mgmt.buildIndex("uid",Vertex.class).unique().addKey(uid).buildCompositeIndex(); mgmt.setConsistency(index, ConsistencyModifier.LOCK); mgmt.makePropertyKey("name").dataType(String.class).make(); mgmt.makePropertyKey("age").dataType(Integer.class).make(); finishSchema(); metricsPrefix = "checkPropertyLockingAndIndex"; TitanTransaction tx = graph.buildTransaction().groupName(metricsPrefix).start(); TitanVertex v = tx.addVertex("uid", "v1", "age", 25, "name", "john"); assertEquals(25,v.property("age").value()); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME); verifyLockingOverwrite(INDEXSTORE_NAME, 1); verifyStoreMetrics(METRICS_STOREMANAGER_NAME, ImmutableMap.of(M_MUTATE, 1l)); resetMetrics(); tx = graph.buildTransaction().groupName(metricsPrefix).start(); v = Iterables.getOnlyElement(tx.query().has("uid", Cmp.EQUAL, "v1").vertices()); assertEquals(25,v.property("age").value()); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE,1l)); verifyStoreMetrics(INDEXSTORE_NAME, ImmutableMap.of(M_GET_SLICE,1l)); verifyStoreMetrics(METRICS_STOREMANAGER_NAME); }
v.addEdge("knows", u); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME); verifyLockingOverwrite(INDEXSTORE_NAME, 3); verifyStoreMetrics(METRICS_STOREMANAGER_NAME, ImmutableMap.of(M_MUTATE, 1l + (features.hasTxIsolation()?0:1))); v = getV(tx,v); assertCount(2, v.properties()); verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 2l)); //1 verify vertex existence, 1 for query verifyTypeCacheMetrics(3, 4); tx.commit(); v = getV(tx,v); assertCount(2, v.properties()); verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 4l)); //1 verify vertex existence, 1 for query verifyTypeCacheMetrics(3, 4); tx.commit(); assertNotNull(v.value("age")); assertNotNull(v.value("name")); verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 7l)); //1 verify vertex existence, 2 for query verifyTypeCacheMetrics(5, 8); tx.commit(); assertNotNull(v.value("name")); assertCount(1, v.query().direction(Direction.BOTH).edges()); verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 11l)); //1 verify vertex existence, 3 for query verifyTypeCacheMetrics(5, 10); tx.commit();
tx.makeVertexLabel("person").make(); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME); verifyLockingOverwrite(INDEXSTORE_NAME, 3); verifyStoreMetrics(METRICS_STOREMANAGER_NAME, ImmutableMap.of(M_MUTATE, 1l)); verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 19l)); verifyStoreMetrics(INDEXSTORE_NAME, e.property("name", "edge"); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME); verifyLockingOverwrite(INDEXSTORE_NAME, 1); tx.commit(); if (!cache || i==0) { verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 4l)); verifyStoreMetrics(INDEXSTORE_NAME, ImmutableMap.of(M_GET_SLICE, 1l)); } else if (cache && i>20) { //Needs a couple of iterations for cache to be cleaned verifyStoreMetrics(EDGESTORE_NAME); verifyStoreMetrics(INDEXSTORE_NAME);
public void verifyStoreMetrics(String storeName, Map<String, Long> operationCounts) { verifyStoreMetrics(storeName, metricsPrefix, operationCounts); }
public void verifyStoreMetrics(String storeName) { verifyStoreMetrics(storeName, new HashMap<String, Long>(0)); }
verifyStoreMetrics(STORE_NAMES.get(3), SYSTEM_METRICS, ImmutableMap.of(M_MUTATE, 2l, M_GET_SLICE, 4l)); ElementHelper.setProperties(v, "age", 25, "name", "john"); TitanVertex u = tx.addVertex(); verifyStoreMetrics(STORE_NAMES.get(0), ImmutableMap.of(M_MUTATE, 8l)); verifyStoreMetrics(STORE_NAMES.get(1), ImmutableMap.of(M_GET_SLICE, 3l, M_MUTATE, 6l, M_ACQUIRE_LOCK, 3l)); verifyStoreMetrics(STORE_NAMES.get(2)); Thread.sleep(500); verifyStoreMetrics(STORE_NAMES.get(3), SYSTEM_METRICS, ImmutableMap.of(M_MUTATE, 4l, M_GET_SLICE, 8l)); verifyTypeCacheMetrics(3, 3, 0, 0); v = tx.getVertex(v.getLongId()); assertEquals(2,Iterables.size(v.getProperties())); verifyStoreMetrics(STORE_NAMES.get(0), ImmutableMap.of(M_MUTATE, 8l, M_GET_SLICE, 4l)); //1 verify vertex existence, 1 for query, 1 for each of the 2 types (Definition) verifyStoreMetrics(STORE_NAMES.get(1), ImmutableMap.of(M_GET_SLICE, 3l, M_MUTATE, 6l, M_ACQUIRE_LOCK, 3l)); verifyStoreMetrics(STORE_NAMES.get(2)); verifyStoreMetrics(STORE_NAMES.get(3), SYSTEM_METRICS, ImmutableMap.of(M_MUTATE, 4l, M_GET_SLICE, 8l)); verifyTypeCacheMetrics(3, 3, 2, 2); tx.commit(); v = tx.getVertex(v.getLongId()); assertEquals(2, Iterables.size(v.getProperties())); verifyStoreMetrics(STORE_NAMES.get(0), ImmutableMap.of(M_MUTATE, 8l, M_GET_SLICE, 6l)); verifyStoreMetrics(STORE_NAMES.get(1), ImmutableMap.of(M_GET_SLICE, 3l, M_MUTATE, 6l, M_ACQUIRE_LOCK, 3l)); verifyStoreMetrics(STORE_NAMES.get(2)); verifyStoreMetrics(STORE_NAMES.get(3), SYSTEM_METRICS, ImmutableMap.of(M_MUTATE, 4l, M_GET_SLICE, 8l)); verifyTypeCacheMetrics(3, 3, 4, 2); tx.commit();
@Test public void testIdCounts() { makeVertexIndexedUniqueKey("uid",Integer.class); mgmt.setConsistency(mgmt.getGraphIndex("uid"),ConsistencyModifier.LOCK); finishSchema(); //Schema and relation id pools are tapped, Schema id pool twice because the renew is triggered. Each id acquisition requires 1 mutations and 2 reads verifyStoreMetrics(ID_STORE_NAME, SYSTEM_METRICS, ImmutableMap.of(M_MUTATE, 3l, M_GET_SLICE, 6l)); }
tx.commit(); if (storeUsesConsistentKeyLocker()) verifyStoreMetrics(STORE_NAMES.get(1)); else verifyStoreMetrics(STORE_NAMES.get(0)); verifyStoreMetrics(STORE_NAMES.get(1)); verifyStoreMetrics(STORE_NAMES.get(2)); verifyStoreMetrics(STORE_NAMES.get(3), ImmutableMap.of(M_MUTATE, 1l)); assertEquals(1, Iterables.size(v.getProperties())); tx.commit(); verifyStoreMetrics(STORE_NAMES.get(0), ImmutableMap.of(M_GET_SLICE, 2l)); verifyStoreMetrics(STORE_NAMES.get(1)); verifyStoreMetrics(STORE_NAMES.get(2)); verifyStoreMetrics(STORE_NAMES.get(3), ImmutableMap.of(M_MUTATE, 2l));
verifyStoreMetrics("edgeStore", ImmutableMap.of(M_MUTATE, 8l)); verifyStoreMetrics("vertexIndexStore", ImmutableMap.of(M_GET_SLICE, 3l, M_MUTATE, 6l, M_ACQUIRE_LOCK, 3l)); verifyTypeCacheMetrics(3, 3, 0, 0); assertEquals(3,Iterables.size(tx.getVertex(parentVertex.getLongId()).getProperties())); tx.commit(); verifyStoreMetrics("edgeStore", ImmutableMap.of(M_MUTATE, 8l, M_GET_SLICE, 5l)); verifyStoreMetrics("vertexIndexStore", ImmutableMap.of(M_GET_SLICE, 3l, M_MUTATE, 6l, M_ACQUIRE_LOCK, 3l)); verifyTypeCacheMetrics(3, 3, 3, 3); verifyStoreMetrics("edgeStore", ImmutableMap.of(M_MUTATE, 8l, M_GET_SLICE, 7l)); verifyStoreMetrics("vertexIndexStore", ImmutableMap.of(M_GET_SLICE, 3l, M_MUTATE, 6l, M_ACQUIRE_LOCK, 3l)); verifyTypeCacheMetrics(3, 3, 6, 3);
ElementHelper.setProperties(v, "uid", "v1", "age", 25, "name", "john"); tx.commit(); verifyStoreMetrics(STORE_NAMES.get(0), ImmutableMap.of(M_MUTATE, 7l)); verifyStoreMetrics(STORE_NAMES.get(1), ImmutableMap.of(M_GET_SLICE, 4l, M_MUTATE, 7l, M_ACQUIRE_LOCK, 3l)); verifyTypeCacheMetrics(0, 0, 0, 0); tx.commit(); if (fastProperty) verifyStoreMetrics(STORE_NAMES.get(0), ImmutableMap.of(M_MUTATE, 8l, M_GET_SLICE, 7l)); else verifyStoreMetrics(STORE_NAMES.get(0), ImmutableMap.of(M_MUTATE, 8l, M_GET_SLICE, 7l)); verifyStoreMetrics(STORE_NAMES.get(1), ImmutableMap.of(M_GET_SLICE, 6l, M_MUTATE, 7l, M_ACQUIRE_LOCK, 4l)); if (fastProperty) verifyTypeCacheMetrics(6, 2, 5, 5); tx.commit(); if (fastProperty) verifyStoreMetrics(STORE_NAMES.get(0), ImmutableMap.of(M_MUTATE, 9l, M_GET_SLICE, 9l)); else verifyStoreMetrics(STORE_NAMES.get(0), ImmutableMap.of(M_MUTATE, 9l, M_GET_SLICE, 10l)); verifyStoreMetrics(STORE_NAMES.get(1), ImmutableMap.of(M_GET_SLICE, 6l, M_MUTATE, 7l, M_ACQUIRE_LOCK, 4l)); if (fastProperty) { verifyTypeCacheMetrics(12, 2, 10, 5); verifyStoreMetrics(STORE_NAMES.get(1), ImmutableMap.of(M_GET_SLICE, 6l, M_MUTATE, 7l, M_ACQUIRE_LOCK, 4l));
tx.makeVertexLabel("person").make(); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME); if (storeUsesConsistentKeyLocker()) verifyStoreMetrics(INDEXSTORE_NAME, ImmutableMap.of(M_GET_SLICE, 6l, M_ACQUIRE_LOCK, 0l)); else verifyStoreMetrics(INDEXSTORE_NAME, ImmutableMap.of(M_GET_SLICE, 3l, M_ACQUIRE_LOCK, 3l)); verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 19l)); verifyStoreMetrics(INDEXSTORE_NAME, e.setProperty("name","edge"); tx.commit(); verifyStoreMetrics(EDGESTORE_NAME); if (storeUsesConsistentKeyLocker()) verifyStoreMetrics(INDEXSTORE_NAME, ImmutableMap.of(M_GET_SLICE, 2L, M_ACQUIRE_LOCK, 0L)); else verifyStoreMetrics(INDEXSTORE_NAME, ImmutableMap.of(M_GET_SLICE, 1l, M_ACQUIRE_LOCK, 1l)); tx.commit(); if (!cache || i==0) { verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE, 4l)); verifyStoreMetrics(INDEXSTORE_NAME, ImmutableMap.of(M_GET_SLICE, 1l)); } else if (cache && i>20) { //Needs a couple of iterations for cache to be cleaned verifyStoreMetrics(EDGESTORE_NAME); verifyStoreMetrics(INDEXSTORE_NAME);