brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From geom...@apache.org
Subject [09/17] brooklyn-server git commit: address PR comments - the straightforward ones
Date Tue, 06 Jun 2017 12:25:29 GMT
address PR comments - the straightforward ones


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/bb7c04dd
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/bb7c04dd
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/bb7c04dd

Branch: refs/heads/master
Commit: bb7c04dd1d49bdabdd76390bff0ee27b7ff1a62a
Parents: f562ce7
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Mon Jun 5 11:05:00 2017 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Mon Jun 5 11:05:00 2017 +0100

----------------------------------------------------------------------
 .../brooklyn/core/mgmt/ha/OsgiArchiveInstaller.java   | 14 +++++++++-----
 .../org/apache/brooklyn/core/mgmt/ha/OsgiManager.java |  8 ++++----
 .../brooklyn/rest/resources/CatalogResource.java      |  3 ++-
 3 files changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/bb7c04dd/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiArchiveInstaller.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiArchiveInstaller.java
b/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiArchiveInstaller.java
index 4044f23..4088564 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiArchiveInstaller.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiArchiveInstaller.java
@@ -58,6 +58,10 @@ class OsgiArchiveInstaller {
 
     private static final Logger log = LoggerFactory.getLogger(OsgiArchiveInstaller.class);
     
+    // must be 1.0; see bottom of
+    // http://www.eclipse.org/virgo/documentation/virgo-documentation-3.7.0.M01/docs/virgo-user-guide/html/ch02s02.html
+    private static final String OSGI_MANIFEST_VERSION_VALUE = "1.0";
+
     final private OsgiManager osgiManager;
     private ManagedBundle suppliedKnownBundleMetadata;
     private InputStream zipIn;
@@ -161,11 +165,9 @@ class OsgiArchiveInstaller {
         }
         
         zipFile = Os.newTempFile("brooklyn-bundle-transient-"+suppliedKnownBundleMetadata,
"zip");
-        try {
-            FileOutputStream fos = new FileOutputStream(zipFile);
+        try (FileOutputStream fos = new FileOutputStream(zipFile)) {
             Streams.copy(zipIn, fos);
             zipIn.close();
-            fos.close();
         } catch (Exception e) {
             throw Exceptions.propagate(e);
         } finally {
@@ -228,7 +230,7 @@ class OsgiArchiveInstaller {
             throw new IllegalArgumentException("Missing bundle version in BOM or MANIFEST");
         }
         if (discoveredManifest.getMainAttributes().getValue(Attributes.Name.MANIFEST_VERSION)==null)
{
-            discoveredManifest.getMainAttributes().putValue(Attributes.Name.MANIFEST_VERSION.toString(),
"1.0");
+            discoveredManifest.getMainAttributes().putValue(Attributes.Name.MANIFEST_VERSION.toString(),
OSGI_MANIFEST_VERSION_VALUE);
             manifestNeedsUpdating = true;                
         }
         if (manifestNeedsUpdating) {
@@ -333,7 +335,7 @@ class OsgiArchiveInstaller {
             if (!updating) { 
                 synchronized (osgiManager.managedBundles) {
                     osgiManager.managedBundles.put(result.getMetadata().getId(), result.getMetadata());
-                    osgiManager.managedBundlesByNam.put(result.getMetadata().getVersionedName(),
result.getMetadata().getId());
+                    osgiManager.managedBundlesByName.put(result.getMetadata().getVersionedName(),
result.getMetadata().getId());
                     if (Strings.isNonBlank(result.getMetadata().getUrl())) {
                         osgiManager.managedBundlesByUrl.put(result.getMetadata().getUrl(),
result.getMetadata().getId());
                     }
@@ -346,6 +348,8 @@ class OsgiArchiveInstaller {
                 result.message = "Updated "+result.getMetadata().getVersionedName()+" as
existing ID "+result.getMetadata().getId();
                 mgmt().getRebindManager().getChangeListener().onChanged(result.getMetadata());
             }
+            log.info(result.message);
+            
             // setting the above before the code below means if there is a problem starting
or loading catalog items
             // a user has to remove then add again, or forcibly reinstall;
             // that seems fine and probably better than allowing bundles to start and catalog
items to be installed 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/bb7c04dd/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java
index 9936ba9..6b9c526 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java
@@ -103,7 +103,7 @@ public class OsgiManager {
     private Set<Bundle> bundlesAtStartup;
     private File osgiCacheDir;
     Map<String, ManagedBundle> managedBundles = MutableMap.of();
-    Map<VersionedName, String> managedBundlesByNam = MutableMap.of();
+    Map<VersionedName, String> managedBundlesByName = MutableMap.of();
     Map<String, String> managedBundlesByUrl = MutableMap.of();
     
     private static AtomicInteger numberOfReusableFrameworksCreated = new AtomicInteger();
@@ -220,13 +220,13 @@ public class OsgiManager {
 
     public String getManagedBundleId(VersionedName vn) {
         synchronized (managedBundles) {
-            return managedBundlesByNam.get(vn);
+            return managedBundlesByName.get(vn);
         }
     }
     
     public ManagedBundle getManagedBundle(VersionedName vn) {
         synchronized (managedBundles) {
-            return managedBundles.get(managedBundlesByNam.get(vn));
+            return managedBundles.get(managedBundlesByName.get(vn));
         }
     }
 
@@ -282,7 +282,7 @@ public class OsgiManager {
             if (metadata==null) {
                 throw new IllegalStateException("No such bundle registered: "+bundleMetadata);
             }
-            managedBundlesByNam.remove(bundleMetadata.getVersionedName());
+            managedBundlesByName.remove(bundleMetadata.getVersionedName());
             managedBundlesByUrl.remove(bundleMetadata.getUrl());
         }
         mgmt.getRebindManager().getChangeListener().onUnmanaged(bundleMetadata);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/bb7c04dd/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/CatalogResource.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/CatalogResource.java
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/CatalogResource.java
index 730482a..57c4ead 100644
--- a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/CatalogResource.java
+++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/CatalogResource.java
@@ -181,7 +181,8 @@ public class CatalogResource extends AbstractBrooklynRestResource implements
Cat
                     //RegisteredType ci = mgmt.getTypeRegistry().get(id);
                     
                     CatalogItem<?, ?> ci = CatalogUtils.getCatalogItemOptionalVersion(mgmt,
id);
-                    CatalogTransformer.catalogItemSummary(brooklynU, ci, ui.getBaseUriBuilder());
+                    CatalogItemSummary summary = CatalogTransformer.catalogItemSummary(brooklynU,
ci, ui.getBaseUriBuilder());
+                    result.types.put(id, summary);
                 }
             }
             return result;


Mime
View raw message