Search in sources :

Example 1 with JobLifecycle

use of com.accenture.trac.svc.orch.service.JobLifecycle in project tracdap by finos.

the class TracOrchestratorService method doStartup.

@Override
protected void doStartup(Duration startupTimeout) {
    PlatformConfig platformConfig;
    OrchServiceConfig orchestratorConfig;
    try {
        pluginManager.initRegularPlugins();
    } catch (Exception e) {
        var errorMessage = "There was a problem loading the plugins: " + e.getMessage();
        log.error(errorMessage, e);
        throw new EStartup(errorMessage, e);
    }
    try {
        log.info("Loading TRAC platform config...");
        platformConfig = configManager.loadRootConfigObject(PlatformConfig.class);
        orchestratorConfig = platformConfig.getServices().getOrch();
        // TODO: Config validation
        log.info("Config looks ok");
    } catch (Exception e) {
        var errorMessage = "There was a problem loading the platform config: " + e.getMessage();
        log.error(errorMessage, e);
        throw new EStartup(errorMessage, e);
    }
    try {
        var channelType = NioServerSocketChannel.class;
        var clientChannelType = NioSocketChannel.class;
        bossGroup = new NioEventLoopGroup(1, new DefaultThreadFactory("orch-boss"));
        nettyGroup = new NioEventLoopGroup(2, new DefaultThreadFactory("orch-netty"));
        serviceGroup = new NioEventLoopGroup(CONCURRENT_REQUESTS, new DefaultThreadFactory("orch-svc"));
        prepareMetadataClientChannel(platformConfig, clientChannelType);
        var metaClient = TrustedMetadataApiGrpc.newFutureStub(clientChannel);
        var jobLifecycle = new JobLifecycle(platformConfig, metaClient);
        jobCache = new LocalJobCache();
        // jobCache = InterfaceLogging.wrap(jobCache, IJobCache.class);
        var executors = new ExecutionManager(pluginManager);
        executors.initExecutor(orchestratorConfig.getExecutor());
        jobExecCtrl = executors.getExecutor();
        jobMonitor = new JobManagementService(jobLifecycle, jobCache, jobExecCtrl, serviceGroup);
        jobMonitor.start();
        var orchestrator = new JobApiService(jobLifecycle, jobCache);
        var orchestratorApi = new TracOrchestratorApi(orchestrator);
        this.server = NettyServerBuilder.forPort(orchestratorConfig.getPort()).addService(orchestratorApi).channelType(channelType).bossEventLoopGroup(bossGroup).workerEventLoopGroup(nettyGroup).executor(serviceGroup).build();
        this.server.start();
        log.info("Orchestrator is listening on port {}", server.getPort());
    } catch (IOException e) {
        throw new EStartup(e.getMessage(), e);
    }
}
Also used : JobLifecycle(com.accenture.trac.svc.orch.service.JobLifecycle) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) LocalJobCache(com.accenture.trac.svc.orch.cache.local.LocalJobCache) ExecutionManager(com.accenture.trac.common.exec.ExecutionManager) TracOrchestratorApi(com.accenture.trac.svc.orch.api.TracOrchestratorApi) IOException(java.io.IOException) EStartup(com.accenture.trac.common.exception.EStartup) IOException(java.io.IOException) NioSocketChannel(io.netty.channel.socket.nio.NioSocketChannel) DefaultThreadFactory(io.netty.util.concurrent.DefaultThreadFactory) PlatformConfig(com.accenture.trac.config.PlatformConfig) JobManagementService(com.accenture.trac.svc.orch.service.JobManagementService) OrchServiceConfig(com.accenture.trac.config.OrchServiceConfig) JobApiService(com.accenture.trac.svc.orch.service.JobApiService) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup)

Aggregations

EStartup (com.accenture.trac.common.exception.EStartup)1 ExecutionManager (com.accenture.trac.common.exec.ExecutionManager)1 OrchServiceConfig (com.accenture.trac.config.OrchServiceConfig)1 PlatformConfig (com.accenture.trac.config.PlatformConfig)1 TracOrchestratorApi (com.accenture.trac.svc.orch.api.TracOrchestratorApi)1 LocalJobCache (com.accenture.trac.svc.orch.cache.local.LocalJobCache)1 JobApiService (com.accenture.trac.svc.orch.service.JobApiService)1 JobLifecycle (com.accenture.trac.svc.orch.service.JobLifecycle)1 JobManagementService (com.accenture.trac.svc.orch.service.JobManagementService)1 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)1 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)1 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)1 DefaultThreadFactory (io.netty.util.concurrent.DefaultThreadFactory)1 IOException (java.io.IOException)1