karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject git commit: [KARAF-3135] Avoid deadlock during boot features installation
Date Tue, 22 Jul 2014 19:25:39 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-2.x a120ff5e2 -> 7c290b6ab


[KARAF-3135] Avoid deadlock during boot features installation


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/7c290b6a
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/7c290b6a
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/7c290b6a

Branch: refs/heads/karaf-2.x
Commit: 7c290b6ab07ee16c4fe4e1e6ea1fca562eb4bec0
Parents: a120ff5
Author: Guillaume Nodet <gnodet@gmail.com>
Authored: Tue Jul 22 21:25:18 2014 +0200
Committer: Guillaume Nodet <gnodet@gmail.com>
Committed: Tue Jul 22 21:25:27 2014 +0200

----------------------------------------------------------------------
 .../apache/karaf/features/FeaturesService.java  |  3 ++-
 .../features/internal/FeaturesServiceImpl.java  | 20 ++++++++++++++++----
 2 files changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/7c290b6a/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java b/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java
index 181d239..14d2c1a 100644
--- a/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java
+++ b/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java
@@ -31,7 +31,8 @@ public interface FeaturesService {
         NoAutoRefreshBundles,
         NoAutoStartBundles,
         ContinueBatchOnFailure,
-        Verbose
+        Verbose,
+        Boot
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/karaf/blob/7c290b6a/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
b/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
index 248d074..3321942 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
@@ -398,6 +398,7 @@ public class FeaturesServiceImpl implements FeaturesService, FrameworkListener
{
         final InstallationState state = new InstallationState();
         final InstallationState failure = new InstallationState();
         boolean verbose = options.contains(FeaturesService.Option.Verbose);
+        Set<Bundle> bundlesToRefresh = null;
         try {
             // Install everything
             for (Feature f : features) {
@@ -432,7 +433,7 @@ public class FeaturesServiceImpl implements FeaturesService, FrameworkListener
{
             boolean print = options.contains(Option.PrintBundlesToRefresh);
             boolean refresh = !options.contains(Option.NoAutoRefreshBundles);
             if (print || refresh) {
-                Set<Bundle> bundlesToRefresh = findBundlesToRefresh(state);
+                bundlesToRefresh = findBundlesToRefresh(state);
                 StringBuilder sb = new StringBuilder();
                 for (Bundle b : bundlesToRefresh) {
                     if (sb.length() > 0) {
@@ -451,7 +452,9 @@ public class FeaturesServiceImpl implements FeaturesService, FrameworkListener
{
                     }
                     if (refresh) {
                         LOGGER.debug("Refreshing bundles: {}", sb.toString());
-                        refreshPackages(bundlesToRefresh);
+                        if (!options.contains(Option.Boot)) {
+                            refreshPackages(bundlesToRefresh);
+                        }
                     }
                 }
             }
@@ -505,6 +508,10 @@ public class FeaturesServiceImpl implements FeaturesService, FrameworkListener
{
                     }
                 }
             }
+            // Refresh bundles async for boot
+            if (options.contains(Option.Boot) && bundlesToRefresh != null &&
!bundlesToRefresh.isEmpty()) {
+                refreshPackagesAsync(bundlesToRefresh);
+            }
         } catch (Exception e) {
             // cleanup on error
             if (!options.contains(Option.NoCleanIfFailure)) {
@@ -1203,7 +1210,7 @@ public class FeaturesServiceImpl implements FeaturesService, FrameworkListener
{
                             }
                         }
                         try {
-                            installFeatures(features, EnumSet.of(Option.NoCleanIfFailure,
Option.ContinueBatchOnFailure));
+                            installFeatures(features, EnumSet.of(Option.NoCleanIfFailure,
Option.ContinueBatchOnFailure, Option.Boot));
                         } catch (Exception e) {
                             LOGGER.error("Error installing boot features", e);
                         }
@@ -1250,7 +1257,7 @@ public class FeaturesServiceImpl implements FeaturesService, FrameworkListener
{
                     }
                 }
                 try {
-                    installFeatures(features, EnumSet.of(Option.NoCleanIfFailure, Option.ContinueBatchOnFailure));
+                    installFeatures(features, EnumSet.of(Option.NoCleanIfFailure, Option.ContinueBatchOnFailure,
Option.Boot));
                 } catch (Exception e) {
                     LOGGER.error("Error installing boot features", e);
                 }
@@ -1290,6 +1297,11 @@ public class FeaturesServiceImpl implements FeaturesService, FrameworkListener
{
         latch.await();
     }
 
+    protected void refreshPackagesAsync(Collection<Bundle> bundles) throws InterruptedException
{
+        FrameworkWiring fw = bundleContext.getBundle(0).adapt(FrameworkWiring.class);
+        fw.refreshBundles(bundles);
+    }
+
     protected String[] parsePid(String pid) {
         int n = pid.indexOf('-');
         if (n > 0) {


Mime
View raw message