You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2020/10/05 16:41:46 UTC
[karaf] branch master updated: Enable karaf assembly builder to be
sequential
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/master by this push:
new 6fc7132 Enable karaf assembly builder to be sequential
new d2e90cd Merge pull request #1202 from rmannibucau/rmannibucau/enable-karaf-assembly-builder-to-be-sequential
6fc7132 is described below
commit 6fc7132d03e695afa219c4fd7c6fc61e1f90bef0
Author: Romain Manni-Bucau <rm...@gmail.com>
AuthorDate: Mon Sep 28 09:37:35 2020 +0200
Enable karaf assembly builder to be sequential
---
.../org/apache/karaf/profile/assembly/Builder.java | 34 +++++++++++++++++++++-
.../org/apache/karaf/tooling/AssemblyMojo.java | 9 ++++++
2 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
index 7a0c7a3..719e211 100644
--- a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
+++ b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
@@ -112,6 +112,7 @@ import org.slf4j.LoggerFactory;
import static java.util.Collections.singletonList;
import static java.util.Comparator.comparing;
import static java.util.jar.JarFile.MANIFEST_NAME;
+import static java.util.stream.Collectors.toMap;
import static org.apache.karaf.profile.assembly.Builder.Stage.Startup;
/**
@@ -311,6 +312,7 @@ public class Builder {
String generateConsistencyReport;
String consistencyReportProjectName;
String consistencyReportProjectVersion;
+ int resolverParallelism = Math.max(1, Runtime.getRuntime().availableProcessors());
private ScheduledExecutorService executor;
private DownloadManager manager;
@@ -564,6 +566,11 @@ public class Builder {
return this;
}
+ public Builder resolverParallelism(final int resolverParallelism) {
+ this.resolverParallelism = resolverParallelism;
+ return this;
+ }
+
/**
* Configure builder to copy generated and configured profiles into <code>${karaf.etc}/profiles</code>
* directory.
@@ -891,7 +898,7 @@ public class Builder {
//
MavenResolver resolver = createMavenResolver();
manager = new CustomDownloadManager(resolver, executor, null, translatedUrls);
- this.resolver = new ResolverImpl(new Slf4jResolverLog(LOGGER));
+ this.resolver = new ResolverImpl(new Slf4jResolverLog(LOGGER), resolverParallelism);
//
// Unzip KARs
@@ -2130,6 +2137,31 @@ public class Builder {
// System bundle will be single bundle installed with bundleId == 0
BundleRevision systemBundle = getSystemBundle();
+ if (resolverParallelism > 1) {
+ return doResolve(manager, resolver, repositories, features, bundles, optionals, processor, systemBundle);
+ }
+ // let a chance to be sequential in case order is important with the current framework
+ return features.stream()
+ .flatMap(it -> {
+ try {
+ return doResolve(manager, resolver, repositories, singletonList(it), bundles, optionals, processor, systemBundle).entrySet().stream();
+ } catch (final RuntimeException e) {
+ throw e;
+ } catch (final Exception e) {
+ throw new IllegalStateException(e);
+ }
+ })
+ .collect(toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> a));
+ }
+
+ private Map<String, Integer> doResolve(DownloadManager manager,
+ Resolver resolver,
+ Collection<Features> repositories,
+ Collection<String> features,
+ Collection<String> bundles,
+ Collection<String> optionals,
+ FeaturesProcessor processor,
+ BundleRevision systemBundle) throws Exception {
// Static distribution building callback and deployer that's used to deploy/collect startup-stage artifacts
AssemblyDeployCallback callback = new AssemblyDeployCallback(manager, this, systemBundle, repositories, processor);
Deployer deployer = new Deployer(manager, resolver, callback);
diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/AssemblyMojo.java b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/AssemblyMojo.java
index 83ce28b..e42edf8 100644
--- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/AssemblyMojo.java
+++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/AssemblyMojo.java
@@ -95,6 +95,12 @@ public class AssemblyMojo extends MojoSupport {
@Parameter
protected File featuresProcessing;
+ /**
+ * If set > 0, the feature resolver concurrency, otherwise it defaults to the machine one.
+ */
+ @Parameter
+ protected int resolverParallelism;
+
/*
* There are three builder stages related to maven dependency scopes:
* - Stage.Startup : scope=compile
@@ -501,6 +507,9 @@ public class AssemblyMojo extends MojoSupport {
if (featuresProcessing != null) {
builder.setFeaturesProcessing(featuresProcessing.toPath());
}
+ if (resolverParallelism > 0) {
+ builder.resolverParallelism(resolverParallelism);
+ }
// Set up remote repositories from Maven build, to be used by pax-url-aether resolver
String remoteRepositories = MavenUtil.remoteRepositoryList(project.getRemoteProjectRepositories());