Search in sources :

Example 1 with ArtipieRepositories

use of com.artipie.http.ArtipieRepositories in project artipie by artipie.

the class VertxMain method startRepos.

/**
 * Start repository servers.
 *
 * @param settings Settings.
 * @param metrics Metrics.
 */
private void startRepos(final Settings settings, final Metrics metrics) {
    final Storage storage = settings.repoConfigsStorage();
    final Collection<RepoConfig> configs = storage.list(Key.ROOT).thenApply(keys -> keys.stream().map(key -> new ConfigFile(key)).filter(Predicate.not(ConfigFile::isSystem).and(ConfigFile::isYamlOrYml)).map(ConfigFile::name).map(name -> new RepositoriesFromStorage(this.http, storage).config(name)).map(stage -> stage.toCompletableFuture().join()).collect(Collectors.toList())).toCompletableFuture().join();
    for (final RepoConfig repo : configs) {
        try {
            repo.port().ifPresent(prt -> {
                final String name = new ConfigFile(repo.name()).name();
                this.listenOn(new ArtipieRepositories(this.http, settings).slice(new Key.From(name), true), metrics, prt);
                Logger.info(VertxMain.class, "Artipie repo '%s' was started on port %d", name, prt);
            });
        } catch (final IllegalStateException err) {
            Logger.error(this, "Invalid repo config file %s: %[exception]s", repo.name(), err);
        }
    }
    new QuartzScheduler(configs).start();
}
Also used : RepoConfig(com.artipie.repo.RepoConfig) Slice(com.artipie.http.Slice) Options(org.apache.commons.cli.Options) ArtipieRepositories(com.artipie.http.ArtipieRepositories) NopMetrics(com.artipie.metrics.nop.NopMetrics) ArrayList(java.util.ArrayList) DefaultParser(org.apache.commons.cli.DefaultParser) BaseSlice(com.artipie.http.BaseSlice) Metrics(com.artipie.metrics.Metrics) Vertx(io.vertx.reactivex.core.Vertx) Storage(com.artipie.asto.Storage) ConfigFile(com.artipie.repo.ConfigFile) VertxSliceServer(com.artipie.vertx.VertxSliceServer) CommandLine(org.apache.commons.cli.CommandLine) MetricsFromConfig(com.artipie.metrics.MetricsFromConfig) Path(java.nio.file.Path) CommandLineParser(org.apache.commons.cli.CommandLineParser) Predicate(java.util.function.Predicate) Collection(java.util.Collection) IOException(java.io.IOException) Key(com.artipie.asto.Key) Collectors(java.util.stream.Collectors) List(java.util.List) ClientSlices(com.artipie.http.client.ClientSlices) JettyClientSlices(com.artipie.http.client.jetty.JettyClientSlices) MainSlice(com.artipie.http.MainSlice) Optional(java.util.Optional) Logger(com.jcabi.log.Logger) ArtipieProperties(com.artipie.misc.ArtipieProperties) Storage(com.artipie.asto.Storage) RepoConfig(com.artipie.repo.RepoConfig) ConfigFile(com.artipie.repo.ConfigFile) ArtipieRepositories(com.artipie.http.ArtipieRepositories)

Aggregations

Key (com.artipie.asto.Key)1 Storage (com.artipie.asto.Storage)1 ArtipieRepositories (com.artipie.http.ArtipieRepositories)1 BaseSlice (com.artipie.http.BaseSlice)1 MainSlice (com.artipie.http.MainSlice)1 Slice (com.artipie.http.Slice)1 ClientSlices (com.artipie.http.client.ClientSlices)1 JettyClientSlices (com.artipie.http.client.jetty.JettyClientSlices)1 Metrics (com.artipie.metrics.Metrics)1 MetricsFromConfig (com.artipie.metrics.MetricsFromConfig)1 NopMetrics (com.artipie.metrics.nop.NopMetrics)1 ArtipieProperties (com.artipie.misc.ArtipieProperties)1 ConfigFile (com.artipie.repo.ConfigFile)1 RepoConfig (com.artipie.repo.RepoConfig)1 VertxSliceServer (com.artipie.vertx.VertxSliceServer)1 Logger (com.jcabi.log.Logger)1 Vertx (io.vertx.reactivex.core.Vertx)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1