Search in sources :

Example 1 with RepositoryInfo

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

the class ServerInfoGetRequest method execute.

@Override
public ServerInfo execute(ServiceProvider context) {
    final Version version = Platform.getBundle(CoreActivator.PLUGIN_ID).getVersion();
    final String description = context.service(SnowOwlConfiguration.class).getDescription();
    final Repositories repositories = RepositoryRequests.prepareSearch().build().execute(context);
    final Set<String> repositoryIndices = repositories.stream().map(RepositoryInfo::indices).flatMap(List::stream).map(EsIndexStatus::getIndex).collect(Collectors.toSet());
    // this represents the current full cluster status with all global and terminology plugin specific indices
    EsClusterStatus clusterStatus = context.service(EsClient.class).status();
    // append global indices to the server info response
    final List<EsIndexStatus> globalIndices = clusterStatus.getIndices().stream().filter(indexStatus -> !repositoryIndices.contains(indexStatus.getIndex())).collect(Collectors.toList());
    EsClusterStatus globalStatus = new EsClusterStatus(clusterStatus.isAvailable(), clusterStatus.getDiagnosis(), globalIndices);
    return new ServerInfo(version.toString(), description, repositories, globalStatus);
}
Also used : Repositories(com.b2international.snowowl.core.Repositories) EsClient(com.b2international.index.es.client.EsClient) EsClusterStatus(com.b2international.index.es.client.EsClusterStatus) Request(com.b2international.snowowl.core.events.Request) Set(java.util.Set) ServerInfo(com.b2international.snowowl.core.ServerInfo) Unprotected(com.b2international.snowowl.core.authorization.Unprotected) Version(org.osgi.framework.Version) Collectors(java.util.stream.Collectors) RepositoryRequests(com.b2international.snowowl.core.repository.RepositoryRequests) RepositoryInfo(com.b2international.snowowl.core.RepositoryInfo) List(java.util.List) EsIndexStatus(com.b2international.index.es.client.EsIndexStatus) CoreActivator(com.b2international.snowowl.core.CoreActivator) ServiceProvider(com.b2international.snowowl.core.ServiceProvider) Platform(org.eclipse.core.runtime.Platform) SnowOwlConfiguration(com.b2international.snowowl.core.config.SnowOwlConfiguration) Repositories(com.b2international.snowowl.core.Repositories) EsIndexStatus(com.b2international.index.es.client.EsIndexStatus) Version(org.osgi.framework.Version) ServerInfo(com.b2international.snowowl.core.ServerInfo) EsClusterStatus(com.b2international.index.es.client.EsClusterStatus) List(java.util.List) EsClient(com.b2international.index.es.client.EsClient) SnowOwlConfiguration(com.b2international.snowowl.core.config.SnowOwlConfiguration)

Example 2 with RepositoryInfo

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

the class RepositoriesCommand method run.

@Override
public void run(CommandLineStream out) {
    RepositorySearchRequestBuilder req = RepositoryRequests.prepareSearch();
    if (!Strings.isNullOrEmpty(repositoryId)) {
        req.one().filterById(repositoryId);
    } else {
        req.all();
    }
    final Repositories repositories = req.buildAsync().execute(getBus()).getSync();
    final int maxDiagLength = ImmutableList.copyOf(repositories).stream().map(RepositoryInfo::diagnosis).map(Strings::nullToEmpty).map(diag -> diag.length()).max(Ints::compare).orElse(16);
    final int maxLength = Math.max(maxDiagLength + 36, 52);
    printSeparator(out, maxLength);
    printHeader(out, "id", "health", Strings.padEnd("diagnosis", maxDiagLength, ' '));
    printSeparator(out, maxLength);
    repositories.forEach(repository -> {
        printLine(out, repository, RepositoryInfo::id, RepositoryInfo::health, repo -> Strings.isNullOrEmpty(repo.diagnosis()) ? "-" : null);
        printSeparator(out, maxLength);
    });
}
Also used : Repositories(com.b2international.snowowl.core.Repositories) RepositorySearchRequestBuilder(com.b2international.snowowl.core.repository.RepositorySearchRequestBuilder) RepositoryInfo(com.b2international.snowowl.core.RepositoryInfo)

Example 3 with RepositoryInfo

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

the class TerminologyRepositoryPlugin method run.

@Override
public final void run(SnowOwlConfiguration configuration, Environment env) throws Exception {
    // register terminology and component definitions
    TerminologyRegistry registry = env.service(TerminologyRegistry.class);
    registry.register(this);
    getAdditionalTerminologyComponents().values().forEach(additionalTerminologyComponent -> registry.register(getToolingId(), additionalTerminologyComponent));
    if (env.isServer()) {
        final DefaultRepositoryManager repositories = (DefaultRepositoryManager) env.service(RepositoryManager.class);
        final RepositoryBuilder builder = repositories.prepareCreate(getToolingId());
        final Repository repo = builder.withPreCommitHook(getTerminologyRepositoryPreCommitHook(builder.log())).addTerminologyComponents(getTerminologyComponents()).addTerminologyComponents(getAdditionalTerminologyComponents()).addMappings(getAdditionalMappings()).bind(ComponentDeletionPolicy.class, getComponentDeletionPolicy()).bind(VersioningRequestBuilder.class, getVersioningRequestBuilder()).bind(ComponentRevisionConflictProcessor.class, getComponentRevisionConflictProcessor()).bind(ConceptSearchRequestEvaluator.class, getConceptSearchRequestEvaluator()).bind(ValueSetMemberSearchRequestEvaluator.class, getMemberSearchRequestEvaluator()).bind(ConceptMapMappingSearchRequestEvaluator.class, getConceptMapMappingSearchRequestEvaluator()).bind(QueryOptimizer.class, getQueryOptimizer()).bind(ContentAvailabilityInfoProvider.class, getContentAvailabilityInfoProvider()).bind(ContextConfigurer.class, getRequestConfigurer()).bind(ResourceURLSchemaSupport.class, getTerminologyURISupport()).build(env);
        RepositoryInfo status = repo.status();
        if (status.health() == Health.GREEN) {
            LOG.info("Started repository '{}' with status '{}'", repo.id(), status.health());
        } else {
            LOG.warn("Started repository '{}' with status '{}'. Diagnosis: {}.", status.id(), status.health(), status.diagnosis());
        }
        // register EsClient from repository globally
        env.services().registerService(EsClient.class, repo.service(IndexClient.class).client());
    }
    afterRun(configuration, env);
}
Also used : Repository(com.b2international.snowowl.core.Repository) VersioningRequestBuilder(com.b2international.snowowl.core.request.version.VersioningRequestBuilder) RepositoryInfo(com.b2international.snowowl.core.RepositoryInfo) ResourceURLSchemaSupport(com.b2international.snowowl.core.uri.ResourceURLSchemaSupport) TerminologyRegistry(com.b2international.snowowl.core.terminology.TerminologyRegistry) RepositoryManager(com.b2international.snowowl.core.RepositoryManager)

Aggregations

RepositoryInfo (com.b2international.snowowl.core.RepositoryInfo)3 Repositories (com.b2international.snowowl.core.Repositories)2 EsClient (com.b2international.index.es.client.EsClient)1 EsClusterStatus (com.b2international.index.es.client.EsClusterStatus)1 EsIndexStatus (com.b2international.index.es.client.EsIndexStatus)1 CoreActivator (com.b2international.snowowl.core.CoreActivator)1 Repository (com.b2international.snowowl.core.Repository)1 RepositoryManager (com.b2international.snowowl.core.RepositoryManager)1 ServerInfo (com.b2international.snowowl.core.ServerInfo)1 ServiceProvider (com.b2international.snowowl.core.ServiceProvider)1 Unprotected (com.b2international.snowowl.core.authorization.Unprotected)1 SnowOwlConfiguration (com.b2international.snowowl.core.config.SnowOwlConfiguration)1 Request (com.b2international.snowowl.core.events.Request)1 RepositoryRequests (com.b2international.snowowl.core.repository.RepositoryRequests)1 RepositorySearchRequestBuilder (com.b2international.snowowl.core.repository.RepositorySearchRequestBuilder)1 VersioningRequestBuilder (com.b2international.snowowl.core.request.version.VersioningRequestBuilder)1 TerminologyRegistry (com.b2international.snowowl.core.terminology.TerminologyRegistry)1 ResourceURLSchemaSupport (com.b2international.snowowl.core.uri.ResourceURLSchemaSupport)1 List (java.util.List)1 Set (java.util.Set)1