Search in sources :

Example 1 with RedisCountStorage

use of ai.grakn.engine.task.postprocessing.redisstorage.RedisCountStorage in project grakn by graknlabs.

the class PostProcessingTest method whenUpdatingInstanceCounts_EnsureRedisIsUpdated.

@Test
public void whenUpdatingInstanceCounts_EnsureRedisIsUpdated() throws InterruptedException {
    RedisCountStorage redis = engine.redis();
    Keyspace keyspace = SampleKBLoader.randomKeyspace();
    String entityType1 = "e1";
    String entityType2 = "e2";
    // Create Artificial configuration
    createAndUploadCountCommitLog(keyspace, ConceptId.of(entityType1), 6L);
    createAndUploadCountCommitLog(keyspace, ConceptId.of(entityType2), 3L);
    // Check cache in redis has been updated
    assertEquals(6L, redis.getCount(RedisCountStorage.getKeyNumInstances(keyspace, ConceptId.of(entityType1))));
    assertEquals(3L, redis.getCount(RedisCountStorage.getKeyNumInstances(keyspace, ConceptId.of(entityType2))));
    // Create Artificial configuration
    createAndUploadCountCommitLog(keyspace, ConceptId.of(entityType1), 1L);
    createAndUploadCountCommitLog(keyspace, ConceptId.of(entityType2), -1L);
    // Check cache in redis has been updated
    assertEquals(7L, redis.getCount(RedisCountStorage.getKeyNumInstances(keyspace, ConceptId.of(entityType1))));
    assertEquals(2L, redis.getCount(RedisCountStorage.getKeyNumInstances(keyspace, ConceptId.of(entityType2))));
}
Also used : RedisCountStorage(ai.grakn.engine.task.postprocessing.redisstorage.RedisCountStorage) Keyspace(ai.grakn.Keyspace) Test(org.junit.Test)

Example 2 with RedisCountStorage

use of ai.grakn.engine.task.postprocessing.redisstorage.RedisCountStorage in project grakn by graknlabs.

the class PostProcessingTest method setupPostProcessor.

@Before
public void setupPostProcessor() {
    MetricRegistry metricRegistry = new MetricRegistry();
    RedisIndexStorage indexStorage = RedisIndexStorage.create(engine.getJedisPool(), metricRegistry);
    IndexPostProcessor indexPostProcessor = IndexPostProcessor.create(engine.server().lockProvider(), indexStorage);
    RedisCountStorage countStorage = RedisCountStorage.create(engine.getJedisPool(), metricRegistry);
    CountPostProcessor countPostProcessor = CountPostProcessor.create(engine.config(), engine.factory(), engine.server().lockProvider(), metricRegistry, countStorage);
    session = engine.sessionWithNewKeyspace();
    postProcessor = PostProcessor.create(indexPostProcessor, countPostProcessor);
}
Also used : RedisIndexStorage(ai.grakn.engine.task.postprocessing.redisstorage.RedisIndexStorage) IndexPostProcessor(ai.grakn.engine.task.postprocessing.IndexPostProcessor) MetricRegistry(com.codahale.metrics.MetricRegistry) RedisCountStorage(ai.grakn.engine.task.postprocessing.redisstorage.RedisCountStorage) CountPostProcessor(ai.grakn.engine.task.postprocessing.CountPostProcessor) Before(org.junit.Before)

Aggregations

RedisCountStorage (ai.grakn.engine.task.postprocessing.redisstorage.RedisCountStorage)2 Keyspace (ai.grakn.Keyspace)1 CountPostProcessor (ai.grakn.engine.task.postprocessing.CountPostProcessor)1 IndexPostProcessor (ai.grakn.engine.task.postprocessing.IndexPostProcessor)1 RedisIndexStorage (ai.grakn.engine.task.postprocessing.redisstorage.RedisIndexStorage)1 MetricRegistry (com.codahale.metrics.MetricRegistry)1 Before (org.junit.Before)1 Test (org.junit.Test)1