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/06/29 13:50:07 UTC
[karaf-cellar] branch master updated: Store the id in a list so we
can install all bundles before trying to start them when pulling,
this way if a bundle depend on another one that is not install yet but is
part of the same update, the start won't fail.
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-cellar.git
The following commit(s) were added to refs/heads/master by this push:
new 4ad8ab7 Store the id in a list so we can install all bundles before trying to start them when pulling, this way if a bundle depend on another one that is not install yet but is part of the same update, the start won't fail.
new f9e12cd Merge pull request #73 from Jahia/install-and-start
4ad8ab7 is described below
commit 4ad8ab7c349d5e4aef3f38888f2e3db35e517d98
Author: tdraier <td...@jahia.com>
AuthorDate: Thu Oct 3 16:03:37 2019 +0200
Store the id in a list so we can install all bundles before trying to start them when pulling, this way if a bundle depend on another one that is not install yet but is part of the same update, the start won't fail.
---
.../karaf/cellar/bundle/BundleSynchronizer.java | 41 +++++++++++++++++-----
1 file changed, 33 insertions(+), 8 deletions(-)
diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java
index 2e78fe4..6e18cfd 100644
--- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java
+++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java
@@ -32,10 +32,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
* The BundleSynchronizer is called when Cellar starts or a node joins a cluster group.
@@ -128,6 +125,8 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
try {
// get the bundles on the cluster to update local bundles
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+
+ List<String> bundleToStart = new ArrayList<String>();
for (Map.Entry<String, BundleState> entry : clusterBundles.entrySet()) {
String id = entry.getKey();
BundleState state = entry.getValue();
@@ -153,8 +152,9 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
installBundleFromLocation(state.getLocation(), state.getStartLevel());
}
if (!isStarted(state.getLocation())) {
- LOGGER.debug("CELLAR BUNDLE: starting bundle {}/{} on node", symbolicName, version);
- startBundle(symbolicName, version);
+ // Store the id in a list so we can install all bundles before trying to start them,
+ // this way if a bundle depend on another one that is not install yet but is part of the same update, the start won't fail.
+ bundleToStart.add(id);
} else {
LOGGER.debug("CELLAR BUNDLE: bundle located {} already started on node", state.getLocation());
}
@@ -177,12 +177,26 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
}
}
} catch (BundleException e) {
- LOGGER.error("CELLAR BUNDLE: failed to pull bundle {}", id, e);
+ resolveBundleException(id, e);
}
} else LOGGER.trace("CELLAR BUNDLE: bundle {} is marked BLOCKED INBOUND for cluster group {}", bundleLocation, groupName);
}
}
}
+
+ for (String id : bundleToStart) {
+ String[] tokens = id.split("/");
+ String symbolicName = tokens[0];
+ String version = tokens[1];
+
+ try {
+ LOGGER.debug("CELLAR BUNDLE: starting bundle {}/{} on node", symbolicName, version);
+ startBundle(symbolicName, version);
+ } catch (BundleException e) {
+ resolveBundleException(id, e);
+ }
+ }
+
// cleanup the local bundles not present on the cluster if the node is not the first one in the cluster group
if (clusterManager.listNodesByGroup(group).size() > 1) {
for (Bundle bundle : bundleContext.getBundles()) {
@@ -268,7 +282,7 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
} else {
BundleState bundleState = clusterBundles.get(id);
if (bundleState.getStatus() != status) {
- LOGGER.debug("CELLAR BUNDLE: updating bundle {} on the cluster", id);
+ LOGGER.debug("CELLAR BUNDLE: updating bundle id: {}, name: {}, location: {} status: {} on the cluster", id, symbolicName, bundleLocation, status);
// update cluster state
bundleState.setStatus(status);
clusterBundles.put(id, bundleState);
@@ -344,4 +358,15 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
return null;
}
+ private void resolveBundleException(String id, BundleException e) {
+ if (BundleException.RESOLVE_ERROR == e.getType()) {
+ // we log unresolved dependencies in DEBUG
+ LOGGER.warn("CELLAR BUNDLE: Bundle {} has unresolved dependencies and won't be started now", id);
+ LOGGER.debug("CELLAR BUNDLE: Error while starting bundle {}.", id, e);
+ } else {
+ LOGGER.error("CELLAR BUNDLE: failed to pull bundle {}", id, e);
+ }
+ }
+
+
}