Search in sources :

Example 1 with RedisWrapper

use of ai.grakn.engine.data.RedisWrapper in project grakn by graknlabs.

the class EngineContext method before.

@Override
protected final void before() throws Throwable {
    RestAssured.baseURI = uri().toURI().toString();
    if (!config.getProperty(GraknConfigKey.TEST_START_EMBEDDED_COMPONENTS)) {
        return;
    }
    SimpleURI redisURI = new SimpleURI(Iterables.getOnlyElement(config.getProperty(GraknConfigKey.REDIS_HOST)));
    jedisPool = new JedisPool(redisURI.getHost(), redisURI.getPort());
    // To ensure consistency b/w test profiles and configuration files, when not using Janus
    // for a unit tests in an IDE, add the following option:
    // -Dgrakn.conf=../conf/test/tinker/grakn.properties
    // 
    // When using janus, add -Dgrakn.test-profile=janus
    // 
    // The reason is that the default configuration of Grakn uses the Janus Factory while the default
    // test profile is tinker: so when running a unit test within an IDE without any extra parameters,
    // we end up wanting to use the JanusFactory but without starting Cassandra first.
    LOG.info("starting engine...");
    // start engine
    setRestAssuredUri(config);
    spark = Service.ignite();
    config.setConfigProperty(GraknConfigKey.REDIS_HOST, Collections.singletonList("localhost:" + redis.port()));
    RedisWrapper redis = RedisWrapper.create(config);
    server = startGraknEngineServer(redis);
    LOG.info("engine started on " + uri());
}
Also used : RedisWrapper(ai.grakn.engine.data.RedisWrapper) SimpleURI(ai.grakn.util.SimpleURI) JedisPool(redis.clients.jedis.JedisPool)

Example 2 with RedisWrapper

use of ai.grakn.engine.data.RedisWrapper in project grakn by graknlabs.

the class GraknEngineServerFactory method createGraknEngineServer.

/**
 * Create a {@link GraknEngineServer} configured for Grakn Core. Grakn Queue (which is needed for post-processing and distributed locks) is implemented with Redis as the backend store
 *
 * @return a {@link GraknEngineServer} instance configured for Grakn Core
 */
public static GraknEngineServer createGraknEngineServer() {
    // grakn engine configuration
    EngineID engineId = EngineID.me();
    GraknConfig config = GraknConfig.create();
    GraknEngineStatus status = new GraknEngineStatus();
    MetricRegistry metricRegistry = new MetricRegistry();
    // redis
    RedisWrapper redisWrapper = RedisWrapper.create(config);
    QueueSanityCheck queueSanityCheck = new RedisSanityCheck(redisWrapper);
    // distributed locks
    LockProvider lockProvider = new JedisLockProvider(redisWrapper.getJedisPool());
    SystemKeyspaceSession systemKeyspaceSession = new GraknSystemKeyspaceSession(config);
    GraknKeyspaceStore graknKeyspaceStore = GraknKeyspaceStoreImpl.create(systemKeyspaceSession);
    // tx-factory
    EngineGraknTxFactory engineGraknTxFactory = EngineGraknTxFactory.create(lockProvider, config, graknKeyspaceStore);
    // post-processing
    IndexStorage indexStorage = RedisIndexStorage.create(redisWrapper.getJedisPool(), metricRegistry);
    CountStorage countStorage = RedisCountStorage.create(redisWrapper.getJedisPool(), metricRegistry);
    IndexPostProcessor indexPostProcessor = IndexPostProcessor.create(lockProvider, indexStorage);
    CountPostProcessor countPostProcessor = CountPostProcessor.create(config, engineGraknTxFactory, lockProvider, metricRegistry, countStorage);
    PostProcessor postProcessor = PostProcessor.create(indexPostProcessor, countPostProcessor);
    // http services: spark, http controller, and gRPC server
    Service sparkHttp = Service.ignite();
    Collection<HttpController> httpControllers = Collections.emptyList();
    GrpcServer grpcServer = configureGrpcServer(config, engineGraknTxFactory, postProcessor);
    return createGraknEngineServer(engineId, config, status, sparkHttp, httpControllers, grpcServer, engineGraknTxFactory, metricRegistry, queueSanityCheck, lockProvider, postProcessor, graknKeyspaceStore);
}
Also used : EngineID(ai.grakn.engine.util.EngineID) RedisWrapper(ai.grakn.engine.data.RedisWrapper) IndexPostProcessor(ai.grakn.engine.task.postprocessing.IndexPostProcessor) MetricRegistry(com.codahale.metrics.MetricRegistry) EngineGraknTxFactory(ai.grakn.engine.factory.EngineGraknTxFactory) GrpcGraknService(ai.grakn.engine.rpc.GrpcGraknService) Service(spark.Service) GrpcServer(ai.grakn.engine.rpc.GrpcServer) SystemKeyspaceSession(ai.grakn.factory.SystemKeyspaceSession) CountPostProcessor(ai.grakn.engine.task.postprocessing.CountPostProcessor) HttpController(ai.grakn.engine.controller.HttpController) LockProvider(ai.grakn.engine.lock.LockProvider) JedisLockProvider(ai.grakn.engine.lock.JedisLockProvider) JedisLockProvider(ai.grakn.engine.lock.JedisLockProvider) QueueSanityCheck(ai.grakn.engine.data.QueueSanityCheck) IndexStorage(ai.grakn.engine.task.postprocessing.IndexStorage) RedisIndexStorage(ai.grakn.engine.task.postprocessing.redisstorage.RedisIndexStorage) RedisSanityCheck(ai.grakn.engine.data.RedisSanityCheck) CountStorage(ai.grakn.engine.task.postprocessing.CountStorage) RedisCountStorage(ai.grakn.engine.task.postprocessing.redisstorage.RedisCountStorage) CountPostProcessor(ai.grakn.engine.task.postprocessing.CountPostProcessor) PostProcessor(ai.grakn.engine.task.postprocessing.PostProcessor) IndexPostProcessor(ai.grakn.engine.task.postprocessing.IndexPostProcessor)

Aggregations

RedisWrapper (ai.grakn.engine.data.RedisWrapper)2 HttpController (ai.grakn.engine.controller.HttpController)1 QueueSanityCheck (ai.grakn.engine.data.QueueSanityCheck)1 RedisSanityCheck (ai.grakn.engine.data.RedisSanityCheck)1 EngineGraknTxFactory (ai.grakn.engine.factory.EngineGraknTxFactory)1 JedisLockProvider (ai.grakn.engine.lock.JedisLockProvider)1 LockProvider (ai.grakn.engine.lock.LockProvider)1 GrpcGraknService (ai.grakn.engine.rpc.GrpcGraknService)1 GrpcServer (ai.grakn.engine.rpc.GrpcServer)1 CountPostProcessor (ai.grakn.engine.task.postprocessing.CountPostProcessor)1 CountStorage (ai.grakn.engine.task.postprocessing.CountStorage)1 IndexPostProcessor (ai.grakn.engine.task.postprocessing.IndexPostProcessor)1 IndexStorage (ai.grakn.engine.task.postprocessing.IndexStorage)1 PostProcessor (ai.grakn.engine.task.postprocessing.PostProcessor)1 RedisCountStorage (ai.grakn.engine.task.postprocessing.redisstorage.RedisCountStorage)1 RedisIndexStorage (ai.grakn.engine.task.postprocessing.redisstorage.RedisIndexStorage)1 EngineID (ai.grakn.engine.util.EngineID)1 SystemKeyspaceSession (ai.grakn.factory.SystemKeyspaceSession)1 SimpleURI (ai.grakn.util.SimpleURI)1 MetricRegistry (com.codahale.metrics.MetricRegistry)1