You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2015/02/09 16:36:33 UTC
[14/22] incubator-brooklyn git commit: better dev-environment
detection and osgi error reporting
better dev-environment detection and osgi error reporting
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/45820728
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/45820728
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/45820728
Branch: refs/heads/master
Commit: 45820728671c18e183e0e296a197fc5d46305d0a
Parents: 689f051
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Fri Feb 6 17:56:38 2015 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Fri Feb 6 22:12:14 2015 +0000
----------------------------------------------------------------------
.../src/main/java/brooklyn/BrooklynVersion.java | 11 ++++-------
.../brooklyn/management/ha/OsgiManager.java | 20 ++++++++++++++++----
2 files changed, 20 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/45820728/core/src/main/java/brooklyn/BrooklynVersion.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/BrooklynVersion.java b/core/src/main/java/brooklyn/BrooklynVersion.java
index 3e7645a..0cdf375 100644
--- a/core/src/main/java/brooklyn/BrooklynVersion.java
+++ b/core/src/main/java/brooklyn/BrooklynVersion.java
@@ -197,20 +197,17 @@ public class BrooklynVersion {
private static boolean computeIsDevelopmentEnvironment() {
Enumeration<URL> paths;
try {
- paths = BrooklynVersion.class.getClassLoader().getResources(MANIFEST_PATH);
+ paths = BrooklynVersion.class.getClassLoader().getResources("brooklyn/BrooklynVersion.class");
} catch (IOException e) {
// shouldn't happen
throw Exceptions.propagate(e);
}
while (paths.hasMoreElements()) {
URL u = paths.nextElement();
- if (u.getPath().endsWith("core/target/classes/META-INF/MANIFEST.MF")) {
+ if (u.getPath().endsWith("core/target/classes/brooklyn/BrooklynVersion.class")) {
try {
- ManifestHelper mh = Osgis.ManifestHelper.forManifest(u.openStream());
- if (BROOKLYN_CORE_SYMBOLIC_NAME.equals(mh.getSymbolicName())) {
- log.debug("Brooklyn debug environment detected; core manifest is at: "+u);
- return true;
- }
+ log.debug("Brooklyn debug environment detected; BrooklynVersion class is at: "+u);
+ return true;
} catch (Exception e) {
Exceptions.propagateIfFatal(e);
log.warn("Error reading manifest to determine whether this is a development environment: "+e, e);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/45820728/core/src/main/java/brooklyn/management/ha/OsgiManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/ha/OsgiManager.java b/core/src/main/java/brooklyn/management/ha/OsgiManager.java
index 260f5ff..d699da3 100644
--- a/core/src/main/java/brooklyn/management/ha/OsgiManager.java
+++ b/core/src/main/java/brooklyn/management/ha/OsgiManager.java
@@ -23,6 +23,7 @@ import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicReference;
@@ -39,6 +40,7 @@ import brooklyn.config.BrooklynServerPaths;
import brooklyn.config.ConfigKey;
import brooklyn.management.ManagementContext;
import brooklyn.util.collections.MutableMap;
+import brooklyn.util.collections.MutableSet;
import brooklyn.util.exceptions.Exceptions;
import brooklyn.util.guava.Maybe;
import brooklyn.util.os.Os;
@@ -46,6 +48,7 @@ import brooklyn.util.os.Os.DeletionResult;
import brooklyn.util.osgi.Osgis;
import brooklyn.util.osgi.Osgis.BundleFinder;
import brooklyn.util.repeat.Repeater;
+import brooklyn.util.text.Strings;
import brooklyn.util.time.Duration;
import com.google.common.base.Throwables;
@@ -187,6 +190,7 @@ public class OsgiManager {
}
public <T> Maybe<Class<T>> tryResolveClass(String type, Iterable<CatalogBundle> catalogBundles) {
Map<CatalogBundle,Throwable> bundleProblems = MutableMap.of();
+ Set<String> extraMessages = MutableSet.of();
for (CatalogBundle catalogBundle: catalogBundles) {
try {
Maybe<Bundle> bundle = findBundle(catalogBundle);
@@ -216,8 +220,14 @@ public class OsgiManager {
Throwable cause = e.getCause();
if (cause != null && cause.getMessage().contains("Unresolved constraint in bundle")) {
- log.warn("Unresolved constraint resolving OSGi bundle "+catalogBundle+" to load "+type+": "+cause.getMessage()+
- (BrooklynVersion.isDevelopmentEnvironment() ? " (may be due to IDE / dev env; try a maven build)" : ""));
+ if (BrooklynVersion.INSTANCE.getVersionFromOsgiManifest()==null) {
+ extraMessages.add("No brooklyn-core OSGi manifest available. OSGi will not work.");
+ }
+ if (BrooklynVersion.isDevelopmentEnvironment()) {
+ extraMessages.add("Your development environment may not have created necessary files. Doing a maven build then retrying may fix the issue.");
+ }
+ if (!extraMessages.isEmpty()) log.warn(Strings.join(extraMessages, " "));
+ log.warn("Unresolved constraint resolving OSGi bundle "+catalogBundle+" to load "+type+": "+cause.getMessage());
if (log.isDebugEnabled()) log.debug("Trace for OSGi resolution failure", e);
}
}
@@ -227,9 +237,11 @@ public class OsgiManager {
if (error instanceof ClassNotFoundException && error.getCause()!=null && error.getCause().getMessage()!=null) {
error = Exceptions.collapseIncludingAllCausalMessages(error);
}
- return Maybe.absent("Unable to resolve class "+type+" in "+Iterables.getOnlyElement(bundleProblems.keySet()), error);
+ return Maybe.absent("Unable to resolve class "+type+" in "+Iterables.getOnlyElement(bundleProblems.keySet())
+ + (extraMessages.isEmpty() ? "" : " ("+Strings.join(extraMessages, " ")+")"), error);
} else {
- return Maybe.absent(Exceptions.create("Unable to resolve class "+type+": "+bundleProblems, bundleProblems.values()));
+ return Maybe.absent(Exceptions.create("Unable to resolve class "+type+": "+bundleProblems
+ + (extraMessages.isEmpty() ? "" : " ("+Strings.join(extraMessages, " ")+")"), bundleProblems.values()));
}
}