[rhq] Branch 'stefan/backingcontent' - 2 commits - modules/plugins
by snegrea
modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java | 1
modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java | 33 ++++++----
modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java | 3
3 files changed, 24 insertions(+), 13 deletions(-)
New commits:
commit 5649eb36a46f7192aabd528d23b18c7324e2fc57
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Dec 8 16:41:19 2011 -0600
[BZ 761593] Update the code to correctly compute SHA 265 for the exploded war file. The existing code was computing MD5 sums.
Also, removed warning supression code left behind from incorrect use of the message digest generator.
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java
index aa48a20..f605e2d 100644
--- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java
+++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java
@@ -228,7 +228,6 @@ public class TomcatVHostComponent extends MBeanResourceComponent<TomcatServerCom
return report;
}
- @SuppressWarnings("static-access")
private void warCreate(CreateResourceReport report) throws Exception {
ResourcePackageDetails details = report.getPackageDetails();
PackageDetailsKey key = details.getKey();
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java
index 42dbde7..a93eddf 100644
--- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java
+++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java
@@ -81,7 +81,6 @@ public class FileContentDelegate {
* it is written, using the package name as the base directory; if <code>false</code> the
* content will be written to directly to a file using the package name as the file name
*/
- @SuppressWarnings("static-access")
public void createContent(File destination, File content, boolean unzip) {
try {
if (unzip) {
@@ -101,7 +100,7 @@ public class FileContentDelegate {
}
Attributes attribs = manifest.getMainAttributes();
- String sha = new MessageDigestGenerator(MessageDigestGenerator.SHA_256).getDigestString(content);
+ String sha = new MessageDigestGenerator(MessageDigestGenerator.SHA_256).calcDigestString(content);
attribs.putValue("RHQ-Sha256", sha);
FileOutputStream outputStream = new FileOutputStream(manifestFile);
commit dfd95c7e1c529aea661847acc6c21432be680946
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Dec 8 16:38:17 2011 -0600
[BZ 761593] The plugin was not obtaining the SHA from the manifest file. Since the deployment is exploded the existing code would just fail.
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java
index d865f56..933792f 100644
--- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java
+++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java
@@ -34,6 +34,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import java.util.jar.Manifest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -450,8 +451,8 @@ public class TomcatWarComponent extends MBeanResourceComponent<TomcatVHostCompon
private List<EmsBean> getVHosts() {
EmsConnection emsConnection = getEmsConnection();
String query = QUERY_TEMPLATE_HOST;
- query = query.replace("%PATH%", getResourceContext().getPluginConfiguration().getSimpleValue(
- PROPERTY_CONTEXT_ROOT, ""));
+ query = query.replace("%PATH%",
+ getResourceContext().getPluginConfiguration().getSimpleValue(PROPERTY_CONTEXT_ROOT, ""));
ObjectNameQueryUtility queryUtil = new ObjectNameQueryUtility(query);
List<EmsBean> mBeans = emsConnection.queryBeans(queryUtil.getTranslatedQuery());
return mBeans;
@@ -633,9 +634,15 @@ public class TomcatWarComponent extends MBeanResourceComponent<TomcatVHostCompon
return packages;
}
- // TODO: if needed we can speed this up by looking in the ResourceContainer's installedPackage
- // list for previously discovered packages. If there use the sha256 from that record. We'd have to
- // get access to that info by adding access in org.rhq.core.pluginapi.content.ContentServices
+ /**
+ * Retrieve SHA 256 for a deployed app.
+ * 1) If the app is exploded then look into the manifest file for the RHQ-Sha265 attribute.
+ * The SHA should have been computed and the attribute added during package deployment.
+ * 2) If the app is not exploded then compute the SHA256 for the archive.
+ *
+ * @param file application file
+ * @return the SHA 256
+ */
private String getSHA256(File file) {
String sha256 = null;
@@ -644,8 +651,15 @@ public class TomcatWarComponent extends MBeanResourceComponent<TomcatVHostCompon
//if the filesize of discovered package is null then it's an exploded and deployed war/ear.
File app = new File(file.getPath());
if (app.isDirectory()) {
- File associatedWarFile = new File(app.getAbsolutePath() + ".war");
- sha256 = new MessageDigestGenerator(MessageDigestGenerator.SHA_256).calcDigestString(associatedWarFile);
+ File manifestFile = new File(app.getAbsolutePath(), "META-INF/MANIFEST.MF");
+ InputStream manifestStream = new FileInputStream(manifestFile);
+ Manifest manifest = null;
+ try {
+ manifest = new Manifest(manifestStream);
+ sha256 = manifest.getMainAttributes().getValue("RHQ-Sha256");
+ } finally {
+ manifestStream.close();
+ }
} else {
sha256 = new MessageDigestGenerator(MessageDigestGenerator.SHA_256).calcDigestString(app);
}
@@ -733,9 +747,8 @@ public class TomcatWarComponent extends MBeanResourceComponent<TomcatVHostCompon
File file = new File(fileName);
if (!file.exists()) {
- log
- .warn("Could not delete web application files (perhaps removed manually?). Proceeding with resource removal for: "
- + fileName);
+ log.warn("Could not delete web application files (perhaps removed manually?). Proceeding with resource removal for: "
+ + fileName);
} else {
deleteApp(pluginConfiguration, file, false, true);
}
12 years, 5 months
[rhq] 3 commits - modules/core
by Jay Shaughnessy
modules/core/dbutils/pom.xml | 2
modules/core/dbutils/src/main/java/org/rhq/core/db/PostgresqlDatabaseType.java | 2
modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DriftTemplateMapDatabaseUpgradeTask.java | 51 ++++++++++
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 43 ++++++--
4 files changed, 84 insertions(+), 14 deletions(-)
New commits:
commit e8db9a190cdf7a1e070bbc077a4d025e30835a24
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Dec 8 16:02:39 2011 -0500
Add 2.117 to remove an obsolete drift table that may exist after upgrades.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 85a5526..3350cdd 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -15,7 +15,7 @@
<description>Database schema setup, upgrade and other utilities</description>
<properties>
- <db.schema.version>2.116</db.schema.version>
+ <db.schema.version>2.117</db.schema.version>
<rhq.ds.type-mapping>${rhq.test.ds.type-mapping}</rhq.ds.type-mapping>
<rhq.ds.db-name>${rhq.test.ds.db-name}</rhq.ds.db-name>
<rhq.ds.connection-url>${rhq.test.ds.connection-url}</rhq.ds.connection-url>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 92ebef7..9e3bbd6 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3823,7 +3823,12 @@
</schemaSpec>
<!-- JON 3.0 RELEASE uses DB Schema 2.116 -->
-
+
+ <schemaSpec version="2.117">
+ <!-- Remove an obsolete drift table that may be hanging around -->
+ <schema-dropTable table="RHQ_DRIFT_TEMPLATE_MAP" />
+ </schemaSpec>
+
</dbupgrade>
</target>
</project>
commit dedfe6ad8738d1be1c5a411943e4e48d4410ffd2
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Dec 8 15:28:14 2011 -0500
[Bug 753866 - DB Upgrade needs more work for existing drift records]
More work to support 4.1 and 4.2 upgrades for drift.
- In the java template map upgrade task
- add logic to generate the rhq_drift_def_template records
- add logic to generate rhq_drift_set records for each initial changeset
- Move some logic from 2.115 to 2.116 to make 2.115 match the
schema produced by a 4.2 dbsetup (fresh db). Note that prior to
an upgrade 4.2 databases must (for now at least) be manually set
to schema version 2.115. They are errantly set to 2.114 in the 4.2
release.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DriftTemplateMapDatabaseUpgradeTask.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DriftTemplateMapDatabaseUpgradeTask.java
index d060a2a..95d9ef7 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DriftTemplateMapDatabaseUpgradeTask.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/DriftTemplateMapDatabaseUpgradeTask.java
@@ -20,6 +20,7 @@ package org.rhq.core.db.upgrade;
import java.sql.Connection;
import java.sql.SQLException;
+import java.util.List;
import mazz.i18n.Logger;
@@ -39,6 +40,8 @@ public class DriftTemplateMapDatabaseUpgradeTask implements DatabaseUpgradeTask
public void execute(DatabaseType databaseType, Connection connection) throws SQLException {
+ // First generate a drift def template for each of the existing mappings
+
String sql = "" //
+ " insert into RHQ_DRIFT_DEF_TEMPLATE (" //
+ " ID," //
@@ -61,5 +64,53 @@ public class DriftTemplateMapDatabaseUpgradeTask implements DatabaseUpgradeTask
LOG.debug(DbUtilsI18NResourceKeys.EXECUTING_SQL, sql);
databaseType.executeSql(connection, sql);
+
+ // Second, assign one of the new templates to each of the existing definitions. Note that in the
+ // upgrade scenario we are guaranteed to only have 1 template for the given resource type so the
+ // select below is safe to return a single value.
+ sql = "" //
+ + " update RHQ_DRIFT_DEFINITION dd set DRIFT_DEF_TEMPLATE_ID =" //
+ + " ( select dt.ID" //
+ + " from RHQ_DRIFT_DEF_TEMPLATE dt" //
+ + " join RHQ_RESOURCE_TYPE rt on dt.RESOURCE_TYPE_ID = rt.ID" //
+ + " join RHQ_RESOURCE res on rt.ID = res.RESOURCE_TYPE_ID" //
+ + " and dd.RESOURCE_ID = res.ID" //
+ + " )" //
+ + " where dd.DRIFT_DEF_TEMPLATE_ID is null";
+
+ LOG.debug(DbUtilsI18NResourceKeys.EXECUTING_SQL, sql);
+
+ databaseType.executeSql(connection, sql);
+
+ // third, for each initial snapshot, create the newly required rhq_drift_set and map the drift to it
+ sql = "select cs.ID from RHQ_DRIFT_CHANGE_SET cs where cs.VERSION = 0";
+ LOG.debug(DbUtilsI18NResourceKeys.EXECUTING_SQL, sql);
+
+ List<Object[]> rows = databaseType.executeSelectSql(connection, sql);
+
+ sql = "insert into RHQ_DRIFT_SET ( ID ) values ( "
+ + databaseType.getSequenceInsertValue(connection, "RHQ_DRIFT_SET_ID_SEQ") + " )";
+
+ for (Object[] row : rows) {
+ int csId = ((Number) row[0]).intValue();
+
+ // insert the new drift set row
+ LOG.debug(DbUtilsI18NResourceKeys.EXECUTING_SQL, sql);
+
+ databaseType.executeSql(connection, sql);
+ int setId = databaseType.getSequenceValue(connection, "RHQ_DRIFT_SET", "ID");
+
+ // update the drift records for the initial change set to refer to the drift set
+ String updateSql = "update RHQ_DRIFT set DRIFT_SET_ID = " + setId + " where DRIFT_CHANGE_SET_ID = " + csId;
+ LOG.debug(DbUtilsI18NResourceKeys.EXECUTING_SQL, updateSql);
+
+ databaseType.executeSql(connection, updateSql);
+
+ // update the change set to refer to the drift set
+ updateSql = "update RHQ_DRIFT_CHANGE_SET set DRIFT_SET_ID = " + setId + " where ID = " + csId;
+ LOG.debug(DbUtilsI18NResourceKeys.EXECUTING_SQL, updateSql);
+
+ databaseType.executeSql(connection, updateSql);
+ }
}
}
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 8f10a3b..92ebef7 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3629,7 +3629,9 @@
<!-- RHQ 4.1 RELEASE uses DB Schema 2.114 -->
<!-- RHQ 4.2 RELEASE uses DB Schema 2.114
- Note, the 4.1 to 4.2 upgrade is broken because most ofthe changes in 2.115 should have gone into 4.2.
+ Note, the 4.1 to 4.2 upgrade is broken because a 4.2 dbsetup actually creates a 2.115 schema. So,
+ for 4.2 dbs to upgrade to 4.3 the schema version must first be corrected and set the schema
+ version to 2.115.
-->
<schemaSpec version="2.115">
@@ -3686,22 +3688,15 @@
</statement>
</schema-directSQL>
- <!-- increase size from 128 to 512 -->
- <schema-alterColumn table="RHQ_DRIFT_DEFINITION" column="NAME" columnType="VARCHAR2" precision="512" />
-
<!-- add new columns -->
<schema-addColumn table="RHQ_DRIFT_DEFINITION" column="DESCRIPTION" columnType="VARCHAR2" precision="512" />
<schema-addColumn table="RHQ_DRIFT_DEFINITION" column="DRIFT_HANDLING_MODE" columnType="VARCHAR2" precision="20" />
<schema-addColumn table="RHQ_DRIFT_DEFINITION" column="IS_PINNED" columnType="BOOLEAN"/>
<schema-addColumn table="RHQ_DRIFT_DEFINITION" column="IS_ATTACHED" columnType="BOOLEAN"/>
- <schema-addColumn table="RHQ_DRIFT_DEFINITION" column="COMPLIANCE_STATUS" columnType="INTEGER"/>
<schema-addColumn table="RHQ_DRIFT_DEFINITION" column="DRIFT_DEF_TEMPLATE_ID" columnType="INTEGER"/>
<!-- initialize new required columns -->
<schema-directSQL>
- <statement desc="RHQ_DRIFT_DEFINITION: set compliance_status column (in compliance)">
- UPDATE RHQ_DRIFT_DEFINITION SET COMPLIANCE_STATUS = 0
- </statement>
<statement targetDBVendor="postgresql" desc="RHQ_DRIFT_DEFINITION: set is_pinned column (false)">
UPDATE RHQ_DRIFT_DEFINITION SET IS_PINNED = FALSE
</statement>
@@ -3719,8 +3714,7 @@
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_DRIFT_DEFINITION" column="IS_PINNED" nullable="FALSE"/>
- <schema-alterColumn table="RHQ_DRIFT_DEFINITION" column="IS_ATTACHED" nullable="FALSE"/>
- <schema-alterColumn table="RHQ_DRIFT_DEFINITION" column="COMPLIANCE_STATUS" nullable="FALSE"/>
+ <schema-alterColumn table="RHQ_DRIFT_DEFINITION" column="IS_ATTACHED" nullable="FALSE"/>
<schema-alterColumn table="RHQ_DRIFT_DEFINITION" column="DRIFT_HANDLING_MODE" nullable="FALSE" />
<!-- add new FK -->
@@ -3771,8 +3765,8 @@
<!-- Add new drift_handling_mode column -->
<schema-addColumn table="RHQ_DRIFT_CHANGE_SET" column="DRIFT_HANDLING_MODE" columnType="VARCHAR2" precision="20" />
<schema-directSQL>
- <statement desc="RHQ_DRIFT_DEFINITION: set drift_handling_mode column (normal)">
- UPDATE RHQ_DRIFT_DEFINITION SET DRIFT_HANDLING_MODE = 'normal'
+ <statement desc="RHQ_DRIFT_CHANGE_SET: set drift_handling_mode column (normal)">
+ UPDATE RHQ_DRIFT_CHANGE_SET SET DRIFT_HANDLING_MODE = 'normal'
</statement>
</schema-directSQL>
<schema-alterColumn table="RHQ_DRIFT_CHANGE_SET" column="DRIFT_HANDLING_MODE" nullable="FALSE" />
@@ -3805,11 +3799,31 @@
</schemaSpec>
+<!-- RHQ 4.2 RELEASE uses DB Schema 2.114, which is incorrect, it should have been 2.115. So, for the
+ upgrade to work for an RHQ 4.2 install the schema version must be set to 2.115 prior to the upgrade.
+
+ The 4.2 upgrade should start with 2.116.
+-->
<schemaSpec version="2.116">
+ <!-- RHQ_DRIFT_DEFINITION changes -->
+ <schema-addColumn table="RHQ_DRIFT_DEFINITION" column="COMPLIANCE_STATUS" columnType="INTEGER"/>
+ <schema-directSQL>
+ <statement desc="RHQ_DRIFT_DEFINITION: set compliance_status column (in compliance)">
+ UPDATE RHQ_DRIFT_DEFINITION SET COMPLIANCE_STATUS = 0
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_DRIFT_DEFINITION" column="COMPLIANCE_STATUS" nullable="FALSE"/>
+
+ <schema-alterColumn table="RHQ_DRIFT_DEFINITION" column="NAME" columnType="VARCHAR2" precision="512" />
+
+
+ <!-- RHQ_PRD_VER changes -->
<!-- Increase the max length of a product version from 50 to 100. -->
<schema-alterColumn table="RHQ_PRD_VER" column="VERSION" columnType="VARCHAR2" precision="100" />
</schemaSpec>
+<!-- JON 3.0 RELEASE uses DB Schema 2.116 -->
+
</dbupgrade>
</target>
</project>
commit 37acc1c7cc76cc8a069936d66f0182640ffb569d
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Dec 8 15:22:04 2011 -0500
Change the getSequenceValue() method for postgres db type so that it
actually works.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/PostgresqlDatabaseType.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/PostgresqlDatabaseType.java
index 53555ed..4d376f3 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/PostgresqlDatabaseType.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/PostgresqlDatabaseType.java
@@ -64,7 +64,7 @@ public abstract class PostgresqlDatabaseType extends DatabaseType {
* @see DatabaseType#getSequenceValue(Connection, String, String)
*/
public int getSequenceValue(Connection conn, String table, String key) throws SQLException {
- String query = "SELECT last_value FROM " + table + "_" + key + "_seq";
+ String query = "SELECT currval('" + table + "_" + key + "_seq')";
PreparedStatement selectPS = null;
ResultSet rs = null;
12 years, 5 months
[rhq] Branch 'stefan/backingcontent' - modules/plugins
by snegrea
modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java | 8 ----
modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java | 18 ++--------
modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java | 14 +++++--
3 files changed, 15 insertions(+), 25 deletions(-)
New commits:
commit 39a4e87a05763fa1c44540b703f111512c7b2e19
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Dec 8 14:45:00 2011 -0600
[BZ 761593] The war component was not using the content delegate to redeploy applications. Because of this any redeployments were missing the SHA manifest attribute.
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java
index 0f63e1f..aa48a20 100644
--- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java
+++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java
@@ -23,13 +23,10 @@
package org.jboss.on.plugins.tomcat;
-import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStream;
import java.util.StringTokenizer;
import java.util.jar.JarEntry;
@@ -54,7 +51,6 @@ import org.rhq.core.pluginapi.content.ContentServices;
import org.rhq.core.pluginapi.inventory.ApplicationServerComponent;
import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
-import org.rhq.core.util.MessageDigestGenerator;
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.plugins.jmx.MBeanResourceComponent;
@@ -308,9 +304,7 @@ public class TomcatVHostComponent extends MBeanResourceComponent<TomcatServerCom
}
FileContentDelegate fileContent = new FileContentDelegate(deployDir, details.getPackageTypeName());
- InputStream isForTempDir = new BufferedInputStream(new FileInputStream(tempFile));
- String sha = new MessageDigestGenerator(MessageDigestGenerator.SHA_256).getDigestString(tempFile);
- fileContent.createContent(path, isForTempDir, explodeOnDeploy, sha);
+ fileContent.createContent(path, tempFile, explodeOnDeploy);
// Resource key is a canonical objectName similar to:
// Catalina:j2eeType=WebModule,name=//<vHost>/<path>,J2EEApplication=none,J2EEServer=none
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java
index 9ecc0d7..d865f56 100644
--- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java
+++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java
@@ -43,6 +43,7 @@ import org.mc4j.ems.connection.bean.EmsBean;
import org.mc4j.ems.connection.bean.attribute.EmsAttribute;
import org.mc4j.ems.connection.bean.operation.EmsOperation;
+import org.jboss.on.plugins.tomcat.helper.FileContentDelegate;
import org.jboss.on.plugins.tomcat.helper.TomcatApplicationDeployer;
import org.rhq.core.domain.configuration.Configuration;
@@ -507,15 +508,17 @@ public class TomcatWarComponent extends MBeanResourceComponent<TomcatVHostCompon
log.warn("Failed to create app backup but proceeding with redeploy of " + appFile.getPath() + ": " + e);
}
+ FileContentDelegate contentDelegate = new FileContentDelegate(appFile.getParentFile(), packageDetails.getName());
+
try {
// Write the new bits for the application. If successful Tomcat will pick it up and complete the deploy.
- moveTempFileToDeployLocation(tempFile, appFile, isExploded);
+ contentDelegate.createContent(appFile, tempFile, isExploded);
} catch (Exception e) {
// Deploy failed - rollback to the original app file...
String errorMessage = ThrowableUtil.getAllMessages(e);
try {
FileUtils.purge(appFile, true);
- moveTempFileToDeployLocation(backupFile, appFile, isExploded);
+ contentDelegate.createContent(appFile, backupFile, isExploded);
errorMessage += " ***** ROLLED BACK TO ORIGINAL APPLICATION FILE. *****";
} catch (Exception e1) {
errorMessage += " ***** FAILED TO ROLLBACK TO ORIGINAL APPLICATION FILE. *****: "
@@ -536,17 +539,6 @@ public class TomcatWarComponent extends MBeanResourceComponent<TomcatVHostCompon
return response;
}
- private void moveTempFileToDeployLocation(File tempFile, File appFile, boolean isExploded) throws IOException {
- InputStream tempIs = null;
- if (isExploded) {
- tempIs = new BufferedInputStream(new FileInputStream(tempFile));
- appFile.mkdir();
- ZipUtil.unzipFile(tempIs, appFile);
- } else {
- tempFile.renameTo(appFile);
- }
- }
-
private File backupAppBitsToTempFile(File appFile) throws Exception {
File tempDir = getResourceContext().getTemporaryDirectory();
File tempFile = new File(tempDir.getAbsolutePath(), appFile.getName() + System.currentTimeMillis());
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java
index 709c6b7..42dbde7 100644
--- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java
+++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java
@@ -37,6 +37,7 @@ import org.rhq.core.domain.content.PackageDetails;
import org.rhq.core.domain.content.PackageDetailsKey;
import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
import org.rhq.core.pluginapi.util.FileUtils;
+import org.rhq.core.util.MessageDigestGenerator;
import org.rhq.core.util.ZipUtil;
import org.rhq.core.util.file.FileUtil;
@@ -80,12 +81,13 @@ public class FileContentDelegate {
* it is written, using the package name as the base directory; if <code>false</code> the
* content will be written to directly to a file using the package name as the file name
*/
- public void createContent(File contentFile, InputStream content, boolean unzip, String sha) {
+ @SuppressWarnings("static-access")
+ public void createContent(File destination, File content, boolean unzip) {
try {
if (unzip) {
- ZipUtil.unzipFile(content, contentFile);
+ ZipUtil.unzipFile(content, destination);
- File manifestFile = new File(contentFile, "META-INF/MANIFEST.MF");
+ File manifestFile = new File(destination, "META-INF/MANIFEST.MF");
Manifest manifest;
if (manifestFile.exists()) {
FileInputStream inputStream = new FileInputStream(manifestFile);
@@ -99,6 +101,7 @@ public class FileContentDelegate {
}
Attributes attribs = manifest.getMainAttributes();
+ String sha = new MessageDigestGenerator(MessageDigestGenerator.SHA_256).getDigestString(content);
attribs.putValue("RHQ-Sha256", sha);
FileOutputStream outputStream = new FileOutputStream(manifestFile);
@@ -108,10 +111,11 @@ public class FileContentDelegate {
outputStream.close();
}
} else {
- FileUtil.writeFile(content, contentFile);
+ InputStream contentStream = new BufferedInputStream(new FileInputStream(content));
+ FileUtil.writeFile(contentStream, destination);
}
} catch (IOException e) {
- throw new RuntimeException("Error creating artifact for contentFile: " + contentFile, e);
+ throw new RuntimeException("Error creating artifact for contentFile: " + destination, e);
}
}
12 years, 5 months
[rhq] modules/core
by John Sanda
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java | 51 ++---
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueue.java | 2
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java | 31 ++-
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java | 94 ++++++----
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftManagerTest.java | 2
5 files changed, 117 insertions(+), 63 deletions(-)
New commits:
commit 518ccccdc4ad05353de809068c289c1fc64a5384
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Dec 8 13:39:47 2011 -0500
[BZ 761320] Only update the detection schedule if drift detection runs
With this commit we no longer update the detection schedule's next scan
time if detection does not run. Drift detection might not run for a few
different reasons - the definition could be disabled, it it earlier than
the next scheduled run, or the server has not acknowledged the previous
change set sent by the agent.
Some additional debug logging has also been added to output when the
next scheduled run is supposed to happen.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
index 71ddf44..21341c4 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
@@ -19,26 +19,8 @@
package org.rhq.core.pc.drift;
-import static org.rhq.common.drift.FileEntry.addedFileEntry;
-import static org.rhq.common.drift.FileEntry.changedFileEntry;
-import static org.rhq.common.drift.FileEntry.removedFileEntry;
-import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
-import static org.rhq.core.domain.drift.DriftChangeSetCategory.DRIFT;
-import static org.rhq.core.util.file.FileUtil.copyFile;
-import static org.rhq.core.util.file.FileUtil.forEachFile;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.rhq.common.drift.ChangeSetReader;
import org.rhq.common.drift.ChangeSetWriter;
import org.rhq.common.drift.FileEntry;
@@ -49,6 +31,17 @@ import org.rhq.core.domain.drift.Filter;
import org.rhq.core.util.MessageDigestGenerator;
import org.rhq.core.util.file.FileVisitor;
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.*;
+
+import static org.rhq.common.drift.FileEntry.*;
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.DRIFT;
+import static org.rhq.core.util.file.FileUtil.copyFile;
+import static org.rhq.core.util.file.FileUtil.forEachFile;
+
public class DriftDetector implements Runnable {
private Log log = LogFactory.getLog(DriftDetector.class);
@@ -76,14 +69,17 @@ public class DriftDetector implements Runnable {
public void run() {
log.debug("Starting drift detection...");
long startTime = System.currentTimeMillis();
+ boolean updateSchedule = true;
+ DriftDetectionSchedule schedule = null;
try {
if (log.isDebugEnabled()) {
log.debug("Fetching next schedule from " + scheduleQueue);
}
- DriftDetectionSchedule schedule = scheduleQueue.getNextSchedule();
+ schedule = scheduleQueue.getNextSchedule();
if (schedule == null) {
log.debug("No schedules are in the queue.");
+ updateSchedule = false;
return;
}
@@ -93,17 +89,26 @@ public class DriftDetector implements Runnable {
}
if (schedule.getNextScan() > (System.currentTimeMillis() + 100L)) {
- log.debug("Skipping " + schedule + " because it is too early to do the next detection.");
+ if (log.isDebugEnabled()) {
+ log.debug("Skipping " + schedule + " because it is too early to do the next detection.");
+ }
+ updateSchedule = false;
return;
}
if (!schedule.getDriftDefinition().isEnabled()) {
- log.debug("Skipping " + schedule + " because the drift definition is disabled.");
+ if (log.isDebugEnabled()) {
+ log.debug("Skipping " + schedule + " because the drift definition is disabled.");
+ }
+ updateSchedule = false;
return;
}
if (previousSnapshotExists(schedule)) {
- log.debug("Skipping " + schedule + " because server has not yet acked previous change set");
+ if (log.isDebugEnabled()) {
+ log.debug("Skipping " + schedule + " because server has not yet acked previous change set");
+ }
+ updateSchedule = false;
return;
}
@@ -140,7 +145,7 @@ public class DriftDetector implements Runnable {
} finally {
try {
- scheduleQueue.deactivateSchedule();
+ scheduleQueue.deactivateSchedule(updateSchedule);
long endTime = System.currentTimeMillis();
log.debug("Finished drift detection in " + (endTime - startTime) + " ms");
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueue.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueue.java
index 35960ad..13f078d 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueue.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueue.java
@@ -35,7 +35,7 @@ public interface ScheduleQueue {
* at the head of the queue to become active. If there is no active schedule this
* method simply does nothing and returns.
*/
- void deactivateSchedule();
+ void deactivateSchedule(boolean updateSchedule);
/**
* Adds a schedule to the queue for processing by the drift detector
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java
index cbc50b8..d008f36 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java
@@ -1,15 +1,14 @@
package org.rhq.core.pc.drift;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.PriorityQueue;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.drift.DriftDefinition;
import org.rhq.core.domain.drift.DriftDefinitionComparator;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
public class ScheduleQueueImpl implements ScheduleQueue {
private static final Runnable NO_OP = new Runnable() {
@@ -26,6 +25,8 @@ public class ScheduleQueueImpl implements ScheduleQueue {
private Runnable deactivationTask;
+ private Log log = LogFactory.getLog(ScheduleQueueImpl.class);
+
@Override
public DriftDetectionSchedule getNextSchedule() {
try {
@@ -66,16 +67,28 @@ public class ScheduleQueueImpl implements ScheduleQueue {
}
@Override
- public void deactivateSchedule() {
+ public void deactivateSchedule(boolean updateSchedule) {
try {
lock.writeLock().lock();
if (deactivationTask != null) {
deactivationTask.run();
}
+
if (activeSchedule == null) {
return;
}
- activeSchedule.updateShedule();
+
+ if (updateSchedule) {
+ activeSchedule.updateShedule();
+ }
+
+ if (log.isDebugEnabled()) {
+ SimpleDateFormat formatter = new SimpleDateFormat();
+ formatter.applyPattern("hh:mm:ss:SSS a");
+ log.debug("The next drift detection run for " + activeSchedule + " is set for " +
+ formatter.format(new Date(activeSchedule.getNextScan())));
+ }
+
queue.offer(activeSchedule);
activeSchedule = null;
} finally {
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
index 4a2b333..08373ec 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
@@ -19,22 +19,12 @@
package org.rhq.core.pc.drift;
-import static java.util.Arrays.asList;
-import static java.util.Collections.emptyList;
-import static org.apache.commons.io.FileUtils.copyFile;
-import static org.apache.commons.io.FileUtils.deleteDirectory;
-import static org.apache.commons.io.FileUtils.touch;
-import static org.rhq.common.drift.FileEntry.addedFileEntry;
-import static org.rhq.common.drift.FileEntry.changedFileEntry;
-import static org.rhq.common.drift.FileEntry.removedFileEntry;
-import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
-import static org.rhq.core.domain.drift.DriftChangeSetCategory.DRIFT;
-import static org.rhq.test.AssertUtils.assertCollectionMatchesNoOrder;
-import static org.rhq.test.AssertUtils.assertPropertiesMatch;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
+import org.rhq.common.drift.*;
+import org.rhq.core.domain.drift.DriftDefinition;
+import org.rhq.core.system.OperatingSystemType;
+import org.rhq.core.system.SystemInfoFactory;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
import java.io.BufferedReader;
import java.io.File;
@@ -43,18 +33,15 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import org.rhq.common.drift.ChangeSetReader;
-import org.rhq.common.drift.ChangeSetReaderImpl;
-import org.rhq.common.drift.ChangeSetWriter;
-import org.rhq.common.drift.ChangeSetWriterImpl;
-import org.rhq.common.drift.FileEntry;
-import org.rhq.common.drift.Headers;
-import org.rhq.core.domain.drift.DriftDefinition;
-import org.rhq.core.system.OperatingSystemType;
-import org.rhq.core.system.SystemInfoFactory;
+import static java.util.Arrays.asList;
+import static java.util.Collections.emptyList;
+import static org.apache.commons.io.FileUtils.*;
+import static org.rhq.common.drift.FileEntry.*;
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.DRIFT;
+import static org.rhq.test.AssertUtils.assertCollectionMatchesNoOrder;
+import static org.rhq.test.AssertUtils.assertPropertiesMatch;
+import static org.testng.Assert.*;
public class DriftDetectorTest extends DriftTest {
@@ -168,6 +155,30 @@ public class DriftDetectorTest extends DriftTest {
changeSet);
}
+ @Test
+ public void updateScheduleAfterGeneratingCoverageChangeSet() throws Exception {
+ DriftDefinition driftDef = driftDefinition("update-schedule-after-coverage-changeset",
+ resourceDir.getAbsolutePath());
+ DriftDetectionSchedule schedule = new DriftDetectionSchedule(resourceId(), driftDef);
+
+ File confDir = mkdir(resourceDir, "conf");
+ File serverConf = createRandomFile(confDir, "server.conf");
+
+ long currentTime = System.currentTimeMillis();
+
+ scheduleQueue.addSchedule(schedule);
+ detector.run();
+
+ assertTrue(schedule.getNextScan() >= (currentTime + driftDef.getInterval()),
+ "Failed to update schedule. next scan is " + schedule.getNextScan() + " and should be greater than " +
+ (currentTime + driftDef.getInterval()));
+ }
+
+ @Test
+ public void updateScheduleAfterGeneratingDriftChangeSet() throws Exception {
+
+ }
+
@SuppressWarnings("unchecked")
@Test
public void doNotUpdateSnapshotOrGenerateDriftChangeSetIfNothingChanges() throws Exception {
@@ -219,12 +230,37 @@ public class DriftDetectorTest extends DriftTest {
DriftDefinition def = driftDefinition("disabled-config-test", resourceDir.getAbsolutePath());
def.setEnabled(false);
+ DriftDetectionSchedule schedule = new DriftDetectionSchedule(resourceId(), def);
+ long nextScan = schedule.getNextScan();
+
File confDir = mkdir(resourceDir, "conf");
File server1Conf = new File(confDir, "server-1.conf");
touch(server1Conf);
- scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), def));
+ scheduleQueue.addSchedule(schedule);
+ detector.run();
+
+ // make sure that the next scan time is not updated
+ assertEquals(schedule.getNextScan(), nextScan, "The next scan time for the drift detection schedule should " +
+ " not get updated if drift detection does not actually run for the definition.");
+ }
+
+ @Test
+ public void doNotUpdateScheduleIfItIsTooEarlyToRunDetection() throws Exception {
+ DriftDefinition driftDef = driftDefinition("schedule-not-ready-test", resourceDir.getAbsolutePath());
+ DriftDetectionSchedule schedule = new DriftDetectionSchedule(resourceId(), driftDef);
+
+ File confDir = mkdir(resourceDir, "conf");
+ File server1Conf = new File(confDir, "server.conf");
+
+ scheduleQueue.addSchedule(schedule);
detector.run();
+
+ long nextScan = schedule.getNextScan();
+ detector.run();
+
+ assertEquals(schedule.getNextScan(), nextScan, "The next scan time for the drift detection schedule should " +
+ " not get updated if drift detection does not actually run for the definition.");
}
@Test
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftManagerTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftManagerTest.java
index 518e8e4..c3e28f5 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftManagerTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftManagerTest.java
@@ -260,7 +260,7 @@ public class DriftManagerTest extends DriftTest {
assertTrue(changeSetDir.exists(), "The change set directory should not be deleted while the schedule is "
+ "still active.");
- driftMgr.getSchedulesQueue().deactivateSchedule();
+ driftMgr.getSchedulesQueue().deactivateSchedule(false);
assertFalse(changeSetDir.exists(), "The change set directory should have been deleted after the schedule is "
+ "deactivated.");
}
12 years, 5 months
[rhq] Changes to 'release_jon3.0.x'
by John Sanda
New branch 'release_jon3.0.x' available with the following commits:
commit 9f35d78132ffb26ad039eea86d19c745c0ae960f
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Dec 8 13:39:47 2011 -0500
[BZ 761320] Only update the detection schedule if drift detection runs
With this commit we no longer update the detection schedule's next scan
time if detection does not run. Drift detection might not run for a few
different reasons - the definition could be disabled, it it earlier than
the next scheduled run, or the server has not acknowledged the previous
change set sent by the agent.
Some additional debug logging has also been added to output when the
next scheduled run is supposed to happen.
12 years, 5 months
[rhq] Branch 'stefan/backingcontent' - modules/plugins
by snegrea
modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java | 10 ++-
modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java | 28 +++++++++-
2 files changed, 33 insertions(+), 5 deletions(-)
New commits:
commit 8d2ea937758b5454b6c2774eaeef0a04cd221658
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Dec 8 12:14:16 2011 -0600
[BZ 761593] Add SHA to manifest for exploded WAR deployments.
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java
index 7f600a7..0f63e1f 100644
--- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java
+++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java
@@ -54,6 +54,7 @@ import org.rhq.core.pluginapi.content.ContentServices;
import org.rhq.core.pluginapi.inventory.ApplicationServerComponent;
import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+import org.rhq.core.util.MessageDigestGenerator;
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.plugins.jmx.MBeanResourceComponent;
@@ -231,6 +232,7 @@ public class TomcatVHostComponent extends MBeanResourceComponent<TomcatServerCom
return report;
}
+ @SuppressWarnings("static-access")
private void warCreate(CreateResourceReport report) throws Exception {
ResourcePackageDetails details = report.getPackageDetails();
PackageDetailsKey key = details.getKey();
@@ -307,11 +309,11 @@ public class TomcatVHostComponent extends MBeanResourceComponent<TomcatServerCom
FileContentDelegate fileContent = new FileContentDelegate(deployDir, details.getPackageTypeName());
InputStream isForTempDir = new BufferedInputStream(new FileInputStream(tempFile));
- fileContent.createContent(path, isForTempDir, explodeOnDeploy);
-
- // Resource key is a canonical objectName similar to :
- // Catalina:j2eeType=WebModule,name=//<vHost>/<path>,J2EEApplication=none,J2EEServer=none
+ String sha = new MessageDigestGenerator(MessageDigestGenerator.SHA_256).getDigestString(tempFile);
+ fileContent.createContent(path, isForTempDir, explodeOnDeploy, sha);
+ // Resource key is a canonical objectName similar to:
+ // Catalina:j2eeType=WebModule,name=//<vHost>/<path>,J2EEApplication=none,J2EEServer=none
String objectName = "Catalina:j2eeType=WebModule,J2EEApplication=none,J2EEServer=none,name=//" + getName()
+ "/" + contextRoot;
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java
index 1d2b6b2..709c6b7 100644
--- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java
+++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java
@@ -26,9 +26,12 @@ import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
import org.rhq.core.domain.content.PackageDetails;
import org.rhq.core.domain.content.PackageDetailsKey;
@@ -77,10 +80,33 @@ public class FileContentDelegate {
* it is written, using the package name as the base directory; if <code>false</code> the
* content will be written to directly to a file using the package name as the file name
*/
- public void createContent(File contentFile, InputStream content, boolean unzip) {
+ public void createContent(File contentFile, InputStream content, boolean unzip, String sha) {
try {
if (unzip) {
ZipUtil.unzipFile(content, contentFile);
+
+ File manifestFile = new File(contentFile, "META-INF/MANIFEST.MF");
+ Manifest manifest;
+ if (manifestFile.exists()) {
+ FileInputStream inputStream = new FileInputStream(manifestFile);
+ try {
+ manifest = new Manifest(inputStream);
+ } finally {
+ inputStream.close();
+ }
+ } else {
+ manifest = new Manifest();
+ }
+
+ Attributes attribs = manifest.getMainAttributes();
+ attribs.putValue("RHQ-Sha256", sha);
+
+ FileOutputStream outputStream = new FileOutputStream(manifestFile);
+ try {
+ manifest.write(outputStream);
+ } finally {
+ outputStream.close();
+ }
} else {
FileUtil.writeFile(content, contentFile);
}
12 years, 5 months
[rhq] modules/core
by mazz
modules/core/dbutils/src/test/java/org/rhq/core/db/ant/dbupdate/SchemaVersionTest.java | 2 ++
1 file changed, 2 insertions(+)
New commits:
commit d7ef96e848f139f231a8c875f8bce655fc463812
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Dec 7 16:22:57 2011 -0500
make sure we can support schema versions that we put inbetween existing versions.
for example, if we have db schema 2.115 and 2.116 and we want something in between, make sure
2.115.1 does what we think.
diff --git a/modules/core/dbutils/src/test/java/org/rhq/core/db/ant/dbupdate/SchemaVersionTest.java b/modules/core/dbutils/src/test/java/org/rhq/core/db/ant/dbupdate/SchemaVersionTest.java
index 393a293..4fdf435 100644
--- a/modules/core/dbutils/src/test/java/org/rhq/core/db/ant/dbupdate/SchemaVersionTest.java
+++ b/modules/core/dbutils/src/test/java/org/rhq/core/db/ant/dbupdate/SchemaVersionTest.java
@@ -19,6 +19,7 @@
package org.rhq.core.db.ant.dbupdate;
import org.testng.annotations.Test;
+
import org.rhq.core.db.ant.dbupgrade.SchemaVersion;
/**
@@ -50,6 +51,7 @@ public class SchemaVersionTest {
* Tests checking between versions.
*/
public void testBetween() {
+ assert new SchemaVersion("2.115.1").between(new SchemaVersion("2.115"), new SchemaVersion("2.116"));
assert new SchemaVersion("2").between(new SchemaVersion("1"), new SchemaVersion("3"));
assert new SchemaVersion("222").between(new SchemaVersion("111"), new SchemaVersion("333"));
assert new SchemaVersion("1.0.2").between(new SchemaVersion("1.0.0"), new SchemaVersion("1.0.3"));
12 years, 5 months
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/IsLongValidator.java | 13 ++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
New commits:
commit 74d3e194811007373811bc1cdc8766b68f23de54
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Dec 7 14:27:05 2011 -0500
[BZ 760721] fix bug where negative values would always get incorrectly normalized to "-" (https://bugzilla.redhat.com/show_bug.cgi?id=760721)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/IsLongValidator.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/IsLongValidator.java
index cb61cab..2b25e73 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/IsLongValidator.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/IsLongValidator.java
@@ -62,11 +62,16 @@ public class IsLongValidator extends CustomValidator {
}
String baseStringValue = stripOffNegativeSignAndLeadingZeroes(stringValue, isNegative);
- updateInputValue((isNegative) ? "-" : "" + baseStringValue);
+ String normalizedValue;
+ if (isNegative) {
+ normalizedValue = "-" + baseStringValue;
+ } else {
+ normalizedValue = baseStringValue;
+ }
+ updateInputValue(normalizedValue);
// all zeroes, optionally prefixed with negative sign, is valid
- if (baseStringValue.length() == 0) {
- updateInputValue("0");
+ if (baseStringValue.equals("0")) {
return true;
}
@@ -107,7 +112,7 @@ public class IsLongValidator extends CustomValidator {
charsToSkip++;
}
- for (int i = charsToSkip; i < stringValue.length(); i++) {
+ for (int i = charsToSkip; i < stringValue.length() - 1; i++) {
if (stringValue.charAt(i) == '0') {
charsToSkip++;
} else {
12 years, 5 months
[rhq] 4 commits - modules/enterprise modules/plugins
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDataStep.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/AbstractWizard.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/AbstractWizardStep.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/Wizard.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardStep.java | 38 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java | 13 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryConfigurationStep.java | 37 ++-
modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASDiscoveryComponent.java | 96 ++++++----
modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentDiscoveryComponent.java | 2
modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptDiscoveryComponent.java | 2
10 files changed, 142 insertions(+), 56 deletions(-)
New commits:
commit 6245b0d8756929ada716e3c3c70d2089fc1d5a48
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Dec 7 13:58:12 2011 -0500
[BZ 751418] Finish button is now disabled / grayed out on final step of resource import/create wizards until the config editor reports the config as being valid; note, to achieve this a new method isNextButtonEnabled() was added to the WizardStep interface and a new method updateButtonEnablement() was added to the WizardView class (https://bugzilla.redhat.com/show_bug.cgi?id=751418); also added javadoc to the WizardStep interface
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/AbstractWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/AbstractWizard.java
index 1b9fa0c..2e75a05 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/AbstractWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/AbstractWizard.java
@@ -77,4 +77,6 @@ public abstract class AbstractWizard implements Wizard {
public WizardView getView() {
return view;
}
+
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/AbstractWizardStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/AbstractWizardStep.java
index 299d0f2..d0aabaf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/AbstractWizardStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/AbstractWizardStep.java
@@ -28,6 +28,10 @@ public abstract class AbstractWizardStep implements WizardStep {
abstract public String getName();
+ public boolean isNextButtonEnabled() {
+ return true;
+ }
+
public boolean nextPage() {
return true;
}
@@ -35,4 +39,5 @@ public abstract class AbstractWizardStep implements WizardStep {
public boolean previousPage() {
return true;
}
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/Wizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/Wizard.java
index 8b38b39..ff4dd08 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/Wizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/Wizard.java
@@ -46,4 +46,5 @@ public interface Wizard {
* This is called when the cancel button or the wizard window's "X" close button is clicked.
*/
void cancel();
+
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardStep.java
index f5005c0..16c7ba0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardStep.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -25,17 +25,53 @@ import org.rhq.enterprise.gui.coregui.client.Messages;
import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
/**
+ * A step in a {@link Wizard wizard}.
+ *
* @author Greg Hinkle
*/
public interface WizardStep {
Messages MSG = CoreGUI.getMessages();
+ /**
+ * Returns the canvas containing this step's widget content. This method should <b>not</b> add the canvas to the
+ * parent canvas - the wizard framework will take care of that.
+ *
+ * @param parent the parent canvas to which the returned canvas will be added -
+ *
+ * @return the canvas containing this step's widget content
+ */
Canvas getCanvas(Locatable parent);
+ /**
+ * Returns true if this step's Next or Finish button should be enabled, or false if it should be disabled.
+ *
+ * @return true if this step's Next or Finish button should be enabled, or false if it should be disabled
+ */
+ boolean isNextButtonEnabled();
+
+ /**
+ * Called when the user clicks this step's Next or Finish button. If all required data has been entered for the
+ * step and is valid, true should be returned, and the wizard will advance to the next step, otherwise false
+ * should be returned, and the wizard will not advance.
+ *
+ * @return true if all required data has been entered for the step and is valid, or false otherwise
+ */
boolean nextPage();
+ /**
+ * Called when the user clicks this step's Previous button. Should return true if the wizard should go to the
+ * previous step, or false if it should not.
+ *
+ * @return true if the wizard should go to the previous step, or false if it should not.
+ */
boolean previousPage();
+ /**
+ * Returns the title of this step, to be displayed in the wizard modal's title bar.
+ *
+ * @return the title of this step, to be displayed in the wizard modal's title bar
+ */
String getName();
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java
index d5fe441..34291f0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java
@@ -48,6 +48,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
* @author Greg Hinkle
*/
public class WizardView extends LocatableVLayout {
+
static private final Messages MSG = CoreGUI.getMessages();
static private final String CANCEL = MSG.common_button_cancel();
@@ -229,7 +230,7 @@ public class WizardView extends LocatableVLayout {
.size())));
stepLabel.setWrap(false);
- WizardStep step = wizardSteps.get(currentStep);
+ final WizardStep step = wizardSteps.get(currentStep);
stepTitleLabel.setContents(step.getName());
@@ -255,7 +256,7 @@ public class WizardView extends LocatableVLayout {
}
currentCanvas = wizardSteps.get(currentStep).getCanvas(this);
- // if null advance to the next step by automatically "clicking" the Next button
+ // if null, advance to the next step by automatically "clicking" the Next button
if (null == currentCanvas) {
if (step.nextPage()) {
wizardSteps.get(currentStep).nextPage();
@@ -282,7 +283,7 @@ public class WizardView extends LocatableVLayout {
cancelButton.setDisabled(false);
previousButton.setDisabled(stepIndex == 0);
- nextButton.setDisabled(false);
+ nextButton.setDisabled(!step.isNextButtonEnabled());
for (IButton button : customButtons) {
button.setDisabled(false);
@@ -356,4 +357,10 @@ public class WizardView extends LocatableVLayout {
public void decrementStep() {
setStep(currentStep - 1);
}
+
+ public void updateButtonEnablement() {
+ WizardStep step = wizard.getSteps().get(currentStep);
+ getNextButton().setDisabled(!step.isNextButtonEnabled());
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryConfigurationStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryConfigurationStep.java
index 932f197..538aa7f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryConfigurationStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/factory/ResourceFactoryConfigurationStep.java
@@ -29,6 +29,8 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeEvent;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeListener;
import org.rhq.enterprise.gui.coregui.client.components.form.DurationItem;
import org.rhq.enterprise.gui.coregui.client.components.form.TimeUnit;
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
@@ -44,14 +46,13 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Jay Shaughnessy
* @author Greg Hinkle
*/
-public class ResourceFactoryConfigurationStep extends AbstractWizardStep {
+public class ResourceFactoryConfigurationStep extends AbstractWizardStep implements PropertyValueChangeListener {
- private boolean noConfigurationNeeded = false; // if true, it has been determined the user doesn't have to set any config
private LocatableVLayout vLayout;
private ConfigurationEditor editor;
private Configuration startingConfig;
private DurationItem timeoutItem;
- AbstractResourceFactoryWizard wizard;
+ private AbstractResourceFactoryWizard wizard;
public ResourceFactoryConfigurationStep(AbstractResourceFactoryWizard wizard) {
this.wizard = wizard;
@@ -102,17 +103,19 @@ public class ResourceFactoryConfigurationStep extends AbstractWizardStep {
ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
configurationService.getOptionValuesForConfigDefinition(def,
new AsyncCallback<ConfigurationDefinition>() {
+ public void onSuccess(ConfigurationDefinition result) {
+ createAndAddConfigurationEditor(result);
+ }
public void onFailure(Throwable throwable) {
- editor = new ConfigurationEditor(vLayout.extendLocatorId("Editor"), def, startingConfig);
- editor.setAllPropertiesWritable(true);
- vLayout.addMember(editor, 0);
-
+ createAndAddConfigurationEditor(def);
}
- public void onSuccess(ConfigurationDefinition result) {
- editor = new ConfigurationEditor(vLayout.extendLocatorId("Editor"), result, startingConfig);
+ private void createAndAddConfigurationEditor(ConfigurationDefinition def) {
+ editor = new ConfigurationEditor(vLayout.extendLocatorId("Editor"), def, startingConfig);
editor.setAllPropertiesWritable(true);
+ editor.addPropertyValueChangeListener(ResourceFactoryConfigurationStep.this);
+ wizard.getView().updateButtonEnablement();
vLayout.addMember(editor, 0);
}
});
@@ -122,9 +125,15 @@ public class ResourceFactoryConfigurationStep extends AbstractWizardStep {
return vLayout;
}
+ @Override
+ public boolean isNextButtonEnabled() {
+ return (editor != null) && editor.isValid();
+ }
+
public boolean nextPage() {
- if (noConfigurationNeeded == true || (editor != null && editor.validate())) {
- wizard.setNewResourceConfiguration((noConfigurationNeeded) ? null : editor.getConfiguration());
+ // Finish.
+ if ((editor != null) && editor.isValid()) {
+ wizard.setNewResourceConfiguration(editor.getConfiguration());
wizard.setNewResourceCreateTimeout(timeoutItem.getValueAsInteger());
wizard.execute();
return true;
@@ -136,4 +145,10 @@ public class ResourceFactoryConfigurationStep extends AbstractWizardStep {
public String getName() {
return MSG.widget_resourceFactoryWizard_editConfigStepName();
}
+
+ @Override
+ public void propertyValueChanged(PropertyValueChangeEvent event) {
+ wizard.getView().updateButtonEnablement();
+ }
+
}
\ No newline at end of file
commit b967a205193b3dbb70f507f7a3df74f0474cb06b
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Dec 7 13:50:58 2011 -0500
minor - remove manual boxing
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDataStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDataStep.java
index 9fa7dd2..b1364b0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDataStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDataStep.java
@@ -64,7 +64,7 @@ public class BundleUploadDataStep extends AbstractWizardStep {
mainLayout = new LocatableVLayout("BundleCreateUploadData");
}
- mainLayout.setMargin(Integer.valueOf(20));
+ mainLayout.setMargin(20);
mainLayout.setWidth100();
mainLayout.setHeight(10);
commit f736fd47d4d07204a9f9b8b0f98f8f74bc0fe9f2
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Dec 7 13:49:40 2011 -0500
don't prepend RHQ Server resource name with "AS "; include JNP port in RHQ Server resource name; refactor formatServerName() to use a StringBuilder and be more readable
diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASDiscoveryComponent.java
index 185ecff..62b39b6 100644
--- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASDiscoveryComponent.java
+++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASDiscoveryComponent.java
@@ -66,7 +66,7 @@ import org.rhq.plugins.jbossas.util.JnpConfig;
import org.rhq.plugins.jmx.JMXDiscoveryComponent;
/**
- * Discovers JBossAS 3.2.x and 4.x server instances.
+ * Discovers instances of JBoss AS 3.2.3 through 4.2.x, and JBoss EAP and SOA-P 4.x.
*
* @author John Mazzitelli
* @author Ian Springer
@@ -296,8 +296,8 @@ public class JBossASDiscoveryComponent implements ResourceDiscoveryComponent, Ma
final JBossProductType productType = installInfo.getProductType();
String description = productType.DESCRIPTION + " " + installInfo.getMajorVersion();
- boolean isInServer = isRhqServer(absoluteConfigPath);
- if (isInServer) {
+ boolean isRhqServer = isRhqServer(absoluteConfigPath);
+ if (isRhqServer) {
description += " hosting the RHQ Server";
// RHQ-633 : We know this is an RHQ Server. Let's auto-configure for tracking its log file, which is not in
@@ -324,13 +324,13 @@ public class JBossASDiscoveryComponent implements ResourceDiscoveryComponent, Ma
}
}
}
- final String PRODUCT_PREFIX = productType.name() + " ";
- String name = PRODUCT_PREFIX
- + formatServerName(bindingAddress, namingPort, discoveryContext.getSystemInformation().getHostname(),
- absoluteConfigPath.getName(), isInServer);
-
- return new DiscoveredResourceDetails(discoveryContext.getResourceType(), key, name, PRODUCT_PREFIX
- + installInfo.getVersion(), description, pluginConfiguration, processInfo);
+
+ String name = formatServerName(bindingAddress, namingPort, discoveryContext.getSystemInformation().getHostname(),
+ absoluteConfigPath.getName(), productType, isRhqServer);
+ String version = productType.name() + " " + installInfo.getVersion();
+
+ return new DiscoveredResourceDetails(discoveryContext.getResourceType(), key, name, version, description,
+ pluginConfiguration, processInfo);
}
/**
@@ -379,7 +379,8 @@ public class JBossASDiscoveryComponent implements ResourceDiscoveryComponent, Ma
try {
installInfo = new JBossInstallationInfo(homeDir);
} catch (IOException e) {
- throw new IllegalStateException(e);
+ throw new IllegalStateException("Failed to determine installation info for JBoss home dir ["
+ + homeDir + "].", e);
}
File configDir = (File) server.getAttribute(configObjectName, "ServerHomeDir");
@@ -405,51 +406,70 @@ public class JBossASDiscoveryComponent implements ResourceDiscoveryComponent, Ma
// Now set default values on any props that are still not set.
setPluginConfigurationDefaults(pluginConfiguration);
- String resourceName = formatServerName(bindAddress, jnpPort, context.getSystemInformation()
- .getHostname(), configName, isRhqServer(configDir));
+ JBossProductType productType = installInfo.getProductType();
+ String name = formatServerName(bindAddress, jnpPort, context.getSystemInformation().getHostname(),
+ configName, productType, isRhqServer(configDir));
+ String description = productType.NAME +
+ " server that the RHQ Plugin Container is running within";
DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(),
- configDir.getAbsolutePath(), resourceName, version,
- "JBoss AS server that the RHQ Plugin Container is running within", pluginConfiguration, null);
+ configDir.getAbsolutePath(), name, version, description, pluginConfiguration, null);
return resource;
}
} catch (Exception e) {
- /* JBoss MBean doesn't exist - not a JBoss server. */
- if (log.isDebugEnabled())
- log.debug("Not detected to be embedded in a JBoss AS Server", e);
+ // JBoss MBean doesn't exist - not a JBoss server.
+ log.debug("Not detected to be embedded in a JBoss AS Server", e);
}
return null;
}
public String formatServerName(String bindingAddress, String jnpPort, String hostname, String configurationName,
- boolean isRhq) {
+ JBossProductType productType, boolean isRhq) {
+ StringBuilder serverName = new StringBuilder();
+
+ if (!isRhq) {
+ // prefix w/ product name (e.g. "AS" or "EAP")
+ serverName.append(productType.name()).append(' ');
+ }
+
+ String bindingHostname = getBindingHostname(bindingAddress);
+ if (bindingHostname != null) {
+ serverName.append(bindingHostname);
+ } else {
+ serverName.append(hostname);
+ }
+
+ if (jnpPort != null && !jnpPort.equals(CHANGE_ME)) {
+ serverName.append(':').append(jnpPort);
+ }
+ serverName.append(' ');
if (isRhq) {
- return hostname + " RHQ Server";
+ serverName.append("RHQ Server");
} else {
- String hostnameToUse = hostname;
+ serverName.append(configurationName);
+ }
- if (bindingAddress != null) {
- try {
- InetAddress bindAddr = InetAddress.getByName(bindingAddress);
- if (!bindAddr.isAnyLocalAddress()) {
- //if the binding address != 0.0.0.0
- hostnameToUse = bindAddr.getHostName();
- }
- } catch (UnknownHostException e) {
- //this should not happen?
- log.warn("Unknown hostname passed in as the binding address for JBoss AS server discovery: "
- + bindingAddress);
- }
- }
+ return serverName.toString();
+ }
- if (jnpPort != null && !jnpPort.equals(CHANGE_ME)) {
- hostnameToUse += ":" + jnpPort;
+ private String getBindingHostname(String bindingAddress) {
+ String bindingHostname = null;
+ if (bindingAddress != null) {
+ try {
+ InetAddress bindAddr = InetAddress.getByName(bindingAddress);
+ if (!bindAddr.isAnyLocalAddress()) {
+ //if the binding address != 0.0.0.0
+ bindingHostname = bindAddr.getHostName();
+ }
+ } catch (UnknownHostException e) {
+ //this should not happen?
+ log.warn("Unknown hostname passed in as the binding address for JBoss AS instance: "
+ + bindingAddress);
}
-
- return hostnameToUse + " " + configurationName;
}
+ return bindingHostname;
}
private static String getJnpURL(JBossInstanceInfo cmdLine, File installHome, File configDir) {
commit 664dc6e66fc82257d60c51837c495d60f873505f
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Dec 7 13:46:44 2011 -0500
change log messages from INFO to DEBUG to be consistent w/ other plugins
diff --git a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentDiscoveryComponent.java b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentDiscoveryComponent.java
index 0faecf2..bef2731 100644
--- a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentDiscoveryComponent.java
+++ b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentDiscoveryComponent.java
@@ -64,7 +64,7 @@ public class AgentDiscoveryComponent implements ResourceDiscoveryComponent, Reso
* @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext)
*/
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
- log.info("Discovering RHQ Agent...");
+ log.debug("Discovering RHQ Agent...");
HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
diff --git a/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptDiscoveryComponent.java b/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptDiscoveryComponent.java
index eb58227..8cbd84e 100644
--- a/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptDiscoveryComponent.java
+++ b/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptDiscoveryComponent.java
@@ -52,7 +52,7 @@ public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent, Man
private final Log log = LogFactory.getLog(ScriptDiscoveryComponent.class);
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
- log.info("Processing discovered management script resources");
+ log.debug("Processing discovered management script resources...");
HashSet<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>();
12 years, 5 months
[rhq] modules/enterprise
by Heiko W. Rupp
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AbstractRestBean.java | 2 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java | 11 +++++-----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerLocal.java | 3 +-
3 files changed, 8 insertions(+), 8 deletions(-)
New commits:
commit 30e90184edd8660d613fe9feffc94368e4c832f5
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Dec 7 15:55:20 2011 +0100
Don't put @Stateless on the (abstract) super class.
Fix some fallout from refactoring the creation of the aggregate.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AbstractRestBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AbstractRestBean.java
index ce4dd43..ea901d1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AbstractRestBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AbstractRestBean.java
@@ -33,7 +33,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import javax.ejb.Stateless;
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
@@ -63,7 +62,6 @@ import org.rhq.enterprise.server.rest.domain.ResourceWithType;
* For the cache and its evicion policies see rhq-cache-service.xml
* @author Heiko W. Rupp
*/
-@Stateless
@javax.annotation.Resource(name="cache",type= TreeCacheMBean.class,mappedName = "RhqCache")
public class AbstractRestBean {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java
index 5934dbe..99dd6fe 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerBean.java
@@ -133,7 +133,7 @@ public class MetricHandlerBean extends AbstractRestBean implements MetricHandle
res.setMaxTimeStamp(maxTime);
res.setMinTimeStamp(minTime);
*/
- res = fill(list,scheduleId,hideEmpty);
+ fill(res, list,scheduleId,hideEmpty);
}
CacheControl cc = new CacheControl();
@@ -156,10 +156,10 @@ public class MetricHandlerBean extends AbstractRestBean implements MetricHandle
return builder.build();
}
- private MetricAggregate fill(List<MeasurementDataNumericHighLowComposite> list,int scheduleId , boolean hideEmpty) {
+ private MetricAggregate fill(MetricAggregate res, List<MeasurementDataNumericHighLowComposite> list, int scheduleId,
+ boolean hideEmpty) {
long minTime=Long.MAX_VALUE;
long maxTime=0;
- MetricAggregate res = new MetricAggregate();
res.setScheduleId(scheduleId);
for (MeasurementDataNumericHighLowComposite c : list) {
@@ -214,8 +214,9 @@ public class MetricHandlerBean extends AbstractRestBean implements MetricHandle
dataManager.findDataForContext(caller, EntityContext.forResource(sched.getResource().getId()),definitionId,startTime,endTime,dataPoints);
if (!listList.isEmpty()) {
List<MeasurementDataNumericHighLowComposite> list = listList.get(0);
- MetricAggregate ma = fill(list,scheduleId,hideEmpty);
- resList.add(ma);
+ MetricAggregate res = new MetricAggregate();
+ fill(res, list,scheduleId,hideEmpty);
+ resList.add(res);
}
else
throw new StuffNotFoundException("Metrics for schedule " + scheduleId);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerLocal.java
index 7e908ad..6631ef4 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/MetricHandlerLocal.java
@@ -22,6 +22,7 @@ import java.util.List;
import javax.ejb.Local;
import javax.ws.rs.Consumes;
+import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
@@ -54,7 +55,7 @@ public interface MetricHandlerLocal {
Response getMetricData(@PathParam("scheduleId") int scheduleId,
@QueryParam("startTime") long startTime,
@QueryParam("endTime") long endTime,
- @QueryParam("dataPoints") int dataPoints,
+ @QueryParam("dataPoints") @DefaultValue("60") int dataPoints,
@QueryParam("hideEmpty") boolean hideEmpty,
@Context Request request,
@Context HttpHeaders headers);
12 years, 5 months