Search in sources :

Example 6 with Service

use of spark.Service in project grakn by graknlabs.

the class GraknEngineServerTest method createGraknEngineServer.

private GraknEngineServer createGraknEngineServer(RedisWrapper redisWrapper) {
    // grakn engine configuration
    EngineID engineId = EngineID.me();
    GraknEngineStatus status = new GraknEngineStatus();
    MetricRegistry metricRegistry = new MetricRegistry();
    // distributed locks
    LockProvider lockProvider = new JedisLockProvider(redisWrapper.getJedisPool());
    graknKeyspaceStore = GraknKeyspaceStoreFake.of();
    // 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();
    int grpcPort = config.getProperty(GraknConfigKey.GRPC_PORT);
    GrpcOpenRequestExecutor requestExecutor = new GrpcOpenRequestExecutorImpl(engineGraknTxFactory);
    Server server = ServerBuilder.forPort(grpcPort).addService(new GrpcGraknService(requestExecutor, postProcessor)).build();
    GrpcServer grpcServer = GrpcServer.create(server);
    QueueSanityCheck queueSanityCheck = new RedisSanityCheck(redisWrapper);
    return GraknEngineServerFactory.createGraknEngineServer(engineId, config, status, sparkHttp, httpControllers, grpcServer, engineGraknTxFactory, metricRegistry, queueSanityCheck, lockProvider, postProcessor, graknKeyspaceStore);
}
Also used : EngineID(ai.grakn.engine.util.EngineID) RedisServer(ai.grakn.redismock.RedisServer) Server(io.grpc.Server) GrpcServer(ai.grakn.engine.rpc.GrpcServer) GrpcOpenRequestExecutorImpl(ai.grakn.engine.rpc.GrpcOpenRequestExecutorImpl) IndexPostProcessor(ai.grakn.engine.task.postprocessing.IndexPostProcessor) MetricRegistry(com.codahale.metrics.MetricRegistry) EngineGraknTxFactory(ai.grakn.engine.factory.EngineGraknTxFactory) GrpcOpenRequestExecutor(ai.grakn.grpc.GrpcOpenRequestExecutor) GrpcGraknService(ai.grakn.engine.rpc.GrpcGraknService) Service(spark.Service) GrpcServer(ai.grakn.engine.rpc.GrpcServer) CountPostProcessor(ai.grakn.engine.task.postprocessing.CountPostProcessor) HttpController(ai.grakn.engine.controller.HttpController) JedisLockProvider(ai.grakn.engine.lock.JedisLockProvider) LockProvider(ai.grakn.engine.lock.LockProvider) JedisLockProvider(ai.grakn.engine.lock.JedisLockProvider) IndexStorage(ai.grakn.engine.task.postprocessing.IndexStorage) RedisIndexStorage(ai.grakn.engine.task.postprocessing.redisstorage.RedisIndexStorage) QueueSanityCheck(ai.grakn.engine.data.QueueSanityCheck) CountStorage(ai.grakn.engine.task.postprocessing.CountStorage) RedisCountStorage(ai.grakn.engine.task.postprocessing.redisstorage.RedisCountStorage) RedisSanityCheck(ai.grakn.engine.data.RedisSanityCheck) IndexPostProcessor(ai.grakn.engine.task.postprocessing.IndexPostProcessor) CountPostProcessor(ai.grakn.engine.task.postprocessing.CountPostProcessor) PostProcessor(ai.grakn.engine.task.postprocessing.PostProcessor) GrpcGraknService(ai.grakn.engine.rpc.GrpcGraknService)

Aggregations

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