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))));
}
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);
}
Aggregations