Search in sources :

Example 1 with RepositoryManager

use of com.b2international.snowowl.core.RepositoryManager 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 RepositoryManager

use of com.b2international.snowowl.core.RepositoryManager in project snow-owl by b2ihealthcare.

the class LocksCommand method parseLockTarget.

private static DatastoreLockTarget parseLockTarget(final String lockTargetOrAll) {
    if (ALL.equalsIgnoreCase(lockTargetOrAll)) {
        return DatastoreLockTarget.ALL;
    }
    final String repositoryId;
    final String path;
    String[] parts = lockTargetOrAll.split(":");
    if (parts.length == 2) {
        repositoryId = parts[0];
        path = parts[1];
    } else if (parts.length == 1) {
        repositoryId = parts[0];
        path = null;
    } else {
        return null;
    }
    final RepositoryManager repositoryManager = ApplicationContext.getInstance().getService(RepositoryManager.class);
    final Repository repository = repositoryManager.get(repositoryId);
    if (null == repository) {
        return null;
    }
    if (Strings.isNullOrEmpty(path)) {
        return new DatastoreLockTarget(repositoryId, null);
    }
    final IBranchPath branchPath = BranchPathUtils.createPath(path);
    // assuming active connection manager service here
    RevisionBranch branch = repository.service(BaseRevisionBranching.class).getBranch(path);
    if (null == branch) {
        return null;
    }
    return new DatastoreLockTarget(repositoryId, branchPath.getPath());
}
Also used : Repository(com.b2international.snowowl.core.Repository) RevisionBranch(com.b2international.index.revision.RevisionBranch) RepositoryManager(com.b2international.snowowl.core.RepositoryManager) DatastoreLockTarget(com.b2international.snowowl.core.internal.locks.DatastoreLockTarget) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) BaseRevisionBranching(com.b2international.index.revision.BaseRevisionBranching)

Example 3 with RepositoryManager

use of com.b2international.snowowl.core.RepositoryManager in project snow-owl by b2ihealthcare.

the class BranchesCommand method isValidRepositoryName.

private boolean isValidRepositoryName(String repositoryId, CommandLineStream out) {
    RepositoryManager repositoryManager = getRepositoryManager();
    Repository repository = repositoryManager.get(repositoryId);
    if (repository == null) {
        out.println("Could not find repository '%s'", repositoryId);
        out.println("Available repositories are:");
        repositoryManager.repositories().forEach(r -> out.println("\t%s", r.id()));
        return false;
    }
    return true;
}
Also used : Repository(com.b2international.snowowl.core.Repository) RepositoryManager(com.b2international.snowowl.core.RepositoryManager)

Aggregations

RepositoryManager (com.b2international.snowowl.core.RepositoryManager)3 Repository (com.b2international.snowowl.core.Repository)2 BaseRevisionBranching (com.b2international.index.revision.BaseRevisionBranching)1 RevisionBranch (com.b2international.index.revision.RevisionBranch)1 IBranchPath (com.b2international.snowowl.core.api.IBranchPath)1 SnowowlRuntimeException (com.b2international.snowowl.core.api.SnowowlRuntimeException)1 SnowowlServiceException (com.b2international.snowowl.core.api.SnowowlServiceException)1 RepositoryConfiguration (com.b2international.snowowl.core.config.RepositoryConfiguration)1 DatastoreLockTarget (com.b2international.snowowl.core.internal.locks.DatastoreLockTarget)1 IEventBus (com.b2international.snowowl.eventbus.IEventBus)1 HostAndPort (com.google.common.net.HostAndPort)1 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)1 IManagedContainer (org.eclipse.net4j.util.container.IManagedContainer)1