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);
}
}
}
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());
}
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;
}
Aggregations