@Override public void dispose() { if (disposed.compareAndSet(false, true)) { for (Repository repository : repositories.values()) { try { repository.dispose(); } catch (Exception e) { LOG.error("Failed to close repository: " + repository.id(), e); } } } }
/** * @return an {@link Observable} of {@link RepositoryEvent}s sent by this {@link Repository}. */ default Observable<RepositoryEvent> notifications() { return service(Notifications.class) .ofType(RepositoryEvent.class) .filter(notification -> id().equals(notification.getRepositoryId())); }
protected AbstractBranchChangeRemoteJob(final Repository repository, UUID id, final String sourcePath, final String targetPath, final String commitComment, final String reviewId) { super(commitComment); this.repository = repository; this.commitComment = commitComment; this.reviewId = reviewId; merge.set(MergeImpl.builder(sourcePath, targetPath).id(id).build()); setSystem(true); setRule(MultiRule.combine( new BranchExclusiveRule(repository.id(), BranchPathUtils.createPath(sourcePath)), new BranchExclusiveRule(repository.id(), BranchPathUtils.createPath(targetPath)))); }
private void initializeRepositories(SnowOwlConfiguration configuration, Environment env) { final Stopwatch branchStopwatch = Stopwatch.createStarted(); LOG.debug(">>> Initializing branch and review services."); final DefaultRepositoryManager repositories = (DefaultRepositoryManager) env.service(RepositoryManager.class); RepositoryConfiguration repositoryConfig = configuration.getModuleConfig(RepositoryConfiguration.class); final ICDORepositoryManager cdoRepositoryManager = env.service(ICDORepositoryManager.class); for (String repositoryId : cdoRepositoryManager.uuidKeySet()) { Repository repo = repositories .prepareCreate(repositoryId, cdoRepositoryManager.getByUuid(repositoryId).getSnowOwlTerminologyComponentId()) .setMergeMaxResults(repositoryConfig.getMergeMaxResults()) .build(env); if (repo.health() == Health.GREEN) { LOG.info("Started repository '{}' with status '{}'", repo.id(), repo.health()); } else { LOG.warn("Started repository '{}' with status '{}'. Diagnosis: {}.", repo.id(), repo.health(), repo.diagnosis()); } } LOG.debug("<<< Branch and review services registered. [{}]", branchStopwatch); }
private void initializeContent(Environment env) { final RepositoryManager repositories = env.service(RepositoryManager.class); for (Repository repository : repositories.repositories()) { final String repositoryId = repository.id(); if (repository.health() == Health.GREEN) { final ICDORepository cdoRepository = ((InternalRepository) repository).getCdoRepository(); RepositoryInitializerRegistry.INSTANCE.getInitializer(repositoryId).initialize(cdoRepository); } } }
@Override protected IStatus run(IProgressMonitor monitor) { merge.getAndUpdate(m -> m.start()); try { applyChanges(); merge.getAndUpdate(m -> m.completed()); } catch (MergeConflictException e) { merge.getAndUpdate(m -> m.failedWithConflicts(e.getConflicts(), e.toApiError())); } catch (ApiException e) { merge.getAndUpdate(m -> m.failed(e.toApiError())); } catch (RuntimeException e) { merge.getAndUpdate(m -> m.failed(ApiError.Builder.of(e.getMessage()).build())); } finally { // Send a notification event with the final state to the global event bus repository.events().publish(String.format(Merge.ADDRESS_TEMPLATE, repository.id(), merge.get().getId()), merge.get()); } return Statuses.ok(); }
@Override protected void applyChanges() { new AsyncRequest<>(new RepositoryRequest<>(repository.id(), new SyncRebaseRequest(getMerge(), commitComment, reviewId))) .execute(repository.events()) .getSync(); } }
@Override protected void applyChanges() { new AsyncRequest<>(new RepositoryRequest<>(repository.id(), new SyncMergeRequest(getMerge(), commitComment, reviewId))) .execute(repository.events()) .getSync(); } }