Search in sources :

Example 1 with IManagedContainer

use of org.eclipse.net4j.util.container.IManagedContainer in project snow-owl by b2ihealthcare.

the class RepositoryPlugin method preRun.

@Override
public void preRun(SnowOwlConfiguration configuration, Environment env) {
    if (env.isServer()) {
        LOG.debug("Initializing repository plugin.");
        final MeterRegistry registry = env.service(MeterRegistry.class);
        final IEventBus eventBus = env.service(IEventBus.class);
        // Add event bus based request metrics
        registerRequestMetrics(registry, eventBus);
        final IManagedContainer container = env.container();
        RpcUtil.getInitialServerSession(container).registerServiceLookup(env::service);
        Net4jUtil.prepareContainer(container);
        JVMUtil.prepareContainer(container);
        TCPUtil.prepareContainer(container);
        LifecycleUtil.activate(container);
        final HostAndPort hostAndPort = env.service(RepositoryConfiguration.class).getHostAndPort();
        // open port in server environments
        if (hostAndPort.getPort() > 0) {
            // Starts the TCP transport
            TCPUtil.getAcceptor(container, hostAndPort.toString());
            LOG.info("Listening on {} for connections", hostAndPort);
        }
        // Starts the JVM transport
        JVMUtil.getAcceptor(container, TransportClient.NET_4_J_CONNECTOR_NAME);
        final RepositoryManager repositoryManager = new DefaultRepositoryManager();
        env.services().registerService(RepositoryManager.class, repositoryManager);
        env.services().registerService(RepositoryContextProvider.class, repositoryManager);
        int numberOfWorkers = env.service(RepositoryConfiguration.class).getMaxThreads();
        initializeRequestSupport(env, numberOfWorkers);
        LOG.debug("Initialized repository plugin.");
    } else {
        LOG.debug("Snow Owl application is running in remote mode.");
    }
    if (env.isServer()) {
        try {
            connectSystemUser(env.container());
        } catch (SnowowlServiceException e) {
            throw new SnowowlRuntimeException(e);
        }
    }
}
Also used : HostAndPort(com.google.common.net.HostAndPort) IManagedContainer(org.eclipse.net4j.util.container.IManagedContainer) RepositoryManager(com.b2international.snowowl.core.RepositoryManager) SnowowlServiceException(com.b2international.snowowl.core.api.SnowowlServiceException) RepositoryConfiguration(com.b2international.snowowl.core.config.RepositoryConfiguration) IEventBus(com.b2international.snowowl.eventbus.IEventBus) SnowowlRuntimeException(com.b2international.snowowl.core.api.SnowowlRuntimeException) MeterRegistry(io.micrometer.core.instrument.MeterRegistry)

Example 2 with IManagedContainer

use of org.eclipse.net4j.util.container.IManagedContainer in project snow-owl by b2ihealthcare.

the class RepositoryPlugin method init.

@Override
public void init(SnowOwlConfiguration configuration, Environment env) throws Exception {
    final IManagedContainer container = env.container();
    final boolean gzip = configuration.isGzip();
    final RpcConfiguration rpcConfig = configuration.getModuleConfig(RpcConfiguration.class);
    LOG.debug("Preparing RPC communication (config={},gzip={})", rpcConfig, gzip);
    RpcUtil.prepareContainer(container, rpcConfig, gzip);
    LOG.debug("Preparing EventBus communication (gzip={})", gzip);
    RepositoryConfiguration repositoryConfiguration = configuration.getModuleConfig(RepositoryConfiguration.class);
    env.services().registerService(RepositoryConfiguration.class, repositoryConfiguration);
    int maxThreads = repositoryConfiguration.getMaxThreads();
    EventBusNet4jUtil.prepareContainer(container, gzip, maxThreads);
    env.services().registerService(IEventBus.class, EventBusNet4jUtil.getBus(container, maxThreads));
    LOG.debug("Preparing JSON support");
    final ObjectMapper mapper = JsonSupport.getDefaultObjectMapper();
    mapper.registerModule(new PrimitiveCollectionModule());
    env.services().registerService(ObjectMapper.class, mapper);
    // initialize Notification support
    env.services().registerService(Notifications.class, new Notifications(env.service(IEventBus.class), env.plugins().getCompositeClassLoader()));
    env.services().registerService(RepositoryCommitNotificationSender.class, new RepositoryCommitNotificationSender());
    // initialize Index Settings
    final IndexSettings indexSettings = new IndexSettings();
    indexSettings.putAll(initIndexSettings(env));
    env.services().registerService(IndexSettings.class, indexSettings);
}
Also used : PrimitiveCollectionModule(com.b2international.collections.PrimitiveCollectionModule) IManagedContainer(org.eclipse.net4j.util.container.IManagedContainer) IndexSettings(com.b2international.snowowl.core.config.IndexSettings) RepositoryConfiguration(com.b2international.snowowl.core.config.RepositoryConfiguration) Notifications(com.b2international.snowowl.core.events.Notifications) RpcConfiguration(com.b2international.snowowl.rpc.RpcConfiguration) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

RepositoryConfiguration (com.b2international.snowowl.core.config.RepositoryConfiguration)2 IManagedContainer (org.eclipse.net4j.util.container.IManagedContainer)2 PrimitiveCollectionModule (com.b2international.collections.PrimitiveCollectionModule)1 RepositoryManager (com.b2international.snowowl.core.RepositoryManager)1 SnowowlRuntimeException (com.b2international.snowowl.core.api.SnowowlRuntimeException)1 SnowowlServiceException (com.b2international.snowowl.core.api.SnowowlServiceException)1 IndexSettings (com.b2international.snowowl.core.config.IndexSettings)1 Notifications (com.b2international.snowowl.core.events.Notifications)1 IEventBus (com.b2international.snowowl.eventbus.IEventBus)1 RpcConfiguration (com.b2international.snowowl.rpc.RpcConfiguration)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 HostAndPort (com.google.common.net.HostAndPort)1 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)1