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

    https://github.com/apache/brooklyn-server/pull/672#discussion_r120078356
  
    --- 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,
    +            boolean start, boolean loadCatalogBom, boolean 
forceUpdateOfNonSnapshots) {
    +        
    +        OsgiArchiveInstaller installer = new OsgiArchiveInstaller(this, 
knownBundleMetadata, zipIn);
    +        installer.setStart(start);
    +        installer.setLoadCatalogBom(loadCatalogBom);
    +        installer.setForce(forceUpdateOfNonSnapshots);
    +        
    +        return installer.install();
    +    }
    +    
    +    /**
    +     * Removes this bundle from Brooklyn management, 
    +     * removes all catalog items it defined,
    +     * and then uninstalls the bundle from OSGi.
    +     * <p>
    +     * No checking is done whether anything is using the bundle;
    +     * behaviour of such things is not guaranteed. They will work for many 
things
    +     * but attempts to load new classes may fail.
    +     * <p>
    +     * Callers should typically fail if anything from this bundle is in 
use.
    +     */
    +    public void uninstallUploadedBundle(ManagedBundle bundleMetadata) {
    --- End diff --
    
    +1 to needing `delete`


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to