Search in sources :

Example 1 with PlatformConfig

use of com.accenture.trac.config.PlatformConfig in project tracdap by finos.

the class TracDataService method doStartup.

@Override
protected void doStartup(Duration startupTimeout) {
    PlatformConfig platformConfig;
    DataServiceConfig dataSvcConfig;
    try {
        if (MemoryUtil.UNSAFE == null)
            throw new NullPointerException("MemoryUtil.UNSAFE == null");
    } catch (RuntimeException e) {
        log.error("Failed to set up native memory access for Apache Arrow", e);
        throw new EStartup("Failed to set up native memory access for Apache Arrow", e);
    }
    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);
        dataSvcConfig = platformConfig.getServices().getData();
        // 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;
        var workerThreads = Runtime.getRuntime().availableProcessors() * 2;
        workerGroup = new NioEventLoopGroup(workerThreads, new DefaultThreadFactory("data-svc"));
        bossGroup = new NioEventLoopGroup(1, new DefaultThreadFactory("data-boss"));
        var execRegister = new ExecutionRegister(workerGroup);
        // TODO: Review setup of Arrow allocator, inc. interaction with Netty / Protobuf allocators
        var arrowAllocatorConfig = RootAllocator.configBuilder().allocationManagerFactory(NettyAllocationManager.FACTORY).build();
        var arrowAllocator = new RootAllocator(arrowAllocatorConfig);
        var formats = new CodecManager(pluginManager);
        var storage = new StorageManager(pluginManager);
        storage.initStorage(dataSvcConfig.getStorageMap(), formats);
        // Check default storage and format are available
        checkDefaultStorageAndFormat(storage, formats, dataSvcConfig);
        var metaClient = prepareMetadataClient(platformConfig, clientChannelType);
        var dataSvc = new DataService(dataSvcConfig, arrowAllocator, storage, formats, metaClient);
        var fileSvc = new FileService(dataSvcConfig, storage, metaClient);
        var publicApi = new TracDataApi(dataSvc, fileSvc);
        // Create the main server
        this.server = NettyServerBuilder.forPort(dataSvcConfig.getPort()).addService(publicApi).channelType(channelType).bossEventLoopGroup(bossGroup).workerEventLoopGroup(workerGroup).directExecutor().intercept(execRegister.registerExecContext()).build();
        // Good to go, let's start!
        server.start();
        log.info("Data service is listening on port {}", server.getPort());
    } catch (IOException e) {
        throw new EStartup(e.getMessage(), e);
    }
}
Also used : NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) FileService(com.accenture.trac.svc.data.service.FileService) StorageManager(com.accenture.trac.common.storage.StorageManager) IStorageManager(com.accenture.trac.common.storage.IStorageManager) IOException(java.io.IOException) EStartup(com.accenture.trac.common.exception.EStartup) IOException(java.io.IOException) DataService(com.accenture.trac.svc.data.service.DataService) TracDataApi(com.accenture.trac.svc.data.api.TracDataApi) NioSocketChannel(io.netty.channel.socket.nio.NioSocketChannel) DefaultThreadFactory(io.netty.util.concurrent.DefaultThreadFactory) DataServiceConfig(com.accenture.trac.config.DataServiceConfig) PlatformConfig(com.accenture.trac.config.PlatformConfig) RootAllocator(org.apache.arrow.memory.RootAllocator) ExecutionRegister(com.accenture.trac.common.concurrent.ExecutionRegister) ICodecManager(com.accenture.trac.common.codec.ICodecManager) CodecManager(com.accenture.trac.common.codec.CodecManager) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup)

Example 2 with PlatformConfig

use of com.accenture.trac.config.PlatformConfig 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)2 PlatformConfig (com.accenture.trac.config.PlatformConfig)2 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)2 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)2 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)2 DefaultThreadFactory (io.netty.util.concurrent.DefaultThreadFactory)2 IOException (java.io.IOException)2 CodecManager (com.accenture.trac.common.codec.CodecManager)1 ICodecManager (com.accenture.trac.common.codec.ICodecManager)1 ExecutionRegister (com.accenture.trac.common.concurrent.ExecutionRegister)1 ExecutionManager (com.accenture.trac.common.exec.ExecutionManager)1 IStorageManager (com.accenture.trac.common.storage.IStorageManager)1 StorageManager (com.accenture.trac.common.storage.StorageManager)1 DataServiceConfig (com.accenture.trac.config.DataServiceConfig)1 OrchServiceConfig (com.accenture.trac.config.OrchServiceConfig)1 TracDataApi (com.accenture.trac.svc.data.api.TracDataApi)1 DataService (com.accenture.trac.svc.data.service.DataService)1 FileService (com.accenture.trac.svc.data.service.FileService)1 TracOrchestratorApi (com.accenture.trac.svc.orch.api.TracOrchestratorApi)1 LocalJobCache (com.accenture.trac.svc.orch.cache.local.LocalJobCache)1