use of ai.grakn.engine.GraknSystemKeyspaceSession in project grakn by graknlabs.
the class EngineContext method startGraknEngineServer.
private GraknEngineServer startGraknEngineServer(RedisWrapper redisWrapper) throws IOException {
EngineID id = EngineID.me();
GraknEngineStatus status = new GraknEngineStatus();
MetricRegistry metricRegistry = new MetricRegistry();
// distributed locks
LockProvider lockProvider = new JedisLockProvider(redisWrapper.getJedisPool());
graknKeyspaceStore = GraknKeyspaceStoreImpl.create(new GraknSystemKeyspaceSession(config));
// tx-factory
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);
GrpcOpenRequestExecutor requestExecutor = new GrpcOpenRequestExecutorImpl(engineGraknTxFactory);
Server server = ServerBuilder.forPort(0).addService(new GrpcGraknService(requestExecutor, postProcessor)).build();
GrpcServer grpcServer = GrpcServer.create(server);
GraknTestUtil.allocateSparkPort(config);
QueueSanityCheck queueSanityCheck = new RedisSanityCheck(redisWrapper);
GraknEngineServer graknEngineServer = GraknEngineServerFactory.createGraknEngineServer(id, config, status, spark, Collections.emptyList(), grpcServer, engineGraknTxFactory, metricRegistry, queueSanityCheck, lockProvider, postProcessor, graknKeyspaceStore);
graknEngineServer.start();
// Read the automatically allocated ports and write them back into the config
config.setConfigProperty(GraknConfigKey.GRPC_PORT, server.getPort());
return graknEngineServer;
}
Aggregations