use of com.b2international.snowowl.core.Repositories 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);
}
use of com.b2international.snowowl.core.Repositories 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);
});
}
Aggregations