Search in sources :

Example 1 with GraknEngineServer

use of ai.grakn.engine.GraknEngineServer 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;
}
Also used : GraknSystemKeyspaceSession(ai.grakn.engine.GraknSystemKeyspaceSession) EngineID(ai.grakn.engine.util.EngineID) GraknEngineServer(ai.grakn.engine.GraknEngineServer) 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) GrpcOpenRequestExecutor(ai.grakn.grpc.GrpcOpenRequestExecutor) GraknEngineServer(ai.grakn.engine.GraknEngineServer) GrpcServer(ai.grakn.engine.rpc.GrpcServer) GraknEngineStatus(ai.grakn.engine.GraknEngineStatus) CountPostProcessor(ai.grakn.engine.task.postprocessing.CountPostProcessor) 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)

Example 2 with GraknEngineServer

use of ai.grakn.engine.GraknEngineServer in project grakn by graknlabs.

the class Grakn method main.

/**
 * Invocation from class 'GraknProcess' in grakn-dist project
 *
 * @param args
 */
public static void main(String[] args) {
    Thread.setDefaultUncaughtExceptionHandler(newUncaughtExceptionHandler(LOG));
    try {
        String graknPidFileProperty = Optional.ofNullable(GraknSystemProperty.GRAKN_PID_FILE.value()).orElseThrow(() -> new RuntimeException(ErrorMessage.GRAKN_PIDFILE_SYSTEM_PROPERTY_UNDEFINED.getMessage()));
        Path pidfile = Paths.get(graknPidFileProperty);
        GraknPidManager graknPidManager = GraknPidManagerFactory.newGraknPidManagerForUnixOS(pidfile);
        graknPidManager.trackGraknPid();
        // Start Engine
        GraknEngineServer graknEngineServer = GraknEngineServerFactory.createGraknEngineServer();
        graknEngineServer.start();
    } catch (IOException e) {
        LOG.error(ErrorMessage.UNCAUGHT_EXCEPTION.getMessage(), e);
    }
}
Also used : Path(java.nio.file.Path) GraknEngineServer(ai.grakn.engine.GraknEngineServer) IOException(java.io.IOException) GraknPidManager(ai.grakn.bootup.graknengine.pid.GraknPidManager)

Aggregations

GraknEngineServer (ai.grakn.engine.GraknEngineServer)2 GraknPidManager (ai.grakn.bootup.graknengine.pid.GraknPidManager)1 GraknEngineStatus (ai.grakn.engine.GraknEngineStatus)1 GraknSystemKeyspaceSession (ai.grakn.engine.GraknSystemKeyspaceSession)1 QueueSanityCheck (ai.grakn.engine.data.QueueSanityCheck)1 RedisSanityCheck (ai.grakn.engine.data.RedisSanityCheck)1 JedisLockProvider (ai.grakn.engine.lock.JedisLockProvider)1 LockProvider (ai.grakn.engine.lock.LockProvider)1 GrpcGraknService (ai.grakn.engine.rpc.GrpcGraknService)1 GrpcOpenRequestExecutorImpl (ai.grakn.engine.rpc.GrpcOpenRequestExecutorImpl)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 GrpcOpenRequestExecutor (ai.grakn.grpc.GrpcOpenRequestExecutor)1