Github user geomacy commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/672#discussion_r115939182
  
    --- Diff: 
core/src/main/java/org/apache/brooklyn/core/mgmt/ha/OsgiManager.java ---
    @@ -209,54 +213,114 @@ public Boolean call() {
         }
     
         public Map<String, ManagedBundle> getManagedBundles() {
    -        return ImmutableMap.copyOf(managedBundles);
    +        synchronized (managedBundles) {
    +            return ImmutableMap.copyOf(managedBundles);
    +        }
    +    }
    +
    +    public String getManagedBundleId(VersionedName vn) {
    +        synchronized (managedBundles) {
    +            return managedBundlesByNam.get(vn);
    +        }
         }
         
    -    public Bundle installUploadedBundle(ManagedBundle bundleMetadata, 
InputStream zipIn, boolean loadCatalogBom) {
    -        try {
    -            Bundle alreadyBundle = 
checkBundleInstalledThrowIfInconsistent(bundleMetadata, false);
    -            if (alreadyBundle!=null) {
    -                return alreadyBundle;
    -            }
    +    public ManagedBundle getManagedBundle(VersionedName vn) {
    +        synchronized (managedBundles) {
    +            return managedBundles.get(managedBundlesByNam.get(vn));
    +        }
    +    }
     
    -            File zipF = 
Os.newTempFile("brooklyn-bundle-transient-"+bundleMetadata, "zip");
    -            FileOutputStream fos = new FileOutputStream(zipF);
    -            Streams.copy(zipIn, fos);
    -            zipIn.close();
    -            fos.close();
    -            
    -            Bundle bundleInstalled = 
framework.getBundleContext().installBundle(bundleMetadata.getOsgiUniqueUrl(), 
    -                new FileInputStream(zipF));
    -            checkCorrectlyInstalled(bundleMetadata, bundleInstalled);
    -            if (!bundleMetadata.isNameResolved()) {
    -                
((BasicManagedBundle)bundleMetadata).setSymbolicName(bundleInstalled.getSymbolicName());
    -                
((BasicManagedBundle)bundleMetadata).setVersion(bundleInstalled.getVersion().toString());
    -            }
    -            
((BasicManagedBundle)bundleMetadata).setTempLocalFileWhenJustUploaded(zipF);
    -            
    -            synchronized (managedBundles) {
    -                managedBundles.put(bundleMetadata.getId(), bundleMetadata);
    -            }
    -            
mgmt.getRebindManager().getChangeListener().onChanged(bundleMetadata);
    -            
    -            // starting here  flags wiring issues earlier
    -            // but may break some things running from the IDE
    -            bundleInstalled.start();
    +    /** For bundles which are installed by a URL, see whether a bundle has 
been installed from that URL */
    +    public ManagedBundle getManagedBundleFromUrl(String url) {
    +        synchronized (managedBundles) {
    +            String id = managedBundlesByUrl.get(url);
    +            if (id==null) return null;
    +            return managedBundles.get(id);
    +        }
    +    }
    +    
    +    /** See {@link OsgiArchiveInstaller#install()}, using default values */
    +    public ReferenceWithError<OsgiBundleInstallationResult> 
install(InputStream zipIn) {
    +        return new OsgiArchiveInstaller(this, null, zipIn).install();
    +    }
     
    -            if (loadCatalogBom) {
    -                loadCatalogBom(bundleInstalled);
    +    /** See {@link OsgiArchiveInstaller#install()}, but deferring the 
start and catalog load */
    +    public ReferenceWithError<OsgiBundleInstallationResult> 
installDeferredStart(@Nullable ManagedBundle knownBundleMetadata, @Nullable 
InputStream zipIn) {
    +        OsgiArchiveInstaller installer = new OsgiArchiveInstaller(this, 
knownBundleMetadata, zipIn);
    +        installer.setDeferredStart(true);
    +        
    +        return installer.install();
    +    }
    +    
    +    /** See {@link OsgiArchiveInstaller#install()} - this exposes custom 
options */
    +    @Beta
    +    public ReferenceWithError<OsgiBundleInstallationResult> 
install(@Nullable ManagedBundle knownBundleMetadata, @Nullable InputStream 
zipIn,
    --- End diff --
    
    It's interesting that the only place this is called is in test code; in one 
sense this maybe isn't needed!  But good to have it for completeness's sake.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to