Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 597664 Details for
Bug 741682
RfE: Allow to deploy descriptor-only plugins
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Proposed patch
BZ_74168_-_allow_to_deploy_descriptor-only__agent__plugins_.patch (text/plain), 7.45 KB, created by
Heiko W. Rupp
on 2012-07-11 20:16:45 UTC
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Heiko W. Rupp
Created:
2012-07-11 20:16:45 UTC
Size:
7.45 KB
patch
obsolete
>Index: modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/AgentPluginScanner.java >IDEA additional info: >Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP ><+>ISO-8859-1 >=================================================================== >--- modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/AgentPluginScanner.java (revision db20267b46527836cbe22b9a2138a4b70ee26885) >+++ modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/AgentPluginScanner.java (revision ) >@@ -24,6 +24,7 @@ > import java.io.FileInputStream; > import java.io.FileOutputStream; > import java.io.FilenameFilter; >+import java.io.IOException; > import java.io.InputStream; > import java.net.URL; > import java.sql.Connection; >@@ -34,6 +35,8 @@ > import java.util.HashMap; > import java.util.List; > import java.util.Map; >+import java.util.jar.JarEntry; >+import java.util.jar.JarOutputStream; > > import javax.sql.DataSource; > import javax.transaction.TransactionManager; >@@ -94,9 +97,15 @@ > void registerAgentPlugins() throws Exception { > try { > for (DeploymentInfo di : this.scanned) { >+ if (di.url.getFile().endsWith("-rhq-plugin.xml")) { >+ // Create a plugin jar and deploy next time >+ createPluginJarFromDescriptor(di); >+ } >+ else { >- log.debug("Hot deploying agent plugin [" + di.url + "]..."); >- this.agentPluginDeployer.pluginDetected(di); >- } >+ log.debug("Hot deploying agent plugin [" + di.url + "]..."); >+ this.agentPluginDeployer.pluginDetected(di); >+ } >+ } > > // Register all the new plugins. > // Call this even if we don't have any update files this time, in case an error occurred last time >@@ -107,6 +116,42 @@ > } > } > >+ private void createPluginJarFromDescriptor(DeploymentInfo di) { >+ log.info("Found a plugin-descriptor at [" + di.url.getFile() + "], creating a jar from it to be deployed at the next scan"); >+ File descriptor = new File(di.url.getFile()); >+ String name = descriptor.getName(); >+ int pos = name.lastIndexOf(".xml"); >+ name = name.substring(0,pos) + ".jar"; // TODO special name for those plugins? >+ String parent = descriptor.getParent(); >+ JarOutputStream jos = null; >+ FileInputStream fis = null; >+ boolean success = false; >+ try { >+ jos = new JarOutputStream(new FileOutputStream(new File(parent,name))); >+ JarEntry jarEntry = new JarEntry("META-INF"); >+ jos.putNextEntry(jarEntry); >+ jarEntry = new JarEntry("META-INF/rhq-plugin.xml"); >+ jos.putNextEntry(jarEntry); >+ fis = new FileInputStream(descriptor); >+ int i; >+ while ((i= fis.read())>0) { >+ jos.write(i); >+ } >+ jos.flush(); >+ success = true; >+ } catch (IOException e) { >+ e.printStackTrace(); // TODO: Customise this generated block >+ } >+ finally { >+ JDBCUtil.safeClose(jos); >+ JDBCUtil.safeClose(fis); >+ } >+ if (success) { >+ boolean deleted = descriptor.delete(); >+ log.info("Deleted the now obsolete plugin descriptor: " + deleted); >+ } >+ } >+ > void agentPluginScan() throws Exception { > // this method just scans the filesystem and database for agent plugin changes but makes > // no attempt to register them or do anything with the agent plugin deployer. >@@ -136,7 +181,7 @@ > /** > * Scans the plugin directory and updates our cache of known plugin files. > * This will purge any old plugins that are deemed obsolete. >- * >+ * > * @return a list of files that appear to be new or updated and should be deployed > */ > List<File> agentPluginScanFilesystem() { >@@ -145,7 +190,7 @@ > // get the current list of plugins deployed on the filesystem > File[] pluginJars = this.agentPluginDeployer.getPluginDir().listFiles(new FilenameFilter() { > public boolean accept(File dir, String name) { >- return name.endsWith(".jar"); >+ return name.endsWith(".jar") || name.endsWith("-rhq-plugin.xml"); > } > }); > >@@ -384,10 +429,10 @@ > log.debug(message); > } > } else { >- //inform on the info level so that it's clear from the logs that the new file >+ //inform on the info level so that it's clear from the logs that the new file > //is going to be used. > log.info(message); >- } >+ } > } > } else { > log.info("Found agent plugin in the DB that we do not yet have: " + name); >Index: modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/PluginDeploymentScanner.java >IDEA additional info: >Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP ><+>ISO-8859-1 >=================================================================== >--- modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/PluginDeploymentScanner.java (revision db20267b46527836cbe22b9a2138a4b70ee26885) >+++ modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/PluginDeploymentScanner.java (revision ) >@@ -200,12 +200,12 @@ > if (listFiles == null || listFiles.length == 0) { > return; // nothing to do > } >- > for (File file : listFiles) { > File destinationDirectory; >- if (file.getName().endsWith(".jar")) { >+ boolean isJarLess = file.getName().endsWith("-rhq-plugin.xml"); >+ if (file.getName().endsWith(".jar") || isJarLess ) { > try { >- if (null == AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(file.toURI().toURL())) { >+ if (!isJarLess && null == AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(file.toURI().toURL())) { > throw new NullPointerException("no xml descriptor found in jar"); > } > destinationDirectory = getAgentPluginDir(); >@@ -244,9 +244,17 @@ > log.error("Failed to set mtime to [" + new Date(file.lastModified()) + "] on file [" > + realPluginFile + "]."); > } >- log.info("Found plugin jar at [" + file.getAbsolutePath() + "] and placed it at [" >+ String tmp; >+ if (!isJarLess) >+ tmp = "jar"; >+ else >+ tmp = "descriptor"; >+ log.info("Found plugin " + tmp + " at [" + file.getAbsolutePath() + "] and placed it at [" > + realPluginFile.getAbsolutePath() + "]"); > } >+ } >+ else { >+ log.info("Found a plugin at [" + file.getAbsolutePath() + "], which is the same as the existing one. It will be ignored"); > } > boolean deleted = file.delete(); > if (!deleted) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 741682
:
597612
| 597664