[rhq] 36 commits - modules/core modules/enterprise
by snegrea
modules/core/dbutils/pom.xml | 949 ++++------
modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java | 139 +
modules/enterprise/gui/installer-war/pom.xml | 1
modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java | 153 +
modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java | 172 -
5 files changed, 762 insertions(+), 652 deletions(-)
New commits:
commit 56627365ac04cd1361448c9694664e3b86c82ebf
Merge: 75ec057 6bcfdeb
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 4 08:31:40 2011 -0500
Merge branch 'stefan/dbreset'
commit 75ec057afa2dd0595ecf95abc669dfcc527f70a5
Merge: 11d7080 cfd9223
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 4 08:31:26 2011 -0500
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 6bcfdeb962f97d9c610bb722dd42111a4f2f0875
Merge: 765585f 19437ca
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 4 08:29:11 2011 -0500
Merge branch 'stefan/dbreset' of ssh://git.fedorahosted.org/git/rhq/rhq into stefan/dbreset
Conflicts:
modules/core/dbutils/pom.xml
diff --cc modules/core/dbutils/pom.xml
index 195b3f3,6a599c0..67de21e
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@@ -545,4 -510,4 +545,8 @@@
</snapshots>
</pluginRepository>
</pluginRepositories>
-</project>
++<<<<<<< HEAD
+</project>
++=======
++</project>
++>>>>>>> 19437cae8ca6ceb053fa191e08dff6368b8574b9
commit 11d70800d0c1dec8adba5c555855eb64a9a6fd21
Merge: b35ba5b 765585f
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 4 08:26:40 2011 -0500
Merge branch 'stefan/dbreset'
commit 765585f603136e217591dda9550ca01d1014c450
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 4 07:44:43 2011 -0500
Throw an exception if trying to use dbreset with anything else other than Oracle and Postgres.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 4736988..ce12786 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -132,5 +132,8 @@ public class DBReset {
}
}
}
+ else {
+ throw new Exception("dbreset not supported for "+ dbTypeMapping +"!");
+ }
}
}
commit 2e31c5013216be0d73287c33431c12c3fc678ad3
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Aug 3 12:23:44 2011 -0500
Forgot to replace three properties with the params after refactoring dbreset.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 9cd49e4..4736988 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -69,6 +69,7 @@ public class DBReset {
public void performDBReset(String dbTypeMapping, String dbUrl, String dbName, String user, String adminUser,
String adminPassword) throws Exception {
if (dbTypeMapping.equals("PostgreSQL")) {
+ System.out.println("PostgreSQL started!");
Connection connection = null;
Statement dropDB = null;
Statement createDB = null;
@@ -95,12 +96,12 @@ public class DBReset {
}
}
- } else if (DB_TYPE_MAPPING.equals("Oracle10g")) {
+ } else if (dbTypeMapping.equals("Oracle10g")) {
Connection connection = null;
PreparedStatement cleanUserStatement = null;
try {
- connection = DbUtil.getConnection(DB_URL, adminUser, ADMIN_PASSWORD);
+ connection = DbUtil.getConnection(dbUrl, adminUser, adminPassword);
connection.setAutoCommit(false);
String plsql = "declare cursor all_objects_to_drop is\n"
commit d72d4e2df7dd69b0523b54b8f8b9cc5ef3f7f6b0
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Aug 2 18:25:57 2011 -0500
DB installation test now uses dbreset to propertly reset the database (even for Oracle configurations).
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 3f99d10..9cd49e4 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -39,14 +39,13 @@ public class DBReset {
private static final String DB_NAME = System.getProperty("rhq.ds.db-name", "rhq_installer_test_db");
private static final String SERVER = System.getProperty("rhq.ds.server-name", "127.0.0.1");
+ private static final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER
+ + ":5432/" + DB_NAME);
private static final String USER = System.getProperty("rhq.ds.user-name", "rhqadmin");
private static final String ADMIN_USER = System.getProperty("rhq.db.admin.username", "postgres");
private static final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
- private static final String DB_RESET = System.getProperty("dbreset", "false");
- private static final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER
- + ":5432/" + DB_NAME);
-
private static final String DB_TYPE_MAPPING = System.getProperty("rhq.ds.type-mapping", "PostgreSQL");
+ private static final String DB_RESET = System.getProperty("dbreset", "false");
/**
* @param args
@@ -67,7 +66,7 @@ public class DBReset {
}
}
- private void performDBReset(String dbTypeMapping, String dbUrl, String dbName, String user, String adminUser,
+ public void performDBReset(String dbTypeMapping, String dbUrl, String dbName, String user, String adminUser,
String adminPassword) throws Exception {
if (dbTypeMapping.equals("PostgreSQL")) {
Connection connection = null;
diff --git a/modules/enterprise/gui/installer-war/pom.xml b/modules/enterprise/gui/installer-war/pom.xml
index 517399c..900d476 100644
--- a/modules/enterprise/gui/installer-war/pom.xml
+++ b/modules/enterprise/gui/installer-war/pom.xml
@@ -147,6 +147,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
+ <rhq.test.ds.type-mapping>${rhq.test.ds.type-mapping}</rhq.test.ds.type-mapping>
<rhq.test.ds.server-name>${rhq.test.ds.server-name}</rhq.test.ds.server-name>
<rhq.test.ds.db-name>${rhq.test.ds.db-name}</rhq.test.ds.db-name>
<rhq.test.ds.connection-url>${rhq.test.ds.connection-url}</rhq.test.ds.connection-url>
diff --git a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java
index 956e25e..6633cb7 100644
--- a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java
+++ b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java
@@ -23,18 +23,18 @@
package org.rhq.enterprise.installer;
-import org.rhq.core.db.DbUtil;
-import org.rhq.core.db.setup.DBSetup;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
import java.io.File;
-import java.net.URI;
import java.net.URL;
-import java.sql.Connection;
-import java.sql.Statement;
import java.util.Properties;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import org.rhq.core.db.reset.DBReset;
+import org.rhq.core.db.setup.DBSetup;
+import org.rhq.enterprise.installer.ServerInformation;
+import org.rhq.enterprise.installer.ServerProperties;
+
/**
* The tests in this class exercise the dbsetup/dbupgrade code that is run in the installer. The tests currently only
* run against postgresql. Support needs to be added for oracle. The tests do not do any post-install/upgrade
@@ -46,13 +46,15 @@ import java.util.Properties;
public class DBInstallationTest {
private final String LOG_DIRECTORY = System.getProperty("java.io.tmpdir", "rhq/installer-test");
- private final String TEST_DB = System.getProperty("rhq.test.ds.db-name","rhq_installer_test_db");
+ private final String DB_NAME = System.getProperty("rhq.test.ds.db-name", "rhq_installer_test_db");
private final String USERNAME = System.getProperty("rhq.test.ds.user-name", "rhqadmin");
private final String PASSWORD = System.getProperty("rhq.test.ds.password", "rhqadmin");
private final String SERVER = System.getProperty("rhq.test.ds.server-name", "127.0.0.1");
- private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
+ private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER
+ + ":5432/" + DB_NAME);
private final String ADMIN_USERNAME = System.getProperty("rhq.db.admin.username", "postgres");
private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
+ private static final String DB_TYPE_MAPPING = System.getProperty("rhq.test.ds.type-mapping", "PostgreSQL");
private ServerInformation installer;
@@ -79,8 +81,8 @@ public class DBInstallationTest {
@Test
public void overwriteJON231Schema() throws Exception {
- installSchemaAndData("2.3.1");
- installer.createNewDatabaseSchema(getInstallProperties());
+ installSchemaAndData("2.3.1");
+ installer.createNewDatabaseSchema(getInstallProperties());
}
@Test
@@ -88,13 +90,13 @@ public class DBInstallationTest {
installSchemaAndData("2.3.1");
installer.upgradeExistingDatabaseSchema(getInstallProperties());
}
-
+
@Test
public void overwriteJON240Schema() throws Exception {
- installSchemaAndData("2.4.0");
- installer.createNewDatabaseSchema(getInstallProperties());
+ installSchemaAndData("2.4.0");
+ installer.createNewDatabaseSchema(getInstallProperties());
}
-
+
@Test
public void upgradeJON240Schema() throws Exception {
installSchemaAndData("2.4.0");
@@ -110,29 +112,8 @@ public class DBInstallationTest {
}
private void recreateTestDatabase() throws Exception {
- Connection connection = null;
- Statement dropDB = null;
- Statement createDB = null;
-
- try {
- connection = DbUtil.getConnection(DB_URL.replace(TEST_DB,"postgres"), ADMIN_USERNAME, ADMIN_PASSWORD);
-
- dropDB = connection.createStatement();
- dropDB.execute("drop database if exists " + TEST_DB);
-
- createDB = connection.createStatement();
- createDB.execute("create database " + TEST_DB + " with owner " + USERNAME);
- } finally {
- if (connection != null) {
- connection.close();
- }
- if (dropDB != null) {
- dropDB.close();
- }
- if (createDB != null) {
- createDB.close();
- }
- }
+ DBReset dbReset = new DBReset();
+ dbReset.performDBReset(DB_TYPE_MAPPING, DB_URL, DB_NAME, USERNAME, ADMIN_USERNAME, ADMIN_PASSWORD);
}
private void installSchemaAndData(String jonVersion) throws Exception {
commit 8cfdf6198fedf0cb3beb3dde17c0ecae2702ca7d
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Aug 2 18:14:51 2011 -0500
Make dbreset configurable to it can be used/consumed by other modules.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 8a32c43..3f99d10 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -37,53 +37,53 @@ import org.rhq.core.db.DbUtil;
public class DBReset {
private static Log log = LogFactory.getLog(DBReset.class);
- private final String DB = System.getProperty("rhq.ds.db-name", "rhq_installer_test_db");
- private final String SERVER = System.getProperty("rhq.ds.server-name", "127.0.0.1");
- private final String USER = System.getProperty("rhq.ds.user-name", "rhqadmin");
- private final String ADMIN_USER = System.getProperty("rhq.db.admin.username", "postgres");
- private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
- private final String DB_RESET = System.getProperty("dbreset", "false");
- private final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"
- + DB);
+ private static final String DB_NAME = System.getProperty("rhq.ds.db-name", "rhq_installer_test_db");
+ private static final String SERVER = System.getProperty("rhq.ds.server-name", "127.0.0.1");
+ private static final String USER = System.getProperty("rhq.ds.user-name", "rhqadmin");
+ private static final String ADMIN_USER = System.getProperty("rhq.db.admin.username", "postgres");
+ private static final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
+ private static final String DB_RESET = System.getProperty("dbreset", "false");
+ private static final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER
+ + ":5432/" + DB_NAME);
- private final String DB_TYPE_MAPPING = System.getProperty("rhq.ds.type-mapping", "PostgreSQL");
+ private static final String DB_TYPE_MAPPING = System.getProperty("rhq.ds.type-mapping", "PostgreSQL");
/**
* @param args
*/
public static void main(String[] args) {
+ if (DB_RESET.equals("false")) {
+ return;
+ }
+
DBReset dbreset = new DBReset();
try {
- dbreset.performDBReset();
+ dbreset.performDBReset(DB_TYPE_MAPPING, DB_URL, DB_NAME, USER, ADMIN_USER, ADMIN_PASSWORD);
+ System.setProperty("dbsetup", "true");
} catch (Exception e) {
log.info(e);
System.exit(1);
}
}
- private void performDBReset() throws Exception {
- if (DB_RESET.equals("false")) {
- return;
- }
-
- System.setProperty("dbsetup", "true");
-
- if (DB_TYPE_MAPPING.equals("PostgreSQL")) {
+ private void performDBReset(String dbTypeMapping, String dbUrl, String dbName, String user, String adminUser,
+ String adminPassword) throws Exception {
+ if (dbTypeMapping.equals("PostgreSQL")) {
Connection connection = null;
Statement dropDB = null;
Statement createDB = null;
try {
- connection = DbUtil.getConnection(DB_URL.replace(DB, "postgres"), ADMIN_USER, ADMIN_PASSWORD);
+ connection = DbUtil.getConnection(dbUrl.replace(dbName, "postgres"), adminUser, adminPassword);
dropDB = connection.createStatement();
- dropDB.execute("drop database if exists " + DB);
+ dropDB.execute("drop database if exists " + dbName);
createDB = connection.createStatement();
- createDB.execute("create database " + DB + " with owner " + USER);
+ createDB.execute("create database " + dbName + " with owner " + user);
- log.info("Dropped and created database " + DB + ".");
+ log.info("Dropped and created postgres database " + dbName + ".");
} finally {
if (dropDB != null) {
dropDB.close();
@@ -101,7 +101,7 @@ public class DBReset {
PreparedStatement cleanUserStatement = null;
try {
- connection = DbUtil.getConnection(DB_URL, ADMIN_USER, ADMIN_PASSWORD);
+ connection = DbUtil.getConnection(DB_URL, adminUser, ADMIN_PASSWORD);
connection.setAutoCommit(false);
String plsql = "declare cursor all_objects_to_drop is\n"
@@ -118,12 +118,11 @@ public class DBReset {
+ " end;\n"
+ " end loop;\n"
+ " end;\n";
- log.info(plsql);
cleanUserStatement = connection.prepareStatement(plsql);
cleanUserStatement.execute();
connection.commit();
- log.info("Cleand database " + DB + ".");
+ log.info("Cleaned Oracle database " + dbName + ".");
} finally {
if (cleanUserStatement != null) {
cleanUserStatement.close();
commit 2b3d20a842caeae3c463dd1aa8ecb9554f8c545e
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 21:21:07 2011 -0500
Removing extra character inserted inadvertently.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index f0113c8..195b3f3 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -200,7 +200,7 @@
<rhq.ds.db-name>${rhq.dev.ds.db-name}</rhq.ds.db-name>
<rhq.ds.connection-url>${rhq.dev.ds.connection-url}</rhq.ds.connection-url>
<rhq.ds.user-name>${rhq.dev.ds.user-name}</rhq.ds.user-name>
- <rhq.ds.password>${rhq.dev.ds.password}></rhq.ds.password>
+ <rhq.ds.password>${rhq.dev.ds.password}</rhq.ds.password>
<rhq.ds.driver-class>${rhq.dev.ds.driver-class}</rhq.ds.driver-class>
</properties>
</profile>
commit b379d494894d0e40449f6296349143dc1a07ca31
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 18:50:28 2011 -0500
Correct the class file name.
diff --git a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java
new file mode 100644
index 0000000..956e25e
--- /dev/null
+++ b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java
@@ -0,0 +1,172 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.installer;
+
+import org.rhq.core.db.DbUtil;
+import org.rhq.core.db.setup.DBSetup;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.util.Properties;
+
+/**
+ * The tests in this class exercise the dbsetup/dbupgrade code that is run in the installer. The tests currently only
+ * run against postgresql. Support needs to be added for oracle. The tests do not do any post-install/upgrade
+ * verification at the time of this writing. They just simply exercise the dbsetup/dbupgrade scripts to ensure that
+ * they do not contain any errors.
+ *
+ * @author John Sanda
+ */
+public class DBInstallationTest {
+
+ private final String LOG_DIRECTORY = System.getProperty("java.io.tmpdir", "rhq/installer-test");
+ private final String TEST_DB = System.getProperty("rhq.test.ds.db-name","rhq_installer_test_db");
+ private final String USERNAME = System.getProperty("rhq.test.ds.user-name", "rhqadmin");
+ private final String PASSWORD = System.getProperty("rhq.test.ds.password", "rhqadmin");
+ private final String SERVER = System.getProperty("rhq.test.ds.server-name", "127.0.0.1");
+ private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
+ private final String ADMIN_USERNAME = System.getProperty("rhq.db.admin.username", "postgres");
+ private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
+
+ private ServerInformation installer;
+
+ @BeforeMethod
+ public void prepareForInstallation() throws Exception {
+ initLogDirectory();
+ recreateTestDatabase();
+
+ installer = new ServerInformation();
+ installer.setLogDirectory(new File(LOG_DIRECTORY));
+ }
+
+ @Test
+ public void overwriteJON230Schema() throws Exception {
+ installSchemaAndData("2.3.0");
+ installer.createNewDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void upgradeJON230Schema() throws Exception {
+ installSchemaAndData("2.3.0");
+ installer.upgradeExistingDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void overwriteJON231Schema() throws Exception {
+ installSchemaAndData("2.3.1");
+ installer.createNewDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void upgradeJON231Schema() throws Exception {
+ installSchemaAndData("2.3.1");
+ installer.upgradeExistingDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void overwriteJON240Schema() throws Exception {
+ installSchemaAndData("2.4.0");
+ installer.createNewDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void upgradeJON240Schema() throws Exception {
+ installSchemaAndData("2.4.0");
+ installer.upgradeExistingDatabaseSchema(getInstallProperties());
+ }
+
+ private void initLogDirectory() {
+ File logDir = new File(LOG_DIRECTORY);
+ if (logDir.exists()) {
+ logDir.delete();
+ }
+ logDir.mkdirs();
+ }
+
+ private void recreateTestDatabase() throws Exception {
+ Connection connection = null;
+ Statement dropDB = null;
+ Statement createDB = null;
+
+ try {
+ connection = DbUtil.getConnection(DB_URL.replace(TEST_DB,"postgres"), ADMIN_USERNAME, ADMIN_PASSWORD);
+
+ dropDB = connection.createStatement();
+ dropDB.execute("drop database if exists " + TEST_DB);
+
+ createDB = connection.createStatement();
+ createDB.execute("create database " + TEST_DB + " with owner " + USERNAME);
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
+ if (dropDB != null) {
+ dropDB.close();
+ }
+ if (createDB != null) {
+ createDB.close();
+ }
+ }
+ }
+
+ private void installSchemaAndData(String jonVersion) throws Exception {
+ DBSetup dbsetup = new DBSetup(DB_URL, USERNAME, PASSWORD);
+ dbsetup.setup(getSchemaFile(jonVersion).getAbsolutePath());
+ dbsetup.setup(getDataFile(jonVersion).getAbsolutePath());
+ }
+
+ private File getSchemaFile(String version) throws Exception {
+ URL url = getClass().getResource("db-schema-combined-" + version + ".xml");
+
+ if (url == null) {
+ throw new RuntimeException("Failed to find schema file for version " + version);
+ }
+
+ return new File(url.toURI().getPath());
+ }
+
+ private File getDataFile(String version) throws Exception {
+ URL url = getClass().getResource("db-data-combined-" + version + ".xml");
+
+ if (url == null) {
+ throw new RuntimeException("Failed to find data file for version " + version);
+ }
+
+ return new File(url.toURI().getPath());
+ }
+
+ private Properties getInstallProperties() {
+ Properties dbProperties = new Properties();
+ dbProperties.put(ServerProperties.PROP_DATABASE_CONNECTION_URL, DB_URL);
+ dbProperties.put(ServerProperties.PROP_DATABASE_USERNAME, USERNAME);
+ dbProperties.put(ServerProperties.PROP_DATABASE_PASSWORD, PASSWORD);
+ dbProperties.put(ServerProperties.PROP_EMAIL_FROM_ADDRESS, "rhqadmin(a)localhost.com");
+ return dbProperties;
+ }
+}
diff --git a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
deleted file mode 100644
index 579bebf..0000000
--- a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.rhq.enterprise.installer;
-
-import org.rhq.core.db.DbUtil;
-import org.rhq.core.db.setup.DBSetup;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.io.File;
-import java.net.URI;
-import java.net.URL;
-import java.sql.Connection;
-import java.sql.Statement;
-import java.util.Properties;
-
-/**
- * The tests in this class exercise the dbsetup/dbupgrade code that is run in the installer. The tests currently only
- * run against postgresql. Support needs to be added for oracle. The tests do not do any post-install/upgrade
- * verification at the time of this writing. They just simply exercise the dbsetup/dbupgrade scripts to ensure that
- * they do not contain any errors.
- *
- * @author John Sanda
- */
-public class DBInstallatonTest {
-
- private final String LOG_DIRECTORY = System.getProperty("java.io.tmpdir", "rhq/installer-test");
- private final String TEST_DB = System.getProperty("rhq.test.ds.db-name","rhq_installer_test_db");
- private final String USERNAME = System.getProperty("rhq.test.ds.user-name", "rhqadmin");
- private final String PASSWORD = System.getProperty("rhq.test.ds.password", "rhqadmin");
- private final String SERVER = System.getProperty("rhq.test.ds.server-name", "127.0.0.1");
- private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
- private final String ADMIN_USERNAME = System.getProperty("rhq.db.admin.username", "postgres");
- private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
-
- private ServerInformation installer;
-
- @BeforeMethod
- public void prepareForInstallation() throws Exception {
- initLogDirectory();
- recreateTestDatabase();
-
- installer = new ServerInformation();
- installer.setLogDirectory(new File(LOG_DIRECTORY));
- }
-
- @Test
- public void overwriteJON230Schema() throws Exception {
- installSchemaAndData("2.3.0");
- installer.createNewDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void upgradeJON230Schema() throws Exception {
- installSchemaAndData("2.3.0");
- installer.upgradeExistingDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void overwriteJON231Schema() throws Exception {
- installSchemaAndData("2.3.1");
- installer.createNewDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void upgradeJON231Schema() throws Exception {
- installSchemaAndData("2.3.1");
- installer.upgradeExistingDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void overwriteJON240Schema() throws Exception {
- installSchemaAndData("2.4.0");
- installer.createNewDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void upgradeJON240Schema() throws Exception {
- installSchemaAndData("2.4.0");
- installer.upgradeExistingDatabaseSchema(getInstallProperties());
- }
-
- private void initLogDirectory() {
- File logDir = new File(LOG_DIRECTORY);
- if (logDir.exists()) {
- logDir.delete();
- }
- logDir.mkdirs();
- }
-
- private void recreateTestDatabase() throws Exception {
- Connection connection = null;
- Statement dropDB = null;
- Statement createDB = null;
-
- try {
- connection = DbUtil.getConnection(DB_URL.replace(TEST_DB,"postgres"), ADMIN_USERNAME, ADMIN_PASSWORD);
-
- dropDB = connection.createStatement();
- dropDB.execute("drop database if exists " + TEST_DB);
-
- createDB = connection.createStatement();
- createDB.execute("create database " + TEST_DB + " with owner " + USERNAME);
- } finally {
- if (connection != null) {
- connection.close();
- }
- if (dropDB != null) {
- dropDB.close();
- }
- if (createDB != null) {
- createDB.close();
- }
- }
- }
-
- private void installSchemaAndData(String jonVersion) throws Exception {
- DBSetup dbsetup = new DBSetup(DB_URL, USERNAME, PASSWORD);
- dbsetup.setup(getSchemaFile(jonVersion).getAbsolutePath());
- dbsetup.setup(getDataFile(jonVersion).getAbsolutePath());
- }
-
- private File getSchemaFile(String version) throws Exception {
- URL url = getClass().getResource("db-schema-combined-" + version + ".xml");
-
- if (url == null) {
- throw new RuntimeException("Failed to find schema file for version " + version);
- }
-
- return new File(url.toURI().getPath());
- }
-
- private File getDataFile(String version) throws Exception {
- URL url = getClass().getResource("db-data-combined-" + version + ".xml");
-
- if (url == null) {
- throw new RuntimeException("Failed to find data file for version " + version);
- }
-
- return new File(url.toURI().getPath());
- }
-
- private Properties getInstallProperties() {
- Properties dbProperties = new Properties();
- dbProperties.put(ServerProperties.PROP_DATABASE_CONNECTION_URL, DB_URL);
- dbProperties.put(ServerProperties.PROP_DATABASE_USERNAME, USERNAME);
- dbProperties.put(ServerProperties.PROP_DATABASE_PASSWORD, PASSWORD);
- dbProperties.put(ServerProperties.PROP_EMAIL_FROM_ADDRESS, "rhqadmin(a)localhost.com");
- return dbProperties;
- }
-}
commit 7da61116768d389fe16039fe0d54054117941ad3
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 17:07:07 2011 -0500
Adding driver class to the property list.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 737150e..f0113c8 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -201,6 +201,7 @@
<rhq.ds.connection-url>${rhq.dev.ds.connection-url}</rhq.ds.connection-url>
<rhq.ds.user-name>${rhq.dev.ds.user-name}</rhq.ds.user-name>
<rhq.ds.password>${rhq.dev.ds.password}></rhq.ds.password>
+ <rhq.ds.driver-class>${rhq.dev.ds.driver-class}</rhq.ds.driver-class>
</properties>
</profile>
commit 14facab3f9eaf5eb0de00e3b371626be1ee4d4a1
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 16:33:35 2011 -0500
Move conditional properties to maven profiles. This reduces code duplication and makes the pom smaller and more manageable.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index ce2a418..737150e 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -187,6 +187,24 @@
<profiles>
<profile>
+ <id>db.dev</id>
+ <activation>
+ <property>
+ <name>db</name>
+ <value>dev</value>
+ </property>
+ </activation>
+
+ <properties>
+ <rhq.ds.type-mapping>${rhq.dev.ds.type-mapping}</rhq.ds.type-mapping>
+ <rhq.ds.db-name>${rhq.dev.ds.db-name}</rhq.ds.db-name>
+ <rhq.ds.connection-url>${rhq.dev.ds.connection-url}</rhq.ds.connection-url>
+ <rhq.ds.user-name>${rhq.dev.ds.user-name}</rhq.ds.user-name>
+ <rhq.ds.password>${rhq.dev.ds.password}></rhq.ds.password>
+ </properties>
+ </profile>
+
+ <profile>
<id>latest</id>
<activation>
<property>
@@ -221,18 +239,6 @@
<phase>test</phase>
<configuration>
<tasks>
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
@@ -264,18 +270,6 @@
<configuration>
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
@@ -305,21 +299,6 @@
<configuration>
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
@@ -367,18 +346,6 @@
<configuration>
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="create-release-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
commit 6443467dcca7a2185fb611ca422bef23156a7a1f
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 15:50:19 2011 -0500
Complete format of the pom file to make it easier to read.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 7ccc00e..ce2a418 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -85,96 +85,117 @@
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
- <version>${postgresql.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.1</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <phase>process-classes</phase>
- <goals>
- <goal>java</goal>
- </goals>
- <configuration>
- <mainClass>org.rhq.core.db.reset.DBReset</mainClass>
- <systemProperties>
- <systemProperty>
- <key>rhq.ds.type-mapping</key>
- <value>${rhq.ds.type-mapping}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.server-name</key>
- <value>${rhq.ds.server-name}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.db-name</key>
- <value>${rhq.ds.db-name}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.connection-url</key>
- <value>${rhq.ds.connection-url}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.db.admin.username</key>
- <value>${rhq.db.admin.username}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.db.admin.password</key>
- <value>${rhq.db.admin.password}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.user-name</key>
- <value>${rhq.ds.user-name}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.password</key>
- <value>${rhq.ds.password}</value>
- </systemProperty>
- </systemProperties>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemProperties>
- <property>
- <name>DatabaseTest.nofail</name>
- <value>${DatabaseTest.nofail}</value>
- </property>
- <property>
- <name>AntDatabaseTest.test-resources</name>
- <value>${basedir}/src/test/resources</value>
- </property>
- </systemProperties>
- <!-- The below is required for tests to run against Oracle. -->
- <additionalClasspathElements>
- <additionalClasspathElement>${settings.localRepository}/com/oracle/ojdbc5/${ojdbc5.version}/ojdbc5-${ojdbc5.version}.jar</additionalClasspathElement>
- </additionalClasspathElements>
- </configuration>
- </plugin>
-
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>latest</id>
- <activation>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>net.sourceforge.jtds</groupId>
+ <artifactId>jtds</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2</version>
+ <dependencies>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>${postgresql.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ <configuration>
+ <mainClass>org.rhq.core.db.reset.DBReset</mainClass>
+ <systemProperties>
+ <systemProperty>
+ <key>rhq.ds.type-mapping</key>
+ <value>${rhq.ds.type-mapping}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.server-name</key>
+ <value>${rhq.ds.server-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.db-name</key>
+ <value>${rhq.ds.db-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.connection-url</key>
+ <value>${rhq.ds.connection-url}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.db.admin.username</key>
+ <value>${rhq.db.admin.username}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.db.admin.password</key>
+ <value>${rhq.db.admin.password}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.user-name</key>
+ <value>${rhq.ds.user-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.password</key>
+ <value>${rhq.ds.password}</value>
+ </systemProperty>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>DatabaseTest.nofail</name>
+ <value>${DatabaseTest.nofail}</value>
+ </property>
+ <property>
+ <name>AntDatabaseTest.test-resources</name>
+ <value>${basedir}/src/test/resources</value>
+ </property>
+ </systemProperties>
+ <!-- The below is required for tests to run against Oracle. -->
+ <additionalClasspathElements>
+ <additionalClasspathElement>${settings.localRepository}/com/oracle/ojdbc5/${ojdbc5.version}/ojdbc5-${ojdbc5.version}.jar</additionalClasspathElement>
+ </additionalClasspathElements>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>latest</id>
+ <activation>
<property>
<name>!jon.release</name>
</property>
</activation>
-
<build>
<plugins>
- <plugin>
+ <plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
@@ -183,7 +204,6 @@
<tasks>
<!-- generate the I18N resource bundles -->
<taskdef name="i18n" classpathref="maven.runtime.classpath" classname="mazz.i18n.ant.I18NAntTask" />
-
<i18n outputdir="${project.build.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true">
<classpath refid="maven.runtime.classpath" />
<classfileset dir="${project.build.outputDirectory}">
@@ -196,396 +216,365 @@
<goal>run</goal>
</goals>
</execution>
-
<execution>
<id>dbsetup-worker</id>
<phase>test</phase>
<configuration>
- <tasks>
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- <property name="dbsetup" value="${dbsetup}" />
- <property name="dbsetup-uninstall" value="${dbsetup-uninstall}" />
- <property name="dbsetup-upgrade" value="${dbsetup-upgrade}" />
- <property name="dbsetup-export" value="${dbsetup-export}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>generate-dbsetup-dbupgrade-xml-files</id>
- <phase>process-classes</phase>
- <configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <!--
- This execution will abort the build if the database schema is not up to date.
- If you want the build to continue, regardless of your currently installed schema,
- then pass -Ddbsetup-do-not-check-schema to the mvn command line.
- -->
- <id>test-db-schema-version</id>
- <phase>test</phase>
- <configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
+ <tasks>
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ <property name="dbsetup" value="${dbsetup}" />
+ <property name="dbsetup-uninstall" value="${dbsetup-uninstall}" />
+ <property name="dbsetup-upgrade" value="${dbsetup-upgrade}" />
+ <property name="dbsetup-export" value="${dbsetup-export}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>generate-dbsetup-dbupgrade-xml-files</id>
+ <phase>process-classes</phase>
+ <configuration>
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <!-- This execution will abort the build if the database schema is not up to date. If you want the build to continue, regardless of your currently installed
+ schema, then pass -Ddbsetup-do-not-check-schema to the mvn command line. -->
+ <id>test-db-schema-version</id>
+ <phase>test</phase>
+ <configuration>
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
+ <property name="dbsetup-do-not-check-schema" value="${dbsetup-do-not-check-schema}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
- <property name="dbsetup-do-not-check-schema" value="${dbsetup-do-not-check-schema}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>jon.release</id>
- <activation>
- <property>
- <name>jon.release</name>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-schema</id>
- <phase>test</phase>
- <configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="create-release-schema">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- <property name="jon.release" value="${jon.release}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>dev</id>
-
- <properties>
- <rhq.rootDir>../../..</rhq.rootDir>
- <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
- <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/lib</rhq.deploymentDir>
- </properties>
-
- <build>
- <plugins>
-
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.1</version>
- <executions>
-
- <execution>
- <id>deploy</id>
- <phase>compile</phase>
- <configuration>
- <tasks>
- <mkdir dir="${rhq.deploymentDir}" />
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Updating ${deployment.file}...</echo>
- <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>undeploy</id>
- <phase>clean</phase>
- <configuration>
- <tasks>
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Deleting ${deployment.file}...</echo>
- <delete file="${deployment.file}" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- </executions>
- </plugin>
-
- </plugins>
- </build>
- </profile>
- <profile>
- <id>cobertura</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>net.sourceforge.cobertura</groupId>
- <artifactId>cobertura</artifactId>
- <version>${cobertura.version}</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <id>cobertura-instrument</id>
- <phase>process-test-classes</phase>
- <configuration>
- <tasks>
- <!-- prepare directory structure for cobertura-->
- <mkdir dir="target/cobertura" />
- <mkdir dir="target/cobertura/backup" />
- <!-- backup all classes so that we can instrument the original classes-->
- <copy toDir="target/cobertura/backup" verbose="true" overwrite="true">
- <fileset dir="target/classes">
- <include name="**/*.class" />
- </fileset>
- </copy>
- <!-- create a properties file and save there location of cobertura data file-->
- <touch file="target/classes/cobertura.properties" />
- <echo file="target/classes/cobertura.properties">net.sourceforge.cobertura.datafile=${project.build.directory}/cobertura/cobertura.ser</echo>
- <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
- <!-- instrument all classes in target/classes directory -->
- <cobertura-instrument datafile="${project.build.directory}/cobertura/cobertura.ser" todir="${project.build.directory}/classes">
- <fileset dir="${project.build.directory}/classes">
- <include name="**/*.class" />
- </fileset>
- </cobertura-instrument>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- <execution>
- <id>cobertura-report</id>
- <phase>prepare-package</phase>
- <configuration>
- <tasks>
- <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
- <!-- prepare directory structure for cobertura-->
- <mkdir dir="target/cobertura" />
- <mkdir dir="target/site/cobertura" />
- <!-- restore classes from backup folder to classes folder -->
- <copy toDir="target/classes" verbose="true" overwrite="true">
- <fileset dir="target/cobertura/backup">
- <include name="**/*.class" />
- </fileset>
- </copy>
- <!-- delete backup folder-->
- <delete dir="target/cobertura/backup" />
- <!-- create a code coverage report -->
- <cobertura-report format="html" datafile="${project.build.directory}/cobertura/cobertura.ser" destdir="${project.build.directory}/site/cobertura">
- <fileset dir="${basedir}/src/main/java">
- <include name="**/*.java" />
- </fileset>
- </cobertura-report>
- <!-- delete cobertura.properties file -->
- <delete file="target/classes/cobertura.properties" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>ojdbc-driver</id>
- <dependencies>
- <dependency>
- <groupId>com.oracle</groupId>
- <artifactId>ojdbc5</artifactId>
- <version>${ojdbc5.version}</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.2</version>
- <dependencies>
- <dependency>
- <groupId>com.oracle</groupId>
- <artifactId>ojdbc5</artifactId>
- <version>${ojdbc5.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
- </profile>
+ <profile>
+ <id>jon.release</id>
+ <activation>
+ <property>
+ <name>jon.release</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-schema</id>
+ <phase>test</phase>
+ <configuration>
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="create-release-schema">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ <property name="jon.release" value="${jon.release}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>dev</id>
+ <properties>
+ <rhq.rootDir>../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/lib</rhq.deploymentDir>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${rhq.deploymentDir}" />
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>cobertura</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>net.sourceforge.cobertura</groupId>
+ <artifactId>cobertura</artifactId>
+ <version>${cobertura.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>cobertura-instrument</id>
+ <phase>process-test-classes</phase>
+ <configuration>
+ <tasks>
+ <!-- prepare directory structure for cobertura -->
+ <mkdir dir="target/cobertura" />
+ <mkdir dir="target/cobertura/backup" />
+ <!-- backup all classes so that we can instrument the original classes -->
+ <copy toDir="target/cobertura/backup" verbose="true" overwrite="true">
+ <fileset dir="target/classes">
+ <include name="**/*.class" />
+ </fileset>
+ </copy>
+ <!-- create a properties file and save there location of cobertura data file -->
+ <touch file="target/classes/cobertura.properties" />
+ <echo file="target/classes/cobertura.properties">net.sourceforge.cobertura.datafile=${project.build.directory}/cobertura/cobertura.ser</echo>
+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
+ <!-- instrument all classes in target/classes directory -->
+ <cobertura-instrument datafile="${project.build.directory}/cobertura/cobertura.ser" todir="${project.build.directory}/classes">
+ <fileset dir="${project.build.directory}/classes">
+ <include name="**/*.class" />
+ </fileset>
+ </cobertura-instrument>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>cobertura-report</id>
+ <phase>prepare-package</phase>
+ <configuration>
+ <tasks>
+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
+ <!-- prepare directory structure for cobertura -->
+ <mkdir dir="target/cobertura" />
+ <mkdir dir="target/site/cobertura" />
+ <!-- restore classes from backup folder to classes folder -->
+ <copy toDir="target/classes" verbose="true" overwrite="true">
+ <fileset dir="target/cobertura/backup">
+ <include name="**/*.class" />
+ </fileset>
+ </copy>
+ <!-- delete backup folder -->
+ <delete dir="target/cobertura/backup" />
+ <!-- create a code coverage report -->
+ <cobertura-report format="html" datafile="${project.build.directory}/cobertura/cobertura.ser" destdir="${project.build.directory}/site/cobertura">
+ <fileset dir="${basedir}/src/main/java">
+ <include name="**/*.java" />
+ </fileset>
+ </cobertura-report>
+ <!-- delete cobertura.properties file -->
+ <delete file="target/classes/cobertura.properties" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>ojdbc-driver</id>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc5</artifactId>
+ <version>${ojdbc5.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2</version>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc5</artifactId>
+ <version>${ojdbc5.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
-
- <pluginRepositories>
- <pluginRepository>
- <id>codehaus-snapshots</id>
- <name>codehaus snapshots</name>
- <url>http://snapshots.repository.codehaus.org</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </pluginRepository>
- </pluginRepositories>
-
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>codehaus-snapshots</id>
+ <name>codehaus snapshots</name>
+ <url>http://snapshots.repository.codehaus.org</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
</project>
-
commit 4a324ffa1c27cc0330e2f79e1f188164f691916e
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 15:44:22 2011 -0500
Stray changes from one more file reverted properly.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 06f1495..7ccc00e 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -35,13 +35,12 @@
<version>1.6.5</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
-
<dependency>
<groupId>ant</groupId>
<artifactId>ant-launcher</artifactId>
@@ -167,48 +166,54 @@
<profiles>
<profile>
<id>latest</id>
- <activation>
- <property>
- <name>!jon.release</name>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <phase>process-classes</phase>
- <configuration>
- <tasks>
- <!-- generate the I18N resource bundles -->
- <taskdef name="i18n" classpathref="maven.runtime.classpath" classname="mazz.i18n.ant.I18NAntTask" />
-
- <i18n outputdir="${project.build.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true">
- <classpath refid="maven.runtime.classpath" />
- <classfileset dir="${project.build.outputDirectory}">
- <include name="**/*I18NResourceKeys.class" />
- </classfileset>
- </i18n>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>dbsetup-worker</id>
- <phase>test</phase>
- <configuration>
+ <activation>
+ <property>
+ <name>!jon.release</name>
+ </property>
+ </activation>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <configuration>
+ <tasks>
+ <!-- generate the I18N resource bundles -->
+ <taskdef name="i18n" classpathref="maven.runtime.classpath" classname="mazz.i18n.ant.I18NAntTask" />
+
+ <i18n outputdir="${project.build.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true">
+ <classpath refid="maven.runtime.classpath" />
+ <classfileset dir="${project.build.outputDirectory}">
+ <include name="**/*I18NResourceKeys.class" />
+ </classfileset>
+ </i18n>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>dbsetup-worker</id>
+ <phase>test</phase>
+ <configuration>
<tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}"/>
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}"/>
- <property name="rhq.ds.password" value="${rhq.ds.password}"/>
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -243,21 +248,21 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
<equals arg1="${db}" arg2="dev" />
- </condition>
+ </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
<equals arg1="${db}" arg2="dev" />
- </condition>
+ </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
<equals arg1="${db}" arg2="dev" />
- </condition>
+ </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
<equals arg1="${db}" arg2="dev" />
- </condition>
+ </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -289,50 +294,50 @@
-->
<id>test-db-schema-version</id>
<phase>test</phase>
- <configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
- <property name="dbsetup-do-not-check-schema" value="${dbsetup-do-not-check-schema}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
+ <configuration>
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
+ <property name="dbsetup-do-not-check-schema" value="${dbsetup-do-not-check-schema}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
<goal>run</goal>
</goals>
</execution>
@@ -361,7 +366,7 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
<equals arg1="${db}" arg2="dev" />
</condition>
@@ -391,7 +396,7 @@
<property name="rhq.ds.password" value="${rhq.ds.password}" />
<property name="project.version" value="${project.version}" />
<property name="db.schema.version" value="${db.schema.version}" />
- <property name="jon.release" value="${jon.release}" />
+ <property name="jon.release" value="${jon.release}" />
</ant>
</tasks>
</configuration>
commit 00b4d34c6e87a4341ccdfc2c322ae711d687909c
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 28 13:46:24 2011 -0500
Revert "Updating the code to use only one set of datasource settings. (rhq.ds.name-of-setting)"
This reverts commit 1876436d7ba7d977e7b4abfcbf223a3fb202e746.
Conflicts:
modules/core/dbutils/pom.xml
diff --git a/etc/m2/settings-bugfixes.xml b/etc/m2/settings-bugfixes.xml
index 01f3173..b64aac6 100644
--- a/etc/m2/settings-bugfixes.xml
+++ b/etc/m2/settings-bugfixes.xml
@@ -28,8 +28,8 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.bugfixes</id>
<properties>
- <rhq.ds.db-name>rhqbugfixes</rhq.ds.db-name>
- <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqbugfixes</rhq.ds.connection-url>
+ <rhq.test.ds.db-name>rhqbugfixes</rhq.test.ds.db-name>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqbugfixes</rhq.test.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings-content.xml b/etc/m2/settings-content.xml
index 3009f75..806006b 100644
--- a/etc/m2/settings-content.xml
+++ b/etc/m2/settings-content.xml
@@ -33,7 +33,7 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.content</id>
<properties>
- <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqcontent</rhq.ds.connection-url>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqcontent</rhq.test.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings-linux-config.xml b/etc/m2/settings-linux-config.xml
index 6605f33..dd464f7 100644
--- a/etc/m2/settings-linux-config.xml
+++ b/etc/m2/settings-linux-config.xml
@@ -28,7 +28,7 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.linux-config</id>
<properties>
- <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqlconf</rhq.ds.connection-url>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqlconf</rhq.test.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings-rawconfig.xml b/etc/m2/settings-rawconfig.xml
index f64b717..f871d66 100644
--- a/etc/m2/settings-rawconfig.xml
+++ b/etc/m2/settings-rawconfig.xml
@@ -28,8 +28,8 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.rawconfig</id>
<properties>
- <rhq.ds.db-name>rhqrawconfig</rhq.ds.db-name>
- <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqrawconfig</rhq.ds.connection-url>
+ <rhq.test.ds.db-name>rhqrawconfig</rhq.test.ds.db-name>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqrawconfig</rhq.test.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings.xml b/etc/m2/settings.xml
index 89c26f2..8c0dada 100644
--- a/etc/m2/settings.xml
+++ b/etc/m2/settings.xml
@@ -91,21 +91,31 @@
<profile>
<id>postgres</id>
<properties>
- <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhq</rhq.ds.connection-url>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
- <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
- <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.server-name>127.0.0.1</rhq.ds.server-name>
- <rhq.ds.port>5432</rhq.ds.port>
- <rhq.ds.db-name>rhq</rhq.ds.db-name>
- <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhq</rhq.test.ds.connection-url>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
+ <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
+ <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.server-name>127.0.0.1</rhq.test.ds.server-name>
+ <rhq.test.ds.port>5432</rhq.test.ds.port>
+ <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
+ <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
+ <rhq.dev.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhq</rhq.dev.ds.connection-url>
+ <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
+ <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
+ <rhq.dev.ds.type-mapping>PostgreSQL</rhq.dev.ds.type-mapping>
+ <rhq.dev.ds.driver-class>org.postgresql.Driver</rhq.dev.ds.driver-class>
+ <rhq.dev.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.dev.ds.xa-datasource-class>
+ <rhq.dev.ds.server-name>127.0.0.1</rhq.dev.ds.server-name>
+ <rhq.dev.ds.port>5432</rhq.dev.ds.port>
+ <rhq.dev.ds.db-name>rhq</rhq.dev.ds.db-name>
+ <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.dev.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.dev.quartz.selectWithLockSQL>
@@ -116,22 +126,33 @@
<profile>
<id>h2</id>
<properties>
- <rhq.ds.driver-class>org.h2.Driver</rhq.ds.driver-class>
- <rhq.ds.connection-url>jdbc:h2:~/rhq;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOG=2</rhq.ds.connection-url>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.type-mapping>h2</rhq.ds.type-mapping>
- <rhq.ds.xa-datasource-class>org.h2.jdbcx.JdbcDataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.server-name>127.0.0.1</rhq.ds.server-name>
- <rhq.ds.port>9092</rhq.ds.port>
- <rhq.ds.db-name>rhq</rhq.ds.db-name>
+ <rhq.test.ds.driver-class>org.h2.Driver</rhq.test.ds.driver-class>
+ <rhq.test.ds.connection-url>jdbc:h2:~/rhq;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOG=2</rhq.test.ds.connection-url>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>h2</rhq.test.ds.type-mapping>
+ <rhq.test.ds.xa-datasource-class>org.h2.jdbcx.JdbcDataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.server-name>127.0.0.1</rhq.test.ds.server-name>
+ <rhq.test.ds.port>9092</rhq.test.ds.port>
+ <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
<!-- This custom dialect is required for proper operation using H2, see class JavaDoc for more info -->
- <rhq.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.test.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.StdJDBCDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
-
+
+ <rhq.dev.ds.driver-class>org.h2.Driver</rhq.dev.ds.driver-class>
+ <rhq.dev.ds.connection-url>jdbc:h2:~/rhq;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOG=2</rhq.dev.ds.connection-url>
+ <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
+ <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
+ <rhq.dev.ds.type-mapping>h2</rhq.dev.ds.type-mapping>
+ <rhq.dev.ds.xa-datasource-class>org.h2.jdbcx.JdbcDataSource</rhq.dev.ds.xa-datasource-class>
+ <rhq.dev.ds.server-name>127.0.0.1</rhq.dev.ds.server-name>
+ <rhq.dev.ds.port>9092</rhq.dev.ds.port>
+ <rhq.dev.ds.db-name>rhq</rhq.dev.ds.db-name>
+ <!-- This custom dialect is required for proper operation using H2, see class JavaDoc for more info -->
+ <rhq.dev.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.dev.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.StdJDBCDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.dev.quartz.selectWithLockSQL>
@@ -142,21 +163,31 @@
<profile>
<id>sqlserver</id>
<properties>
- <rhq.ds.driver-class>net.sourceforge.jtds.jdbc.Driver</rhq.ds.driver-class>
- <rhq.ds.connection-url>jdbc:jtds:sqlserver://localhost:1433;databaseName=rhq</rhq.ds.connection-url>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.type-mapping>sqlserver</rhq.ds.type-mapping>
- <rhq.ds.xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.server-name>localhost</rhq.ds.server-name>
- <rhq.ds.port>1433</rhq.ds.port>
- <rhq.ds.db-name>rhq</rhq.ds.db-name>
- <rhq.ds.hibernate-dialect>org.hibernate.dialect.SQLServerDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.driver-class>net.sourceforge.jtds.jdbc.Driver</rhq.test.ds.driver-class>
+ <rhq.test.ds.connection-url>jdbc:jtds:sqlserver://localhost:1433;databaseName=rhq</rhq.test.ds.connection-url>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>sqlserver</rhq.test.ds.type-mapping>
+ <rhq.test.ds.xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.server-name>localhost</rhq.test.ds.server-name>
+ <rhq.test.ds.port>1433</rhq.test.ds.port>
+ <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
+ <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.SQLServerDialect</rhq.test.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.MSSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>UPDATE {0}LOCKS SET LOCK_NAME = LOCK_NAME WHERE LOCK_NAME = ?</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.UpdateLockRowSemaphore</rhq.test.quartz.lockHandlerClass>
-
+
+ <rhq.dev.ds.driver-class>net.sourceforge.jtds.jdbc.Driver</rhq.dev.ds.driver-class>
+ <rhq.dev.ds.connection-url>jdbc:jtds:sqlserver://localhost:1433;databaseName=rhq</rhq.dev.ds.connection-url>
+ <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
+ <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
+ <rhq.dev.ds.type-mapping>sqlserver</rhq.dev.ds.type-mapping>
+ <rhq.dev.ds.xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</rhq.dev.ds.xa-datasource-class>
+ <rhq.dev.ds.server-name>localhost</rhq.dev.ds.server-name>
+ <rhq.dev.ds.port>1433</rhq.dev.ds.port>
+ <rhq.dev.ds.db-name>rhq</rhq.dev.ds.db-name>
+ <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.SQLServerDialect</rhq.dev.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.MSSQLDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>UPDATE {0}LOCKS SET LOCK_NAME = LOCK_NAME WHERE LOCK_NAME = ?</rhq.dev.quartz.selectWithLockSQL>
@@ -167,21 +198,31 @@
<profile>
<id>oracle</id>
<properties>
- <rhq.ds.connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</rhq.ds.connection-url>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.type-mapping>Oracle10g</rhq.ds.type-mapping>
- <rhq.ds.driver-class>oracle.jdbc.driver.OracleDriver</rhq.ds.driver-class>
- <rhq.ds.xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.server-name></rhq.ds.server-name> <!-- can be left blank, oracle does not use this -->
- <rhq.ds.port></rhq.ds.port> <!-- can be left blank, oracle does not use this -->
- <rhq.ds.db-name></rhq.ds.db-name> <!-- can be left blank, oracle does not use this -->
- <rhq.ds.hibernate-dialect>org.hibernate.dialect.Oracle10gDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</rhq.test.ds.connection-url>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>Oracle10g</rhq.test.ds.type-mapping>
+ <rhq.test.ds.driver-class>oracle.jdbc.driver.OracleDriver</rhq.test.ds.driver-class>
+ <rhq.test.ds.xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.server-name></rhq.test.ds.server-name> <!-- can be left blank, oracle does not use this -->
+ <rhq.test.ds.port></rhq.test.ds.port> <!-- can be left blank, oracle does not use this -->
+ <rhq.test.ds.db-name></rhq.test.ds.db-name> <!-- can be left blank, oracle does not use this -->
+ <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.Oracle10gDialect</rhq.test.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.oracle.OracleDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
+ <rhq.dev.ds.connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</rhq.dev.ds.connection-url>
+ <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
+ <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
+ <rhq.dev.ds.type-mapping>Oracle10g</rhq.dev.ds.type-mapping>
+ <rhq.dev.ds.driver-class>oracle.jdbc.driver.OracleDriver</rhq.dev.ds.driver-class>
+ <rhq.dev.ds.xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</rhq.dev.ds.xa-datasource-class>
+ <rhq.dev.ds.server-name></rhq.dev.ds.server-name> <!-- can be left blank, oracle does not use this -->
+ <rhq.dev.ds.port></rhq.dev.ds.port> <!-- can be left blank, oracle does not use this -->
+ <rhq.dev.ds.db-name></rhq.dev.ds.db-name> <!-- can be left blank, oracle does not use this -->
+ <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.Oracle10gDialect</rhq.dev.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.oracle.OracleDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.dev.quartz.selectWithLockSQL>
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index a492187..06f1495 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -241,12 +241,23 @@
<phase>process-classes</phase>
<configuration>
<tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}"/>
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}"/>
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}"/>
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}"/>
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}"/>
- <property name="rhq.ds.password" value="${rhq.ds.password}"/>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -279,14 +290,28 @@
<id>test-db-schema-version</id>
<phase>test</phase>
<configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -334,13 +359,24 @@
<phase>test</phase>
<configuration>
<tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
-
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="create-release-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
@@ -355,10 +391,10 @@
<property name="rhq.ds.password" value="${rhq.ds.password}" />
<property name="project.version" value="${project.version}" />
<property name="db.schema.version" value="${db.schema.version}" />
- <property name="jon.release" value="${jon.release}" />
- </ant>
- </tasks>
- </configuration>
+ <property name="jon.release" value="${jon.release}" />
+ </ant>
+ </tasks>
+ </configuration>
<goals>
<goal>run</goal>
</goals>
diff --git a/modules/core/domain/pom.xml b/modules/core/domain/pom.xml
index c8ce307..42d28e1 100644
--- a/modules/core/domain/pom.xml
+++ b/modules/core/domain/pom.xml
@@ -282,7 +282,7 @@
</property>
<property>
<name>hibernate.dialect</name>
- <value>${rhq.ds.hibernate-dialect}</value>
+ <value>${rhq.test.ds.hibernate-dialect}</value>
</property>
</systemProperties>
<excludes>
diff --git a/modules/core/domain/src/test/resources/embedded-jboss-beans.xml b/modules/core/domain/src/test/resources/embedded-jboss-beans.xml
index a51f3e3..ae9de01 100644
--- a/modules/core/domain/src/test/resources/embedded-jboss-beans.xml
+++ b/modules/core/domain/src/test/resources/embedded-jboss-beans.xml
@@ -85,10 +85,10 @@
-->
<bean name="RHQDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
- <property name="driverClass">${rhq.ds.driver-class}</property>
- <property name="connectionURL">${rhq.ds.connection-url}</property>
- <property name="userName">${rhq.ds.user-name}</property>
- <property name="password">${rhq.ds.password}</property>
+ <property name="driverClass">${rhq.test.ds.driver-class}</property>
+ <property name="connectionURL">${rhq.test.ds.connection-url}</property>
+ <property name="userName">${rhq.test.ds.user-name}</property>
+ <property name="password">${rhq.test.ds.password}</property>
<property name="jndiName">java:/RHQDS</property>
<property name="minSize">0</property>
<property name="maxSize">10</property>
diff --git a/modules/enterprise/gui/installer-war/pom.xml b/modules/enterprise/gui/installer-war/pom.xml
index f73e403..517399c 100644
--- a/modules/enterprise/gui/installer-war/pom.xml
+++ b/modules/enterprise/gui/installer-war/pom.xml
@@ -147,13 +147,13 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
- <rhq.ds.server-name>${rhq.ds.server-name}</rhq.ds.server-name>
- <rhq.ds.db-name>${rhq.ds.db-name}</rhq.ds.db-name>
- <rhq.ds.connection-url>${rhq.ds.connection-url}</rhq.ds.connection-url>
+ <rhq.test.ds.server-name>${rhq.test.ds.server-name}</rhq.test.ds.server-name>
+ <rhq.test.ds.db-name>${rhq.test.ds.db-name}</rhq.test.ds.db-name>
+ <rhq.test.ds.connection-url>${rhq.test.ds.connection-url}</rhq.test.ds.connection-url>
<rhq.db.admin.username>${rhq.db.admin.username}</rhq.db.admin.username>
<rhq.db.admin.password>${rhq.db.admin.password}</rhq.db.admin.password>
- <rhq.ds.user-name>${rhq.ds.user-name}</rhq.ds.user-name>
- <rhq.ds.password>${rhq.ds.password}</rhq.ds.password>
+ <rhq.test.ds.user-name>${rhq.test.ds.user-name}</rhq.test.ds.user-name>
+ <rhq.test.ds.password>${rhq.test.ds.password}</rhq.test.ds.password>
</systemPropertyVariables>
</configuration>
</plugin>
diff --git a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
index 0e68830..579bebf 100644
--- a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
+++ b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
@@ -46,11 +46,11 @@ import java.util.Properties;
public class DBInstallatonTest {
private final String LOG_DIRECTORY = System.getProperty("java.io.tmpdir", "rhq/installer-test");
- private final String TEST_DB = System.getProperty("rhq.ds.db-name","rhq_installer_test_db");
- private final String USERNAME = System.getProperty("rhq.ds.user-name", "rhqadmin");
- private final String PASSWORD = System.getProperty("rhq.ds.password", "rhqadmin");
- private final String SERVER = System.getProperty("rhq.ds.server-name", "127.0.0.1");
- private final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
+ private final String TEST_DB = System.getProperty("rhq.test.ds.db-name","rhq_installer_test_db");
+ private final String USERNAME = System.getProperty("rhq.test.ds.user-name", "rhqadmin");
+ private final String PASSWORD = System.getProperty("rhq.test.ds.password", "rhqadmin");
+ private final String SERVER = System.getProperty("rhq.test.ds.server-name", "127.0.0.1");
+ private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
private final String ADMIN_USERNAME = System.getProperty("rhq.db.admin.username", "postgres");
private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
diff --git a/modules/enterprise/server/container/pom.xml b/modules/enterprise/server/container/pom.xml
index 8e59747..7329bb5 100644
--- a/modules/enterprise/server/container/pom.xml
+++ b/modules/enterprise/server/container/pom.xml
@@ -183,16 +183,16 @@
<property name="quartz.version" value="${quartz.version}" />
<!-- dev DB settings (used to init rhq-server.properties if dev profile is active or developer prop is set) -->
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
- <property name="rhq.ds.xa-datasource-class" value="${rhq.ds.xa-datasource-class}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password.encrypted" value="${rhq.ds.password.encrypted}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.server-name" value="${rhq.ds.server-name}" />
- <property name="rhq.ds.port" value="${rhq.ds.port}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.hibernate-dialect" value="${rhq.ds.hibernate-dialect}" />
+ <property name="rhq.dev.ds.connection-url" value="${rhq.dev.ds.connection-url}" />
+ <property name="rhq.dev.ds.driver-class" value="${rhq.dev.ds.driver-class}" />
+ <property name="rhq.dev.ds.xa-datasource-class" value="${rhq.dev.ds.xa-datasource-class}" />
+ <property name="rhq.dev.ds.user-name" value="${rhq.dev.ds.user-name}" />
+ <property name="rhq.dev.ds.password.encrypted" value="${rhq.dev.ds.password.encrypted}" />
+ <property name="rhq.dev.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" />
+ <property name="rhq.dev.ds.server-name" value="${rhq.dev.ds.server-name}" />
+ <property name="rhq.dev.ds.port" value="${rhq.dev.ds.port}" />
+ <property name="rhq.dev.ds.db-name" value="${rhq.dev.ds.db-name}" />
+ <property name="rhq.dev.ds.hibernate-dialect" value="${rhq.dev.ds.hibernate-dialect}" />
<property name="rhq.dev.quartz.driverDelegateClass" value="${rhq.dev.quartz.driverDelegateClass}" />
<property name="rhq.dev.quartz.selectWithLockSQL" value="${rhq.dev.quartz.selectWithLockSQL}" />
<property name="rhq.dev.quartz.lockHandlerClass" value="${rhq.dev.quartz.lockHandlerClass}" />
@@ -233,7 +233,8 @@
<property name="rhq.earName" value="${rhq.earName}" />
<!-- dev/test DB type (needed to init rhq-ds.xml) -->
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.test.ds.type-mapping" value="${rhq.test.ds.type-mapping}" />
+ <property name="rhq.dev.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" />
<property name="rhq.server.enable.web.services" value="${rhq.server.enable.ws}" />
</ant>
</tasks>
diff --git a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
index c4d83a0..704c50a 100644
--- a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
@@ -33,16 +33,16 @@
<target name="set-dev-server-props" if="predeploy">
<echo>*** Using dev database settings in rhq-server.properties...</echo>
- <property name="rhq.server.database.hibernate-dialect" value="${rhq.ds.hibernate-dialect}" />
- <property name="rhq.server.database.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.server.database.driver-class" value="${rhq.ds.driver-class}" />
- <property name="rhq.server.database.xa-datasource-class" value="${rhq.ds.xa-datasource-class}" />
- <property name="rhq.server.database.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.server.database.password" value="${rhq.ds.password.encrypted}" />
- <property name="rhq.server.database.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.server.database.server-name" value="${rhq.ds.server-name}" />
- <property name="rhq.server.database.port" value="${rhq.ds.port}" />
- <property name="rhq.server.database.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.server.database.hibernate-dialect" value="${rhq.dev.ds.hibernate-dialect}" />
+ <property name="rhq.server.database.connection-url" value="${rhq.dev.ds.connection-url}" />
+ <property name="rhq.server.database.driver-class" value="${rhq.dev.ds.driver-class}" />
+ <property name="rhq.server.database.xa-datasource-class" value="${rhq.dev.ds.xa-datasource-class}" />
+ <property name="rhq.server.database.user-name" value="${rhq.dev.ds.user-name}" />
+ <property name="rhq.server.database.password" value="${rhq.dev.ds.password.encrypted}" />
+ <property name="rhq.server.database.type-mapping" value="${rhq.dev.ds.type-mapping}" />
+ <property name="rhq.server.database.server-name" value="${rhq.dev.ds.server-name}" />
+ <property name="rhq.server.database.port" value="${rhq.dev.ds.port}" />
+ <property name="rhq.server.database.db-name" value="${rhq.dev.ds.db-name}" />
<property name="rhq.server.quartz.driverDelegateClass" value="${rhq.dev.quartz.driverDelegateClass}" />
<property name="rhq.server.quartz.selectWithLockSQL" value="${rhq.dev.quartz.selectWithLockSQL}" />
<property name="rhq.server.quartz.lockHandlerClass" value="${rhq.dev.quartz.lockHandlerClass}" />
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index 000808c..c5bb3ec 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -559,7 +559,7 @@ Build-OS-Version=${os.version}
<systemPropertyVariables>
<embeddedDeployment>true</embeddedDeployment>
<deploymentDirectory>target/classes</deploymentDirectory>
- <hibernate.dialect>${rhq.ds.hibernate-dialect}</hibernate.dialect>
+ <hibernate.dialect>${rhq.test.ds.hibernate-dialect}</hibernate.dialect>
<clean.db>${clean.db}</clean.db>
</systemPropertyVariables>
<additionalClasspathElements>
diff --git a/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml b/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml
index 05451bd..55d697b 100644
--- a/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml
+++ b/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml
@@ -76,10 +76,10 @@
</bean>
<bean name="RHQDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
- <property name="driverClass">${rhq.ds.driver-class}</property>
- <property name="connectionURL">${rhq.ds.connection-url}</property>
- <property name="userName">${rhq.ds.user-name}</property>
- <property name="password">${rhq.ds.password}</property>
+ <property name="driverClass">${rhq.test.ds.driver-class}</property>
+ <property name="connectionURL">${rhq.test.ds.connection-url}</property>
+ <property name="userName">${rhq.test.ds.user-name}</property>
+ <property name="password">${rhq.test.ds.password}</property>
<property name="jndiName">java:/RHQDS</property>
<property name="minSize">0</property>
<property name="maxSize">20</property>
@@ -104,10 +104,10 @@
<!-- needed for Quartz' no-TX data source (even though this is a local-tx, seems like Quartz is still working) -->
<bean name="NoTxRHQDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
- <property name="driverClass">${rhq.ds.driver-class}</property>
- <property name="connectionURL">${rhq.ds.connection-url}</property>
- <property name="userName">${rhq.ds.user-name}</property>
- <property name="password">${rhq.ds.password}</property>
+ <property name="driverClass">${rhq.test.ds.driver-class}</property>
+ <property name="connectionURL">${rhq.test.ds.connection-url}</property>
+ <property name="userName">${rhq.test.ds.user-name}</property>
+ <property name="password">${rhq.test.ds.password}</property>
<property name="jndiName">java:/NoTxRHQDS</property>
<property name="minSize">0</property>
<property name="maxSize">10</property>
diff --git a/modules/jopr/release.sh b/modules/jopr/release.sh
index c05b6ee..54f26ab 100755
--- a/modules/jopr/release.sh
+++ b/modules/jopr/release.sh
@@ -226,16 +226,16 @@ cat <<EOF >${SETTINGS}
<profile>
<id>release</id>
<properties>
- <rhq.ds.connection-url>jdbc:postgresql://jon03.qa.atl2.redhat.com:5432/rhq_release</rhq.ds.connection-url>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
- <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
- <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.server-name>jon03.qa.atl2.redhat.com</rhq.ds.server-name>
- <rhq.ds.port>5432</rhq.ds.port>
- <rhq.ds.db-name>rhq_release</rhq.ds.db-name>
- <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.connection-url>jdbc:postgresql://jon03.qa.atl2.redhat.com:5432/rhq_release</rhq.test.ds.connection-url>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
+ <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
+ <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.server-name>jon03.qa.atl2.redhat.com</rhq.test.ds.server-name>
+ <rhq.test.ds.port>5432</rhq.test.ds.port>
+ <rhq.test.ds.db-name>rhq_release</rhq.test.ds.db-name>
+ <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
diff --git a/pom.xml b/pom.xml
index 23afa62..549e0d0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -107,22 +107,42 @@
defaults for datasource used by integration tests -
these may be overridden in ~/.m2/settings.xml
-->
- <rhq.ds.db-name>rhq</rhq.ds.db-name>
- <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.ds.db-name}</rhq.ds.connection-url>
- <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
- <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.password.encrypted>1eeb2f255e832171df8592078de921bc</rhq.ds.password.encrypted>
- <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
- <rhq.ds.server-name>127.0.0.1</rhq.ds.server-name>
- <rhq.ds.port>5432</rhq.ds.port>
- <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.test.ds.db-name}</rhq.test.ds.connection-url>
+ <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
+ <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
+ <rhq.test.ds.server-name>127.0.0.1</rhq.test.ds.server-name>
+ <rhq.test.ds.port>5432</rhq.test.ds.port>
+ <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>
SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE
</rhq.test.quartz.selectWithLockSQL>
- <rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
+ <rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
+
+ <!--
+ defaults for datasource used by the dev container build (see dev docs on the 'dev' profile) -
+ these may be overridden in ~/.m2/settings.xml
+ -->
+ <rhq.dev.ds.db-name>rhqdev</rhq.dev.ds.db-name>
+ <rhq.dev.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.dev.ds.db-name}</rhq.dev.ds.connection-url>
+ <rhq.dev.ds.driver-class>org.postgresql.Driver</rhq.dev.ds.driver-class>
+ <rhq.dev.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.dev.ds.xa-datasource-class>
+ <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
+ <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
+ <rhq.dev.ds.password.encrypted>1eeb2f255e832171df8592078de921bc</rhq.dev.ds.password.encrypted>
+ <rhq.dev.ds.type-mapping>PostgreSQL</rhq.dev.ds.type-mapping>
+ <rhq.dev.ds.server-name>127.0.0.1</rhq.dev.ds.server-name>
+ <rhq.dev.ds.port>5432</rhq.dev.ds.port>
+ <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.dev.ds.hibernate-dialect>
+ <rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.dev.quartz.driverDelegateClass>
+ <rhq.dev.quartz.selectWithLockSQL>
+ SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE
+ </rhq.dev.quartz.selectWithLockSQL>
+ <rhq.dev.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.dev.quartz.lockHandlerClass>
<!-- default port numbers for RHQ server -->
<rhq.server.http.port>7080</rhq.server.http.port>
diff --git a/release.sh b/release.sh
index 4c7166e..316af14 100755
--- a/release.sh
+++ b/release.sh
@@ -282,16 +282,16 @@ cat <<EOF >"${MAVEN_SETTINGS_FILE}"
<profile>
<id>release</id>
<properties>
- <rhq.ds.server-name>hudson-qe.rhq.rdu.redhat.com</rhq.ds.server-name>
- <rhq.ds.port>5432</rhq.ds.port>
- <rhq.ds.db-name>rhq_release_tag</rhq.ds.db-name>
- <rhq.ds.connection-url>jdbc:postgresql://hudson-qe.rhq.rdu.redhat.com:5432/rhq_release_tag</rhq.ds.connection-url>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
- <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
- <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.server-name>hudson-qe.rhq.rdu.redhat.com</rhq.test.ds.server-name>
+ <rhq.test.ds.port>5432</rhq.test.ds.port>
+ <rhq.test.ds.db-name>rhq_release_tag</rhq.test.ds.db-name>
+ <rhq.test.ds.connection-url>jdbc:postgresql://hudson-qe.rhq.rdu.redhat.com:5432/rhq_release_tag</rhq.test.ds.connection-url>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
+ <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
+ <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
commit 7d845dfebd066d307411fba2544778f16389cbe9
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 25 15:07:09 2011 -0500
Final touches to get dbreset working for oracle databases.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 536f692..a492187 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -104,6 +104,10 @@
<mainClass>org.rhq.core.db.reset.DBReset</mainClass>
<systemProperties>
<systemProperty>
+ <key>rhq.ds.type-mapping</key>
+ <value>${rhq.ds.type-mapping}</value>
+ </systemProperty>
+ <systemProperty>
<key>rhq.ds.server-name</key>
<value>${rhq.ds.server-name}</value>
</systemProperty>
@@ -502,7 +506,34 @@
</plugins>
</build>
</profile>
- </profiles>
+
+ <profile>
+ <id>ojdbc-driver</id>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc5</artifactId>
+ <version>${ojdbc5.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2</version>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc5</artifactId>
+ <version>${ojdbc5.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
<pluginRepositories>
<pluginRepository>
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index a6970ca..8a32c43 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -104,17 +104,24 @@ public class DBReset {
connection = DbUtil.getConnection(DB_URL, ADMIN_USER, ADMIN_PASSWORD);
connection.setAutoCommit(false);
- String plsql = "declare cursor all_objects_to_drop is"
- + "select * from user_objects where object_type in ('TABLE', 'VIEW', 'FUNCTION', 'SEQUENCE');"
- + "begin"
- + " for obj in all_objects_to_drop loop"
- + " begin"
- + " if obj.object_type = 'TABLE' THEN"
- + " execute immediate('DROP '||obj.object_type||' '||obj.object_name||' CASCADE CONSTRAINTS PURGE');"
- + " else" + " execute immediate('DROP '||obj.object_type||' '||obj.object_name);"
- + " end if;" + " exception when others then null;" + " end;" + " end loop;" + "end;";
+ String plsql = "declare cursor all_objects_to_drop is\n"
+ + "select * from user_objects where object_type in ('TABLE', 'VIEW', 'FUNCTION', 'SEQUENCE');\n"
+ + "begin\n"
+ + " for obj in all_objects_to_drop loop\n"
+ + " begin\n"
+ + " if obj.object_type = 'TABLE' then\n"
+ + " execute immediate('DROP '||obj.object_type||' '||obj.object_name||' CASCADE CONSTRAINTS PURGE');\n"
+ + " else\n"
+ + " execute immediate('DROP '||obj.object_type||' '||obj.object_name);\n"
+ + " end if;\n"
+ + " exception when others then null;\n"
+ + " end;\n"
+ + " end loop;\n"
+ + " end;\n";
+ log.info(plsql);
cleanUserStatement = connection.prepareStatement(plsql);
cleanUserStatement.execute();
+ connection.commit();
log.info("Cleand database " + DB + ".");
} finally {
commit 377619dd2d069cf915310b7dee29cd5426722c9a
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 25 13:22:53 2011 -0500
Pass system properties to DBReset correctly. Also, added missing db-name property to the rest of the profiles.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 7e58645..536f692 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -101,7 +101,37 @@
<goal>java</goal>
</goals>
<configuration>
- <mainClass>org.rhq.core.db.reset.DBReset</mainClass>
+ <mainClass>org.rhq.core.db.reset.DBReset</mainClass>
+ <systemProperties>
+ <systemProperty>
+ <key>rhq.ds.server-name</key>
+ <value>${rhq.ds.server-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.db-name</key>
+ <value>${rhq.ds.db-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.connection-url</key>
+ <value>${rhq.ds.connection-url}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.db.admin.username</key>
+ <value>${rhq.db.admin.username}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.db.admin.password</key>
+ <value>${rhq.db.admin.password}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.user-name</key>
+ <value>${rhq.ds.user-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.password</key>
+ <value>${rhq.ds.password}</value>
+ </systemProperty>
+ </systemProperties>
</configuration>
</execution>
</executions>
@@ -171,6 +201,7 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}"/>
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}"/>
<property name="rhq.ds.password" value="${rhq.ds.password}"/>
@@ -183,6 +214,7 @@
<property name="jtds.version" value="${jtds.version}" />
<property name="task.classpath.property" refid="maven.test.classpath" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
<property name="rhq.ds.password" value="${rhq.ds.password}" />
@@ -207,6 +239,7 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}"/>
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}"/>
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}"/>
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}"/>
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}"/>
<property name="rhq.ds.password" value="${rhq.ds.password}"/>
@@ -219,6 +252,7 @@
<property name="jtds.version" value="${jtds.version}" />
<property name="task.classpath.property" refid="maven.test.classpath" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
<property name="rhq.ds.password" value="${rhq.ds.password}" />
@@ -244,6 +278,7 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
<property name="rhq.ds.password" value="${rhq.ds.password}" />
@@ -256,6 +291,7 @@
<property name="h2.version" value="${h2.version}" />
<property name="jtds.version" value="${jtds.version}" />
<property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
@@ -296,6 +332,7 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
<property name="rhq.ds.password" value="${rhq.ds.password}" />
@@ -308,6 +345,7 @@
<property name="jtds.version" value="${jtds.version}" />
<property name="task.classpath.property" refid="maven.test.classpath" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
<property name="rhq.ds.password" value="${rhq.ds.password}" />
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 9a17f19..a6970ca 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -83,7 +83,7 @@ public class DBReset {
createDB = connection.createStatement();
createDB.execute("create database " + DB + " with owner " + USER);
- log.info("Dropped and created database " + DB +".");
+ log.info("Dropped and created database " + DB + ".");
} finally {
if (dropDB != null) {
dropDB.close();
@@ -94,7 +94,7 @@ public class DBReset {
if (connection != null) {
connection.close();
}
-
+
}
} else if (DB_TYPE_MAPPING.equals("Oracle10g")) {
Connection connection = null;
@@ -111,17 +111,12 @@ public class DBReset {
+ " begin"
+ " if obj.object_type = 'TABLE' THEN"
+ " execute immediate('DROP '||obj.object_type||' '||obj.object_name||' CASCADE CONSTRAINTS PURGE');"
- + " else"
- + " execute immediate('DROP '||obj.object_type||' '||obj.object_name);"
- + " end if;"
- + " exception when others then null;"
- + " end;"
- + " end loop;"
- + "end;";
+ + " else" + " execute immediate('DROP '||obj.object_type||' '||obj.object_name);"
+ + " end if;" + " exception when others then null;" + " end;" + " end loop;" + "end;";
cleanUserStatement = connection.prepareStatement(plsql);
cleanUserStatement.execute();
-
- log.info("Cleand database " + DB +".");
+
+ log.info("Cleand database " + DB + ".");
} finally {
if (cleanUserStatement != null) {
cleanUserStatement.close();
commit 660f9cff3d76ca230075df86241bec53bce84ebd
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Jul 22 21:44:51 2011 -0500
Add dbreset support for Oracle database by executing an anonymous pl/sql script.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 2d85ff0..9a17f19 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -20,6 +20,7 @@
package org.rhq.core.db.reset;
import java.sql.Connection;
+import java.sql.PreparedStatement;
import java.sql.Statement;
import org.apache.commons.logging.Log;
@@ -45,6 +46,8 @@ public class DBReset {
private final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"
+ DB);
+ private final String DB_TYPE_MAPPING = System.getProperty("rhq.ds.type-mapping", "PostgreSQL");
+
/**
* @param args
*/
@@ -66,29 +69,66 @@ public class DBReset {
System.setProperty("dbsetup", "true");
- Connection connection = null;
- Statement dropDB = null;
- Statement createDB = null;
-
- try {
- connection = DbUtil.getConnection(DB_URL.replace(DB, "postgres"), ADMIN_USER, ADMIN_PASSWORD);
-
- dropDB = connection.createStatement();
- dropDB.execute("drop database if exists " + DB);
-
- createDB = connection.createStatement();
- createDB.execute("create database " + DB + " with owner " + USER);
-
- log.info("created database $database");
- } finally {
- if (connection != null) {
- connection.close();
- }
- if (dropDB != null) {
- dropDB.close();
+ if (DB_TYPE_MAPPING.equals("PostgreSQL")) {
+ Connection connection = null;
+ Statement dropDB = null;
+ Statement createDB = null;
+
+ try {
+ connection = DbUtil.getConnection(DB_URL.replace(DB, "postgres"), ADMIN_USER, ADMIN_PASSWORD);
+
+ dropDB = connection.createStatement();
+ dropDB.execute("drop database if exists " + DB);
+
+ createDB = connection.createStatement();
+ createDB.execute("create database " + DB + " with owner " + USER);
+
+ log.info("Dropped and created database " + DB +".");
+ } finally {
+ if (dropDB != null) {
+ dropDB.close();
+ }
+ if (createDB != null) {
+ createDB.close();
+ }
+ if (connection != null) {
+ connection.close();
+ }
+
}
- if (createDB != null) {
- createDB.close();
+ } else if (DB_TYPE_MAPPING.equals("Oracle10g")) {
+ Connection connection = null;
+ PreparedStatement cleanUserStatement = null;
+
+ try {
+ connection = DbUtil.getConnection(DB_URL, ADMIN_USER, ADMIN_PASSWORD);
+ connection.setAutoCommit(false);
+
+ String plsql = "declare cursor all_objects_to_drop is"
+ + "select * from user_objects where object_type in ('TABLE', 'VIEW', 'FUNCTION', 'SEQUENCE');"
+ + "begin"
+ + " for obj in all_objects_to_drop loop"
+ + " begin"
+ + " if obj.object_type = 'TABLE' THEN"
+ + " execute immediate('DROP '||obj.object_type||' '||obj.object_name||' CASCADE CONSTRAINTS PURGE');"
+ + " else"
+ + " execute immediate('DROP '||obj.object_type||' '||obj.object_name);"
+ + " end if;"
+ + " exception when others then null;"
+ + " end;"
+ + " end loop;"
+ + "end;";
+ cleanUserStatement = connection.prepareStatement(plsql);
+ cleanUserStatement.execute();
+
+ log.info("Cleand database " + DB +".");
+ } finally {
+ if (cleanUserStatement != null) {
+ cleanUserStatement.close();
+ }
+ if (connection != null) {
+ connection.close();
+ }
}
}
}
commit 3813104783a672fc5f12b49e4605f99e5e95808e
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Jul 22 10:26:53 2011 -0500
Updating the code to use only one set of datasource settings. (rhq.ds.name-of-setting)
diff --git a/etc/m2/settings-bugfixes.xml b/etc/m2/settings-bugfixes.xml
index b64aac6..01f3173 100644
--- a/etc/m2/settings-bugfixes.xml
+++ b/etc/m2/settings-bugfixes.xml
@@ -28,8 +28,8 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.bugfixes</id>
<properties>
- <rhq.test.ds.db-name>rhqbugfixes</rhq.test.ds.db-name>
- <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqbugfixes</rhq.test.ds.connection-url>
+ <rhq.ds.db-name>rhqbugfixes</rhq.ds.db-name>
+ <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqbugfixes</rhq.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings-content.xml b/etc/m2/settings-content.xml
index 806006b..3009f75 100644
--- a/etc/m2/settings-content.xml
+++ b/etc/m2/settings-content.xml
@@ -33,7 +33,7 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.content</id>
<properties>
- <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqcontent</rhq.test.ds.connection-url>
+ <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqcontent</rhq.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings-linux-config.xml b/etc/m2/settings-linux-config.xml
index dd464f7..6605f33 100644
--- a/etc/m2/settings-linux-config.xml
+++ b/etc/m2/settings-linux-config.xml
@@ -28,7 +28,7 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.linux-config</id>
<properties>
- <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqlconf</rhq.test.ds.connection-url>
+ <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqlconf</rhq.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings-rawconfig.xml b/etc/m2/settings-rawconfig.xml
index f871d66..f64b717 100644
--- a/etc/m2/settings-rawconfig.xml
+++ b/etc/m2/settings-rawconfig.xml
@@ -28,8 +28,8 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.rawconfig</id>
<properties>
- <rhq.test.ds.db-name>rhqrawconfig</rhq.test.ds.db-name>
- <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqrawconfig</rhq.test.ds.connection-url>
+ <rhq.ds.db-name>rhqrawconfig</rhq.ds.db-name>
+ <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqrawconfig</rhq.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings.xml b/etc/m2/settings.xml
index 8c0dada..89c26f2 100644
--- a/etc/m2/settings.xml
+++ b/etc/m2/settings.xml
@@ -91,31 +91,21 @@
<profile>
<id>postgres</id>
<properties>
- <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhq</rhq.test.ds.connection-url>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
- <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
- <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.server-name>127.0.0.1</rhq.test.ds.server-name>
- <rhq.test.ds.port>5432</rhq.test.ds.port>
- <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
- <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhq</rhq.ds.connection-url>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
+ <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
+ <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.server-name>127.0.0.1</rhq.ds.server-name>
+ <rhq.ds.port>5432</rhq.ds.port>
+ <rhq.ds.db-name>rhq</rhq.ds.db-name>
+ <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
- <rhq.dev.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhq</rhq.dev.ds.connection-url>
- <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
- <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
- <rhq.dev.ds.type-mapping>PostgreSQL</rhq.dev.ds.type-mapping>
- <rhq.dev.ds.driver-class>org.postgresql.Driver</rhq.dev.ds.driver-class>
- <rhq.dev.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.dev.ds.xa-datasource-class>
- <rhq.dev.ds.server-name>127.0.0.1</rhq.dev.ds.server-name>
- <rhq.dev.ds.port>5432</rhq.dev.ds.port>
- <rhq.dev.ds.db-name>rhq</rhq.dev.ds.db-name>
- <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.dev.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.dev.quartz.selectWithLockSQL>
@@ -126,33 +116,22 @@
<profile>
<id>h2</id>
<properties>
- <rhq.test.ds.driver-class>org.h2.Driver</rhq.test.ds.driver-class>
- <rhq.test.ds.connection-url>jdbc:h2:~/rhq;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOG=2</rhq.test.ds.connection-url>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>h2</rhq.test.ds.type-mapping>
- <rhq.test.ds.xa-datasource-class>org.h2.jdbcx.JdbcDataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.server-name>127.0.0.1</rhq.test.ds.server-name>
- <rhq.test.ds.port>9092</rhq.test.ds.port>
- <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
+ <rhq.ds.driver-class>org.h2.Driver</rhq.ds.driver-class>
+ <rhq.ds.connection-url>jdbc:h2:~/rhq;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOG=2</rhq.ds.connection-url>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.type-mapping>h2</rhq.ds.type-mapping>
+ <rhq.ds.xa-datasource-class>org.h2.jdbcx.JdbcDataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.server-name>127.0.0.1</rhq.ds.server-name>
+ <rhq.ds.port>9092</rhq.ds.port>
+ <rhq.ds.db-name>rhq</rhq.ds.db-name>
<!-- This custom dialect is required for proper operation using H2, see class JavaDoc for more info -->
- <rhq.test.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.StdJDBCDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
-
- <rhq.dev.ds.driver-class>org.h2.Driver</rhq.dev.ds.driver-class>
- <rhq.dev.ds.connection-url>jdbc:h2:~/rhq;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOG=2</rhq.dev.ds.connection-url>
- <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
- <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
- <rhq.dev.ds.type-mapping>h2</rhq.dev.ds.type-mapping>
- <rhq.dev.ds.xa-datasource-class>org.h2.jdbcx.JdbcDataSource</rhq.dev.ds.xa-datasource-class>
- <rhq.dev.ds.server-name>127.0.0.1</rhq.dev.ds.server-name>
- <rhq.dev.ds.port>9092</rhq.dev.ds.port>
- <rhq.dev.ds.db-name>rhq</rhq.dev.ds.db-name>
- <!-- This custom dialect is required for proper operation using H2, see class JavaDoc for more info -->
- <rhq.dev.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.dev.ds.hibernate-dialect>
+
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.StdJDBCDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.dev.quartz.selectWithLockSQL>
@@ -163,31 +142,21 @@
<profile>
<id>sqlserver</id>
<properties>
- <rhq.test.ds.driver-class>net.sourceforge.jtds.jdbc.Driver</rhq.test.ds.driver-class>
- <rhq.test.ds.connection-url>jdbc:jtds:sqlserver://localhost:1433;databaseName=rhq</rhq.test.ds.connection-url>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>sqlserver</rhq.test.ds.type-mapping>
- <rhq.test.ds.xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.server-name>localhost</rhq.test.ds.server-name>
- <rhq.test.ds.port>1433</rhq.test.ds.port>
- <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
- <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.SQLServerDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.driver-class>net.sourceforge.jtds.jdbc.Driver</rhq.ds.driver-class>
+ <rhq.ds.connection-url>jdbc:jtds:sqlserver://localhost:1433;databaseName=rhq</rhq.ds.connection-url>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.type-mapping>sqlserver</rhq.ds.type-mapping>
+ <rhq.ds.xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.server-name>localhost</rhq.ds.server-name>
+ <rhq.ds.port>1433</rhq.ds.port>
+ <rhq.ds.db-name>rhq</rhq.ds.db-name>
+ <rhq.ds.hibernate-dialect>org.hibernate.dialect.SQLServerDialect</rhq.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.MSSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>UPDATE {0}LOCKS SET LOCK_NAME = LOCK_NAME WHERE LOCK_NAME = ?</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.UpdateLockRowSemaphore</rhq.test.quartz.lockHandlerClass>
-
- <rhq.dev.ds.driver-class>net.sourceforge.jtds.jdbc.Driver</rhq.dev.ds.driver-class>
- <rhq.dev.ds.connection-url>jdbc:jtds:sqlserver://localhost:1433;databaseName=rhq</rhq.dev.ds.connection-url>
- <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
- <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
- <rhq.dev.ds.type-mapping>sqlserver</rhq.dev.ds.type-mapping>
- <rhq.dev.ds.xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</rhq.dev.ds.xa-datasource-class>
- <rhq.dev.ds.server-name>localhost</rhq.dev.ds.server-name>
- <rhq.dev.ds.port>1433</rhq.dev.ds.port>
- <rhq.dev.ds.db-name>rhq</rhq.dev.ds.db-name>
- <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.SQLServerDialect</rhq.dev.ds.hibernate-dialect>
+
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.MSSQLDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>UPDATE {0}LOCKS SET LOCK_NAME = LOCK_NAME WHERE LOCK_NAME = ?</rhq.dev.quartz.selectWithLockSQL>
@@ -198,31 +167,21 @@
<profile>
<id>oracle</id>
<properties>
- <rhq.test.ds.connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</rhq.test.ds.connection-url>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>Oracle10g</rhq.test.ds.type-mapping>
- <rhq.test.ds.driver-class>oracle.jdbc.driver.OracleDriver</rhq.test.ds.driver-class>
- <rhq.test.ds.xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.server-name></rhq.test.ds.server-name> <!-- can be left blank, oracle does not use this -->
- <rhq.test.ds.port></rhq.test.ds.port> <!-- can be left blank, oracle does not use this -->
- <rhq.test.ds.db-name></rhq.test.ds.db-name> <!-- can be left blank, oracle does not use this -->
- <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.Oracle10gDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</rhq.ds.connection-url>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.type-mapping>Oracle10g</rhq.ds.type-mapping>
+ <rhq.ds.driver-class>oracle.jdbc.driver.OracleDriver</rhq.ds.driver-class>
+ <rhq.ds.xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.server-name></rhq.ds.server-name> <!-- can be left blank, oracle does not use this -->
+ <rhq.ds.port></rhq.ds.port> <!-- can be left blank, oracle does not use this -->
+ <rhq.ds.db-name></rhq.ds.db-name> <!-- can be left blank, oracle does not use this -->
+ <rhq.ds.hibernate-dialect>org.hibernate.dialect.Oracle10gDialect</rhq.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.oracle.OracleDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
- <rhq.dev.ds.connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</rhq.dev.ds.connection-url>
- <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
- <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
- <rhq.dev.ds.type-mapping>Oracle10g</rhq.dev.ds.type-mapping>
- <rhq.dev.ds.driver-class>oracle.jdbc.driver.OracleDriver</rhq.dev.ds.driver-class>
- <rhq.dev.ds.xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</rhq.dev.ds.xa-datasource-class>
- <rhq.dev.ds.server-name></rhq.dev.ds.server-name> <!-- can be left blank, oracle does not use this -->
- <rhq.dev.ds.port></rhq.dev.ds.port> <!-- can be left blank, oracle does not use this -->
- <rhq.dev.ds.db-name></rhq.dev.ds.db-name> <!-- can be left blank, oracle does not use this -->
- <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.Oracle10gDialect</rhq.dev.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.oracle.OracleDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.dev.quartz.selectWithLockSQL>
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index be3fbe3..7e58645 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -205,23 +205,11 @@
<phase>process-classes</phase>
<configuration>
<tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}"/>
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}"/>
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}"/>
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}"/>
+ <property name="rhq.ds.password" value="${rhq.ds.password}"/>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -253,28 +241,13 @@
<id>test-db-schema-version</id>
<phase>test</phase>
<configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -321,24 +294,12 @@
<phase>test</phase>
<configuration>
<tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="create-release-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
@@ -352,10 +313,10 @@
<property name="rhq.ds.password" value="${rhq.ds.password}" />
<property name="project.version" value="${project.version}" />
<property name="db.schema.version" value="${db.schema.version}" />
- <property name="jon.release" value="${jon.release}" />
- </ant>
- </tasks>
- </configuration>
+ <property name="jon.release" value="${jon.release}" />
+ </ant>
+ </tasks>
+ </configuration>
<goals>
<goal>run</goal>
</goals>
diff --git a/modules/core/domain/pom.xml b/modules/core/domain/pom.xml
index 42d28e1..c8ce307 100644
--- a/modules/core/domain/pom.xml
+++ b/modules/core/domain/pom.xml
@@ -282,7 +282,7 @@
</property>
<property>
<name>hibernate.dialect</name>
- <value>${rhq.test.ds.hibernate-dialect}</value>
+ <value>${rhq.ds.hibernate-dialect}</value>
</property>
</systemProperties>
<excludes>
diff --git a/modules/core/domain/src/test/resources/embedded-jboss-beans.xml b/modules/core/domain/src/test/resources/embedded-jboss-beans.xml
index ae9de01..a51f3e3 100644
--- a/modules/core/domain/src/test/resources/embedded-jboss-beans.xml
+++ b/modules/core/domain/src/test/resources/embedded-jboss-beans.xml
@@ -85,10 +85,10 @@
-->
<bean name="RHQDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
- <property name="driverClass">${rhq.test.ds.driver-class}</property>
- <property name="connectionURL">${rhq.test.ds.connection-url}</property>
- <property name="userName">${rhq.test.ds.user-name}</property>
- <property name="password">${rhq.test.ds.password}</property>
+ <property name="driverClass">${rhq.ds.driver-class}</property>
+ <property name="connectionURL">${rhq.ds.connection-url}</property>
+ <property name="userName">${rhq.ds.user-name}</property>
+ <property name="password">${rhq.ds.password}</property>
<property name="jndiName">java:/RHQDS</property>
<property name="minSize">0</property>
<property name="maxSize">10</property>
diff --git a/modules/enterprise/gui/installer-war/pom.xml b/modules/enterprise/gui/installer-war/pom.xml
index 517399c..f73e403 100644
--- a/modules/enterprise/gui/installer-war/pom.xml
+++ b/modules/enterprise/gui/installer-war/pom.xml
@@ -147,13 +147,13 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
- <rhq.test.ds.server-name>${rhq.test.ds.server-name}</rhq.test.ds.server-name>
- <rhq.test.ds.db-name>${rhq.test.ds.db-name}</rhq.test.ds.db-name>
- <rhq.test.ds.connection-url>${rhq.test.ds.connection-url}</rhq.test.ds.connection-url>
+ <rhq.ds.server-name>${rhq.ds.server-name}</rhq.ds.server-name>
+ <rhq.ds.db-name>${rhq.ds.db-name}</rhq.ds.db-name>
+ <rhq.ds.connection-url>${rhq.ds.connection-url}</rhq.ds.connection-url>
<rhq.db.admin.username>${rhq.db.admin.username}</rhq.db.admin.username>
<rhq.db.admin.password>${rhq.db.admin.password}</rhq.db.admin.password>
- <rhq.test.ds.user-name>${rhq.test.ds.user-name}</rhq.test.ds.user-name>
- <rhq.test.ds.password>${rhq.test.ds.password}</rhq.test.ds.password>
+ <rhq.ds.user-name>${rhq.ds.user-name}</rhq.ds.user-name>
+ <rhq.ds.password>${rhq.ds.password}</rhq.ds.password>
</systemPropertyVariables>
</configuration>
</plugin>
diff --git a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
index 579bebf..0e68830 100644
--- a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
+++ b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
@@ -46,11 +46,11 @@ import java.util.Properties;
public class DBInstallatonTest {
private final String LOG_DIRECTORY = System.getProperty("java.io.tmpdir", "rhq/installer-test");
- private final String TEST_DB = System.getProperty("rhq.test.ds.db-name","rhq_installer_test_db");
- private final String USERNAME = System.getProperty("rhq.test.ds.user-name", "rhqadmin");
- private final String PASSWORD = System.getProperty("rhq.test.ds.password", "rhqadmin");
- private final String SERVER = System.getProperty("rhq.test.ds.server-name", "127.0.0.1");
- private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
+ private final String TEST_DB = System.getProperty("rhq.ds.db-name","rhq_installer_test_db");
+ private final String USERNAME = System.getProperty("rhq.ds.user-name", "rhqadmin");
+ private final String PASSWORD = System.getProperty("rhq.ds.password", "rhqadmin");
+ private final String SERVER = System.getProperty("rhq.ds.server-name", "127.0.0.1");
+ private final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
private final String ADMIN_USERNAME = System.getProperty("rhq.db.admin.username", "postgres");
private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
diff --git a/modules/enterprise/server/container/pom.xml b/modules/enterprise/server/container/pom.xml
index 7329bb5..8e59747 100644
--- a/modules/enterprise/server/container/pom.xml
+++ b/modules/enterprise/server/container/pom.xml
@@ -183,16 +183,16 @@
<property name="quartz.version" value="${quartz.version}" />
<!-- dev DB settings (used to init rhq-server.properties if dev profile is active or developer prop is set) -->
- <property name="rhq.dev.ds.connection-url" value="${rhq.dev.ds.connection-url}" />
- <property name="rhq.dev.ds.driver-class" value="${rhq.dev.ds.driver-class}" />
- <property name="rhq.dev.ds.xa-datasource-class" value="${rhq.dev.ds.xa-datasource-class}" />
- <property name="rhq.dev.ds.user-name" value="${rhq.dev.ds.user-name}" />
- <property name="rhq.dev.ds.password.encrypted" value="${rhq.dev.ds.password.encrypted}" />
- <property name="rhq.dev.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" />
- <property name="rhq.dev.ds.server-name" value="${rhq.dev.ds.server-name}" />
- <property name="rhq.dev.ds.port" value="${rhq.dev.ds.port}" />
- <property name="rhq.dev.ds.db-name" value="${rhq.dev.ds.db-name}" />
- <property name="rhq.dev.ds.hibernate-dialect" value="${rhq.dev.ds.hibernate-dialect}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
+ <property name="rhq.ds.xa-datasource-class" value="${rhq.ds.xa-datasource-class}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password.encrypted" value="${rhq.ds.password.encrypted}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.server-name" value="${rhq.ds.server-name}" />
+ <property name="rhq.ds.port" value="${rhq.ds.port}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.hibernate-dialect" value="${rhq.ds.hibernate-dialect}" />
<property name="rhq.dev.quartz.driverDelegateClass" value="${rhq.dev.quartz.driverDelegateClass}" />
<property name="rhq.dev.quartz.selectWithLockSQL" value="${rhq.dev.quartz.selectWithLockSQL}" />
<property name="rhq.dev.quartz.lockHandlerClass" value="${rhq.dev.quartz.lockHandlerClass}" />
@@ -233,8 +233,7 @@
<property name="rhq.earName" value="${rhq.earName}" />
<!-- dev/test DB type (needed to init rhq-ds.xml) -->
- <property name="rhq.test.ds.type-mapping" value="${rhq.test.ds.type-mapping}" />
- <property name="rhq.dev.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
<property name="rhq.server.enable.web.services" value="${rhq.server.enable.ws}" />
</ant>
</tasks>
diff --git a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
index 704c50a..c4d83a0 100644
--- a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
@@ -33,16 +33,16 @@
<target name="set-dev-server-props" if="predeploy">
<echo>*** Using dev database settings in rhq-server.properties...</echo>
- <property name="rhq.server.database.hibernate-dialect" value="${rhq.dev.ds.hibernate-dialect}" />
- <property name="rhq.server.database.connection-url" value="${rhq.dev.ds.connection-url}" />
- <property name="rhq.server.database.driver-class" value="${rhq.dev.ds.driver-class}" />
- <property name="rhq.server.database.xa-datasource-class" value="${rhq.dev.ds.xa-datasource-class}" />
- <property name="rhq.server.database.user-name" value="${rhq.dev.ds.user-name}" />
- <property name="rhq.server.database.password" value="${rhq.dev.ds.password.encrypted}" />
- <property name="rhq.server.database.type-mapping" value="${rhq.dev.ds.type-mapping}" />
- <property name="rhq.server.database.server-name" value="${rhq.dev.ds.server-name}" />
- <property name="rhq.server.database.port" value="${rhq.dev.ds.port}" />
- <property name="rhq.server.database.db-name" value="${rhq.dev.ds.db-name}" />
+ <property name="rhq.server.database.hibernate-dialect" value="${rhq.ds.hibernate-dialect}" />
+ <property name="rhq.server.database.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.server.database.driver-class" value="${rhq.ds.driver-class}" />
+ <property name="rhq.server.database.xa-datasource-class" value="${rhq.ds.xa-datasource-class}" />
+ <property name="rhq.server.database.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.server.database.password" value="${rhq.ds.password.encrypted}" />
+ <property name="rhq.server.database.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.server.database.server-name" value="${rhq.ds.server-name}" />
+ <property name="rhq.server.database.port" value="${rhq.ds.port}" />
+ <property name="rhq.server.database.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.server.quartz.driverDelegateClass" value="${rhq.dev.quartz.driverDelegateClass}" />
<property name="rhq.server.quartz.selectWithLockSQL" value="${rhq.dev.quartz.selectWithLockSQL}" />
<property name="rhq.server.quartz.lockHandlerClass" value="${rhq.dev.quartz.lockHandlerClass}" />
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index c5bb3ec..000808c 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -559,7 +559,7 @@ Build-OS-Version=${os.version}
<systemPropertyVariables>
<embeddedDeployment>true</embeddedDeployment>
<deploymentDirectory>target/classes</deploymentDirectory>
- <hibernate.dialect>${rhq.test.ds.hibernate-dialect}</hibernate.dialect>
+ <hibernate.dialect>${rhq.ds.hibernate-dialect}</hibernate.dialect>
<clean.db>${clean.db}</clean.db>
</systemPropertyVariables>
<additionalClasspathElements>
diff --git a/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml b/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml
index 55d697b..05451bd 100644
--- a/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml
+++ b/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml
@@ -76,10 +76,10 @@
</bean>
<bean name="RHQDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
- <property name="driverClass">${rhq.test.ds.driver-class}</property>
- <property name="connectionURL">${rhq.test.ds.connection-url}</property>
- <property name="userName">${rhq.test.ds.user-name}</property>
- <property name="password">${rhq.test.ds.password}</property>
+ <property name="driverClass">${rhq.ds.driver-class}</property>
+ <property name="connectionURL">${rhq.ds.connection-url}</property>
+ <property name="userName">${rhq.ds.user-name}</property>
+ <property name="password">${rhq.ds.password}</property>
<property name="jndiName">java:/RHQDS</property>
<property name="minSize">0</property>
<property name="maxSize">20</property>
@@ -104,10 +104,10 @@
<!-- needed for Quartz' no-TX data source (even though this is a local-tx, seems like Quartz is still working) -->
<bean name="NoTxRHQDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
- <property name="driverClass">${rhq.test.ds.driver-class}</property>
- <property name="connectionURL">${rhq.test.ds.connection-url}</property>
- <property name="userName">${rhq.test.ds.user-name}</property>
- <property name="password">${rhq.test.ds.password}</property>
+ <property name="driverClass">${rhq.ds.driver-class}</property>
+ <property name="connectionURL">${rhq.ds.connection-url}</property>
+ <property name="userName">${rhq.ds.user-name}</property>
+ <property name="password">${rhq.ds.password}</property>
<property name="jndiName">java:/NoTxRHQDS</property>
<property name="minSize">0</property>
<property name="maxSize">10</property>
diff --git a/modules/jopr/release.sh b/modules/jopr/release.sh
index 54f26ab..c05b6ee 100755
--- a/modules/jopr/release.sh
+++ b/modules/jopr/release.sh
@@ -226,16 +226,16 @@ cat <<EOF >${SETTINGS}
<profile>
<id>release</id>
<properties>
- <rhq.test.ds.connection-url>jdbc:postgresql://jon03.qa.atl2.redhat.com:5432/rhq_release</rhq.test.ds.connection-url>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
- <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
- <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.server-name>jon03.qa.atl2.redhat.com</rhq.test.ds.server-name>
- <rhq.test.ds.port>5432</rhq.test.ds.port>
- <rhq.test.ds.db-name>rhq_release</rhq.test.ds.db-name>
- <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.connection-url>jdbc:postgresql://jon03.qa.atl2.redhat.com:5432/rhq_release</rhq.ds.connection-url>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
+ <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
+ <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.server-name>jon03.qa.atl2.redhat.com</rhq.ds.server-name>
+ <rhq.ds.port>5432</rhq.ds.port>
+ <rhq.ds.db-name>rhq_release</rhq.ds.db-name>
+ <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
diff --git a/pom.xml b/pom.xml
index 549e0d0..23afa62 100644
--- a/pom.xml
+++ b/pom.xml
@@ -107,42 +107,22 @@
defaults for datasource used by integration tests -
these may be overridden in ~/.m2/settings.xml
-->
- <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
- <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.test.ds.db-name}</rhq.test.ds.connection-url>
- <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
- <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
- <rhq.test.ds.server-name>127.0.0.1</rhq.test.ds.server-name>
- <rhq.test.ds.port>5432</rhq.test.ds.port>
- <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.db-name>rhq</rhq.ds.db-name>
+ <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.ds.db-name}</rhq.ds.connection-url>
+ <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
+ <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.password.encrypted>1eeb2f255e832171df8592078de921bc</rhq.ds.password.encrypted>
+ <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
+ <rhq.ds.server-name>127.0.0.1</rhq.ds.server-name>
+ <rhq.ds.port>5432</rhq.ds.port>
+ <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>
SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE
</rhq.test.quartz.selectWithLockSQL>
- <rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
-
- <!--
- defaults for datasource used by the dev container build (see dev docs on the 'dev' profile) -
- these may be overridden in ~/.m2/settings.xml
- -->
- <rhq.dev.ds.db-name>rhqdev</rhq.dev.ds.db-name>
- <rhq.dev.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.dev.ds.db-name}</rhq.dev.ds.connection-url>
- <rhq.dev.ds.driver-class>org.postgresql.Driver</rhq.dev.ds.driver-class>
- <rhq.dev.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.dev.ds.xa-datasource-class>
- <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
- <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
- <rhq.dev.ds.password.encrypted>1eeb2f255e832171df8592078de921bc</rhq.dev.ds.password.encrypted>
- <rhq.dev.ds.type-mapping>PostgreSQL</rhq.dev.ds.type-mapping>
- <rhq.dev.ds.server-name>127.0.0.1</rhq.dev.ds.server-name>
- <rhq.dev.ds.port>5432</rhq.dev.ds.port>
- <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.dev.ds.hibernate-dialect>
- <rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.dev.quartz.driverDelegateClass>
- <rhq.dev.quartz.selectWithLockSQL>
- SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE
- </rhq.dev.quartz.selectWithLockSQL>
- <rhq.dev.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.dev.quartz.lockHandlerClass>
+ <rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
<!-- default port numbers for RHQ server -->
<rhq.server.http.port>7080</rhq.server.http.port>
diff --git a/release.sh b/release.sh
index 316af14..4c7166e 100755
--- a/release.sh
+++ b/release.sh
@@ -282,16 +282,16 @@ cat <<EOF >"${MAVEN_SETTINGS_FILE}"
<profile>
<id>release</id>
<properties>
- <rhq.test.ds.server-name>hudson-qe.rhq.rdu.redhat.com</rhq.test.ds.server-name>
- <rhq.test.ds.port>5432</rhq.test.ds.port>
- <rhq.test.ds.db-name>rhq_release_tag</rhq.test.ds.db-name>
- <rhq.test.ds.connection-url>jdbc:postgresql://hudson-qe.rhq.rdu.redhat.com:5432/rhq_release_tag</rhq.test.ds.connection-url>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
- <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
- <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.server-name>hudson-qe.rhq.rdu.redhat.com</rhq.ds.server-name>
+ <rhq.ds.port>5432</rhq.ds.port>
+ <rhq.ds.db-name>rhq_release_tag</rhq.ds.db-name>
+ <rhq.ds.connection-url>jdbc:postgresql://hudson-qe.rhq.rdu.redhat.com:5432/rhq_release_tag</rhq.ds.connection-url>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
+ <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
+ <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
commit 550d8fea05f98554643f1ba1c91ae56630ef9d20
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 21 13:31:40 2011 -0500
Moving dbreset from inline groovy script to a java file.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index e2a599d..be3fbe3 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -34,6 +34,13 @@
<artifactId>ant</artifactId>
<version>1.6.5</version>
</dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+
<dependency>
<groupId>ant</groupId>
@@ -50,9 +57,7 @@
<dependency>
<groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>test</scope>
+ <artifactId>postgresql</artifactId>
</dependency>
<dependency>
@@ -74,65 +79,29 @@
<build>
<plugins>
<plugin>
- <groupId>org.codehaus.groovy.maven</groupId>
- <artifactId>gmaven-plugin</artifactId>
- <version>1.0</version>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2</version>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
</dependencies>
<executions>
<execution>
- <phase>compile</phase>
+ <phase>process-classes</phase>
<goals>
- <goal>execute</goal>
+ <goal>java</goal>
</goals>
<configuration>
- <source>
- import org.postgresql.Driver
- import groovy.sql.Sql
-
- if (!project.properties.dbreset) {
- return
- }
-
- db = project.properties.db
- if (db == 'dev') {
- database = project.properties['rhq.dev.ds.db-name']
- server = project.properties['rhq.dev.ds.server-name'] ?: '127.0.0.1'
- rhqUser = project.properties['rhq.dev.ds.user-name'] ?: 'rhqadmin'
- }
- else {
- database = project.properties['rhq.test.ds.db-name']
- server = project.properties['rhq.test.ds.server-name'] ?: '127.0.0.1'
- rhqUser = project.properties['rhq.test.ds.user-name'] ?: 'rhqadmin'
- }
-
- // The upgrade.db property should be set for local builds when you
- // need to test upgrade changes. Hudson builds will specify the
- // database to use in settings.xml
- if (project.properties['upgrade.db']) {
- database = 'rhqupgrade'
- }
-
- adminUsername = project.properties['rhq.db.admin.username'] ?: 'postgres'
- adminPassword = project.properties['rhq.db.admin.password'] ?: 'postgres'
- project.properties.dbsetup = 'true'
-
- sql = Sql.newInstance(
- "jdbc:postgresql://${server}:5432/postgres",
- adminUsername,
- adminPassword,
- "org.postgresql.Driver")
-
- sql.execute("drop database if exists ${Sql.expand(database)};")
- log.info("dropped database $database")
- sql.execute("create database ${Sql.expand(database)} with owner ${Sql.expand(rhqUser)};")
- log.info("created database $database")
- </source>
+ <mainClass>org.rhq.core.db.reset.DBReset</mainClass>
</configuration>
</execution>
</executions>
@@ -201,22 +170,10 @@
<configuration>
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}"/>
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}"/>
+ <property name="rhq.ds.password" value="${rhq.ds.password}"/>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml">
<property name="settings.localRepository" value="${settings.localRepository}" />
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
new file mode 100644
index 0000000..2d85ff0
--- /dev/null
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -0,0 +1,95 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.core.db.reset;
+
+import java.sql.Connection;
+import java.sql.Statement;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.db.DbUtil;
+
+//import groovy.sql.Sql;
+
+/**
+ * @author Stefan Negrea
+ *
+ */
+public class DBReset {
+ private static Log log = LogFactory.getLog(DBReset.class);
+
+ private final String DB = System.getProperty("rhq.ds.db-name", "rhq_installer_test_db");
+ private final String SERVER = System.getProperty("rhq.ds.server-name", "127.0.0.1");
+ private final String USER = System.getProperty("rhq.ds.user-name", "rhqadmin");
+ private final String ADMIN_USER = System.getProperty("rhq.db.admin.username", "postgres");
+ private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
+ private final String DB_RESET = System.getProperty("dbreset", "false");
+ private final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"
+ + DB);
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ DBReset dbreset = new DBReset();
+
+ try {
+ dbreset.performDBReset();
+ } catch (Exception e) {
+ log.info(e);
+ System.exit(1);
+ }
+ }
+
+ private void performDBReset() throws Exception {
+ if (DB_RESET.equals("false")) {
+ return;
+ }
+
+ System.setProperty("dbsetup", "true");
+
+ Connection connection = null;
+ Statement dropDB = null;
+ Statement createDB = null;
+
+ try {
+ connection = DbUtil.getConnection(DB_URL.replace(DB, "postgres"), ADMIN_USER, ADMIN_PASSWORD);
+
+ dropDB = connection.createStatement();
+ dropDB.execute("drop database if exists " + DB);
+
+ createDB = connection.createStatement();
+ createDB.execute("create database " + DB + " with owner " + USER);
+
+ log.info("created database $database");
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
+ if (dropDB != null) {
+ dropDB.close();
+ }
+ if (createDB != null) {
+ createDB.close();
+ }
+ }
+ }
+}
commit 19437cae8ca6ceb053fa191e08dff6368b8574b9
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 4 07:44:43 2011 -0500
Throw an exception if trying to use dbreset with anything else other than Oracle and Postgres.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 4736988..ce12786 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -132,5 +132,8 @@ public class DBReset {
}
}
}
+ else {
+ throw new Exception("dbreset not supported for "+ dbTypeMapping +"!");
+ }
}
}
commit b4746083421af4d6a0ae4991dbcbf90272ff67a8
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Aug 3 12:23:44 2011 -0500
Forgot to replace three properties with the params after refactoring dbreset.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 9cd49e4..4736988 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -69,6 +69,7 @@ public class DBReset {
public void performDBReset(String dbTypeMapping, String dbUrl, String dbName, String user, String adminUser,
String adminPassword) throws Exception {
if (dbTypeMapping.equals("PostgreSQL")) {
+ System.out.println("PostgreSQL started!");
Connection connection = null;
Statement dropDB = null;
Statement createDB = null;
@@ -95,12 +96,12 @@ public class DBReset {
}
}
- } else if (DB_TYPE_MAPPING.equals("Oracle10g")) {
+ } else if (dbTypeMapping.equals("Oracle10g")) {
Connection connection = null;
PreparedStatement cleanUserStatement = null;
try {
- connection = DbUtil.getConnection(DB_URL, adminUser, ADMIN_PASSWORD);
+ connection = DbUtil.getConnection(dbUrl, adminUser, adminPassword);
connection.setAutoCommit(false);
String plsql = "declare cursor all_objects_to_drop is\n"
commit c89fd0c3b66219fbce0b3f079ea7ade0ddcee14f
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Aug 2 18:25:57 2011 -0500
DB installation test now uses dbreset to propertly reset the database (even for Oracle configurations).
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 3f99d10..9cd49e4 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -39,14 +39,13 @@ public class DBReset {
private static final String DB_NAME = System.getProperty("rhq.ds.db-name", "rhq_installer_test_db");
private static final String SERVER = System.getProperty("rhq.ds.server-name", "127.0.0.1");
+ private static final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER
+ + ":5432/" + DB_NAME);
private static final String USER = System.getProperty("rhq.ds.user-name", "rhqadmin");
private static final String ADMIN_USER = System.getProperty("rhq.db.admin.username", "postgres");
private static final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
- private static final String DB_RESET = System.getProperty("dbreset", "false");
- private static final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER
- + ":5432/" + DB_NAME);
-
private static final String DB_TYPE_MAPPING = System.getProperty("rhq.ds.type-mapping", "PostgreSQL");
+ private static final String DB_RESET = System.getProperty("dbreset", "false");
/**
* @param args
@@ -67,7 +66,7 @@ public class DBReset {
}
}
- private void performDBReset(String dbTypeMapping, String dbUrl, String dbName, String user, String adminUser,
+ public void performDBReset(String dbTypeMapping, String dbUrl, String dbName, String user, String adminUser,
String adminPassword) throws Exception {
if (dbTypeMapping.equals("PostgreSQL")) {
Connection connection = null;
diff --git a/modules/enterprise/gui/installer-war/pom.xml b/modules/enterprise/gui/installer-war/pom.xml
index 517399c..900d476 100644
--- a/modules/enterprise/gui/installer-war/pom.xml
+++ b/modules/enterprise/gui/installer-war/pom.xml
@@ -147,6 +147,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
+ <rhq.test.ds.type-mapping>${rhq.test.ds.type-mapping}</rhq.test.ds.type-mapping>
<rhq.test.ds.server-name>${rhq.test.ds.server-name}</rhq.test.ds.server-name>
<rhq.test.ds.db-name>${rhq.test.ds.db-name}</rhq.test.ds.db-name>
<rhq.test.ds.connection-url>${rhq.test.ds.connection-url}</rhq.test.ds.connection-url>
diff --git a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java
index 956e25e..6633cb7 100644
--- a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java
+++ b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java
@@ -23,18 +23,18 @@
package org.rhq.enterprise.installer;
-import org.rhq.core.db.DbUtil;
-import org.rhq.core.db.setup.DBSetup;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
import java.io.File;
-import java.net.URI;
import java.net.URL;
-import java.sql.Connection;
-import java.sql.Statement;
import java.util.Properties;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import org.rhq.core.db.reset.DBReset;
+import org.rhq.core.db.setup.DBSetup;
+import org.rhq.enterprise.installer.ServerInformation;
+import org.rhq.enterprise.installer.ServerProperties;
+
/**
* The tests in this class exercise the dbsetup/dbupgrade code that is run in the installer. The tests currently only
* run against postgresql. Support needs to be added for oracle. The tests do not do any post-install/upgrade
@@ -46,13 +46,15 @@ import java.util.Properties;
public class DBInstallationTest {
private final String LOG_DIRECTORY = System.getProperty("java.io.tmpdir", "rhq/installer-test");
- private final String TEST_DB = System.getProperty("rhq.test.ds.db-name","rhq_installer_test_db");
+ private final String DB_NAME = System.getProperty("rhq.test.ds.db-name", "rhq_installer_test_db");
private final String USERNAME = System.getProperty("rhq.test.ds.user-name", "rhqadmin");
private final String PASSWORD = System.getProperty("rhq.test.ds.password", "rhqadmin");
private final String SERVER = System.getProperty("rhq.test.ds.server-name", "127.0.0.1");
- private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
+ private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER
+ + ":5432/" + DB_NAME);
private final String ADMIN_USERNAME = System.getProperty("rhq.db.admin.username", "postgres");
private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
+ private static final String DB_TYPE_MAPPING = System.getProperty("rhq.test.ds.type-mapping", "PostgreSQL");
private ServerInformation installer;
@@ -79,8 +81,8 @@ public class DBInstallationTest {
@Test
public void overwriteJON231Schema() throws Exception {
- installSchemaAndData("2.3.1");
- installer.createNewDatabaseSchema(getInstallProperties());
+ installSchemaAndData("2.3.1");
+ installer.createNewDatabaseSchema(getInstallProperties());
}
@Test
@@ -88,13 +90,13 @@ public class DBInstallationTest {
installSchemaAndData("2.3.1");
installer.upgradeExistingDatabaseSchema(getInstallProperties());
}
-
+
@Test
public void overwriteJON240Schema() throws Exception {
- installSchemaAndData("2.4.0");
- installer.createNewDatabaseSchema(getInstallProperties());
+ installSchemaAndData("2.4.0");
+ installer.createNewDatabaseSchema(getInstallProperties());
}
-
+
@Test
public void upgradeJON240Schema() throws Exception {
installSchemaAndData("2.4.0");
@@ -110,29 +112,8 @@ public class DBInstallationTest {
}
private void recreateTestDatabase() throws Exception {
- Connection connection = null;
- Statement dropDB = null;
- Statement createDB = null;
-
- try {
- connection = DbUtil.getConnection(DB_URL.replace(TEST_DB,"postgres"), ADMIN_USERNAME, ADMIN_PASSWORD);
-
- dropDB = connection.createStatement();
- dropDB.execute("drop database if exists " + TEST_DB);
-
- createDB = connection.createStatement();
- createDB.execute("create database " + TEST_DB + " with owner " + USERNAME);
- } finally {
- if (connection != null) {
- connection.close();
- }
- if (dropDB != null) {
- dropDB.close();
- }
- if (createDB != null) {
- createDB.close();
- }
- }
+ DBReset dbReset = new DBReset();
+ dbReset.performDBReset(DB_TYPE_MAPPING, DB_URL, DB_NAME, USERNAME, ADMIN_USERNAME, ADMIN_PASSWORD);
}
private void installSchemaAndData(String jonVersion) throws Exception {
commit 3d19754c73074ab2478d8b537af48878dd7863e1
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Aug 2 18:14:51 2011 -0500
Make dbreset configurable to it can be used/consumed by other modules.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 8a32c43..3f99d10 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -37,53 +37,53 @@ import org.rhq.core.db.DbUtil;
public class DBReset {
private static Log log = LogFactory.getLog(DBReset.class);
- private final String DB = System.getProperty("rhq.ds.db-name", "rhq_installer_test_db");
- private final String SERVER = System.getProperty("rhq.ds.server-name", "127.0.0.1");
- private final String USER = System.getProperty("rhq.ds.user-name", "rhqadmin");
- private final String ADMIN_USER = System.getProperty("rhq.db.admin.username", "postgres");
- private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
- private final String DB_RESET = System.getProperty("dbreset", "false");
- private final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"
- + DB);
+ private static final String DB_NAME = System.getProperty("rhq.ds.db-name", "rhq_installer_test_db");
+ private static final String SERVER = System.getProperty("rhq.ds.server-name", "127.0.0.1");
+ private static final String USER = System.getProperty("rhq.ds.user-name", "rhqadmin");
+ private static final String ADMIN_USER = System.getProperty("rhq.db.admin.username", "postgres");
+ private static final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
+ private static final String DB_RESET = System.getProperty("dbreset", "false");
+ private static final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER
+ + ":5432/" + DB_NAME);
- private final String DB_TYPE_MAPPING = System.getProperty("rhq.ds.type-mapping", "PostgreSQL");
+ private static final String DB_TYPE_MAPPING = System.getProperty("rhq.ds.type-mapping", "PostgreSQL");
/**
* @param args
*/
public static void main(String[] args) {
+ if (DB_RESET.equals("false")) {
+ return;
+ }
+
DBReset dbreset = new DBReset();
try {
- dbreset.performDBReset();
+ dbreset.performDBReset(DB_TYPE_MAPPING, DB_URL, DB_NAME, USER, ADMIN_USER, ADMIN_PASSWORD);
+ System.setProperty("dbsetup", "true");
} catch (Exception e) {
log.info(e);
System.exit(1);
}
}
- private void performDBReset() throws Exception {
- if (DB_RESET.equals("false")) {
- return;
- }
-
- System.setProperty("dbsetup", "true");
-
- if (DB_TYPE_MAPPING.equals("PostgreSQL")) {
+ private void performDBReset(String dbTypeMapping, String dbUrl, String dbName, String user, String adminUser,
+ String adminPassword) throws Exception {
+ if (dbTypeMapping.equals("PostgreSQL")) {
Connection connection = null;
Statement dropDB = null;
Statement createDB = null;
try {
- connection = DbUtil.getConnection(DB_URL.replace(DB, "postgres"), ADMIN_USER, ADMIN_PASSWORD);
+ connection = DbUtil.getConnection(dbUrl.replace(dbName, "postgres"), adminUser, adminPassword);
dropDB = connection.createStatement();
- dropDB.execute("drop database if exists " + DB);
+ dropDB.execute("drop database if exists " + dbName);
createDB = connection.createStatement();
- createDB.execute("create database " + DB + " with owner " + USER);
+ createDB.execute("create database " + dbName + " with owner " + user);
- log.info("Dropped and created database " + DB + ".");
+ log.info("Dropped and created postgres database " + dbName + ".");
} finally {
if (dropDB != null) {
dropDB.close();
@@ -101,7 +101,7 @@ public class DBReset {
PreparedStatement cleanUserStatement = null;
try {
- connection = DbUtil.getConnection(DB_URL, ADMIN_USER, ADMIN_PASSWORD);
+ connection = DbUtil.getConnection(DB_URL, adminUser, ADMIN_PASSWORD);
connection.setAutoCommit(false);
String plsql = "declare cursor all_objects_to_drop is\n"
@@ -118,12 +118,11 @@ public class DBReset {
+ " end;\n"
+ " end loop;\n"
+ " end;\n";
- log.info(plsql);
cleanUserStatement = connection.prepareStatement(plsql);
cleanUserStatement.execute();
connection.commit();
- log.info("Cleand database " + DB + ".");
+ log.info("Cleaned Oracle database " + dbName + ".");
} finally {
if (cleanUserStatement != null) {
cleanUserStatement.close();
commit 01916aee00baea73f8cae784eac6b2d950ebe453
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 21:21:07 2011 -0500
Removing extra character inserted inadvertently.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 318afde..6a599c0 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -21,7 +21,7 @@
<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>
<rhq.ds.user-name>${rhq.test.ds.user-name}</rhq.ds.user-name>
- <rhq.ds.password>${rhq.test.ds.password}></rhq.ds.password>
+ <rhq.ds.password>${rhq.test.ds.password}</rhq.ds.password>
<rhq.ds.driver-class>${rhq.test.ds.driver-class}</rhq.ds.driver-class>
</properties>
<dependencies>
@@ -165,7 +165,7 @@
<rhq.ds.db-name>${rhq.dev.ds.db-name}</rhq.ds.db-name>
<rhq.ds.connection-url>${rhq.dev.ds.connection-url}</rhq.ds.connection-url>
<rhq.ds.user-name>${rhq.dev.ds.user-name}</rhq.ds.user-name>
- <rhq.ds.password>${rhq.dev.ds.password}></rhq.ds.password>
+ <rhq.ds.password>${rhq.dev.ds.password}</rhq.ds.password>
<rhq.ds.driver-class>${rhq.dev.ds.driver-class}</rhq.ds.driver-class>
</properties>
</profile>
commit 911a6035859f0ddd62c5defad3d843d54fb01e8a
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 18:50:28 2011 -0500
Correct the class file name.
diff --git a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java
new file mode 100644
index 0000000..956e25e
--- /dev/null
+++ b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java
@@ -0,0 +1,172 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.installer;
+
+import org.rhq.core.db.DbUtil;
+import org.rhq.core.db.setup.DBSetup;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.util.Properties;
+
+/**
+ * The tests in this class exercise the dbsetup/dbupgrade code that is run in the installer. The tests currently only
+ * run against postgresql. Support needs to be added for oracle. The tests do not do any post-install/upgrade
+ * verification at the time of this writing. They just simply exercise the dbsetup/dbupgrade scripts to ensure that
+ * they do not contain any errors.
+ *
+ * @author John Sanda
+ */
+public class DBInstallationTest {
+
+ private final String LOG_DIRECTORY = System.getProperty("java.io.tmpdir", "rhq/installer-test");
+ private final String TEST_DB = System.getProperty("rhq.test.ds.db-name","rhq_installer_test_db");
+ private final String USERNAME = System.getProperty("rhq.test.ds.user-name", "rhqadmin");
+ private final String PASSWORD = System.getProperty("rhq.test.ds.password", "rhqadmin");
+ private final String SERVER = System.getProperty("rhq.test.ds.server-name", "127.0.0.1");
+ private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
+ private final String ADMIN_USERNAME = System.getProperty("rhq.db.admin.username", "postgres");
+ private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
+
+ private ServerInformation installer;
+
+ @BeforeMethod
+ public void prepareForInstallation() throws Exception {
+ initLogDirectory();
+ recreateTestDatabase();
+
+ installer = new ServerInformation();
+ installer.setLogDirectory(new File(LOG_DIRECTORY));
+ }
+
+ @Test
+ public void overwriteJON230Schema() throws Exception {
+ installSchemaAndData("2.3.0");
+ installer.createNewDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void upgradeJON230Schema() throws Exception {
+ installSchemaAndData("2.3.0");
+ installer.upgradeExistingDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void overwriteJON231Schema() throws Exception {
+ installSchemaAndData("2.3.1");
+ installer.createNewDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void upgradeJON231Schema() throws Exception {
+ installSchemaAndData("2.3.1");
+ installer.upgradeExistingDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void overwriteJON240Schema() throws Exception {
+ installSchemaAndData("2.4.0");
+ installer.createNewDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void upgradeJON240Schema() throws Exception {
+ installSchemaAndData("2.4.0");
+ installer.upgradeExistingDatabaseSchema(getInstallProperties());
+ }
+
+ private void initLogDirectory() {
+ File logDir = new File(LOG_DIRECTORY);
+ if (logDir.exists()) {
+ logDir.delete();
+ }
+ logDir.mkdirs();
+ }
+
+ private void recreateTestDatabase() throws Exception {
+ Connection connection = null;
+ Statement dropDB = null;
+ Statement createDB = null;
+
+ try {
+ connection = DbUtil.getConnection(DB_URL.replace(TEST_DB,"postgres"), ADMIN_USERNAME, ADMIN_PASSWORD);
+
+ dropDB = connection.createStatement();
+ dropDB.execute("drop database if exists " + TEST_DB);
+
+ createDB = connection.createStatement();
+ createDB.execute("create database " + TEST_DB + " with owner " + USERNAME);
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
+ if (dropDB != null) {
+ dropDB.close();
+ }
+ if (createDB != null) {
+ createDB.close();
+ }
+ }
+ }
+
+ private void installSchemaAndData(String jonVersion) throws Exception {
+ DBSetup dbsetup = new DBSetup(DB_URL, USERNAME, PASSWORD);
+ dbsetup.setup(getSchemaFile(jonVersion).getAbsolutePath());
+ dbsetup.setup(getDataFile(jonVersion).getAbsolutePath());
+ }
+
+ private File getSchemaFile(String version) throws Exception {
+ URL url = getClass().getResource("db-schema-combined-" + version + ".xml");
+
+ if (url == null) {
+ throw new RuntimeException("Failed to find schema file for version " + version);
+ }
+
+ return new File(url.toURI().getPath());
+ }
+
+ private File getDataFile(String version) throws Exception {
+ URL url = getClass().getResource("db-data-combined-" + version + ".xml");
+
+ if (url == null) {
+ throw new RuntimeException("Failed to find data file for version " + version);
+ }
+
+ return new File(url.toURI().getPath());
+ }
+
+ private Properties getInstallProperties() {
+ Properties dbProperties = new Properties();
+ dbProperties.put(ServerProperties.PROP_DATABASE_CONNECTION_URL, DB_URL);
+ dbProperties.put(ServerProperties.PROP_DATABASE_USERNAME, USERNAME);
+ dbProperties.put(ServerProperties.PROP_DATABASE_PASSWORD, PASSWORD);
+ dbProperties.put(ServerProperties.PROP_EMAIL_FROM_ADDRESS, "rhqadmin(a)localhost.com");
+ return dbProperties;
+ }
+}
diff --git a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
deleted file mode 100644
index 579bebf..0000000
--- a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.rhq.enterprise.installer;
-
-import org.rhq.core.db.DbUtil;
-import org.rhq.core.db.setup.DBSetup;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.io.File;
-import java.net.URI;
-import java.net.URL;
-import java.sql.Connection;
-import java.sql.Statement;
-import java.util.Properties;
-
-/**
- * The tests in this class exercise the dbsetup/dbupgrade code that is run in the installer. The tests currently only
- * run against postgresql. Support needs to be added for oracle. The tests do not do any post-install/upgrade
- * verification at the time of this writing. They just simply exercise the dbsetup/dbupgrade scripts to ensure that
- * they do not contain any errors.
- *
- * @author John Sanda
- */
-public class DBInstallatonTest {
-
- private final String LOG_DIRECTORY = System.getProperty("java.io.tmpdir", "rhq/installer-test");
- private final String TEST_DB = System.getProperty("rhq.test.ds.db-name","rhq_installer_test_db");
- private final String USERNAME = System.getProperty("rhq.test.ds.user-name", "rhqadmin");
- private final String PASSWORD = System.getProperty("rhq.test.ds.password", "rhqadmin");
- private final String SERVER = System.getProperty("rhq.test.ds.server-name", "127.0.0.1");
- private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
- private final String ADMIN_USERNAME = System.getProperty("rhq.db.admin.username", "postgres");
- private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
-
- private ServerInformation installer;
-
- @BeforeMethod
- public void prepareForInstallation() throws Exception {
- initLogDirectory();
- recreateTestDatabase();
-
- installer = new ServerInformation();
- installer.setLogDirectory(new File(LOG_DIRECTORY));
- }
-
- @Test
- public void overwriteJON230Schema() throws Exception {
- installSchemaAndData("2.3.0");
- installer.createNewDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void upgradeJON230Schema() throws Exception {
- installSchemaAndData("2.3.0");
- installer.upgradeExistingDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void overwriteJON231Schema() throws Exception {
- installSchemaAndData("2.3.1");
- installer.createNewDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void upgradeJON231Schema() throws Exception {
- installSchemaAndData("2.3.1");
- installer.upgradeExistingDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void overwriteJON240Schema() throws Exception {
- installSchemaAndData("2.4.0");
- installer.createNewDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void upgradeJON240Schema() throws Exception {
- installSchemaAndData("2.4.0");
- installer.upgradeExistingDatabaseSchema(getInstallProperties());
- }
-
- private void initLogDirectory() {
- File logDir = new File(LOG_DIRECTORY);
- if (logDir.exists()) {
- logDir.delete();
- }
- logDir.mkdirs();
- }
-
- private void recreateTestDatabase() throws Exception {
- Connection connection = null;
- Statement dropDB = null;
- Statement createDB = null;
-
- try {
- connection = DbUtil.getConnection(DB_URL.replace(TEST_DB,"postgres"), ADMIN_USERNAME, ADMIN_PASSWORD);
-
- dropDB = connection.createStatement();
- dropDB.execute("drop database if exists " + TEST_DB);
-
- createDB = connection.createStatement();
- createDB.execute("create database " + TEST_DB + " with owner " + USERNAME);
- } finally {
- if (connection != null) {
- connection.close();
- }
- if (dropDB != null) {
- dropDB.close();
- }
- if (createDB != null) {
- createDB.close();
- }
- }
- }
-
- private void installSchemaAndData(String jonVersion) throws Exception {
- DBSetup dbsetup = new DBSetup(DB_URL, USERNAME, PASSWORD);
- dbsetup.setup(getSchemaFile(jonVersion).getAbsolutePath());
- dbsetup.setup(getDataFile(jonVersion).getAbsolutePath());
- }
-
- private File getSchemaFile(String version) throws Exception {
- URL url = getClass().getResource("db-schema-combined-" + version + ".xml");
-
- if (url == null) {
- throw new RuntimeException("Failed to find schema file for version " + version);
- }
-
- return new File(url.toURI().getPath());
- }
-
- private File getDataFile(String version) throws Exception {
- URL url = getClass().getResource("db-data-combined-" + version + ".xml");
-
- if (url == null) {
- throw new RuntimeException("Failed to find data file for version " + version);
- }
-
- return new File(url.toURI().getPath());
- }
-
- private Properties getInstallProperties() {
- Properties dbProperties = new Properties();
- dbProperties.put(ServerProperties.PROP_DATABASE_CONNECTION_URL, DB_URL);
- dbProperties.put(ServerProperties.PROP_DATABASE_USERNAME, USERNAME);
- dbProperties.put(ServerProperties.PROP_DATABASE_PASSWORD, PASSWORD);
- dbProperties.put(ServerProperties.PROP_EMAIL_FROM_ADDRESS, "rhqadmin(a)localhost.com");
- return dbProperties;
- }
-}
commit 83aaa00ffc0af1b6817e6a11366c189bb89a6ecc
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 17:07:07 2011 -0500
Adding driver class to the property list.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index d2f7e16..318afde 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,6 +22,7 @@
<rhq.ds.connection-url>${rhq.test.ds.connection-url}</rhq.ds.connection-url>
<rhq.ds.user-name>${rhq.test.ds.user-name}</rhq.ds.user-name>
<rhq.ds.password>${rhq.test.ds.password}></rhq.ds.password>
+ <rhq.ds.driver-class>${rhq.test.ds.driver-class}</rhq.ds.driver-class>
</properties>
<dependencies>
<!-- 3rd Party Deps -->
@@ -165,6 +166,7 @@
<rhq.ds.connection-url>${rhq.dev.ds.connection-url}</rhq.ds.connection-url>
<rhq.ds.user-name>${rhq.dev.ds.user-name}</rhq.ds.user-name>
<rhq.ds.password>${rhq.dev.ds.password}></rhq.ds.password>
+ <rhq.ds.driver-class>${rhq.dev.ds.driver-class}</rhq.ds.driver-class>
</properties>
</profile>
commit e53fbd175f6b181f9e09580e4c067e923e92996e
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 16:33:35 2011 -0500
Move conditional properties to maven profiles. This reduces code duplication and makes the pom smaller and more manageable.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index b47e499..d2f7e16 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -17,6 +17,11 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
<db.schema.version>2.111</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>
+ <rhq.ds.user-name>${rhq.test.ds.user-name}</rhq.ds.user-name>
+ <rhq.ds.password>${rhq.test.ds.password}></rhq.ds.password>
</properties>
<dependencies>
<!-- 3rd Party Deps -->
@@ -146,6 +151,24 @@
<profiles>
<profile>
+ <id>db.dev</id>
+ <activation>
+ <property>
+ <name>db</name>
+ <value>dev</value>
+ </property>
+ </activation>
+
+ <properties>
+ <rhq.ds.type-mapping>${rhq.dev.ds.type-mapping}</rhq.ds.type-mapping>
+ <rhq.ds.db-name>${rhq.dev.ds.db-name}</rhq.ds.db-name>
+ <rhq.ds.connection-url>${rhq.dev.ds.connection-url}</rhq.ds.connection-url>
+ <rhq.ds.user-name>${rhq.dev.ds.user-name}</rhq.ds.user-name>
+ <rhq.ds.password>${rhq.dev.ds.password}></rhq.ds.password>
+ </properties>
+ </profile>
+
+ <profile>
<id>latest</id>
<activation>
<property>
@@ -180,18 +203,6 @@
<phase>test</phase>
<configuration>
<tasks>
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
@@ -223,18 +234,6 @@
<configuration>
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
@@ -264,21 +263,6 @@
<configuration>
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
@@ -326,18 +310,6 @@
<configuration>
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="create-release-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
commit 5fabd79e13498fc1fcbcb53b890d4968df87d3d6
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 15:50:19 2011 -0500
Complete format of the pom file to make it easier to read.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 6907de0..b47e499 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -1,180 +1,160 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-parent</artifactId>
- <version>4.1.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-dbutils</artifactId>
- <packaging>jar</packaging>
-
- <name>RHQ Database Utilities</name>
- <description>Database schema setup, upgrade and other utilities</description>
-
- <scm>
- <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/core/dbutils</connection>
- <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/core/dbutils</developerConnection>
- </scm>
-
- <properties>
- <scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.111</db.schema.version>
- </properties>
-
- <dependencies>
-
- <!-- 3rd Party Deps -->
-
- <dependency>
- <groupId>ant</groupId>
- <artifactId>ant</artifactId>
- <version>1.6.5</version>
- </dependency>
-
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.1</version>
- </dependency>
-
- <dependency>
- <groupId>ant</groupId>
- <artifactId>ant-launcher</artifactId>
- <version>1.6.5</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>i18nlog</groupId>
- <artifactId>i18nlog</artifactId>
- <version>${i18nlog.version}</version>
- </dependency>
-
- <dependency>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>net.sourceforge.jtds</groupId>
- <artifactId>jtds</artifactId>
- <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.2</version>
- <dependencies>
- <dependency>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-parent</artifactId>
+ <version>4.1.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-dbutils</artifactId>
+ <packaging>jar</packaging>
+ <name>RHQ Database Utilities</name>
+ <description>Database schema setup, upgrade and other utilities</description>
+ <scm>
+ <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/core/dbutils</connection>
+ <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/core/dbutils</developerConnection>
+ </scm>
+ <properties>
+ <scm.module.path>modules/core/dbutils/</scm.module.path>
+ <db.schema.version>2.111</db.schema.version>
+ </properties>
+ <dependencies>
+ <!-- 3rd Party Deps -->
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ <version>1.6.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>i18nlog</groupId>
+ <artifactId>i18nlog</artifactId>
+ <version>${i18nlog.version}</version>
+ </dependency>
+ <dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
- <version>${postgresql.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.1</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <phase>process-classes</phase>
- <goals>
- <goal>java</goal>
- </goals>
- <configuration>
- <mainClass>org.rhq.core.db.reset.DBReset</mainClass>
- <systemProperties>
- <systemProperty>
- <key>rhq.ds.type-mapping</key>
- <value>${rhq.ds.type-mapping}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.server-name</key>
- <value>${rhq.ds.server-name}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.db-name</key>
- <value>${rhq.ds.db-name}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.connection-url</key>
- <value>${rhq.ds.connection-url}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.db.admin.username</key>
- <value>${rhq.db.admin.username}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.db.admin.password</key>
- <value>${rhq.db.admin.password}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.user-name</key>
- <value>${rhq.ds.user-name}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.password</key>
- <value>${rhq.ds.password}</value>
- </systemProperty>
- </systemProperties>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemProperties>
- <property>
- <name>DatabaseTest.nofail</name>
- <value>${DatabaseTest.nofail}</value>
- </property>
- <property>
- <name>AntDatabaseTest.test-resources</name>
- <value>${basedir}/src/test/resources</value>
- </property>
- </systemProperties>
- <!-- The below is required for tests to run against Oracle. -->
- <additionalClasspathElements>
- <additionalClasspathElement>${settings.localRepository}/com/oracle/ojdbc5/${ojdbc5.version}/ojdbc5-${ojdbc5.version}.jar</additionalClasspathElement>
- </additionalClasspathElements>
- </configuration>
- </plugin>
-
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>latest</id>
- <activation>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>net.sourceforge.jtds</groupId>
+ <artifactId>jtds</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2</version>
+ <dependencies>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>${postgresql.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ <configuration>
+ <mainClass>org.rhq.core.db.reset.DBReset</mainClass>
+ <systemProperties>
+ <systemProperty>
+ <key>rhq.ds.type-mapping</key>
+ <value>${rhq.ds.type-mapping}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.server-name</key>
+ <value>${rhq.ds.server-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.db-name</key>
+ <value>${rhq.ds.db-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.connection-url</key>
+ <value>${rhq.ds.connection-url}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.db.admin.username</key>
+ <value>${rhq.db.admin.username}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.db.admin.password</key>
+ <value>${rhq.db.admin.password}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.user-name</key>
+ <value>${rhq.ds.user-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.password</key>
+ <value>${rhq.ds.password}</value>
+ </systemProperty>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>DatabaseTest.nofail</name>
+ <value>${DatabaseTest.nofail}</value>
+ </property>
+ <property>
+ <name>AntDatabaseTest.test-resources</name>
+ <value>${basedir}/src/test/resources</value>
+ </property>
+ </systemProperties>
+ <!-- The below is required for tests to run against Oracle. -->
+ <additionalClasspathElements>
+ <additionalClasspathElement>${settings.localRepository}/com/oracle/ojdbc5/${ojdbc5.version}/ojdbc5-${ojdbc5.version}.jar</additionalClasspathElement>
+ </additionalClasspathElements>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>latest</id>
+ <activation>
<property>
<name>!jon.release</name>
</property>
</activation>
-
<build>
<plugins>
- <plugin>
+ <plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
@@ -183,7 +163,6 @@
<tasks>
<!-- generate the I18N resource bundles -->
<taskdef name="i18n" classpathref="maven.runtime.classpath" classname="mazz.i18n.ant.I18NAntTask" />
-
<i18n outputdir="${project.build.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true">
<classpath refid="maven.runtime.classpath" />
<classfileset dir="${project.build.outputDirectory}">
@@ -196,396 +175,365 @@
<goal>run</goal>
</goals>
</execution>
-
<execution>
<id>dbsetup-worker</id>
<phase>test</phase>
<configuration>
- <tasks>
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- <property name="dbsetup" value="${dbsetup}" />
- <property name="dbsetup-uninstall" value="${dbsetup-uninstall}" />
- <property name="dbsetup-upgrade" value="${dbsetup-upgrade}" />
- <property name="dbsetup-export" value="${dbsetup-export}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>generate-dbsetup-dbupgrade-xml-files</id>
- <phase>process-classes</phase>
- <configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <!--
- This execution will abort the build if the database schema is not up to date.
- If you want the build to continue, regardless of your currently installed schema,
- then pass -Ddbsetup-do-not-check-schema to the mvn command line.
- -->
- <id>test-db-schema-version</id>
- <phase>test</phase>
- <configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
+ <tasks>
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ <property name="dbsetup" value="${dbsetup}" />
+ <property name="dbsetup-uninstall" value="${dbsetup-uninstall}" />
+ <property name="dbsetup-upgrade" value="${dbsetup-upgrade}" />
+ <property name="dbsetup-export" value="${dbsetup-export}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>generate-dbsetup-dbupgrade-xml-files</id>
+ <phase>process-classes</phase>
+ <configuration>
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <!-- This execution will abort the build if the database schema is not up to date. If you want the build to continue, regardless of your currently installed
+ schema, then pass -Ddbsetup-do-not-check-schema to the mvn command line. -->
+ <id>test-db-schema-version</id>
+ <phase>test</phase>
+ <configuration>
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
+ <property name="dbsetup-do-not-check-schema" value="${dbsetup-do-not-check-schema}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
- <property name="dbsetup-do-not-check-schema" value="${dbsetup-do-not-check-schema}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>jon.release</id>
- <activation>
- <property>
- <name>jon.release</name>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-schema</id>
- <phase>test</phase>
- <configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="create-release-schema">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- <property name="jon.release" value="${jon.release}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>dev</id>
-
- <properties>
- <rhq.rootDir>../../..</rhq.rootDir>
- <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
- <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/lib</rhq.deploymentDir>
- </properties>
-
- <build>
- <plugins>
-
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.1</version>
- <executions>
-
- <execution>
- <id>deploy</id>
- <phase>compile</phase>
- <configuration>
- <tasks>
- <mkdir dir="${rhq.deploymentDir}" />
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Updating ${deployment.file}...</echo>
- <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>undeploy</id>
- <phase>clean</phase>
- <configuration>
- <tasks>
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Deleting ${deployment.file}...</echo>
- <delete file="${deployment.file}" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- </executions>
- </plugin>
-
- </plugins>
- </build>
- </profile>
- <profile>
- <id>cobertura</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>net.sourceforge.cobertura</groupId>
- <artifactId>cobertura</artifactId>
- <version>${cobertura.version}</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <id>cobertura-instrument</id>
- <phase>process-test-classes</phase>
- <configuration>
- <tasks>
- <!-- prepare directory structure for cobertura-->
- <mkdir dir="target/cobertura" />
- <mkdir dir="target/cobertura/backup" />
- <!-- backup all classes so that we can instrument the original classes-->
- <copy toDir="target/cobertura/backup" verbose="true" overwrite="true">
- <fileset dir="target/classes">
- <include name="**/*.class" />
- </fileset>
- </copy>
- <!-- create a properties file and save there location of cobertura data file-->
- <touch file="target/classes/cobertura.properties" />
- <echo file="target/classes/cobertura.properties">net.sourceforge.cobertura.datafile=${project.build.directory}/cobertura/cobertura.ser</echo>
- <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
- <!-- instrument all classes in target/classes directory -->
- <cobertura-instrument datafile="${project.build.directory}/cobertura/cobertura.ser" todir="${project.build.directory}/classes">
- <fileset dir="${project.build.directory}/classes">
- <include name="**/*.class" />
- </fileset>
- </cobertura-instrument>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- <execution>
- <id>cobertura-report</id>
- <phase>prepare-package</phase>
- <configuration>
- <tasks>
- <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
- <!-- prepare directory structure for cobertura-->
- <mkdir dir="target/cobertura" />
- <mkdir dir="target/site/cobertura" />
- <!-- restore classes from backup folder to classes folder -->
- <copy toDir="target/classes" verbose="true" overwrite="true">
- <fileset dir="target/cobertura/backup">
- <include name="**/*.class" />
- </fileset>
- </copy>
- <!-- delete backup folder-->
- <delete dir="target/cobertura/backup" />
- <!-- create a code coverage report -->
- <cobertura-report format="html" datafile="${project.build.directory}/cobertura/cobertura.ser" destdir="${project.build.directory}/site/cobertura">
- <fileset dir="${basedir}/src/main/java">
- <include name="**/*.java" />
- </fileset>
- </cobertura-report>
- <!-- delete cobertura.properties file -->
- <delete file="target/classes/cobertura.properties" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>ojdbc-driver</id>
- <dependencies>
- <dependency>
- <groupId>com.oracle</groupId>
- <artifactId>ojdbc5</artifactId>
- <version>${ojdbc5.version}</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.2</version>
- <dependencies>
- <dependency>
- <groupId>com.oracle</groupId>
- <artifactId>ojdbc5</artifactId>
- <version>${ojdbc5.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
- </profile>
+ <profile>
+ <id>jon.release</id>
+ <activation>
+ <property>
+ <name>jon.release</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-schema</id>
+ <phase>test</phase>
+ <configuration>
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="create-release-schema">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ <property name="jon.release" value="${jon.release}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>dev</id>
+ <properties>
+ <rhq.rootDir>../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/lib</rhq.deploymentDir>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${rhq.deploymentDir}" />
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>cobertura</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>net.sourceforge.cobertura</groupId>
+ <artifactId>cobertura</artifactId>
+ <version>${cobertura.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>cobertura-instrument</id>
+ <phase>process-test-classes</phase>
+ <configuration>
+ <tasks>
+ <!-- prepare directory structure for cobertura -->
+ <mkdir dir="target/cobertura" />
+ <mkdir dir="target/cobertura/backup" />
+ <!-- backup all classes so that we can instrument the original classes -->
+ <copy toDir="target/cobertura/backup" verbose="true" overwrite="true">
+ <fileset dir="target/classes">
+ <include name="**/*.class" />
+ </fileset>
+ </copy>
+ <!-- create a properties file and save there location of cobertura data file -->
+ <touch file="target/classes/cobertura.properties" />
+ <echo file="target/classes/cobertura.properties">net.sourceforge.cobertura.datafile=${project.build.directory}/cobertura/cobertura.ser</echo>
+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
+ <!-- instrument all classes in target/classes directory -->
+ <cobertura-instrument datafile="${project.build.directory}/cobertura/cobertura.ser" todir="${project.build.directory}/classes">
+ <fileset dir="${project.build.directory}/classes">
+ <include name="**/*.class" />
+ </fileset>
+ </cobertura-instrument>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>cobertura-report</id>
+ <phase>prepare-package</phase>
+ <configuration>
+ <tasks>
+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
+ <!-- prepare directory structure for cobertura -->
+ <mkdir dir="target/cobertura" />
+ <mkdir dir="target/site/cobertura" />
+ <!-- restore classes from backup folder to classes folder -->
+ <copy toDir="target/classes" verbose="true" overwrite="true">
+ <fileset dir="target/cobertura/backup">
+ <include name="**/*.class" />
+ </fileset>
+ </copy>
+ <!-- delete backup folder -->
+ <delete dir="target/cobertura/backup" />
+ <!-- create a code coverage report -->
+ <cobertura-report format="html" datafile="${project.build.directory}/cobertura/cobertura.ser" destdir="${project.build.directory}/site/cobertura">
+ <fileset dir="${basedir}/src/main/java">
+ <include name="**/*.java" />
+ </fileset>
+ </cobertura-report>
+ <!-- delete cobertura.properties file -->
+ <delete file="target/classes/cobertura.properties" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>ojdbc-driver</id>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc5</artifactId>
+ <version>${ojdbc5.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2</version>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc5</artifactId>
+ <version>${ojdbc5.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
-
- <pluginRepositories>
- <pluginRepository>
- <id>codehaus-snapshots</id>
- <name>codehaus snapshots</name>
- <url>http://snapshots.repository.codehaus.org</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </pluginRepository>
- </pluginRepositories>
-
-</project>
-
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>codehaus-snapshots</id>
+ <name>codehaus snapshots</name>
+ <url>http://snapshots.repository.codehaus.org</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+</project>
\ No newline at end of file
commit f74c6545ec40b20691d4557d85da06e2ab9b4f89
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 15:44:22 2011 -0500
Stray changes from one more file reverted properly.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 996ae31..6907de0 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -35,13 +35,12 @@
<version>1.6.5</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
-
<dependency>
<groupId>ant</groupId>
<artifactId>ant-launcher</artifactId>
@@ -167,48 +166,54 @@
<profiles>
<profile>
<id>latest</id>
- <activation>
- <property>
- <name>!jon.release</name>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <phase>process-classes</phase>
- <configuration>
- <tasks>
- <!-- generate the I18N resource bundles -->
- <taskdef name="i18n" classpathref="maven.runtime.classpath" classname="mazz.i18n.ant.I18NAntTask" />
-
- <i18n outputdir="${project.build.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true">
- <classpath refid="maven.runtime.classpath" />
- <classfileset dir="${project.build.outputDirectory}">
- <include name="**/*I18NResourceKeys.class" />
- </classfileset>
- </i18n>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>dbsetup-worker</id>
- <phase>test</phase>
- <configuration>
+ <activation>
+ <property>
+ <name>!jon.release</name>
+ </property>
+ </activation>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <configuration>
+ <tasks>
+ <!-- generate the I18N resource bundles -->
+ <taskdef name="i18n" classpathref="maven.runtime.classpath" classname="mazz.i18n.ant.I18NAntTask" />
+
+ <i18n outputdir="${project.build.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true">
+ <classpath refid="maven.runtime.classpath" />
+ <classfileset dir="${project.build.outputDirectory}">
+ <include name="**/*I18NResourceKeys.class" />
+ </classfileset>
+ </i18n>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>dbsetup-worker</id>
+ <phase>test</phase>
+ <configuration>
<tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}"/>
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}"/>
- <property name="rhq.ds.password" value="${rhq.ds.password}"/>
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -243,21 +248,21 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
<equals arg1="${db}" arg2="dev" />
- </condition>
+ </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
<equals arg1="${db}" arg2="dev" />
- </condition>
+ </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
<equals arg1="${db}" arg2="dev" />
- </condition>
+ </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
<equals arg1="${db}" arg2="dev" />
- </condition>
+ </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -289,50 +294,50 @@
-->
<id>test-db-schema-version</id>
<phase>test</phase>
- <configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
- <property name="dbsetup-do-not-check-schema" value="${dbsetup-do-not-check-schema}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
+ <configuration>
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
+ <property name="dbsetup-do-not-check-schema" value="${dbsetup-do-not-check-schema}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
<goal>run</goal>
</goals>
</execution>
@@ -361,7 +366,7 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
<equals arg1="${db}" arg2="dev" />
</condition>
@@ -391,7 +396,7 @@
<property name="rhq.ds.password" value="${rhq.ds.password}" />
<property name="project.version" value="${project.version}" />
<property name="db.schema.version" value="${db.schema.version}" />
- <property name="jon.release" value="${jon.release}" />
+ <property name="jon.release" value="${jon.release}" />
</ant>
</tasks>
</configuration>
commit eb40603c1a83cce426644f52a7f05b2b95809cb3
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 28 13:46:24 2011 -0500
Revert "Updating the code to use only one set of datasource settings. (rhq.ds.name-of-setting)"
This reverts commit 1876436d7ba7d977e7b4abfcbf223a3fb202e746.
Conflicts:
modules/core/dbutils/pom.xml
diff --git a/etc/m2/settings-bugfixes.xml b/etc/m2/settings-bugfixes.xml
index 01f3173..b64aac6 100644
--- a/etc/m2/settings-bugfixes.xml
+++ b/etc/m2/settings-bugfixes.xml
@@ -28,8 +28,8 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.bugfixes</id>
<properties>
- <rhq.ds.db-name>rhqbugfixes</rhq.ds.db-name>
- <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqbugfixes</rhq.ds.connection-url>
+ <rhq.test.ds.db-name>rhqbugfixes</rhq.test.ds.db-name>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqbugfixes</rhq.test.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings-content.xml b/etc/m2/settings-content.xml
index 3009f75..806006b 100644
--- a/etc/m2/settings-content.xml
+++ b/etc/m2/settings-content.xml
@@ -33,7 +33,7 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.content</id>
<properties>
- <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqcontent</rhq.ds.connection-url>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqcontent</rhq.test.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings-linux-config.xml b/etc/m2/settings-linux-config.xml
index 6605f33..dd464f7 100644
--- a/etc/m2/settings-linux-config.xml
+++ b/etc/m2/settings-linux-config.xml
@@ -28,7 +28,7 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.linux-config</id>
<properties>
- <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqlconf</rhq.ds.connection-url>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqlconf</rhq.test.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings-rawconfig.xml b/etc/m2/settings-rawconfig.xml
index f64b717..f871d66 100644
--- a/etc/m2/settings-rawconfig.xml
+++ b/etc/m2/settings-rawconfig.xml
@@ -28,8 +28,8 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.rawconfig</id>
<properties>
- <rhq.ds.db-name>rhqrawconfig</rhq.ds.db-name>
- <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqrawconfig</rhq.ds.connection-url>
+ <rhq.test.ds.db-name>rhqrawconfig</rhq.test.ds.db-name>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqrawconfig</rhq.test.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings.xml b/etc/m2/settings.xml
index 89c26f2..8c0dada 100644
--- a/etc/m2/settings.xml
+++ b/etc/m2/settings.xml
@@ -91,21 +91,31 @@
<profile>
<id>postgres</id>
<properties>
- <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhq</rhq.ds.connection-url>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
- <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
- <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.server-name>127.0.0.1</rhq.ds.server-name>
- <rhq.ds.port>5432</rhq.ds.port>
- <rhq.ds.db-name>rhq</rhq.ds.db-name>
- <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhq</rhq.test.ds.connection-url>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
+ <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
+ <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.server-name>127.0.0.1</rhq.test.ds.server-name>
+ <rhq.test.ds.port>5432</rhq.test.ds.port>
+ <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
+ <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
+ <rhq.dev.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhq</rhq.dev.ds.connection-url>
+ <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
+ <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
+ <rhq.dev.ds.type-mapping>PostgreSQL</rhq.dev.ds.type-mapping>
+ <rhq.dev.ds.driver-class>org.postgresql.Driver</rhq.dev.ds.driver-class>
+ <rhq.dev.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.dev.ds.xa-datasource-class>
+ <rhq.dev.ds.server-name>127.0.0.1</rhq.dev.ds.server-name>
+ <rhq.dev.ds.port>5432</rhq.dev.ds.port>
+ <rhq.dev.ds.db-name>rhq</rhq.dev.ds.db-name>
+ <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.dev.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.dev.quartz.selectWithLockSQL>
@@ -116,22 +126,33 @@
<profile>
<id>h2</id>
<properties>
- <rhq.ds.driver-class>org.h2.Driver</rhq.ds.driver-class>
- <rhq.ds.connection-url>jdbc:h2:~/rhq;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOG=2</rhq.ds.connection-url>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.type-mapping>h2</rhq.ds.type-mapping>
- <rhq.ds.xa-datasource-class>org.h2.jdbcx.JdbcDataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.server-name>127.0.0.1</rhq.ds.server-name>
- <rhq.ds.port>9092</rhq.ds.port>
- <rhq.ds.db-name>rhq</rhq.ds.db-name>
+ <rhq.test.ds.driver-class>org.h2.Driver</rhq.test.ds.driver-class>
+ <rhq.test.ds.connection-url>jdbc:h2:~/rhq;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOG=2</rhq.test.ds.connection-url>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>h2</rhq.test.ds.type-mapping>
+ <rhq.test.ds.xa-datasource-class>org.h2.jdbcx.JdbcDataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.server-name>127.0.0.1</rhq.test.ds.server-name>
+ <rhq.test.ds.port>9092</rhq.test.ds.port>
+ <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
<!-- This custom dialect is required for proper operation using H2, see class JavaDoc for more info -->
- <rhq.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.test.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.StdJDBCDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
-
+
+ <rhq.dev.ds.driver-class>org.h2.Driver</rhq.dev.ds.driver-class>
+ <rhq.dev.ds.connection-url>jdbc:h2:~/rhq;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOG=2</rhq.dev.ds.connection-url>
+ <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
+ <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
+ <rhq.dev.ds.type-mapping>h2</rhq.dev.ds.type-mapping>
+ <rhq.dev.ds.xa-datasource-class>org.h2.jdbcx.JdbcDataSource</rhq.dev.ds.xa-datasource-class>
+ <rhq.dev.ds.server-name>127.0.0.1</rhq.dev.ds.server-name>
+ <rhq.dev.ds.port>9092</rhq.dev.ds.port>
+ <rhq.dev.ds.db-name>rhq</rhq.dev.ds.db-name>
+ <!-- This custom dialect is required for proper operation using H2, see class JavaDoc for more info -->
+ <rhq.dev.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.dev.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.StdJDBCDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.dev.quartz.selectWithLockSQL>
@@ -142,21 +163,31 @@
<profile>
<id>sqlserver</id>
<properties>
- <rhq.ds.driver-class>net.sourceforge.jtds.jdbc.Driver</rhq.ds.driver-class>
- <rhq.ds.connection-url>jdbc:jtds:sqlserver://localhost:1433;databaseName=rhq</rhq.ds.connection-url>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.type-mapping>sqlserver</rhq.ds.type-mapping>
- <rhq.ds.xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.server-name>localhost</rhq.ds.server-name>
- <rhq.ds.port>1433</rhq.ds.port>
- <rhq.ds.db-name>rhq</rhq.ds.db-name>
- <rhq.ds.hibernate-dialect>org.hibernate.dialect.SQLServerDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.driver-class>net.sourceforge.jtds.jdbc.Driver</rhq.test.ds.driver-class>
+ <rhq.test.ds.connection-url>jdbc:jtds:sqlserver://localhost:1433;databaseName=rhq</rhq.test.ds.connection-url>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>sqlserver</rhq.test.ds.type-mapping>
+ <rhq.test.ds.xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.server-name>localhost</rhq.test.ds.server-name>
+ <rhq.test.ds.port>1433</rhq.test.ds.port>
+ <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
+ <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.SQLServerDialect</rhq.test.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.MSSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>UPDATE {0}LOCKS SET LOCK_NAME = LOCK_NAME WHERE LOCK_NAME = ?</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.UpdateLockRowSemaphore</rhq.test.quartz.lockHandlerClass>
-
+
+ <rhq.dev.ds.driver-class>net.sourceforge.jtds.jdbc.Driver</rhq.dev.ds.driver-class>
+ <rhq.dev.ds.connection-url>jdbc:jtds:sqlserver://localhost:1433;databaseName=rhq</rhq.dev.ds.connection-url>
+ <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
+ <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
+ <rhq.dev.ds.type-mapping>sqlserver</rhq.dev.ds.type-mapping>
+ <rhq.dev.ds.xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</rhq.dev.ds.xa-datasource-class>
+ <rhq.dev.ds.server-name>localhost</rhq.dev.ds.server-name>
+ <rhq.dev.ds.port>1433</rhq.dev.ds.port>
+ <rhq.dev.ds.db-name>rhq</rhq.dev.ds.db-name>
+ <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.SQLServerDialect</rhq.dev.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.MSSQLDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>UPDATE {0}LOCKS SET LOCK_NAME = LOCK_NAME WHERE LOCK_NAME = ?</rhq.dev.quartz.selectWithLockSQL>
@@ -167,21 +198,31 @@
<profile>
<id>oracle</id>
<properties>
- <rhq.ds.connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</rhq.ds.connection-url>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.type-mapping>Oracle10g</rhq.ds.type-mapping>
- <rhq.ds.driver-class>oracle.jdbc.driver.OracleDriver</rhq.ds.driver-class>
- <rhq.ds.xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.server-name></rhq.ds.server-name> <!-- can be left blank, oracle does not use this -->
- <rhq.ds.port></rhq.ds.port> <!-- can be left blank, oracle does not use this -->
- <rhq.ds.db-name></rhq.ds.db-name> <!-- can be left blank, oracle does not use this -->
- <rhq.ds.hibernate-dialect>org.hibernate.dialect.Oracle10gDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</rhq.test.ds.connection-url>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>Oracle10g</rhq.test.ds.type-mapping>
+ <rhq.test.ds.driver-class>oracle.jdbc.driver.OracleDriver</rhq.test.ds.driver-class>
+ <rhq.test.ds.xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.server-name></rhq.test.ds.server-name> <!-- can be left blank, oracle does not use this -->
+ <rhq.test.ds.port></rhq.test.ds.port> <!-- can be left blank, oracle does not use this -->
+ <rhq.test.ds.db-name></rhq.test.ds.db-name> <!-- can be left blank, oracle does not use this -->
+ <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.Oracle10gDialect</rhq.test.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.oracle.OracleDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
+ <rhq.dev.ds.connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</rhq.dev.ds.connection-url>
+ <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
+ <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
+ <rhq.dev.ds.type-mapping>Oracle10g</rhq.dev.ds.type-mapping>
+ <rhq.dev.ds.driver-class>oracle.jdbc.driver.OracleDriver</rhq.dev.ds.driver-class>
+ <rhq.dev.ds.xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</rhq.dev.ds.xa-datasource-class>
+ <rhq.dev.ds.server-name></rhq.dev.ds.server-name> <!-- can be left blank, oracle does not use this -->
+ <rhq.dev.ds.port></rhq.dev.ds.port> <!-- can be left blank, oracle does not use this -->
+ <rhq.dev.ds.db-name></rhq.dev.ds.db-name> <!-- can be left blank, oracle does not use this -->
+ <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.Oracle10gDialect</rhq.dev.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.oracle.OracleDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.dev.quartz.selectWithLockSQL>
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 4d2f4ca..996ae31 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -241,12 +241,23 @@
<phase>process-classes</phase>
<configuration>
<tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}"/>
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}"/>
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}"/>
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}"/>
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}"/>
- <property name="rhq.ds.password" value="${rhq.ds.password}"/>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -279,14 +290,28 @@
<id>test-db-schema-version</id>
<phase>test</phase>
<configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -334,13 +359,24 @@
<phase>test</phase>
<configuration>
<tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
-
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="create-release-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
@@ -355,10 +391,10 @@
<property name="rhq.ds.password" value="${rhq.ds.password}" />
<property name="project.version" value="${project.version}" />
<property name="db.schema.version" value="${db.schema.version}" />
- <property name="jon.release" value="${jon.release}" />
- </ant>
- </tasks>
- </configuration>
+ <property name="jon.release" value="${jon.release}" />
+ </ant>
+ </tasks>
+ </configuration>
<goals>
<goal>run</goal>
</goals>
diff --git a/modules/core/domain/pom.xml b/modules/core/domain/pom.xml
index c8ce307..42d28e1 100644
--- a/modules/core/domain/pom.xml
+++ b/modules/core/domain/pom.xml
@@ -282,7 +282,7 @@
</property>
<property>
<name>hibernate.dialect</name>
- <value>${rhq.ds.hibernate-dialect}</value>
+ <value>${rhq.test.ds.hibernate-dialect}</value>
</property>
</systemProperties>
<excludes>
diff --git a/modules/core/domain/src/test/resources/embedded-jboss-beans.xml b/modules/core/domain/src/test/resources/embedded-jboss-beans.xml
index a51f3e3..ae9de01 100644
--- a/modules/core/domain/src/test/resources/embedded-jboss-beans.xml
+++ b/modules/core/domain/src/test/resources/embedded-jboss-beans.xml
@@ -85,10 +85,10 @@
-->
<bean name="RHQDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
- <property name="driverClass">${rhq.ds.driver-class}</property>
- <property name="connectionURL">${rhq.ds.connection-url}</property>
- <property name="userName">${rhq.ds.user-name}</property>
- <property name="password">${rhq.ds.password}</property>
+ <property name="driverClass">${rhq.test.ds.driver-class}</property>
+ <property name="connectionURL">${rhq.test.ds.connection-url}</property>
+ <property name="userName">${rhq.test.ds.user-name}</property>
+ <property name="password">${rhq.test.ds.password}</property>
<property name="jndiName">java:/RHQDS</property>
<property name="minSize">0</property>
<property name="maxSize">10</property>
diff --git a/modules/enterprise/gui/installer-war/pom.xml b/modules/enterprise/gui/installer-war/pom.xml
index f73e403..517399c 100644
--- a/modules/enterprise/gui/installer-war/pom.xml
+++ b/modules/enterprise/gui/installer-war/pom.xml
@@ -147,13 +147,13 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
- <rhq.ds.server-name>${rhq.ds.server-name}</rhq.ds.server-name>
- <rhq.ds.db-name>${rhq.ds.db-name}</rhq.ds.db-name>
- <rhq.ds.connection-url>${rhq.ds.connection-url}</rhq.ds.connection-url>
+ <rhq.test.ds.server-name>${rhq.test.ds.server-name}</rhq.test.ds.server-name>
+ <rhq.test.ds.db-name>${rhq.test.ds.db-name}</rhq.test.ds.db-name>
+ <rhq.test.ds.connection-url>${rhq.test.ds.connection-url}</rhq.test.ds.connection-url>
<rhq.db.admin.username>${rhq.db.admin.username}</rhq.db.admin.username>
<rhq.db.admin.password>${rhq.db.admin.password}</rhq.db.admin.password>
- <rhq.ds.user-name>${rhq.ds.user-name}</rhq.ds.user-name>
- <rhq.ds.password>${rhq.ds.password}</rhq.ds.password>
+ <rhq.test.ds.user-name>${rhq.test.ds.user-name}</rhq.test.ds.user-name>
+ <rhq.test.ds.password>${rhq.test.ds.password}</rhq.test.ds.password>
</systemPropertyVariables>
</configuration>
</plugin>
diff --git a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
index 0e68830..579bebf 100644
--- a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
+++ b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
@@ -46,11 +46,11 @@ import java.util.Properties;
public class DBInstallatonTest {
private final String LOG_DIRECTORY = System.getProperty("java.io.tmpdir", "rhq/installer-test");
- private final String TEST_DB = System.getProperty("rhq.ds.db-name","rhq_installer_test_db");
- private final String USERNAME = System.getProperty("rhq.ds.user-name", "rhqadmin");
- private final String PASSWORD = System.getProperty("rhq.ds.password", "rhqadmin");
- private final String SERVER = System.getProperty("rhq.ds.server-name", "127.0.0.1");
- private final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
+ private final String TEST_DB = System.getProperty("rhq.test.ds.db-name","rhq_installer_test_db");
+ private final String USERNAME = System.getProperty("rhq.test.ds.user-name", "rhqadmin");
+ private final String PASSWORD = System.getProperty("rhq.test.ds.password", "rhqadmin");
+ private final String SERVER = System.getProperty("rhq.test.ds.server-name", "127.0.0.1");
+ private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
private final String ADMIN_USERNAME = System.getProperty("rhq.db.admin.username", "postgres");
private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
diff --git a/modules/enterprise/server/container/pom.xml b/modules/enterprise/server/container/pom.xml
index 8e59747..7329bb5 100644
--- a/modules/enterprise/server/container/pom.xml
+++ b/modules/enterprise/server/container/pom.xml
@@ -183,16 +183,16 @@
<property name="quartz.version" value="${quartz.version}" />
<!-- dev DB settings (used to init rhq-server.properties if dev profile is active or developer prop is set) -->
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
- <property name="rhq.ds.xa-datasource-class" value="${rhq.ds.xa-datasource-class}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password.encrypted" value="${rhq.ds.password.encrypted}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.server-name" value="${rhq.ds.server-name}" />
- <property name="rhq.ds.port" value="${rhq.ds.port}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.hibernate-dialect" value="${rhq.ds.hibernate-dialect}" />
+ <property name="rhq.dev.ds.connection-url" value="${rhq.dev.ds.connection-url}" />
+ <property name="rhq.dev.ds.driver-class" value="${rhq.dev.ds.driver-class}" />
+ <property name="rhq.dev.ds.xa-datasource-class" value="${rhq.dev.ds.xa-datasource-class}" />
+ <property name="rhq.dev.ds.user-name" value="${rhq.dev.ds.user-name}" />
+ <property name="rhq.dev.ds.password.encrypted" value="${rhq.dev.ds.password.encrypted}" />
+ <property name="rhq.dev.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" />
+ <property name="rhq.dev.ds.server-name" value="${rhq.dev.ds.server-name}" />
+ <property name="rhq.dev.ds.port" value="${rhq.dev.ds.port}" />
+ <property name="rhq.dev.ds.db-name" value="${rhq.dev.ds.db-name}" />
+ <property name="rhq.dev.ds.hibernate-dialect" value="${rhq.dev.ds.hibernate-dialect}" />
<property name="rhq.dev.quartz.driverDelegateClass" value="${rhq.dev.quartz.driverDelegateClass}" />
<property name="rhq.dev.quartz.selectWithLockSQL" value="${rhq.dev.quartz.selectWithLockSQL}" />
<property name="rhq.dev.quartz.lockHandlerClass" value="${rhq.dev.quartz.lockHandlerClass}" />
@@ -233,7 +233,8 @@
<property name="rhq.earName" value="${rhq.earName}" />
<!-- dev/test DB type (needed to init rhq-ds.xml) -->
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.test.ds.type-mapping" value="${rhq.test.ds.type-mapping}" />
+ <property name="rhq.dev.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" />
<property name="rhq.server.enable.web.services" value="${rhq.server.enable.ws}" />
</ant>
</tasks>
diff --git a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
index c4d83a0..704c50a 100644
--- a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
@@ -33,16 +33,16 @@
<target name="set-dev-server-props" if="predeploy">
<echo>*** Using dev database settings in rhq-server.properties...</echo>
- <property name="rhq.server.database.hibernate-dialect" value="${rhq.ds.hibernate-dialect}" />
- <property name="rhq.server.database.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.server.database.driver-class" value="${rhq.ds.driver-class}" />
- <property name="rhq.server.database.xa-datasource-class" value="${rhq.ds.xa-datasource-class}" />
- <property name="rhq.server.database.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.server.database.password" value="${rhq.ds.password.encrypted}" />
- <property name="rhq.server.database.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.server.database.server-name" value="${rhq.ds.server-name}" />
- <property name="rhq.server.database.port" value="${rhq.ds.port}" />
- <property name="rhq.server.database.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.server.database.hibernate-dialect" value="${rhq.dev.ds.hibernate-dialect}" />
+ <property name="rhq.server.database.connection-url" value="${rhq.dev.ds.connection-url}" />
+ <property name="rhq.server.database.driver-class" value="${rhq.dev.ds.driver-class}" />
+ <property name="rhq.server.database.xa-datasource-class" value="${rhq.dev.ds.xa-datasource-class}" />
+ <property name="rhq.server.database.user-name" value="${rhq.dev.ds.user-name}" />
+ <property name="rhq.server.database.password" value="${rhq.dev.ds.password.encrypted}" />
+ <property name="rhq.server.database.type-mapping" value="${rhq.dev.ds.type-mapping}" />
+ <property name="rhq.server.database.server-name" value="${rhq.dev.ds.server-name}" />
+ <property name="rhq.server.database.port" value="${rhq.dev.ds.port}" />
+ <property name="rhq.server.database.db-name" value="${rhq.dev.ds.db-name}" />
<property name="rhq.server.quartz.driverDelegateClass" value="${rhq.dev.quartz.driverDelegateClass}" />
<property name="rhq.server.quartz.selectWithLockSQL" value="${rhq.dev.quartz.selectWithLockSQL}" />
<property name="rhq.server.quartz.lockHandlerClass" value="${rhq.dev.quartz.lockHandlerClass}" />
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index 000808c..c5bb3ec 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -559,7 +559,7 @@ Build-OS-Version=${os.version}
<systemPropertyVariables>
<embeddedDeployment>true</embeddedDeployment>
<deploymentDirectory>target/classes</deploymentDirectory>
- <hibernate.dialect>${rhq.ds.hibernate-dialect}</hibernate.dialect>
+ <hibernate.dialect>${rhq.test.ds.hibernate-dialect}</hibernate.dialect>
<clean.db>${clean.db}</clean.db>
</systemPropertyVariables>
<additionalClasspathElements>
diff --git a/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml b/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml
index 05451bd..55d697b 100644
--- a/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml
+++ b/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml
@@ -76,10 +76,10 @@
</bean>
<bean name="RHQDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
- <property name="driverClass">${rhq.ds.driver-class}</property>
- <property name="connectionURL">${rhq.ds.connection-url}</property>
- <property name="userName">${rhq.ds.user-name}</property>
- <property name="password">${rhq.ds.password}</property>
+ <property name="driverClass">${rhq.test.ds.driver-class}</property>
+ <property name="connectionURL">${rhq.test.ds.connection-url}</property>
+ <property name="userName">${rhq.test.ds.user-name}</property>
+ <property name="password">${rhq.test.ds.password}</property>
<property name="jndiName">java:/RHQDS</property>
<property name="minSize">0</property>
<property name="maxSize">20</property>
@@ -104,10 +104,10 @@
<!-- needed for Quartz' no-TX data source (even though this is a local-tx, seems like Quartz is still working) -->
<bean name="NoTxRHQDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
- <property name="driverClass">${rhq.ds.driver-class}</property>
- <property name="connectionURL">${rhq.ds.connection-url}</property>
- <property name="userName">${rhq.ds.user-name}</property>
- <property name="password">${rhq.ds.password}</property>
+ <property name="driverClass">${rhq.test.ds.driver-class}</property>
+ <property name="connectionURL">${rhq.test.ds.connection-url}</property>
+ <property name="userName">${rhq.test.ds.user-name}</property>
+ <property name="password">${rhq.test.ds.password}</property>
<property name="jndiName">java:/NoTxRHQDS</property>
<property name="minSize">0</property>
<property name="maxSize">10</property>
diff --git a/modules/jopr/release.sh b/modules/jopr/release.sh
index c05b6ee..54f26ab 100755
--- a/modules/jopr/release.sh
+++ b/modules/jopr/release.sh
@@ -226,16 +226,16 @@ cat <<EOF >${SETTINGS}
<profile>
<id>release</id>
<properties>
- <rhq.ds.connection-url>jdbc:postgresql://jon03.qa.atl2.redhat.com:5432/rhq_release</rhq.ds.connection-url>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
- <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
- <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.server-name>jon03.qa.atl2.redhat.com</rhq.ds.server-name>
- <rhq.ds.port>5432</rhq.ds.port>
- <rhq.ds.db-name>rhq_release</rhq.ds.db-name>
- <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.connection-url>jdbc:postgresql://jon03.qa.atl2.redhat.com:5432/rhq_release</rhq.test.ds.connection-url>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
+ <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
+ <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.server-name>jon03.qa.atl2.redhat.com</rhq.test.ds.server-name>
+ <rhq.test.ds.port>5432</rhq.test.ds.port>
+ <rhq.test.ds.db-name>rhq_release</rhq.test.ds.db-name>
+ <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
diff --git a/pom.xml b/pom.xml
index 23afa62..549e0d0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -107,22 +107,42 @@
defaults for datasource used by integration tests -
these may be overridden in ~/.m2/settings.xml
-->
- <rhq.ds.db-name>rhq</rhq.ds.db-name>
- <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.ds.db-name}</rhq.ds.connection-url>
- <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
- <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.password.encrypted>1eeb2f255e832171df8592078de921bc</rhq.ds.password.encrypted>
- <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
- <rhq.ds.server-name>127.0.0.1</rhq.ds.server-name>
- <rhq.ds.port>5432</rhq.ds.port>
- <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.test.ds.db-name}</rhq.test.ds.connection-url>
+ <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
+ <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
+ <rhq.test.ds.server-name>127.0.0.1</rhq.test.ds.server-name>
+ <rhq.test.ds.port>5432</rhq.test.ds.port>
+ <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>
SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE
</rhq.test.quartz.selectWithLockSQL>
- <rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
+ <rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
+
+ <!--
+ defaults for datasource used by the dev container build (see dev docs on the 'dev' profile) -
+ these may be overridden in ~/.m2/settings.xml
+ -->
+ <rhq.dev.ds.db-name>rhqdev</rhq.dev.ds.db-name>
+ <rhq.dev.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.dev.ds.db-name}</rhq.dev.ds.connection-url>
+ <rhq.dev.ds.driver-class>org.postgresql.Driver</rhq.dev.ds.driver-class>
+ <rhq.dev.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.dev.ds.xa-datasource-class>
+ <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
+ <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
+ <rhq.dev.ds.password.encrypted>1eeb2f255e832171df8592078de921bc</rhq.dev.ds.password.encrypted>
+ <rhq.dev.ds.type-mapping>PostgreSQL</rhq.dev.ds.type-mapping>
+ <rhq.dev.ds.server-name>127.0.0.1</rhq.dev.ds.server-name>
+ <rhq.dev.ds.port>5432</rhq.dev.ds.port>
+ <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.dev.ds.hibernate-dialect>
+ <rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.dev.quartz.driverDelegateClass>
+ <rhq.dev.quartz.selectWithLockSQL>
+ SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE
+ </rhq.dev.quartz.selectWithLockSQL>
+ <rhq.dev.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.dev.quartz.lockHandlerClass>
<!-- default port numbers for RHQ server -->
<rhq.server.http.port>7080</rhq.server.http.port>
diff --git a/release.sh b/release.sh
index 4c7166e..316af14 100755
--- a/release.sh
+++ b/release.sh
@@ -282,16 +282,16 @@ cat <<EOF >"${MAVEN_SETTINGS_FILE}"
<profile>
<id>release</id>
<properties>
- <rhq.ds.server-name>hudson-qe.rhq.rdu.redhat.com</rhq.ds.server-name>
- <rhq.ds.port>5432</rhq.ds.port>
- <rhq.ds.db-name>rhq_release_tag</rhq.ds.db-name>
- <rhq.ds.connection-url>jdbc:postgresql://hudson-qe.rhq.rdu.redhat.com:5432/rhq_release_tag</rhq.ds.connection-url>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
- <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
- <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.server-name>hudson-qe.rhq.rdu.redhat.com</rhq.test.ds.server-name>
+ <rhq.test.ds.port>5432</rhq.test.ds.port>
+ <rhq.test.ds.db-name>rhq_release_tag</rhq.test.ds.db-name>
+ <rhq.test.ds.connection-url>jdbc:postgresql://hudson-qe.rhq.rdu.redhat.com:5432/rhq_release_tag</rhq.test.ds.connection-url>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
+ <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
+ <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
commit 5ccf5f0429fff6e1d5a5011928589c0732ae614b
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 25 15:07:09 2011 -0500
Final touches to get dbreset working for oracle databases.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 3ce393a..4d2f4ca 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -104,6 +104,10 @@
<mainClass>org.rhq.core.db.reset.DBReset</mainClass>
<systemProperties>
<systemProperty>
+ <key>rhq.ds.type-mapping</key>
+ <value>${rhq.ds.type-mapping}</value>
+ </systemProperty>
+ <systemProperty>
<key>rhq.ds.server-name</key>
<value>${rhq.ds.server-name}</value>
</systemProperty>
@@ -502,7 +506,34 @@
</plugins>
</build>
</profile>
- </profiles>
+
+ <profile>
+ <id>ojdbc-driver</id>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc5</artifactId>
+ <version>${ojdbc5.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2</version>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc5</artifactId>
+ <version>${ojdbc5.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
<pluginRepositories>
<pluginRepository>
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index a6970ca..8a32c43 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -104,17 +104,24 @@ public class DBReset {
connection = DbUtil.getConnection(DB_URL, ADMIN_USER, ADMIN_PASSWORD);
connection.setAutoCommit(false);
- String plsql = "declare cursor all_objects_to_drop is"
- + "select * from user_objects where object_type in ('TABLE', 'VIEW', 'FUNCTION', 'SEQUENCE');"
- + "begin"
- + " for obj in all_objects_to_drop loop"
- + " begin"
- + " if obj.object_type = 'TABLE' THEN"
- + " execute immediate('DROP '||obj.object_type||' '||obj.object_name||' CASCADE CONSTRAINTS PURGE');"
- + " else" + " execute immediate('DROP '||obj.object_type||' '||obj.object_name);"
- + " end if;" + " exception when others then null;" + " end;" + " end loop;" + "end;";
+ String plsql = "declare cursor all_objects_to_drop is\n"
+ + "select * from user_objects where object_type in ('TABLE', 'VIEW', 'FUNCTION', 'SEQUENCE');\n"
+ + "begin\n"
+ + " for obj in all_objects_to_drop loop\n"
+ + " begin\n"
+ + " if obj.object_type = 'TABLE' then\n"
+ + " execute immediate('DROP '||obj.object_type||' '||obj.object_name||' CASCADE CONSTRAINTS PURGE');\n"
+ + " else\n"
+ + " execute immediate('DROP '||obj.object_type||' '||obj.object_name);\n"
+ + " end if;\n"
+ + " exception when others then null;\n"
+ + " end;\n"
+ + " end loop;\n"
+ + " end;\n";
+ log.info(plsql);
cleanUserStatement = connection.prepareStatement(plsql);
cleanUserStatement.execute();
+ connection.commit();
log.info("Cleand database " + DB + ".");
} finally {
commit 983483fdfb5a1c06bb8bd30d9a008148e3c80772
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 25 13:22:53 2011 -0500
Pass system properties to DBReset correctly. Also, added missing db-name property to the rest of the profiles.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index fc5c9c8..3ce393a 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -101,7 +101,37 @@
<goal>java</goal>
</goals>
<configuration>
- <mainClass>org.rhq.core.db.reset.DBReset</mainClass>
+ <mainClass>org.rhq.core.db.reset.DBReset</mainClass>
+ <systemProperties>
+ <systemProperty>
+ <key>rhq.ds.server-name</key>
+ <value>${rhq.ds.server-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.db-name</key>
+ <value>${rhq.ds.db-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.connection-url</key>
+ <value>${rhq.ds.connection-url}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.db.admin.username</key>
+ <value>${rhq.db.admin.username}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.db.admin.password</key>
+ <value>${rhq.db.admin.password}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.user-name</key>
+ <value>${rhq.ds.user-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.password</key>
+ <value>${rhq.ds.password}</value>
+ </systemProperty>
+ </systemProperties>
</configuration>
</execution>
</executions>
@@ -171,6 +201,7 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}"/>
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}"/>
<property name="rhq.ds.password" value="${rhq.ds.password}"/>
@@ -183,6 +214,7 @@
<property name="jtds.version" value="${jtds.version}" />
<property name="task.classpath.property" refid="maven.test.classpath" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
<property name="rhq.ds.password" value="${rhq.ds.password}" />
@@ -207,6 +239,7 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}"/>
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}"/>
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}"/>
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}"/>
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}"/>
<property name="rhq.ds.password" value="${rhq.ds.password}"/>
@@ -219,6 +252,7 @@
<property name="jtds.version" value="${jtds.version}" />
<property name="task.classpath.property" refid="maven.test.classpath" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
<property name="rhq.ds.password" value="${rhq.ds.password}" />
@@ -244,6 +278,7 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
<property name="rhq.ds.password" value="${rhq.ds.password}" />
@@ -256,6 +291,7 @@
<property name="h2.version" value="${h2.version}" />
<property name="jtds.version" value="${jtds.version}" />
<property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
@@ -296,6 +332,7 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
<property name="rhq.ds.password" value="${rhq.ds.password}" />
@@ -308,6 +345,7 @@
<property name="jtds.version" value="${jtds.version}" />
<property name="task.classpath.property" refid="maven.test.classpath" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
<property name="rhq.ds.password" value="${rhq.ds.password}" />
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 9a17f19..a6970ca 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -83,7 +83,7 @@ public class DBReset {
createDB = connection.createStatement();
createDB.execute("create database " + DB + " with owner " + USER);
- log.info("Dropped and created database " + DB +".");
+ log.info("Dropped and created database " + DB + ".");
} finally {
if (dropDB != null) {
dropDB.close();
@@ -94,7 +94,7 @@ public class DBReset {
if (connection != null) {
connection.close();
}
-
+
}
} else if (DB_TYPE_MAPPING.equals("Oracle10g")) {
Connection connection = null;
@@ -111,17 +111,12 @@ public class DBReset {
+ " begin"
+ " if obj.object_type = 'TABLE' THEN"
+ " execute immediate('DROP '||obj.object_type||' '||obj.object_name||' CASCADE CONSTRAINTS PURGE');"
- + " else"
- + " execute immediate('DROP '||obj.object_type||' '||obj.object_name);"
- + " end if;"
- + " exception when others then null;"
- + " end;"
- + " end loop;"
- + "end;";
+ + " else" + " execute immediate('DROP '||obj.object_type||' '||obj.object_name);"
+ + " end if;" + " exception when others then null;" + " end;" + " end loop;" + "end;";
cleanUserStatement = connection.prepareStatement(plsql);
cleanUserStatement.execute();
-
- log.info("Cleand database " + DB +".");
+
+ log.info("Cleand database " + DB + ".");
} finally {
if (cleanUserStatement != null) {
cleanUserStatement.close();
commit 11efba2005f1b9bee570a842d224e24b783acd47
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Jul 22 21:44:51 2011 -0500
Add dbreset support for Oracle database by executing an anonymous pl/sql script.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 2d85ff0..9a17f19 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -20,6 +20,7 @@
package org.rhq.core.db.reset;
import java.sql.Connection;
+import java.sql.PreparedStatement;
import java.sql.Statement;
import org.apache.commons.logging.Log;
@@ -45,6 +46,8 @@ public class DBReset {
private final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"
+ DB);
+ private final String DB_TYPE_MAPPING = System.getProperty("rhq.ds.type-mapping", "PostgreSQL");
+
/**
* @param args
*/
@@ -66,29 +69,66 @@ public class DBReset {
System.setProperty("dbsetup", "true");
- Connection connection = null;
- Statement dropDB = null;
- Statement createDB = null;
-
- try {
- connection = DbUtil.getConnection(DB_URL.replace(DB, "postgres"), ADMIN_USER, ADMIN_PASSWORD);
-
- dropDB = connection.createStatement();
- dropDB.execute("drop database if exists " + DB);
-
- createDB = connection.createStatement();
- createDB.execute("create database " + DB + " with owner " + USER);
-
- log.info("created database $database");
- } finally {
- if (connection != null) {
- connection.close();
- }
- if (dropDB != null) {
- dropDB.close();
+ if (DB_TYPE_MAPPING.equals("PostgreSQL")) {
+ Connection connection = null;
+ Statement dropDB = null;
+ Statement createDB = null;
+
+ try {
+ connection = DbUtil.getConnection(DB_URL.replace(DB, "postgres"), ADMIN_USER, ADMIN_PASSWORD);
+
+ dropDB = connection.createStatement();
+ dropDB.execute("drop database if exists " + DB);
+
+ createDB = connection.createStatement();
+ createDB.execute("create database " + DB + " with owner " + USER);
+
+ log.info("Dropped and created database " + DB +".");
+ } finally {
+ if (dropDB != null) {
+ dropDB.close();
+ }
+ if (createDB != null) {
+ createDB.close();
+ }
+ if (connection != null) {
+ connection.close();
+ }
+
}
- if (createDB != null) {
- createDB.close();
+ } else if (DB_TYPE_MAPPING.equals("Oracle10g")) {
+ Connection connection = null;
+ PreparedStatement cleanUserStatement = null;
+
+ try {
+ connection = DbUtil.getConnection(DB_URL, ADMIN_USER, ADMIN_PASSWORD);
+ connection.setAutoCommit(false);
+
+ String plsql = "declare cursor all_objects_to_drop is"
+ + "select * from user_objects where object_type in ('TABLE', 'VIEW', 'FUNCTION', 'SEQUENCE');"
+ + "begin"
+ + " for obj in all_objects_to_drop loop"
+ + " begin"
+ + " if obj.object_type = 'TABLE' THEN"
+ + " execute immediate('DROP '||obj.object_type||' '||obj.object_name||' CASCADE CONSTRAINTS PURGE');"
+ + " else"
+ + " execute immediate('DROP '||obj.object_type||' '||obj.object_name);"
+ + " end if;"
+ + " exception when others then null;"
+ + " end;"
+ + " end loop;"
+ + "end;";
+ cleanUserStatement = connection.prepareStatement(plsql);
+ cleanUserStatement.execute();
+
+ log.info("Cleand database " + DB +".");
+ } finally {
+ if (cleanUserStatement != null) {
+ cleanUserStatement.close();
+ }
+ if (connection != null) {
+ connection.close();
+ }
}
}
}
commit 1876436d7ba7d977e7b4abfcbf223a3fb202e746
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Jul 22 10:26:53 2011 -0500
Updating the code to use only one set of datasource settings. (rhq.ds.name-of-setting)
diff --git a/etc/m2/settings-bugfixes.xml b/etc/m2/settings-bugfixes.xml
index b64aac6..01f3173 100644
--- a/etc/m2/settings-bugfixes.xml
+++ b/etc/m2/settings-bugfixes.xml
@@ -28,8 +28,8 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.bugfixes</id>
<properties>
- <rhq.test.ds.db-name>rhqbugfixes</rhq.test.ds.db-name>
- <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqbugfixes</rhq.test.ds.connection-url>
+ <rhq.ds.db-name>rhqbugfixes</rhq.ds.db-name>
+ <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqbugfixes</rhq.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings-content.xml b/etc/m2/settings-content.xml
index 806006b..3009f75 100644
--- a/etc/m2/settings-content.xml
+++ b/etc/m2/settings-content.xml
@@ -33,7 +33,7 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.content</id>
<properties>
- <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqcontent</rhq.test.ds.connection-url>
+ <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqcontent</rhq.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings-linux-config.xml b/etc/m2/settings-linux-config.xml
index dd464f7..6605f33 100644
--- a/etc/m2/settings-linux-config.xml
+++ b/etc/m2/settings-linux-config.xml
@@ -28,7 +28,7 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.linux-config</id>
<properties>
- <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqlconf</rhq.test.ds.connection-url>
+ <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqlconf</rhq.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings-rawconfig.xml b/etc/m2/settings-rawconfig.xml
index f871d66..f64b717 100644
--- a/etc/m2/settings-rawconfig.xml
+++ b/etc/m2/settings-rawconfig.xml
@@ -28,8 +28,8 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.rawconfig</id>
<properties>
- <rhq.test.ds.db-name>rhqrawconfig</rhq.test.ds.db-name>
- <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqrawconfig</rhq.test.ds.connection-url>
+ <rhq.ds.db-name>rhqrawconfig</rhq.ds.db-name>
+ <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqrawconfig</rhq.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings.xml b/etc/m2/settings.xml
index 8c0dada..89c26f2 100644
--- a/etc/m2/settings.xml
+++ b/etc/m2/settings.xml
@@ -91,31 +91,21 @@
<profile>
<id>postgres</id>
<properties>
- <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhq</rhq.test.ds.connection-url>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
- <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
- <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.server-name>127.0.0.1</rhq.test.ds.server-name>
- <rhq.test.ds.port>5432</rhq.test.ds.port>
- <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
- <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhq</rhq.ds.connection-url>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
+ <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
+ <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.server-name>127.0.0.1</rhq.ds.server-name>
+ <rhq.ds.port>5432</rhq.ds.port>
+ <rhq.ds.db-name>rhq</rhq.ds.db-name>
+ <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
- <rhq.dev.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhq</rhq.dev.ds.connection-url>
- <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
- <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
- <rhq.dev.ds.type-mapping>PostgreSQL</rhq.dev.ds.type-mapping>
- <rhq.dev.ds.driver-class>org.postgresql.Driver</rhq.dev.ds.driver-class>
- <rhq.dev.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.dev.ds.xa-datasource-class>
- <rhq.dev.ds.server-name>127.0.0.1</rhq.dev.ds.server-name>
- <rhq.dev.ds.port>5432</rhq.dev.ds.port>
- <rhq.dev.ds.db-name>rhq</rhq.dev.ds.db-name>
- <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.dev.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.dev.quartz.selectWithLockSQL>
@@ -126,33 +116,22 @@
<profile>
<id>h2</id>
<properties>
- <rhq.test.ds.driver-class>org.h2.Driver</rhq.test.ds.driver-class>
- <rhq.test.ds.connection-url>jdbc:h2:~/rhq;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOG=2</rhq.test.ds.connection-url>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>h2</rhq.test.ds.type-mapping>
- <rhq.test.ds.xa-datasource-class>org.h2.jdbcx.JdbcDataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.server-name>127.0.0.1</rhq.test.ds.server-name>
- <rhq.test.ds.port>9092</rhq.test.ds.port>
- <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
+ <rhq.ds.driver-class>org.h2.Driver</rhq.ds.driver-class>
+ <rhq.ds.connection-url>jdbc:h2:~/rhq;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOG=2</rhq.ds.connection-url>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.type-mapping>h2</rhq.ds.type-mapping>
+ <rhq.ds.xa-datasource-class>org.h2.jdbcx.JdbcDataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.server-name>127.0.0.1</rhq.ds.server-name>
+ <rhq.ds.port>9092</rhq.ds.port>
+ <rhq.ds.db-name>rhq</rhq.ds.db-name>
<!-- This custom dialect is required for proper operation using H2, see class JavaDoc for more info -->
- <rhq.test.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.StdJDBCDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
-
- <rhq.dev.ds.driver-class>org.h2.Driver</rhq.dev.ds.driver-class>
- <rhq.dev.ds.connection-url>jdbc:h2:~/rhq;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOG=2</rhq.dev.ds.connection-url>
- <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
- <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
- <rhq.dev.ds.type-mapping>h2</rhq.dev.ds.type-mapping>
- <rhq.dev.ds.xa-datasource-class>org.h2.jdbcx.JdbcDataSource</rhq.dev.ds.xa-datasource-class>
- <rhq.dev.ds.server-name>127.0.0.1</rhq.dev.ds.server-name>
- <rhq.dev.ds.port>9092</rhq.dev.ds.port>
- <rhq.dev.ds.db-name>rhq</rhq.dev.ds.db-name>
- <!-- This custom dialect is required for proper operation using H2, see class JavaDoc for more info -->
- <rhq.dev.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.dev.ds.hibernate-dialect>
+
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.StdJDBCDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.dev.quartz.selectWithLockSQL>
@@ -163,31 +142,21 @@
<profile>
<id>sqlserver</id>
<properties>
- <rhq.test.ds.driver-class>net.sourceforge.jtds.jdbc.Driver</rhq.test.ds.driver-class>
- <rhq.test.ds.connection-url>jdbc:jtds:sqlserver://localhost:1433;databaseName=rhq</rhq.test.ds.connection-url>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>sqlserver</rhq.test.ds.type-mapping>
- <rhq.test.ds.xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.server-name>localhost</rhq.test.ds.server-name>
- <rhq.test.ds.port>1433</rhq.test.ds.port>
- <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
- <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.SQLServerDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.driver-class>net.sourceforge.jtds.jdbc.Driver</rhq.ds.driver-class>
+ <rhq.ds.connection-url>jdbc:jtds:sqlserver://localhost:1433;databaseName=rhq</rhq.ds.connection-url>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.type-mapping>sqlserver</rhq.ds.type-mapping>
+ <rhq.ds.xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.server-name>localhost</rhq.ds.server-name>
+ <rhq.ds.port>1433</rhq.ds.port>
+ <rhq.ds.db-name>rhq</rhq.ds.db-name>
+ <rhq.ds.hibernate-dialect>org.hibernate.dialect.SQLServerDialect</rhq.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.MSSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>UPDATE {0}LOCKS SET LOCK_NAME = LOCK_NAME WHERE LOCK_NAME = ?</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.UpdateLockRowSemaphore</rhq.test.quartz.lockHandlerClass>
-
- <rhq.dev.ds.driver-class>net.sourceforge.jtds.jdbc.Driver</rhq.dev.ds.driver-class>
- <rhq.dev.ds.connection-url>jdbc:jtds:sqlserver://localhost:1433;databaseName=rhq</rhq.dev.ds.connection-url>
- <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
- <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
- <rhq.dev.ds.type-mapping>sqlserver</rhq.dev.ds.type-mapping>
- <rhq.dev.ds.xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</rhq.dev.ds.xa-datasource-class>
- <rhq.dev.ds.server-name>localhost</rhq.dev.ds.server-name>
- <rhq.dev.ds.port>1433</rhq.dev.ds.port>
- <rhq.dev.ds.db-name>rhq</rhq.dev.ds.db-name>
- <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.SQLServerDialect</rhq.dev.ds.hibernate-dialect>
+
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.MSSQLDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>UPDATE {0}LOCKS SET LOCK_NAME = LOCK_NAME WHERE LOCK_NAME = ?</rhq.dev.quartz.selectWithLockSQL>
@@ -198,31 +167,21 @@
<profile>
<id>oracle</id>
<properties>
- <rhq.test.ds.connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</rhq.test.ds.connection-url>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>Oracle10g</rhq.test.ds.type-mapping>
- <rhq.test.ds.driver-class>oracle.jdbc.driver.OracleDriver</rhq.test.ds.driver-class>
- <rhq.test.ds.xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.server-name></rhq.test.ds.server-name> <!-- can be left blank, oracle does not use this -->
- <rhq.test.ds.port></rhq.test.ds.port> <!-- can be left blank, oracle does not use this -->
- <rhq.test.ds.db-name></rhq.test.ds.db-name> <!-- can be left blank, oracle does not use this -->
- <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.Oracle10gDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</rhq.ds.connection-url>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.type-mapping>Oracle10g</rhq.ds.type-mapping>
+ <rhq.ds.driver-class>oracle.jdbc.driver.OracleDriver</rhq.ds.driver-class>
+ <rhq.ds.xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.server-name></rhq.ds.server-name> <!-- can be left blank, oracle does not use this -->
+ <rhq.ds.port></rhq.ds.port> <!-- can be left blank, oracle does not use this -->
+ <rhq.ds.db-name></rhq.ds.db-name> <!-- can be left blank, oracle does not use this -->
+ <rhq.ds.hibernate-dialect>org.hibernate.dialect.Oracle10gDialect</rhq.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.oracle.OracleDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
- <rhq.dev.ds.connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</rhq.dev.ds.connection-url>
- <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
- <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
- <rhq.dev.ds.type-mapping>Oracle10g</rhq.dev.ds.type-mapping>
- <rhq.dev.ds.driver-class>oracle.jdbc.driver.OracleDriver</rhq.dev.ds.driver-class>
- <rhq.dev.ds.xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</rhq.dev.ds.xa-datasource-class>
- <rhq.dev.ds.server-name></rhq.dev.ds.server-name> <!-- can be left blank, oracle does not use this -->
- <rhq.dev.ds.port></rhq.dev.ds.port> <!-- can be left blank, oracle does not use this -->
- <rhq.dev.ds.db-name></rhq.dev.ds.db-name> <!-- can be left blank, oracle does not use this -->
- <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.Oracle10gDialect</rhq.dev.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.oracle.OracleDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.dev.quartz.selectWithLockSQL>
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 1a39740..fc5c9c8 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -205,23 +205,11 @@
<phase>process-classes</phase>
<configuration>
<tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}"/>
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}"/>
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}"/>
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}"/>
+ <property name="rhq.ds.password" value="${rhq.ds.password}"/>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -253,28 +241,13 @@
<id>test-db-schema-version</id>
<phase>test</phase>
<configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -321,24 +294,12 @@
<phase>test</phase>
<configuration>
<tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="create-release-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
@@ -352,10 +313,10 @@
<property name="rhq.ds.password" value="${rhq.ds.password}" />
<property name="project.version" value="${project.version}" />
<property name="db.schema.version" value="${db.schema.version}" />
- <property name="jon.release" value="${jon.release}" />
- </ant>
- </tasks>
- </configuration>
+ <property name="jon.release" value="${jon.release}" />
+ </ant>
+ </tasks>
+ </configuration>
<goals>
<goal>run</goal>
</goals>
diff --git a/modules/core/domain/pom.xml b/modules/core/domain/pom.xml
index 42d28e1..c8ce307 100644
--- a/modules/core/domain/pom.xml
+++ b/modules/core/domain/pom.xml
@@ -282,7 +282,7 @@
</property>
<property>
<name>hibernate.dialect</name>
- <value>${rhq.test.ds.hibernate-dialect}</value>
+ <value>${rhq.ds.hibernate-dialect}</value>
</property>
</systemProperties>
<excludes>
diff --git a/modules/core/domain/src/test/resources/embedded-jboss-beans.xml b/modules/core/domain/src/test/resources/embedded-jboss-beans.xml
index ae9de01..a51f3e3 100644
--- a/modules/core/domain/src/test/resources/embedded-jboss-beans.xml
+++ b/modules/core/domain/src/test/resources/embedded-jboss-beans.xml
@@ -85,10 +85,10 @@
-->
<bean name="RHQDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
- <property name="driverClass">${rhq.test.ds.driver-class}</property>
- <property name="connectionURL">${rhq.test.ds.connection-url}</property>
- <property name="userName">${rhq.test.ds.user-name}</property>
- <property name="password">${rhq.test.ds.password}</property>
+ <property name="driverClass">${rhq.ds.driver-class}</property>
+ <property name="connectionURL">${rhq.ds.connection-url}</property>
+ <property name="userName">${rhq.ds.user-name}</property>
+ <property name="password">${rhq.ds.password}</property>
<property name="jndiName">java:/RHQDS</property>
<property name="minSize">0</property>
<property name="maxSize">10</property>
diff --git a/modules/enterprise/gui/installer-war/pom.xml b/modules/enterprise/gui/installer-war/pom.xml
index 517399c..f73e403 100644
--- a/modules/enterprise/gui/installer-war/pom.xml
+++ b/modules/enterprise/gui/installer-war/pom.xml
@@ -147,13 +147,13 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
- <rhq.test.ds.server-name>${rhq.test.ds.server-name}</rhq.test.ds.server-name>
- <rhq.test.ds.db-name>${rhq.test.ds.db-name}</rhq.test.ds.db-name>
- <rhq.test.ds.connection-url>${rhq.test.ds.connection-url}</rhq.test.ds.connection-url>
+ <rhq.ds.server-name>${rhq.ds.server-name}</rhq.ds.server-name>
+ <rhq.ds.db-name>${rhq.ds.db-name}</rhq.ds.db-name>
+ <rhq.ds.connection-url>${rhq.ds.connection-url}</rhq.ds.connection-url>
<rhq.db.admin.username>${rhq.db.admin.username}</rhq.db.admin.username>
<rhq.db.admin.password>${rhq.db.admin.password}</rhq.db.admin.password>
- <rhq.test.ds.user-name>${rhq.test.ds.user-name}</rhq.test.ds.user-name>
- <rhq.test.ds.password>${rhq.test.ds.password}</rhq.test.ds.password>
+ <rhq.ds.user-name>${rhq.ds.user-name}</rhq.ds.user-name>
+ <rhq.ds.password>${rhq.ds.password}</rhq.ds.password>
</systemPropertyVariables>
</configuration>
</plugin>
diff --git a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
index 579bebf..0e68830 100644
--- a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
+++ b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
@@ -46,11 +46,11 @@ import java.util.Properties;
public class DBInstallatonTest {
private final String LOG_DIRECTORY = System.getProperty("java.io.tmpdir", "rhq/installer-test");
- private final String TEST_DB = System.getProperty("rhq.test.ds.db-name","rhq_installer_test_db");
- private final String USERNAME = System.getProperty("rhq.test.ds.user-name", "rhqadmin");
- private final String PASSWORD = System.getProperty("rhq.test.ds.password", "rhqadmin");
- private final String SERVER = System.getProperty("rhq.test.ds.server-name", "127.0.0.1");
- private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
+ private final String TEST_DB = System.getProperty("rhq.ds.db-name","rhq_installer_test_db");
+ private final String USERNAME = System.getProperty("rhq.ds.user-name", "rhqadmin");
+ private final String PASSWORD = System.getProperty("rhq.ds.password", "rhqadmin");
+ private final String SERVER = System.getProperty("rhq.ds.server-name", "127.0.0.1");
+ private final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
private final String ADMIN_USERNAME = System.getProperty("rhq.db.admin.username", "postgres");
private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
diff --git a/modules/enterprise/server/container/pom.xml b/modules/enterprise/server/container/pom.xml
index 7329bb5..8e59747 100644
--- a/modules/enterprise/server/container/pom.xml
+++ b/modules/enterprise/server/container/pom.xml
@@ -183,16 +183,16 @@
<property name="quartz.version" value="${quartz.version}" />
<!-- dev DB settings (used to init rhq-server.properties if dev profile is active or developer prop is set) -->
- <property name="rhq.dev.ds.connection-url" value="${rhq.dev.ds.connection-url}" />
- <property name="rhq.dev.ds.driver-class" value="${rhq.dev.ds.driver-class}" />
- <property name="rhq.dev.ds.xa-datasource-class" value="${rhq.dev.ds.xa-datasource-class}" />
- <property name="rhq.dev.ds.user-name" value="${rhq.dev.ds.user-name}" />
- <property name="rhq.dev.ds.password.encrypted" value="${rhq.dev.ds.password.encrypted}" />
- <property name="rhq.dev.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" />
- <property name="rhq.dev.ds.server-name" value="${rhq.dev.ds.server-name}" />
- <property name="rhq.dev.ds.port" value="${rhq.dev.ds.port}" />
- <property name="rhq.dev.ds.db-name" value="${rhq.dev.ds.db-name}" />
- <property name="rhq.dev.ds.hibernate-dialect" value="${rhq.dev.ds.hibernate-dialect}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
+ <property name="rhq.ds.xa-datasource-class" value="${rhq.ds.xa-datasource-class}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password.encrypted" value="${rhq.ds.password.encrypted}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.server-name" value="${rhq.ds.server-name}" />
+ <property name="rhq.ds.port" value="${rhq.ds.port}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.hibernate-dialect" value="${rhq.ds.hibernate-dialect}" />
<property name="rhq.dev.quartz.driverDelegateClass" value="${rhq.dev.quartz.driverDelegateClass}" />
<property name="rhq.dev.quartz.selectWithLockSQL" value="${rhq.dev.quartz.selectWithLockSQL}" />
<property name="rhq.dev.quartz.lockHandlerClass" value="${rhq.dev.quartz.lockHandlerClass}" />
@@ -233,8 +233,7 @@
<property name="rhq.earName" value="${rhq.earName}" />
<!-- dev/test DB type (needed to init rhq-ds.xml) -->
- <property name="rhq.test.ds.type-mapping" value="${rhq.test.ds.type-mapping}" />
- <property name="rhq.dev.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
<property name="rhq.server.enable.web.services" value="${rhq.server.enable.ws}" />
</ant>
</tasks>
diff --git a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
index 704c50a..c4d83a0 100644
--- a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
@@ -33,16 +33,16 @@
<target name="set-dev-server-props" if="predeploy">
<echo>*** Using dev database settings in rhq-server.properties...</echo>
- <property name="rhq.server.database.hibernate-dialect" value="${rhq.dev.ds.hibernate-dialect}" />
- <property name="rhq.server.database.connection-url" value="${rhq.dev.ds.connection-url}" />
- <property name="rhq.server.database.driver-class" value="${rhq.dev.ds.driver-class}" />
- <property name="rhq.server.database.xa-datasource-class" value="${rhq.dev.ds.xa-datasource-class}" />
- <property name="rhq.server.database.user-name" value="${rhq.dev.ds.user-name}" />
- <property name="rhq.server.database.password" value="${rhq.dev.ds.password.encrypted}" />
- <property name="rhq.server.database.type-mapping" value="${rhq.dev.ds.type-mapping}" />
- <property name="rhq.server.database.server-name" value="${rhq.dev.ds.server-name}" />
- <property name="rhq.server.database.port" value="${rhq.dev.ds.port}" />
- <property name="rhq.server.database.db-name" value="${rhq.dev.ds.db-name}" />
+ <property name="rhq.server.database.hibernate-dialect" value="${rhq.ds.hibernate-dialect}" />
+ <property name="rhq.server.database.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.server.database.driver-class" value="${rhq.ds.driver-class}" />
+ <property name="rhq.server.database.xa-datasource-class" value="${rhq.ds.xa-datasource-class}" />
+ <property name="rhq.server.database.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.server.database.password" value="${rhq.ds.password.encrypted}" />
+ <property name="rhq.server.database.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.server.database.server-name" value="${rhq.ds.server-name}" />
+ <property name="rhq.server.database.port" value="${rhq.ds.port}" />
+ <property name="rhq.server.database.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.server.quartz.driverDelegateClass" value="${rhq.dev.quartz.driverDelegateClass}" />
<property name="rhq.server.quartz.selectWithLockSQL" value="${rhq.dev.quartz.selectWithLockSQL}" />
<property name="rhq.server.quartz.lockHandlerClass" value="${rhq.dev.quartz.lockHandlerClass}" />
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index c5bb3ec..000808c 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -559,7 +559,7 @@ Build-OS-Version=${os.version}
<systemPropertyVariables>
<embeddedDeployment>true</embeddedDeployment>
<deploymentDirectory>target/classes</deploymentDirectory>
- <hibernate.dialect>${rhq.test.ds.hibernate-dialect}</hibernate.dialect>
+ <hibernate.dialect>${rhq.ds.hibernate-dialect}</hibernate.dialect>
<clean.db>${clean.db}</clean.db>
</systemPropertyVariables>
<additionalClasspathElements>
diff --git a/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml b/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml
index 55d697b..05451bd 100644
--- a/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml
+++ b/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml
@@ -76,10 +76,10 @@
</bean>
<bean name="RHQDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
- <property name="driverClass">${rhq.test.ds.driver-class}</property>
- <property name="connectionURL">${rhq.test.ds.connection-url}</property>
- <property name="userName">${rhq.test.ds.user-name}</property>
- <property name="password">${rhq.test.ds.password}</property>
+ <property name="driverClass">${rhq.ds.driver-class}</property>
+ <property name="connectionURL">${rhq.ds.connection-url}</property>
+ <property name="userName">${rhq.ds.user-name}</property>
+ <property name="password">${rhq.ds.password}</property>
<property name="jndiName">java:/RHQDS</property>
<property name="minSize">0</property>
<property name="maxSize">20</property>
@@ -104,10 +104,10 @@
<!-- needed for Quartz' no-TX data source (even though this is a local-tx, seems like Quartz is still working) -->
<bean name="NoTxRHQDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
- <property name="driverClass">${rhq.test.ds.driver-class}</property>
- <property name="connectionURL">${rhq.test.ds.connection-url}</property>
- <property name="userName">${rhq.test.ds.user-name}</property>
- <property name="password">${rhq.test.ds.password}</property>
+ <property name="driverClass">${rhq.ds.driver-class}</property>
+ <property name="connectionURL">${rhq.ds.connection-url}</property>
+ <property name="userName">${rhq.ds.user-name}</property>
+ <property name="password">${rhq.ds.password}</property>
<property name="jndiName">java:/NoTxRHQDS</property>
<property name="minSize">0</property>
<property name="maxSize">10</property>
diff --git a/modules/jopr/release.sh b/modules/jopr/release.sh
index 54f26ab..c05b6ee 100755
--- a/modules/jopr/release.sh
+++ b/modules/jopr/release.sh
@@ -226,16 +226,16 @@ cat <<EOF >${SETTINGS}
<profile>
<id>release</id>
<properties>
- <rhq.test.ds.connection-url>jdbc:postgresql://jon03.qa.atl2.redhat.com:5432/rhq_release</rhq.test.ds.connection-url>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
- <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
- <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.server-name>jon03.qa.atl2.redhat.com</rhq.test.ds.server-name>
- <rhq.test.ds.port>5432</rhq.test.ds.port>
- <rhq.test.ds.db-name>rhq_release</rhq.test.ds.db-name>
- <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.connection-url>jdbc:postgresql://jon03.qa.atl2.redhat.com:5432/rhq_release</rhq.ds.connection-url>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
+ <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
+ <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.server-name>jon03.qa.atl2.redhat.com</rhq.ds.server-name>
+ <rhq.ds.port>5432</rhq.ds.port>
+ <rhq.ds.db-name>rhq_release</rhq.ds.db-name>
+ <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
diff --git a/pom.xml b/pom.xml
index 549e0d0..23afa62 100644
--- a/pom.xml
+++ b/pom.xml
@@ -107,42 +107,22 @@
defaults for datasource used by integration tests -
these may be overridden in ~/.m2/settings.xml
-->
- <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
- <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.test.ds.db-name}</rhq.test.ds.connection-url>
- <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
- <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
- <rhq.test.ds.server-name>127.0.0.1</rhq.test.ds.server-name>
- <rhq.test.ds.port>5432</rhq.test.ds.port>
- <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.db-name>rhq</rhq.ds.db-name>
+ <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.ds.db-name}</rhq.ds.connection-url>
+ <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
+ <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.password.encrypted>1eeb2f255e832171df8592078de921bc</rhq.ds.password.encrypted>
+ <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
+ <rhq.ds.server-name>127.0.0.1</rhq.ds.server-name>
+ <rhq.ds.port>5432</rhq.ds.port>
+ <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>
SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE
</rhq.test.quartz.selectWithLockSQL>
- <rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
-
- <!--
- defaults for datasource used by the dev container build (see dev docs on the 'dev' profile) -
- these may be overridden in ~/.m2/settings.xml
- -->
- <rhq.dev.ds.db-name>rhqdev</rhq.dev.ds.db-name>
- <rhq.dev.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.dev.ds.db-name}</rhq.dev.ds.connection-url>
- <rhq.dev.ds.driver-class>org.postgresql.Driver</rhq.dev.ds.driver-class>
- <rhq.dev.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.dev.ds.xa-datasource-class>
- <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
- <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
- <rhq.dev.ds.password.encrypted>1eeb2f255e832171df8592078de921bc</rhq.dev.ds.password.encrypted>
- <rhq.dev.ds.type-mapping>PostgreSQL</rhq.dev.ds.type-mapping>
- <rhq.dev.ds.server-name>127.0.0.1</rhq.dev.ds.server-name>
- <rhq.dev.ds.port>5432</rhq.dev.ds.port>
- <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.dev.ds.hibernate-dialect>
- <rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.dev.quartz.driverDelegateClass>
- <rhq.dev.quartz.selectWithLockSQL>
- SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE
- </rhq.dev.quartz.selectWithLockSQL>
- <rhq.dev.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.dev.quartz.lockHandlerClass>
+ <rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
<!-- default port numbers for RHQ server -->
<rhq.server.http.port>7080</rhq.server.http.port>
diff --git a/release.sh b/release.sh
index 316af14..4c7166e 100755
--- a/release.sh
+++ b/release.sh
@@ -282,16 +282,16 @@ cat <<EOF >"${MAVEN_SETTINGS_FILE}"
<profile>
<id>release</id>
<properties>
- <rhq.test.ds.server-name>hudson-qe.rhq.rdu.redhat.com</rhq.test.ds.server-name>
- <rhq.test.ds.port>5432</rhq.test.ds.port>
- <rhq.test.ds.db-name>rhq_release_tag</rhq.test.ds.db-name>
- <rhq.test.ds.connection-url>jdbc:postgresql://hudson-qe.rhq.rdu.redhat.com:5432/rhq_release_tag</rhq.test.ds.connection-url>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
- <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
- <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.server-name>hudson-qe.rhq.rdu.redhat.com</rhq.ds.server-name>
+ <rhq.ds.port>5432</rhq.ds.port>
+ <rhq.ds.db-name>rhq_release_tag</rhq.ds.db-name>
+ <rhq.ds.connection-url>jdbc:postgresql://hudson-qe.rhq.rdu.redhat.com:5432/rhq_release_tag</rhq.ds.connection-url>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
+ <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
+ <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
commit b416e59ff46e7899f44c3d047406952b2989b823
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 21 13:31:40 2011 -0500
Moving dbreset from inline groovy script to a java file.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 39f0798..1a39740 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -34,6 +34,13 @@
<artifactId>ant</artifactId>
<version>1.6.5</version>
</dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+
<dependency>
<groupId>ant</groupId>
@@ -50,9 +57,7 @@
<dependency>
<groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>test</scope>
+ <artifactId>postgresql</artifactId>
</dependency>
<dependency>
@@ -74,65 +79,29 @@
<build>
<plugins>
<plugin>
- <groupId>org.codehaus.groovy.maven</groupId>
- <artifactId>gmaven-plugin</artifactId>
- <version>1.0</version>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2</version>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
</dependencies>
<executions>
<execution>
- <phase>compile</phase>
+ <phase>process-classes</phase>
<goals>
- <goal>execute</goal>
+ <goal>java</goal>
</goals>
<configuration>
- <source>
- import org.postgresql.Driver
- import groovy.sql.Sql
-
- if (!project.properties.dbreset) {
- return
- }
-
- db = project.properties.db
- if (db == 'dev') {
- database = project.properties['rhq.dev.ds.db-name']
- server = project.properties['rhq.dev.ds.server-name'] ?: '127.0.0.1'
- rhqUser = project.properties['rhq.dev.ds.user-name'] ?: 'rhqadmin'
- }
- else {
- database = project.properties['rhq.test.ds.db-name']
- server = project.properties['rhq.test.ds.server-name'] ?: '127.0.0.1'
- rhqUser = project.properties['rhq.test.ds.user-name'] ?: 'rhqadmin'
- }
-
- // The upgrade.db property should be set for local builds when you
- // need to test upgrade changes. Hudson builds will specify the
- // database to use in settings.xml
- if (project.properties['upgrade.db']) {
- database = 'rhqupgrade'
- }
-
- adminUsername = project.properties['rhq.db.admin.username'] ?: 'postgres'
- adminPassword = project.properties['rhq.db.admin.password'] ?: 'postgres'
- project.properties.dbsetup = 'true'
-
- sql = Sql.newInstance(
- "jdbc:postgresql://${server}:5432/postgres",
- adminUsername,
- adminPassword,
- "org.postgresql.Driver")
-
- sql.execute("drop database if exists ${Sql.expand(database)};")
- log.info("dropped database $database")
- sql.execute("create database ${Sql.expand(database)} with owner ${Sql.expand(rhqUser)};")
- log.info("created database $database")
- </source>
+ <mainClass>org.rhq.core.db.reset.DBReset</mainClass>
</configuration>
</execution>
</executions>
@@ -201,22 +170,10 @@
<configuration>
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}"/>
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}"/>
+ <property name="rhq.ds.password" value="${rhq.ds.password}"/>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml">
<property name="settings.localRepository" value="${settings.localRepository}" />
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
new file mode 100644
index 0000000..2d85ff0
--- /dev/null
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -0,0 +1,95 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.core.db.reset;
+
+import java.sql.Connection;
+import java.sql.Statement;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.db.DbUtil;
+
+//import groovy.sql.Sql;
+
+/**
+ * @author Stefan Negrea
+ *
+ */
+public class DBReset {
+ private static Log log = LogFactory.getLog(DBReset.class);
+
+ private final String DB = System.getProperty("rhq.ds.db-name", "rhq_installer_test_db");
+ private final String SERVER = System.getProperty("rhq.ds.server-name", "127.0.0.1");
+ private final String USER = System.getProperty("rhq.ds.user-name", "rhqadmin");
+ private final String ADMIN_USER = System.getProperty("rhq.db.admin.username", "postgres");
+ private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
+ private final String DB_RESET = System.getProperty("dbreset", "false");
+ private final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"
+ + DB);
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ DBReset dbreset = new DBReset();
+
+ try {
+ dbreset.performDBReset();
+ } catch (Exception e) {
+ log.info(e);
+ System.exit(1);
+ }
+ }
+
+ private void performDBReset() throws Exception {
+ if (DB_RESET.equals("false")) {
+ return;
+ }
+
+ System.setProperty("dbsetup", "true");
+
+ Connection connection = null;
+ Statement dropDB = null;
+ Statement createDB = null;
+
+ try {
+ connection = DbUtil.getConnection(DB_URL.replace(DB, "postgres"), ADMIN_USER, ADMIN_PASSWORD);
+
+ dropDB = connection.createStatement();
+ dropDB.execute("drop database if exists " + DB);
+
+ createDB = connection.createStatement();
+ createDB.execute("create database " + DB + " with owner " + USER);
+
+ log.info("created database $database");
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
+ if (dropDB != null) {
+ dropDB.close();
+ }
+ if (createDB != null) {
+ createDB.close();
+ }
+ }
+ }
+}
12 years, 10 months
[rhq] Branch 'stefan/dbreset' - 117 commits - .classpath modules/core modules/enterprise modules/integration-tests modules/plugins modules/test-utils
by snegrea
.classpath | 2
modules/core/dbutils/pom.xml | 139 ++-
modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml | 6
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 16
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BaseCriteria.java | 7
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java | 18
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java | 48 +
modules/core/domain/src/main/java/org/rhq/core/domain/drift/DiffReport.java | 38
modules/core/domain/src/main/java/org/rhq/core/domain/drift/Snapshot.java | 68 +
modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java | 41 -
modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java | 383 ++++++++++
modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java | 44 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java | 13
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java | 56 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java | 59 +
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueue.java | 72 +
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java | 119 +++
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java | 12
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java | 43 -
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftTest.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java | 41 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java | 266 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java | 295 +++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java | 78 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeDataSource.java | 51 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java | 56 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsView.java | 40 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java | 12
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties | 3
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png |binary
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java | 14
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java | 7
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java | 19
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java | 38
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerBean.java | 90 --
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerLocal.java | 21
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java | 86 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginConfigurationMetadataManagerBean.java | 10
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java | 312 --------
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java | 9
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java | 34
modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java | 7
modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/UploadAndDeployTest.java | 85 ++
modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java | 210 +++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java | 53 +
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java | 91 +-
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java | 111 ++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java | 184 ++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java | 6
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java | 72 -
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java | 64 +
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java | 3
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java | 70 +
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java | 9
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java | 5
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java | 38
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java | 19
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 222 +++--
modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java | 2
modules/plugins/mod-cluster/pom.xml | 271 +++++++
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java | 102 ++
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java | 118 +++
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java | 45 +
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java | 310 ++++++++
modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml | 132 +++
modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java | 80 ++
modules/plugins/mod-cluster/src/test/resources/log4j.xml | 51 +
modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_1.txt | 13
modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_2.txt | 16
modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_empty.txt | 1
modules/plugins/pom.xml | 3
modules/test-utils/pom.xml | 10
modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java | 207 +++++
modules/test-utils/src/main/java/org/rhq/test/TransactionCallback.java | 7
86 files changed, 4493 insertions(+), 852 deletions(-)
New commits:
commit 6bcfdeb962f97d9c610bb722dd42111a4f2f0875
Merge: 765585f 19437ca
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 4 08:29:11 2011 -0500
Merge branch 'stefan/dbreset' of ssh://git.fedorahosted.org/git/rhq/rhq into stefan/dbreset
Conflicts:
modules/core/dbutils/pom.xml
diff --cc modules/core/dbutils/pom.xml
index 195b3f3,6a599c0..67de21e
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@@ -545,4 -510,4 +545,8 @@@
</snapshots>
</pluginRepository>
</pluginRepositories>
-</project>
++<<<<<<< HEAD
+</project>
++=======
++</project>
++>>>>>>> 19437cae8ca6ceb053fa191e08dff6368b8574b9
commit 765585f603136e217591dda9550ca01d1014c450
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 4 07:44:43 2011 -0500
Throw an exception if trying to use dbreset with anything else other than Oracle and Postgres.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 4736988..ce12786 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -132,5 +132,8 @@ public class DBReset {
}
}
}
+ else {
+ throw new Exception("dbreset not supported for "+ dbTypeMapping +"!");
+ }
}
}
commit 2e31c5013216be0d73287c33431c12c3fc678ad3
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Aug 3 12:23:44 2011 -0500
Forgot to replace three properties with the params after refactoring dbreset.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 9cd49e4..4736988 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -69,6 +69,7 @@ public class DBReset {
public void performDBReset(String dbTypeMapping, String dbUrl, String dbName, String user, String adminUser,
String adminPassword) throws Exception {
if (dbTypeMapping.equals("PostgreSQL")) {
+ System.out.println("PostgreSQL started!");
Connection connection = null;
Statement dropDB = null;
Statement createDB = null;
@@ -95,12 +96,12 @@ public class DBReset {
}
}
- } else if (DB_TYPE_MAPPING.equals("Oracle10g")) {
+ } else if (dbTypeMapping.equals("Oracle10g")) {
Connection connection = null;
PreparedStatement cleanUserStatement = null;
try {
- connection = DbUtil.getConnection(DB_URL, adminUser, ADMIN_PASSWORD);
+ connection = DbUtil.getConnection(dbUrl, adminUser, adminPassword);
connection.setAutoCommit(false);
String plsql = "declare cursor all_objects_to_drop is\n"
commit d72d4e2df7dd69b0523b54b8f8b9cc5ef3f7f6b0
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Aug 2 18:25:57 2011 -0500
DB installation test now uses dbreset to propertly reset the database (even for Oracle configurations).
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 3f99d10..9cd49e4 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -39,14 +39,13 @@ public class DBReset {
private static final String DB_NAME = System.getProperty("rhq.ds.db-name", "rhq_installer_test_db");
private static final String SERVER = System.getProperty("rhq.ds.server-name", "127.0.0.1");
+ private static final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER
+ + ":5432/" + DB_NAME);
private static final String USER = System.getProperty("rhq.ds.user-name", "rhqadmin");
private static final String ADMIN_USER = System.getProperty("rhq.db.admin.username", "postgres");
private static final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
- private static final String DB_RESET = System.getProperty("dbreset", "false");
- private static final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER
- + ":5432/" + DB_NAME);
-
private static final String DB_TYPE_MAPPING = System.getProperty("rhq.ds.type-mapping", "PostgreSQL");
+ private static final String DB_RESET = System.getProperty("dbreset", "false");
/**
* @param args
@@ -67,7 +66,7 @@ public class DBReset {
}
}
- private void performDBReset(String dbTypeMapping, String dbUrl, String dbName, String user, String adminUser,
+ public void performDBReset(String dbTypeMapping, String dbUrl, String dbName, String user, String adminUser,
String adminPassword) throws Exception {
if (dbTypeMapping.equals("PostgreSQL")) {
Connection connection = null;
diff --git a/modules/enterprise/gui/installer-war/pom.xml b/modules/enterprise/gui/installer-war/pom.xml
index 517399c..900d476 100644
--- a/modules/enterprise/gui/installer-war/pom.xml
+++ b/modules/enterprise/gui/installer-war/pom.xml
@@ -147,6 +147,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
+ <rhq.test.ds.type-mapping>${rhq.test.ds.type-mapping}</rhq.test.ds.type-mapping>
<rhq.test.ds.server-name>${rhq.test.ds.server-name}</rhq.test.ds.server-name>
<rhq.test.ds.db-name>${rhq.test.ds.db-name}</rhq.test.ds.db-name>
<rhq.test.ds.connection-url>${rhq.test.ds.connection-url}</rhq.test.ds.connection-url>
diff --git a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java
index 956e25e..6633cb7 100644
--- a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java
+++ b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java
@@ -23,18 +23,18 @@
package org.rhq.enterprise.installer;
-import org.rhq.core.db.DbUtil;
-import org.rhq.core.db.setup.DBSetup;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
import java.io.File;
-import java.net.URI;
import java.net.URL;
-import java.sql.Connection;
-import java.sql.Statement;
import java.util.Properties;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import org.rhq.core.db.reset.DBReset;
+import org.rhq.core.db.setup.DBSetup;
+import org.rhq.enterprise.installer.ServerInformation;
+import org.rhq.enterprise.installer.ServerProperties;
+
/**
* The tests in this class exercise the dbsetup/dbupgrade code that is run in the installer. The tests currently only
* run against postgresql. Support needs to be added for oracle. The tests do not do any post-install/upgrade
@@ -46,13 +46,15 @@ import java.util.Properties;
public class DBInstallationTest {
private final String LOG_DIRECTORY = System.getProperty("java.io.tmpdir", "rhq/installer-test");
- private final String TEST_DB = System.getProperty("rhq.test.ds.db-name","rhq_installer_test_db");
+ private final String DB_NAME = System.getProperty("rhq.test.ds.db-name", "rhq_installer_test_db");
private final String USERNAME = System.getProperty("rhq.test.ds.user-name", "rhqadmin");
private final String PASSWORD = System.getProperty("rhq.test.ds.password", "rhqadmin");
private final String SERVER = System.getProperty("rhq.test.ds.server-name", "127.0.0.1");
- private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
+ private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER
+ + ":5432/" + DB_NAME);
private final String ADMIN_USERNAME = System.getProperty("rhq.db.admin.username", "postgres");
private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
+ private static final String DB_TYPE_MAPPING = System.getProperty("rhq.test.ds.type-mapping", "PostgreSQL");
private ServerInformation installer;
@@ -79,8 +81,8 @@ public class DBInstallationTest {
@Test
public void overwriteJON231Schema() throws Exception {
- installSchemaAndData("2.3.1");
- installer.createNewDatabaseSchema(getInstallProperties());
+ installSchemaAndData("2.3.1");
+ installer.createNewDatabaseSchema(getInstallProperties());
}
@Test
@@ -88,13 +90,13 @@ public class DBInstallationTest {
installSchemaAndData("2.3.1");
installer.upgradeExistingDatabaseSchema(getInstallProperties());
}
-
+
@Test
public void overwriteJON240Schema() throws Exception {
- installSchemaAndData("2.4.0");
- installer.createNewDatabaseSchema(getInstallProperties());
+ installSchemaAndData("2.4.0");
+ installer.createNewDatabaseSchema(getInstallProperties());
}
-
+
@Test
public void upgradeJON240Schema() throws Exception {
installSchemaAndData("2.4.0");
@@ -110,29 +112,8 @@ public class DBInstallationTest {
}
private void recreateTestDatabase() throws Exception {
- Connection connection = null;
- Statement dropDB = null;
- Statement createDB = null;
-
- try {
- connection = DbUtil.getConnection(DB_URL.replace(TEST_DB,"postgres"), ADMIN_USERNAME, ADMIN_PASSWORD);
-
- dropDB = connection.createStatement();
- dropDB.execute("drop database if exists " + TEST_DB);
-
- createDB = connection.createStatement();
- createDB.execute("create database " + TEST_DB + " with owner " + USERNAME);
- } finally {
- if (connection != null) {
- connection.close();
- }
- if (dropDB != null) {
- dropDB.close();
- }
- if (createDB != null) {
- createDB.close();
- }
- }
+ DBReset dbReset = new DBReset();
+ dbReset.performDBReset(DB_TYPE_MAPPING, DB_URL, DB_NAME, USERNAME, ADMIN_USERNAME, ADMIN_PASSWORD);
}
private void installSchemaAndData(String jonVersion) throws Exception {
commit 8cfdf6198fedf0cb3beb3dde17c0ecae2702ca7d
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Aug 2 18:14:51 2011 -0500
Make dbreset configurable to it can be used/consumed by other modules.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 8a32c43..3f99d10 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -37,53 +37,53 @@ import org.rhq.core.db.DbUtil;
public class DBReset {
private static Log log = LogFactory.getLog(DBReset.class);
- private final String DB = System.getProperty("rhq.ds.db-name", "rhq_installer_test_db");
- private final String SERVER = System.getProperty("rhq.ds.server-name", "127.0.0.1");
- private final String USER = System.getProperty("rhq.ds.user-name", "rhqadmin");
- private final String ADMIN_USER = System.getProperty("rhq.db.admin.username", "postgres");
- private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
- private final String DB_RESET = System.getProperty("dbreset", "false");
- private final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"
- + DB);
+ private static final String DB_NAME = System.getProperty("rhq.ds.db-name", "rhq_installer_test_db");
+ private static final String SERVER = System.getProperty("rhq.ds.server-name", "127.0.0.1");
+ private static final String USER = System.getProperty("rhq.ds.user-name", "rhqadmin");
+ private static final String ADMIN_USER = System.getProperty("rhq.db.admin.username", "postgres");
+ private static final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
+ private static final String DB_RESET = System.getProperty("dbreset", "false");
+ private static final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER
+ + ":5432/" + DB_NAME);
- private final String DB_TYPE_MAPPING = System.getProperty("rhq.ds.type-mapping", "PostgreSQL");
+ private static final String DB_TYPE_MAPPING = System.getProperty("rhq.ds.type-mapping", "PostgreSQL");
/**
* @param args
*/
public static void main(String[] args) {
+ if (DB_RESET.equals("false")) {
+ return;
+ }
+
DBReset dbreset = new DBReset();
try {
- dbreset.performDBReset();
+ dbreset.performDBReset(DB_TYPE_MAPPING, DB_URL, DB_NAME, USER, ADMIN_USER, ADMIN_PASSWORD);
+ System.setProperty("dbsetup", "true");
} catch (Exception e) {
log.info(e);
System.exit(1);
}
}
- private void performDBReset() throws Exception {
- if (DB_RESET.equals("false")) {
- return;
- }
-
- System.setProperty("dbsetup", "true");
-
- if (DB_TYPE_MAPPING.equals("PostgreSQL")) {
+ private void performDBReset(String dbTypeMapping, String dbUrl, String dbName, String user, String adminUser,
+ String adminPassword) throws Exception {
+ if (dbTypeMapping.equals("PostgreSQL")) {
Connection connection = null;
Statement dropDB = null;
Statement createDB = null;
try {
- connection = DbUtil.getConnection(DB_URL.replace(DB, "postgres"), ADMIN_USER, ADMIN_PASSWORD);
+ connection = DbUtil.getConnection(dbUrl.replace(dbName, "postgres"), adminUser, adminPassword);
dropDB = connection.createStatement();
- dropDB.execute("drop database if exists " + DB);
+ dropDB.execute("drop database if exists " + dbName);
createDB = connection.createStatement();
- createDB.execute("create database " + DB + " with owner " + USER);
+ createDB.execute("create database " + dbName + " with owner " + user);
- log.info("Dropped and created database " + DB + ".");
+ log.info("Dropped and created postgres database " + dbName + ".");
} finally {
if (dropDB != null) {
dropDB.close();
@@ -101,7 +101,7 @@ public class DBReset {
PreparedStatement cleanUserStatement = null;
try {
- connection = DbUtil.getConnection(DB_URL, ADMIN_USER, ADMIN_PASSWORD);
+ connection = DbUtil.getConnection(DB_URL, adminUser, ADMIN_PASSWORD);
connection.setAutoCommit(false);
String plsql = "declare cursor all_objects_to_drop is\n"
@@ -118,12 +118,11 @@ public class DBReset {
+ " end;\n"
+ " end loop;\n"
+ " end;\n";
- log.info(plsql);
cleanUserStatement = connection.prepareStatement(plsql);
cleanUserStatement.execute();
connection.commit();
- log.info("Cleand database " + DB + ".");
+ log.info("Cleaned Oracle database " + dbName + ".");
} finally {
if (cleanUserStatement != null) {
cleanUserStatement.close();
commit 2b3d20a842caeae3c463dd1aa8ecb9554f8c545e
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 21:21:07 2011 -0500
Removing extra character inserted inadvertently.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index f0113c8..195b3f3 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -200,7 +200,7 @@
<rhq.ds.db-name>${rhq.dev.ds.db-name}</rhq.ds.db-name>
<rhq.ds.connection-url>${rhq.dev.ds.connection-url}</rhq.ds.connection-url>
<rhq.ds.user-name>${rhq.dev.ds.user-name}</rhq.ds.user-name>
- <rhq.ds.password>${rhq.dev.ds.password}></rhq.ds.password>
+ <rhq.ds.password>${rhq.dev.ds.password}</rhq.ds.password>
<rhq.ds.driver-class>${rhq.dev.ds.driver-class}</rhq.ds.driver-class>
</properties>
</profile>
commit b379d494894d0e40449f6296349143dc1a07ca31
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 18:50:28 2011 -0500
Correct the class file name.
diff --git a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java
new file mode 100644
index 0000000..956e25e
--- /dev/null
+++ b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallationTest.java
@@ -0,0 +1,172 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.installer;
+
+import org.rhq.core.db.DbUtil;
+import org.rhq.core.db.setup.DBSetup;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.util.Properties;
+
+/**
+ * The tests in this class exercise the dbsetup/dbupgrade code that is run in the installer. The tests currently only
+ * run against postgresql. Support needs to be added for oracle. The tests do not do any post-install/upgrade
+ * verification at the time of this writing. They just simply exercise the dbsetup/dbupgrade scripts to ensure that
+ * they do not contain any errors.
+ *
+ * @author John Sanda
+ */
+public class DBInstallationTest {
+
+ private final String LOG_DIRECTORY = System.getProperty("java.io.tmpdir", "rhq/installer-test");
+ private final String TEST_DB = System.getProperty("rhq.test.ds.db-name","rhq_installer_test_db");
+ private final String USERNAME = System.getProperty("rhq.test.ds.user-name", "rhqadmin");
+ private final String PASSWORD = System.getProperty("rhq.test.ds.password", "rhqadmin");
+ private final String SERVER = System.getProperty("rhq.test.ds.server-name", "127.0.0.1");
+ private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
+ private final String ADMIN_USERNAME = System.getProperty("rhq.db.admin.username", "postgres");
+ private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
+
+ private ServerInformation installer;
+
+ @BeforeMethod
+ public void prepareForInstallation() throws Exception {
+ initLogDirectory();
+ recreateTestDatabase();
+
+ installer = new ServerInformation();
+ installer.setLogDirectory(new File(LOG_DIRECTORY));
+ }
+
+ @Test
+ public void overwriteJON230Schema() throws Exception {
+ installSchemaAndData("2.3.0");
+ installer.createNewDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void upgradeJON230Schema() throws Exception {
+ installSchemaAndData("2.3.0");
+ installer.upgradeExistingDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void overwriteJON231Schema() throws Exception {
+ installSchemaAndData("2.3.1");
+ installer.createNewDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void upgradeJON231Schema() throws Exception {
+ installSchemaAndData("2.3.1");
+ installer.upgradeExistingDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void overwriteJON240Schema() throws Exception {
+ installSchemaAndData("2.4.0");
+ installer.createNewDatabaseSchema(getInstallProperties());
+ }
+
+ @Test
+ public void upgradeJON240Schema() throws Exception {
+ installSchemaAndData("2.4.0");
+ installer.upgradeExistingDatabaseSchema(getInstallProperties());
+ }
+
+ private void initLogDirectory() {
+ File logDir = new File(LOG_DIRECTORY);
+ if (logDir.exists()) {
+ logDir.delete();
+ }
+ logDir.mkdirs();
+ }
+
+ private void recreateTestDatabase() throws Exception {
+ Connection connection = null;
+ Statement dropDB = null;
+ Statement createDB = null;
+
+ try {
+ connection = DbUtil.getConnection(DB_URL.replace(TEST_DB,"postgres"), ADMIN_USERNAME, ADMIN_PASSWORD);
+
+ dropDB = connection.createStatement();
+ dropDB.execute("drop database if exists " + TEST_DB);
+
+ createDB = connection.createStatement();
+ createDB.execute("create database " + TEST_DB + " with owner " + USERNAME);
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
+ if (dropDB != null) {
+ dropDB.close();
+ }
+ if (createDB != null) {
+ createDB.close();
+ }
+ }
+ }
+
+ private void installSchemaAndData(String jonVersion) throws Exception {
+ DBSetup dbsetup = new DBSetup(DB_URL, USERNAME, PASSWORD);
+ dbsetup.setup(getSchemaFile(jonVersion).getAbsolutePath());
+ dbsetup.setup(getDataFile(jonVersion).getAbsolutePath());
+ }
+
+ private File getSchemaFile(String version) throws Exception {
+ URL url = getClass().getResource("db-schema-combined-" + version + ".xml");
+
+ if (url == null) {
+ throw new RuntimeException("Failed to find schema file for version " + version);
+ }
+
+ return new File(url.toURI().getPath());
+ }
+
+ private File getDataFile(String version) throws Exception {
+ URL url = getClass().getResource("db-data-combined-" + version + ".xml");
+
+ if (url == null) {
+ throw new RuntimeException("Failed to find data file for version " + version);
+ }
+
+ return new File(url.toURI().getPath());
+ }
+
+ private Properties getInstallProperties() {
+ Properties dbProperties = new Properties();
+ dbProperties.put(ServerProperties.PROP_DATABASE_CONNECTION_URL, DB_URL);
+ dbProperties.put(ServerProperties.PROP_DATABASE_USERNAME, USERNAME);
+ dbProperties.put(ServerProperties.PROP_DATABASE_PASSWORD, PASSWORD);
+ dbProperties.put(ServerProperties.PROP_EMAIL_FROM_ADDRESS, "rhqadmin(a)localhost.com");
+ return dbProperties;
+ }
+}
diff --git a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
deleted file mode 100644
index 579bebf..0000000
--- a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.rhq.enterprise.installer;
-
-import org.rhq.core.db.DbUtil;
-import org.rhq.core.db.setup.DBSetup;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.io.File;
-import java.net.URI;
-import java.net.URL;
-import java.sql.Connection;
-import java.sql.Statement;
-import java.util.Properties;
-
-/**
- * The tests in this class exercise the dbsetup/dbupgrade code that is run in the installer. The tests currently only
- * run against postgresql. Support needs to be added for oracle. The tests do not do any post-install/upgrade
- * verification at the time of this writing. They just simply exercise the dbsetup/dbupgrade scripts to ensure that
- * they do not contain any errors.
- *
- * @author John Sanda
- */
-public class DBInstallatonTest {
-
- private final String LOG_DIRECTORY = System.getProperty("java.io.tmpdir", "rhq/installer-test");
- private final String TEST_DB = System.getProperty("rhq.test.ds.db-name","rhq_installer_test_db");
- private final String USERNAME = System.getProperty("rhq.test.ds.user-name", "rhqadmin");
- private final String PASSWORD = System.getProperty("rhq.test.ds.password", "rhqadmin");
- private final String SERVER = System.getProperty("rhq.test.ds.server-name", "127.0.0.1");
- private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
- private final String ADMIN_USERNAME = System.getProperty("rhq.db.admin.username", "postgres");
- private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
-
- private ServerInformation installer;
-
- @BeforeMethod
- public void prepareForInstallation() throws Exception {
- initLogDirectory();
- recreateTestDatabase();
-
- installer = new ServerInformation();
- installer.setLogDirectory(new File(LOG_DIRECTORY));
- }
-
- @Test
- public void overwriteJON230Schema() throws Exception {
- installSchemaAndData("2.3.0");
- installer.createNewDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void upgradeJON230Schema() throws Exception {
- installSchemaAndData("2.3.0");
- installer.upgradeExistingDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void overwriteJON231Schema() throws Exception {
- installSchemaAndData("2.3.1");
- installer.createNewDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void upgradeJON231Schema() throws Exception {
- installSchemaAndData("2.3.1");
- installer.upgradeExistingDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void overwriteJON240Schema() throws Exception {
- installSchemaAndData("2.4.0");
- installer.createNewDatabaseSchema(getInstallProperties());
- }
-
- @Test
- public void upgradeJON240Schema() throws Exception {
- installSchemaAndData("2.4.0");
- installer.upgradeExistingDatabaseSchema(getInstallProperties());
- }
-
- private void initLogDirectory() {
- File logDir = new File(LOG_DIRECTORY);
- if (logDir.exists()) {
- logDir.delete();
- }
- logDir.mkdirs();
- }
-
- private void recreateTestDatabase() throws Exception {
- Connection connection = null;
- Statement dropDB = null;
- Statement createDB = null;
-
- try {
- connection = DbUtil.getConnection(DB_URL.replace(TEST_DB,"postgres"), ADMIN_USERNAME, ADMIN_PASSWORD);
-
- dropDB = connection.createStatement();
- dropDB.execute("drop database if exists " + TEST_DB);
-
- createDB = connection.createStatement();
- createDB.execute("create database " + TEST_DB + " with owner " + USERNAME);
- } finally {
- if (connection != null) {
- connection.close();
- }
- if (dropDB != null) {
- dropDB.close();
- }
- if (createDB != null) {
- createDB.close();
- }
- }
- }
-
- private void installSchemaAndData(String jonVersion) throws Exception {
- DBSetup dbsetup = new DBSetup(DB_URL, USERNAME, PASSWORD);
- dbsetup.setup(getSchemaFile(jonVersion).getAbsolutePath());
- dbsetup.setup(getDataFile(jonVersion).getAbsolutePath());
- }
-
- private File getSchemaFile(String version) throws Exception {
- URL url = getClass().getResource("db-schema-combined-" + version + ".xml");
-
- if (url == null) {
- throw new RuntimeException("Failed to find schema file for version " + version);
- }
-
- return new File(url.toURI().getPath());
- }
-
- private File getDataFile(String version) throws Exception {
- URL url = getClass().getResource("db-data-combined-" + version + ".xml");
-
- if (url == null) {
- throw new RuntimeException("Failed to find data file for version " + version);
- }
-
- return new File(url.toURI().getPath());
- }
-
- private Properties getInstallProperties() {
- Properties dbProperties = new Properties();
- dbProperties.put(ServerProperties.PROP_DATABASE_CONNECTION_URL, DB_URL);
- dbProperties.put(ServerProperties.PROP_DATABASE_USERNAME, USERNAME);
- dbProperties.put(ServerProperties.PROP_DATABASE_PASSWORD, PASSWORD);
- dbProperties.put(ServerProperties.PROP_EMAIL_FROM_ADDRESS, "rhqadmin(a)localhost.com");
- return dbProperties;
- }
-}
commit 7da61116768d389fe16039fe0d54054117941ad3
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 17:07:07 2011 -0500
Adding driver class to the property list.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 737150e..f0113c8 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -201,6 +201,7 @@
<rhq.ds.connection-url>${rhq.dev.ds.connection-url}</rhq.ds.connection-url>
<rhq.ds.user-name>${rhq.dev.ds.user-name}</rhq.ds.user-name>
<rhq.ds.password>${rhq.dev.ds.password}></rhq.ds.password>
+ <rhq.ds.driver-class>${rhq.dev.ds.driver-class}</rhq.ds.driver-class>
</properties>
</profile>
commit 14facab3f9eaf5eb0de00e3b371626be1ee4d4a1
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 16:33:35 2011 -0500
Move conditional properties to maven profiles. This reduces code duplication and makes the pom smaller and more manageable.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index ce2a418..737150e 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -187,6 +187,24 @@
<profiles>
<profile>
+ <id>db.dev</id>
+ <activation>
+ <property>
+ <name>db</name>
+ <value>dev</value>
+ </property>
+ </activation>
+
+ <properties>
+ <rhq.ds.type-mapping>${rhq.dev.ds.type-mapping}</rhq.ds.type-mapping>
+ <rhq.ds.db-name>${rhq.dev.ds.db-name}</rhq.ds.db-name>
+ <rhq.ds.connection-url>${rhq.dev.ds.connection-url}</rhq.ds.connection-url>
+ <rhq.ds.user-name>${rhq.dev.ds.user-name}</rhq.ds.user-name>
+ <rhq.ds.password>${rhq.dev.ds.password}></rhq.ds.password>
+ </properties>
+ </profile>
+
+ <profile>
<id>latest</id>
<activation>
<property>
@@ -221,18 +239,6 @@
<phase>test</phase>
<configuration>
<tasks>
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
@@ -264,18 +270,6 @@
<configuration>
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
@@ -305,21 +299,6 @@
<configuration>
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
@@ -367,18 +346,6 @@
<configuration>
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="create-release-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
commit 6443467dcca7a2185fb611ca422bef23156a7a1f
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 15:50:19 2011 -0500
Complete format of the pom file to make it easier to read.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 7ccc00e..ce2a418 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -85,96 +85,117 @@
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
- <version>${postgresql.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.1</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <phase>process-classes</phase>
- <goals>
- <goal>java</goal>
- </goals>
- <configuration>
- <mainClass>org.rhq.core.db.reset.DBReset</mainClass>
- <systemProperties>
- <systemProperty>
- <key>rhq.ds.type-mapping</key>
- <value>${rhq.ds.type-mapping}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.server-name</key>
- <value>${rhq.ds.server-name}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.db-name</key>
- <value>${rhq.ds.db-name}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.connection-url</key>
- <value>${rhq.ds.connection-url}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.db.admin.username</key>
- <value>${rhq.db.admin.username}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.db.admin.password</key>
- <value>${rhq.db.admin.password}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.user-name</key>
- <value>${rhq.ds.user-name}</value>
- </systemProperty>
- <systemProperty>
- <key>rhq.ds.password</key>
- <value>${rhq.ds.password}</value>
- </systemProperty>
- </systemProperties>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemProperties>
- <property>
- <name>DatabaseTest.nofail</name>
- <value>${DatabaseTest.nofail}</value>
- </property>
- <property>
- <name>AntDatabaseTest.test-resources</name>
- <value>${basedir}/src/test/resources</value>
- </property>
- </systemProperties>
- <!-- The below is required for tests to run against Oracle. -->
- <additionalClasspathElements>
- <additionalClasspathElement>${settings.localRepository}/com/oracle/ojdbc5/${ojdbc5.version}/ojdbc5-${ojdbc5.version}.jar</additionalClasspathElement>
- </additionalClasspathElements>
- </configuration>
- </plugin>
-
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>latest</id>
- <activation>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>net.sourceforge.jtds</groupId>
+ <artifactId>jtds</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2</version>
+ <dependencies>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>${postgresql.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ <configuration>
+ <mainClass>org.rhq.core.db.reset.DBReset</mainClass>
+ <systemProperties>
+ <systemProperty>
+ <key>rhq.ds.type-mapping</key>
+ <value>${rhq.ds.type-mapping}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.server-name</key>
+ <value>${rhq.ds.server-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.db-name</key>
+ <value>${rhq.ds.db-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.connection-url</key>
+ <value>${rhq.ds.connection-url}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.db.admin.username</key>
+ <value>${rhq.db.admin.username}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.db.admin.password</key>
+ <value>${rhq.db.admin.password}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.user-name</key>
+ <value>${rhq.ds.user-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.password</key>
+ <value>${rhq.ds.password}</value>
+ </systemProperty>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>DatabaseTest.nofail</name>
+ <value>${DatabaseTest.nofail}</value>
+ </property>
+ <property>
+ <name>AntDatabaseTest.test-resources</name>
+ <value>${basedir}/src/test/resources</value>
+ </property>
+ </systemProperties>
+ <!-- The below is required for tests to run against Oracle. -->
+ <additionalClasspathElements>
+ <additionalClasspathElement>${settings.localRepository}/com/oracle/ojdbc5/${ojdbc5.version}/ojdbc5-${ojdbc5.version}.jar</additionalClasspathElement>
+ </additionalClasspathElements>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>latest</id>
+ <activation>
<property>
<name>!jon.release</name>
</property>
</activation>
-
<build>
<plugins>
- <plugin>
+ <plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
@@ -183,7 +204,6 @@
<tasks>
<!-- generate the I18N resource bundles -->
<taskdef name="i18n" classpathref="maven.runtime.classpath" classname="mazz.i18n.ant.I18NAntTask" />
-
<i18n outputdir="${project.build.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true">
<classpath refid="maven.runtime.classpath" />
<classfileset dir="${project.build.outputDirectory}">
@@ -196,396 +216,365 @@
<goal>run</goal>
</goals>
</execution>
-
<execution>
<id>dbsetup-worker</id>
<phase>test</phase>
<configuration>
- <tasks>
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- <property name="dbsetup" value="${dbsetup}" />
- <property name="dbsetup-uninstall" value="${dbsetup-uninstall}" />
- <property name="dbsetup-upgrade" value="${dbsetup-upgrade}" />
- <property name="dbsetup-export" value="${dbsetup-export}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>generate-dbsetup-dbupgrade-xml-files</id>
- <phase>process-classes</phase>
- <configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <!--
- This execution will abort the build if the database schema is not up to date.
- If you want the build to continue, regardless of your currently installed schema,
- then pass -Ddbsetup-do-not-check-schema to the mvn command line.
- -->
- <id>test-db-schema-version</id>
- <phase>test</phase>
- <configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
+ <tasks>
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ <property name="dbsetup" value="${dbsetup}" />
+ <property name="dbsetup-uninstall" value="${dbsetup-uninstall}" />
+ <property name="dbsetup-upgrade" value="${dbsetup-upgrade}" />
+ <property name="dbsetup-export" value="${dbsetup-export}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>generate-dbsetup-dbupgrade-xml-files</id>
+ <phase>process-classes</phase>
+ <configuration>
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <!-- This execution will abort the build if the database schema is not up to date. If you want the build to continue, regardless of your currently installed
+ schema, then pass -Ddbsetup-do-not-check-schema to the mvn command line. -->
+ <id>test-db-schema-version</id>
+ <phase>test</phase>
+ <configuration>
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
+ <property name="dbsetup-do-not-check-schema" value="${dbsetup-do-not-check-schema}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
- <property name="dbsetup-do-not-check-schema" value="${dbsetup-do-not-check-schema}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>jon.release</id>
- <activation>
- <property>
- <name>jon.release</name>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-schema</id>
- <phase>test</phase>
- <configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="create-release-schema">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- <property name="jon.release" value="${jon.release}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>dev</id>
-
- <properties>
- <rhq.rootDir>../../..</rhq.rootDir>
- <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
- <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/lib</rhq.deploymentDir>
- </properties>
-
- <build>
- <plugins>
-
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.1</version>
- <executions>
-
- <execution>
- <id>deploy</id>
- <phase>compile</phase>
- <configuration>
- <tasks>
- <mkdir dir="${rhq.deploymentDir}" />
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Updating ${deployment.file}...</echo>
- <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>undeploy</id>
- <phase>clean</phase>
- <configuration>
- <tasks>
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Deleting ${deployment.file}...</echo>
- <delete file="${deployment.file}" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- </executions>
- </plugin>
-
- </plugins>
- </build>
- </profile>
- <profile>
- <id>cobertura</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>net.sourceforge.cobertura</groupId>
- <artifactId>cobertura</artifactId>
- <version>${cobertura.version}</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <id>cobertura-instrument</id>
- <phase>process-test-classes</phase>
- <configuration>
- <tasks>
- <!-- prepare directory structure for cobertura-->
- <mkdir dir="target/cobertura" />
- <mkdir dir="target/cobertura/backup" />
- <!-- backup all classes so that we can instrument the original classes-->
- <copy toDir="target/cobertura/backup" verbose="true" overwrite="true">
- <fileset dir="target/classes">
- <include name="**/*.class" />
- </fileset>
- </copy>
- <!-- create a properties file and save there location of cobertura data file-->
- <touch file="target/classes/cobertura.properties" />
- <echo file="target/classes/cobertura.properties">net.sourceforge.cobertura.datafile=${project.build.directory}/cobertura/cobertura.ser</echo>
- <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
- <!-- instrument all classes in target/classes directory -->
- <cobertura-instrument datafile="${project.build.directory}/cobertura/cobertura.ser" todir="${project.build.directory}/classes">
- <fileset dir="${project.build.directory}/classes">
- <include name="**/*.class" />
- </fileset>
- </cobertura-instrument>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- <execution>
- <id>cobertura-report</id>
- <phase>prepare-package</phase>
- <configuration>
- <tasks>
- <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
- <!-- prepare directory structure for cobertura-->
- <mkdir dir="target/cobertura" />
- <mkdir dir="target/site/cobertura" />
- <!-- restore classes from backup folder to classes folder -->
- <copy toDir="target/classes" verbose="true" overwrite="true">
- <fileset dir="target/cobertura/backup">
- <include name="**/*.class" />
- </fileset>
- </copy>
- <!-- delete backup folder-->
- <delete dir="target/cobertura/backup" />
- <!-- create a code coverage report -->
- <cobertura-report format="html" datafile="${project.build.directory}/cobertura/cobertura.ser" destdir="${project.build.directory}/site/cobertura">
- <fileset dir="${basedir}/src/main/java">
- <include name="**/*.java" />
- </fileset>
- </cobertura-report>
- <!-- delete cobertura.properties file -->
- <delete file="target/classes/cobertura.properties" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>ojdbc-driver</id>
- <dependencies>
- <dependency>
- <groupId>com.oracle</groupId>
- <artifactId>ojdbc5</artifactId>
- <version>${ojdbc5.version}</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.2</version>
- <dependencies>
- <dependency>
- <groupId>com.oracle</groupId>
- <artifactId>ojdbc5</artifactId>
- <version>${ojdbc5.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
- </profile>
+ <profile>
+ <id>jon.release</id>
+ <activation>
+ <property>
+ <name>jon.release</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-schema</id>
+ <phase>test</phase>
+ <configuration>
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="create-release-schema">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ <property name="jon.release" value="${jon.release}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>dev</id>
+ <properties>
+ <rhq.rootDir>../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/lib</rhq.deploymentDir>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${rhq.deploymentDir}" />
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>cobertura</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>net.sourceforge.cobertura</groupId>
+ <artifactId>cobertura</artifactId>
+ <version>${cobertura.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>cobertura-instrument</id>
+ <phase>process-test-classes</phase>
+ <configuration>
+ <tasks>
+ <!-- prepare directory structure for cobertura -->
+ <mkdir dir="target/cobertura" />
+ <mkdir dir="target/cobertura/backup" />
+ <!-- backup all classes so that we can instrument the original classes -->
+ <copy toDir="target/cobertura/backup" verbose="true" overwrite="true">
+ <fileset dir="target/classes">
+ <include name="**/*.class" />
+ </fileset>
+ </copy>
+ <!-- create a properties file and save there location of cobertura data file -->
+ <touch file="target/classes/cobertura.properties" />
+ <echo file="target/classes/cobertura.properties">net.sourceforge.cobertura.datafile=${project.build.directory}/cobertura/cobertura.ser</echo>
+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
+ <!-- instrument all classes in target/classes directory -->
+ <cobertura-instrument datafile="${project.build.directory}/cobertura/cobertura.ser" todir="${project.build.directory}/classes">
+ <fileset dir="${project.build.directory}/classes">
+ <include name="**/*.class" />
+ </fileset>
+ </cobertura-instrument>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>cobertura-report</id>
+ <phase>prepare-package</phase>
+ <configuration>
+ <tasks>
+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
+ <!-- prepare directory structure for cobertura -->
+ <mkdir dir="target/cobertura" />
+ <mkdir dir="target/site/cobertura" />
+ <!-- restore classes from backup folder to classes folder -->
+ <copy toDir="target/classes" verbose="true" overwrite="true">
+ <fileset dir="target/cobertura/backup">
+ <include name="**/*.class" />
+ </fileset>
+ </copy>
+ <!-- delete backup folder -->
+ <delete dir="target/cobertura/backup" />
+ <!-- create a code coverage report -->
+ <cobertura-report format="html" datafile="${project.build.directory}/cobertura/cobertura.ser" destdir="${project.build.directory}/site/cobertura">
+ <fileset dir="${basedir}/src/main/java">
+ <include name="**/*.java" />
+ </fileset>
+ </cobertura-report>
+ <!-- delete cobertura.properties file -->
+ <delete file="target/classes/cobertura.properties" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>ojdbc-driver</id>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc5</artifactId>
+ <version>${ojdbc5.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2</version>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc5</artifactId>
+ <version>${ojdbc5.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
-
- <pluginRepositories>
- <pluginRepository>
- <id>codehaus-snapshots</id>
- <name>codehaus snapshots</name>
- <url>http://snapshots.repository.codehaus.org</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </pluginRepository>
- </pluginRepositories>
-
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>codehaus-snapshots</id>
+ <name>codehaus snapshots</name>
+ <url>http://snapshots.repository.codehaus.org</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
</project>
-
commit 4a324ffa1c27cc0330e2f79e1f188164f691916e
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 1 15:44:22 2011 -0500
Stray changes from one more file reverted properly.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 06f1495..7ccc00e 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -35,13 +35,12 @@
<version>1.6.5</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
-
<dependency>
<groupId>ant</groupId>
<artifactId>ant-launcher</artifactId>
@@ -167,48 +166,54 @@
<profiles>
<profile>
<id>latest</id>
- <activation>
- <property>
- <name>!jon.release</name>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <phase>process-classes</phase>
- <configuration>
- <tasks>
- <!-- generate the I18N resource bundles -->
- <taskdef name="i18n" classpathref="maven.runtime.classpath" classname="mazz.i18n.ant.I18NAntTask" />
-
- <i18n outputdir="${project.build.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true">
- <classpath refid="maven.runtime.classpath" />
- <classfileset dir="${project.build.outputDirectory}">
- <include name="**/*I18NResourceKeys.class" />
- </classfileset>
- </i18n>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>dbsetup-worker</id>
- <phase>test</phase>
- <configuration>
+ <activation>
+ <property>
+ <name>!jon.release</name>
+ </property>
+ </activation>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <configuration>
+ <tasks>
+ <!-- generate the I18N resource bundles -->
+ <taskdef name="i18n" classpathref="maven.runtime.classpath" classname="mazz.i18n.ant.I18NAntTask" />
+
+ <i18n outputdir="${project.build.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true">
+ <classpath refid="maven.runtime.classpath" />
+ <classfileset dir="${project.build.outputDirectory}">
+ <include name="**/*I18NResourceKeys.class" />
+ </classfileset>
+ </i18n>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>dbsetup-worker</id>
+ <phase>test</phase>
+ <configuration>
<tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}"/>
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}"/>
- <property name="rhq.ds.password" value="${rhq.ds.password}"/>
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -243,21 +248,21 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
<equals arg1="${db}" arg2="dev" />
- </condition>
+ </condition>
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
<equals arg1="${db}" arg2="dev" />
- </condition>
+ </condition>
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
<equals arg1="${db}" arg2="dev" />
- </condition>
+ </condition>
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
<equals arg1="${db}" arg2="dev" />
- </condition>
+ </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -289,50 +294,50 @@
-->
<id>test-db-schema-version</id>
<phase>test</phase>
- <configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
- <property name="settings.localRepository" value="${settings.localRepository}" />
- <property name="ojdbc5.version" value="${ojdbc5.version}" />
- <property name="postgresql.version" value="${postgresql.version}" />
- <property name="h2.version" value="${h2.version}" />
- <property name="jtds.version" value="${jtds.version}" />
- <property name="task.classpath.property" refid="maven.test.classpath" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="project.version" value="${project.version}" />
- <property name="db.schema.version" value="${db.schema.version}" />
- <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
- <property name="dbsetup-do-not-check-schema" value="${dbsetup-do-not-check-schema}" />
- </ant>
- </tasks>
- </configuration>
- <goals>
+ <configuration>
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
+ <property name="settings.localRepository" value="${settings.localRepository}" />
+ <property name="ojdbc5.version" value="${ojdbc5.version}" />
+ <property name="postgresql.version" value="${postgresql.version}" />
+ <property name="h2.version" value="${h2.version}" />
+ <property name="jtds.version" value="${jtds.version}" />
+ <property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="project.version" value="${project.version}" />
+ <property name="db.schema.version" value="${db.schema.version}" />
+ <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
+ <property name="dbsetup-do-not-check-schema" value="${dbsetup-do-not-check-schema}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
<goal>run</goal>
</goals>
</execution>
@@ -361,7 +366,7 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
<equals arg1="${db}" arg2="dev" />
</condition>
@@ -391,7 +396,7 @@
<property name="rhq.ds.password" value="${rhq.ds.password}" />
<property name="project.version" value="${project.version}" />
<property name="db.schema.version" value="${db.schema.version}" />
- <property name="jon.release" value="${jon.release}" />
+ <property name="jon.release" value="${jon.release}" />
</ant>
</tasks>
</configuration>
commit 00b4d34c6e87a4341ccdfc2c322ae711d687909c
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 28 13:46:24 2011 -0500
Revert "Updating the code to use only one set of datasource settings. (rhq.ds.name-of-setting)"
This reverts commit 1876436d7ba7d977e7b4abfcbf223a3fb202e746.
Conflicts:
modules/core/dbutils/pom.xml
diff --git a/etc/m2/settings-bugfixes.xml b/etc/m2/settings-bugfixes.xml
index 01f3173..b64aac6 100644
--- a/etc/m2/settings-bugfixes.xml
+++ b/etc/m2/settings-bugfixes.xml
@@ -28,8 +28,8 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.bugfixes</id>
<properties>
- <rhq.ds.db-name>rhqbugfixes</rhq.ds.db-name>
- <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqbugfixes</rhq.ds.connection-url>
+ <rhq.test.ds.db-name>rhqbugfixes</rhq.test.ds.db-name>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqbugfixes</rhq.test.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings-content.xml b/etc/m2/settings-content.xml
index 3009f75..806006b 100644
--- a/etc/m2/settings-content.xml
+++ b/etc/m2/settings-content.xml
@@ -33,7 +33,7 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.content</id>
<properties>
- <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqcontent</rhq.ds.connection-url>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqcontent</rhq.test.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings-linux-config.xml b/etc/m2/settings-linux-config.xml
index 6605f33..dd464f7 100644
--- a/etc/m2/settings-linux-config.xml
+++ b/etc/m2/settings-linux-config.xml
@@ -28,7 +28,7 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.linux-config</id>
<properties>
- <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqlconf</rhq.ds.connection-url>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqlconf</rhq.test.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings-rawconfig.xml b/etc/m2/settings-rawconfig.xml
index f64b717..f871d66 100644
--- a/etc/m2/settings-rawconfig.xml
+++ b/etc/m2/settings-rawconfig.xml
@@ -28,8 +28,8 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.rawconfig</id>
<properties>
- <rhq.ds.db-name>rhqrawconfig</rhq.ds.db-name>
- <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqrawconfig</rhq.ds.connection-url>
+ <rhq.test.ds.db-name>rhqrawconfig</rhq.test.ds.db-name>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqrawconfig</rhq.test.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings.xml b/etc/m2/settings.xml
index 89c26f2..8c0dada 100644
--- a/etc/m2/settings.xml
+++ b/etc/m2/settings.xml
@@ -91,21 +91,31 @@
<profile>
<id>postgres</id>
<properties>
- <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhq</rhq.ds.connection-url>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
- <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
- <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.server-name>127.0.0.1</rhq.ds.server-name>
- <rhq.ds.port>5432</rhq.ds.port>
- <rhq.ds.db-name>rhq</rhq.ds.db-name>
- <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhq</rhq.test.ds.connection-url>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
+ <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
+ <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.server-name>127.0.0.1</rhq.test.ds.server-name>
+ <rhq.test.ds.port>5432</rhq.test.ds.port>
+ <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
+ <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
+ <rhq.dev.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhq</rhq.dev.ds.connection-url>
+ <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
+ <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
+ <rhq.dev.ds.type-mapping>PostgreSQL</rhq.dev.ds.type-mapping>
+ <rhq.dev.ds.driver-class>org.postgresql.Driver</rhq.dev.ds.driver-class>
+ <rhq.dev.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.dev.ds.xa-datasource-class>
+ <rhq.dev.ds.server-name>127.0.0.1</rhq.dev.ds.server-name>
+ <rhq.dev.ds.port>5432</rhq.dev.ds.port>
+ <rhq.dev.ds.db-name>rhq</rhq.dev.ds.db-name>
+ <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.dev.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.dev.quartz.selectWithLockSQL>
@@ -116,22 +126,33 @@
<profile>
<id>h2</id>
<properties>
- <rhq.ds.driver-class>org.h2.Driver</rhq.ds.driver-class>
- <rhq.ds.connection-url>jdbc:h2:~/rhq;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOG=2</rhq.ds.connection-url>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.type-mapping>h2</rhq.ds.type-mapping>
- <rhq.ds.xa-datasource-class>org.h2.jdbcx.JdbcDataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.server-name>127.0.0.1</rhq.ds.server-name>
- <rhq.ds.port>9092</rhq.ds.port>
- <rhq.ds.db-name>rhq</rhq.ds.db-name>
+ <rhq.test.ds.driver-class>org.h2.Driver</rhq.test.ds.driver-class>
+ <rhq.test.ds.connection-url>jdbc:h2:~/rhq;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOG=2</rhq.test.ds.connection-url>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>h2</rhq.test.ds.type-mapping>
+ <rhq.test.ds.xa-datasource-class>org.h2.jdbcx.JdbcDataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.server-name>127.0.0.1</rhq.test.ds.server-name>
+ <rhq.test.ds.port>9092</rhq.test.ds.port>
+ <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
<!-- This custom dialect is required for proper operation using H2, see class JavaDoc for more info -->
- <rhq.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.test.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.StdJDBCDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
-
+
+ <rhq.dev.ds.driver-class>org.h2.Driver</rhq.dev.ds.driver-class>
+ <rhq.dev.ds.connection-url>jdbc:h2:~/rhq;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOG=2</rhq.dev.ds.connection-url>
+ <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
+ <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
+ <rhq.dev.ds.type-mapping>h2</rhq.dev.ds.type-mapping>
+ <rhq.dev.ds.xa-datasource-class>org.h2.jdbcx.JdbcDataSource</rhq.dev.ds.xa-datasource-class>
+ <rhq.dev.ds.server-name>127.0.0.1</rhq.dev.ds.server-name>
+ <rhq.dev.ds.port>9092</rhq.dev.ds.port>
+ <rhq.dev.ds.db-name>rhq</rhq.dev.ds.db-name>
+ <!-- This custom dialect is required for proper operation using H2, see class JavaDoc for more info -->
+ <rhq.dev.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.dev.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.StdJDBCDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.dev.quartz.selectWithLockSQL>
@@ -142,21 +163,31 @@
<profile>
<id>sqlserver</id>
<properties>
- <rhq.ds.driver-class>net.sourceforge.jtds.jdbc.Driver</rhq.ds.driver-class>
- <rhq.ds.connection-url>jdbc:jtds:sqlserver://localhost:1433;databaseName=rhq</rhq.ds.connection-url>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.type-mapping>sqlserver</rhq.ds.type-mapping>
- <rhq.ds.xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.server-name>localhost</rhq.ds.server-name>
- <rhq.ds.port>1433</rhq.ds.port>
- <rhq.ds.db-name>rhq</rhq.ds.db-name>
- <rhq.ds.hibernate-dialect>org.hibernate.dialect.SQLServerDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.driver-class>net.sourceforge.jtds.jdbc.Driver</rhq.test.ds.driver-class>
+ <rhq.test.ds.connection-url>jdbc:jtds:sqlserver://localhost:1433;databaseName=rhq</rhq.test.ds.connection-url>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>sqlserver</rhq.test.ds.type-mapping>
+ <rhq.test.ds.xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.server-name>localhost</rhq.test.ds.server-name>
+ <rhq.test.ds.port>1433</rhq.test.ds.port>
+ <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
+ <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.SQLServerDialect</rhq.test.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.MSSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>UPDATE {0}LOCKS SET LOCK_NAME = LOCK_NAME WHERE LOCK_NAME = ?</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.UpdateLockRowSemaphore</rhq.test.quartz.lockHandlerClass>
-
+
+ <rhq.dev.ds.driver-class>net.sourceforge.jtds.jdbc.Driver</rhq.dev.ds.driver-class>
+ <rhq.dev.ds.connection-url>jdbc:jtds:sqlserver://localhost:1433;databaseName=rhq</rhq.dev.ds.connection-url>
+ <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
+ <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
+ <rhq.dev.ds.type-mapping>sqlserver</rhq.dev.ds.type-mapping>
+ <rhq.dev.ds.xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</rhq.dev.ds.xa-datasource-class>
+ <rhq.dev.ds.server-name>localhost</rhq.dev.ds.server-name>
+ <rhq.dev.ds.port>1433</rhq.dev.ds.port>
+ <rhq.dev.ds.db-name>rhq</rhq.dev.ds.db-name>
+ <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.SQLServerDialect</rhq.dev.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.MSSQLDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>UPDATE {0}LOCKS SET LOCK_NAME = LOCK_NAME WHERE LOCK_NAME = ?</rhq.dev.quartz.selectWithLockSQL>
@@ -167,21 +198,31 @@
<profile>
<id>oracle</id>
<properties>
- <rhq.ds.connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</rhq.ds.connection-url>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.type-mapping>Oracle10g</rhq.ds.type-mapping>
- <rhq.ds.driver-class>oracle.jdbc.driver.OracleDriver</rhq.ds.driver-class>
- <rhq.ds.xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.server-name></rhq.ds.server-name> <!-- can be left blank, oracle does not use this -->
- <rhq.ds.port></rhq.ds.port> <!-- can be left blank, oracle does not use this -->
- <rhq.ds.db-name></rhq.ds.db-name> <!-- can be left blank, oracle does not use this -->
- <rhq.ds.hibernate-dialect>org.hibernate.dialect.Oracle10gDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</rhq.test.ds.connection-url>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>Oracle10g</rhq.test.ds.type-mapping>
+ <rhq.test.ds.driver-class>oracle.jdbc.driver.OracleDriver</rhq.test.ds.driver-class>
+ <rhq.test.ds.xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.server-name></rhq.test.ds.server-name> <!-- can be left blank, oracle does not use this -->
+ <rhq.test.ds.port></rhq.test.ds.port> <!-- can be left blank, oracle does not use this -->
+ <rhq.test.ds.db-name></rhq.test.ds.db-name> <!-- can be left blank, oracle does not use this -->
+ <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.Oracle10gDialect</rhq.test.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.oracle.OracleDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
+ <rhq.dev.ds.connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</rhq.dev.ds.connection-url>
+ <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
+ <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
+ <rhq.dev.ds.type-mapping>Oracle10g</rhq.dev.ds.type-mapping>
+ <rhq.dev.ds.driver-class>oracle.jdbc.driver.OracleDriver</rhq.dev.ds.driver-class>
+ <rhq.dev.ds.xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</rhq.dev.ds.xa-datasource-class>
+ <rhq.dev.ds.server-name></rhq.dev.ds.server-name> <!-- can be left blank, oracle does not use this -->
+ <rhq.dev.ds.port></rhq.dev.ds.port> <!-- can be left blank, oracle does not use this -->
+ <rhq.dev.ds.db-name></rhq.dev.ds.db-name> <!-- can be left blank, oracle does not use this -->
+ <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.Oracle10gDialect</rhq.dev.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.oracle.OracleDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.dev.quartz.selectWithLockSQL>
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index a492187..06f1495 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -241,12 +241,23 @@
<phase>process-classes</phase>
<configuration>
<tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}"/>
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}"/>
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}"/>
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}"/>
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}"/>
- <property name="rhq.ds.password" value="${rhq.ds.password}"/>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -279,14 +290,28 @@
<id>test-db-schema-version</id>
<phase>test</phase>
<configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
- <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -334,13 +359,24 @@
<phase>test</phase>
<configuration>
<tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password" value="${rhq.ds.password}" />
-
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+
+ <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
+ <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
+ <equals arg1="${db}" arg2="dev" />
+ </condition>
+
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="create-release-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
@@ -355,10 +391,10 @@
<property name="rhq.ds.password" value="${rhq.ds.password}" />
<property name="project.version" value="${project.version}" />
<property name="db.schema.version" value="${db.schema.version}" />
- <property name="jon.release" value="${jon.release}" />
- </ant>
- </tasks>
- </configuration>
+ <property name="jon.release" value="${jon.release}" />
+ </ant>
+ </tasks>
+ </configuration>
<goals>
<goal>run</goal>
</goals>
diff --git a/modules/core/domain/pom.xml b/modules/core/domain/pom.xml
index c8ce307..42d28e1 100644
--- a/modules/core/domain/pom.xml
+++ b/modules/core/domain/pom.xml
@@ -282,7 +282,7 @@
</property>
<property>
<name>hibernate.dialect</name>
- <value>${rhq.ds.hibernate-dialect}</value>
+ <value>${rhq.test.ds.hibernate-dialect}</value>
</property>
</systemProperties>
<excludes>
diff --git a/modules/core/domain/src/test/resources/embedded-jboss-beans.xml b/modules/core/domain/src/test/resources/embedded-jboss-beans.xml
index a51f3e3..ae9de01 100644
--- a/modules/core/domain/src/test/resources/embedded-jboss-beans.xml
+++ b/modules/core/domain/src/test/resources/embedded-jboss-beans.xml
@@ -85,10 +85,10 @@
-->
<bean name="RHQDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
- <property name="driverClass">${rhq.ds.driver-class}</property>
- <property name="connectionURL">${rhq.ds.connection-url}</property>
- <property name="userName">${rhq.ds.user-name}</property>
- <property name="password">${rhq.ds.password}</property>
+ <property name="driverClass">${rhq.test.ds.driver-class}</property>
+ <property name="connectionURL">${rhq.test.ds.connection-url}</property>
+ <property name="userName">${rhq.test.ds.user-name}</property>
+ <property name="password">${rhq.test.ds.password}</property>
<property name="jndiName">java:/RHQDS</property>
<property name="minSize">0</property>
<property name="maxSize">10</property>
diff --git a/modules/enterprise/gui/installer-war/pom.xml b/modules/enterprise/gui/installer-war/pom.xml
index f73e403..517399c 100644
--- a/modules/enterprise/gui/installer-war/pom.xml
+++ b/modules/enterprise/gui/installer-war/pom.xml
@@ -147,13 +147,13 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
- <rhq.ds.server-name>${rhq.ds.server-name}</rhq.ds.server-name>
- <rhq.ds.db-name>${rhq.ds.db-name}</rhq.ds.db-name>
- <rhq.ds.connection-url>${rhq.ds.connection-url}</rhq.ds.connection-url>
+ <rhq.test.ds.server-name>${rhq.test.ds.server-name}</rhq.test.ds.server-name>
+ <rhq.test.ds.db-name>${rhq.test.ds.db-name}</rhq.test.ds.db-name>
+ <rhq.test.ds.connection-url>${rhq.test.ds.connection-url}</rhq.test.ds.connection-url>
<rhq.db.admin.username>${rhq.db.admin.username}</rhq.db.admin.username>
<rhq.db.admin.password>${rhq.db.admin.password}</rhq.db.admin.password>
- <rhq.ds.user-name>${rhq.ds.user-name}</rhq.ds.user-name>
- <rhq.ds.password>${rhq.ds.password}</rhq.ds.password>
+ <rhq.test.ds.user-name>${rhq.test.ds.user-name}</rhq.test.ds.user-name>
+ <rhq.test.ds.password>${rhq.test.ds.password}</rhq.test.ds.password>
</systemPropertyVariables>
</configuration>
</plugin>
diff --git a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
index 0e68830..579bebf 100644
--- a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
+++ b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
@@ -46,11 +46,11 @@ import java.util.Properties;
public class DBInstallatonTest {
private final String LOG_DIRECTORY = System.getProperty("java.io.tmpdir", "rhq/installer-test");
- private final String TEST_DB = System.getProperty("rhq.ds.db-name","rhq_installer_test_db");
- private final String USERNAME = System.getProperty("rhq.ds.user-name", "rhqadmin");
- private final String PASSWORD = System.getProperty("rhq.ds.password", "rhqadmin");
- private final String SERVER = System.getProperty("rhq.ds.server-name", "127.0.0.1");
- private final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
+ private final String TEST_DB = System.getProperty("rhq.test.ds.db-name","rhq_installer_test_db");
+ private final String USERNAME = System.getProperty("rhq.test.ds.user-name", "rhqadmin");
+ private final String PASSWORD = System.getProperty("rhq.test.ds.password", "rhqadmin");
+ private final String SERVER = System.getProperty("rhq.test.ds.server-name", "127.0.0.1");
+ private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
private final String ADMIN_USERNAME = System.getProperty("rhq.db.admin.username", "postgres");
private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
diff --git a/modules/enterprise/server/container/pom.xml b/modules/enterprise/server/container/pom.xml
index 8e59747..7329bb5 100644
--- a/modules/enterprise/server/container/pom.xml
+++ b/modules/enterprise/server/container/pom.xml
@@ -183,16 +183,16 @@
<property name="quartz.version" value="${quartz.version}" />
<!-- dev DB settings (used to init rhq-server.properties if dev profile is active or developer prop is set) -->
- <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
- <property name="rhq.ds.xa-datasource-class" value="${rhq.ds.xa-datasource-class}" />
- <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.ds.password.encrypted" value="${rhq.ds.password.encrypted}" />
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.ds.server-name" value="${rhq.ds.server-name}" />
- <property name="rhq.ds.port" value="${rhq.ds.port}" />
- <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
- <property name="rhq.ds.hibernate-dialect" value="${rhq.ds.hibernate-dialect}" />
+ <property name="rhq.dev.ds.connection-url" value="${rhq.dev.ds.connection-url}" />
+ <property name="rhq.dev.ds.driver-class" value="${rhq.dev.ds.driver-class}" />
+ <property name="rhq.dev.ds.xa-datasource-class" value="${rhq.dev.ds.xa-datasource-class}" />
+ <property name="rhq.dev.ds.user-name" value="${rhq.dev.ds.user-name}" />
+ <property name="rhq.dev.ds.password.encrypted" value="${rhq.dev.ds.password.encrypted}" />
+ <property name="rhq.dev.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" />
+ <property name="rhq.dev.ds.server-name" value="${rhq.dev.ds.server-name}" />
+ <property name="rhq.dev.ds.port" value="${rhq.dev.ds.port}" />
+ <property name="rhq.dev.ds.db-name" value="${rhq.dev.ds.db-name}" />
+ <property name="rhq.dev.ds.hibernate-dialect" value="${rhq.dev.ds.hibernate-dialect}" />
<property name="rhq.dev.quartz.driverDelegateClass" value="${rhq.dev.quartz.driverDelegateClass}" />
<property name="rhq.dev.quartz.selectWithLockSQL" value="${rhq.dev.quartz.selectWithLockSQL}" />
<property name="rhq.dev.quartz.lockHandlerClass" value="${rhq.dev.quartz.lockHandlerClass}" />
@@ -233,7 +233,8 @@
<property name="rhq.earName" value="${rhq.earName}" />
<!-- dev/test DB type (needed to init rhq-ds.xml) -->
- <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.test.ds.type-mapping" value="${rhq.test.ds.type-mapping}" />
+ <property name="rhq.dev.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" />
<property name="rhq.server.enable.web.services" value="${rhq.server.enable.ws}" />
</ant>
</tasks>
diff --git a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
index c4d83a0..704c50a 100644
--- a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
@@ -33,16 +33,16 @@
<target name="set-dev-server-props" if="predeploy">
<echo>*** Using dev database settings in rhq-server.properties...</echo>
- <property name="rhq.server.database.hibernate-dialect" value="${rhq.ds.hibernate-dialect}" />
- <property name="rhq.server.database.connection-url" value="${rhq.ds.connection-url}" />
- <property name="rhq.server.database.driver-class" value="${rhq.ds.driver-class}" />
- <property name="rhq.server.database.xa-datasource-class" value="${rhq.ds.xa-datasource-class}" />
- <property name="rhq.server.database.user-name" value="${rhq.ds.user-name}" />
- <property name="rhq.server.database.password" value="${rhq.ds.password.encrypted}" />
- <property name="rhq.server.database.type-mapping" value="${rhq.ds.type-mapping}" />
- <property name="rhq.server.database.server-name" value="${rhq.ds.server-name}" />
- <property name="rhq.server.database.port" value="${rhq.ds.port}" />
- <property name="rhq.server.database.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.server.database.hibernate-dialect" value="${rhq.dev.ds.hibernate-dialect}" />
+ <property name="rhq.server.database.connection-url" value="${rhq.dev.ds.connection-url}" />
+ <property name="rhq.server.database.driver-class" value="${rhq.dev.ds.driver-class}" />
+ <property name="rhq.server.database.xa-datasource-class" value="${rhq.dev.ds.xa-datasource-class}" />
+ <property name="rhq.server.database.user-name" value="${rhq.dev.ds.user-name}" />
+ <property name="rhq.server.database.password" value="${rhq.dev.ds.password.encrypted}" />
+ <property name="rhq.server.database.type-mapping" value="${rhq.dev.ds.type-mapping}" />
+ <property name="rhq.server.database.server-name" value="${rhq.dev.ds.server-name}" />
+ <property name="rhq.server.database.port" value="${rhq.dev.ds.port}" />
+ <property name="rhq.server.database.db-name" value="${rhq.dev.ds.db-name}" />
<property name="rhq.server.quartz.driverDelegateClass" value="${rhq.dev.quartz.driverDelegateClass}" />
<property name="rhq.server.quartz.selectWithLockSQL" value="${rhq.dev.quartz.selectWithLockSQL}" />
<property name="rhq.server.quartz.lockHandlerClass" value="${rhq.dev.quartz.lockHandlerClass}" />
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index 000808c..c5bb3ec 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -559,7 +559,7 @@ Build-OS-Version=${os.version}
<systemPropertyVariables>
<embeddedDeployment>true</embeddedDeployment>
<deploymentDirectory>target/classes</deploymentDirectory>
- <hibernate.dialect>${rhq.ds.hibernate-dialect}</hibernate.dialect>
+ <hibernate.dialect>${rhq.test.ds.hibernate-dialect}</hibernate.dialect>
<clean.db>${clean.db}</clean.db>
</systemPropertyVariables>
<additionalClasspathElements>
diff --git a/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml b/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml
index 05451bd..55d697b 100644
--- a/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml
+++ b/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml
@@ -76,10 +76,10 @@
</bean>
<bean name="RHQDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
- <property name="driverClass">${rhq.ds.driver-class}</property>
- <property name="connectionURL">${rhq.ds.connection-url}</property>
- <property name="userName">${rhq.ds.user-name}</property>
- <property name="password">${rhq.ds.password}</property>
+ <property name="driverClass">${rhq.test.ds.driver-class}</property>
+ <property name="connectionURL">${rhq.test.ds.connection-url}</property>
+ <property name="userName">${rhq.test.ds.user-name}</property>
+ <property name="password">${rhq.test.ds.password}</property>
<property name="jndiName">java:/RHQDS</property>
<property name="minSize">0</property>
<property name="maxSize">20</property>
@@ -104,10 +104,10 @@
<!-- needed for Quartz' no-TX data source (even though this is a local-tx, seems like Quartz is still working) -->
<bean name="NoTxRHQDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
- <property name="driverClass">${rhq.ds.driver-class}</property>
- <property name="connectionURL">${rhq.ds.connection-url}</property>
- <property name="userName">${rhq.ds.user-name}</property>
- <property name="password">${rhq.ds.password}</property>
+ <property name="driverClass">${rhq.test.ds.driver-class}</property>
+ <property name="connectionURL">${rhq.test.ds.connection-url}</property>
+ <property name="userName">${rhq.test.ds.user-name}</property>
+ <property name="password">${rhq.test.ds.password}</property>
<property name="jndiName">java:/NoTxRHQDS</property>
<property name="minSize">0</property>
<property name="maxSize">10</property>
diff --git a/modules/jopr/release.sh b/modules/jopr/release.sh
index c05b6ee..54f26ab 100755
--- a/modules/jopr/release.sh
+++ b/modules/jopr/release.sh
@@ -226,16 +226,16 @@ cat <<EOF >${SETTINGS}
<profile>
<id>release</id>
<properties>
- <rhq.ds.connection-url>jdbc:postgresql://jon03.qa.atl2.redhat.com:5432/rhq_release</rhq.ds.connection-url>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
- <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
- <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.server-name>jon03.qa.atl2.redhat.com</rhq.ds.server-name>
- <rhq.ds.port>5432</rhq.ds.port>
- <rhq.ds.db-name>rhq_release</rhq.ds.db-name>
- <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.connection-url>jdbc:postgresql://jon03.qa.atl2.redhat.com:5432/rhq_release</rhq.test.ds.connection-url>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
+ <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
+ <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.server-name>jon03.qa.atl2.redhat.com</rhq.test.ds.server-name>
+ <rhq.test.ds.port>5432</rhq.test.ds.port>
+ <rhq.test.ds.db-name>rhq_release</rhq.test.ds.db-name>
+ <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
diff --git a/pom.xml b/pom.xml
index 23afa62..549e0d0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -107,22 +107,42 @@
defaults for datasource used by integration tests -
these may be overridden in ~/.m2/settings.xml
-->
- <rhq.ds.db-name>rhq</rhq.ds.db-name>
- <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.ds.db-name}</rhq.ds.connection-url>
- <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
- <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.password.encrypted>1eeb2f255e832171df8592078de921bc</rhq.ds.password.encrypted>
- <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
- <rhq.ds.server-name>127.0.0.1</rhq.ds.server-name>
- <rhq.ds.port>5432</rhq.ds.port>
- <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
+ <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.test.ds.db-name}</rhq.test.ds.connection-url>
+ <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
+ <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
+ <rhq.test.ds.server-name>127.0.0.1</rhq.test.ds.server-name>
+ <rhq.test.ds.port>5432</rhq.test.ds.port>
+ <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>
SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE
</rhq.test.quartz.selectWithLockSQL>
- <rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
+ <rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
+
+ <!--
+ defaults for datasource used by the dev container build (see dev docs on the 'dev' profile) -
+ these may be overridden in ~/.m2/settings.xml
+ -->
+ <rhq.dev.ds.db-name>rhqdev</rhq.dev.ds.db-name>
+ <rhq.dev.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.dev.ds.db-name}</rhq.dev.ds.connection-url>
+ <rhq.dev.ds.driver-class>org.postgresql.Driver</rhq.dev.ds.driver-class>
+ <rhq.dev.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.dev.ds.xa-datasource-class>
+ <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
+ <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
+ <rhq.dev.ds.password.encrypted>1eeb2f255e832171df8592078de921bc</rhq.dev.ds.password.encrypted>
+ <rhq.dev.ds.type-mapping>PostgreSQL</rhq.dev.ds.type-mapping>
+ <rhq.dev.ds.server-name>127.0.0.1</rhq.dev.ds.server-name>
+ <rhq.dev.ds.port>5432</rhq.dev.ds.port>
+ <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.dev.ds.hibernate-dialect>
+ <rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.dev.quartz.driverDelegateClass>
+ <rhq.dev.quartz.selectWithLockSQL>
+ SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE
+ </rhq.dev.quartz.selectWithLockSQL>
+ <rhq.dev.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.dev.quartz.lockHandlerClass>
<!-- default port numbers for RHQ server -->
<rhq.server.http.port>7080</rhq.server.http.port>
diff --git a/release.sh b/release.sh
index 4c7166e..316af14 100755
--- a/release.sh
+++ b/release.sh
@@ -282,16 +282,16 @@ cat <<EOF >"${MAVEN_SETTINGS_FILE}"
<profile>
<id>release</id>
<properties>
- <rhq.ds.server-name>hudson-qe.rhq.rdu.redhat.com</rhq.ds.server-name>
- <rhq.ds.port>5432</rhq.ds.port>
- <rhq.ds.db-name>rhq_release_tag</rhq.ds.db-name>
- <rhq.ds.connection-url>jdbc:postgresql://hudson-qe.rhq.rdu.redhat.com:5432/rhq_release_tag</rhq.ds.connection-url>
- <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
- <rhq.ds.password>rhqadmin</rhq.ds.password>
- <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
- <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
- <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
- <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
+ <rhq.test.ds.server-name>hudson-qe.rhq.rdu.redhat.com</rhq.test.ds.server-name>
+ <rhq.test.ds.port>5432</rhq.test.ds.port>
+ <rhq.test.ds.db-name>rhq_release_tag</rhq.test.ds.db-name>
+ <rhq.test.ds.connection-url>jdbc:postgresql://hudson-qe.rhq.rdu.redhat.com:5432/rhq_release_tag</rhq.test.ds.connection-url>
+ <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
+ <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
+ <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
+ <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
+ <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
+ <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
commit 7d845dfebd066d307411fba2544778f16389cbe9
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 25 15:07:09 2011 -0500
Final touches to get dbreset working for oracle databases.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 536f692..a492187 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -104,6 +104,10 @@
<mainClass>org.rhq.core.db.reset.DBReset</mainClass>
<systemProperties>
<systemProperty>
+ <key>rhq.ds.type-mapping</key>
+ <value>${rhq.ds.type-mapping}</value>
+ </systemProperty>
+ <systemProperty>
<key>rhq.ds.server-name</key>
<value>${rhq.ds.server-name}</value>
</systemProperty>
@@ -502,7 +506,34 @@
</plugins>
</build>
</profile>
- </profiles>
+
+ <profile>
+ <id>ojdbc-driver</id>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc5</artifactId>
+ <version>${ojdbc5.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2</version>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc5</artifactId>
+ <version>${ojdbc5.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
<pluginRepositories>
<pluginRepository>
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index a6970ca..8a32c43 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -104,17 +104,24 @@ public class DBReset {
connection = DbUtil.getConnection(DB_URL, ADMIN_USER, ADMIN_PASSWORD);
connection.setAutoCommit(false);
- String plsql = "declare cursor all_objects_to_drop is"
- + "select * from user_objects where object_type in ('TABLE', 'VIEW', 'FUNCTION', 'SEQUENCE');"
- + "begin"
- + " for obj in all_objects_to_drop loop"
- + " begin"
- + " if obj.object_type = 'TABLE' THEN"
- + " execute immediate('DROP '||obj.object_type||' '||obj.object_name||' CASCADE CONSTRAINTS PURGE');"
- + " else" + " execute immediate('DROP '||obj.object_type||' '||obj.object_name);"
- + " end if;" + " exception when others then null;" + " end;" + " end loop;" + "end;";
+ String plsql = "declare cursor all_objects_to_drop is\n"
+ + "select * from user_objects where object_type in ('TABLE', 'VIEW', 'FUNCTION', 'SEQUENCE');\n"
+ + "begin\n"
+ + " for obj in all_objects_to_drop loop\n"
+ + " begin\n"
+ + " if obj.object_type = 'TABLE' then\n"
+ + " execute immediate('DROP '||obj.object_type||' '||obj.object_name||' CASCADE CONSTRAINTS PURGE');\n"
+ + " else\n"
+ + " execute immediate('DROP '||obj.object_type||' '||obj.object_name);\n"
+ + " end if;\n"
+ + " exception when others then null;\n"
+ + " end;\n"
+ + " end loop;\n"
+ + " end;\n";
+ log.info(plsql);
cleanUserStatement = connection.prepareStatement(plsql);
cleanUserStatement.execute();
+ connection.commit();
log.info("Cleand database " + DB + ".");
} finally {
commit 377619dd2d069cf915310b7dee29cd5426722c9a
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 25 13:22:53 2011 -0500
Pass system properties to DBReset correctly. Also, added missing db-name property to the rest of the profiles.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 7e58645..536f692 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -101,7 +101,37 @@
<goal>java</goal>
</goals>
<configuration>
- <mainClass>org.rhq.core.db.reset.DBReset</mainClass>
+ <mainClass>org.rhq.core.db.reset.DBReset</mainClass>
+ <systemProperties>
+ <systemProperty>
+ <key>rhq.ds.server-name</key>
+ <value>${rhq.ds.server-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.db-name</key>
+ <value>${rhq.ds.db-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.connection-url</key>
+ <value>${rhq.ds.connection-url}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.db.admin.username</key>
+ <value>${rhq.db.admin.username}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.db.admin.password</key>
+ <value>${rhq.db.admin.password}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.user-name</key>
+ <value>${rhq.ds.user-name}</value>
+ </systemProperty>
+ <systemProperty>
+ <key>rhq.ds.password</key>
+ <value>${rhq.ds.password}</value>
+ </systemProperty>
+ </systemProperties>
</configuration>
</execution>
</executions>
@@ -171,6 +201,7 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}"/>
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}"/>
<property name="rhq.ds.password" value="${rhq.ds.password}"/>
@@ -183,6 +214,7 @@
<property name="jtds.version" value="${jtds.version}" />
<property name="task.classpath.property" refid="maven.test.classpath" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
<property name="rhq.ds.password" value="${rhq.ds.password}" />
@@ -207,6 +239,7 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}"/>
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}"/>
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}"/>
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}"/>
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}"/>
<property name="rhq.ds.password" value="${rhq.ds.password}"/>
@@ -219,6 +252,7 @@
<property name="jtds.version" value="${jtds.version}" />
<property name="task.classpath.property" refid="maven.test.classpath" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
<property name="rhq.ds.password" value="${rhq.ds.password}" />
@@ -244,6 +278,7 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
<property name="rhq.ds.password" value="${rhq.ds.password}" />
@@ -256,6 +291,7 @@
<property name="h2.version" value="${h2.version}" />
<property name="jtds.version" value="${jtds.version}" />
<property name="task.classpath.property" refid="maven.test.classpath" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
@@ -296,6 +332,7 @@
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
<property name="rhq.ds.password" value="${rhq.ds.password}" />
@@ -308,6 +345,7 @@
<property name="jtds.version" value="${jtds.version}" />
<property name="task.classpath.property" refid="maven.test.classpath" />
<property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
<property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
<property name="rhq.ds.password" value="${rhq.ds.password}" />
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 9a17f19..a6970ca 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -83,7 +83,7 @@ public class DBReset {
createDB = connection.createStatement();
createDB.execute("create database " + DB + " with owner " + USER);
- log.info("Dropped and created database " + DB +".");
+ log.info("Dropped and created database " + DB + ".");
} finally {
if (dropDB != null) {
dropDB.close();
@@ -94,7 +94,7 @@ public class DBReset {
if (connection != null) {
connection.close();
}
-
+
}
} else if (DB_TYPE_MAPPING.equals("Oracle10g")) {
Connection connection = null;
@@ -111,17 +111,12 @@ public class DBReset {
+ " begin"
+ " if obj.object_type = 'TABLE' THEN"
+ " execute immediate('DROP '||obj.object_type||' '||obj.object_name||' CASCADE CONSTRAINTS PURGE');"
- + " else"
- + " execute immediate('DROP '||obj.object_type||' '||obj.object_name);"
- + " end if;"
- + " exception when others then null;"
- + " end;"
- + " end loop;"
- + "end;";
+ + " else" + " execute immediate('DROP '||obj.object_type||' '||obj.object_name);"
+ + " end if;" + " exception when others then null;" + " end;" + " end loop;" + "end;";
cleanUserStatement = connection.prepareStatement(plsql);
cleanUserStatement.execute();
-
- log.info("Cleand database " + DB +".");
+
+ log.info("Cleand database " + DB + ".");
} finally {
if (cleanUserStatement != null) {
cleanUserStatement.close();
commit 660f9cff3d76ca230075df86241bec53bce84ebd
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Jul 22 21:44:51 2011 -0500
Add dbreset support for Oracle database by executing an anonymous pl/sql script.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 2d85ff0..9a17f19 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -20,6 +20,7 @@
package org.rhq.core.db.reset;
import java.sql.Connection;
+import java.sql.PreparedStatement;
import java.sql.Statement;
import org.apache.commons.logging.Log;
@@ -45,6 +46,8 @@ public class DBReset {
private final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"
+ DB);
+ private final String DB_TYPE_MAPPING = System.getProperty("rhq.ds.type-mapping", "PostgreSQL");
+
/**
* @param args
*/
@@ -66,29 +69,66 @@ public class DBReset {
System.setProperty("dbsetup", "true");
- Connection connection = null;
- Statement dropDB = null;
- Statement createDB = null;
-
- try {
- connection = DbUtil.getConnection(DB_URL.replace(DB, "postgres"), ADMIN_USER, ADMIN_PASSWORD);
-
- dropDB = connection.createStatement();
- dropDB.execute("drop database if exists " + DB);
-
- createDB = connection.createStatement();
- createDB.execute("create database " + DB + " with owner " + USER);
-
- log.info("created database $database");
- } finally {
- if (connection != null) {
- connection.close();
- }
- if (dropDB != null) {
- dropDB.close();
+ if (DB_TYPE_MAPPING.equals("PostgreSQL")) {
+ Connection connection = null;
+ Statement dropDB = null;
+ Statement createDB = null;
+
+ try {
+ connection = DbUtil.getConnection(DB_URL.replace(DB, "postgres"), ADMIN_USER, ADMIN_PASSWORD);
+
+ dropDB = connection.createStatement();
+ dropDB.execute("drop database if exists " + DB);
+
+ createDB = connection.createStatement();
+ createDB.execute("create database " + DB + " with owner " + USER);
+
+ log.info("Dropped and created database " + DB +".");
+ } finally {
+ if (dropDB != null) {
+ dropDB.close();
+ }
+ if (createDB != null) {
+ createDB.close();
+ }
+ if (connection != null) {
+ connection.close();
+ }
+
}
- if (createDB != null) {
- createDB.close();
+ } else if (DB_TYPE_MAPPING.equals("Oracle10g")) {
+ Connection connection = null;
+ PreparedStatement cleanUserStatement = null;
+
+ try {
+ connection = DbUtil.getConnection(DB_URL, ADMIN_USER, ADMIN_PASSWORD);
+ connection.setAutoCommit(false);
+
+ String plsql = "declare cursor all_objects_to_drop is"
+ + "select * from user_objects where object_type in ('TABLE', 'VIEW', 'FUNCTION', 'SEQUENCE');"
+ + "begin"
+ + " for obj in all_objects_to_drop loop"
+ + " begin"
+ + " if obj.object_type = 'TABLE' THEN"
+ + " execute immediate('DROP '||obj.object_type||' '||obj.object_name||' CASCADE CONSTRAINTS PURGE');"
+ + " else"
+ + " execute immediate('DROP '||obj.object_type||' '||obj.object_name);"
+ + " end if;"
+ + " exception when others then null;"
+ + " end;"
+ + " end loop;"
+ + "end;";
+ cleanUserStatement = connection.prepareStatement(plsql);
+ cleanUserStatement.execute();
+
+ log.info("Cleand database " + DB +".");
+ } finally {
+ if (cleanUserStatement != null) {
+ cleanUserStatement.close();
+ }
+ if (connection != null) {
+ connection.close();
+ }
}
}
}
commit 3813104783a672fc5f12b49e4605f99e5e95808e
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Jul 22 10:26:53 2011 -0500
Updating the code to use only one set of datasource settings. (rhq.ds.name-of-setting)
diff --git a/etc/m2/settings-bugfixes.xml b/etc/m2/settings-bugfixes.xml
index b64aac6..01f3173 100644
--- a/etc/m2/settings-bugfixes.xml
+++ b/etc/m2/settings-bugfixes.xml
@@ -28,8 +28,8 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.bugfixes</id>
<properties>
- <rhq.test.ds.db-name>rhqbugfixes</rhq.test.ds.db-name>
- <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqbugfixes</rhq.test.ds.connection-url>
+ <rhq.ds.db-name>rhqbugfixes</rhq.ds.db-name>
+ <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqbugfixes</rhq.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings-content.xml b/etc/m2/settings-content.xml
index 806006b..3009f75 100644
--- a/etc/m2/settings-content.xml
+++ b/etc/m2/settings-content.xml
@@ -33,7 +33,7 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.content</id>
<properties>
- <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqcontent</rhq.test.ds.connection-url>
+ <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqcontent</rhq.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings-linux-config.xml b/etc/m2/settings-linux-config.xml
index dd464f7..6605f33 100644
--- a/etc/m2/settings-linux-config.xml
+++ b/etc/m2/settings-linux-config.xml
@@ -28,7 +28,7 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.linux-config</id>
<properties>
- <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqlconf</rhq.test.ds.connection-url>
+ <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqlconf</rhq.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings-rawconfig.xml b/etc/m2/settings-rawconfig.xml
index f871d66..f64b717 100644
--- a/etc/m2/settings-rawconfig.xml
+++ b/etc/m2/settings-rawconfig.xml
@@ -28,8 +28,8 @@
<!-- Profile to use to point test runs at a different db -->
<id>test.rawconfig</id>
<properties>
- <rhq.test.ds.db-name>rhqrawconfig</rhq.test.ds.db-name>
- <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqrawconfig</rhq.test.ds.connection-url>
+ <rhq.ds.db-name>rhqrawconfig</rhq.ds.db-name>
+ <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqrawconfig</rhq.ds.connection-url>
<DatabaseTest.nofail>true</DatabaseTest.nofail>
<!-- comm and agent config properties -->
diff --git a/etc/m2/settings.xml b/etc/m2/settings.xml
index 8c0dada..89c26f2 100644
--- a/etc/m2/settings.xml
+++ b/etc/m2/settings.xml
@@ -91,31 +91,21 @@
<profile>
<id>postgres</id>
<properties>
- <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhq</rhq.test.ds.connection-url>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
- <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
- <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.server-name>127.0.0.1</rhq.test.ds.server-name>
- <rhq.test.ds.port>5432</rhq.test.ds.port>
- <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
- <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhq</rhq.ds.connection-url>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
+ <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
+ <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.server-name>127.0.0.1</rhq.ds.server-name>
+ <rhq.ds.port>5432</rhq.ds.port>
+ <rhq.ds.db-name>rhq</rhq.ds.db-name>
+ <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
- <rhq.dev.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhq</rhq.dev.ds.connection-url>
- <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
- <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
- <rhq.dev.ds.type-mapping>PostgreSQL</rhq.dev.ds.type-mapping>
- <rhq.dev.ds.driver-class>org.postgresql.Driver</rhq.dev.ds.driver-class>
- <rhq.dev.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.dev.ds.xa-datasource-class>
- <rhq.dev.ds.server-name>127.0.0.1</rhq.dev.ds.server-name>
- <rhq.dev.ds.port>5432</rhq.dev.ds.port>
- <rhq.dev.ds.db-name>rhq</rhq.dev.ds.db-name>
- <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.dev.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.dev.quartz.selectWithLockSQL>
@@ -126,33 +116,22 @@
<profile>
<id>h2</id>
<properties>
- <rhq.test.ds.driver-class>org.h2.Driver</rhq.test.ds.driver-class>
- <rhq.test.ds.connection-url>jdbc:h2:~/rhq;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOG=2</rhq.test.ds.connection-url>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>h2</rhq.test.ds.type-mapping>
- <rhq.test.ds.xa-datasource-class>org.h2.jdbcx.JdbcDataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.server-name>127.0.0.1</rhq.test.ds.server-name>
- <rhq.test.ds.port>9092</rhq.test.ds.port>
- <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
+ <rhq.ds.driver-class>org.h2.Driver</rhq.ds.driver-class>
+ <rhq.ds.connection-url>jdbc:h2:~/rhq;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOG=2</rhq.ds.connection-url>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.type-mapping>h2</rhq.ds.type-mapping>
+ <rhq.ds.xa-datasource-class>org.h2.jdbcx.JdbcDataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.server-name>127.0.0.1</rhq.ds.server-name>
+ <rhq.ds.port>9092</rhq.ds.port>
+ <rhq.ds.db-name>rhq</rhq.ds.db-name>
<!-- This custom dialect is required for proper operation using H2, see class JavaDoc for more info -->
- <rhq.test.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.StdJDBCDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
-
- <rhq.dev.ds.driver-class>org.h2.Driver</rhq.dev.ds.driver-class>
- <rhq.dev.ds.connection-url>jdbc:h2:~/rhq;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOG=2</rhq.dev.ds.connection-url>
- <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
- <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
- <rhq.dev.ds.type-mapping>h2</rhq.dev.ds.type-mapping>
- <rhq.dev.ds.xa-datasource-class>org.h2.jdbcx.JdbcDataSource</rhq.dev.ds.xa-datasource-class>
- <rhq.dev.ds.server-name>127.0.0.1</rhq.dev.ds.server-name>
- <rhq.dev.ds.port>9092</rhq.dev.ds.port>
- <rhq.dev.ds.db-name>rhq</rhq.dev.ds.db-name>
- <!-- This custom dialect is required for proper operation using H2, see class JavaDoc for more info -->
- <rhq.dev.ds.hibernate-dialect>org.rhq.core.server.H2CustomDialect</rhq.dev.ds.hibernate-dialect>
+
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.StdJDBCDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.dev.quartz.selectWithLockSQL>
@@ -163,31 +142,21 @@
<profile>
<id>sqlserver</id>
<properties>
- <rhq.test.ds.driver-class>net.sourceforge.jtds.jdbc.Driver</rhq.test.ds.driver-class>
- <rhq.test.ds.connection-url>jdbc:jtds:sqlserver://localhost:1433;databaseName=rhq</rhq.test.ds.connection-url>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>sqlserver</rhq.test.ds.type-mapping>
- <rhq.test.ds.xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.server-name>localhost</rhq.test.ds.server-name>
- <rhq.test.ds.port>1433</rhq.test.ds.port>
- <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
- <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.SQLServerDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.driver-class>net.sourceforge.jtds.jdbc.Driver</rhq.ds.driver-class>
+ <rhq.ds.connection-url>jdbc:jtds:sqlserver://localhost:1433;databaseName=rhq</rhq.ds.connection-url>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.type-mapping>sqlserver</rhq.ds.type-mapping>
+ <rhq.ds.xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.server-name>localhost</rhq.ds.server-name>
+ <rhq.ds.port>1433</rhq.ds.port>
+ <rhq.ds.db-name>rhq</rhq.ds.db-name>
+ <rhq.ds.hibernate-dialect>org.hibernate.dialect.SQLServerDialect</rhq.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.MSSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>UPDATE {0}LOCKS SET LOCK_NAME = LOCK_NAME WHERE LOCK_NAME = ?</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.UpdateLockRowSemaphore</rhq.test.quartz.lockHandlerClass>
-
- <rhq.dev.ds.driver-class>net.sourceforge.jtds.jdbc.Driver</rhq.dev.ds.driver-class>
- <rhq.dev.ds.connection-url>jdbc:jtds:sqlserver://localhost:1433;databaseName=rhq</rhq.dev.ds.connection-url>
- <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
- <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
- <rhq.dev.ds.type-mapping>sqlserver</rhq.dev.ds.type-mapping>
- <rhq.dev.ds.xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</rhq.dev.ds.xa-datasource-class>
- <rhq.dev.ds.server-name>localhost</rhq.dev.ds.server-name>
- <rhq.dev.ds.port>1433</rhq.dev.ds.port>
- <rhq.dev.ds.db-name>rhq</rhq.dev.ds.db-name>
- <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.SQLServerDialect</rhq.dev.ds.hibernate-dialect>
+
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.MSSQLDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>UPDATE {0}LOCKS SET LOCK_NAME = LOCK_NAME WHERE LOCK_NAME = ?</rhq.dev.quartz.selectWithLockSQL>
@@ -198,31 +167,21 @@
<profile>
<id>oracle</id>
<properties>
- <rhq.test.ds.connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</rhq.test.ds.connection-url>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>Oracle10g</rhq.test.ds.type-mapping>
- <rhq.test.ds.driver-class>oracle.jdbc.driver.OracleDriver</rhq.test.ds.driver-class>
- <rhq.test.ds.xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.server-name></rhq.test.ds.server-name> <!-- can be left blank, oracle does not use this -->
- <rhq.test.ds.port></rhq.test.ds.port> <!-- can be left blank, oracle does not use this -->
- <rhq.test.ds.db-name></rhq.test.ds.db-name> <!-- can be left blank, oracle does not use this -->
- <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.Oracle10gDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</rhq.ds.connection-url>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.type-mapping>Oracle10g</rhq.ds.type-mapping>
+ <rhq.ds.driver-class>oracle.jdbc.driver.OracleDriver</rhq.ds.driver-class>
+ <rhq.ds.xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.server-name></rhq.ds.server-name> <!-- can be left blank, oracle does not use this -->
+ <rhq.ds.port></rhq.ds.port> <!-- can be left blank, oracle does not use this -->
+ <rhq.ds.db-name></rhq.ds.db-name> <!-- can be left blank, oracle does not use this -->
+ <rhq.ds.hibernate-dialect>org.hibernate.dialect.Oracle10gDialect</rhq.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.oracle.OracleDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
<rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
- <rhq.dev.ds.connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</rhq.dev.ds.connection-url>
- <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
- <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
- <rhq.dev.ds.type-mapping>Oracle10g</rhq.dev.ds.type-mapping>
- <rhq.dev.ds.driver-class>oracle.jdbc.driver.OracleDriver</rhq.dev.ds.driver-class>
- <rhq.dev.ds.xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</rhq.dev.ds.xa-datasource-class>
- <rhq.dev.ds.server-name></rhq.dev.ds.server-name> <!-- can be left blank, oracle does not use this -->
- <rhq.dev.ds.port></rhq.dev.ds.port> <!-- can be left blank, oracle does not use this -->
- <rhq.dev.ds.db-name></rhq.dev.ds.db-name> <!-- can be left blank, oracle does not use this -->
- <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.Oracle10gDialect</rhq.dev.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.oracle.OracleDelegate</rhq.dev.quartz.driverDelegateClass>
<rhq.dev.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.dev.quartz.selectWithLockSQL>
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index be3fbe3..7e58645 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -205,23 +205,11 @@
<phase>process-classes</phase>
<configuration>
<tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}"/>
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}"/>
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}"/>
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}"/>
+ <property name="rhq.ds.password" value="${rhq.ds.password}"/>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-combine">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -253,28 +241,13 @@
<id>test-db-schema-version</id>
<phase>test</phase>
<configuration>
- <tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.driver-class" value="${rhq.dev.ds.driver-class}" else="${rhq.test.ds.driver-class}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
+ <tasks>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+ <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="dbsetup-check-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
@@ -321,24 +294,12 @@
<phase>test</phase>
<configuration>
<tasks>
- <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
+ <property name="settings.localRepository" location="${user.home}/.m2/repository}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password" value="${rhq.ds.password}" />
+
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml" target="create-release-schema">
<property name="settings.localRepository" value="${settings.localRepository}" />
<property name="ojdbc5.version" value="${ojdbc5.version}" />
@@ -352,10 +313,10 @@
<property name="rhq.ds.password" value="${rhq.ds.password}" />
<property name="project.version" value="${project.version}" />
<property name="db.schema.version" value="${db.schema.version}" />
- <property name="jon.release" value="${jon.release}" />
- </ant>
- </tasks>
- </configuration>
+ <property name="jon.release" value="${jon.release}" />
+ </ant>
+ </tasks>
+ </configuration>
<goals>
<goal>run</goal>
</goals>
diff --git a/modules/core/domain/pom.xml b/modules/core/domain/pom.xml
index 42d28e1..c8ce307 100644
--- a/modules/core/domain/pom.xml
+++ b/modules/core/domain/pom.xml
@@ -282,7 +282,7 @@
</property>
<property>
<name>hibernate.dialect</name>
- <value>${rhq.test.ds.hibernate-dialect}</value>
+ <value>${rhq.ds.hibernate-dialect}</value>
</property>
</systemProperties>
<excludes>
diff --git a/modules/core/domain/src/test/resources/embedded-jboss-beans.xml b/modules/core/domain/src/test/resources/embedded-jboss-beans.xml
index ae9de01..a51f3e3 100644
--- a/modules/core/domain/src/test/resources/embedded-jboss-beans.xml
+++ b/modules/core/domain/src/test/resources/embedded-jboss-beans.xml
@@ -85,10 +85,10 @@
-->
<bean name="RHQDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
- <property name="driverClass">${rhq.test.ds.driver-class}</property>
- <property name="connectionURL">${rhq.test.ds.connection-url}</property>
- <property name="userName">${rhq.test.ds.user-name}</property>
- <property name="password">${rhq.test.ds.password}</property>
+ <property name="driverClass">${rhq.ds.driver-class}</property>
+ <property name="connectionURL">${rhq.ds.connection-url}</property>
+ <property name="userName">${rhq.ds.user-name}</property>
+ <property name="password">${rhq.ds.password}</property>
<property name="jndiName">java:/RHQDS</property>
<property name="minSize">0</property>
<property name="maxSize">10</property>
diff --git a/modules/enterprise/gui/installer-war/pom.xml b/modules/enterprise/gui/installer-war/pom.xml
index 517399c..f73e403 100644
--- a/modules/enterprise/gui/installer-war/pom.xml
+++ b/modules/enterprise/gui/installer-war/pom.xml
@@ -147,13 +147,13 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
- <rhq.test.ds.server-name>${rhq.test.ds.server-name}</rhq.test.ds.server-name>
- <rhq.test.ds.db-name>${rhq.test.ds.db-name}</rhq.test.ds.db-name>
- <rhq.test.ds.connection-url>${rhq.test.ds.connection-url}</rhq.test.ds.connection-url>
+ <rhq.ds.server-name>${rhq.ds.server-name}</rhq.ds.server-name>
+ <rhq.ds.db-name>${rhq.ds.db-name}</rhq.ds.db-name>
+ <rhq.ds.connection-url>${rhq.ds.connection-url}</rhq.ds.connection-url>
<rhq.db.admin.username>${rhq.db.admin.username}</rhq.db.admin.username>
<rhq.db.admin.password>${rhq.db.admin.password}</rhq.db.admin.password>
- <rhq.test.ds.user-name>${rhq.test.ds.user-name}</rhq.test.ds.user-name>
- <rhq.test.ds.password>${rhq.test.ds.password}</rhq.test.ds.password>
+ <rhq.ds.user-name>${rhq.ds.user-name}</rhq.ds.user-name>
+ <rhq.ds.password>${rhq.ds.password}</rhq.ds.password>
</systemPropertyVariables>
</configuration>
</plugin>
diff --git a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
index 579bebf..0e68830 100644
--- a/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
+++ b/modules/enterprise/gui/installer-war/src/test/java/org/rhq/enterprise/installer/DBInstallatonTest.java
@@ -46,11 +46,11 @@ import java.util.Properties;
public class DBInstallatonTest {
private final String LOG_DIRECTORY = System.getProperty("java.io.tmpdir", "rhq/installer-test");
- private final String TEST_DB = System.getProperty("rhq.test.ds.db-name","rhq_installer_test_db");
- private final String USERNAME = System.getProperty("rhq.test.ds.user-name", "rhqadmin");
- private final String PASSWORD = System.getProperty("rhq.test.ds.password", "rhqadmin");
- private final String SERVER = System.getProperty("rhq.test.ds.server-name", "127.0.0.1");
- private final String DB_URL = System.getProperty("rhq.test.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
+ private final String TEST_DB = System.getProperty("rhq.ds.db-name","rhq_installer_test_db");
+ private final String USERNAME = System.getProperty("rhq.ds.user-name", "rhqadmin");
+ private final String PASSWORD = System.getProperty("rhq.ds.password", "rhqadmin");
+ private final String SERVER = System.getProperty("rhq.ds.server-name", "127.0.0.1");
+ private final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"+TEST_DB);
private final String ADMIN_USERNAME = System.getProperty("rhq.db.admin.username", "postgres");
private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
diff --git a/modules/enterprise/server/container/pom.xml b/modules/enterprise/server/container/pom.xml
index 7329bb5..8e59747 100644
--- a/modules/enterprise/server/container/pom.xml
+++ b/modules/enterprise/server/container/pom.xml
@@ -183,16 +183,16 @@
<property name="quartz.version" value="${quartz.version}" />
<!-- dev DB settings (used to init rhq-server.properties if dev profile is active or developer prop is set) -->
- <property name="rhq.dev.ds.connection-url" value="${rhq.dev.ds.connection-url}" />
- <property name="rhq.dev.ds.driver-class" value="${rhq.dev.ds.driver-class}" />
- <property name="rhq.dev.ds.xa-datasource-class" value="${rhq.dev.ds.xa-datasource-class}" />
- <property name="rhq.dev.ds.user-name" value="${rhq.dev.ds.user-name}" />
- <property name="rhq.dev.ds.password.encrypted" value="${rhq.dev.ds.password.encrypted}" />
- <property name="rhq.dev.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" />
- <property name="rhq.dev.ds.server-name" value="${rhq.dev.ds.server-name}" />
- <property name="rhq.dev.ds.port" value="${rhq.dev.ds.port}" />
- <property name="rhq.dev.ds.db-name" value="${rhq.dev.ds.db-name}" />
- <property name="rhq.dev.ds.hibernate-dialect" value="${rhq.dev.ds.hibernate-dialect}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.ds.driver-class" value="${rhq.ds.driver-class}" />
+ <property name="rhq.ds.xa-datasource-class" value="${rhq.ds.xa-datasource-class}" />
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.ds.password.encrypted" value="${rhq.ds.password.encrypted}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.server-name" value="${rhq.ds.server-name}" />
+ <property name="rhq.ds.port" value="${rhq.ds.port}" />
+ <property name="rhq.ds.db-name" value="${rhq.ds.db-name}" />
+ <property name="rhq.ds.hibernate-dialect" value="${rhq.ds.hibernate-dialect}" />
<property name="rhq.dev.quartz.driverDelegateClass" value="${rhq.dev.quartz.driverDelegateClass}" />
<property name="rhq.dev.quartz.selectWithLockSQL" value="${rhq.dev.quartz.selectWithLockSQL}" />
<property name="rhq.dev.quartz.lockHandlerClass" value="${rhq.dev.quartz.lockHandlerClass}" />
@@ -233,8 +233,7 @@
<property name="rhq.earName" value="${rhq.earName}" />
<!-- dev/test DB type (needed to init rhq-ds.xml) -->
- <property name="rhq.test.ds.type-mapping" value="${rhq.test.ds.type-mapping}" />
- <property name="rhq.dev.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" />
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
<property name="rhq.server.enable.web.services" value="${rhq.server.enable.ws}" />
</ant>
</tasks>
diff --git a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
index 704c50a..c4d83a0 100644
--- a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
@@ -33,16 +33,16 @@
<target name="set-dev-server-props" if="predeploy">
<echo>*** Using dev database settings in rhq-server.properties...</echo>
- <property name="rhq.server.database.hibernate-dialect" value="${rhq.dev.ds.hibernate-dialect}" />
- <property name="rhq.server.database.connection-url" value="${rhq.dev.ds.connection-url}" />
- <property name="rhq.server.database.driver-class" value="${rhq.dev.ds.driver-class}" />
- <property name="rhq.server.database.xa-datasource-class" value="${rhq.dev.ds.xa-datasource-class}" />
- <property name="rhq.server.database.user-name" value="${rhq.dev.ds.user-name}" />
- <property name="rhq.server.database.password" value="${rhq.dev.ds.password.encrypted}" />
- <property name="rhq.server.database.type-mapping" value="${rhq.dev.ds.type-mapping}" />
- <property name="rhq.server.database.server-name" value="${rhq.dev.ds.server-name}" />
- <property name="rhq.server.database.port" value="${rhq.dev.ds.port}" />
- <property name="rhq.server.database.db-name" value="${rhq.dev.ds.db-name}" />
+ <property name="rhq.server.database.hibernate-dialect" value="${rhq.ds.hibernate-dialect}" />
+ <property name="rhq.server.database.connection-url" value="${rhq.ds.connection-url}" />
+ <property name="rhq.server.database.driver-class" value="${rhq.ds.driver-class}" />
+ <property name="rhq.server.database.xa-datasource-class" value="${rhq.ds.xa-datasource-class}" />
+ <property name="rhq.server.database.user-name" value="${rhq.ds.user-name}" />
+ <property name="rhq.server.database.password" value="${rhq.ds.password.encrypted}" />
+ <property name="rhq.server.database.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.server.database.server-name" value="${rhq.ds.server-name}" />
+ <property name="rhq.server.database.port" value="${rhq.ds.port}" />
+ <property name="rhq.server.database.db-name" value="${rhq.ds.db-name}" />
<property name="rhq.server.quartz.driverDelegateClass" value="${rhq.dev.quartz.driverDelegateClass}" />
<property name="rhq.server.quartz.selectWithLockSQL" value="${rhq.dev.quartz.selectWithLockSQL}" />
<property name="rhq.server.quartz.lockHandlerClass" value="${rhq.dev.quartz.lockHandlerClass}" />
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index c5bb3ec..000808c 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -559,7 +559,7 @@ Build-OS-Version=${os.version}
<systemPropertyVariables>
<embeddedDeployment>true</embeddedDeployment>
<deploymentDirectory>target/classes</deploymentDirectory>
- <hibernate.dialect>${rhq.test.ds.hibernate-dialect}</hibernate.dialect>
+ <hibernate.dialect>${rhq.ds.hibernate-dialect}</hibernate.dialect>
<clean.db>${clean.db}</clean.db>
</systemPropertyVariables>
<additionalClasspathElements>
diff --git a/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml b/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml
index 55d697b..05451bd 100644
--- a/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml
+++ b/modules/enterprise/server/jar/src/test/resources/embedded-jboss-beans.xml
@@ -76,10 +76,10 @@
</bean>
<bean name="RHQDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
- <property name="driverClass">${rhq.test.ds.driver-class}</property>
- <property name="connectionURL">${rhq.test.ds.connection-url}</property>
- <property name="userName">${rhq.test.ds.user-name}</property>
- <property name="password">${rhq.test.ds.password}</property>
+ <property name="driverClass">${rhq.ds.driver-class}</property>
+ <property name="connectionURL">${rhq.ds.connection-url}</property>
+ <property name="userName">${rhq.ds.user-name}</property>
+ <property name="password">${rhq.ds.password}</property>
<property name="jndiName">java:/RHQDS</property>
<property name="minSize">0</property>
<property name="maxSize">20</property>
@@ -104,10 +104,10 @@
<!-- needed for Quartz' no-TX data source (even though this is a local-tx, seems like Quartz is still working) -->
<bean name="NoTxRHQDSBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
- <property name="driverClass">${rhq.test.ds.driver-class}</property>
- <property name="connectionURL">${rhq.test.ds.connection-url}</property>
- <property name="userName">${rhq.test.ds.user-name}</property>
- <property name="password">${rhq.test.ds.password}</property>
+ <property name="driverClass">${rhq.ds.driver-class}</property>
+ <property name="connectionURL">${rhq.ds.connection-url}</property>
+ <property name="userName">${rhq.ds.user-name}</property>
+ <property name="password">${rhq.ds.password}</property>
<property name="jndiName">java:/NoTxRHQDS</property>
<property name="minSize">0</property>
<property name="maxSize">10</property>
diff --git a/modules/jopr/release.sh b/modules/jopr/release.sh
index 54f26ab..c05b6ee 100755
--- a/modules/jopr/release.sh
+++ b/modules/jopr/release.sh
@@ -226,16 +226,16 @@ cat <<EOF >${SETTINGS}
<profile>
<id>release</id>
<properties>
- <rhq.test.ds.connection-url>jdbc:postgresql://jon03.qa.atl2.redhat.com:5432/rhq_release</rhq.test.ds.connection-url>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
- <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
- <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.server-name>jon03.qa.atl2.redhat.com</rhq.test.ds.server-name>
- <rhq.test.ds.port>5432</rhq.test.ds.port>
- <rhq.test.ds.db-name>rhq_release</rhq.test.ds.db-name>
- <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.connection-url>jdbc:postgresql://jon03.qa.atl2.redhat.com:5432/rhq_release</rhq.ds.connection-url>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
+ <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
+ <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.server-name>jon03.qa.atl2.redhat.com</rhq.ds.server-name>
+ <rhq.ds.port>5432</rhq.ds.port>
+ <rhq.ds.db-name>rhq_release</rhq.ds.db-name>
+ <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
diff --git a/pom.xml b/pom.xml
index 549e0d0..23afa62 100644
--- a/pom.xml
+++ b/pom.xml
@@ -107,42 +107,22 @@
defaults for datasource used by integration tests -
these may be overridden in ~/.m2/settings.xml
-->
- <rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
- <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.test.ds.db-name}</rhq.test.ds.connection-url>
- <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
- <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
- <rhq.test.ds.server-name>127.0.0.1</rhq.test.ds.server-name>
- <rhq.test.ds.port>5432</rhq.test.ds.port>
- <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.db-name>rhq</rhq.ds.db-name>
+ <rhq.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.ds.db-name}</rhq.ds.connection-url>
+ <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
+ <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.password.encrypted>1eeb2f255e832171df8592078de921bc</rhq.ds.password.encrypted>
+ <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
+ <rhq.ds.server-name>127.0.0.1</rhq.ds.server-name>
+ <rhq.ds.port>5432</rhq.ds.port>
+ <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>
SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE
</rhq.test.quartz.selectWithLockSQL>
- <rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
-
- <!--
- defaults for datasource used by the dev container build (see dev docs on the 'dev' profile) -
- these may be overridden in ~/.m2/settings.xml
- -->
- <rhq.dev.ds.db-name>rhqdev</rhq.dev.ds.db-name>
- <rhq.dev.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.dev.ds.db-name}</rhq.dev.ds.connection-url>
- <rhq.dev.ds.driver-class>org.postgresql.Driver</rhq.dev.ds.driver-class>
- <rhq.dev.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.dev.ds.xa-datasource-class>
- <rhq.dev.ds.user-name>rhqadmin</rhq.dev.ds.user-name>
- <rhq.dev.ds.password>rhqadmin</rhq.dev.ds.password>
- <rhq.dev.ds.password.encrypted>1eeb2f255e832171df8592078de921bc</rhq.dev.ds.password.encrypted>
- <rhq.dev.ds.type-mapping>PostgreSQL</rhq.dev.ds.type-mapping>
- <rhq.dev.ds.server-name>127.0.0.1</rhq.dev.ds.server-name>
- <rhq.dev.ds.port>5432</rhq.dev.ds.port>
- <rhq.dev.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.dev.ds.hibernate-dialect>
- <rhq.dev.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.dev.quartz.driverDelegateClass>
- <rhq.dev.quartz.selectWithLockSQL>
- SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE
- </rhq.dev.quartz.selectWithLockSQL>
- <rhq.dev.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.dev.quartz.lockHandlerClass>
+ <rhq.test.quartz.lockHandlerClass>org.quartz.impl.jdbcjobstore.StdRowLockSemaphore</rhq.test.quartz.lockHandlerClass>
<!-- default port numbers for RHQ server -->
<rhq.server.http.port>7080</rhq.server.http.port>
diff --git a/release.sh b/release.sh
index 316af14..4c7166e 100755
--- a/release.sh
+++ b/release.sh
@@ -282,16 +282,16 @@ cat <<EOF >"${MAVEN_SETTINGS_FILE}"
<profile>
<id>release</id>
<properties>
- <rhq.test.ds.server-name>hudson-qe.rhq.rdu.redhat.com</rhq.test.ds.server-name>
- <rhq.test.ds.port>5432</rhq.test.ds.port>
- <rhq.test.ds.db-name>rhq_release_tag</rhq.test.ds.db-name>
- <rhq.test.ds.connection-url>jdbc:postgresql://hudson-qe.rhq.rdu.redhat.com:5432/rhq_release_tag</rhq.test.ds.connection-url>
- <rhq.test.ds.user-name>rhqadmin</rhq.test.ds.user-name>
- <rhq.test.ds.password>rhqadmin</rhq.test.ds.password>
- <rhq.test.ds.type-mapping>PostgreSQL</rhq.test.ds.type-mapping>
- <rhq.test.ds.driver-class>org.postgresql.Driver</rhq.test.ds.driver-class>
- <rhq.test.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.test.ds.xa-datasource-class>
- <rhq.test.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.test.ds.hibernate-dialect>
+ <rhq.ds.server-name>hudson-qe.rhq.rdu.redhat.com</rhq.ds.server-name>
+ <rhq.ds.port>5432</rhq.ds.port>
+ <rhq.ds.db-name>rhq_release_tag</rhq.ds.db-name>
+ <rhq.ds.connection-url>jdbc:postgresql://hudson-qe.rhq.rdu.redhat.com:5432/rhq_release_tag</rhq.ds.connection-url>
+ <rhq.ds.user-name>rhqadmin</rhq.ds.user-name>
+ <rhq.ds.password>rhqadmin</rhq.ds.password>
+ <rhq.ds.type-mapping>PostgreSQL</rhq.ds.type-mapping>
+ <rhq.ds.driver-class>org.postgresql.Driver</rhq.ds.driver-class>
+ <rhq.ds.xa-datasource-class>org.postgresql.xa.PGXADataSource</rhq.ds.xa-datasource-class>
+ <rhq.ds.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</rhq.ds.hibernate-dialect>
<!-- quartz properties -->
<rhq.test.quartz.driverDelegateClass>org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</rhq.test.quartz.driverDelegateClass>
<rhq.test.quartz.selectWithLockSQL>SELECT * FROM {0}LOCKS ROWLOCK WHERE LOCK_NAME = ? FOR UPDATE</rhq.test.quartz.selectWithLockSQL>
commit 550d8fea05f98554643f1ba1c91ae56630ef9d20
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 21 13:31:40 2011 -0500
Moving dbreset from inline groovy script to a java file.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index e2a599d..be3fbe3 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -34,6 +34,13 @@
<artifactId>ant</artifactId>
<version>1.6.5</version>
</dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+
<dependency>
<groupId>ant</groupId>
@@ -50,9 +57,7 @@
<dependency>
<groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
- <scope>test</scope>
+ <artifactId>postgresql</artifactId>
</dependency>
<dependency>
@@ -74,65 +79,29 @@
<build>
<plugins>
<plugin>
- <groupId>org.codehaus.groovy.maven</groupId>
- <artifactId>gmaven-plugin</artifactId>
- <version>1.0</version>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2</version>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
</dependencies>
<executions>
<execution>
- <phase>compile</phase>
+ <phase>process-classes</phase>
<goals>
- <goal>execute</goal>
+ <goal>java</goal>
</goals>
<configuration>
- <source>
- import org.postgresql.Driver
- import groovy.sql.Sql
-
- if (!project.properties.dbreset) {
- return
- }
-
- db = project.properties.db
- if (db == 'dev') {
- database = project.properties['rhq.dev.ds.db-name']
- server = project.properties['rhq.dev.ds.server-name'] ?: '127.0.0.1'
- rhqUser = project.properties['rhq.dev.ds.user-name'] ?: 'rhqadmin'
- }
- else {
- database = project.properties['rhq.test.ds.db-name']
- server = project.properties['rhq.test.ds.server-name'] ?: '127.0.0.1'
- rhqUser = project.properties['rhq.test.ds.user-name'] ?: 'rhqadmin'
- }
-
- // The upgrade.db property should be set for local builds when you
- // need to test upgrade changes. Hudson builds will specify the
- // database to use in settings.xml
- if (project.properties['upgrade.db']) {
- database = 'rhqupgrade'
- }
-
- adminUsername = project.properties['rhq.db.admin.username'] ?: 'postgres'
- adminPassword = project.properties['rhq.db.admin.password'] ?: 'postgres'
- project.properties.dbsetup = 'true'
-
- sql = Sql.newInstance(
- "jdbc:postgresql://${server}:5432/postgres",
- adminUsername,
- adminPassword,
- "org.postgresql.Driver")
-
- sql.execute("drop database if exists ${Sql.expand(database)};")
- log.info("dropped database $database")
- sql.execute("create database ${Sql.expand(database)} with owner ${Sql.expand(rhqUser)};")
- log.info("created database $database")
- </source>
+ <mainClass>org.rhq.core.db.reset.DBReset</mainClass>
</configuration>
</execution>
</executions>
@@ -201,22 +170,10 @@
<configuration>
<tasks>
<property name="settings.localRepository" location="${user.home}/.m2/repository}" />
-
- <condition property="rhq.ds.type-mapping" value="${rhq.dev.ds.type-mapping}" else="${rhq.test.ds.type-mapping}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.connection-url" value="${rhq.dev.ds.connection-url}" else="${rhq.test.ds.connection-url}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.user-name" value="${rhq.dev.ds.user-name}" else="${rhq.test.ds.user-name}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
-
- <condition property="rhq.ds.password" value="${rhq.dev.ds.password}" else="${rhq.test.ds.password}">
- <equals arg1="${db}" arg2="dev" />
- </condition>
+ <property name="rhq.ds.type-mapping" value="${rhq.ds.type-mapping}" />
+ <property name="rhq.ds.connection-url" value="${rhq.ds.connection-url}"/>
+ <property name="rhq.ds.user-name" value="${rhq.ds.user-name}"/>
+ <property name="rhq.ds.password" value="${rhq.ds.password}"/>
<ant antfile="${basedir}/src/main/scripts/dbsetup-build.xml">
<property name="settings.localRepository" value="${settings.localRepository}" />
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
new file mode 100644
index 0000000..2d85ff0
--- /dev/null
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -0,0 +1,95 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.core.db.reset;
+
+import java.sql.Connection;
+import java.sql.Statement;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.db.DbUtil;
+
+//import groovy.sql.Sql;
+
+/**
+ * @author Stefan Negrea
+ *
+ */
+public class DBReset {
+ private static Log log = LogFactory.getLog(DBReset.class);
+
+ private final String DB = System.getProperty("rhq.ds.db-name", "rhq_installer_test_db");
+ private final String SERVER = System.getProperty("rhq.ds.server-name", "127.0.0.1");
+ private final String USER = System.getProperty("rhq.ds.user-name", "rhqadmin");
+ private final String ADMIN_USER = System.getProperty("rhq.db.admin.username", "postgres");
+ private final String ADMIN_PASSWORD = System.getProperty("rhq.db.admin.password", "postgres");
+ private final String DB_RESET = System.getProperty("dbreset", "false");
+ private final String DB_URL = System.getProperty("rhq.ds.connection-url", "jdbc:postgresql://" + SERVER + ":5432/"
+ + DB);
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ DBReset dbreset = new DBReset();
+
+ try {
+ dbreset.performDBReset();
+ } catch (Exception e) {
+ log.info(e);
+ System.exit(1);
+ }
+ }
+
+ private void performDBReset() throws Exception {
+ if (DB_RESET.equals("false")) {
+ return;
+ }
+
+ System.setProperty("dbsetup", "true");
+
+ Connection connection = null;
+ Statement dropDB = null;
+ Statement createDB = null;
+
+ try {
+ connection = DbUtil.getConnection(DB_URL.replace(DB, "postgres"), ADMIN_USER, ADMIN_PASSWORD);
+
+ dropDB = connection.createStatement();
+ dropDB.execute("drop database if exists " + DB);
+
+ createDB = connection.createStatement();
+ createDB.execute("create database " + DB + " with owner " + USER);
+
+ log.info("created database $database");
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
+ if (dropDB != null) {
+ dropDB.close();
+ }
+ if (createDB != null) {
+ createDB.close();
+ }
+ }
+ }
+}
commit b35ba5b025f995e7658bd1f56a8e002f5b05e84b
Merge: 47451f9 f1b3ecd
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Jul 28 15:48:01 2011 +0200
Merge branch 'as7plugin' of ssh://git.fedorahosted.org/git/rhq/rhq into as7plugin
commit 47451f90a8383fe368a398e45e5e4d75d0efd256
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Jul 28 15:44:35 2011 +0200
BZ 726378 - management port settings on AS7 were not honored.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 322e453..9aa9db0 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -111,12 +111,15 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
this.context = context;
pluginConfiguration = context.getPluginConfiguration();
- String typeName = context.getResourceType().getName();
- // TODO can we use parent's connection and only set this up for top level base component?
- host = pluginConfiguration.getSimpleValue("hostname", LOCALHOST);
- String portString = pluginConfiguration.getSimpleValue("port", DEFAULT_HTTP_MANAGEMENT_PORT);
- port = Integer.parseInt(portString);
- connection = new ASConnection(host,port);
+ if (!(context.getParentResourceComponent() instanceof BaseComponent)) {
+ host = pluginConfiguration.getSimpleValue("hostname", LOCALHOST);
+ String portString = pluginConfiguration.getSimpleValue("port", DEFAULT_HTTP_MANAGEMENT_PORT);
+ port = Integer.parseInt(portString);
+ connection = new ASConnection(host,port);
+ }
+ else {
+ connection = ((BaseComponent)context.getParentResourceComponent()).getASConnection();
+ }
path = pluginConfiguration.getSimpleValue("path", null);
key = context.getResourceKey();
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
index 475fd62..471fd42 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
@@ -79,11 +79,8 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
String psName = psr.getProcessScan().getName();
String description = discoveryContext.getResourceType().getDescription();
String version = null;
- String startScript;
- if (psName.equals("ProcessController")) {
- serverNameFull = "ProcessController";
- serverName = "ProcessController";
- } else if (psName.equals("HostController")) {
+
+ if (psName.equals("HostController")) {
readStandaloneOrHostXml(psr.getProcessInfo(), true);
HostPort hp = getDomainControllerFromHostXml();
if (hp.isLocal) {
@@ -118,11 +115,10 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
tmp = tmp.substring( i + 8);
tmp = tmp.substring(0,tmp.indexOf("/"));
serverNameFull = tmp;
-
- String host = findHost(psr.getProcessInfo(),true);
- config.put(new PropertySimple("domainHost",host));
-
}
+ String host = findHost(psr.getProcessInfo(),true);
+ config.put(new PropertySimple("domainHost",host));
+
config.put(new PropertySimple("baseDir",serverNameFull));
serverName = findHostName();
if (serverName.isEmpty())
@@ -139,6 +135,11 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
}
String logFile = getLogFileFromCommandLine(commandLine);
initLogEventSourcesConfigProp(logFile,config);
+
+ HostPort managmentPort = getManagementPortFromHostXml();
+ config.put(new PropertySimple("hostname",managmentPort.host));
+ config.put(new PropertySimple("port",managmentPort.port));
+
// String javaClazz = psr.getProcessInfo().getName();
commit b160369e4999f327871e961fb75fe74f470d6914
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Jul 28 13:17:00 2011 +0200
Initial support for messaging (JMS)
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 776e5ef..322e453 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -23,6 +23,8 @@ import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
@@ -480,12 +482,34 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
} else if (what.equals("destination")) {
address.addAll(pathToAddress(getPath()));
String newName = parameters.getSimpleValue("name","");
-// String type = parameters.getSimpleValue("type","Queue").toLowerCase();
-// address.add(new PROPERTY_VALUE(type,newName));
- String queueName = parameters.getSimpleValue("queue-address","");
- Map<String,Object> props = new HashMap<String, Object>();
- props.put("queue-address",queueName);
+ String type = parameters.getSimpleValue("type","jms-queue").toLowerCase();
+ address.add(new PROPERTY_VALUE(type,newName));
+ PropertyList jndiNamesProp = parameters.getList("entries");
+ if (jndiNamesProp==null || jndiNamesProp.getList().isEmpty()) {
+ OperationResult fail = new OperationResult();
+ fail.setErrorMessage("No jndi bindings given");
+ return fail;
+ }
+ List<String> jndiNames = new ArrayList<String>();
+ for (Property p : jndiNamesProp.getList()) {
+ PropertySimple ps = (PropertySimple) p;
+ jndiNames.add(ps.getStringValue());
+ }
+
operation = new Operation(op,address);
+ operation.addAdditionalProperty("entries",jndiNames);
+ if (type.equals("jms-queue")) {
+ PropertySimple ps = (PropertySimple) parameters.get("durable");
+ if (ps!=null) {
+ boolean durable = ps.getBooleanValue();
+ operation.addAdditionalProperty("durable",durable);
+ }
+ String selector = parameters.getSimpleValue("selector","");
+ if (!selector.isEmpty())
+ operation.addAdditionalProperty("selector",selector);
+ }
+
+
} else if (what.equals("managed-server")) {
String chost = parameters.getSimpleValue("hostname","");
String serverName = parameters.getSimpleValue("servername","");
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 6a8698e..20395e0 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -444,7 +444,7 @@
<server name="Messaging"
discovery="SubsystemDiscovery"
class="BaseComponent"
- description="The underlying HornetQ based messaging subsystem"
+ description="The HornetQ based messaging subsystem"
singleton="true"
>
<runs-inside>
@@ -459,15 +459,16 @@
<operation name="destination:add" displayName="Add destination" description="Add a Queue or Topic">
<parameters>
<c:simple-property name="name" description="Name of the Destination" required="true"/>
- <c:simple-property name="queue-address" description="The queue address defines what address is used for routing messages." required="true"/>
+ <c:list-property name="entries" description="The JNDI names the destination should be bound to." required="true">
+ <c:simple-property name="entry" description="A single JNDI name. Note, this is relative to java:jboss/jms/"/>
+ </c:list-property>
<c:simple-property name="type" description="Type of Destination to create" default="Queue">
<c:property-options>
- <c:option value="Queue"/>
- <c:option value="Topic"/>
+ <c:option value="jms-queue" name="Queue"/>
+ <c:option value="jms-topic" name="Topic"/>
</c:property-options>
</c:simple-property>
- <c:simple-property name="filter" description="The queue message filter definition."/>
- <c:simple-property name="durable" description="Defines whether the queue is durable." type="boolean" default="false"/>
+ <c:simple-property name="durable" description="Defines whether the queue is durable (for Queues only)." type="boolean" default="false"/>
</parameters>
<results>
<c:simple-property name="operationResult"/>
@@ -487,73 +488,23 @@
<c:simple-property name="journal-type" />
</resource-configuration>
- <!-- this is no child resource TODO
-
- <service name="Acceptor"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- >
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="acceptor"/>
- </plugin-configuration>
- </service>
- <service name="MessagingConnector"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- >
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="connector"/>
- </plugin-configuration>
- </service>
- <service name="HQueue"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- >
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="queue"/>
- </plugin-configuration>
- <resource-configuration>
- <c:simple-property name="queue-address" required="true"/>
- <c:simple-property name="filter" />
- <c:simple-property name="durable" type="boolean"/>
- </resource-configuration>
-
- </service>
--->
- </server>
-
- <server name="JMS"
- discovery="SubsystemDiscovery"
- class="JmsComponent"
- description="The JMS messaging subsystem"
- singleton="true"
- >
- <runs-inside>
- <parent-resource-type name="Profile" plugin="jboss-as-7"/>
- <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
- </runs-inside>
-
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="subsystem=jms"/>
- </plugin-configuration>
-
- <service name="Queue"
+ <service name="JMS Queue"
discovery="SubsystemDiscovery"
class="JmsComponent"
- createDeletePolicy="both"
+ createDeletePolicy="delete-only"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="queue"/>
+ <c:simple-property name="path" readOnly="true" default="jms-queue"/>
</plugin-configuration>
<resource-configuration> <!-- See BZ 705713 TODO -->
- <c:simple-property name="durable" required="false" type="boolean" readOnly="false" default="false"
+ <c:simple-property name="durable" required="false" type="boolean" readOnly="true" default="false"
description="Whether the queue is durable or not."/>
- <c:list-property name="entries" required="false" readOnly="false"
+ <c:list-property name="entries" required="false" readOnly="true"
description="The jndi names the queue will be bound to.">
<c:simple-property name="entries" type="string"/>
</c:list-property>
- <c:simple-property name="selector" required="false" type="string" readOnly="false" description="The queue selector."/>
+ <c:simple-property name="selector" required="false" type="string" readOnly="true" description="The queue selector."/>
<c:template name="add" description="Properties when adding a new queue" >
<c:simple-property name="durable" required="false" type="boolean" default="false"
description="Whether the queue is durable or not."/>
@@ -565,16 +516,16 @@
</c:template>
</resource-configuration>
</service>
- <service name="Topic"
+ <service name="JMS Topic"
discovery="SubsystemDiscovery"
class="JmsComponent"
- createDeletePolicy="both"
+ createDeletePolicy="delete-only"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="topic"/>
+ <c:simple-property name="path" readOnly="true" default="jms-topic"/>
</plugin-configuration>
<resource-configuration> <!-- See BZ 705713 TODO -->
- <c:list-property name="entries" required="false" readOnly="false"
+ <c:list-property name="entries" required="false" readOnly="true"
description="The jndi names the queue will be bound to.">
<c:simple-property name="entries" type="string"/>
</c:list-property>
commit d3f942a14e0497b7bcbd6561c495f391513cdb29
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jul 26 22:29:16 2011 +0200
Add more properties for JBossWeb. Unfortunately they are read-only in AS7
Follow :read-resource output, as the resource description from AS7 is not up to date.
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index d9f79d1..6a8698e 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -614,6 +614,78 @@
<c:simple-property name="path" readOnly="true" default="subsystem=web"/>
</plugin-configuration>
+ <resource-configuration>
+ <c:simple-property name="default-virtual-server" required="false" type="string" readOnly="true" defaultValue="localhost"
+ description="The web container's default virtual server."/>
+ <c:simple-property name="native" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Add the native initialization listener to the web container."/>
+ <c:map-property name="configuration" description="The common web container configuration." >
+ <c:map-property name="static-resources" description="Configuration for static resources" >
+ <c:simple-property name="listings" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable folder listings."/>
+ <c:simple-property name="sendfile" required="false" type="integer" readOnly="true" defaultValue="49152"
+ description="Enable sendfile if possible, for files bigger than the specified byte size."/>
+ <c:simple-property name="read-only" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Allow write HTTP methods (PUT, DELETE)."/>
+ <c:simple-property name="webdav" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable WebDAV functionality."/>
+ <c:simple-property name="secret" required="false" type="string" readOnly="true" description="Secret for WebDAV locking operations."/>
+ <c:simple-property name="max-depth" required="false" type="integer" readOnly="true" defaultValue="3"
+ description="Maximum recursion for PROPFIND."/>
+ <c:simple-property name="disabled" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable the JSP container."/>
+ </c:map-property>
+ <c:map-property name="jsp-configuration" description="JSP container configuration">
+ <c:simple-property name="development" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable the development mode, which gives more information when an error occurs."/>
+ <c:simple-property name="file-encoding" required="false" type="string" readOnly="true" description="Force a file encoding."/>
+ <c:simple-property name="keep-generated" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Keep the generated Servlets."/>
+ <c:simple-property name="trim-spaces" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Trim some spaces from the generated Servlet."/>
+ <c:simple-property name="tag-pooling" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Enable tag pooling."/>
+ <c:simple-property name="mapped-file" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Map to the JSP source."/>
+ <c:simple-property name="check-interval" required="false" type="integer" readOnly="true" defaultValue="0"
+ description="Check interval for JSP updates using a background thread."/>
+ <c:simple-property name="modification-test-interval" required="false" type="integer" readOnly="true" defaultValue="4"
+ description="Minimum amount of time between two tests for updates, in seconds."/>
+ <c:simple-property name="recompile-on-fail" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Retry failed JSP compilations on each request."/>
+ <c:simple-property name="smap" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable SMAP."/>
+ <c:simple-property name="dump-smap" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Write SMAP data to a file."/>
+ <c:simple-property name="generate-strings-as-char-arrays" required="false" type="boolean" readOnly="true"
+ defaultValue="false"
+ description="Generate String constants as char arrays."/>
+ <c:simple-property name="error-on-use-bean-invalid-class-attribute" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable errors when using a bad class in useBean."/>
+ <c:simple-property name="scratch-dir" required="false" type="string" readOnly="true" description="Specify a different work directory."/>
+ <c:simple-property name="source-vm" required="false" type="string" readOnly="true" defaultValue="1.5"
+ description="Source VM level for compilation."/>
+ <c:simple-property name="target-vm" required="false" type="string" readOnly="true" defaultValue="1.5"
+ description="Target VM level for compilation."/>
+ <c:simple-property name="java-encoding" required="false" type="string" readOnly="true" defaultValue="UTF-8"
+ description="Specify the encoding used for Java sources."/>
+ <c:simple-property name="x-powered-by" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Enable advertising the JSP engine in x-powered-by."/>
+ <c:simple-property name="display-source-fragment" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="When a runtime error occurs, attempts to display corresponding JSP source fragment."/>
+ </c:map-property>
+ <c:list-property name="mime-mapping" description="A mime-mapping definition." >
+ <c:map-property name="mime-mapping" >
+ <c:simple-property name="name" description="A MIME mapping name"/>
+ <c:simple-property name="value" description="A MIME mapping value"/>
+ </c:map-property>
+ </c:list-property>
+ <c:list-property name="welcome-file" description="A welcome file declaration." >
+ <c:simple-property name="welcome-file" />
+ </c:list-property>
+ </c:map-property>
+ </resource-configuration>
+
<service name="Connector"
discovery="SubsystemDiscovery"
class="BaseComponent"
commit 8cf10dd720219a5b1a03e825eae5ca2ccd978a5f
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jul 27 09:18:58 2011 +0200
Get rid of the explicit version number and let maven do the magic.
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 0927693..d9f79d1 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -48,7 +48,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin"
xmlns:c="urn:xmlns:rhq-configuration"
- version="4.0.0-SNAPSHOT"
>
<!-- <depends plugin="JMX" useClasses="true"/> -->
commit 9b8876e0032bf4c94568bd784ac44b38198f4731
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jul 27 11:18:39 2011 +0200
Log the property being null and don't pollute stdout.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java
index e978962..c999be6 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java
@@ -269,8 +269,10 @@ public class ConfigurationLoadDelegate implements ConfigurationFacet {
if (property!=null)
propertyMap.put(property);
- else
- System.out.println("Property " + key + " was null");
+ else {
+ if (log.isDebugEnabled())
+ log.debug("Property " + key + " was null");
+ }
}
commit 8de2372999f6778ac2c41d7f4d80fcea239e4e2d
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jul 25 18:00:50 2011 +0200
Provide more connection properties for standalone servers as well as the version. Add start and restart operations for standalone servers.
Read the running instance name (i.e. standalone server name) from standalone.xml
Allow to start a domain/host controller.
Allow to shut down hosts in a domain.
Allow to shut down host controllers. Revert the ability to shutdown hosts - this needs to be done at HC level.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
index 63a4e45..c089b79 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
@@ -46,9 +46,15 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
protected Document hostXml;
protected final Log log = LogFactory.getLog(this.getClass());
-// private final Log log = LogFactory.getLog(AbstractBaseDiscovery.class);
- protected void readHostXml(ProcessInfo processInfo,boolean isDomainMode) {
+ /**
+ * Read the host.xml or standalone.xml file depending on isDomainMode. If isDomainMode is true,
+ * host.xml is read, otherwise standalone.xml.
+ * The xml file content is stored in the variable hostXml for future use.
+ * @param processInfo Process info to determine the base file location
+ * @param isDomainMode Indiates if host.xml should be read (true) or standalone.xml (false)
+ */
+ protected void readStandaloneOrHostXml(ProcessInfo processInfo, boolean isDomainMode) {
String hostXmlFile = getHostXmlFileLocation(processInfo,isDomainMode);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
@@ -61,7 +67,11 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
}
}
-
+ /**
+ * Determine the server home (=base) directory by parsing the passed command line
+ * @param commandLine command line arguments of the process
+ * @return The home dir if found or empty string otherwise
+ */
String getHomeDirFromCommandLine(String[] commandLine) {
for (String line: commandLine) {
if (line.startsWith(DJBOSS_SERVER_HOME_DIR))
@@ -70,6 +80,11 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
return "";
}
+ /**
+ * Determine the location of the boot log file of the server by parsing the command line
+ * @param commandLine command line arguments of the process
+ * @return The log file location or empty string otherwise
+ */
String getLogFileFromCommandLine(String[] commandLine) {
for (String line: commandLine) {
@@ -79,7 +94,14 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
return "";
}
+ /**
+ * Try to obtain the management IP and port from the already parsed host.xml or standalone.xml
+ * @return an Object containing host and port
+ * @see #readStandaloneOrHostXml(org.rhq.core.system.ProcessInfo, boolean) on how to obtain the parsed xml
+ */
protected HostPort getManagementPortFromHostXml() {
+ if (hostXml==null)
+ throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first.");
Element host = hostXml.getDocumentElement();
NodeList interfaceParent = host.getElementsByTagName("management-interfaces");
if (interfaceParent ==null || interfaceParent.getLength()==0) {
@@ -112,7 +134,15 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
return new HostPort();
}
+ /**
+ * Try to obtain the management interface IP from the host/standalone.xml files
+ * @param nIf Interface to look for
+ * @return IP address to use
+ */
private String getInterface(String nIf) {
+ if (hostXml==null)
+ throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first.");
+
Element host = hostXml.getDocumentElement();
NodeList interfaceParent = host.getElementsByTagName("interfaces");
if (interfaceParent ==null || interfaceParent.getLength()==0) {
@@ -155,12 +185,26 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
return null; // TODO: Customise this generated block
}
+ /**
+ * Try to determine the host name - that is the name of a standalone server or a
+ * host in domain mode by looking at the standalone/host.xml files
+ * @return server name
+ */
protected String findHostName() {
+ if (hostXml==null)
+ throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first.");
+
String hostName = hostXml.getDocumentElement().getAttribute("name");
return hostName;
}
+ /**
+ * Try to obtain the domain controller's location from looking at host.xml
+ * @return host and port of the domain controller
+ */
protected HostPort getDomainControllerFromHostXml() {
+ if (hostXml==null)
+ throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first.");
Element host = hostXml.getDocumentElement();
NodeList dcParent = host.getElementsByTagName("domain-controller");
@@ -211,6 +255,9 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
}
+ /**
+ * Helper class that holds information about the host,port tuple
+ */
protected static class HostPort {
String host;
int port;
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 8851706..776e5ef 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -79,7 +79,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
final Log log = LogFactory.getLog(this.getClass());
ResourceContext context;
- Configuration conf;
+ Configuration pluginConfiguration;
String myServerName;
ASConnection connection;
String path;
@@ -107,16 +107,16 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
*/
public void start(ResourceContext context) throws InvalidPluginConfigurationException, Exception {
this.context = context;
- conf = context.getPluginConfiguration();
+ pluginConfiguration = context.getPluginConfiguration();
String typeName = context.getResourceType().getName();
// TODO can we use parent's connection and only set this up for top level base component?
- host = conf.getSimpleValue("hostname", LOCALHOST);
- String portString = conf.getSimpleValue("port", DEFAULT_HTTP_MANAGEMENT_PORT);
+ host = pluginConfiguration.getSimpleValue("hostname", LOCALHOST);
+ String portString = pluginConfiguration.getSimpleValue("port", DEFAULT_HTTP_MANAGEMENT_PORT);
port = Integer.parseInt(portString);
connection = new ASConnection(host,port);
- path = conf.getSimpleValue("path", null);
+ path = pluginConfiguration.getSimpleValue("path", null);
key = context.getResourceKey();
myServerName = context.getResourceKey().substring(context.getResourceKey().lastIndexOf("/")+1);
@@ -445,16 +445,15 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>();
if (what.equals("server-group")) {
- String groupName = parameters.getSimpleValue("name",null);
+ String groupName = parameters.getSimpleValue("name","");
String profile = parameters.getSimpleValue("profile","default");
address.add(new PROPERTY_VALUE("server-group",groupName));
operation = new Operation(op,address,"profile",profile);
} else if (what.equals("server")) {
-
if (context.getResourceType().getName().equals("JBossAS-Managed")) {
- String host = conf.getSimpleValue("domainHost","local");
+ String host = pluginConfiguration.getSimpleValue("domainHost","local");
address.add(new PROPERTY_VALUE("host",host));
address.add(new PROPERTY_VALUE("server-config",myServerName));
operation = new Operation(op,address);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
index 2f71edb..475fd62 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
@@ -18,8 +18,11 @@
*/
package org.rhq.modules.plugins.jbossas7;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.List;
@@ -30,7 +33,6 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.mc4j.ems.connection.support.metadata.LocalVMTypeDescriptor;
import org.w3c.dom.Document;
import org.rhq.core.domain.configuration.Configuration;
@@ -43,8 +45,6 @@ import org.rhq.core.pluginapi.inventory.ProcessScanResult;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.core.system.ProcessInfo;
-import org.rhq.plugins.jmx.JMXDiscoveryComponent;
-
/**
* Discovery class
@@ -53,9 +53,10 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
{
- static final String DJBOSS_SERVER_BASE_DIR = "-Djboss.server.base.dir=";
+ static final String DJBOSS_HOME_DIR = "-Djboss.home.dir=";
static final String DORG_JBOSS_BOOT_LOG_FILE = "-Dorg.jboss.boot.log.file=";
static final String DLOGGING_CONFIGURATION = "-Dlogging.configuration=";
+ static final String DASH_DASH_SERVER_CONFIG = "--server-config=";
private final Log log = LogFactory.getLog(this.getClass());
/**
@@ -77,11 +78,13 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
String serverName;
String psName = psr.getProcessScan().getName();
String description = discoveryContext.getResourceType().getDescription();
+ String version = null;
+ String startScript;
if (psName.equals("ProcessController")) {
serverNameFull = "ProcessController";
serverName = "ProcessController";
} else if (psName.equals("HostController")) {
- readHostXml(psr.getProcessInfo(),true);
+ readStandaloneOrHostXml(psr.getProcessInfo(), true);
HostPort hp = getDomainControllerFromHostXml();
if (hp.isLocal) {
serverName = "DomainController";
@@ -92,11 +95,20 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
serverName = "HostController";
serverNameFull = "HostController";
}
- config.put(new PropertySimple("homedir",getHomeDirFromCommandLine(psr.getProcessInfo().getCommandLine())));
- // TODO add the start script
+ String homeDir = getHomeDirFromCommandLine(psr.getProcessInfo().getCommandLine());
+ config.put(new PropertySimple("baseDir", homeDir));
+ version = homeDir.substring(homeDir.lastIndexOf("-")+1);
+ config.put(new PropertySimple("startScript","bin/domain.sh"));
+ String host = findHost(psr.getProcessInfo(),true);
+ config.put(new PropertySimple("domainHost",host));
+
+ fillUserPassFromFile(config,"domain",homeDir);
+
+ // TODO provide running config
- } else {
- serverNameFull = getBaseDirFromCommandLine(commandLine);
+ } else { // Standalone server
+ serverNameFull = getHomeDirFromCommandLine(commandLine);
+ readStandaloneOrHostXml(psr.getProcessInfo(), false);
if (serverNameFull==null || serverNameFull.isEmpty()) {
// Try to obtain the server name
// -Dorg.jboss.boot.log.file=domain/servers/server-one/log/boot.log
@@ -111,10 +123,19 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
config.put(new PropertySimple("domainHost",host));
}
- serverName = serverNameFull.substring(serverNameFull.lastIndexOf("/")+1);
+ config.put(new PropertySimple("baseDir",serverNameFull));
+ serverName = findHostName();
if (serverName.isEmpty())
serverName = serverNameFull;
+ version = serverName.substring(serverName.lastIndexOf("-")+1);
+
+ String serverConfig = getServerConfigFromCommandLine(commandLine);
+ config.put(new PropertySimple("config",serverConfig));
+ config.put(new PropertySimple("startScript","bin/standalone.sh"));
+
+ fillUserPassFromFile(config,"standalone", serverNameFull);
+
}
String logFile = getLogFileFromCommandLine(commandLine);
initLogEventSourcesConfigProp(logFile,config);
@@ -139,7 +160,7 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
discoveryContext.getResourceType(), // ResourceType
serverNameFull, // key TODO distinguish per domain?
serverName, // Name
- null, // TODO real version ?
+ version, // TODO get via API ?Á
description, // Description
config,
psr.getProcessInfo()
@@ -155,6 +176,48 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
}
+ private void fillUserPassFromFile(Configuration config, String mode, String baseDir) {
+
+ String configDir = baseDir + File.separator + mode + File.separator + "configuration";
+
+ File file = new File(configDir ,"mgmt-users.properties");
+ if (!file.exists() || !file.canRead()) {
+ if (log.isDebugEnabled())
+ log.debug("No console user properties file found at [" + file.getAbsolutePath() + "] or file is not readable");
+ return;
+ }
+ BufferedReader br=null;
+ try {
+ FileReader fileReader = new FileReader(file);
+ br = new BufferedReader(fileReader);
+ String line;
+ while ((line = br.readLine())!=null) {
+ if (line.startsWith("#"))
+ continue;
+ if (line.isEmpty())
+ continue;
+ if (!line.contains("="))
+ continue;
+ // found a candidate
+ String user = line.substring(0,line.indexOf("="));
+ String pass = line.substring(line.indexOf("=")+1);
+ config.put(new PropertySimple("user",user));
+ config.put(new PropertySimple("password",pass));
+
+ }
+ } catch (IOException e) {
+ e.printStackTrace(); // TODO: Customise this generated block
+ } finally {
+ if (br!=null)
+ try {
+ br.close();
+ } catch (IOException e) {
+ // empty
+ }
+ }
+
+ }
+
private String findHost(ProcessInfo processInfo,boolean isDomain) {
String hostXmlFile = getHostXmlFileLocation(processInfo, isDomain);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@@ -173,12 +236,13 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
return hostName;
}
- String getBaseDirFromCommandLine(String[] commandLine) {
+
+ String getServerConfigFromCommandLine(String[] commandLine) {
for (String line: commandLine) {
- if (line.startsWith(DJBOSS_SERVER_BASE_DIR))
- return line.substring(DJBOSS_SERVER_BASE_DIR.length());
+ if (line.startsWith(DASH_DASH_SERVER_CONFIG))
+ return line.substring(DASH_DASH_SERVER_CONFIG.length());
}
- return "";
+ return "standalone.xml";
}
//-Dorg.jboss.boot.log.file=/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/log/server-manager/boot.log
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
new file mode 100644
index 0000000..c8703a6
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
@@ -0,0 +1,184 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.io.File;
+import java.net.ConnectException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.core.pluginapi.util.ProcessExecutionUtility;
+import org.rhq.core.system.ProcessExecution;
+import org.rhq.core.system.ProcessExecutionResults;
+import org.rhq.modules.plugins.jbossas7.json.Result;
+
+/**
+ * Base component for functionality that is common to Standalone AS and HostControllers
+ * @author Heiko W. Rupp
+ */
+public class BaseServerComponent extends BaseComponent {
+
+ private static final String STANDALONE_XML = "standalone.xml";
+ private static final String SEPARATOR = "\n-----------------------\n";
+ final Log log = LogFactory.getLog(BaseServerComponent.class);
+
+ /**
+ * Restart the server by first executing a 'shutdown' operation via its API. Then call
+ * the #startServer method to start it again.
+ *
+ * @param parameters Parameters to pass to the (recursive) invocation of #invokeOperation
+ * @param mode
+ * @return State of execution
+ * @throws Exception If anything goes wrong
+ */
+ protected OperationResult restartServer(Configuration parameters, Mode mode) throws Exception {
+ OperationResult tmp = invokeOperation("shutdown",parameters);
+
+ if (tmp.getErrorMessage()!=null) {
+ tmp.setErrorMessage("Restart failed while failing to shut down: " + tmp.getErrorMessage());
+ return tmp;
+ }
+ Thread.sleep(500); // Wait 0.5s -- this is plenty
+ return startServer(mode);
+ }
+
+ /**
+ * Start the server by calling the start script listed in the plugin configuration. If a different
+ * config is given, this is passed via --server-config
+ * @return State of Execution.
+ * @param mode
+ */
+ protected OperationResult startServer(Mode mode) {
+ OperationResult operationResult = new OperationResult();
+ Configuration conf = context.getPluginConfiguration();
+ String startScript = conf.getSimpleValue("startScript", mode.getStartScript());
+ String baseDir = conf.getSimpleValue("baseDir","");
+ if (baseDir.isEmpty()) {
+ operationResult.setErrorMessage("No base directory provided");
+ return operationResult;
+ }
+ String script = baseDir + File.separator + startScript;
+ String config = conf.getSimpleValue("config", mode.getXmlFile());
+
+ ProcessExecution processExecution;
+ processExecution = ProcessExecutionUtility.createProcessExecution(new File(script));
+ if (!config.equals(mode.getXmlFile())) {
+ processExecution.getArguments().add(mode.getConfigArg());
+ processExecution.getArguments().add(config);
+ }
+ processExecution.setWorkingDirectory(baseDir);
+ processExecution.setCaptureOutput(true);
+ processExecution.setWaitForCompletion(2000L); // 2 seconds // TODO: Should we wait longer than two seconds?
+ processExecution.setKillOnTimeout(false);
+
+
+ long start = System.currentTimeMillis();
+ if (log.isDebugEnabled()) {
+ log.debug("About to execute the following process: [" + processExecution + "]");
+ }
+ ProcessExecutionResults results = context.getSystemInformation().executeProcess(processExecution);
+ logExecutionResults(results);
+ if (results.getError()!=null) {
+ operationResult.setErrorMessage(results.getError().getMessage());
+ } else {
+ operationResult.setSimpleResult("Success");
+ }
+
+ return operationResult;
+
+ }
+
+ private void logExecutionResults(ProcessExecutionResults results) {
+ // Always log the output at info level. On Unix we could switch depending on a exitCode being !=0, but ...
+ log.info("Exit code from process execution: " + results.getExitCode());
+ log.info("Output from process execution: " + SEPARATOR + results.getCapturedOutput() + SEPARATOR);
+ }
+
+ /**
+ * Do some post processing of the Result - especially the 'shutdown' operation needs a special
+ * treatment.
+ * @param name Name of the operation
+ * @param res Result of the operation vs. AS7
+ * @return OperationResult filled in from values of res
+ */
+ protected OperationResult postProcessResult(String name, Result res) {
+ OperationResult operationResult = new OperationResult();
+ if (name.equals("shutdown")) {
+ /*
+ * Shutdown needs a special treatment, because after sending the operation, if shutdown suceeds,
+ * the server connection is closed and we can't read from it. So if we get connection refused for
+ * reading, this is a good sign.
+ */
+ if (!res.isSuccess()) {
+ if (res.getThrowable()!=null && (res.getThrowable() instanceof ConnectException || res.getThrowable().getMessage().equals("Connection refused")))
+ operationResult.setSimpleResult("Success");
+ else
+ operationResult.setErrorMessage(res.getFailureDescription());
+ }
+ }
+ else {
+ if (res.isSuccess()) {
+ if (res.getResult()!=null)
+ operationResult.setSimpleResult(res.getResult().toString());
+ else
+ operationResult.setSimpleResult("-None provided by server-");
+ }
+ else
+ operationResult.setErrorMessage(res.getFailureDescription());
+ }
+ return operationResult;
+ }
+
+ enum Mode {
+ STANDALONE(STANDALONE_XML,"standalone","--server-config","bin/standalone.sh"),
+ DOMAIN("domain.xml","domain", "--domain-config","bin/domain.sh"),
+ HOST("host.xml","domain", "--host-config","bin/domain.sh");
+
+ private String xmlFile;
+ private String baseDir;
+ private String configArg;
+ private String startScript;
+
+ private Mode(String xmlFile, String baseDir, String configArg, String startScript) {
+ this.xmlFile = xmlFile;
+ this.baseDir = baseDir;
+ this.configArg = configArg;
+ this.startScript = startScript;
+ }
+
+ public String getXmlFile() {
+ return xmlFile;
+ }
+
+ public String getBaseDir() {
+ return baseDir;
+ }
+
+ public String getConfigArg() {
+ return configArg;
+ }
+
+ public String getStartScript() {
+ return startScript;
+ }
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
deleted file mode 100644
index c25fe88..0000000
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.modules.plugins.jbossas7;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.codehaus.jackson.JsonNode;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.pluginapi.operation.OperationFacet;
-import org.rhq.core.pluginapi.operation.OperationResult;
-import org.rhq.modules.plugins.jbossas7.json.Operation;
-import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
-import org.rhq.modules.plugins.jbossas7.json.Result;
-
-/**
- * Common stuff for the Domain
- * @author Heiko W. Rupp
- */
-@SuppressWarnings("unused")
-public class DomainComponent extends BaseComponent implements OperationFacet{
-
- @Override
- public AvailabilityType getAvailability() {
-
- if (context.getResourceType().getName().equals("JBossAS-Managed")) {
- List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>(2);
- String host = conf.getSimpleValue("domainHost","local");
- address.add(new PROPERTY_VALUE("host",host));
- address.add(new PROPERTY_VALUE("server-config",myServerName));
- Operation getStatus = new Operation("read-attribute",address,"name","status");
- Result result = null;
- try {
- result = connection.execute(getStatus);
- } catch (Exception e) {
- log.warn(e.getMessage());
- return AvailabilityType.DOWN;
- }
- if (!result.isSuccess())
- return AvailabilityType.DOWN;
-
- String msg = result.getResult().toString();
- if (msg.contains("STARTED"))
- return AvailabilityType.UP;
- else
- return AvailabilityType.DOWN;
- }
-
- return super.getAvailability(); // TODO: Customise this generated block
- }
-
-}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java
new file mode 100644
index 0000000..73eb0bb
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java
@@ -0,0 +1,64 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.Result;
+
+/**
+ * Component class for host- and domain controller
+ * @author Heiko W. Rupp
+ */
+public class HostControllerComponent extends BaseServerComponent implements OperationFacet {
+
+ private final Log log = LogFactory.getLog(HostControllerComponent.class);
+
+ @Override
+ public OperationResult invokeOperation(String name,
+ Configuration parameters) throws InterruptedException, Exception {
+
+ if (name.equals("start")) {
+ return startServer(Mode.DOMAIN);
+ } else if (name.equals("restart")) {
+ return restartServer(parameters, Mode.DOMAIN);
+
+ } else if (name.equals("shutdown")) {
+ // This is a bit trickier, as it needs to be executed on the level on /host=xx
+ String domainHost = pluginConfiguration.getSimpleValue("domainHost","");
+ if (domainHost.isEmpty()) {
+ OperationResult result = new OperationResult();
+ result.setErrorMessage("No domain host found - can not continue");
+ return result;
+ }
+ Operation op = new Operation("shutdown","host",domainHost);
+ Result res = getASConnection().execute(op);
+
+ postProcessResult(name,res);
+ }
+
+ // Defer other stuff to the base component for now
+ return super.invokeOperation(name, parameters);
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java
index d0d3eee..951430c 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java
@@ -32,7 +32,6 @@ import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
-import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.resource.CreateResourceStatus;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
@@ -43,7 +42,7 @@ import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
* Component class for the JMS subsystem
* @author Heiko W. Rupp
*/
-public class JmsComponent extends DomainComponent {
+public class JmsComponent extends BaseComponent {
private final Log log = LogFactory.getLog(JmsComponent.class);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java
new file mode 100644
index 0000000..64ac2b6
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java
@@ -0,0 +1,70 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+import org.rhq.modules.plugins.jbossas7.json.Result;
+
+/**
+ * Common stuff for the Domain
+ * @author Heiko W. Rupp
+ */
+@SuppressWarnings("unused")
+public class ManagedASComponent extends BaseComponent {
+
+ /**
+ * Get the availability of the managed AS server. We can't just check if
+ * a connection succeeds, as the check runs against the API/HostController
+ * and the managed server may still be down even if the connection succeeds.
+ * @return Availability of the managed AS instance.
+ */
+ @Override
+ public AvailabilityType getAvailability() {
+
+ if (context.getResourceType().getName().equals("JBossAS-Managed")) {
+ List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>(2);
+ String host = pluginConfiguration.getSimpleValue("domainHost","local");
+ address.add(new PROPERTY_VALUE("host",host));
+ address.add(new PROPERTY_VALUE("server-config",myServerName));
+ Operation getStatus = new Operation("read-attribute",address,"name","status");
+ Result result = null;
+ try {
+ result = connection.execute(getStatus);
+ } catch (Exception e) {
+ log.warn(e.getMessage());
+ return AvailabilityType.DOWN;
+ }
+ if (!result.isSuccess())
+ return AvailabilityType.DOWN;
+
+ String msg = result.getResult().toString();
+ if (msg.contains("STARTED"))
+ return AvailabilityType.UP;
+ else
+ return AvailabilityType.DOWN;
+ }
+
+ return super.getAvailability();
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
index 3946dbe..fd1b65d 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
@@ -70,7 +70,7 @@ public class ManagedASDiscovery extends AbstractBaseDiscovery
// Now we have the host controller, lets get the host.xml file
// and obtain the servers from there.
ProcessInfo processInfo = psr.getProcessInfo();
- readHostXml(processInfo,true);
+ readStandaloneOrHostXml(processInfo, true);
String hostName = findHostName();
HostPort managementHostPort = getManagementPortFromHostXml();
@@ -105,13 +105,16 @@ public class ManagedASDiscovery extends AbstractBaseDiscovery
// TODO this fails for the downed servers.
// get from the domain or other place as soon as the domain provides it.
- initLogFile(scans, serverInfo.name, config, getHomeDirFromCommandLine(processInfo.getCommandLine()));
+ String homeDir = getHomeDirFromCommandLine(processInfo.getCommandLine());
+ initLogFile(scans, serverInfo.name, config, homeDir);
+
+ String version = homeDir.substring(homeDir.lastIndexOf("-")+1);
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
discoveryContext.getResourceType(), // ResourceType
hostName + "/" + serverInfo.name, // key
serverInfo.name, // Name
- null, // TODO real version - get from Domain as soon as it is provided
+ version, // TODO get from Domain as soon as it is provided
"Managed AS 7 instance", // Description
config,
null
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
index 15cb5d3..ad1109b 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
@@ -23,7 +23,6 @@ import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -38,12 +37,10 @@ import org.rhq.core.domain.content.transfer.DeployPackageStep;
import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
-import org.rhq.core.domain.resource.CreateResourceStatus;
import org.rhq.core.pluginapi.content.ContentContext;
import org.rhq.core.pluginapi.content.ContentFacet;
import org.rhq.core.pluginapi.content.ContentServices;
import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
-import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.modules.plugins.jbossas7.json.CompositeOperation;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
@@ -55,7 +52,7 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
* @author Heiko W. Rupp
*/
@SuppressWarnings("unused")
-public class ServerGroupComponent extends DomainComponent implements ContentFacet, CreateChildResourceFacet {
+public class ServerGroupComponent extends ManagedASComponent implements ContentFacet, CreateChildResourceFacet {
private static final String SUCCESS = "success";
private static final String OUTCOME = "outcome";
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
index 0281279..ebddf95 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
@@ -31,41 +31,25 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
* Component class for standalone AS7 servers
* @author Heiko W. Rupp
*/
-public class StandaloneASComponent extends BaseComponent implements OperationFacet {
-
+public class StandaloneASComponent extends BaseServerComponent implements OperationFacet {
@Override
public OperationResult invokeOperation(String name,
Configuration parameters) throws Exception {
- // reload, shutdown
+ if (name.equals("start")) {
+ return startServer(Mode.STANDALONE);
+ } else if (name.equals("restart")) {
+ return restartServer(parameters, Mode.STANDALONE);
+
+ }
+
+ // reload, shutdown go to the remote server
Operation op = new Operation(name,new Address());
Result res = getASConnection().execute(op);
- OperationResult operationResult = new OperationResult();
- if (name.equals("shutdown")) {
- /*
- * Shutdown needs a special treatment, because after sending the operation, if shutdown suceeds,
- * the server connection is closed and we can't read from it. So if we get connection refused for
- * reading, this is a good sign.
- */
- if (!res.isSuccess()) {
- if (res.getThrowable() instanceof ConnectException || res.getThrowable().getMessage().equals("Connection refused"))
- operationResult.setSimpleResult("Success");
- else
- operationResult.setErrorMessage(res.getFailureDescription());
- }
- }
- else {
- if (res.isSuccess()) {
- if (res.getResult()!=null)
- operationResult.setSimpleResult(res.getResult().toString());
- else
- operationResult.setSimpleResult("-None provided by server-");
- }
- else
- operationResult.setErrorMessage(res.getFailureDescription());
- }
+ OperationResult operationResult = postProcessResult(name, res);
return operationResult;
}
+
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
index ad91dac..d762485 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
@@ -51,6 +51,25 @@ public class Address {
path.addAll(other);
}
+ public Address(String path) {
+ this();
+ String[] components = path.split(",");
+ for (String component : components) {
+ String tmp = component.trim();
+
+ if (tmp.contains("=")) {
+ // strip / from the start of the key if it happens to be there
+ if (tmp.startsWith("/"))
+ tmp = tmp.substring(1);
+
+ String[] pair = tmp.split("=");
+ PROPERTY_VALUE valuePair = new PROPERTY_VALUE(pair[0], pair[1]);
+ this.path.add(valuePair);
+ }
+ }
+
+ }
+
public void add(String key, String value) {
path.add(new PROPERTY_VALUE(key,value));
}
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index c0e364d..0927693 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -58,6 +58,7 @@
~~ additional 'Personalities' for the kinds of servers (PM, SM, Standalone AS, Managed AS)
-->
+ <!-- TODO do we want to show the process controller at all? We have no benefit from it
<server name="ProcessController"
discovery="BaseProcessDiscovery"
class="BaseComponent"
@@ -68,27 +69,28 @@
<c:simple-property name="hostname" default="localhost" required="true"/>
<c:simple-property name="port" default="9990" type="integer" required="true"/>
- &logSources;
</plugin-configuration>
<process-scan name="ProcessController" query="process|basename|match=^java.*,arg|org.jboss.as.process-controller|match=.*"/>
- <operation name="dummyOperation">
- <!-- TODO supply parameters and return values -->
- </operation>
-
-
</server>
+ -->
<server name="HostController"
discovery="BaseProcessDiscovery"
- class="BaseComponent"
+ class="HostControllerComponent"
description="Domain controller (delegate) for this host"
>
<plugin-configuration>
- <c:simple-property name="hostname" default="localhost" required="true"/>
- <c:simple-property name="port" default="9990" type="integer" required="true"/>
+ <c:simple-property name="hostname" default="localhost" required="true" description="Host name of the domain API"/>
+ <c:simple-property name="port" default="9990" type="integer" required="true" description="Port of the domain API"/>
+ <c:simple-property name="user" type="string" description="Management user for a secured Host controller" required="false"/>
+ <c:simple-property name="password" type="password" description="Password for the management user" required="false"/>
+ <c:simple-property name="config" type="string" default="domain.xml" description="Running configuration" displayName="Configuration"/>
+ <c:simple-property name="baseDir" type="file" description="Base directory of the server installation" displayName="Base directory" readOnly="true" required="false"/>
+ <c:simple-property name="startScript" type="file" default="bin/domain.sh" description="Script used to start the server. If the path is not absolute, it is relative to the base directory"/>
+ <c:simple-property name="domainHost" type="string" readOnly="true" required="false" description="Host name within the AS7 domain"/>
&logSources;
</plugin-configuration>
@@ -96,8 +98,10 @@
<process-scan name="HostController" query="process|basename|match=^java.*,arg|org.jboss.as.host-controller|match=.*"/>
+<!-- Currently not provided by AS7
<operation name="domain:shutdown" displayName="Shutdown Domain" description="Shut this Host-/Domaincontroller down with all managed servers.">
</operation>
+-->
<operation name="server-group:add" displayName="Add ServerGroup" description="Add a server group to the Domain.">
<parameters>
@@ -146,6 +150,17 @@
</operation>
+ <operation name="start" description="Start this Host-/Domaincontroller" displayName="Start this host controller">
+ <results>
+ <c:simple-property name="operationResult" description="Outcome of the start operation"/>
+ </results>
+ </operation>
+ <operation name="shutdown" description="Stop this Host-/Domaincontroller" displayName="Shut down this host controller">
+ <results>
+ <c:simple-property name="operationResult" description="Outcome of the stop operation"/>
+ </results>
+ </operation>
+
<metric property="_internal:mgmtRequests" category="performance" dataType="measurement" defaultInterval="120000"
displayType="summary" measurementType="trendsup" description="Number of requests sent to the controller"
@@ -206,7 +221,7 @@
<resource-configuration>
<c:simple-property name="profile" description="The profile name" required="true"/>
<c:simple-property name="socket-binding-group" readOnly="false" required="true">
- <c:option-source target="resource" expression="type=SocketBindingGroup"/>
+ <c:option-source target="resource" expression="type=SocketBindingGroupDomain"/>
</c:simple-property>
<c:simple-property name="socket-binding-port-offset" required="false" defaultValue="0" type="integer"
description="The default offset to be added to the port values given by the socket binding group."/>
@@ -217,7 +232,7 @@
<server name="Host"
description="Host involved in this domain"
discovery="SubsystemDiscovery"
- class="DomainComponent"
+ class="BaseComponent"
>
<plugin-configuration>
<c:simple-property name="path" default="host" readOnly="true"/>
@@ -287,11 +302,17 @@
<server name="JBossAS7-Standalone"
discovery="BaseProcessDiscovery"
class="StandaloneASComponent"
+ description="Standalone AS7 server"
>
<plugin-configuration>
<c:simple-property name="hostname" default="localhost" required="true"/>
<c:simple-property name="port" default="9990" type="integer" required="true"/>
+ <c:simple-property name="user" type="string" description="Management user for a secured AS" required="false"/>
+ <c:simple-property name="password" type="password" description="Password for the management user" required="false"/>
+ <c:simple-property name="config" type="string" default="standalone.xml" description="Running configuration" displayName="Configuration"/>
+ <c:simple-property name="baseDir" type="file" description="Base directory of the server installation" displayName="Base directory" readOnly="true" required="false"/>
+ <c:simple-property name="startScript" type="file" default="bin/standalone.sh" description="Script used to start the server. If the path is not absolute, it is relative to the base directory"/>
<c:list-property name="system-properties">
<c:map-property name="system-property">
<c:simple-property name="key" readOnly="true"/>
@@ -303,7 +324,18 @@
<process-scan name="StandaloneAS" query="process|basename|match=^java.*,arg|org.jboss.as.standalone|match=.*"/>
- <operation name="reload" description="Make the server load the (changed) configuration." displayName="Reload">
+
+ <operation name="reload" description="Make the server re-load the (changed) configuration. To load a different startup config use 'restart'" displayName="Reload">
+ <results>
+ <c:simple-property name="operationResult"/>
+ </results>
+ </operation>
+ <operation name="start" description="Start the server by invoking its start script">
+ <results>
+ <c:simple-property name="operationResult"/>
+ </results>
+ </operation>
+ <operation name="restart" description="Restart the server by shutting it down and invoking its start script">
<results>
<c:simple-property name="operationResult"/>
</results>
@@ -353,14 +385,14 @@
<server name="JBossAS-Managed"
discovery="ManagedASDiscovery"
- class="DomainComponent"
+ class="ManagedASComponent"
>
<plugin-configuration>
<c:simple-property name="hostname" default="localhost" displayName="Management host" required="true"/>
<c:simple-property name="port" default="9990" type="integer" displayName="Management port" required="true"/>
<c:simple-property name="domainHost" readOnly="true" description="Hostname in the domain"/>
<c:simple-property name="group" readOnly="true" displayName="Server Group" description="Server Group this instance belongs to."/>
- <c:simple-property name="socket-binding-group" readOnly="true" displayName="Socket binding group" description="Socket bindngs to use"/>
+ <c:simple-property name="socket-binding-group" readOnly="true" displayName="Socket binding group" description="Socket bindings to use"/>
<c:simple-property name="socket-binding-port-offset" readOnly="true" displayName="Port Offset" type="integer" default="0" description="Offset to the base ports"/>
<c:simple-property name="path" readOnly="true" />
@@ -412,7 +444,7 @@
<server name="Messaging"
discovery="SubsystemDiscovery"
- class="DomainComponent"
+ class="BaseComponent"
description="The underlying HornetQ based messaging subsystem"
singleton="true"
>
@@ -1792,8 +1824,8 @@ working area for individual server instances</li></ul>"/>
<c:list-property name="includes" required="false">
<c:simple-property name="includes" displayName="Included bindings" description="Other bindings that are included in this one (only needed in Domain Mode)"/>
</c:list-property>
- <c:group name="children:socket.binding">
- <c:list-property name="socket-binding">
+ <c:group name="children:socket-binding:name" displayName="Individual socket bindings">
+ <c:list-property name="*">
<c:map-property name="binding">
<c:simple-property name="name" description="The name of the socket. Services which need to access the socket configuration information will find it using this name." readOnly="true"/>
<c:simple-property name="interface" description="Name of the interface to which the socket should be bound, or, for multicast sockets, the interface on which it should listen. This should be one of the declared interfaces."
commit ae90811cb167e8e8c20cb4677fe1e7580714db51
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jul 25 17:25:23 2011 +0200
BZ 725417 - if the 'default' attribute is missing on a required property, throw a descriptive exception instead of a NPE.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginConfigurationMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginConfigurationMetadataManagerBean.java
index 9b2d1db..3963f9d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginConfigurationMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginConfigurationMetadataManagerBean.java
@@ -106,8 +106,14 @@ public class PluginConfigurationMetadataManagerBean implements PluginConfigurati
for (PropertyDefinition propertyDef : updateReport.getNewPropertyDefinitions()) {
if (propertyDef.isRequired()) {
Property templateProperty = templateConfiguration.get(propertyDef.getName());
- pluginConfiguration.put(templateProperty.deepCopy(false));
- modified = true;
+ if (templateProperty==null) {
+ throw new IllegalArgumentException("The property [" + propertyDef.getName()
+ + "] marked as required in the configuration definition of [" + propertyDef.getConfigurationDefinition().getName()
+ + "] has no attribute 'default'");
+ } else {
+ pluginConfiguration.put(templateProperty.deepCopy(false));
+ modified = true;
+ }
}
}
commit e194ab53e5b63d1c17e67d370a65c29fb8b17efe
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jul 25 07:54:06 2011 +0200
Extract the deploy-to-server-magic from createChild() and add tests to use this extracted code to deploy to domain and server-group.
diff --git a/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/UploadAndDeployTest.java b/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/UploadAndDeployTest.java
index 8581ada..2010640 100644
--- a/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/UploadAndDeployTest.java
+++ b/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/UploadAndDeployTest.java
@@ -26,7 +26,17 @@ import java.util.Map;
import org.codehaus.jackson.JsonNode;
import org.testng.annotations.Test;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.content.PackageDetailsKey;
+import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
+import org.rhq.core.domain.resource.CreateResourceStatus;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.modules.plugins.jbossas7.ASConnection;
+import org.rhq.modules.plugins.jbossas7.BaseComponent;
+import org.rhq.modules.plugins.jbossas7.json.Address;
import org.rhq.modules.plugins.jbossas7.json.CompositeOperation;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
@@ -292,7 +302,7 @@ public class UploadAndDeployTest extends AbstractIntegrationTest {
/**
* Test uploading to domain only, but not to a server group
- * @throws Exception
+ * @throws Exception if anything goes wrong.
*/
@Test(timeOut = 60*1000L,enabled = isEnabled)
public void testUploadComposite2() throws Exception {
@@ -346,4 +356,77 @@ public class UploadAndDeployTest extends AbstractIntegrationTest {
}
+ /**
+ * Test the real API code for uploading - case 1: just upload to /deployment
+ * @throws Exception if anything goes wrong.
+ */
+ @Test
+ public void testUploadViaCreateChild1() throws Exception {
+
+ BaseComponent bc = new BaseComponent();
+ bc.setConnection(getASConnection());
+ bc.setPath("");
+ ResourceType rt = new ResourceType();
+ rt.setName("Deployment");
+ Resource resource = new Resource("deployment="+TEST_WAR,TEST_WAR,rt); // TODO resource key?
+ ResourceContext context = new ResourceContext(resource,null,null,null,null,null,null,null,null,null,null,null);
+ bc.start(context);
+
+ String bytes_value = uploadToAs(TEST_WAR);
+
+ ResourcePackageDetails details = new ResourcePackageDetails(new PackageDetailsKey(TEST_WAR,"1.0","deployment","all"));
+ CreateResourceReport report = new CreateResourceReport(TEST_WAR,rt,new Configuration(), new Configuration(),details);
+ try {
+ report = bc.runDeploymentMagicOnServer(report,TEST_WAR,TEST_WAR,bytes_value);
+ assert report != null;
+ assert report.getErrorMessage()==null: "Report contained an unexpected error: " + report.getErrorMessage();
+ assert report.getStatus()!=null : "Report did not contain a status";
+ assert report.getStatus()== CreateResourceStatus.SUCCESS : "Status was no success";
+ assert report.getResourceName().equals(TEST_WAR);
+ assert report.getResourceKey().equals("deployment=" + TEST_WAR);
+ } finally {
+ Remove r =new Remove("deployment",TEST_WAR);
+ getASConnection().execute(r);
+ }
+
+ }
+
+ /**
+ * Test the real API code for uploading - case 2: upload to /deployment and a server group
+ * @throws Exception if anything goes wrong.
+ */
+ @Test
+ public void testUploadViaCreateChild2() throws Exception {
+
+ BaseComponent bc = new BaseComponent();
+ bc.setConnection(getASConnection());
+ bc.setPath("server-group=main-server-group");
+ ResourceType rt = new ResourceType();
+ rt.setName("Deployment");
+ Resource resource = new Resource("server-group=main-server-group",TEST_WAR,rt);
+ ResourceContext context = new ResourceContext(resource,null,null,null,null,null,null,null,null,null,null,null);
+ bc.start(context);
+
+ String bytes_value = uploadToAs(TEST_WAR);
+
+ ResourcePackageDetails details = new ResourcePackageDetails(new PackageDetailsKey(TEST_WAR,"1.0","deployment","all"));
+ CreateResourceReport report = new CreateResourceReport(TEST_WAR,rt,new Configuration(), new Configuration(),details);
+ try {
+ report = bc.runDeploymentMagicOnServer(report,TEST_WAR,TEST_WAR,bytes_value);
+ assert report != null;
+ assert report.getErrorMessage()==null: "Report contained an unexpected error: " + report.getErrorMessage();
+ assert report.getStatus()!=null : "Report did not contain a status";
+ assert report.getStatus()== CreateResourceStatus.SUCCESS : "Status was no success";
+ assert report.getResourceName().equals(TEST_WAR);
+ assert report.getResourceKey().equals("server-group=main-server-group,deployment=" + TEST_WAR) : "Resource key was wrong";
+ } finally {
+ Address sgd = new Address("server-group","main-server-group");
+ sgd.add("deployment", TEST_WAR);
+ Remove r =new Remove(sgd);
+ getASConnection().execute(r);
+ r =new Remove("deployment",TEST_WAR);
+ getASConnection().execute(r);
+ }
+
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 83b221b..8851706 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -331,18 +331,34 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
fileName=fileName.substring("C:\\fakepath\\".length());
}
- boolean toServerGroup = context.getResourceKey().contains("server-group=");
- log.info("Deploying [" + fileName + "] to domain only= " + !toServerGroup + " ...");
String tmpName = fileName; // TODO figure out the tmp-name biz with the AS guys
JsonNode resultNode = uploadResult.get("result");
String hash = resultNode.get("BYTES_VALUE").getTextValue();
+ return runDeploymentMagicOnServer(report, fileName, tmpName, hash);
+
+ }
+
+ /**
+ * Do the actual fumbling with the domain api to deploy the uploaded content
+ * @param report CreateResourceReport to report the result
+ * @param runtimeName File name to use as runtime name
+ * @param deploymentName Name of the deployment
+ * @param hash Hash of the content bytes
+ * @return the passed report with success or failure settings
+ */
+ public CreateResourceReport runDeploymentMagicOnServer(CreateResourceReport report, String runtimeName,
+ String deploymentName, String hash) {
+
+ boolean toServerGroup = context.getResourceKey().contains("server-group=");
+ log.info("Deploying [" + runtimeName + "] to domain only= " + !toServerGroup + " ...");
+
ASConnection connection = getASConnection();
- Operation step1 = new Operation("add","deployment",tmpName);
+ Operation step1 = new Operation("add","deployment",deploymentName);
// step1.addAdditionalProperty("hash", new PROPERTY_VALUE("BYTES_VALUE", hash));
List<Object> content = new ArrayList<Object>(1);
Map<String,Object> contentValues = new HashMap<String,Object>();
@@ -350,8 +366,8 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
content.add(contentValues);
step1.addAdditionalProperty("content",content);
- step1.addAdditionalProperty("name", tmpName);
- step1.addAdditionalProperty("runtime-name", fileName);
+ step1.addAdditionalProperty("name", deploymentName);
+ step1.addAdditionalProperty("runtime-name", runtimeName);
String resourceKey;
Result result ;
@@ -379,7 +395,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>();
serverGroupAddress.addAll(pathToAddress(context.getResourceKey()));
- serverGroupAddress.add(new PROPERTY_VALUE("deployment", tmpName));
+ serverGroupAddress.add(new PROPERTY_VALUE("deployment", deploymentName));
Operation step2 = new Operation("add",serverGroupAddress);
cop.addStep(step2);
@@ -403,13 +419,12 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
}
else {
report.setStatus(CreateResourceStatus.SUCCESS);
- report.setResourceName(fileName);
+ report.setResourceName(runtimeName);
report.setResourceKey(resourceKey);
log.info(" ... with success and key [" + resourceKey + "]" );
}
return report;
-
}
@Override
commit f1b3ecdcd88a1dca8e39236caca260f51a100311
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Jul 28 15:44:35 2011 +0200
BZ 726378 - management port settings on AS7 were not honored.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 322e453..9aa9db0 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -111,12 +111,15 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
this.context = context;
pluginConfiguration = context.getPluginConfiguration();
- String typeName = context.getResourceType().getName();
- // TODO can we use parent's connection and only set this up for top level base component?
- host = pluginConfiguration.getSimpleValue("hostname", LOCALHOST);
- String portString = pluginConfiguration.getSimpleValue("port", DEFAULT_HTTP_MANAGEMENT_PORT);
- port = Integer.parseInt(portString);
- connection = new ASConnection(host,port);
+ if (!(context.getParentResourceComponent() instanceof BaseComponent)) {
+ host = pluginConfiguration.getSimpleValue("hostname", LOCALHOST);
+ String portString = pluginConfiguration.getSimpleValue("port", DEFAULT_HTTP_MANAGEMENT_PORT);
+ port = Integer.parseInt(portString);
+ connection = new ASConnection(host,port);
+ }
+ else {
+ connection = ((BaseComponent)context.getParentResourceComponent()).getASConnection();
+ }
path = pluginConfiguration.getSimpleValue("path", null);
key = context.getResourceKey();
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
index 475fd62..471fd42 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
@@ -79,11 +79,8 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
String psName = psr.getProcessScan().getName();
String description = discoveryContext.getResourceType().getDescription();
String version = null;
- String startScript;
- if (psName.equals("ProcessController")) {
- serverNameFull = "ProcessController";
- serverName = "ProcessController";
- } else if (psName.equals("HostController")) {
+
+ if (psName.equals("HostController")) {
readStandaloneOrHostXml(psr.getProcessInfo(), true);
HostPort hp = getDomainControllerFromHostXml();
if (hp.isLocal) {
@@ -118,11 +115,10 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
tmp = tmp.substring( i + 8);
tmp = tmp.substring(0,tmp.indexOf("/"));
serverNameFull = tmp;
-
- String host = findHost(psr.getProcessInfo(),true);
- config.put(new PropertySimple("domainHost",host));
-
}
+ String host = findHost(psr.getProcessInfo(),true);
+ config.put(new PropertySimple("domainHost",host));
+
config.put(new PropertySimple("baseDir",serverNameFull));
serverName = findHostName();
if (serverName.isEmpty())
@@ -139,6 +135,11 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
}
String logFile = getLogFileFromCommandLine(commandLine);
initLogEventSourcesConfigProp(logFile,config);
+
+ HostPort managmentPort = getManagementPortFromHostXml();
+ config.put(new PropertySimple("hostname",managmentPort.host));
+ config.put(new PropertySimple("port",managmentPort.port));
+
// String javaClazz = psr.getProcessInfo().getName();
commit d46c2fc9b284b6c4d8d1ef50d098f495a4ae9a50
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Jul 28 13:17:00 2011 +0200
Initial support for messaging (JMS)
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 776e5ef..322e453 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -23,6 +23,8 @@ import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
@@ -480,12 +482,34 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
} else if (what.equals("destination")) {
address.addAll(pathToAddress(getPath()));
String newName = parameters.getSimpleValue("name","");
-// String type = parameters.getSimpleValue("type","Queue").toLowerCase();
-// address.add(new PROPERTY_VALUE(type,newName));
- String queueName = parameters.getSimpleValue("queue-address","");
- Map<String,Object> props = new HashMap<String, Object>();
- props.put("queue-address",queueName);
+ String type = parameters.getSimpleValue("type","jms-queue").toLowerCase();
+ address.add(new PROPERTY_VALUE(type,newName));
+ PropertyList jndiNamesProp = parameters.getList("entries");
+ if (jndiNamesProp==null || jndiNamesProp.getList().isEmpty()) {
+ OperationResult fail = new OperationResult();
+ fail.setErrorMessage("No jndi bindings given");
+ return fail;
+ }
+ List<String> jndiNames = new ArrayList<String>();
+ for (Property p : jndiNamesProp.getList()) {
+ PropertySimple ps = (PropertySimple) p;
+ jndiNames.add(ps.getStringValue());
+ }
+
operation = new Operation(op,address);
+ operation.addAdditionalProperty("entries",jndiNames);
+ if (type.equals("jms-queue")) {
+ PropertySimple ps = (PropertySimple) parameters.get("durable");
+ if (ps!=null) {
+ boolean durable = ps.getBooleanValue();
+ operation.addAdditionalProperty("durable",durable);
+ }
+ String selector = parameters.getSimpleValue("selector","");
+ if (!selector.isEmpty())
+ operation.addAdditionalProperty("selector",selector);
+ }
+
+
} else if (what.equals("managed-server")) {
String chost = parameters.getSimpleValue("hostname","");
String serverName = parameters.getSimpleValue("servername","");
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 6a8698e..20395e0 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -444,7 +444,7 @@
<server name="Messaging"
discovery="SubsystemDiscovery"
class="BaseComponent"
- description="The underlying HornetQ based messaging subsystem"
+ description="The HornetQ based messaging subsystem"
singleton="true"
>
<runs-inside>
@@ -459,15 +459,16 @@
<operation name="destination:add" displayName="Add destination" description="Add a Queue or Topic">
<parameters>
<c:simple-property name="name" description="Name of the Destination" required="true"/>
- <c:simple-property name="queue-address" description="The queue address defines what address is used for routing messages." required="true"/>
+ <c:list-property name="entries" description="The JNDI names the destination should be bound to." required="true">
+ <c:simple-property name="entry" description="A single JNDI name. Note, this is relative to java:jboss/jms/"/>
+ </c:list-property>
<c:simple-property name="type" description="Type of Destination to create" default="Queue">
<c:property-options>
- <c:option value="Queue"/>
- <c:option value="Topic"/>
+ <c:option value="jms-queue" name="Queue"/>
+ <c:option value="jms-topic" name="Topic"/>
</c:property-options>
</c:simple-property>
- <c:simple-property name="filter" description="The queue message filter definition."/>
- <c:simple-property name="durable" description="Defines whether the queue is durable." type="boolean" default="false"/>
+ <c:simple-property name="durable" description="Defines whether the queue is durable (for Queues only)." type="boolean" default="false"/>
</parameters>
<results>
<c:simple-property name="operationResult"/>
@@ -487,73 +488,23 @@
<c:simple-property name="journal-type" />
</resource-configuration>
- <!-- this is no child resource TODO
-
- <service name="Acceptor"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- >
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="acceptor"/>
- </plugin-configuration>
- </service>
- <service name="MessagingConnector"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- >
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="connector"/>
- </plugin-configuration>
- </service>
- <service name="HQueue"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- >
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="queue"/>
- </plugin-configuration>
- <resource-configuration>
- <c:simple-property name="queue-address" required="true"/>
- <c:simple-property name="filter" />
- <c:simple-property name="durable" type="boolean"/>
- </resource-configuration>
-
- </service>
--->
- </server>
-
- <server name="JMS"
- discovery="SubsystemDiscovery"
- class="JmsComponent"
- description="The JMS messaging subsystem"
- singleton="true"
- >
- <runs-inside>
- <parent-resource-type name="Profile" plugin="jboss-as-7"/>
- <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
- </runs-inside>
-
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="subsystem=jms"/>
- </plugin-configuration>
-
- <service name="Queue"
+ <service name="JMS Queue"
discovery="SubsystemDiscovery"
class="JmsComponent"
- createDeletePolicy="both"
+ createDeletePolicy="delete-only"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="queue"/>
+ <c:simple-property name="path" readOnly="true" default="jms-queue"/>
</plugin-configuration>
<resource-configuration> <!-- See BZ 705713 TODO -->
- <c:simple-property name="durable" required="false" type="boolean" readOnly="false" default="false"
+ <c:simple-property name="durable" required="false" type="boolean" readOnly="true" default="false"
description="Whether the queue is durable or not."/>
- <c:list-property name="entries" required="false" readOnly="false"
+ <c:list-property name="entries" required="false" readOnly="true"
description="The jndi names the queue will be bound to.">
<c:simple-property name="entries" type="string"/>
</c:list-property>
- <c:simple-property name="selector" required="false" type="string" readOnly="false" description="The queue selector."/>
+ <c:simple-property name="selector" required="false" type="string" readOnly="true" description="The queue selector."/>
<c:template name="add" description="Properties when adding a new queue" >
<c:simple-property name="durable" required="false" type="boolean" default="false"
description="Whether the queue is durable or not."/>
@@ -565,16 +516,16 @@
</c:template>
</resource-configuration>
</service>
- <service name="Topic"
+ <service name="JMS Topic"
discovery="SubsystemDiscovery"
class="JmsComponent"
- createDeletePolicy="both"
+ createDeletePolicy="delete-only"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="topic"/>
+ <c:simple-property name="path" readOnly="true" default="jms-topic"/>
</plugin-configuration>
<resource-configuration> <!-- See BZ 705713 TODO -->
- <c:list-property name="entries" required="false" readOnly="false"
+ <c:list-property name="entries" required="false" readOnly="true"
description="The jndi names the queue will be bound to.">
<c:simple-property name="entries" type="string"/>
</c:list-property>
commit 60c8260da5440b889746aac23e7bb3c347a09c81
Merge: 0890ce0 462e94c
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Jul 27 23:11:59 2011 -0500
Merge branch 'mod_cluster_plugin'
commit 462e94c290eeb017427f6a1925f254d859d31140
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Jul 27 23:07:42 2011 -0500
Move mod_cluster integration tests in the correct integration folder.
diff --git a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
new file mode 100644
index 0000000..0f644fc
--- /dev/null
+++ b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -0,0 +1,210 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster.test;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
+
+import org.rhq.core.clientapi.server.discovery.InventoryReport;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.measurement.MeasurementData;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.pc.PluginContainer;
+import org.rhq.core.pc.PluginContainerConfiguration;
+import org.rhq.core.pc.plugin.FileSystemPluginFinder;
+import org.rhq.core.pc.plugin.PluginEnvironment;
+import org.rhq.core.pc.plugin.PluginManager;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
+
+/**
+ * @author Stefan Negrea
+ */
+@SuppressWarnings("rawtypes")
+@Test(groups = "modcluster-plugin")
+public class ModclusterPluginTest {
+ private Log log = LogFactory.getLog(this.getClass());
+ private static final String PLUGIN_NAME = "mod_cluster";
+
+ @BeforeSuite
+ public void start() {
+ try {
+ File pluginDir = new File("target/testsetup/plugins");
+ PluginContainerConfiguration pcConfig = new PluginContainerConfiguration();
+ pcConfig.setPluginFinder(new FileSystemPluginFinder(pluginDir));
+ pcConfig.setPluginDirectory(pluginDir);
+
+ pcConfig.setInsideAgent(false);
+ PluginContainer.getInstance().setConfiguration(pcConfig);
+ PluginContainer.getInstance().initialize();
+ log.info("PC started.");
+ for (String plugin : PluginContainer.getInstance().getPluginManager().getMetadataManager().getPluginNames()) {
+ log.info("...Loaded plugin: " + plugin);
+ }
+ } catch (Exception e) {
+ log.info("Error initializing the context", e);
+ }
+ }
+
+ @AfterSuite
+ public void stop() {
+ PluginContainer.getInstance().shutdown();
+ }
+
+ @Test
+ public void testPluginLoad() {
+ PluginManager pluginManager = PluginContainer.getInstance().getPluginManager();
+ PluginEnvironment pluginEnvironment = pluginManager.getPlugin(PLUGIN_NAME);
+ assert (pluginEnvironment != null) : "Null environment, plugin not loaded";
+ assert (pluginEnvironment.getPluginName().equals(PLUGIN_NAME));
+ }
+
+ @Test(dependsOnMethods = "testPluginLoad")
+ public void testDiscovery() throws Exception {
+ InventoryReport report = PluginContainer.getInstance().getInventoryManager().executeServerScanImmediately();
+ assert report != null;
+ log.info("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+
+ Thread.sleep(1000);
+
+ report = PluginContainer.getInstance().getInventoryManager().executeServiceScanImmediately();
+ assert report != null;
+ log.info("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+
+ List<String> typeNames = new ArrayList<String>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ add(PLUGIN_NAME);
+ add(PLUGIN_NAME + " Webapp Context");
+ }
+ };
+
+ Set<Resource> resources = findResource(PluginContainer.getInstance().getInventoryManager().getPlatform(),
+ typeNames);
+ log.info("Found " + resources.size() + " mod_cluster and mod_cluster_context instance(s).");
+
+ assert (resources.size() != 0) : "No mod_cluster or related instances found.";
+
+ if (resources.size() != 0) {
+ for (Object objectResource : resources.toArray()) {
+ Resource resource = (Resource) objectResource;
+ if (resource.getResourceType().getName().equals("mod_cluster")) {
+ testResourceMeasurement(resource);
+ } else {
+ testContextOperations(resource);
+ }
+ }
+ }
+ }
+
+ private void testResourceMeasurement(Resource resource) throws Exception {
+ ResourceComponent resourceComponent = PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+ if (resourceComponent instanceof MeasurementFacet) {
+ for (MeasurementDefinition def : resource.getResourceType().getMetricDefinitions()) {
+ Set<MeasurementScheduleRequest> metricList = new HashSet<MeasurementScheduleRequest>();
+ metricList.add(new MeasurementScheduleRequest(1, def.getName(), 1000, true, def.getDataType(), null));
+ MeasurementReport report = new MeasurementReport();
+ ((MeasurementFacet) resourceComponent).getValues(report, metricList);
+
+ MeasurementData data = report.getTraitData().iterator().next();
+ assert data != null : "Unable to collect trait [" + def.getName() + "] on " + resource;
+ log.info("Measurement: " + def.getName() + "=" + data.getValue());
+ }
+ }
+
+ if (resourceComponent instanceof OperationFacet) {
+ OperationResult result = ((OperationFacet) resourceComponent).invokeOperation("reset", null);
+ log.info("Result of operation test was: " + result);
+
+ result = ((OperationFacet) resourceComponent).invokeOperation("disable", null);
+ log.info("Result of operation test was: " + result.getSimpleResult());
+ }
+ }
+
+ private void testContextOperations(Resource resource) throws Exception {
+ ResourceComponent resourceComponent = PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+
+ if (resourceComponent instanceof OperationFacet) {
+ try {
+ OperationResult result = ((OperationFacet) resourceComponent).invokeOperation("enableContext", null);
+ log.info("Result of operation " + "enableContext" + " was: " + result.getSimpleResult());
+
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("timeout", "1000"));
+ config.put(new PropertySimple("unit", java.util.concurrent.TimeUnit.SECONDS));
+ result = ((OperationFacet) resourceComponent).invokeOperation("stopContext", config);
+ log.info("Result of operation stopContext was: " + result.getSimpleResult());
+
+ result = ((OperationFacet) resourceComponent).invokeOperation("enableContext", null);
+ log.info("Result of operation enableContext was: " + result.getSimpleResult());
+
+ result = ((OperationFacet) resourceComponent).invokeOperation("disableContext", null);
+ log.info("Result of operation disableContext was: " + result.getSimpleResult());
+
+ } catch (Exception e) {
+ log.info("Operation failed. ", e);
+ }
+
+ }
+ }
+
+ private Set<Resource> findResource(Resource parent, List<String> typeNames) {
+ Set<Resource> found = new HashSet<Resource>();
+
+ Queue<Resource> discoveryQueue = new LinkedList<Resource>();
+ discoveryQueue.add(parent);
+
+ while (!discoveryQueue.isEmpty()) {
+ Resource currentResource = discoveryQueue.poll();
+
+ log.info("Discovered resource of type: " + currentResource.getResourceType().getName());
+ if (typeNames.contains(currentResource.getResourceType().getName())) {
+ found.add(currentResource);
+ }
+
+ if (currentResource.getChildResources() != null) {
+ for (Resource child : currentResource.getChildResources()) {
+ discoveryQueue.add(child);
+ }
+ }
+ }
+
+ return found;
+ }
+}
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
deleted file mode 100644
index 0f644fc..0000000
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster.test;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Queue;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.testng.annotations.AfterSuite;
-import org.testng.annotations.BeforeSuite;
-import org.testng.annotations.Test;
-
-import org.rhq.core.clientapi.server.discovery.InventoryReport;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.measurement.MeasurementData;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.measurement.MeasurementReport;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.pc.PluginContainer;
-import org.rhq.core.pc.PluginContainerConfiguration;
-import org.rhq.core.pc.plugin.FileSystemPluginFinder;
-import org.rhq.core.pc.plugin.PluginEnvironment;
-import org.rhq.core.pc.plugin.PluginManager;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-import org.rhq.core.pluginapi.measurement.MeasurementFacet;
-import org.rhq.core.pluginapi.operation.OperationFacet;
-import org.rhq.core.pluginapi.operation.OperationResult;
-
-/**
- * @author Stefan Negrea
- */
-@SuppressWarnings("rawtypes")
-@Test(groups = "modcluster-plugin")
-public class ModclusterPluginTest {
- private Log log = LogFactory.getLog(this.getClass());
- private static final String PLUGIN_NAME = "mod_cluster";
-
- @BeforeSuite
- public void start() {
- try {
- File pluginDir = new File("target/testsetup/plugins");
- PluginContainerConfiguration pcConfig = new PluginContainerConfiguration();
- pcConfig.setPluginFinder(new FileSystemPluginFinder(pluginDir));
- pcConfig.setPluginDirectory(pluginDir);
-
- pcConfig.setInsideAgent(false);
- PluginContainer.getInstance().setConfiguration(pcConfig);
- PluginContainer.getInstance().initialize();
- log.info("PC started.");
- for (String plugin : PluginContainer.getInstance().getPluginManager().getMetadataManager().getPluginNames()) {
- log.info("...Loaded plugin: " + plugin);
- }
- } catch (Exception e) {
- log.info("Error initializing the context", e);
- }
- }
-
- @AfterSuite
- public void stop() {
- PluginContainer.getInstance().shutdown();
- }
-
- @Test
- public void testPluginLoad() {
- PluginManager pluginManager = PluginContainer.getInstance().getPluginManager();
- PluginEnvironment pluginEnvironment = pluginManager.getPlugin(PLUGIN_NAME);
- assert (pluginEnvironment != null) : "Null environment, plugin not loaded";
- assert (pluginEnvironment.getPluginName().equals(PLUGIN_NAME));
- }
-
- @Test(dependsOnMethods = "testPluginLoad")
- public void testDiscovery() throws Exception {
- InventoryReport report = PluginContainer.getInstance().getInventoryManager().executeServerScanImmediately();
- assert report != null;
- log.info("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
-
- Thread.sleep(1000);
-
- report = PluginContainer.getInstance().getInventoryManager().executeServiceScanImmediately();
- assert report != null;
- log.info("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
-
- List<String> typeNames = new ArrayList<String>() {
- private static final long serialVersionUID = 1L;
-
- {
- add(PLUGIN_NAME);
- add(PLUGIN_NAME + " Webapp Context");
- }
- };
-
- Set<Resource> resources = findResource(PluginContainer.getInstance().getInventoryManager().getPlatform(),
- typeNames);
- log.info("Found " + resources.size() + " mod_cluster and mod_cluster_context instance(s).");
-
- assert (resources.size() != 0) : "No mod_cluster or related instances found.";
-
- if (resources.size() != 0) {
- for (Object objectResource : resources.toArray()) {
- Resource resource = (Resource) objectResource;
- if (resource.getResourceType().getName().equals("mod_cluster")) {
- testResourceMeasurement(resource);
- } else {
- testContextOperations(resource);
- }
- }
- }
- }
-
- private void testResourceMeasurement(Resource resource) throws Exception {
- ResourceComponent resourceComponent = PluginContainer.getInstance().getInventoryManager()
- .getResourceComponent(resource);
- if (resourceComponent instanceof MeasurementFacet) {
- for (MeasurementDefinition def : resource.getResourceType().getMetricDefinitions()) {
- Set<MeasurementScheduleRequest> metricList = new HashSet<MeasurementScheduleRequest>();
- metricList.add(new MeasurementScheduleRequest(1, def.getName(), 1000, true, def.getDataType(), null));
- MeasurementReport report = new MeasurementReport();
- ((MeasurementFacet) resourceComponent).getValues(report, metricList);
-
- MeasurementData data = report.getTraitData().iterator().next();
- assert data != null : "Unable to collect trait [" + def.getName() + "] on " + resource;
- log.info("Measurement: " + def.getName() + "=" + data.getValue());
- }
- }
-
- if (resourceComponent instanceof OperationFacet) {
- OperationResult result = ((OperationFacet) resourceComponent).invokeOperation("reset", null);
- log.info("Result of operation test was: " + result);
-
- result = ((OperationFacet) resourceComponent).invokeOperation("disable", null);
- log.info("Result of operation test was: " + result.getSimpleResult());
- }
- }
-
- private void testContextOperations(Resource resource) throws Exception {
- ResourceComponent resourceComponent = PluginContainer.getInstance().getInventoryManager()
- .getResourceComponent(resource);
-
- if (resourceComponent instanceof OperationFacet) {
- try {
- OperationResult result = ((OperationFacet) resourceComponent).invokeOperation("enableContext", null);
- log.info("Result of operation " + "enableContext" + " was: " + result.getSimpleResult());
-
- Configuration config = new Configuration();
- config.put(new PropertySimple("timeout", "1000"));
- config.put(new PropertySimple("unit", java.util.concurrent.TimeUnit.SECONDS));
- result = ((OperationFacet) resourceComponent).invokeOperation("stopContext", config);
- log.info("Result of operation stopContext was: " + result.getSimpleResult());
-
- result = ((OperationFacet) resourceComponent).invokeOperation("enableContext", null);
- log.info("Result of operation enableContext was: " + result.getSimpleResult());
-
- result = ((OperationFacet) resourceComponent).invokeOperation("disableContext", null);
- log.info("Result of operation disableContext was: " + result.getSimpleResult());
-
- } catch (Exception e) {
- log.info("Operation failed. ", e);
- }
-
- }
- }
-
- private Set<Resource> findResource(Resource parent, List<String> typeNames) {
- Set<Resource> found = new HashSet<Resource>();
-
- Queue<Resource> discoveryQueue = new LinkedList<Resource>();
- discoveryQueue.add(parent);
-
- while (!discoveryQueue.isEmpty()) {
- Resource currentResource = discoveryQueue.poll();
-
- log.info("Discovered resource of type: " + currentResource.getResourceType().getName());
- if (typeNames.contains(currentResource.getResourceType().getName())) {
- found.add(currentResource);
- }
-
- if (currentResource.getChildResources() != null) {
- for (Resource child : currentResource.getChildResources()) {
- discoveryQueue.add(child);
- }
- }
- }
-
- return found;
- }
-}
commit d5d01cb8c70fd39febb46b8418e2e972ae871b60
Merge: aac766a b13a351
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Jul 27 22:46:02 2011 -0500
Merge branch 'mod_cluster_plugin' of ssh://git.fedorahosted.org/git/rhq/rhq into mod_cluster_plugin
commit aac766a243e3aed738184a5563d9ceaeea2f9a38
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Jul 27 22:42:04 2011 -0500
Make the error message useful by adding the name of the attribute that failed to set.
diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
index 2e1ae41..cb7f901 100644
--- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
+++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
@@ -503,7 +503,7 @@ public class MBeanResourceComponent<T extends JMXComponent> implements Measureme
property.setErrorMessage(ThrowableUtil.getStackAsString(e));
report
.setErrorMessage("Failed setting resource configuration - see property error messages for details");
- log.info("Failure setting MBean Resource configuration value", e);
+ log.info("Failure setting MBean Resource configuration value for " + key, e);
}
}
}
commit 2c7893abae2d8472490f6eb65305ca91e9b61f74
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Jul 27 22:41:13 2011 -0500
Final touches for mod_cluster plugin configuration. Updated a couple of the plugin settings to match mod_cluster specifications.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
index 5c9c3fd..3d03715 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
@@ -42,9 +42,9 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
@SuppressWarnings("rawtypes")
public class ContextDiscoveryComponent implements ResourceDiscoveryComponent<MBeanResourceComponent> {
- private final String JVM_ROUTE_PROPERTY = "jvmRoute";
- private final String PROXY_INFO_PROPERTY = "proxyInfo";
- private final String ADDITIONAL_CONFIG_BEAN_PROPERTY = "additionalConfigurationObjectName";
+ private static final String JVM_ROUTE_PROPERTY = "jvmRoute";
+ private static final String PROXY_INFO_PROPERTY = "proxyInfo";
+ private static final String ENGINE_OBJECT_NAME = "engineObjectName";
/* (non-Javadoc)
* @see org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext)
@@ -76,8 +76,8 @@ public class ContextDiscoveryComponent implements ResourceDiscoveryComponent<MBe
*/
private String getJvmRoute(ResourceDiscoveryContext<MBeanResourceComponent> context) {
Configuration pluginConfig = context.getParentResourceComponent().getResourceContext().getPluginConfiguration();
- String objectName = pluginConfig.getSimple(ADDITIONAL_CONFIG_BEAN_PROPERTY).getStringValue();
- EmsBean engineBean = this.loadBean(objectName, context.getParentResourceComponent());
+ String engineObjectName = pluginConfig.getSimple(ENGINE_OBJECT_NAME).getStringValue();
+ EmsBean engineBean = this.loadBean(engineObjectName, context.getParentResourceComponent());
return (String) engineBean.getAttribute(JVM_ROUTE_PROPERTY).refresh().toString();
}
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index 591fef6..70898ef 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -25,7 +25,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
* @author Stefan Negrea
*
*/
-@SuppressWarnings("rawtypes")
+@SuppressWarnings({ "rawtypes" })
public class ModclusterServerComponent extends MBeanResourceComponent {
/* (non-Javadoc)
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 992c5b0..29b334f 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -25,9 +25,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="Catalina:type=ModClusterListener,*"/>
- <c:simple-property name="additionalConfigurationObjectName" readOnly="true" default="jboss.web:type=Engine"/>
- <c:simple-property name="jvmRoute" readOnly="false"/>
- <c:simple-property name="nameTemplate" default="mod_cluster"/>
+ <c:simple-property name="engineObjectName" readOnly="true" default="jboss.web:type=Engine"/>
</plugin-configuration>
<operation name="stop" displayName="Stop all webapps" description="Gracefully stops all webapps for all engines.">
@@ -76,12 +74,12 @@
<metric property="proxyConfiguration" displayName="Proxy Configuration" displayType="summary" dataType="trait" />
<metric property="modelerType" displayName="Type of the modeled resource" displayType="summary" dataType="trait" />
<metric property="className" displayName="Fully qualified class name of the managed object" displayType="summary" dataType="trait" />
+ <metric property="advertise" displayName="Enable autodiscovery of httpd servers." displayType="summary" dataType="trait" />
<resource-configuration>
<c:simple-property name="workerTimeout" type="integer" description="Timeout to wait for an available worker (default is no wait)" />
<c:simple-property name="stickySession" type="boolean" description="Enables sticky session for the cluster."/>
<c:simple-property name="stickySessionRemove" type="boolean" description="Remove session when the request cannot be routed to the right node."/>
- <!-- c:simple-property name="advertise" type="boolean" description="Enable autodiscovery of httpd servers."/-->
<c:simple-property name="smax" type="integer" description="Maximum time on seconds for idle connections above smax."/>
<c:simple-property name="maxAttempts" type="integer" description="Maximum number of attempts to send the request to the backend server."/>
<c:simple-property name="advertiseSecurityKey" type="string" required="false" description="Security key for discovery."/>
@@ -89,7 +87,6 @@
<c:simple-property name="balancer" type="string" required="false" description="Name of the balancer."/>
<c:simple-property name="flushPackets" type="boolean" description="Allows controlling flusing of packets."/>
<c:simple-property name="socketTimeout" type="integer" description="Connection timeout for communication with the proxy." />
- <c:simple-property name="domain" type="string" required="false" description="Domain parameter, which allows tying a jvmRoute to a particular domain."/>
<c:simple-property name="advertisePort" type="integer" required="false" description="Multicast port for discovery" />
<c:simple-property name="advertiseGroupAddress" type="string" required="false" description="Multicast address for discovery."/>
<c:simple-property name="flushWait" type="integer" description="Time in ms to wait before flushing packets."/>
commit 34ee85b04b0ad8592caf75511eb7dbc1fec8f857
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 26 16:11:50 2011 -0500
Fully enable jvmRoute for context identification and discovery. Also, addressed all the compiler warnings in the plugin code.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
index 23d7d62..3545fa5 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
@@ -32,6 +32,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
*
* @author Stefan Negrea
*/
+@SuppressWarnings({ "rawtypes", "deprecation" })
public class ContextComponent extends MBeanResourceComponent<MBeanResourceComponent> {
@Override
protected EmsBean loadBean() {
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
index 35ecf30..5c9c3fd 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
@@ -57,10 +57,12 @@ public class ContextDiscoveryComponent implements ResourceDiscoveryComponent<MBe
Set<DiscoveredResourceDetails> entities = new HashSet<DiscoveredResourceDetails>();
for (ProxyInfo.Context availableContext : proxyInfo.getAvailableContexts()) {
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(context.getResourceType(),
- availableContext.createKey(), availableContext.createName(), null, "mod_cluster Webapp Context", null,
- null);
- entities.add(detail);
+ if (availableContext.getJvmRoute().equals(jvmRoute)) {
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(context.getResourceType(),
+ availableContext.createKey(), availableContext.createName(), null, "mod_cluster Webapp Context",
+ null, null);
+ entities.add(detail);
+ }
}
return entities;
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
index 4cca539..8614402 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
@@ -54,9 +54,9 @@ public class ProxyInfo {
identifier = identifier.substring(identifier.indexOf("[") + 1, identifier.indexOf("]"));
String jvmRoute = nodePieces[1];
- jvmRoute = jvmRoute.substring(jvmRoute.indexOf(':')).trim();
+ jvmRoute = jvmRoute.substring(jvmRoute.indexOf(':') + 1).trim();
- availableNodes.put(jvmRoute, new Node(jvmRoute, identifier));
+ availableNodes.put(identifier, new Node(jvmRoute, identifier));
}
}
@@ -90,13 +90,18 @@ public class ProxyInfo {
identifier = identifier.substring(identifier.indexOf("[") + 1, identifier.indexOf("]"));
identifier = identifier.substring(0, identifier.lastIndexOf(":"));
+ String nodeIdentifier = contextPieces[0];
+ nodeIdentifier = nodeIdentifier.substring(nodeIdentifier.indexOf("[") + 1, nodeIdentifier.indexOf("]"));
+ nodeIdentifier = nodeIdentifier.substring(0, nodeIdentifier.indexOf(":"));
+ String jvmRoute = availableNodes.get(nodeIdentifier).getJvmRoute();
+
String rawIsEnabled = contextPieces[2];
rawIsEnabled = rawIsEnabled.substring(rawIsEnabled.indexOf(':') + 1).trim();
boolean isEnabled = rawIsEnabled.equals("ENABLED") ? true : false;
Vhost relatedVhost = availableVhosts.get(identifier);
- availableContexts.add(new Context("", relatedVhost.getHost(), actualContext, isEnabled));
+ availableContexts.add(new Context(jvmRoute, relatedVhost.getHost(), actualContext, isEnabled));
}
}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 3c01b30..992c5b0 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -18,12 +18,12 @@
description="mod_cluster plugin"
singleton="true">
- <runs-inside>
+ <runs-inside>
<parent-resource-type name="JBossAS Server" plugin="JBossAS"/>
<parent-resource-type name="JBossAS5 Server" plugin="JBossAS5"/>
</runs-inside>
- <plugin-configuration>
+ <plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="Catalina:type=ModClusterListener,*"/>
<c:simple-property name="additionalConfigurationObjectName" readOnly="true" default="jboss.web:type=Engine"/>
<c:simple-property name="jvmRoute" readOnly="false"/>
@@ -34,12 +34,14 @@
<parameters>
<c:simple-property required="true" name="timeout" type="string" displayName="Session draining timeout"/>
<c:simple-property required="true" name="unit" default="MILLISECONDS" displayName="Time unit of the timeout parameter">
- <c:property-options allowCustomValue="false">
- <c:option value="MICROSECONDS" name="MICROSECONDS"/>
+ <c:property-options allowCustomValue="false">
+ <c:option value="MICROSECONDS" name="MICROSECONDS"/>
<c:option value="MILLISECONDS" name="MILLISECONDS"/>
<c:option value="NANOSECONDS" name="NANOSECONDS"/>
- <c:option value="SECONDS" name="SECONDS"/>
- </c:property-options>
+ <c:option value="SECONDS" name="SECONDS"/>
+ <c:option value="HOURS" name="HOURS"/>
+ <c:option value="DAYS" name="DAYS"/>
+ </c:property-options>
</c:simple-property>
</parameters>
<results>
@@ -56,7 +58,7 @@
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
- </operation>
+ </operation>
<operation name="reset" displayName="Reset the node" description="Move the node out of an error state." />
<operation name="disable" displayName="Disable all webpapps" description="Disable all webapps for all engines.">
<results>
@@ -71,7 +73,6 @@
</operation>
<operation name="refresh" displayName="Refresh configuration" description="Refresh configuration" />
-
<metric property="proxyConfiguration" displayName="Proxy Configuration" displayType="summary" dataType="trait" />
<metric property="modelerType" displayName="Type of the modeled resource" displayType="summary" dataType="trait" />
<metric property="className" displayName="Fully qualified class name of the managed object" displayType="summary" dataType="trait" />
@@ -87,7 +88,7 @@
<c:simple-property name="stickySessionForce" type="boolean" description="Return an error when the request cannot be routed to the right node."/>
<c:simple-property name="balancer" type="string" required="false" description="Name of the balancer."/>
<c:simple-property name="flushPackets" type="boolean" description="Allows controlling flusing of packets."/>
- <c:simple-property name="socketTimeout" type="integer" description="Connection timeout for communication with the proxy." />
+ <c:simple-property name="socketTimeout" type="integer" description="Connection timeout for communication with the proxy." />
<c:simple-property name="domain" type="string" required="false" description="Domain parameter, which allows tying a jvmRoute to a particular domain."/>
<c:simple-property name="advertisePort" type="integer" required="false" description="Multicast port for discovery" />
<c:simple-property name="advertiseGroupAddress" type="string" required="false" description="Multicast address for discovery."/>
@@ -130,6 +131,5 @@
</operation>
</service>
-
</service>
</plugin>
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index 57aed4d..0f644fc 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -53,6 +53,7 @@ import org.rhq.core.pluginapi.operation.OperationResult;
/**
* @author Stefan Negrea
*/
+@SuppressWarnings("rawtypes")
@Test(groups = "modcluster-plugin")
public class ModclusterPluginTest {
private Log log = LogFactory.getLog(this.getClass());
@@ -104,6 +105,8 @@ public class ModclusterPluginTest {
log.info("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
List<String> typeNames = new ArrayList<String>() {
+ private static final long serialVersionUID = 1L;
+
{
add(PLUGIN_NAME);
add(PLUGIN_NAME + " Webapp Context");
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
index df7d222..625d8d4 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
@@ -21,8 +21,6 @@ package org.rhq.plugins.modcluster.test;
import java.io.IOException;
import java.io.InputStream;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.testng.annotations.Test;
import org.rhq.plugins.modcluster.ProxyInfo;
@@ -32,7 +30,6 @@ import org.rhq.plugins.modcluster.ProxyInfo;
*/
@Test(groups = "modcluster-plugin")
public class ProxyInfoTest {
- private Log log = LogFactory.getLog(this.getClass());
@Test
public void testProxyInfo() throws Exception {
commit d8c6f150e4e80fa19842708e1adf65ddbb9499fa
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 26 15:08:59 2011 -0500
Adding jvmRoute in the mix for webapp context identification. jvmRoute uniquely identifies nodes in a cluster and will be used to decide which contexts run on the node monitored by RHQ.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
index 7cefa46..35ecf30 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
@@ -25,8 +25,10 @@ package org.rhq.plugins.modcluster;
import java.util.HashSet;
import java.util.Set;
+import org.mc4j.ems.connection.EmsConnection;
import org.mc4j.ems.connection.bean.EmsBean;
+import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
@@ -37,26 +39,78 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
*
* @author Stefan Negrea
*/
+@SuppressWarnings("rawtypes")
public class ContextDiscoveryComponent implements ResourceDiscoveryComponent<MBeanResourceComponent> {
+ private final String JVM_ROUTE_PROPERTY = "jvmRoute";
+ private final String PROXY_INFO_PROPERTY = "proxyInfo";
+ private final String ADDITIONAL_CONFIG_BEAN_PROPERTY = "additionalConfigurationObjectName";
+
/* (non-Javadoc)
* @see org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext)
*/
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<MBeanResourceComponent> context) {
- Set<DiscoveredResourceDetails> entities = new HashSet<DiscoveredResourceDetails>();
+ String jvmRoute = this.getJvmRoute(context);
+ String rawProxyInfo = this.getRawProxyInfo(context);
- EmsBean statsBean = context.getParentResourceComponent().getEmsBean();
-
- String rawProxyInfo = (String) statsBean.getAttribute("proxyInfo").refresh().toString();
ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+ Set<DiscoveredResourceDetails> entities = new HashSet<DiscoveredResourceDetails>();
for (ProxyInfo.Context availableContext : proxyInfo.getAvailableContexts()) {
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(context.getResourceType(),
- availableContext.toString(), availableContext.toString(), null, "mod_cluster Webapp Context", null,
+ availableContext.createKey(), availableContext.createName(), null, "mod_cluster Webapp Context", null,
null);
entities.add(detail);
}
return entities;
}
+
+ /**
+ * Retrieves the jvm route for the node from the parent context.
+ *
+ * @param context the discovery context
+ * @return node's jvm route
+ */
+ private String getJvmRoute(ResourceDiscoveryContext<MBeanResourceComponent> context) {
+ Configuration pluginConfig = context.getParentResourceComponent().getResourceContext().getPluginConfiguration();
+ String objectName = pluginConfig.getSimple(ADDITIONAL_CONFIG_BEAN_PROPERTY).getStringValue();
+ EmsBean engineBean = this.loadBean(objectName, context.getParentResourceComponent());
+
+ return (String) engineBean.getAttribute(JVM_ROUTE_PROPERTY).refresh().toString();
+ }
+
+ /**
+ * Retrieves raw proxy configuration from the parent context.
+ *
+ * @param context the discovery context
+ * @return raw proxy configuration
+ */
+ private String getRawProxyInfo(ResourceDiscoveryContext<MBeanResourceComponent> context) {
+ EmsBean statsBean = context.getParentResourceComponent().getEmsBean();
+ return (String) statsBean.getAttribute(PROXY_INFO_PROPERTY).refresh().toString();
+ }
+
+ /**
+ * Loads the bean with the given object name.
+ *
+ * Subclasses are free to override this method in order to load the bean.
+ *
+ * @param objectName the name of the bean to load
+ * @return the bean that is loaded
+ */
+ protected EmsBean loadBean(String objectName, MBeanResourceComponent context) {
+ EmsConnection emsConnection = context.getEmsConnection();
+ EmsBean bean = emsConnection.getBean(objectName);
+ if (bean == null) {
+ // In some cases, this resource component may have been discovered by some means other than querying its
+ // parent's EMSConnection (e.g. ApplicationDiscoveryComponent uses a filesystem to discover EARs and
+ // WARs that are not yet deployed). In such cases, getBean() will return null, since EMS won't have the
+ // bean in its cache. To cover such cases, make an attempt to query the underlying MBeanServer for the
+ // bean before giving up.
+ emsConnection.queryBeans(objectName);
+ bean = emsConnection.getBean(objectName);
+ }
+ return bean;
+ }
}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index 52dd287..591fef6 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -25,6 +25,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
* @author Stefan Negrea
*
*/
+@SuppressWarnings("rawtypes")
public class ModclusterServerComponent extends MBeanResourceComponent {
/* (non-Javadoc)
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
index 36f490d..4cca539 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
@@ -33,11 +33,35 @@ import java.util.regex.Pattern;
*/
public class ProxyInfo {
- private List<Context> availableContexts = new ArrayList<ProxyInfo.Context>();
+ private Map<String, Node> availableNodes = new HashMap<String, Node>();
private Map<String, Vhost> availableVhosts = new HashMap<String, Vhost>();
+ private List<Context> availableContexts = new ArrayList<ProxyInfo.Context>();
public ProxyInfo(String rawProxyInfo) {
- Pattern vhostPattern = Pattern.compile("Vhost.*\n");
+ parseNodes(rawProxyInfo);
+ parseVhosts(rawProxyInfo);
+ parseContexts(rawProxyInfo);
+ }
+
+ private void parseNodes(String rawProxyInfo) {
+ Pattern nodePattern = Pattern.compile("Node:.*\n");
+ Matcher nodeMatcher = nodePattern.matcher(rawProxyInfo);
+ while (nodeMatcher.find()) {
+ String rawNode = nodeMatcher.group();
+ String[] nodePieces = rawNode.split(",");
+
+ String identifier = nodePieces[0];
+ identifier = identifier.substring(identifier.indexOf("[") + 1, identifier.indexOf("]"));
+
+ String jvmRoute = nodePieces[1];
+ jvmRoute = jvmRoute.substring(jvmRoute.indexOf(':')).trim();
+
+ availableNodes.put(jvmRoute, new Node(jvmRoute, identifier));
+ }
+ }
+
+ private void parseVhosts(String rawProxyInfo) {
+ Pattern vhostPattern = Pattern.compile("Vhost:.*\n");
Matcher vhostMatcher = vhostPattern.matcher(rawProxyInfo);
while (vhostMatcher.find()) {
String rawVhost = vhostMatcher.group();
@@ -52,8 +76,10 @@ public class ProxyInfo {
availableVhosts.put(identifier, new Vhost(identifier, host));
}
+ }
- Pattern contextPattern = Pattern.compile("Context.*[\n|}]");
+ private void parseContexts(String rawProxyInfo) {
+ Pattern contextPattern = Pattern.compile("Context:.*[\n|}]");
Matcher contextMatcher = contextPattern.matcher(rawProxyInfo);
while (contextMatcher.find()) {
String rawContext = contextMatcher.group();
@@ -70,7 +96,7 @@ public class ProxyInfo {
Vhost relatedVhost = availableVhosts.get(identifier);
- availableContexts.add(new Context(relatedVhost.getHost(), actualContext, isEnabled));
+ availableContexts.add(new Context("", relatedVhost.getHost(), actualContext, isEnabled));
}
}
@@ -82,7 +108,60 @@ public class ProxyInfo {
return Collections.unmodifiableList(new ArrayList<Vhost>(availableVhosts.values()));
}
- private static class Vhost {
+ public List<Node> getAvailableNodes() {
+ return Collections.unmodifiableList(new ArrayList<Node>(availableNodes.values()));
+ }
+
+ public static class Node {
+ private String jvmRoute;
+ private String nodeId;
+
+ public Node(String jvmRoute, String nodeId) {
+ this.jvmRoute = jvmRoute;
+ this.nodeId = nodeId;
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public String getJvmRoute() {
+ return jvmRoute;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((jvmRoute == null) ? 0 : jvmRoute.hashCode());
+ result = prime * result + ((nodeId == null) ? 0 : nodeId.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Node other = (Node) obj;
+ if (jvmRoute == null) {
+ if (other.jvmRoute != null)
+ return false;
+ } else if (!jvmRoute.equals(other.jvmRoute))
+ return false;
+ if (nodeId == null) {
+ if (other.nodeId != null)
+ return false;
+ } else if (!nodeId.equals(other.nodeId))
+ return false;
+ return true;
+ }
+ }
+
+ public static class Vhost {
private String identifier;
private String host;
@@ -99,20 +178,52 @@ public class ProxyInfo {
return host;
}
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((host == null) ? 0 : host.hashCode());
+ result = prime * result + ((identifier == null) ? 0 : identifier.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Vhost other = (Vhost) obj;
+ if (host == null) {
+ if (other.host != null)
+ return false;
+ } else if (!host.equals(other.host))
+ return false;
+ if (identifier == null) {
+ if (other.identifier != null)
+ return false;
+ } else if (!identifier.equals(other.identifier))
+ return false;
+ return true;
+ }
}
public static class Context {
private String path;
private String host;
+ private String jvmRoute;
private boolean isEnabled;
- public Context(String host, String path) {
- this(path, host, false);
+ public Context(String jvmRoute, String host, String path) {
+ this(jvmRoute, host, path, false);
}
- public Context(String host, String path, boolean isEnabled) {
- this.path = path;
+ public Context(String jvmRoute, String host, String path, boolean isEnabled) {
+ this.jvmRoute = jvmRoute;
this.host = host;
+ this.path = path;
this.isEnabled = isEnabled;
}
@@ -124,13 +235,25 @@ public class ProxyInfo {
return host;
}
+ public String getJvmRoute() {
+ return jvmRoute;
+ }
+
public boolean isEnabled() {
return isEnabled;
}
+ public String createKey() {
+ return jvmRoute + ":" + host + ":" + path;
+ }
+
+ public String createName() {
+ return host + ":" + path;
+ }
+
@Override
public String toString() {
- return host + ":" + path;
+ return createKey();
}
@Override
@@ -138,6 +261,7 @@ public class ProxyInfo {
final int prime = 31;
int result = 1;
result = prime * result + ((host == null) ? 0 : host.hashCode());
+ result = prime * result + ((jvmRoute == null) ? 0 : jvmRoute.hashCode());
result = prime * result + ((path == null) ? 0 : path.hashCode());
return result;
}
@@ -156,6 +280,11 @@ public class ProxyInfo {
return false;
} else if (!host.equals(other.host))
return false;
+ if (jvmRoute == null) {
+ if (other.jvmRoute != null)
+ return false;
+ } else if (!jvmRoute.equals(other.jvmRoute))
+ return false;
if (path == null) {
if (other.path != null)
return false;
@@ -164,9 +293,13 @@ public class ProxyInfo {
return true;
}
- public static Context fromString(String stringRepresentation) {
- String part[] = stringRepresentation.trim().split(":");
- return new Context(part[1], part[0]);
+ public static Context fromString(String stringRepresentation) throws Exception {
+ String parts[] = stringRepresentation.trim().split(":");
+ if (parts.length < 3) {
+ throw new Exception("Parsing error. Not enough information to create a context.");
+ }
+
+ return new Context(parts[0], parts[1], parts[2]);
}
}
}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index b1a0f51..3c01b30 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -25,7 +25,9 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="Catalina:type=ModClusterListener,*"/>
- <c:simple-property name="nameTemplate" default="mod_cluster"/>
+ <c:simple-property name="additionalConfigurationObjectName" readOnly="true" default="jboss.web:type=Engine"/>
+ <c:simple-property name="jvmRoute" readOnly="false"/>
+ <c:simple-property name="nameTemplate" default="mod_cluster"/>
</plugin-configuration>
<operation name="stop" displayName="Stop all webapps" description="Gracefully stops all webapps for all engines.">
@@ -129,6 +131,5 @@
</service>
-
</service>
</plugin>
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
index 8c8c6f4..df7d222 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
@@ -35,7 +35,7 @@ public class ProxyInfoTest {
private Log log = LogFactory.getLog(this.getClass());
@Test
- public void testProxyInfo() throws IOException {
+ public void testProxyInfo() throws Exception {
String[] availableFiles = new String[] { "/proxy_config/proxy_config_1.txt", "/proxy_config/proxy_config_2.txt" };
for (String testConfigurationFile : availableFiles) {
commit 7d68fefbc54053c19fb5b4bc423599fc7f5b3055
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Jul 22 14:31:38 2011 -0500
Added support for stopContext operation for webapp contexts. Updated service description. Added more complex integration tests for webapp context service.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
index 42a1d6e..23d7d62 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
@@ -18,6 +18,8 @@
*/
package org.rhq.plugins.modcluster;
+import java.util.concurrent.TimeUnit;
+
import org.mc4j.ems.connection.bean.EmsBean;
import org.rhq.core.domain.configuration.Configuration;
@@ -75,11 +77,14 @@ public class ContextComponent extends MBeanResourceComponent<MBeanResourceCompon
Object[] configuration = null;
if ("stopContext".equals(name)) {
configuration = new Object[] { context.getHost(), context.getPath(),
- parameters.getSimple("timeout").getLongValue(), parameters.getSimple("unit").getStringValue() };
+ parameters.getSimple("timeout").getLongValue(),
+ TimeUnit.valueOf(parameters.getSimple("unit").getStringValue()) };
} else {
configuration = new Object[] { context.getHost(), context.getPath() };
}
+ log.info(name + " - " + context.getHost() + " " + context.getPath());
+
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
index 4b3adcd..7cefa46 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
@@ -52,7 +52,8 @@ public class ContextDiscoveryComponent implements ResourceDiscoveryComponent<MBe
for (ProxyInfo.Context availableContext : proxyInfo.getAvailableContexts()) {
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(context.getResourceType(),
- availableContext.toString(), availableContext.toString(), null, "mod_cluster Context", null, null);
+ availableContext.toString(), availableContext.toString(), null, "mod_cluster Webapp Context", null,
+ null);
entities.add(detail);
}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 70a9f2b..b1a0f51 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -2,6 +2,7 @@
<plugin name="mod_cluster"
displayName="mod_cluster"
+ description="Monitoring and management of mod_cluster plugin."
version="1.0"
package="org.rhq.plugins.modcluster"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -77,7 +78,7 @@
<c:simple-property name="workerTimeout" type="integer" description="Timeout to wait for an available worker (default is no wait)" />
<c:simple-property name="stickySession" type="boolean" description="Enables sticky session for the cluster."/>
<c:simple-property name="stickySessionRemove" type="boolean" description="Remove session when the request cannot be routed to the right node."/>
- <c:simple-property name="advertise" type="boolean" description="Enable autodiscovery of httpd servers."/>
+ <!-- c:simple-property name="advertise" type="boolean" description="Enable autodiscovery of httpd servers."/-->
<c:simple-property name="smax" type="integer" description="Maximum time on seconds for idle connections above smax."/>
<c:simple-property name="maxAttempts" type="integer" description="Maximum number of attempts to send the request to the backend server."/>
<c:simple-property name="advertiseSecurityKey" type="string" required="false" description="Security key for discovery."/>
@@ -95,7 +96,7 @@
<service name="mod_cluster Webapp Context"
discovery="ContextDiscoveryComponent"
class="ContextComponent"
- description="A mod_cluster context">
+ description="mod_cluster webapp context">
<operation name="disableContext" displayName="Disable webapp" description="Disable this webapp.">
<results>
@@ -110,7 +111,9 @@
<c:option value="MICROSECONDS" name="MICROSECONDS"/>
<c:option value="MILLISECONDS" name="MILLISECONDS"/>
<c:option value="NANOSECONDS" name="NANOSECONDS"/>
- <c:option value="SECONDS" name="SECONDS"/>
+ <c:option value="SECONDS" name="SECONDS"/>
+ <c:option value="HOURS" name="HOURS"/>
+ <c:option value="DAYS" name="DAYS"/>
</c:property-options>
</c:simple-property>
</parameters>
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index 8bead55..57aed4d 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -33,6 +33,8 @@ import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import org.rhq.core.clientapi.server.discovery.InventoryReport;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.measurement.MeasurementData;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.MeasurementReport;
@@ -159,11 +161,23 @@ public class ModclusterPluginTest {
try {
OperationResult result = ((OperationFacet) resourceComponent).invokeOperation("enableContext", null);
log.info("Result of operation " + "enableContext" + " was: " + result.getSimpleResult());
+
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("timeout", "1000"));
+ config.put(new PropertySimple("unit", java.util.concurrent.TimeUnit.SECONDS));
+ result = ((OperationFacet) resourceComponent).invokeOperation("stopContext", config);
+ log.info("Result of operation stopContext was: " + result.getSimpleResult());
+
+ result = ((OperationFacet) resourceComponent).invokeOperation("enableContext", null);
+ log.info("Result of operation enableContext was: " + result.getSimpleResult());
+
+ result = ((OperationFacet) resourceComponent).invokeOperation("disableContext", null);
+ log.info("Result of operation disableContext was: " + result.getSimpleResult());
+
} catch (Exception e) {
- log.info("Operation failed");
+ log.info("Operation failed. ", e);
}
- /*result = ((OperationFacet) resourceComponent).invokeOperation("disable", null);
- log.info("Result of operation test was: " + result.getSimpleResult());*/
+
}
}
commit 0963aa55fe898cab3f6a16eb6d595421abe61d76
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 19 23:16:19 2011 -0500
Returning back to simple availability methods (no availability collectors) after getting clarifications from the mod_cluster team with regards to JMX attributes and node refresh operations.
The simple method to get availability now works correctly for mod_cluster resources.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
index 8512ed5..42a1d6e 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
@@ -42,15 +42,19 @@ public class ContextComponent extends MBeanResourceComponent<MBeanResourceCompon
try {
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
String rawProxyInfo = (String) getEmsBean().getAttribute("proxyInfo").refresh().toString();
+
ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
ProxyInfo.Context context = ProxyInfo.Context.fromString(resourceContext.getResourceKey());
- ProxyInfo.Context currentContext = proxyInfo.getAvailableContexts().get(
- proxyInfo.getAvailableContexts().indexOf(context));
+ int indexOfCurrentContext = proxyInfo.getAvailableContexts().indexOf(context);
+
+ if (indexOfCurrentContext != -1) {
+ ProxyInfo.Context currentContext = proxyInfo.getAvailableContexts().get(indexOfCurrentContext);
- if (currentContext.isEnabled()) {
- return AvailabilityType.UP;
+ if (currentContext.isEnabled()) {
+ return AvailabilityType.UP;
+ }
}
return AvailabilityType.DOWN;
@@ -68,12 +72,18 @@ public class ContextComponent extends MBeanResourceComponent<MBeanResourceCompon
ProxyInfo.Context context = ProxyInfo.Context.fromString(resourceContext.getResourceKey());
+ Object[] configuration = null;
+ if ("stopContext".equals(name)) {
+ configuration = new Object[] { context.getHost(), context.getPath(),
+ parameters.getSimple("timeout").getLongValue(), parameters.getSimple("unit").getStringValue() };
+ } else {
+ configuration = new Object[] { context.getHost(), context.getPath() };
+ }
+
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
-
- Object resultObject = getEmsBean().getOperation(name).invoke(
- new Object[] { context.getHost(), context.getPath() });
+ Object resultObject = getEmsBean().getOperation(name).invoke(configuration);
return new OperationResult(String.valueOf(resultObject));
} finally {
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index e6495a1..52dd287 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -18,13 +18,7 @@
*/
package org.rhq.plugins.modcluster;
-import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.pluginapi.availability.AvailabilityCollectorRunnable;
-import org.rhq.core.pluginapi.availability.AvailabilityFacet;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.plugins.jmx.MBeanResourceComponent;
/**
@@ -33,66 +27,18 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
*/
public class ModclusterServerComponent extends MBeanResourceComponent {
- private AvailabilityCollectorRunnable availabilityCollector;
-
- /* (non-Javadoc)
- * @see org.rhq.plugins.jmx.MBeanResourceComponent#start(org.rhq.core.pluginapi.inventory.ResourceContext)
- */
- @Override
- public void start(ResourceContext context) {
-
- availabilityCollector = context.createAvailabilityCollectorRunnable(new AvailabilityFacet() {
- public AvailabilityType getAvailability() {
- try {
- OperationResult result = ModclusterServerComponent.this.invokeOperation("refresh",
- new Configuration());
-
- int numberOfAttempts = 0;
-
- //The configuration should be loaded in less than 20 attempts.
- //Only in extraneous cases (like network overload or a huge list webapp contexts)
- //it can take more than this.
- while (numberOfAttempts < 20) {
- String rawProxyInfo = (String) getEmsBean().getAttribute("proxyInfo").refresh().toString();
- ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
-
- if (proxyInfo.getAvailableContexts().size() != 0) {
- break;
- }
-
- numberOfAttempts++;
- Thread.sleep(2000);
- }
- } catch (Exception e) {
- log.info("mod_cluster availability update failed. Node configuration could not be refreshed.", e);
- return AvailabilityType.DOWN;
- }
-
- return ModclusterServerComponent.super.getAvailability();
- }
- }, 60000L); // 1 minute - the minimum interval allowed
-
- // Now that you've created your availability collector, you must start it. Once started,
- // it is assigned a thread in a thread pool and begins periodically collecting availability.
- availabilityCollector.start();
-
- super.start(context);
- }
-
- /**
- * Cleans the old resource context and the old MBean.
- * @see ResourceComponent#stop()
- */
- public void stop() {
- availabilityCollector.stop();
- super.stop();
- }
-
/* (non-Javadoc)
* @see org.rhq.plugins.jmx.MBeanResourceComponent#getAvailability()
*/
@Override
public AvailabilityType getAvailability() {
- return availabilityCollector.getLastKnownAvailability();
+ String rawProxyInfo = (String) getEmsBean().getAttribute("proxyInfo").refresh().toString();
+ ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+
+ if (proxyInfo.getAvailableContexts().size() == 0) {
+ return AvailabilityType.DOWN;
+ }
+
+ return super.getAvailability();
}
}
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
index c517364..36f490d 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
@@ -34,7 +34,7 @@ import java.util.regex.Pattern;
public class ProxyInfo {
private List<Context> availableContexts = new ArrayList<ProxyInfo.Context>();
- private Map<String, Vhost> availableVHosts = new HashMap<String, Vhost>();
+ private Map<String, Vhost> availableVhosts = new HashMap<String, Vhost>();
public ProxyInfo(String rawProxyInfo) {
Pattern vhostPattern = Pattern.compile("Vhost.*\n");
@@ -50,7 +50,7 @@ public class ProxyInfo {
String host = vhostPieces[1].trim();
host = host.substring(host.indexOf(":") + 1).trim();
- availableVHosts.put(identifier, new Vhost(identifier, host));
+ availableVhosts.put(identifier, new Vhost(identifier, host));
}
Pattern contextPattern = Pattern.compile("Context.*[\n|}]");
@@ -68,7 +68,7 @@ public class ProxyInfo {
rawIsEnabled = rawIsEnabled.substring(rawIsEnabled.indexOf(':') + 1).trim();
boolean isEnabled = rawIsEnabled.equals("ENABLED") ? true : false;
- Vhost relatedVhost = availableVHosts.get(identifier);
+ Vhost relatedVhost = availableVhosts.get(identifier);
availableContexts.add(new Context(relatedVhost.getHost(), actualContext, isEnabled));
}
@@ -78,6 +78,10 @@ public class ProxyInfo {
return Collections.unmodifiableList(availableContexts);
}
+ public List<Vhost> getAvailableVhosts() {
+ return Collections.unmodifiableList(new ArrayList<Vhost>(availableVhosts.values()));
+ }
+
private static class Vhost {
private String identifier;
private String host;
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index b7322bd..8bead55 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -72,7 +72,7 @@ public class ModclusterPluginTest {
log.info("...Loaded plugin: " + plugin);
}
} catch (Exception e) {
- e.printStackTrace();
+ log.info("Error initializing the context", e);
}
}
@@ -93,19 +93,13 @@ public class ModclusterPluginTest {
public void testDiscovery() throws Exception {
InventoryReport report = PluginContainer.getInstance().getInventoryManager().executeServerScanImmediately();
assert report != null;
- System.out.println("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+ log.info("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
- Thread.sleep(10000);
+ Thread.sleep(1000);
report = PluginContainer.getInstance().getInventoryManager().executeServiceScanImmediately();
assert report != null;
- System.out.println("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
-
- Thread.sleep(10000);
-
- report = PluginContainer.getInstance().getInventoryManager().executeServiceScanImmediately();
- assert report != null;
- System.out.println("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+ log.info("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
List<String> typeNames = new ArrayList<String>() {
{
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
index fb1ccba..8c8c6f4 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
@@ -50,10 +50,21 @@ public class ProxyInfoTest {
+ ProxyInfo.Context.class.getCanonicalName();
}
- assert (proxyInfo.getAvailableContexts().size() != 0) : "Raw proxy info parsing failed!";
+ assert (proxyInfo.getAvailableContexts().size() != 0) : "Raw proxy info parsing failed to parse application contexts!";
+ assert (proxyInfo.getAvailableVhosts().size() != 0) : "Raw proxy info parsing failed to parse vhosts!";
}
}
+ @Test
+ public void testProxyInfoWithEmptyConfig() throws IOException {
+ String testConfigurationFile = "/proxy_config/proxy_config_empty.txt";
+ String testConfiguration = readConfigFile(testConfigurationFile);
+ ProxyInfo proxyInfo = new ProxyInfo(testConfiguration);
+
+ assert (proxyInfo.getAvailableContexts().size() == 0) : "Raw proxy info parsing failed to parse an empty proxy config.";
+ assert (proxyInfo.getAvailableVhosts().size() == 0) : "Raw proxy info parsing failed to parse an empty proxy config.";
+ }
+
private String readConfigFile(String filePath) throws IOException {
StringBuffer tempBuffer = new StringBuffer();
byte[] readBuffer = new byte[1024];
commit 3de9b2c6b6d5fd3bb20104221cfb15c31a0c5207
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Jul 15 15:40:54 2011 -0500
Implemented getAvailability using the async collector because there is no guarantee when node full refreshes its configuration. The configuration is read from the httpd proxy and parsed; so network latency and number of loaded contexts influence the reload time.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index ef13143..e6495a1 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -20,6 +20,10 @@ package org.rhq.plugins.modcluster;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.pluginapi.availability.AvailabilityCollectorRunnable;
+import org.rhq.core.pluginapi.availability.AvailabilityFacet;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.plugins.jmx.MBeanResourceComponent;
@@ -29,14 +33,66 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
*/
public class ModclusterServerComponent extends MBeanResourceComponent {
+ private AvailabilityCollectorRunnable availabilityCollector;
+
+ /* (non-Javadoc)
+ * @see org.rhq.plugins.jmx.MBeanResourceComponent#start(org.rhq.core.pluginapi.inventory.ResourceContext)
+ */
@Override
- public AvailabilityType getAvailability() {
- try {
- OperationResult result = this.invokeOperation("refresh", new Configuration());
- } catch (Exception e) {
- log.info(e);
- }
+ public void start(ResourceContext context) {
+
+ availabilityCollector = context.createAvailabilityCollectorRunnable(new AvailabilityFacet() {
+ public AvailabilityType getAvailability() {
+ try {
+ OperationResult result = ModclusterServerComponent.this.invokeOperation("refresh",
+ new Configuration());
+
+ int numberOfAttempts = 0;
+
+ //The configuration should be loaded in less than 20 attempts.
+ //Only in extraneous cases (like network overload or a huge list webapp contexts)
+ //it can take more than this.
+ while (numberOfAttempts < 20) {
+ String rawProxyInfo = (String) getEmsBean().getAttribute("proxyInfo").refresh().toString();
+ ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+
+ if (proxyInfo.getAvailableContexts().size() != 0) {
+ break;
+ }
+
+ numberOfAttempts++;
+ Thread.sleep(2000);
+ }
+ } catch (Exception e) {
+ log.info("mod_cluster availability update failed. Node configuration could not be refreshed.", e);
+ return AvailabilityType.DOWN;
+ }
+
+ return ModclusterServerComponent.super.getAvailability();
+ }
+ }, 60000L); // 1 minute - the minimum interval allowed
- return super.getAvailability();
+ // Now that you've created your availability collector, you must start it. Once started,
+ // it is assigned a thread in a thread pool and begins periodically collecting availability.
+ availabilityCollector.start();
+
+ super.start(context);
+ }
+
+ /**
+ * Cleans the old resource context and the old MBean.
+ * @see ResourceComponent#stop()
+ */
+ public void stop() {
+ availabilityCollector.stop();
+ super.stop();
+ }
+
+ /* (non-Javadoc)
+ * @see org.rhq.plugins.jmx.MBeanResourceComponent#getAvailability()
+ */
+ @Override
+ public AvailabilityType getAvailability() {
+ return availabilityCollector.getLastKnownAvailability();
}
}
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index 874011a..b7322bd 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -87,7 +87,6 @@ public class ModclusterPluginTest {
PluginEnvironment pluginEnvironment = pluginManager.getPlugin(PLUGIN_NAME);
assert (pluginEnvironment != null) : "Null environment, plugin not loaded";
assert (pluginEnvironment.getPluginName().equals(PLUGIN_NAME));
-
}
@Test(dependsOnMethods = "testPluginLoad")
@@ -96,6 +95,14 @@ public class ModclusterPluginTest {
assert report != null;
System.out.println("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+ Thread.sleep(10000);
+
+ report = PluginContainer.getInstance().getInventoryManager().executeServiceScanImmediately();
+ assert report != null;
+ System.out.println("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+
+ Thread.sleep(10000);
+
report = PluginContainer.getInstance().getInventoryManager().executeServiceScanImmediately();
assert report != null;
System.out.println("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
@@ -103,7 +110,7 @@ public class ModclusterPluginTest {
List<String> typeNames = new ArrayList<String>() {
{
add(PLUGIN_NAME);
- add(PLUGIN_NAME + "_context");
+ add(PLUGIN_NAME + " Webapp Context");
}
};
diff --git a/modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_empty.txt b/modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_empty.txt
new file mode 100644
index 0000000..815b8a4
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_empty.txt
@@ -0,0 +1 @@
+{192.168.0.101/192.168.0.101:6666=null}
commit c6cf04fe0acc2d3f05a7bc028bae794b6cb34801
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 11 15:33:59 2011 -0500
A couple of small configuration and test corrections.
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index cf12b89..70a9f2b 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -60,7 +60,7 @@
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
</operation>
- <operation name="refreshProxy" displayName="Remove a proxy" description="Remove a proxy.">
+ <operation name="removeProxy" displayName="Remove a proxy" description="Remove a proxy.">
<parameters>
<c:simple-property required="true" name="host" type="string" displayName="Proxy address"/>
<c:simple-property required="true" name="port" type="string" displayName="Proxy port"/>
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
index 41bf26a..fb1ccba 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
@@ -36,7 +36,6 @@ public class ProxyInfoTest {
@Test
public void testProxyInfo() throws IOException {
-
String[] availableFiles = new String[] { "/proxy_config/proxy_config_1.txt", "/proxy_config/proxy_config_2.txt" };
for (String testConfigurationFile : availableFiles) {
@@ -44,10 +43,6 @@ public class ProxyInfoTest {
ProxyInfo proxyInfo = new ProxyInfo(testConfiguration);
for (ProxyInfo.Context context : proxyInfo.getAvailableContexts()) {
- log.info(context.toString() + " - " + context.isEnabled());
-
- log.info(proxyInfo.getAvailableContexts().indexOf(context));
-
assert (proxyInfo.getAvailableContexts().indexOf(context) != -1) : "Equals and hash functions not implemented correctly for "
+ ProxyInfo.Context.class.getCanonicalName();
commit 5c794ba6bc45e518200acc7d78f1fec86869becb
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 11 15:33:39 2011 -0500
The configuration needs to be refreshed before computing availability on all the contexts. Attempt to correctly invoke the operation.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index 783f579..ef13143 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -18,6 +18,9 @@
*/
package org.rhq.plugins.modcluster;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.plugins.jmx.MBeanResourceComponent;
/**
@@ -25,4 +28,15 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
*
*/
public class ModclusterServerComponent extends MBeanResourceComponent {
+
+ @Override
+ public AvailabilityType getAvailability() {
+ try {
+ OperationResult result = this.invokeOperation("refresh", new Configuration());
+ } catch (Exception e) {
+ log.info(e);
+ }
+
+ return super.getAvailability();
+ }
}
commit f4c3e963d2d00b2f02986ba8ea593c1aa2c02893
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 11 13:23:22 2011 -0500
Added availability attribute for contexts. Also improved unit test and coverage.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
index 922197a..8512ed5 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
@@ -21,6 +21,7 @@ package org.rhq.plugins.modcluster;
import org.mc4j.ems.connection.bean.EmsBean;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.plugins.jmx.MBeanResourceComponent;
@@ -36,18 +37,43 @@ public class ContextComponent extends MBeanResourceComponent<MBeanResourceCompon
}
@Override
+ public AvailabilityType getAvailability() {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
+ String rawProxyInfo = (String) getEmsBean().getAttribute("proxyInfo").refresh().toString();
+ ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+
+ ProxyInfo.Context context = ProxyInfo.Context.fromString(resourceContext.getResourceKey());
+
+ ProxyInfo.Context currentContext = proxyInfo.getAvailableContexts().get(
+ proxyInfo.getAvailableContexts().indexOf(context));
+
+ if (currentContext.isEnabled()) {
+ return AvailabilityType.UP;
+ }
+
+ return AvailabilityType.DOWN;
+ } catch (Exception e) {
+ log.info(e);
+ return AvailabilityType.DOWN;
+ } finally {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
+
+ @Override
public OperationResult invokeOperation(String name, Configuration parameters) throws Exception {
if ("enableContext".equals(name) || "disableContext".equals(name) || "stopContext".equals(name)) {
ProxyInfo.Context context = ProxyInfo.Context.fromString(resourceContext.getResourceKey());
- System.out.println(context.toString());
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
Object resultObject = getEmsBean().getOperation(name).invoke(
- new Object[] { context.host, context.path });
+ new Object[] { context.getHost(), context.getPath() });
return new OperationResult(String.valueOf(resultObject));
} finally {
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
index 40b24f9..c517364 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
@@ -50,9 +50,7 @@ public class ProxyInfo {
String host = vhostPieces[1].trim();
host = host.substring(host.indexOf(":") + 1).trim();
- System.out.println(identifier + "--" + host);
availableVHosts.put(identifier, new Vhost(identifier, host));
-
}
Pattern contextPattern = Pattern.compile("Context.*[\n|}]");
@@ -65,9 +63,14 @@ public class ProxyInfo {
String identifier = contextPieces[0];
identifier = identifier.substring(identifier.indexOf("[") + 1, identifier.indexOf("]"));
identifier = identifier.substring(0, identifier.lastIndexOf(":"));
+
+ String rawIsEnabled = contextPieces[2];
+ rawIsEnabled = rawIsEnabled.substring(rawIsEnabled.indexOf(':') + 1).trim();
+ boolean isEnabled = rawIsEnabled.equals("ENABLED") ? true : false;
+
Vhost relatedVhost = availableVHosts.get(identifier);
- availableContexts.add(new Context(relatedVhost.getHost(), actualContext));
+ availableContexts.add(new Context(relatedVhost.getHost(), actualContext, isEnabled));
}
}
@@ -95,12 +98,18 @@ public class ProxyInfo {
}
public static class Context {
- String path;
- String host;
+ private String path;
+ private String host;
+ private boolean isEnabled;
public Context(String host, String path) {
+ this(path, host, false);
+ }
+
+ public Context(String host, String path, boolean isEnabled) {
this.path = path;
this.host = host;
+ this.isEnabled = isEnabled;
}
public String getPath() {
@@ -111,14 +120,49 @@ public class ProxyInfo {
return host;
}
+ public boolean isEnabled() {
+ return isEnabled;
+ }
+
@Override
public String toString() {
return host + ":" + path;
}
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((host == null) ? 0 : host.hashCode());
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Context other = (Context) obj;
+ if (host == null) {
+ if (other.host != null)
+ return false;
+ } else if (!host.equals(other.host))
+ return false;
+ if (path == null) {
+ if (other.path != null)
+ return false;
+ } else if (!path.equals(other.path))
+ return false;
+ return true;
+ }
+
public static Context fromString(String stringRepresentation) {
String part[] = stringRepresentation.trim().split(":");
- return new Context(part[0], part[1]);
+ return new Context(part[1], part[0]);
}
}
}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
index be5e987..41bf26a 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
@@ -37,15 +37,26 @@ public class ProxyInfoTest {
@Test
public void testProxyInfo() throws IOException {
- String testConfiguration = readConfigFile("/proxy_config/proxy_config_1.txt");
+ String[] availableFiles = new String[] { "/proxy_config/proxy_config_1.txt", "/proxy_config/proxy_config_2.txt" };
- ProxyInfo proxyInfo = new ProxyInfo(testConfiguration);
+ for (String testConfigurationFile : availableFiles) {
+ String testConfiguration = readConfigFile(testConfigurationFile);
+ ProxyInfo proxyInfo = new ProxyInfo(testConfiguration);
- for (ProxyInfo.Context context : proxyInfo.getAvailableContexts()) {
- log.info(context.toString());
- }
+ for (ProxyInfo.Context context : proxyInfo.getAvailableContexts()) {
+ log.info(context.toString() + " - " + context.isEnabled());
+
+ log.info(proxyInfo.getAvailableContexts().indexOf(context));
+
+ assert (proxyInfo.getAvailableContexts().indexOf(context) != -1) : "Equals and hash functions not implemented correctly for "
+ + ProxyInfo.Context.class.getCanonicalName();
- assert (proxyInfo.getAvailableContexts().size() != 0) : "Raw proxy info parsing failed!";
+ assert (context.equals(ProxyInfo.Context.fromString(context.toString())) == true) : "fromString and toString are not equivalent for:"
+ + ProxyInfo.Context.class.getCanonicalName();
+ }
+
+ assert (proxyInfo.getAvailableContexts().size() != 0) : "Raw proxy info parsing failed!";
+ }
}
private String readConfigFile(String filePath) throws IOException {
diff --git a/modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_2.txt b/modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_2.txt
new file mode 100644
index 0000000..573967a
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_2.txt
@@ -0,0 +1,16 @@
+{mobile-work/192.168.1.40:6666=Node: [1],Name: 4e6189af-0502-3305-8ff3-fad7fee8b516,Balancer: mycluster,LBGroup: ,Host: 127.0.0.1,Port: 8009,Type: ajp,Flushpackets: Off,Flushwait: 10,Ping: 10,Smax: 26,Ttl: 60,Elected: 3690,Read: 27864911,Transfered: 0,Connected: 0,Load: 100
+Node: [2],Name: node2,Balancer: mycluster,LBGroup: ,Host: 127.0.0.1,Port: 8009,Type: ajp,Flushpackets: Off,Flushwait: 10,Ping: 10,Smax: 26,Ttl: 60,Elected: 148,Read: 57994,Transfered: 0,Connected: 0,Load: 100
+Vhost: [1:1:1], Alias: test-agent-1
+Vhost: [2:1:2], Alias: remote-agent-2
+Context: [1:1:1], Context: /invoker, Status: DISABLED
+Context: [1:1:2], Context: /loaddemo, Status: DISABLED
+Context: [1:1:3], Context: /jbossws, Status: DISABLED
+Context: [1:1:4], Context: /juddi, Status: DISABLED
+Context: [1:1:5], Context: /jbossmq-httpil, Status: DISABLED
+Context: [1:1:6], Context: /web-console, Status: DISABLED
+Context: [1:1:7], Context: /jmx-console, Status: DISABLED
+Context: [1:1:8], Context: /, Status: DISABLED
+Context: [2:1:9], Context: /, Status: ENABLED
+Context: [2:1:10], Context: /loaddemo, Status: ENABLED
+Context: [2:1:11], Context: /juddi, Status: ENABLED
+Context: [2:1:12], Context: /invoker, Status: ENABLED}
\ No newline at end of file
commit 066d08cc62c780b42ea8650c046eaa30efb6c9a7
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 7 16:37:41 2011 -0500
Created separate unit test suite for proxy info parser. Also, the code now parses the vhost from the actual config property.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
index f2af2bc..40b24f9 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
@@ -20,7 +20,9 @@ package org.rhq.plugins.modcluster;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -32,17 +34,40 @@ import java.util.regex.Pattern;
public class ProxyInfo {
private List<Context> availableContexts = new ArrayList<ProxyInfo.Context>();
+ private Map<String, Vhost> availableVHosts = new HashMap<String, Vhost>();
public ProxyInfo(String rawProxyInfo) {
+ Pattern vhostPattern = Pattern.compile("Vhost.*\n");
+ Matcher vhostMatcher = vhostPattern.matcher(rawProxyInfo);
+ while (vhostMatcher.find()) {
+ String rawVhost = vhostMatcher.group();
+ String[] vhostPieces = rawVhost.split(",");
- Pattern test = Pattern.compile("Context.*\n");
- Matcher m = test.matcher(rawProxyInfo);
- while (m.find()) {
- String rawContext = m.group();
+ String identifier = vhostPieces[0].trim();
+ identifier = identifier.substring(identifier.indexOf("[") + 1, identifier.indexOf("]"));
+ identifier = identifier.substring(0, identifier.lastIndexOf(":"));
+
+ String host = vhostPieces[1].trim();
+ host = host.substring(host.indexOf(":") + 1).trim();
+
+ System.out.println(identifier + "--" + host);
+ availableVHosts.put(identifier, new Vhost(identifier, host));
+
+ }
+
+ Pattern contextPattern = Pattern.compile("Context.*[\n|}]");
+ Matcher contextMatcher = contextPattern.matcher(rawProxyInfo);
+ while (contextMatcher.find()) {
+ String rawContext = contextMatcher.group();
String[] contextPieces = rawContext.split(",");
String actualContext = contextPieces[1].substring(contextPieces[1].indexOf("/")).trim();
- availableContexts.add(new Context("localhost", actualContext));
+ String identifier = contextPieces[0];
+ identifier = identifier.substring(identifier.indexOf("[") + 1, identifier.indexOf("]"));
+ identifier = identifier.substring(0, identifier.lastIndexOf(":"));
+ Vhost relatedVhost = availableVHosts.get(identifier);
+
+ availableContexts.add(new Context(relatedVhost.getHost(), actualContext));
}
}
@@ -50,6 +75,25 @@ public class ProxyInfo {
return Collections.unmodifiableList(availableContexts);
}
+ private static class Vhost {
+ private String identifier;
+ private String host;
+
+ public Vhost(String identifier, String host) {
+ this.identifier = identifier;
+ this.host = host;
+ }
+
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ }
+
public static class Context {
String path;
String host;
@@ -63,18 +107,10 @@ public class ProxyInfo {
return path;
}
- public void setPath(String path) {
- this.path = path;
- }
-
public String getHost() {
return host;
}
- public void setHost(String host) {
- this.host = host;
- }
-
@Override
public String toString() {
return host + ":" + path;
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index 0d16e92..874011a 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -47,10 +47,9 @@ import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
-import org.rhq.plugins.modcluster.ProxyInfo;
/**
- * @author Fady Matar
+ * @author Stefan Negrea
*/
@Test(groups = "modcluster-plugin")
public class ModclusterPluginTest {
@@ -83,31 +82,6 @@ public class ModclusterPluginTest {
}
@Test
- public void testProxyInfo() {
- String test = "{mobile-work/192.168.1.40:6666=Node: [1],Name: 4e6189af-0502-3305-8ff3-fad7fee8b516,Balancer: mycluster,LBGroup: ,Host: 127.0.0.1,Port: 8009,Type: ajp,Flushpackets: Off,Flushwait: 10,Ping: 10,Smax: 26,Ttl: 60,Elected: 3233,Read: 7355619,Transfered: 0,Connected: 0,Load: 100\n"
- + "Node: [2],Name: node2,Balancer: mycluster,LBGroup: ,Host: 127.0.0.1,Port: 8009,Type: ajp,Flushpackets: Off,Flushwait: 10,Ping: 10,Smax: 26,Ttl: 60,Elected: 0,Read: 0,Transfered: 0,Connected: 0,Load: 99\n"
- + "Vhost: [1:1:1], Alias: localhost\n"
- + "Vhost: [2:1:2], Alias: localhost\n"
- + "Context: [1:1:1], Context: /invoker, Status: DISABLED\n"
- + "Context: [1:1:2], Context: /loaddemo, Status: DISABLED\n"
- + "Context: [1:1:3], Context: /jbossws, Status: DISABLED\n"
- + "Context: [1:1:4], Context: /juddi, Status: DISABLED\n"
- + "Context: [1:1:5], Context: /jbossmq-httpil, Status: DISABLED\n"
- + "Context: [1:1:6], Context: /web-console, Status: DISABLED\n"
- + "Context: [1:1:7], Context: /jmx-console, Status: DISABLED\n"
- + "Context: [1:1:8], Context: /, Status: DISABLED\n"
- + "Context: [2:1:9], Context: /loaddemo, Status: ENABLED\n" + "}";
-
- ProxyInfo proxyInfo = new ProxyInfo(test);
-
- for (ProxyInfo.Context context : proxyInfo.getAvailableContexts()) {
- log.info(context.toString());
- }
-
- assert (proxyInfo.getAvailableContexts().size() != 0) : "Raw proxy info parsing failed!";
- }
-
- @Test
public void testPluginLoad() {
PluginManager pluginManager = PluginContainer.getInstance().getPluginManager();
PluginEnvironment pluginEnvironment = pluginManager.getPlugin(PLUGIN_NAME);
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
new file mode 100644
index 0000000..be5e987
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
@@ -0,0 +1,66 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.testng.annotations.Test;
+
+import org.rhq.plugins.modcluster.ProxyInfo;
+
+/**
+ * @author Stefan Negrea
+ */
+@Test(groups = "modcluster-plugin")
+public class ProxyInfoTest {
+ private Log log = LogFactory.getLog(this.getClass());
+
+ @Test
+ public void testProxyInfo() throws IOException {
+
+ String testConfiguration = readConfigFile("/proxy_config/proxy_config_1.txt");
+
+ ProxyInfo proxyInfo = new ProxyInfo(testConfiguration);
+
+ for (ProxyInfo.Context context : proxyInfo.getAvailableContexts()) {
+ log.info(context.toString());
+ }
+
+ assert (proxyInfo.getAvailableContexts().size() != 0) : "Raw proxy info parsing failed!";
+ }
+
+ private String readConfigFile(String filePath) throws IOException {
+ StringBuffer tempBuffer = new StringBuffer();
+ byte[] readBuffer = new byte[1024];
+ int bytesRead = 0;
+
+ InputStream resourceStream = getClass().getResourceAsStream(filePath);
+
+ while ((bytesRead = resourceStream.read(readBuffer)) != -1) {
+ tempBuffer.append(new String(readBuffer, 0, bytesRead));
+ }
+
+ resourceStream.close();
+
+ return tempBuffer.toString();
+ }
+}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_1.txt b/modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_1.txt
new file mode 100644
index 0000000..c99edd3
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_1.txt
@@ -0,0 +1,13 @@
+{mobile-work/192.168.1.40:6666=Node: [1],Name: 4e6189af-0502-3305-8ff3-fad7fee8b516,Balancer: mycluster,LBGroup: ,Host: 127.0.0.1,Port: 8009,Type: ajp,Flushpackets: Off,Flushwait: 10,Ping: 10,Smax: 26,Ttl: 60,Elected: 3233,Read: 7355619,Transfered: 0,Connected: 0,Load: 100
+Node: [2],Name: node2,Balancer: mycluster,LBGroup: ,Host: 127.0.0.1,Port: 8009,Type: ajp,Flushpackets: Off,Flushwait: 10,Ping: 10,Smax: 26,Ttl: 60,Elected: 0,Read: 0,Transfered: 0,Connected: 0,Load: 99
+Vhost: [1:1:1], Alias: localhost
+Vhost: [2:1:2], Alias: localhost
+Context: [1:1:1], Context: /invoker, Status: DISABLED
+Context: [1:1:2], Context: /loaddemo, Status: DISABLED
+Context: [1:1:3], Context: /jbossws, Status: DISABLED
+Context: [1:1:4], Context: /juddi, Status: DISABLED
+Context: [1:1:5], Context: /jbossmq-httpil, Status: DISABLED
+Context: [1:1:6], Context: /web-console, Status: DISABLED
+Context: [1:1:7], Context: /jmx-console, Status: DISABLED
+Context: [1:1:8], Context: /, Status: DISABLED
+Context: [2:1:9], Context: /loaddemo, Status: ENABLED}
\ No newline at end of file
commit a6eeb51869e48dc230cd206d7f25eb815538b2bf
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 7 13:27:01 2011 -0600
Fine tunning the plugin based on UI testing.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
index fb72b5f..f2af2bc 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
@@ -77,7 +77,7 @@ public class ProxyInfo {
@Override
public String toString() {
- return path + ":" + host;
+ return host + ":" + path;
}
public static Context fromString(String stringRepresentation) {
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 88357db..cf12b89 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -80,15 +80,14 @@
<c:simple-property name="advertise" type="boolean" description="Enable autodiscovery of httpd servers."/>
<c:simple-property name="smax" type="integer" description="Maximum time on seconds for idle connections above smax."/>
<c:simple-property name="maxAttempts" type="integer" description="Maximum number of attempts to send the request to the backend server."/>
- <c:simple-property name="advertiseSecurityKey" type="integer" description="Security key for discovery."/>
+ <c:simple-property name="advertiseSecurityKey" type="string" required="false" description="Security key for discovery."/>
<c:simple-property name="stickySessionForce" type="boolean" description="Return an error when the request cannot be routed to the right node."/>
- <c:simple-property name="balancer" type="string" description="Name of the balancer."/>
+ <c:simple-property name="balancer" type="string" required="false" description="Name of the balancer."/>
<c:simple-property name="flushPackets" type="boolean" description="Allows controlling flusing of packets."/>
- <c:simple-property name="socketTimeout" type="integer" description="Connection timeout for communication with the proxy." />
- <c:simple-property name="containerName" type="string" description="Object name of the container."/>
- <c:simple-property name="domain" type="string" description="Domain parameter, which allows tying a jvmRoute to a particular domain."/>
- <c:simple-property name="advertisePort" type="integer" description="Multicast port for discovery" />
- <c:simple-property name="advertiseGroupAddress" type="string" description="Multicast address for discovery."/>
+ <c:simple-property name="socketTimeout" type="integer" description="Connection timeout for communication with the proxy." />
+ <c:simple-property name="domain" type="string" required="false" description="Domain parameter, which allows tying a jvmRoute to a particular domain."/>
+ <c:simple-property name="advertisePort" type="integer" required="false" description="Multicast port for discovery" />
+ <c:simple-property name="advertiseGroupAddress" type="string" required="false" description="Multicast address for discovery."/>
<c:simple-property name="flushWait" type="integer" description="Time in ms to wait before flushing packets."/>
<c:simple-property name="ping" type="integer" description="Time in s to wait for a pong answer to a ping."/>
</resource-configuration>
commit c294e9ec57a4be4d969d8fa453e353f1f39fda8a
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 7 10:38:53 2011 -0600
Changed the name of context objects to the proposed short notation.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
index 9cb6b86..fb72b5f 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
@@ -42,7 +42,7 @@ public class ProxyInfo {
String[] contextPieces = rawContext.split(",");
String actualContext = contextPieces[1].substring(contextPieces[1].indexOf("/")).trim();
- availableContexts.add(new Context(actualContext, "localhost"));
+ availableContexts.add(new Context("localhost", actualContext));
}
}
@@ -54,7 +54,7 @@ public class ProxyInfo {
String path;
String host;
- public Context(String path, String host) {
+ public Context(String host, String path) {
this.path = path;
this.host = host;
}
@@ -77,25 +77,12 @@ public class ProxyInfo {
@Override
public String toString() {
- return "Context [path=" + path + ", host=" + host + "]";
+ return path + ":" + host;
}
public static Context fromString(String stringRepresentation) {
- stringRepresentation = stringRepresentation.substring(stringRepresentation.indexOf('[') + 1);
- stringRepresentation = stringRepresentation.substring(0, stringRepresentation.indexOf(']'));
- stringRepresentation = stringRepresentation.trim();
-
- String host = null;
- String path = null;
- for (String part : stringRepresentation.split(",")) {
- part = part.trim();
- if (part.startsWith("path=")) {
- path = part.substring(5).trim();
- } else if (part.startsWith("host=")) {
- host = part.substring(5).trim();
- }
- }
- return new Context(path, host);
+ String part[] = stringRepresentation.trim().split(":");
+ return new Context(part[0], part[1]);
}
}
}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index ad23d34..88357db 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -74,7 +74,7 @@
<metric property="className" displayName="Fully qualified class name of the managed object" displayType="summary" dataType="trait" />
<resource-configuration>
- <c:simple-property name="workerTimeout" type="integer" description="Timeout to wait for an available worker (default is no wait)"
+ <c:simple-property name="workerTimeout" type="integer" description="Timeout to wait for an available worker (default is no wait)" />
<c:simple-property name="stickySession" type="boolean" description="Enables sticky session for the cluster."/>
<c:simple-property name="stickySessionRemove" type="boolean" description="Remove session when the request cannot be routed to the right node."/>
<c:simple-property name="advertise" type="boolean" description="Enable autodiscovery of httpd servers."/>
@@ -83,7 +83,7 @@
<c:simple-property name="advertiseSecurityKey" type="integer" description="Security key for discovery."/>
<c:simple-property name="stickySessionForce" type="boolean" description="Return an error when the request cannot be routed to the right node."/>
<c:simple-property name="balancer" type="string" description="Name of the balancer."/>
- <c:simple-property name="flushPackets" type="boolean" descritpion="Allows controlling flusing of packets."/>
+ <c:simple-property name="flushPackets" type="boolean" description="Allows controlling flusing of packets."/>
<c:simple-property name="socketTimeout" type="integer" description="Connection timeout for communication with the proxy." />
<c:simple-property name="containerName" type="string" description="Object name of the container."/>
<c:simple-property name="domain" type="string" description="Domain parameter, which allows tying a jvmRoute to a particular domain."/>
commit 70f87fe4818e8a4b6dbef2c479aacf992bb71df7
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 7 10:23:06 2011 -0600
Added support for all the mod_cluster available operations.
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 17a4267..ad23d34 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -27,41 +27,70 @@
<c:simple-property name="nameTemplate" default="mod_cluster"/>
</plugin-configuration>
- <operation name="reset" displayName="Reset the node" description="Move the node out of an error state" />
- <operation name="refresh" displayName="Refresh configuration" description="Refresh configuration" />
- <operation name="enable" displayName="Enable all webapps" description="Enable all webapps for all engines">
+ <operation name="stop" displayName="Stop all webapps" description="Gracefully stops all webapps for all engines.">
+ <parameters>
+ <c:simple-property required="true" name="timeout" type="string" displayName="Session draining timeout"/>
+ <c:simple-property required="true" name="unit" default="MILLISECONDS" displayName="Time unit of the timeout parameter">
+ <c:property-options allowCustomValue="false">
+ <c:option value="MICROSECONDS" name="MICROSECONDS"/>
+ <c:option value="MILLISECONDS" name="MILLISECONDS"/>
+ <c:option value="NANOSECONDS" name="NANOSECONDS"/>
+ <c:option value="SECONDS" name="SECONDS"/>
+ </c:property-options>
+ </c:simple-property>
+ </parameters>
+ <results>
+ <c:simple-property name="result" type="boolean" description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="addProxy" displayName="Add a proxy" description="Add a proxy.">
+ <parameters>
+ <c:simple-property required="true" name="host" type="string" displayName="Proxy address"/>
+ <c:simple-property required="true" name="port" type="string" displayName="Proxy port"/>
+ </parameters>
+ </operation>
+ <operation name="enable" displayName="Enable all webapps" description="Enable all webapps for all engines">
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
- </operation>
- <operation name="disable" displayName="Disable all webpapps" description="Disable all webapps for all engines">
+ </operation>
+ <operation name="reset" displayName="Reset the node" description="Move the node out of an error state." />
+ <operation name="disable" displayName="Disable all webpapps" description="Disable all webapps for all engines.">
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
</operation>
+ <operation name="refreshProxy" displayName="Remove a proxy" description="Remove a proxy.">
+ <parameters>
+ <c:simple-property required="true" name="host" type="string" displayName="Proxy address"/>
+ <c:simple-property required="true" name="port" type="string" displayName="Proxy port"/>
+ </parameters>
+ </operation>
+ <operation name="refresh" displayName="Refresh configuration" description="Refresh configuration" />
+
<metric property="proxyConfiguration" displayName="Proxy Configuration" displayType="summary" dataType="trait" />
<metric property="modelerType" displayName="Type of the modeled resource" displayType="summary" dataType="trait" />
<metric property="className" displayName="Fully qualified class name of the managed object" displayType="summary" dataType="trait" />
<resource-configuration>
- <c:simple-property name="workerTimeout" type="int" description="Timeout to wait for an available worker (default is no wait)"
+ <c:simple-property name="workerTimeout" type="integer" description="Timeout to wait for an available worker (default is no wait)"
<c:simple-property name="stickySession" type="boolean" description="Enables sticky session for the cluster."/>
<c:simple-property name="stickySessionRemove" type="boolean" description="Remove session when the request cannot be routed to the right node."/>
<c:simple-property name="advertise" type="boolean" description="Enable autodiscovery of httpd servers."/>
- <c:simple-property name="smax" type="int" description="Maximum time on seconds for idle connections above smax."/>
- <c:simple-property name="maxAttempts" type="int" description="Maximum number of attempts to send the request to the backend server."/>
- <c:simple-property name="advertiseSecurityKey" type="int" description="Security key for discovery."/>
+ <c:simple-property name="smax" type="integer" description="Maximum time on seconds for idle connections above smax."/>
+ <c:simple-property name="maxAttempts" type="integer" description="Maximum number of attempts to send the request to the backend server."/>
+ <c:simple-property name="advertiseSecurityKey" type="integer" description="Security key for discovery."/>
<c:simple-property name="stickySessionForce" type="boolean" description="Return an error when the request cannot be routed to the right node."/>
<c:simple-property name="balancer" type="string" description="Name of the balancer."/>
<c:simple-property name="flushPackets" type="boolean" descritpion="Allows controlling flusing of packets."/>
- <c:simple-property name="socketTimeout" type="int" description="Connection timeout for communication with the proxy." />
+ <c:simple-property name="socketTimeout" type="integer" description="Connection timeout for communication with the proxy." />
<c:simple-property name="containerName" type="string" description="Object name of the container."/>
<c:simple-property name="domain" type="string" description="Domain parameter, which allows tying a jvmRoute to a particular domain."/>
- <c:simple-property name="advertisePort" type="int" description="Multicast port for discovery" />
+ <c:simple-property name="advertisePort" type="integer" description="Multicast port for discovery" />
<c:simple-property name="advertiseGroupAddress" type="string" description="Multicast address for discovery."/>
- <c:simple-property name="flushWait" type="int" description="Time in ms to wait before flushing packets."/>
- <c:simple-property name="ping" type="int" description="Time in s to wait for a pong answer to a ping"/>
+ <c:simple-property name="flushWait" type="integer" description="Time in ms to wait before flushing packets."/>
+ <c:simple-property name="ping" type="integer" description="Time in s to wait for a pong answer to a ping."/>
</resource-configuration>
<service name="mod_cluster Webapp Context"
@@ -69,19 +98,30 @@
class="ContextComponent"
description="A mod_cluster context">
- <operation name="enableContext" displayName="Enable webapp" description="Enable this webapp">
+ <operation name="disableContext" displayName="Disable webapp" description="Disable this webapp.">
<results>
- <c:simple-property name="result" type="boolean" description="The result of the operation" />
+ <c:simple-property name="result" type="boolean" description="The result of the operation."/>
</results>
</operation>
- <operation name="disableContext" displayName="Disable webapp" description="Disable this webapp">
+ <operation name="stopContext" displayName="Stop webapp" description="Gracefully stops this webapp.">
+ <parameters>
+ <c:simple-property required="true" name="timeout" type="integer" displayName="Session draining timeout"/>
+ <c:simple-property required="true" name="unit" default="MILLISECONDS" displayName="Time unit of the timeout parameter">
+ <c:property-options allowCustomValue="false">
+ <c:option value="MICROSECONDS" name="MICROSECONDS"/>
+ <c:option value="MILLISECONDS" name="MILLISECONDS"/>
+ <c:option value="NANOSECONDS" name="NANOSECONDS"/>
+ <c:option value="SECONDS" name="SECONDS"/>
+ </c:property-options>
+ </c:simple-property>
+ </parameters>
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
</operation>
- <operation name="stopContext" displayName="Stop webapp" description="Gracefully stops this webapp.">
+ <operation name="enableContext" displayName="Enable webapp" description="Enable this webapp.">
<results>
- <c:simple-property name="result" type="boolean" description="The result of the operation" />
+ <c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
</operation>
commit 2342ca9a222b3aae20a890d084a7855ce4ff02fd
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 7 09:49:10 2011 -0600
Added all the properties available through the JMX interface to the plugin configuration.
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index b2179c3..17a4267 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -45,9 +45,23 @@
<metric property="className" displayName="Fully qualified class name of the managed object" displayType="summary" dataType="trait" />
<resource-configuration>
- <c:simple-property name="stickySessions" type="boolean" description="Enables sticky sessions."/>
+ <c:simple-property name="workerTimeout" type="int" description="Timeout to wait for an available worker (default is no wait)"
+ <c:simple-property name="stickySession" type="boolean" description="Enables sticky session for the cluster."/>
<c:simple-property name="stickySessionRemove" type="boolean" description="Remove session when the request cannot be routed to the right node."/>
<c:simple-property name="advertise" type="boolean" description="Enable autodiscovery of httpd servers."/>
+ <c:simple-property name="smax" type="int" description="Maximum time on seconds for idle connections above smax."/>
+ <c:simple-property name="maxAttempts" type="int" description="Maximum number of attempts to send the request to the backend server."/>
+ <c:simple-property name="advertiseSecurityKey" type="int" description="Security key for discovery."/>
+ <c:simple-property name="stickySessionForce" type="boolean" description="Return an error when the request cannot be routed to the right node."/>
+ <c:simple-property name="balancer" type="string" description="Name of the balancer."/>
+ <c:simple-property name="flushPackets" type="boolean" descritpion="Allows controlling flusing of packets."/>
+ <c:simple-property name="socketTimeout" type="int" description="Connection timeout for communication with the proxy." />
+ <c:simple-property name="containerName" type="string" description="Object name of the container."/>
+ <c:simple-property name="domain" type="string" description="Domain parameter, which allows tying a jvmRoute to a particular domain."/>
+ <c:simple-property name="advertisePort" type="int" description="Multicast port for discovery" />
+ <c:simple-property name="advertiseGroupAddress" type="string" description="Multicast address for discovery."/>
+ <c:simple-property name="flushWait" type="int" description="Time in ms to wait before flushing packets."/>
+ <c:simple-property name="ping" type="int" description="Time in s to wait for a pong answer to a ping"/>
</resource-configuration>
<service name="mod_cluster Webapp Context"
@@ -55,17 +69,17 @@
class="ContextComponent"
description="A mod_cluster context">
- <operation name="enableContext" displayName="Enable webapp" description="Enable the webapp">
+ <operation name="enableContext" displayName="Enable webapp" description="Enable this webapp">
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
</operation>
- <operation name="disableContext" displayName="Disable webpapp" description="Disable the webapp">
+ <operation name="disableContext" displayName="Disable webapp" description="Disable this webapp">
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
</operation>
- <operation name="stopContext" displayName="Stop webpapp" description="Gracefully stops the webapp">
+ <operation name="stopContext" displayName="Stop webapp" description="Gracefully stops this webapp.">
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
commit 526d7241227292380f1ccd644d5f3e0b41eda7d3
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Jul 6 15:28:48 2011 -0500
A couple more tweaks to make the user interface for mod_cluster display correct and proper text.
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index cdfa7fb..b2179c3 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -24,7 +24,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="Catalina:type=ModClusterListener,*"/>
- <c:simple-property name="nameTemplate" default="{application}"/>
+ <c:simple-property name="nameTemplate" default="mod_cluster"/>
</plugin-configuration>
<operation name="reset" displayName="Reset the node" description="Move the node out of an error state" />
@@ -50,22 +50,22 @@
<c:simple-property name="advertise" type="boolean" description="Enable autodiscovery of httpd servers."/>
</resource-configuration>
- <service name="mod_cluster_context"
+ <service name="mod_cluster Webapp Context"
discovery="ContextDiscoveryComponent"
class="ContextComponent"
description="A mod_cluster context">
- <operation name="enableContext" displayName="Enable webapp" description="Enable a single webapp">
+ <operation name="enableContext" displayName="Enable webapp" description="Enable the webapp">
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
</operation>
- <operation name="disableContext" displayName="Disable webpapp" description="Disable a single webapp">
+ <operation name="disableContext" displayName="Disable webpapp" description="Disable the webapp">
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
</operation>
- <operation name="stopContext" displayName="Stop webpapp" description="Gracefully stops a single webapp">
+ <operation name="stopContext" displayName="Stop webpapp" description="Gracefully stops the webapp">
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
commit 4a6bb37c939ba001b3be6774cf89d1ec409f2827
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Jul 6 13:19:07 2011 -0500
Fine tuning the plugin configuration based other plugin configuration and test deployment issues.
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml
index 74defeb..4536125 100644
--- a/modules/plugins/mod-cluster/pom.xml
+++ b/modules/plugins/mod-cluster/pom.xml
@@ -12,7 +12,7 @@
<artifactId>modcluster-plugin</artifactId>
<packaging>jar</packaging>
- <name>mod_cluster RHQ Plugin</name>
+ <name>RHQ mod_cluster Plugin</name>
<description>mod_cluster RHQ Agent plugin</description>
<dependencies>
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index be4b25b..cdfa7fb 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -14,11 +14,12 @@
discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
class="ModclusterServerComponent"
supportsManualAdd="true"
- description="mod_cluster plugin">
+ description="mod_cluster plugin"
+ singleton="true">
<runs-inside>
<parent-resource-type name="JBossAS Server" plugin="JBossAS"/>
- <parent-resource-type name="JBossAS Server" plugin="JBossAS5"/>
+ <parent-resource-type name="JBossAS5 Server" plugin="JBossAS5"/>
</runs-inside>
<plugin-configuration>
diff --git a/modules/plugins/pom.xml b/modules/plugins/pom.xml
index 02f6584..f32159e 100644
--- a/modules/plugins/pom.xml
+++ b/modules/plugins/pom.xml
@@ -125,10 +125,11 @@
<module>augeas</module>
<module>apache</module>
<module>tomcat</module>
- <module>jboss-as</module>
<module>hibernate</module>
+ <module>mod-cluster</module>
<module>rhq-server</module>
<module>jboss-cache</module>
+ <module>jboss-as</module>
<module>jboss-as-5</module>
<module>jboss-as-7</module>
<module>jboss-cache-v3</module>
commit 20f0f36e49fa935deafed1fc2ac057f7e480dd9a
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Jul 6 10:00:21 2011 -0500
Added dev profile for plugin deployment in the local plugin repo.
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml
index a19dfc0..74defeb 100644
--- a/modules/plugins/mod-cluster/pom.xml
+++ b/modules/plugins/mod-cluster/pom.xml
@@ -190,6 +190,82 @@
</plugins>
</build>
</profile>
+
+
+ <profile>
+ <id>dev</id>
+
+ <properties>
+ <rhq.rootDir>../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-plugins</rhq.deploymentDir>
+ </properties>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${rhq.deploymentDir}" />
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>deploy-jar-meta-inf</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating META-INF dir in ${deployment.file}...</echo>
+ <unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.outputDirectory}">
+ <patternset><include name="META-INF/**" /></patternset>
+ </unjar>
+ <jar destfile="${deployment.file}" manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF" update="true">
+ </jar>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+
</profiles>
</project>
commit 4ee3094d6e29330d68730729edaa04e4a85cc81d
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 5 23:31:24 2011 -0500
All the context dependent operations are now passed for execution to the parent MBean. The operation arguments are parsed from the proxyInfo MBean property.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
index f73a151..922197a 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
@@ -1,24 +1,20 @@
/*
- * Jopr Management Platform
+ * RHQ Management Platform
* Copyright (C) 2005-2008 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
+ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package org.rhq.plugins.modcluster;
@@ -29,10 +25,9 @@ import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.plugins.jmx.MBeanResourceComponent;
/**
- * Manages a Hibernate Entity.
+ * Manages a mod_cluster context entity.
*
- * @author Greg Hinkle
- * @author John Mazzitelli
+ * @author Stefan Negrea
*/
public class ContextComponent extends MBeanResourceComponent<MBeanResourceComponent> {
@Override
@@ -42,46 +37,24 @@ public class ContextComponent extends MBeanResourceComponent<MBeanResourceCompon
@Override
public OperationResult invokeOperation(String name, Configuration parameters) throws Exception {
- if ("enableContext".equals(name)) {
- //String[] queryStrings = (String[]) getEmsBean().getAttribute("Queries").refresh();
- OperationResult result = new OperationResult();
- result.setSimpleResult("This works!");
- /*PropertyList queries = new PropertyList("queries");
- result.getComplexResults().put(queries);*/
+ if ("enableContext".equals(name) || "disableContext".equals(name) || "stopContext".equals(name)) {
+
+ ProxyInfo.Context context = ProxyInfo.Context.fromString(resourceContext.getResourceKey());
+ System.out.println(context.toString());
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
- /*Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
- for (String queryString : queryStrings) {
- Object queryStatistics = getEmsBean().getOperation("getQueryStatistics").invoke(
- new Object[] { queryString });
-
- Long executionCount = (Long) queryStatistics.getClass().getMethod("getExecutionCount")
- .invoke(queryStatistics);
- Long executionRowCount = (Long) queryStatistics.getClass().getMethod("getExecutionRowCount")
- .invoke(queryStatistics);
- Long executionMinTime = (Long) queryStatistics.getClass().getMethod("getExecutionMinTime")
- .invoke(queryStatistics);
- Long executionMaxTime = (Long) queryStatistics.getClass().getMethod("getExecutionMaxTime")
- .invoke(queryStatistics);
- Long executionAvgTime = (Long) queryStatistics.getClass().getMethod("getExecutionAvgTime")
- .invoke(queryStatistics);
-
- PropertyMap query = new PropertyMap("query", new PropertySimple("query", queryString),
- new PropertySimple("executionCount", executionCount), new PropertySimple("executionRowCount",
- executionRowCount), new PropertySimple("executionMinTime", executionMinTime),
- new PropertySimple("executionMaxTime", executionMaxTime), new PropertySimple(
- "executionAvgTime", executionAvgTime));
+ Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
- queries.add(query);
- }*/
+ Object resultObject = getEmsBean().getOperation(name).invoke(
+ new Object[] { context.host, context.path });
- return result;
+ return new OperationResult(String.valueOf(resultObject));
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
}
- return super.invokeOperation(name, parameters);
+ throw new Exception("Operation " + name + " not available mod_cluster_context service");
}
}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
index 90e5c6b..4b3adcd 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
@@ -33,11 +33,15 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.jmx.MBeanResourceComponent;
/**
- * Discovers hibernate entities from a hibernate stats mbean
+ * Discovers mod_cluster contexts from the proxyInfo mbean property.
*
- * @author Greg Hinkle
+ * @author Stefan Negrea
*/
public class ContextDiscoveryComponent implements ResourceDiscoveryComponent<MBeanResourceComponent> {
+
+ /* (non-Javadoc)
+ * @see org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext)
+ */
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<MBeanResourceComponent> context) {
Set<DiscoveredResourceDetails> entities = new HashSet<DiscoveredResourceDetails>();
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
index 15a9a68..9cb6b86 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
@@ -16,7 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
package org.rhq.plugins.modcluster;
import java.util.ArrayList;
@@ -25,16 +24,17 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+/**
+ * Simple parser for the raw proxy information provided by mod_cluster.
+ *
+ * @author Stefan Negrea
+ */
public class ProxyInfo {
private List<Context> availableContexts = new ArrayList<ProxyInfo.Context>();
public ProxyInfo(String rawProxyInfo) {
- System.out.println("--------------------------------------");
- System.out.println(rawProxyInfo);
- System.out.println("--------------------------------------");
-
Pattern test = Pattern.compile("Context.*\n");
Matcher m = test.matcher(rawProxyInfo);
while (m.find()) {
@@ -42,7 +42,7 @@ public class ProxyInfo {
String[] contextPieces = rawContext.split(",");
String actualContext = contextPieces[1].substring(contextPieces[1].indexOf("/")).trim();
- availableContexts.add(new Context(actualContext, "localHost"));
+ availableContexts.add(new Context(actualContext, "localhost"));
}
}
@@ -50,12 +50,11 @@ public class ProxyInfo {
return Collections.unmodifiableList(availableContexts);
}
- public class Context {
+ public static class Context {
String path;
String host;
public Context(String path, String host) {
- super();
this.path = path;
this.host = host;
}
@@ -80,5 +79,23 @@ public class ProxyInfo {
public String toString() {
return "Context [path=" + path + ", host=" + host + "]";
}
+
+ public static Context fromString(String stringRepresentation) {
+ stringRepresentation = stringRepresentation.substring(stringRepresentation.indexOf('[') + 1);
+ stringRepresentation = stringRepresentation.substring(0, stringRepresentation.indexOf(']'));
+ stringRepresentation = stringRepresentation.trim();
+
+ String host = null;
+ String path = null;
+ for (String part : stringRepresentation.split(",")) {
+ part = part.trim();
+ if (part.startsWith("path=")) {
+ path = part.substring(5).trim();
+ } else if (part.startsWith("host=")) {
+ host = part.substring(5).trim();
+ }
+ }
+ return new Context(path, host);
+ }
}
}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 084165e..be4b25b 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -45,6 +45,8 @@
<resource-configuration>
<c:simple-property name="stickySessions" type="boolean" description="Enables sticky sessions."/>
+ <c:simple-property name="stickySessionRemove" type="boolean" description="Remove session when the request cannot be routed to the right node."/>
+ <c:simple-property name="advertise" type="boolean" description="Enable autodiscovery of httpd servers."/>
</resource-configuration>
<service name="mod_cluster_context"
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index deceb70..0d16e92 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -140,8 +140,14 @@ public class ModclusterPluginTest {
assert (resources.size() != 0) : "No mod_cluster or related instances found.";
if (resources.size() != 0) {
- testResourceMeasurement((Resource) resources.toArray()[0]);
- testContextOperations((Resource) resources.toArray()[1]);
+ for (Object objectResource : resources.toArray()) {
+ Resource resource = (Resource) objectResource;
+ if (resource.getResourceType().getName().equals("mod_cluster")) {
+ testResourceMeasurement(resource);
+ } else {
+ testContextOperations(resource);
+ }
+ }
}
}
@@ -175,9 +181,12 @@ public class ModclusterPluginTest {
.getResourceComponent(resource);
if (resourceComponent instanceof OperationFacet) {
- OperationResult result = ((OperationFacet) resourceComponent).invokeOperation("enableContext", null);
- log.info("Result of operation " + "enableContext" + " was: " + result.getSimpleResult());
-
+ try {
+ OperationResult result = ((OperationFacet) resourceComponent).invokeOperation("enableContext", null);
+ log.info("Result of operation " + "enableContext" + " was: " + result.getSimpleResult());
+ } catch (Exception e) {
+ log.info("Operation failed");
+ }
/*result = ((OperationFacet) resourceComponent).invokeOperation("disable", null);
log.info("Result of operation test was: " + result.getSimpleResult());*/
}
commit 821df1aa30368c6d97eacad1401a52295e6d2181
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 5 18:43:06 2011 -0500
Added individual contexts as sub services to mod_cluster service.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
new file mode 100644
index 0000000..f73a151
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
@@ -0,0 +1,87 @@
+/*
+ * Jopr Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import org.mc4j.ems.connection.bean.EmsBean;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
+
+/**
+ * Manages a Hibernate Entity.
+ *
+ * @author Greg Hinkle
+ * @author John Mazzitelli
+ */
+public class ContextComponent extends MBeanResourceComponent<MBeanResourceComponent> {
+ @Override
+ protected EmsBean loadBean() {
+ return getResourceContext().getParentResourceComponent().getEmsBean();
+ }
+
+ @Override
+ public OperationResult invokeOperation(String name, Configuration parameters) throws Exception {
+ if ("enableContext".equals(name)) {
+ //String[] queryStrings = (String[]) getEmsBean().getAttribute("Queries").refresh();
+ OperationResult result = new OperationResult();
+ result.setSimpleResult("This works!");
+ /*PropertyList queries = new PropertyList("queries");
+ result.getComplexResults().put(queries);*/
+
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try {
+ /*Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
+ for (String queryString : queryStrings) {
+ Object queryStatistics = getEmsBean().getOperation("getQueryStatistics").invoke(
+ new Object[] { queryString });
+
+ Long executionCount = (Long) queryStatistics.getClass().getMethod("getExecutionCount")
+ .invoke(queryStatistics);
+ Long executionRowCount = (Long) queryStatistics.getClass().getMethod("getExecutionRowCount")
+ .invoke(queryStatistics);
+ Long executionMinTime = (Long) queryStatistics.getClass().getMethod("getExecutionMinTime")
+ .invoke(queryStatistics);
+ Long executionMaxTime = (Long) queryStatistics.getClass().getMethod("getExecutionMaxTime")
+ .invoke(queryStatistics);
+ Long executionAvgTime = (Long) queryStatistics.getClass().getMethod("getExecutionAvgTime")
+ .invoke(queryStatistics);
+
+ PropertyMap query = new PropertyMap("query", new PropertySimple("query", queryString),
+ new PropertySimple("executionCount", executionCount), new PropertySimple("executionRowCount",
+ executionRowCount), new PropertySimple("executionMinTime", executionMinTime),
+ new PropertySimple("executionMaxTime", executionMaxTime), new PropertySimple(
+ "executionAvgTime", executionAvgTime));
+
+ queries.add(query);
+ }*/
+
+ return result;
+ } finally {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
+
+ return super.invokeOperation(name, parameters);
+ }
+}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
new file mode 100644
index 0000000..90e5c6b
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
@@ -0,0 +1,57 @@
+/*
+ * Jopr Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.mc4j.ems.connection.bean.EmsBean;
+
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
+
+/**
+ * Discovers hibernate entities from a hibernate stats mbean
+ *
+ * @author Greg Hinkle
+ */
+public class ContextDiscoveryComponent implements ResourceDiscoveryComponent<MBeanResourceComponent> {
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<MBeanResourceComponent> context) {
+ Set<DiscoveredResourceDetails> entities = new HashSet<DiscoveredResourceDetails>();
+
+ EmsBean statsBean = context.getParentResourceComponent().getEmsBean();
+
+ String rawProxyInfo = (String) statsBean.getAttribute("proxyInfo").refresh().toString();
+ ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+
+ for (ProxyInfo.Context availableContext : proxyInfo.getAvailableContexts()) {
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(context.getResourceType(),
+ availableContext.toString(), availableContext.toString(), null, "mod_cluster Context", null, null);
+ entities.add(detail);
+ }
+
+ return entities;
+ }
+}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index a98792e..783f579 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -18,9 +18,6 @@
*/
package org.rhq.plugins.modcluster;
-import org.rhq.core.domain.operation.OperationDefinition;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.plugins.jmx.MBeanResourceComponent;
/**
@@ -28,16 +25,4 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
*
*/
public class ModclusterServerComponent extends MBeanResourceComponent {
-
- /**
- * Stores the context and loads the MBean.
- * @see ResourceComponent#start(ResourceContext)
- */
- @Override
- public void start(ResourceContext context) {
- super.start(context);
-
- OperationDefinition test = new OperationDefinition(context.getResourceType(), "Text");
- context.getResourceType().addOperationDefinition(test);
- }
}
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
new file mode 100644
index 0000000..15a9a68
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
@@ -0,0 +1,84 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.modcluster;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class ProxyInfo {
+
+ private List<Context> availableContexts = new ArrayList<ProxyInfo.Context>();
+
+ public ProxyInfo(String rawProxyInfo) {
+
+ System.out.println("--------------------------------------");
+ System.out.println(rawProxyInfo);
+ System.out.println("--------------------------------------");
+
+ Pattern test = Pattern.compile("Context.*\n");
+ Matcher m = test.matcher(rawProxyInfo);
+ while (m.find()) {
+ String rawContext = m.group();
+ String[] contextPieces = rawContext.split(",");
+ String actualContext = contextPieces[1].substring(contextPieces[1].indexOf("/")).trim();
+
+ availableContexts.add(new Context(actualContext, "localHost"));
+ }
+ }
+
+ public List<Context> getAvailableContexts() {
+ return Collections.unmodifiableList(availableContexts);
+ }
+
+ public class Context {
+ String path;
+ String host;
+
+ public Context(String path, String host) {
+ super();
+ this.path = path;
+ this.host = host;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ @Override
+ public String toString() {
+ return "Context [path=" + path + ", host=" + host + "]";
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index b8d7249..084165e 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -47,5 +47,29 @@
<c:simple-property name="stickySessions" type="boolean" description="Enables sticky sessions."/>
</resource-configuration>
+ <service name="mod_cluster_context"
+ discovery="ContextDiscoveryComponent"
+ class="ContextComponent"
+ description="A mod_cluster context">
+
+ <operation name="enableContext" displayName="Enable webapp" description="Enable a single webapp">
+ <results>
+ <c:simple-property name="result" type="boolean" description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="disableContext" displayName="Disable webpapp" description="Disable a single webapp">
+ <results>
+ <c:simple-property name="result" type="boolean" description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="stopContext" displayName="Stop webpapp" description="Gracefully stops a single webapp">
+ <results>
+ <c:simple-property name="result" type="boolean" description="The result of the operation" />
+ </results>
+ </operation>
+
+ </service>
+
+
</service>
</plugin>
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index da0303e..deceb70 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -19,8 +19,10 @@
package org.rhq.plugins.modcluster.test;
import java.io.File;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
+import java.util.List;
import java.util.Queue;
import java.util.Set;
@@ -45,6 +47,7 @@ import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.plugins.modcluster.ProxyInfo;
/**
* @author Fady Matar
@@ -80,6 +83,31 @@ public class ModclusterPluginTest {
}
@Test
+ public void testProxyInfo() {
+ String test = "{mobile-work/192.168.1.40:6666=Node: [1],Name: 4e6189af-0502-3305-8ff3-fad7fee8b516,Balancer: mycluster,LBGroup: ,Host: 127.0.0.1,Port: 8009,Type: ajp,Flushpackets: Off,Flushwait: 10,Ping: 10,Smax: 26,Ttl: 60,Elected: 3233,Read: 7355619,Transfered: 0,Connected: 0,Load: 100\n"
+ + "Node: [2],Name: node2,Balancer: mycluster,LBGroup: ,Host: 127.0.0.1,Port: 8009,Type: ajp,Flushpackets: Off,Flushwait: 10,Ping: 10,Smax: 26,Ttl: 60,Elected: 0,Read: 0,Transfered: 0,Connected: 0,Load: 99\n"
+ + "Vhost: [1:1:1], Alias: localhost\n"
+ + "Vhost: [2:1:2], Alias: localhost\n"
+ + "Context: [1:1:1], Context: /invoker, Status: DISABLED\n"
+ + "Context: [1:1:2], Context: /loaddemo, Status: DISABLED\n"
+ + "Context: [1:1:3], Context: /jbossws, Status: DISABLED\n"
+ + "Context: [1:1:4], Context: /juddi, Status: DISABLED\n"
+ + "Context: [1:1:5], Context: /jbossmq-httpil, Status: DISABLED\n"
+ + "Context: [1:1:6], Context: /web-console, Status: DISABLED\n"
+ + "Context: [1:1:7], Context: /jmx-console, Status: DISABLED\n"
+ + "Context: [1:1:8], Context: /, Status: DISABLED\n"
+ + "Context: [2:1:9], Context: /loaddemo, Status: ENABLED\n" + "}";
+
+ ProxyInfo proxyInfo = new ProxyInfo(test);
+
+ for (ProxyInfo.Context context : proxyInfo.getAvailableContexts()) {
+ log.info(context.toString());
+ }
+
+ assert (proxyInfo.getAvailableContexts().size() != 0) : "Raw proxy info parsing failed!";
+ }
+
+ @Test
public void testPluginLoad() {
PluginManager pluginManager = PluginContainer.getInstance().getPluginManager();
PluginEnvironment pluginEnvironment = pluginManager.getPlugin(PLUGIN_NAME);
@@ -98,12 +126,22 @@ public class ModclusterPluginTest {
assert report != null;
System.out.println("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+ List<String> typeNames = new ArrayList<String>() {
+ {
+ add(PLUGIN_NAME);
+ add(PLUGIN_NAME + "_context");
+ }
+ };
+
Set<Resource> resources = findResource(PluginContainer.getInstance().getInventoryManager().getPlatform(),
- PLUGIN_NAME);
- log.info("Found " + resources.size() + " mod_cluster instance(s).");
+ typeNames);
+ log.info("Found " + resources.size() + " mod_cluster and mod_cluster_context instance(s).");
+
+ assert (resources.size() != 0) : "No mod_cluster or related instances found.";
if (resources.size() != 0) {
testResourceMeasurement((Resource) resources.toArray()[0]);
+ testContextOperations((Resource) resources.toArray()[1]);
}
}
@@ -132,7 +170,20 @@ public class ModclusterPluginTest {
}
}
- private Set<Resource> findResource(Resource parent, String typeName) {
+ private void testContextOperations(Resource resource) throws Exception {
+ ResourceComponent resourceComponent = PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+
+ if (resourceComponent instanceof OperationFacet) {
+ OperationResult result = ((OperationFacet) resourceComponent).invokeOperation("enableContext", null);
+ log.info("Result of operation " + "enableContext" + " was: " + result.getSimpleResult());
+
+ /*result = ((OperationFacet) resourceComponent).invokeOperation("disable", null);
+ log.info("Result of operation test was: " + result.getSimpleResult());*/
+ }
+ }
+
+ private Set<Resource> findResource(Resource parent, List<String> typeNames) {
Set<Resource> found = new HashSet<Resource>();
Queue<Resource> discoveryQueue = new LinkedList<Resource>();
@@ -142,7 +193,7 @@ public class ModclusterPluginTest {
Resource currentResource = discoveryQueue.poll();
log.info("Discovered resource of type: " + currentResource.getResourceType().getName());
- if (currentResource.getResourceType().getName().equals(typeName)) {
+ if (typeNames.contains(currentResource.getResourceType().getName())) {
found.add(currentResource);
}
commit d2b8d0f801936bfc318be141737aa237bc7d7b74
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 5 15:46:03 2011 -0500
Attempt to manually manipulate the operations list for mod_cluster to dynamically load the contexts.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index c70f53b..a98792e 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -18,6 +18,9 @@
*/
package org.rhq.plugins.modcluster;
+import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.plugins.jmx.MBeanResourceComponent;
/**
@@ -26,4 +29,15 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
*/
public class ModclusterServerComponent extends MBeanResourceComponent {
+ /**
+ * Stores the context and loads the MBean.
+ * @see ResourceComponent#start(ResourceContext)
+ */
+ @Override
+ public void start(ResourceContext context) {
+ super.start(context);
+
+ OperationDefinition test = new OperationDefinition(context.getResourceType(), "Text");
+ context.getResourceType().addOperationDefinition(test);
+ }
}
commit 384ac9ada9f59a2f2f1cbd52088c81044ba2038c
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 5 15:45:23 2011 -0500
Added simple operations to the list of operations supported by the plugin. Complex operations to follow....
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterDiscoveryComponent.java
deleted file mode 100644
index fa807a3..0000000
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterDiscoveryComponent.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ManualAddFacet;
-import org.rhq.core.pluginapi.inventory.ProcessScanResult;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-
-/**
- * This can be the start of your own custom plugin's discovery component. Review the javadoc for
- * {@link ResourceDiscoveryComponent}.
- *
- * @author John Mazzitelli
- */
-@SuppressWarnings("unchecked")
-public class ModclusterDiscoveryComponent implements ResourceDiscoveryComponent, ManualAddFacet {
- private final Log log = LogFactory.getLog(ModclusterDiscoveryComponent.class);
-
- /**
- * This discovery method is the way the plugin supports "manual-add" capability. The plugin
- * descriptor must specify supportsManualAdd="true" to allow the resource to be manually added.
- * If that attribute is false, this method will never be used since it will not be possible to manually
- * add an instance of the resource.
- *
- * Review the javadoc for both {@link ManualAddFacet} and {@link ResourceDiscoveryContext} to learn what
- * you need to do in this method.
- *
- * @see ManualAddFacet#discoverResource(Configuration, ResourceDiscoveryContext)
- */
- @Override
- public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration,
- ResourceDiscoveryContext context) throws InvalidPluginConfigurationException {
-
- // pluginConfiguration contains information on a resource that was manually added by the user.
- // take it and build a details object that represents that resource.
-
- // key = this must be a unique string across all of your resources - see docs for uniqueness rules
- // name = this is the name you give the new resource; it does not necessarily have to be unique
- // version = this is any string that corresponds to the resource's version
- // description = this is any string that you want to assign as the default description for your resource
- String key = "My Manually Added Resource Key";
- String name = "My Resource";
- String version = "1.0";
- String description = "This describes My Resource";
-
- DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
- version, description, pluginConfiguration, null);
-
- return resource;
- }
-
- /**
- * Review the javadoc for both {@link ResourceDiscoveryComponent} and {@link ResourceDiscoveryContext} to learn what
- * you need to do in this method.
- *
- * @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext)
- */
- @Override
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
- log.info("Discovering my custom plugin's resources");
-
- // if your plugin descriptor defined one or more <process-scan>s, then see if the plugin container
- // auto-discovered processes using those process scan definitions. Process all those that were found.
- List<ProcessScanResult> autoDiscoveryResults = context.getAutoDiscoveredProcesses();
- for (ProcessScanResult autoDiscoveryResult : autoDiscoveryResults) {
- // determine if you want to include the result in this method's returned set of discovered resources
- }
-
- // now perform your own discovery mechanism, if you have one. For each resource discovered, you need to
- // create a details object that describe the resource that you discovered.
- HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
-
- // key = this must be a unique string across all of your resources - see docs for uniqueness rules
- // name = this is the name you give the new resource; it does not necessarily have to be unique
- // version = this is any string that corresponds to the resource's version
- // description = this is any string that you want to assign as the default description for your resource
- String key = "My Resource Key";
- String name = "My Resource";
- String version = "1.0";
- String description = "This describes My Resource";
-
- DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
- version, description, null, null);
-
- set.add(resource);
-
- return set;
- }
-}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index c924753..b8d7249 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -27,10 +27,25 @@
</plugin-configuration>
<operation name="reset" displayName="Reset the node" description="Move the node out of an error state" />
+ <operation name="refresh" displayName="Refresh configuration" description="Refresh configuration" />
+ <operation name="enable" displayName="Enable all webapps" description="Enable all webapps for all engines">
+ <results>
+ <c:simple-property name="result" type="boolean" description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="disable" displayName="Disable all webpapps" description="Disable all webapps for all engines">
+ <results>
+ <c:simple-property name="result" type="boolean" description="The result of the operation" />
+ </results>
+ </operation>
<metric property="proxyConfiguration" displayName="Proxy Configuration" displayType="summary" dataType="trait" />
<metric property="modelerType" displayName="Type of the modeled resource" displayType="summary" dataType="trait" />
<metric property="className" displayName="Fully qualified class name of the managed object" displayType="summary" dataType="trait" />
+ <resource-configuration>
+ <c:simple-property name="stickySessions" type="boolean" description="Enables sticky sessions."/>
+ </resource-configuration>
+
</service>
</plugin>
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index 5f68989..da0303e 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -43,6 +43,8 @@ import org.rhq.core.pc.plugin.PluginEnvironment;
import org.rhq.core.pc.plugin.PluginManager;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
/**
* @author Fady Matar
@@ -115,13 +117,19 @@ public class ModclusterPluginTest {
MeasurementReport report = new MeasurementReport();
((MeasurementFacet) resourceComponent).getValues(report, metricList);
- /*assert report.getNumericData().size() > 0 : "Measurement " + def.getName() + " not collected from "
- + resource;*/
MeasurementData data = report.getTraitData().iterator().next();
assert data != null : "Unable to collect trait [" + def.getName() + "] on " + resource;
log.info("Measurement: " + def.getName() + "=" + data.getValue());
}
}
+
+ if (resourceComponent instanceof OperationFacet) {
+ OperationResult result = ((OperationFacet) resourceComponent).invokeOperation("reset", null);
+ log.info("Result of operation test was: " + result);
+
+ result = ((OperationFacet) resourceComponent).invokeOperation("disable", null);
+ log.info("Result of operation test was: " + result.getSimpleResult());
+ }
}
private Set<Resource> findResource(Resource parent, String typeName) {
commit 53efc864c9d00bae1a7c8ed66ea0f25baed05b65
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Jul 1 16:12:13 2011 -0500
Remove unused file.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetric.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetric.java
deleted file mode 100644
index 1223508..0000000
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetric.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster;
-
-import org.rhq.plugins.jmx.MBeanResourceComponent;
-
-/**
- * @author Stefan Negrea
- *
- */
-public class LoadMetric extends MBeanResourceComponent {
-
-}
commit 30737d3a2d1e3fc85111416203cafdf4d47b70a2
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Jul 1 15:11:36 2011 -0600
Added all the metrics proposed in the design document to the plugin with complete unit tests.
Also, corrected the cumbersome find resource code. No reason to have recursion when a simple queue can do the job more efficiently.
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml
index 869a25e..a19dfc0 100644
--- a/modules/plugins/mod-cluster/pom.xml
+++ b/modules/plugins/mod-cluster/pom.xml
@@ -69,6 +69,8 @@
<fileset dir="${settings.localRepository}/">
<include name="org/rhq/rhq-platform-plugin/${project.version}/rhq-platform-plugin-${project.version}.jar" />
<include name="org/rhq/rhq-jmx-plugin/${project.version}/rhq-jmx-plugin-${project.version}.jar" />
+ <include name="org/jboss/on/jopr-jboss-as-plugin/${project.version}/jopr-jboss-as-plugin-${project.version}.jar" />
+ <include name="org/jboss/on/jopr-jboss-as-5-plugin/${project.version}/jopr-jboss-as-5-plugin-${project.version}.jar" />
</fileset>
<fileset dir="${rhq.deploymentDir}">
<include name="${project.artifactId}-${project.version}.jar" />
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index 6d6998a..c70f53b 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2009 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -18,151 +18,12 @@
*/
package org.rhq.plugins.modcluster;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.MeasurementDataNumeric;
-import org.rhq.core.domain.measurement.MeasurementReport;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
-import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.core.pluginapi.measurement.MeasurementFacet;
-import org.rhq.core.pluginapi.operation.OperationFacet;
-import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
/**
- * This can be the start of your own custom plugin's server component. Review the javadoc for {@link ResourceComponent}
- * and all the facet interfaces to learn what you can do in your resource component. This component has a lot of methods
- * in it because it implements all possible facets. If your resource does not support, for example, configuration, you
- * can remove the {@link ConfigurationFacet} from the <code>implements</code> clause and remove all method
- * implementations that that facet required.
- *
- * <p>You should not only read the javadoc in each of this class' methods, but you should also read the javadocs linked
- * by their "see" javadoc tags since those additional javadocs will contain a good deal of additional information you
- * will need to know.</p>
+ * @author Stefan Negrea
*
- * @author John Mazzitelli
*/
-public class ModclusterServerComponent implements ResourceComponent, MeasurementFacet, OperationFacet,
- ConfigurationFacet {
- private final Log log = LogFactory.getLog(ModclusterServerComponent.class);
-
- /**
- * Represents the resource configuration of the custom product being managed.
- */
- private Configuration resourceConfiguration;
-
- /**
- * All AMPS plugins are stateful - this context contains information that your resource component can use when
- * performing its processing.
- */
- private ResourceContext resourceContext;
-
- /**
- * This is called when your component has been started with the given context. You normally initialize some internal
- * state of your component as well as attempt to make a stateful connection to your managed resource.
- *
- * @see ResourceComponent#start(ResourceContext)
- */
- public void start(ResourceContext context) {
- resourceContext = context;
- }
-
- /**
- * This is called when the component is being stopped, usually due to the plugin container shutting down. You can
- * perform some cleanup here; though normally not much needs to be done here.
- *
- * @see ResourceComponent#stop()
- */
- public void stop() {
- }
-
- /**
- * All resource components must be able to tell the plugin container if the managed resource is available or not.
- * This method is called by the plugin container when it needs to know if the managed resource is actually up and
- * available.
- *
- * @see ResourceComponent#getAvailability()
- */
- public AvailabilityType getAvailability() {
- // TODO: here you normally make some type of connection attempt to the managed resource
- // to determine if it is really up and running.
- return AvailabilityType.UP;
- }
-
- /**
- * The plugin container will call this method when your resource component has been scheduled to collect some
- * measurements now. It is within this method that you actually talk to the managed resource and collect the
- * measurement data that is has emitted.
- *
- * @see MeasurementFacet#getValues(MeasurementReport, Set)
- */
- public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) {
- for (MeasurementScheduleRequest request : requests) {
- String name = request.getName();
-
- // TODO: based on the request information, you must collect the requested measurement(s)
- // you can use the name of the measurement to determine what you actually need to collect
- try {
- Number value = new Integer(1); // dummy measurement value - this should come from the managed resource
- report.addData(new MeasurementDataNumeric(request, value.doubleValue()));
- } catch (Exception e) {
- log.error("Failed to obtain measurement [" + name + "]. Cause: " + e);
- }
- }
-
- return;
- }
-
- /**
- * The plugin container will call this method when it wants to invoke an operation on your managed resource. Your
- * plugin will connect to the managed resource and invoke the analogous operation in your own custom way.
- *
- * @see OperationFacet#invokeOperation(String, Configuration)
- */
- public OperationResult invokeOperation(String name, Configuration configuration) {
- return null;
- }
-
- /**
- * The plugin container will call this method and it needs to obtain the current configuration of the managed
- * resource. Your plugin will obtain the managed resource's configuration in your own custom way and populate the
- * returned Configuration object with the managed resource's configuration property values.
- *
- * @see ConfigurationFacet#loadResourceConfiguration()
- */
- public Configuration loadResourceConfiguration() {
- // here we simulate the loading of the managed resource's configuration
-
- if (resourceConfiguration == null) {
- // for this example, we will create a simple dummy configuration to start with.
- // note that it is empty, so we're assuming there are no required configs in the plugin descriptor.
- resourceConfiguration = new Configuration();
- }
-
- Configuration config = resourceConfiguration;
-
- return config;
- }
-
- /**
- * The plugin container will call this method when it has a new configuration for your managed resource. Your plugin
- * will re-configure the managed resource in your own custom way, setting its configuration based on the new values
- * of the given configuration.
- *
- * @see ConfigurationFacet#updateResourceConfiguration(ConfigurationUpdateReport)
- */
- public void updateResourceConfiguration(ConfigurationUpdateReport report) {
- // this simulates the plugin taking the new configuration and reconfiguring the managed resource
- resourceConfiguration = report.getConfiguration().deepCopy();
+public class ModclusterServerComponent extends MBeanResourceComponent {
- report.setStatus(ConfigurationUpdateStatus.SUCCESS);
- }
}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index fe6d1b3..c924753 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -12,21 +12,25 @@
<service name="mod_cluster"
discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
- class="LoadMetric"
+ class="ModclusterServerComponent"
supportsManualAdd="true"
description="mod_cluster plugin">
- <!-- runs-inside>
- <parent-resource-type name="JMX Server" plugin="JMX"/>
- </runs-inside-->
- <runs-inside>
- <parent-resource-type name="JMX Server" plugin="JMX"/>
- </runs-inside>
+ <runs-inside>
+ <parent-resource-type name="JBossAS Server" plugin="JBossAS"/>
+ <parent-resource-type name="JBossAS Server" plugin="JBossAS5"/>
+ </runs-inside>
- <plugin-configuration>
- <c:simple-property name="connectorAddress" default="http://192.168.1.56:6666"/>
- <c:simple-property name="objectName" readOnly="true" default="ModClusterServiceMBean"/>
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true" default="Catalina:type=ModClusterListener,*"/>
+ <c:simple-property name="nameTemplate" default="{application}"/>
</plugin-configuration>
-
+
+ <operation name="reset" displayName="Reset the node" description="Move the node out of an error state" />
+
+ <metric property="proxyConfiguration" displayName="Proxy Configuration" displayType="summary" dataType="trait" />
+ <metric property="modelerType" displayName="Type of the modeled resource" displayType="summary" dataType="trait" />
+ <metric property="className" displayName="Fully qualified class name of the managed object" displayType="summary" dataType="trait" />
+
</service>
</plugin>
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index 971ccb1..5f68989 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -20,6 +20,8 @@ package org.rhq.plugins.modcluster.test;
import java.io.File;
import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Queue;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -29,12 +31,18 @@ import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import org.rhq.core.clientapi.server.discovery.InventoryReport;
+import org.rhq.core.domain.measurement.MeasurementData;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.pc.PluginContainer;
import org.rhq.core.pc.PluginContainerConfiguration;
import org.rhq.core.pc.plugin.FileSystemPluginFinder;
import org.rhq.core.pc.plugin.PluginEnvironment;
import org.rhq.core.pc.plugin.PluginManager;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
/**
* @author Fady Matar
@@ -90,23 +98,53 @@ public class ModclusterPluginTest {
Set<Resource> resources = findResource(PluginContainer.getInstance().getInventoryManager().getPlatform(),
PLUGIN_NAME);
- log.info("Found " + resources.size() + "mod_cluster instance(s).");
+ log.info("Found " + resources.size() + " mod_cluster instance(s).");
+
+ if (resources.size() != 0) {
+ testResourceMeasurement((Resource) resources.toArray()[0]);
+ }
+ }
+
+ private void testResourceMeasurement(Resource resource) throws Exception {
+ ResourceComponent resourceComponent = PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+ if (resourceComponent instanceof MeasurementFacet) {
+ for (MeasurementDefinition def : resource.getResourceType().getMetricDefinitions()) {
+ Set<MeasurementScheduleRequest> metricList = new HashSet<MeasurementScheduleRequest>();
+ metricList.add(new MeasurementScheduleRequest(1, def.getName(), 1000, true, def.getDataType(), null));
+ MeasurementReport report = new MeasurementReport();
+ ((MeasurementFacet) resourceComponent).getValues(report, metricList);
+
+ /*assert report.getNumericData().size() > 0 : "Measurement " + def.getName() + " not collected from "
+ + resource;*/
+ MeasurementData data = report.getTraitData().iterator().next();
+ assert data != null : "Unable to collect trait [" + def.getName() + "] on " + resource;
+ log.info("Measurement: " + def.getName() + "=" + data.getValue());
+ }
+ }
}
private Set<Resource> findResource(Resource parent, String typeName) {
Set<Resource> found = new HashSet<Resource>();
- Resource platform = parent;
- for (Resource resource : platform.getChildResources()) {
- log.info("Discovered resource of type: " + resource.getResourceType().getName());
- if (resource.getResourceType().getName().equals(typeName)) {
- found.add(resource);
+
+ Queue<Resource> discoveryQueue = new LinkedList<Resource>();
+ discoveryQueue.add(parent);
+
+ while (!discoveryQueue.isEmpty()) {
+ Resource currentResource = discoveryQueue.poll();
+
+ log.info("Discovered resource of type: " + currentResource.getResourceType().getName());
+ if (currentResource.getResourceType().getName().equals(typeName)) {
+ found.add(currentResource);
}
- if (resource.getChildResources() != null) {
- for (Resource child : found) {
- found.addAll(findResource(child, typeName));
+
+ if (currentResource.getChildResources() != null) {
+ for (Resource child : currentResource.getChildResources()) {
+ discoveryQueue.add(child);
}
}
}
+
return found;
}
}
commit e12cc04174250dcabd6dd81ca7f97e998ca801fb
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jun 28 09:21:49 2011 -0500
Attempts to make mod_cluster a simple derivation from JMX plugin.
diff --git a/.classpath b/.classpath
index d5bec34..c215ebf 100644
--- a/.classpath
+++ b/.classpath
@@ -271,5 +271,7 @@
<classpathentry excluding="**" kind="src" path="modules/enterprise/comm/src/test/resources"/>
<classpathentry excluding="**" kind="src" path="modules/enterprise/agent/src/main/resources"/>
<classpathentry excluding="**" kind="src" path="modules/enterprise/agent/src/test/resources"/>
+ <classpathentry kind="src" path="modules/plugins/mod-cluster/src/main/java"/>
+ <classpathentry kind="src" path="modules/plugins/mod-cluster/src/test/java"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml
index e22efc7..869a25e 100644
--- a/modules/plugins/mod-cluster/pom.xml
+++ b/modules/plugins/mod-cluster/pom.xml
@@ -1,5 +1,3 @@
-<?xml version="1.0"?>
-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -12,16 +10,11 @@
<groupId>org.rhq.plugins.modcluster</groupId>
<artifactId>modcluster-plugin</artifactId>
- <version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>mod_cluster RHQ Plugin</name>
<description>mod_cluster RHQ Agent plugin</description>
- <!--properties>
- <rhq.version>4.1.0-SNAPSHOT</rhq.version>
- </properties-->
-
<dependencies>
<dependency>
@@ -31,220 +24,170 @@
<scope>provided</scope>
</dependency>
- <!-- Below are the core modules that are required dependencies of all plugins -->
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <version>${rhq.version}</version>
- <scope>provided</scope> <!-- provided by the agent/plugin-container -->
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-plugin-api</artifactId>
- <version>${rhq.version}</version>
- <scope>provided</scope> <!-- provided by the agent/plugin-container -->
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-native-system</artifactId>
- <version>${rhq.version}</version>
- <scope>provided</scope> <!-- provided by the agent/plugin-container -->
- </dependency>
-
- <!-- Fix for the Javac bug requiring annotations to be available when compiling classes. (fixed in JDK 6) -->
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>1.0</version>
- <scope>provided</scope> <!-- provided by the agent/plugin-container -->
- </dependency>
-
- <!-- Fix for the Javac bug requiring annotations to be available when compiling classes. (fixed in JDK 6) -->
- <dependency>
- <groupId>hibernate-annotations</groupId>
- <artifactId>hibernate-annotations</artifactId>
- <version>3.2.1.GA</version>
- <scope>provided</scope> <!-- provided by the agent/plugin-container -->
- </dependency>
-
- <!-- Fix for the Javac bug requiring annotations to be available when compiling classes. (fixed in JDK 6) -->
- <dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
- <version>2.1</version>
- <scope>provided</scope> <!-- provided by the agent/plugin-container -->
- </dependency>
-
- <!--
- Uncomment the one of the three logging systems your plugin uses: log4j, commons-logging or i18nlog
- All three are provided to your plugin by the agent/plugin-container.
- -->
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1</version>
- <scope>provided</scope>
- </dependency>
-
-
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>provided</scope>
</dependency>
-
- <!--
- <dependency>
- <groupId>i18nlog</groupId>
- <artifactId>i18nlog</artifactId>
- <version>1.0.9</version>
- <scope>provided</scope>
- </dependency>
- -->
-
- <!-- Define any third-party dependencies your plugin has here. -->
- <!--
- <dependency>
- <groupId>group-id-of-dependency-goes-here</groupId>
- <artifactId>artifact-id-of-dependency-goes-here</artifactId>
- <version>version-of-dependency-goes-here</version>
- </dependency>
- -->
</dependencies>
- <build>
- <plugins>
-
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
-
- <!--
- If your plugin has third-party jar dependencies that are not already available when deployed in the plugin
- container, you can package these jars in your plugin. They go in your plugin jar's "lib" directory.
- Uncomment the maven plugin definition below and define one or more jar files (aka "artifactItem" elements)
- that you want to include in your plugin jar.
- -->
- <!--
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <phase>process-resources</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>your-third-party-dep-group</groupId>
- <artifactId>your-third-party-dep-artifact</artifactId>
- <version>your-third-party-dep-version</version>
- </artifactItem>
- </artifactItems>
- <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- -->
-
- </plugins>
- </build>
-
<profiles>
+
<profile>
- <id>dev</id>
+ <id>integration-tests</id>
+ <activation>
+ <property>
+ <name>maven.test.skip</name>
+ <value>!true</value>
+ </property>
+ </activation>
+
<properties>
- <!-- define the location of your RHQ root directory - typically rhq.rootDir is overridden in Maven's settings.xml -->
- <rhq.rootDir>/rhq/trunk</rhq.rootDir>
- <rhq.defaultDevContainerPath>dev-container</rhq.defaultDevContainerPath>
+ <rhq.rootDir>../../..</rhq.rootDir>
<rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
- <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/rhq.ear/rhq-downloads/rhq-plugins</rhq.deploymentDir>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-plugins</rhq.deploymentDir>
</properties>
+
<build>
<plugins>
+
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
- <version>1.1</version>
<executions>
<execution>
- <id>deploy</id>
- <phase>compile</phase>
+ <phase>process-test-resources</phase>
<configuration>
<tasks>
- <mkdir dir="${rhq.deploymentDir}" />
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Updating ${deployment.file}...</echo>
- <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ <echo>Setting up plugin dependencies...</echo>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository" />
+ <mkdir dir="target/testsetup" />
+
+ <mkdir dir="target/testsetup/plugins" />
+ <copy toDir="target/testsetup/plugins" flatten="true">
+ <fileset dir="${settings.localRepository}/">
+ <include name="org/rhq/rhq-platform-plugin/${project.version}/rhq-platform-plugin-${project.version}.jar" />
+ <include name="org/rhq/rhq-jmx-plugin/${project.version}/rhq-jmx-plugin-${project.version}.jar" />
+ </fileset>
+ <fileset dir="${rhq.deploymentDir}">
+ <include name="${project.artifactId}-${project.version}.jar" />
+ </fileset>
+ </copy>
+
+ <mkdir dir="target/testsetup/lib" />
+ <unzip dest="target/testsetup/lib">
+ <fileset dir="${settings.localRepository}/org/hyperic/sigar-dist/${sigar.version}" includes="*.zip" />
+ <patternset>
+ <include name="**/lib/sigar.jar" />
+ <include name="**/lib/bcel*.jar" />
+ <include name="**/lib/*.so" />
+ <include name="**/lib/*.sl" />
+ <include name="**/lib/*.dll" />
+ <include name="**/lib/*.dylib" />
+ </patternset>
+ </unzip>
+ <move todir="target/testsetup/lib" flatten="true">
+ <fileset dir="target/testsetup/lib">
+ <include name="**/lib/*" />
+ </fileset>
+ </move>
+ <delete dir="target/testsetup/lib/hyperic-sigar-${sigar.version}" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
+
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${rhq.deploymentDir}" />
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
<execution>
<id>deploy-jar-meta-inf</id>
<phase>package</phase>
<configuration>
- <tasks>
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Updating META-INF dir in ${deployment.file}...</echo>
- <unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.outputDirectory}">
- <patternset>
- <include name="META-INF/**" />
- </patternset>
- </unjar>
- <jar destfile="${deployment.file}"
- manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF"
- update="true">
- </jar>
- </tasks>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating META-INF dir in ${deployment.file}...</echo>
+ <unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.outputDirectory}">
+ <patternset><include name="META-INF/**" /></patternset>
+ </unjar>
+ <jar destfile="${deployment.file}" manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF" update="true">
+ </jar>
+ </tasks>
</configuration>
<goals>
- <goal>run</goal>
+ <goal>run</goal>
</goals>
</execution>
+
<execution>
<id>undeploy</id>
<phase>clean</phase>
<configuration>
- <tasks>
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Deleting ${deployment.file}...</echo>
- <delete file="${deployment.file}" />
- </tasks>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}" />
+ </tasks>
</configuration>
<goals>
- <goal>run</goal>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ <executions>
+ <execution>
+ <id>surefire-it</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
</goals>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
+ <useSystemClassLoader>false</useSystemClassLoader>
+ <argLine>-Dorg.hyperic.sigar.path=${basedir}/target/testsetup/lib</argLine>
+ <systemProperties>
+ <property>
+ <name>project.artifactId</name>
+ <value>${project.artifactId}</value>
+ </property>
+ <property>
+ <name>project.version</name>
+ <value>${project.version}</value>
+ </property>
+ </systemProperties>
+ </configuration>
</execution>
</executions>
</plugin>
+
</plugins>
</build>
</profile>
</profiles>
- <repositories>
- <repository>
- <id>jboss-public-repository-group</id>
- <name>JBoss Public Maven Repository Group</name>
- <url>https://repository.jboss.org/nexus/content/groups/public/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
-
</project>
-
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetric.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetric.java
new file mode 100644
index 0000000..1223508
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetric.java
@@ -0,0 +1,29 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import org.rhq.plugins.jmx.MBeanResourceComponent;
+
+/**
+ * @author Stefan Negrea
+ *
+ */
+public class LoadMetric extends MBeanResourceComponent {
+
+}
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterDiscoveryComponent.java
new file mode 100644
index 0000000..fa807a3
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterDiscoveryComponent.java
@@ -0,0 +1,116 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ManualAddFacet;
+import org.rhq.core.pluginapi.inventory.ProcessScanResult;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+
+/**
+ * This can be the start of your own custom plugin's discovery component. Review the javadoc for
+ * {@link ResourceDiscoveryComponent}.
+ *
+ * @author John Mazzitelli
+ */
+@SuppressWarnings("unchecked")
+public class ModclusterDiscoveryComponent implements ResourceDiscoveryComponent, ManualAddFacet {
+ private final Log log = LogFactory.getLog(ModclusterDiscoveryComponent.class);
+
+ /**
+ * This discovery method is the way the plugin supports "manual-add" capability. The plugin
+ * descriptor must specify supportsManualAdd="true" to allow the resource to be manually added.
+ * If that attribute is false, this method will never be used since it will not be possible to manually
+ * add an instance of the resource.
+ *
+ * Review the javadoc for both {@link ManualAddFacet} and {@link ResourceDiscoveryContext} to learn what
+ * you need to do in this method.
+ *
+ * @see ManualAddFacet#discoverResource(Configuration, ResourceDiscoveryContext)
+ */
+ @Override
+ public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration,
+ ResourceDiscoveryContext context) throws InvalidPluginConfigurationException {
+
+ // pluginConfiguration contains information on a resource that was manually added by the user.
+ // take it and build a details object that represents that resource.
+
+ // key = this must be a unique string across all of your resources - see docs for uniqueness rules
+ // name = this is the name you give the new resource; it does not necessarily have to be unique
+ // version = this is any string that corresponds to the resource's version
+ // description = this is any string that you want to assign as the default description for your resource
+ String key = "My Manually Added Resource Key";
+ String name = "My Resource";
+ String version = "1.0";
+ String description = "This describes My Resource";
+
+ DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
+ version, description, pluginConfiguration, null);
+
+ return resource;
+ }
+
+ /**
+ * Review the javadoc for both {@link ResourceDiscoveryComponent} and {@link ResourceDiscoveryContext} to learn what
+ * you need to do in this method.
+ *
+ * @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext)
+ */
+ @Override
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
+ log.info("Discovering my custom plugin's resources");
+
+ // if your plugin descriptor defined one or more <process-scan>s, then see if the plugin container
+ // auto-discovered processes using those process scan definitions. Process all those that were found.
+ List<ProcessScanResult> autoDiscoveryResults = context.getAutoDiscoveredProcesses();
+ for (ProcessScanResult autoDiscoveryResult : autoDiscoveryResults) {
+ // determine if you want to include the result in this method's returned set of discovered resources
+ }
+
+ // now perform your own discovery mechanism, if you have one. For each resource discovered, you need to
+ // create a details object that describe the resource that you discovered.
+ HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
+
+ // key = this must be a unique string across all of your resources - see docs for uniqueness rules
+ // name = this is the name you give the new resource; it does not necessarily have to be unique
+ // version = this is any string that corresponds to the resource's version
+ // description = this is any string that you want to assign as the default description for your resource
+ String key = "My Resource Key";
+ String name = "My Resource";
+ String version = "1.0";
+ String description = "This describes My Resource";
+
+ DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
+ version, description, null, null);
+
+ set.add(resource);
+
+ return set;
+ }
+}
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
new file mode 100644
index 0000000..6d6998a
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -0,0 +1,168 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
+
+/**
+ * This can be the start of your own custom plugin's server component. Review the javadoc for {@link ResourceComponent}
+ * and all the facet interfaces to learn what you can do in your resource component. This component has a lot of methods
+ * in it because it implements all possible facets. If your resource does not support, for example, configuration, you
+ * can remove the {@link ConfigurationFacet} from the <code>implements</code> clause and remove all method
+ * implementations that that facet required.
+ *
+ * <p>You should not only read the javadoc in each of this class' methods, but you should also read the javadocs linked
+ * by their "see" javadoc tags since those additional javadocs will contain a good deal of additional information you
+ * will need to know.</p>
+ *
+ * @author John Mazzitelli
+ */
+public class ModclusterServerComponent implements ResourceComponent, MeasurementFacet, OperationFacet,
+ ConfigurationFacet {
+ private final Log log = LogFactory.getLog(ModclusterServerComponent.class);
+
+ /**
+ * Represents the resource configuration of the custom product being managed.
+ */
+ private Configuration resourceConfiguration;
+
+ /**
+ * All AMPS plugins are stateful - this context contains information that your resource component can use when
+ * performing its processing.
+ */
+ private ResourceContext resourceContext;
+
+ /**
+ * This is called when your component has been started with the given context. You normally initialize some internal
+ * state of your component as well as attempt to make a stateful connection to your managed resource.
+ *
+ * @see ResourceComponent#start(ResourceContext)
+ */
+ public void start(ResourceContext context) {
+ resourceContext = context;
+ }
+
+ /**
+ * This is called when the component is being stopped, usually due to the plugin container shutting down. You can
+ * perform some cleanup here; though normally not much needs to be done here.
+ *
+ * @see ResourceComponent#stop()
+ */
+ public void stop() {
+ }
+
+ /**
+ * All resource components must be able to tell the plugin container if the managed resource is available or not.
+ * This method is called by the plugin container when it needs to know if the managed resource is actually up and
+ * available.
+ *
+ * @see ResourceComponent#getAvailability()
+ */
+ public AvailabilityType getAvailability() {
+ // TODO: here you normally make some type of connection attempt to the managed resource
+ // to determine if it is really up and running.
+ return AvailabilityType.UP;
+ }
+
+ /**
+ * The plugin container will call this method when your resource component has been scheduled to collect some
+ * measurements now. It is within this method that you actually talk to the managed resource and collect the
+ * measurement data that is has emitted.
+ *
+ * @see MeasurementFacet#getValues(MeasurementReport, Set)
+ */
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) {
+ for (MeasurementScheduleRequest request : requests) {
+ String name = request.getName();
+
+ // TODO: based on the request information, you must collect the requested measurement(s)
+ // you can use the name of the measurement to determine what you actually need to collect
+ try {
+ Number value = new Integer(1); // dummy measurement value - this should come from the managed resource
+ report.addData(new MeasurementDataNumeric(request, value.doubleValue()));
+ } catch (Exception e) {
+ log.error("Failed to obtain measurement [" + name + "]. Cause: " + e);
+ }
+ }
+
+ return;
+ }
+
+ /**
+ * The plugin container will call this method when it wants to invoke an operation on your managed resource. Your
+ * plugin will connect to the managed resource and invoke the analogous operation in your own custom way.
+ *
+ * @see OperationFacet#invokeOperation(String, Configuration)
+ */
+ public OperationResult invokeOperation(String name, Configuration configuration) {
+ return null;
+ }
+
+ /**
+ * The plugin container will call this method and it needs to obtain the current configuration of the managed
+ * resource. Your plugin will obtain the managed resource's configuration in your own custom way and populate the
+ * returned Configuration object with the managed resource's configuration property values.
+ *
+ * @see ConfigurationFacet#loadResourceConfiguration()
+ */
+ public Configuration loadResourceConfiguration() {
+ // here we simulate the loading of the managed resource's configuration
+
+ if (resourceConfiguration == null) {
+ // for this example, we will create a simple dummy configuration to start with.
+ // note that it is empty, so we're assuming there are no required configs in the plugin descriptor.
+ resourceConfiguration = new Configuration();
+ }
+
+ Configuration config = resourceConfiguration;
+
+ return config;
+ }
+
+ /**
+ * The plugin container will call this method when it has a new configuration for your managed resource. Your plugin
+ * will re-configure the managed resource in your own custom way, setting its configuration based on the new values
+ * of the given configuration.
+ *
+ * @see ConfigurationFacet#updateResourceConfiguration(ConfigurationUpdateReport)
+ */
+ public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ // this simulates the plugin taking the new configuration and reconfiguring the managed resource
+ resourceConfiguration = report.getConfiguration().deepCopy();
+
+ report.setStatus(ConfigurationUpdateStatus.SUCCESS);
+ }
+}
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java
deleted file mode 100644
index 2abd0ea..0000000
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ManualAddFacet;
-import org.rhq.core.pluginapi.inventory.ProcessScanResult;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-
-/**
- * This can be the start of your own custom plugin's discovery component. Review the javadoc for
- * {@link ResourceDiscoveryComponent}.
- *
- * @author John Mazzitelli
- */
-@SuppressWarnings("unchecked")
-public class SamplePluginDiscoveryComponent implements ResourceDiscoveryComponent, ManualAddFacet {
- private final Log log = LogFactory.getLog(SamplePluginDiscoveryComponent.class);
-
- /**
- * This discovery method is the way the plugin supports "manual-add" capability. The plugin
- * descriptor must specify supportsManualAdd="true" to allow the resource to be manually added.
- * If that attribute is false, this method will never be used since it will not be possible to manually
- * add an instance of the resource.
- *
- * Review the javadoc for both {@link ManualAddFacet} and {@link ResourceDiscoveryContext} to learn what
- * you need to do in this method.
- *
- * @see ManualAddFacet#discoverResource(Configuration, ResourceDiscoveryContext)
- */
- @Override
- public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration,
- ResourceDiscoveryContext context) throws InvalidPluginConfigurationException {
-
- // pluginConfiguration contains information on a resource that was manually added by the user.
- // take it and build a details object that represents that resource.
-
- // key = this must be a unique string across all of your resources - see docs for uniqueness rules
- // name = this is the name you give the new resource; it does not necessarily have to be unique
- // version = this is any string that corresponds to the resource's version
- // description = this is any string that you want to assign as the default description for your resource
- String key = "My Manually Added Resource Key";
- String name = "My Resource";
- String version = "1.0";
- String description = "This describes My Resource";
-
- DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
- version, description, pluginConfiguration, null);
-
- return resource;
- }
-
- /**
- * Review the javadoc for both {@link ResourceDiscoveryComponent} and {@link ResourceDiscoveryContext} to learn what
- * you need to do in this method.
- *
- * @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext)
- */
- @Override
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
- log.info("Discovering my custom plugin's resources");
-
- // if your plugin descriptor defined one or more <process-scan>s, then see if the plugin container
- // auto-discovered processes using those process scan definitions. Process all those that were found.
- List<ProcessScanResult> autoDiscoveryResults = context.getAutoDiscoveredProcesses();
- for (ProcessScanResult autoDiscoveryResult : autoDiscoveryResults) {
- // determine if you want to include the result in this method's returned set of discovered resources
- }
-
- // now perform your own discovery mechanism, if you have one. For each resource discovered, you need to
- // create a details object that describe the resource that you discovered.
- HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
-
- // key = this must be a unique string across all of your resources - see docs for uniqueness rules
- // name = this is the name you give the new resource; it does not necessarily have to be unique
- // version = this is any string that corresponds to the resource's version
- // description = this is any string that you want to assign as the default description for your resource
- String key = "My Resource Key";
- String name = "My Resource";
- String version = "1.0";
- String description = "This describes My Resource";
-
- DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
- version, description, null, null);
-
- set.add(resource);
-
- return set;
- }
-}
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java
deleted file mode 100644
index 0236532..0000000
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster;
-
-import java.io.InputStream;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
-import org.rhq.core.domain.content.PackageType;
-import org.rhq.core.domain.content.transfer.DeployPackageStep;
-import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
-import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
-import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.MeasurementDataNumeric;
-import org.rhq.core.domain.measurement.MeasurementReport;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
-import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
-import org.rhq.core.pluginapi.content.ContentFacet;
-import org.rhq.core.pluginapi.content.ContentServices;
-import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
-import org.rhq.core.pluginapi.inventory.CreateResourceReport;
-import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.core.pluginapi.measurement.MeasurementFacet;
-import org.rhq.core.pluginapi.operation.OperationFacet;
-import org.rhq.core.pluginapi.operation.OperationResult;
-
-/**
- * This can be the start of your own custom plugin's server component. Review the javadoc for {@link ResourceComponent}
- * and all the facet interfaces to learn what you can do in your resource component. This component has a lot of methods
- * in it because it implements all possible facets. If your resource does not support, for example, configuration, you
- * can remove the {@link ConfigurationFacet} from the <code>implements</code> clause and remove all method
- * implementations that that facet required.
- *
- * <p>You should not only read the javadoc in each of this class' methods, but you should also read the javadocs linked
- * by their "see" javadoc tags since those additional javadocs will contain a good deal of additional information you
- * will need to know.</p>
- *
- * @author John Mazzitelli
- */
-public class SamplePluginServerComponent implements ResourceComponent, MeasurementFacet, OperationFacet,
- ConfigurationFacet, ContentFacet, DeleteResourceFacet, CreateChildResourceFacet {
- private final Log log = LogFactory.getLog(SamplePluginServerComponent.class);
-
- /**
- * Represents the resource configuration of the custom product being managed.
- */
- private Configuration resourceConfiguration;
-
- /**
- * All AMPS plugins are stateful - this context contains information that your resource component can use when
- * performing its processing.
- */
- private ResourceContext resourceContext;
-
- /**
- * This is called when your component has been started with the given context. You normally initialize some internal
- * state of your component as well as attempt to make a stateful connection to your managed resource.
- *
- * @see ResourceComponent#start(ResourceContext)
- */
- public void start(ResourceContext context) {
- resourceContext = context;
- }
-
- /**
- * This is called when the component is being stopped, usually due to the plugin container shutting down. You can
- * perform some cleanup here; though normally not much needs to be done here.
- *
- * @see ResourceComponent#stop()
- */
- public void stop() {
- }
-
- /**
- * All resource components must be able to tell the plugin container if the managed resource is available or not.
- * This method is called by the plugin container when it needs to know if the managed resource is actually up and
- * available.
- *
- * @see ResourceComponent#getAvailability()
- */
- public AvailabilityType getAvailability() {
- // TODO: here you normally make some type of connection attempt to the managed resource
- // to determine if it is really up and running.
- return AvailabilityType.UP;
- }
-
- /**
- * The plugin container will call this method when your resource component has been scheduled to collect some
- * measurements now. It is within this method that you actually talk to the managed resource and collect the
- * measurement data that is has emitted.
- *
- * @see MeasurementFacet#getValues(MeasurementReport, Set)
- */
- public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) {
- for (MeasurementScheduleRequest request : requests) {
- String name = request.getName();
-
- // TODO: based on the request information, you must collect the requested measurement(s)
- // you can use the name of the measurement to determine what you actually need to collect
- try {
- Number value = new Integer(1); // dummy measurement value - this should come from the managed resource
- report.addData(new MeasurementDataNumeric(request, value.doubleValue()));
- } catch (Exception e) {
- log.error("Failed to obtain measurement [" + name + "]. Cause: " + e);
- }
- }
-
- return;
- }
-
- /**
- * The plugin container will call this method when it wants to invoke an operation on your managed resource. Your
- * plugin will connect to the managed resource and invoke the analogous operation in your own custom way.
- *
- * @see OperationFacet#invokeOperation(String, Configuration)
- */
- public OperationResult invokeOperation(String name, Configuration configuration) {
- return null;
- }
-
- /**
- * The plugin container will call this method and it needs to obtain the current configuration of the managed
- * resource. Your plugin will obtain the managed resource's configuration in your own custom way and populate the
- * returned Configuration object with the managed resource's configuration property values.
- *
- * @see ConfigurationFacet#loadResourceConfiguration()
- */
- public Configuration loadResourceConfiguration() {
- // here we simulate the loading of the managed resource's configuration
-
- if (resourceConfiguration == null) {
- // for this example, we will create a simple dummy configuration to start with.
- // note that it is empty, so we're assuming there are no required configs in the plugin descriptor.
- resourceConfiguration = new Configuration();
- }
-
- Configuration config = resourceConfiguration;
-
- return config;
- }
-
- /**
- * The plugin container will call this method when it has a new configuration for your managed resource. Your plugin
- * will re-configure the managed resource in your own custom way, setting its configuration based on the new values
- * of the given configuration.
- *
- * @see ConfigurationFacet#updateResourceConfiguration(ConfigurationUpdateReport)
- */
- public void updateResourceConfiguration(ConfigurationUpdateReport report) {
- // this simulates the plugin taking the new configuration and reconfiguring the managed resource
- resourceConfiguration = report.getConfiguration().deepCopy();
-
- report.setStatus(ConfigurationUpdateStatus.SUCCESS);
- }
-
- /**
- * When this is called, the plugin is responsible for scanning its managed resource and look for content that need
- * to be managed for that resource. This method should only discover packages of the given package type.
- *
- * @see ContentFacet#discoverDeployedPackages(PackageType)
- */
- public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) {
- return null;
- }
-
- /**
- * The plugin container calls this method when new packages need to be deployed/installed on resources.
- *
- * @see ContentFacet#deployPackages(Set, ContentServices)
- */
- public DeployPackagesResponse deployPackages(Set<ResourcePackageDetails> packages, ContentServices contentServices) {
- return null;
- }
-
- /**
- * When a remote client wants to see the actual data content for an installed package, this method will be called.
- * This method must return a stream of data containing the full content of the package.
- *
- * @see ContentFacet#retrievePackageBits(ResourcePackageDetails)
- */
- public InputStream retrievePackageBits(ResourcePackageDetails packageDetails) {
- return null;
- }
-
- /**
- * This is the method that is used when the component has to create the installation steps and their results.
- *
- * @see ContentFacet#generateInstallationSteps(ResourcePackageDetails)
- */
- public List<DeployPackageStep> generateInstallationSteps(ResourcePackageDetails packageDetails) {
- return null;
- }
-
- /**
- * This is called when the actual content of packages should be deleted from the managed resource.
- *
- * @see ContentFacet#removePackages(Set)
- */
- public RemovePackagesResponse removePackages(Set<ResourcePackageDetails> packages) {
- return null;
- }
-
- /**
- * When called, the plugin container is asking the plugin to create a new managed resource. The new resource's
- * details need to be added to the given report.
- *
- * @see CreateChildResourceFacet#createResource(CreateResourceReport)
- */
- public CreateResourceReport createResource(CreateResourceReport report) {
- return null;
- }
-
- /**
- * When called, the plugin container is asking the plugin to delete a managed resource.
- *
- * @see DeleteResourceFacet#deleteResource()
- */
- public void deleteResource() {
- }
-}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 1a99bf7..fe6d1b3 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -10,97 +10,23 @@
<depends plugin="JMX" />
- <!--
- CHANGE: The following is a sample server resource type. This entry is here to serve as a model and should
- be removed prior to deploying the plugin. Multiple resource types (either server or service) may be
- defined at this level.
- -->
- <server name="mod_cluster"
- discovery="SamplePluginDiscoveryComponent"
- class="SamplePluginServerComponent"
+ <service name="mod_cluster"
+ discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
+ class="LoadMetric"
supportsManualAdd="true"
description="mod_cluster plugin">
-
- <!--
- CHANGE: Categories are optional; this entire section may be removed if there is no need to further group
- related child resources. Categories defined at this level can carry metadata on the category itself,
- such as a display name and description.
- -->
- <subcategories>
- <subcategory name="Category1" displayName="Sample Category 1"
- description="This is a sample category that should be removed."/>
- <subcategory name="Category2" >
- <subcategory name="ChildCategory2a" />
- </subcategory>
- </subcategories>
-
- <!--
- CHANGE: The entire plugin configuration is optional. If there are properties specific to handling how the
- resource component will connect to the resource, they should be added here. If the plugin-configuration
- entity is specified, at least one property must be provided.
- -->
- <plugin-configuration>
- <c:simple-property name="SamplePluginProperty" displayName="Sample Plugin Property" default="Value" />
+
+ <!-- runs-inside>
+ <parent-resource-type name="JMX Server" plugin="JMX"/>
+ </runs-inside-->
+ <runs-inside>
+ <parent-resource-type name="JMX Server" plugin="JMX"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="connectorAddress" default="http://192.168.1.56:6666"/>
+ <c:simple-property name="objectName" readOnly="true" default="ModClusterServiceMBean"/>
</plugin-configuration>
- <!--
- CHANGE: The process-scan element requests the plugin container provide the discovery component for
- this resource type with the results of scanning the machine for running processes. If there is
- no use for this in a given resource type, this entry may be omitted.
- -->
- <process-scan name="ScanIdentifier" query="process|basename|match=^java.*,arg|org.jboss.Main|match=.*"/>
-
- <!--
- CHANGE: An operation element is added for each operation that may be executed against resources of this type.
- The parameters element is optional; properties defined within will be displayed to the user when
- invoking the operation. If the resource has no applicable operations, these elements may be omitted.
-
- REQUIRED INTERFACE: The resource component for this resource type must implement the OperationFacet interface
- if any operations are specified.
- -->
- <operation name="testSimple"
- description="Test simple-property configuration element for a resource operation">
- <parameters>
- <c:group name="required" displayName="Required Parameters" hiddenByDefault="false">
- <c:description>All of these properties are required</c:description>
- <c:simple-property name="aNumber" type="integer" required="true" default="42" displayName="A Number" description="A number between 1 and 100, inclusive">
- <c:constraint>
- <c:integer-constraint minimum="1" maximum="100"/>
- </c:constraint>
- </c:simple-property>
- </c:group>
- </parameters>
- <results>
- <c:simple-property name="results" />
- </results>
- </operation>
-
- <!--
- CHANGE: For each measurement that should be collected for resources of this type, a metric element is added.
- In addition to identifying the metric, a default collection interval and whether or not the
- metric is even collected by default are indicated. If the resource has no measurements to be
- collected, these elements may be omitted.
-
- REQUIRED INTERFACE: The resource component for this resource type must implement the MeasurementFacet interface
- if any metrics are specified.
- -->
- <metric property="MeasurementName"
- displayName="The Measurement Name"
- description="Describes what this measurement is actually telling you"
- defaultOn="true"
- defaultInterval="300000"
- category="performance" />
-
- <!--
- CHANGE: Resource configuration properties are used to configure resources themselves, as compared to the plugin
- configuration which refers to the connection to a resource. If the resource-configuration
- entity is specified, at least one property must be provided.
-
- REQUIRED INTERFACE: The resource component for this resource type must implement the ConfigurationFacet
- interface if a resource-configuration element is supplied.
- -->
- <resource-configuration>
- <c:simple-property name="port" type="integer" displayName="Port on which to listen" />
- </resource-configuration>
- </server>
+ </service>
</plugin>
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index bada521..971ccb1 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -24,6 +24,9 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.domain.resource.Resource;
@@ -32,22 +35,19 @@ import org.rhq.core.pc.PluginContainerConfiguration;
import org.rhq.core.pc.plugin.FileSystemPluginFinder;
import org.rhq.core.pc.plugin.PluginEnvironment;
import org.rhq.core.pc.plugin.PluginManager;
-import org.testng.annotations.AfterSuite;
-import org.testng.annotations.BeforeSuite;
-import org.testng.annotations.Test;
/**
* @author Fady Matar
*/
-@Test(groups = "tomcat-plugin")
+@Test(groups = "modcluster-plugin")
public class ModclusterPluginTest {
private Log log = LogFactory.getLog(this.getClass());
- private static final String PLUGIN_NAME = "Tomcat";
+ private static final String PLUGIN_NAME = "mod_cluster";
@BeforeSuite
public void start() {
try {
- File pluginDir = new File("target/itest/plugins");
+ File pluginDir = new File("target/testsetup/plugins");
PluginContainerConfiguration pcConfig = new PluginContainerConfiguration();
pcConfig.setPluginFinder(new FileSystemPluginFinder(pluginDir));
pcConfig.setPluginDirectory(pluginDir);
@@ -75,16 +75,22 @@ public class ModclusterPluginTest {
PluginEnvironment pluginEnvironment = pluginManager.getPlugin(PLUGIN_NAME);
assert (pluginEnvironment != null) : "Null environment, plugin not loaded";
assert (pluginEnvironment.getPluginName().equals(PLUGIN_NAME));
+
}
@Test(dependsOnMethods = "testPluginLoad")
public void testDiscovery() throws Exception {
InventoryReport report = PluginContainer.getInstance().getInventoryManager().executeServerScanImmediately();
assert report != null;
- log.info("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+ System.out.println("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+
+ report = PluginContainer.getInstance().getInventoryManager().executeServiceScanImmediately();
+ assert report != null;
+ System.out.println("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+
Set<Resource> resources = findResource(PluginContainer.getInstance().getInventoryManager().getPlatform(),
- "Tomcat");
- log.info("Found " + resources.size() + " ews / apache tomcat instance(s).");
+ PLUGIN_NAME);
+ log.info("Found " + resources.size() + "mod_cluster instance(s).");
}
private Set<Resource> findResource(Resource parent, String typeName) {
commit 288af403c3c181cb3915b2fbe067bb23937f1e39
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jun 23 11:09:56 2011 -0500
A couple of updates to modcluster plugin based on tomcat plugin (modified the initial template commit).
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml
index b72c93d..e22efc7 100644
--- a/modules/plugins/mod-cluster/pom.xml
+++ b/modules/plugins/mod-cluster/pom.xml
@@ -1,25 +1,36 @@
<?xml version="1.0"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.rhq.sample.skeletonplugin</groupId>
- <artifactId>skeleton-plugin</artifactId>
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-plugins-parent</artifactId>
+ <version>4.1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.rhq.plugins.modcluster</groupId>
+ <artifactId>modcluster-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
- <name>Skeleton RHQ Plugin Template</name>
- <description>A template for building a custom RHQ Agent plugin</description>
+ <name>mod_cluster RHQ Plugin</name>
+ <description>mod_cluster RHQ Agent plugin</description>
- <properties>
+ <!--properties>
<rhq.version>4.1.0-SNAPSHOT</rhq.version>
- </properties>
+ </properties-->
<dependencies>
+ <dependency>
+ <groupId>${rhq.groupId}</groupId>
+ <artifactId>rhq-jmx-plugin</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
<!-- Below are the core modules that are required dependencies of all plugins -->
<dependency>
<groupId>org.rhq</groupId>
@@ -77,15 +88,14 @@
<scope>provided</scope>
</dependency>
- <!--
+
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>provided</scope>
</dependency>
- -->
-
+
<!--
<dependency>
<groupId>i18nlog</groupId>
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java
index 2bb46e6..2abd0ea 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-package org.rhq.sample.skeletonplugin;
+package org.rhq.plugins.modcluster;
import java.util.HashSet;
import java.util.List;
@@ -113,4 +113,4 @@ public class SamplePluginDiscoveryComponent implements ResourceDiscoveryComponen
return set;
}
-}
\ No newline at end of file
+}
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java
index 701afb0..0236532 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-package org.rhq.sample.skeletonplugin;
+package org.rhq.plugins.modcluster;
import java.io.InputStream;
import java.util.List;
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 2547af7..1a99bf7 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -1,36 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- See the rhq-plugin.xsd file for detailed documentatoin on the schema. The notes in this file are to
- facilitate using this file as a base plugin descriptor.
--->
-
-<!--
- CHANGE: The name (and optional displayName) should be changed to reflect the plugin being developed. Keep in mind
- the value for name must be unique across all other plugins that are deployed.
-
- The package attribute should be changed to reflect the package in which all of the component classes
- are built.
--->
-<plugin name="SkeletonPlugin"
- displayName="Skeleton Plugin"
+<plugin name="mod_cluster"
+ displayName="mod_cluster"
version="1.0"
- package="org.rhq.sample.skeletonplugin"
+ package="org.rhq.plugins.modcluster"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin"
xmlns:c="urn:xmlns:rhq-configuration">
+ <depends plugin="JMX" />
- <!--
+ <!--
CHANGE: The following is a sample server resource type. This entry is here to serve as a model and should
be removed prior to deploying the plugin. Multiple resource types (either server or service) may be
defined at this level.
-->
- <server name="Sample Plugin Server"
+ <server name="mod_cluster"
discovery="SamplePluginDiscoveryComponent"
class="SamplePluginServerComponent"
supportsManualAdd="true"
- description="This is a sample resource type and should be removed.">
+ description="mod_cluster plugin">
<!--
CHANGE: Categories are optional; this entire section may be removed if there is no need to further group
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
new file mode 100644
index 0000000..bada521
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -0,0 +1,106 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster.test;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.clientapi.server.discovery.InventoryReport;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.pc.PluginContainer;
+import org.rhq.core.pc.PluginContainerConfiguration;
+import org.rhq.core.pc.plugin.FileSystemPluginFinder;
+import org.rhq.core.pc.plugin.PluginEnvironment;
+import org.rhq.core.pc.plugin.PluginManager;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
+
+/**
+ * @author Fady Matar
+ */
+@Test(groups = "tomcat-plugin")
+public class ModclusterPluginTest {
+ private Log log = LogFactory.getLog(this.getClass());
+ private static final String PLUGIN_NAME = "Tomcat";
+
+ @BeforeSuite
+ public void start() {
+ try {
+ File pluginDir = new File("target/itest/plugins");
+ PluginContainerConfiguration pcConfig = new PluginContainerConfiguration();
+ pcConfig.setPluginFinder(new FileSystemPluginFinder(pluginDir));
+ pcConfig.setPluginDirectory(pluginDir);
+
+ pcConfig.setInsideAgent(false);
+ PluginContainer.getInstance().setConfiguration(pcConfig);
+ PluginContainer.getInstance().initialize();
+ log.info("PC started.");
+ for (String plugin : PluginContainer.getInstance().getPluginManager().getMetadataManager().getPluginNames()) {
+ log.info("...Loaded plugin: " + plugin);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterSuite
+ public void stop() {
+ PluginContainer.getInstance().shutdown();
+ }
+
+ @Test
+ public void testPluginLoad() {
+ PluginManager pluginManager = PluginContainer.getInstance().getPluginManager();
+ PluginEnvironment pluginEnvironment = pluginManager.getPlugin(PLUGIN_NAME);
+ assert (pluginEnvironment != null) : "Null environment, plugin not loaded";
+ assert (pluginEnvironment.getPluginName().equals(PLUGIN_NAME));
+ }
+
+ @Test(dependsOnMethods = "testPluginLoad")
+ public void testDiscovery() throws Exception {
+ InventoryReport report = PluginContainer.getInstance().getInventoryManager().executeServerScanImmediately();
+ assert report != null;
+ log.info("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+ Set<Resource> resources = findResource(PluginContainer.getInstance().getInventoryManager().getPlatform(),
+ "Tomcat");
+ log.info("Found " + resources.size() + " ews / apache tomcat instance(s).");
+ }
+
+ private Set<Resource> findResource(Resource parent, String typeName) {
+ Set<Resource> found = new HashSet<Resource>();
+ Resource platform = parent;
+ for (Resource resource : platform.getChildResources()) {
+ log.info("Discovered resource of type: " + resource.getResourceType().getName());
+ if (resource.getResourceType().getName().equals(typeName)) {
+ found.add(resource);
+ }
+ if (resource.getChildResources() != null) {
+ for (Resource child : found) {
+ found.addAll(findResource(child, typeName));
+ }
+ }
+ }
+ return found;
+ }
+}
diff --git a/modules/plugins/mod-cluster/src/test/resources/log4j.xml b/modules/plugins/mod-cluster/src/test/resources/log4j.xml
new file mode 100644
index 0000000..9ac1be8
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/test/resources/log4j.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml 9973 2008-05-08 00:57:31Z ispringer $ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="INFO"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Messagen -->
+
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+
+ <!--<param name="ConversionPattern" value="%-5p %d{dd-MM HH:mm:ss,SSS} (%F:%M:%L) -%m%n"/>-->
+ </layout>
+ </appender>
+
+ <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
+ <param name="File" value="target/test.log"/>
+ <param name="Threshold" value="DEBUG"/>
+ <param name="Append" value="false"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Messagen -->
+ <!--
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ -->
+ <param name="ConversionPattern" value="%-5p %d{dd-MM HH:mm:ss,SSS} (%F:%M:%L) -%m%n"/>
+ </layout>
+ </appender>
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
commit f5d95830a0ef0c23f58af2f60e34375a2b9273b9
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Jun 22 15:52:27 2011 -0500
Start for mod_cluster plugin from skeleton-plugin template.
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml
new file mode 100644
index 0000000..b72c93d
--- /dev/null
+++ b/modules/plugins/mod-cluster/pom.xml
@@ -0,0 +1,240 @@
+<?xml version="1.0"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.rhq.sample.skeletonplugin</groupId>
+ <artifactId>skeleton-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>Skeleton RHQ Plugin Template</name>
+ <description>A template for building a custom RHQ Agent plugin</description>
+
+ <properties>
+ <rhq.version>4.1.0-SNAPSHOT</rhq.version>
+ </properties>
+
+ <dependencies>
+
+ <!-- Below are the core modules that are required dependencies of all plugins -->
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${rhq.version}</version>
+ <scope>provided</scope> <!-- provided by the agent/plugin-container -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-plugin-api</artifactId>
+ <version>${rhq.version}</version>
+ <scope>provided</scope> <!-- provided by the agent/plugin-container -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-native-system</artifactId>
+ <version>${rhq.version}</version>
+ <scope>provided</scope> <!-- provided by the agent/plugin-container -->
+ </dependency>
+
+ <!-- Fix for the Javac bug requiring annotations to be available when compiling classes. (fixed in JDK 6) -->
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope> <!-- provided by the agent/plugin-container -->
+ </dependency>
+
+ <!-- Fix for the Javac bug requiring annotations to be available when compiling classes. (fixed in JDK 6) -->
+ <dependency>
+ <groupId>hibernate-annotations</groupId>
+ <artifactId>hibernate-annotations</artifactId>
+ <version>3.2.1.GA</version>
+ <scope>provided</scope> <!-- provided by the agent/plugin-container -->
+ </dependency>
+
+ <!-- Fix for the Javac bug requiring annotations to be available when compiling classes. (fixed in JDK 6) -->
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope> <!-- provided by the agent/plugin-container -->
+ </dependency>
+
+ <!--
+ Uncomment the one of the three logging systems your plugin uses: log4j, commons-logging or i18nlog
+ All three are provided to your plugin by the agent/plugin-container.
+ -->
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!--
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>provided</scope>
+ </dependency>
+ -->
+
+ <!--
+ <dependency>
+ <groupId>i18nlog</groupId>
+ <artifactId>i18nlog</artifactId>
+ <version>1.0.9</version>
+ <scope>provided</scope>
+ </dependency>
+ -->
+
+ <!-- Define any third-party dependencies your plugin has here. -->
+ <!--
+ <dependency>
+ <groupId>group-id-of-dependency-goes-here</groupId>
+ <artifactId>artifact-id-of-dependency-goes-here</artifactId>
+ <version>version-of-dependency-goes-here</version>
+ </dependency>
+ -->
+
+ </dependencies>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+
+ <!--
+ If your plugin has third-party jar dependencies that are not already available when deployed in the plugin
+ container, you can package these jars in your plugin. They go in your plugin jar's "lib" directory.
+ Uncomment the maven plugin definition below and define one or more jar files (aka "artifactItem" elements)
+ that you want to include in your plugin jar.
+ -->
+ <!--
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>your-third-party-dep-group</groupId>
+ <artifactId>your-third-party-dep-artifact</artifactId>
+ <version>your-third-party-dep-version</version>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ -->
+
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>dev</id>
+ <properties>
+ <!-- define the location of your RHQ root directory - typically rhq.rootDir is overridden in Maven's settings.xml -->
+ <rhq.rootDir>/rhq/trunk</rhq.rootDir>
+ <rhq.defaultDevContainerPath>dev-container</rhq.defaultDevContainerPath>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/rhq.ear/rhq-downloads/rhq-plugins</rhq.deploymentDir>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${rhq.deploymentDir}" />
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>deploy-jar-meta-inf</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating META-INF dir in ${deployment.file}...</echo>
+ <unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.outputDirectory}">
+ <patternset>
+ <include name="META-INF/**" />
+ </patternset>
+ </unjar>
+ <jar destfile="${deployment.file}"
+ manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF"
+ update="true">
+ </jar>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <repositories>
+ <repository>
+ <id>jboss-public-repository-group</id>
+ <name>JBoss Public Maven Repository Group</name>
+ <url>https://repository.jboss.org/nexus/content/groups/public/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+</project>
+
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java
new file mode 100644
index 0000000..2bb46e6
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java
@@ -0,0 +1,116 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.sample.skeletonplugin;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ManualAddFacet;
+import org.rhq.core.pluginapi.inventory.ProcessScanResult;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+
+/**
+ * This can be the start of your own custom plugin's discovery component. Review the javadoc for
+ * {@link ResourceDiscoveryComponent}.
+ *
+ * @author John Mazzitelli
+ */
+@SuppressWarnings("unchecked")
+public class SamplePluginDiscoveryComponent implements ResourceDiscoveryComponent, ManualAddFacet {
+ private final Log log = LogFactory.getLog(SamplePluginDiscoveryComponent.class);
+
+ /**
+ * This discovery method is the way the plugin supports "manual-add" capability. The plugin
+ * descriptor must specify supportsManualAdd="true" to allow the resource to be manually added.
+ * If that attribute is false, this method will never be used since it will not be possible to manually
+ * add an instance of the resource.
+ *
+ * Review the javadoc for both {@link ManualAddFacet} and {@link ResourceDiscoveryContext} to learn what
+ * you need to do in this method.
+ *
+ * @see ManualAddFacet#discoverResource(Configuration, ResourceDiscoveryContext)
+ */
+ @Override
+ public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration,
+ ResourceDiscoveryContext context) throws InvalidPluginConfigurationException {
+
+ // pluginConfiguration contains information on a resource that was manually added by the user.
+ // take it and build a details object that represents that resource.
+
+ // key = this must be a unique string across all of your resources - see docs for uniqueness rules
+ // name = this is the name you give the new resource; it does not necessarily have to be unique
+ // version = this is any string that corresponds to the resource's version
+ // description = this is any string that you want to assign as the default description for your resource
+ String key = "My Manually Added Resource Key";
+ String name = "My Resource";
+ String version = "1.0";
+ String description = "This describes My Resource";
+
+ DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
+ version, description, pluginConfiguration, null);
+
+ return resource;
+ }
+
+ /**
+ * Review the javadoc for both {@link ResourceDiscoveryComponent} and {@link ResourceDiscoveryContext} to learn what
+ * you need to do in this method.
+ *
+ * @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext)
+ */
+ @Override
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
+ log.info("Discovering my custom plugin's resources");
+
+ // if your plugin descriptor defined one or more <process-scan>s, then see if the plugin container
+ // auto-discovered processes using those process scan definitions. Process all those that were found.
+ List<ProcessScanResult> autoDiscoveryResults = context.getAutoDiscoveredProcesses();
+ for (ProcessScanResult autoDiscoveryResult : autoDiscoveryResults) {
+ // determine if you want to include the result in this method's returned set of discovered resources
+ }
+
+ // now perform your own discovery mechanism, if you have one. For each resource discovered, you need to
+ // create a details object that describe the resource that you discovered.
+ HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
+
+ // key = this must be a unique string across all of your resources - see docs for uniqueness rules
+ // name = this is the name you give the new resource; it does not necessarily have to be unique
+ // version = this is any string that corresponds to the resource's version
+ // description = this is any string that you want to assign as the default description for your resource
+ String key = "My Resource Key";
+ String name = "My Resource";
+ String version = "1.0";
+ String description = "This describes My Resource";
+
+ DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
+ version, description, null, null);
+
+ set.add(resource);
+
+ return set;
+ }
+}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java
new file mode 100644
index 0000000..701afb0
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java
@@ -0,0 +1,245 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.sample.skeletonplugin;
+
+import java.io.InputStream;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.content.PackageType;
+import org.rhq.core.domain.content.transfer.DeployPackageStep;
+import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
+import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
+import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.pluginapi.content.ContentFacet;
+import org.rhq.core.pluginapi.content.ContentServices;
+import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
+
+/**
+ * This can be the start of your own custom plugin's server component. Review the javadoc for {@link ResourceComponent}
+ * and all the facet interfaces to learn what you can do in your resource component. This component has a lot of methods
+ * in it because it implements all possible facets. If your resource does not support, for example, configuration, you
+ * can remove the {@link ConfigurationFacet} from the <code>implements</code> clause and remove all method
+ * implementations that that facet required.
+ *
+ * <p>You should not only read the javadoc in each of this class' methods, but you should also read the javadocs linked
+ * by their "see" javadoc tags since those additional javadocs will contain a good deal of additional information you
+ * will need to know.</p>
+ *
+ * @author John Mazzitelli
+ */
+public class SamplePluginServerComponent implements ResourceComponent, MeasurementFacet, OperationFacet,
+ ConfigurationFacet, ContentFacet, DeleteResourceFacet, CreateChildResourceFacet {
+ private final Log log = LogFactory.getLog(SamplePluginServerComponent.class);
+
+ /**
+ * Represents the resource configuration of the custom product being managed.
+ */
+ private Configuration resourceConfiguration;
+
+ /**
+ * All AMPS plugins are stateful - this context contains information that your resource component can use when
+ * performing its processing.
+ */
+ private ResourceContext resourceContext;
+
+ /**
+ * This is called when your component has been started with the given context. You normally initialize some internal
+ * state of your component as well as attempt to make a stateful connection to your managed resource.
+ *
+ * @see ResourceComponent#start(ResourceContext)
+ */
+ public void start(ResourceContext context) {
+ resourceContext = context;
+ }
+
+ /**
+ * This is called when the component is being stopped, usually due to the plugin container shutting down. You can
+ * perform some cleanup here; though normally not much needs to be done here.
+ *
+ * @see ResourceComponent#stop()
+ */
+ public void stop() {
+ }
+
+ /**
+ * All resource components must be able to tell the plugin container if the managed resource is available or not.
+ * This method is called by the plugin container when it needs to know if the managed resource is actually up and
+ * available.
+ *
+ * @see ResourceComponent#getAvailability()
+ */
+ public AvailabilityType getAvailability() {
+ // TODO: here you normally make some type of connection attempt to the managed resource
+ // to determine if it is really up and running.
+ return AvailabilityType.UP;
+ }
+
+ /**
+ * The plugin container will call this method when your resource component has been scheduled to collect some
+ * measurements now. It is within this method that you actually talk to the managed resource and collect the
+ * measurement data that is has emitted.
+ *
+ * @see MeasurementFacet#getValues(MeasurementReport, Set)
+ */
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) {
+ for (MeasurementScheduleRequest request : requests) {
+ String name = request.getName();
+
+ // TODO: based on the request information, you must collect the requested measurement(s)
+ // you can use the name of the measurement to determine what you actually need to collect
+ try {
+ Number value = new Integer(1); // dummy measurement value - this should come from the managed resource
+ report.addData(new MeasurementDataNumeric(request, value.doubleValue()));
+ } catch (Exception e) {
+ log.error("Failed to obtain measurement [" + name + "]. Cause: " + e);
+ }
+ }
+
+ return;
+ }
+
+ /**
+ * The plugin container will call this method when it wants to invoke an operation on your managed resource. Your
+ * plugin will connect to the managed resource and invoke the analogous operation in your own custom way.
+ *
+ * @see OperationFacet#invokeOperation(String, Configuration)
+ */
+ public OperationResult invokeOperation(String name, Configuration configuration) {
+ return null;
+ }
+
+ /**
+ * The plugin container will call this method and it needs to obtain the current configuration of the managed
+ * resource. Your plugin will obtain the managed resource's configuration in your own custom way and populate the
+ * returned Configuration object with the managed resource's configuration property values.
+ *
+ * @see ConfigurationFacet#loadResourceConfiguration()
+ */
+ public Configuration loadResourceConfiguration() {
+ // here we simulate the loading of the managed resource's configuration
+
+ if (resourceConfiguration == null) {
+ // for this example, we will create a simple dummy configuration to start with.
+ // note that it is empty, so we're assuming there are no required configs in the plugin descriptor.
+ resourceConfiguration = new Configuration();
+ }
+
+ Configuration config = resourceConfiguration;
+
+ return config;
+ }
+
+ /**
+ * The plugin container will call this method when it has a new configuration for your managed resource. Your plugin
+ * will re-configure the managed resource in your own custom way, setting its configuration based on the new values
+ * of the given configuration.
+ *
+ * @see ConfigurationFacet#updateResourceConfiguration(ConfigurationUpdateReport)
+ */
+ public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ // this simulates the plugin taking the new configuration and reconfiguring the managed resource
+ resourceConfiguration = report.getConfiguration().deepCopy();
+
+ report.setStatus(ConfigurationUpdateStatus.SUCCESS);
+ }
+
+ /**
+ * When this is called, the plugin is responsible for scanning its managed resource and look for content that need
+ * to be managed for that resource. This method should only discover packages of the given package type.
+ *
+ * @see ContentFacet#discoverDeployedPackages(PackageType)
+ */
+ public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) {
+ return null;
+ }
+
+ /**
+ * The plugin container calls this method when new packages need to be deployed/installed on resources.
+ *
+ * @see ContentFacet#deployPackages(Set, ContentServices)
+ */
+ public DeployPackagesResponse deployPackages(Set<ResourcePackageDetails> packages, ContentServices contentServices) {
+ return null;
+ }
+
+ /**
+ * When a remote client wants to see the actual data content for an installed package, this method will be called.
+ * This method must return a stream of data containing the full content of the package.
+ *
+ * @see ContentFacet#retrievePackageBits(ResourcePackageDetails)
+ */
+ public InputStream retrievePackageBits(ResourcePackageDetails packageDetails) {
+ return null;
+ }
+
+ /**
+ * This is the method that is used when the component has to create the installation steps and their results.
+ *
+ * @see ContentFacet#generateInstallationSteps(ResourcePackageDetails)
+ */
+ public List<DeployPackageStep> generateInstallationSteps(ResourcePackageDetails packageDetails) {
+ return null;
+ }
+
+ /**
+ * This is called when the actual content of packages should be deleted from the managed resource.
+ *
+ * @see ContentFacet#removePackages(Set)
+ */
+ public RemovePackagesResponse removePackages(Set<ResourcePackageDetails> packages) {
+ return null;
+ }
+
+ /**
+ * When called, the plugin container is asking the plugin to create a new managed resource. The new resource's
+ * details need to be added to the given report.
+ *
+ * @see CreateChildResourceFacet#createResource(CreateResourceReport)
+ */
+ public CreateResourceReport createResource(CreateResourceReport report) {
+ return null;
+ }
+
+ /**
+ * When called, the plugin container is asking the plugin to delete a managed resource.
+ *
+ * @see DeleteResourceFacet#deleteResource()
+ */
+ public void deleteResource() {
+ }
+}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
new file mode 100644
index 0000000..2547af7
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!--
+ See the rhq-plugin.xsd file for detailed documentatoin on the schema. The notes in this file are to
+ facilitate using this file as a base plugin descriptor.
+-->
+
+<!--
+ CHANGE: The name (and optional displayName) should be changed to reflect the plugin being developed. Keep in mind
+ the value for name must be unique across all other plugins that are deployed.
+
+ The package attribute should be changed to reflect the package in which all of the component classes
+ are built.
+-->
+<plugin name="SkeletonPlugin"
+ displayName="Skeleton Plugin"
+ version="1.0"
+ package="org.rhq.sample.skeletonplugin"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration">
+
+
+ <!--
+ CHANGE: The following is a sample server resource type. This entry is here to serve as a model and should
+ be removed prior to deploying the plugin. Multiple resource types (either server or service) may be
+ defined at this level.
+ -->
+ <server name="Sample Plugin Server"
+ discovery="SamplePluginDiscoveryComponent"
+ class="SamplePluginServerComponent"
+ supportsManualAdd="true"
+ description="This is a sample resource type and should be removed.">
+
+ <!--
+ CHANGE: Categories are optional; this entire section may be removed if there is no need to further group
+ related child resources. Categories defined at this level can carry metadata on the category itself,
+ such as a display name and description.
+ -->
+ <subcategories>
+ <subcategory name="Category1" displayName="Sample Category 1"
+ description="This is a sample category that should be removed."/>
+ <subcategory name="Category2" >
+ <subcategory name="ChildCategory2a" />
+ </subcategory>
+ </subcategories>
+
+ <!--
+ CHANGE: The entire plugin configuration is optional. If there are properties specific to handling how the
+ resource component will connect to the resource, they should be added here. If the plugin-configuration
+ entity is specified, at least one property must be provided.
+ -->
+ <plugin-configuration>
+ <c:simple-property name="SamplePluginProperty" displayName="Sample Plugin Property" default="Value" />
+ </plugin-configuration>
+
+ <!--
+ CHANGE: The process-scan element requests the plugin container provide the discovery component for
+ this resource type with the results of scanning the machine for running processes. If there is
+ no use for this in a given resource type, this entry may be omitted.
+ -->
+ <process-scan name="ScanIdentifier" query="process|basename|match=^java.*,arg|org.jboss.Main|match=.*"/>
+
+ <!--
+ CHANGE: An operation element is added for each operation that may be executed against resources of this type.
+ The parameters element is optional; properties defined within will be displayed to the user when
+ invoking the operation. If the resource has no applicable operations, these elements may be omitted.
+
+ REQUIRED INTERFACE: The resource component for this resource type must implement the OperationFacet interface
+ if any operations are specified.
+ -->
+ <operation name="testSimple"
+ description="Test simple-property configuration element for a resource operation">
+ <parameters>
+ <c:group name="required" displayName="Required Parameters" hiddenByDefault="false">
+ <c:description>All of these properties are required</c:description>
+ <c:simple-property name="aNumber" type="integer" required="true" default="42" displayName="A Number" description="A number between 1 and 100, inclusive">
+ <c:constraint>
+ <c:integer-constraint minimum="1" maximum="100"/>
+ </c:constraint>
+ </c:simple-property>
+ </c:group>
+ </parameters>
+ <results>
+ <c:simple-property name="results" />
+ </results>
+ </operation>
+
+ <!--
+ CHANGE: For each measurement that should be collected for resources of this type, a metric element is added.
+ In addition to identifying the metric, a default collection interval and whether or not the
+ metric is even collected by default are indicated. If the resource has no measurements to be
+ collected, these elements may be omitted.
+
+ REQUIRED INTERFACE: The resource component for this resource type must implement the MeasurementFacet interface
+ if any metrics are specified.
+ -->
+ <metric property="MeasurementName"
+ displayName="The Measurement Name"
+ description="Describes what this measurement is actually telling you"
+ defaultOn="true"
+ defaultInterval="300000"
+ category="performance" />
+
+ <!--
+ CHANGE: Resource configuration properties are used to configure resources themselves, as compared to the plugin
+ configuration which refers to the connection to a resource. If the resource-configuration
+ entity is specified, at least one property must be provided.
+
+ REQUIRED INTERFACE: The resource component for this resource type must implement the ConfigurationFacet
+ interface if a resource-configuration element is supplied.
+ -->
+ <resource-configuration>
+ <c:simple-property name="port" type="integer" displayName="Port on which to listen" />
+ </resource-configuration>
+ </server>
+</plugin>
commit b13a3515a996de937f8345fa287f044f90454d41
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Jul 27 22:42:04 2011 -0500
Make the error message useful by adding the name of the attribute that failed to set.
diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
index 2e1ae41..cb7f901 100644
--- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
+++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
@@ -503,7 +503,7 @@ public class MBeanResourceComponent<T extends JMXComponent> implements Measureme
property.setErrorMessage(ThrowableUtil.getStackAsString(e));
report
.setErrorMessage("Failed setting resource configuration - see property error messages for details");
- log.info("Failure setting MBean Resource configuration value", e);
+ log.info("Failure setting MBean Resource configuration value for " + key, e);
}
}
}
commit 7e0f49de3b2da3b4b4d1987eb3fe53e42abbbf68
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Jul 27 22:41:13 2011 -0500
Final touches for mod_cluster plugin configuration. Updated a couple of the plugin settings to match mod_cluster specifications.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
index 5c9c3fd..3d03715 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
@@ -42,9 +42,9 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
@SuppressWarnings("rawtypes")
public class ContextDiscoveryComponent implements ResourceDiscoveryComponent<MBeanResourceComponent> {
- private final String JVM_ROUTE_PROPERTY = "jvmRoute";
- private final String PROXY_INFO_PROPERTY = "proxyInfo";
- private final String ADDITIONAL_CONFIG_BEAN_PROPERTY = "additionalConfigurationObjectName";
+ private static final String JVM_ROUTE_PROPERTY = "jvmRoute";
+ private static final String PROXY_INFO_PROPERTY = "proxyInfo";
+ private static final String ENGINE_OBJECT_NAME = "engineObjectName";
/* (non-Javadoc)
* @see org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext)
@@ -76,8 +76,8 @@ public class ContextDiscoveryComponent implements ResourceDiscoveryComponent<MBe
*/
private String getJvmRoute(ResourceDiscoveryContext<MBeanResourceComponent> context) {
Configuration pluginConfig = context.getParentResourceComponent().getResourceContext().getPluginConfiguration();
- String objectName = pluginConfig.getSimple(ADDITIONAL_CONFIG_BEAN_PROPERTY).getStringValue();
- EmsBean engineBean = this.loadBean(objectName, context.getParentResourceComponent());
+ String engineObjectName = pluginConfig.getSimple(ENGINE_OBJECT_NAME).getStringValue();
+ EmsBean engineBean = this.loadBean(engineObjectName, context.getParentResourceComponent());
return (String) engineBean.getAttribute(JVM_ROUTE_PROPERTY).refresh().toString();
}
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index 591fef6..70898ef 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -25,7 +25,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
* @author Stefan Negrea
*
*/
-@SuppressWarnings("rawtypes")
+@SuppressWarnings({ "rawtypes" })
public class ModclusterServerComponent extends MBeanResourceComponent {
/* (non-Javadoc)
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 992c5b0..29b334f 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -25,9 +25,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="Catalina:type=ModClusterListener,*"/>
- <c:simple-property name="additionalConfigurationObjectName" readOnly="true" default="jboss.web:type=Engine"/>
- <c:simple-property name="jvmRoute" readOnly="false"/>
- <c:simple-property name="nameTemplate" default="mod_cluster"/>
+ <c:simple-property name="engineObjectName" readOnly="true" default="jboss.web:type=Engine"/>
</plugin-configuration>
<operation name="stop" displayName="Stop all webapps" description="Gracefully stops all webapps for all engines.">
@@ -76,12 +74,12 @@
<metric property="proxyConfiguration" displayName="Proxy Configuration" displayType="summary" dataType="trait" />
<metric property="modelerType" displayName="Type of the modeled resource" displayType="summary" dataType="trait" />
<metric property="className" displayName="Fully qualified class name of the managed object" displayType="summary" dataType="trait" />
+ <metric property="advertise" displayName="Enable autodiscovery of httpd servers." displayType="summary" dataType="trait" />
<resource-configuration>
<c:simple-property name="workerTimeout" type="integer" description="Timeout to wait for an available worker (default is no wait)" />
<c:simple-property name="stickySession" type="boolean" description="Enables sticky session for the cluster."/>
<c:simple-property name="stickySessionRemove" type="boolean" description="Remove session when the request cannot be routed to the right node."/>
- <!-- c:simple-property name="advertise" type="boolean" description="Enable autodiscovery of httpd servers."/-->
<c:simple-property name="smax" type="integer" description="Maximum time on seconds for idle connections above smax."/>
<c:simple-property name="maxAttempts" type="integer" description="Maximum number of attempts to send the request to the backend server."/>
<c:simple-property name="advertiseSecurityKey" type="string" required="false" description="Security key for discovery."/>
@@ -89,7 +87,6 @@
<c:simple-property name="balancer" type="string" required="false" description="Name of the balancer."/>
<c:simple-property name="flushPackets" type="boolean" description="Allows controlling flusing of packets."/>
<c:simple-property name="socketTimeout" type="integer" description="Connection timeout for communication with the proxy." />
- <c:simple-property name="domain" type="string" required="false" description="Domain parameter, which allows tying a jvmRoute to a particular domain."/>
<c:simple-property name="advertisePort" type="integer" required="false" description="Multicast port for discovery" />
<c:simple-property name="advertiseGroupAddress" type="string" required="false" description="Multicast address for discovery."/>
<c:simple-property name="flushWait" type="integer" description="Time in ms to wait before flushing packets."/>
commit 0890ce0e4f2e6331d3bcca15c799eecba8a15f38
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Jul 27 16:10:09 2011 -0400
[BZ-726202 - alerts not firing despite valid baseline values and alert conditions templates for some agents]
The issue here was that user created baseline did not properly trigger a
measurement condition cache reload for the affected agent. This was due
to the new Baseline not committed/visible to the trans executing the
agent status update.
- also, removed unused findBaselineForResourceAndMeasurementDefinition as
opposed to changing it for this fix.
- made a local public method private and removed some dead commented code
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerBean.java
index 282ae1a..286a75e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerBean.java
@@ -355,9 +355,25 @@ public class MeasurementBaselineManagerBean implements MeasurementBaselineManage
return baseline;
}
+ @TransactionAttribute(TransactionAttributeType.NEVER)
public MeasurementBaseline calculateAutoBaseline(Subject subject, Integer measurementScheduleId, long startDate,
long endDate, boolean save) throws BaselineCreationException, MeasurementNotFoundException {
+ MeasurementBaseline result = measurementBaselineManager.calculateAutoBaselineInNewTransaction(subject,
+ measurementScheduleId, startDate, endDate, save);
+
+ if (save) {
+ // note, this executes in a new transaction so the baseline must already be committed to the database
+ agentStatusManager.updateByMeasurementBaseline(result.getId());
+ }
+
+ return result;
+ }
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public MeasurementBaseline calculateAutoBaselineInNewTransaction(Subject subject, Integer measurementScheduleId,
+ long startDate, long endDate, boolean save) throws BaselineCreationException, MeasurementNotFoundException {
+
MeasurementBaseline baseline;
MeasurementSchedule sched = entityManager.find(MeasurementSchedule.class, measurementScheduleId);
@@ -391,13 +407,26 @@ public class MeasurementBaselineManagerBean implements MeasurementBaselineManage
return baseline;
}
- //calculateAutoBaseline(LookupUtil.getSubjectManager().getOverlord(),
- //chartForm.getGroupId(), chartForm.getM()[0], chartForm.getStartDate().getTime(), chartForm
- //.getEndDate().getTime(), false);
-
+ @TransactionAttribute(TransactionAttributeType.NEVER)
public MeasurementBaseline calculateAutoBaseline(Subject subject, int groupId, int definitionId, long startDate,
long endDate, boolean save) throws BaselineCreationException, MeasurementNotFoundException {
+ MeasurementBaseline result = measurementBaselineManager.calculateAutoBaselineForGroupInNewTransaction(subject,
+ groupId, definitionId, startDate, endDate, save);
+
+ if (save) {
+ // note, this executes in a new transaction so the baseline must already be committed to the database
+ agentStatusManager.updateByMeasurementBaseline(result.getId());
+ }
+
+ return result;
+ }
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public MeasurementBaseline calculateAutoBaselineForGroupInNewTransaction(Subject subject, int groupId,
+ int definitionId, long startDate, long endDate, boolean save) throws BaselineCreationException,
+ MeasurementNotFoundException {
+
if (save && !authorizationManager.hasGroupPermission(subject, Permission.MANAGE_MEASUREMENTS, groupId)) {
throw new PermissionException("User[" + subject.getName()
+ "] does not have permission to calculate and set baselines for group[id=" + groupId + "]");
@@ -405,7 +434,7 @@ public class MeasurementBaselineManagerBean implements MeasurementBaselineManage
MeasurementBaseline baseline;
try {
- baseline = calculateBaseline(groupId, definitionId, true, startDate, endDate, save);
+ baseline = calculateBaselineForGroup(groupId, definitionId, true, startDate, endDate, save);
if (save) {
// We have changed the baseline information for the schedule, so remove the now outdated OOB info.
oobManager.removeOOBsForGroupAndDefinition(subject, groupId, definitionId);
@@ -435,43 +464,6 @@ public class MeasurementBaselineManagerBean implements MeasurementBaselineManage
}
}
- public MeasurementBaseline findBaselineForResourceAndMeasurementDefinition(Subject subject, Integer resourceId,
- Integer measurementDefinitionId) {
- if (!authorizationManager.canViewResource(subject, resourceId)) {
- throw new PermissionException("Cannot view the baseline for resourceId=" + resourceId
- + "] - you do not have permission");
- }
-
- List<MeasurementBaseline> baselines = getBaselinesForResourcesAndDefinitionIds(new Integer[] { resourceId },
- new Integer[] { measurementDefinitionId });
- if ((baselines != null) && (baselines.size() > 0)) {
- return baselines.get(0);
- }
-
- Subject overlord = subjectManager.getOverlord();
- try {
- MeasurementSchedule schedule = measurementScheduleManager.getSchedule(overlord, resourceId,
- measurementDefinitionId, true);
-
- /*
- * Use all available data from the epoch until now to calculate the baseline (we don't need to start from
- * the epoch, because the baseline should have been auto-calculated after a few days, but it's a catch-all)
- */
- MeasurementBaseline baseline = calculateAutoBaseline(overlord, schedule.getId(), 0, System
- .currentTimeMillis(), true);
-
- return baseline;
- } catch (MeasurementNotFoundException mnfe) {
- log.error("Could not find measurement schedule for " + "resourceId=" + resourceId + ", "
- + "measurementDefinitionId=" + measurementDefinitionId, mnfe);
- } catch (BaselineCreationException bce) {
- log.error("Could not calculate baseline for " + "resourceId=" + resourceId + ", "
- + "measurementDefinitionId=" + measurementDefinitionId, bce);
- }
-
- return null;
- }
-
@SuppressWarnings("unchecked")
private List<MeasurementBaseline> getBaselinesForResourcesAndDefinitionIds(Integer[] resourceIds,
Integer[] definitionIds) {
@@ -531,15 +523,13 @@ public class MeasurementBaselineManagerBean implements MeasurementBaselineManage
if (save) {
entityManager.persist(baseline);
entityManager.merge(schedule);
-
- notifyAlertConditionCacheManager("calculateBaseline", baseline);
}
return baseline;
}
- public MeasurementBaseline calculateBaseline(int groupId, int definitionId, boolean userEntered, long startDate,
- long endDate, boolean save) throws DataNotAvailableException, BaselineCreationException {
+ private MeasurementBaseline calculateBaselineForGroup(int groupId, int definitionId, boolean userEntered,
+ long startDate, long endDate, boolean save) throws DataNotAvailableException, BaselineCreationException {
MeasurementAggregate agg = dataManager.getAggregate(subjectManager.getOverlord(), groupId, definitionId,
startDate, endDate);
@@ -583,8 +573,6 @@ public class MeasurementBaselineManagerBean implements MeasurementBaselineManage
if (save) {
entityManager.persist(baseline);
entityManager.merge(schedule);
-
- notifyAlertConditionCacheManager("calculateBaseline", baseline);
}
}
@@ -592,12 +580,6 @@ public class MeasurementBaselineManagerBean implements MeasurementBaselineManage
return baseline;
}
- private void notifyAlertConditionCacheManager(String callingMethod, MeasurementBaseline baseline) {
- agentStatusManager.updateByMeasurementBaseline(baseline.getId());
-
- log.debug("Invoking... " + callingMethod);
- }
-
@SuppressWarnings("unchecked")
public List<MeasurementBaseline> findBaselinesForResource(Subject subject, int resourceId) {
if (authorizationManager.canViewResource(subject, resourceId) == false) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerLocal.java
index 88d8e94..7f7655a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerLocal.java
@@ -92,9 +92,17 @@ public interface MeasurementBaselineManagerLocal {
MeasurementBaseline calculateAutoBaseline(Subject subject, Integer measurementScheduleId, long startDate,
long endDate, boolean save) throws BaselineCreationException, MeasurementNotFoundException;
+ // internal use only for transactioning reasons
+ MeasurementBaseline calculateAutoBaselineInNewTransaction(Subject subject, Integer measurementScheduleId,
+ long startDate, long endDate, boolean save) throws BaselineCreationException, MeasurementNotFoundException;
+
MeasurementBaseline calculateAutoBaseline(Subject subject, int groupId, int definitionId, long startDate,
long endDate, boolean save) throws BaselineCreationException, MeasurementNotFoundException;
+ // internal use only for transactioning reasons
+ MeasurementBaseline calculateAutoBaselineForGroupInNewTransaction(Subject subject, int groupId, int definitionId,
+ long startDate, long endDate, boolean save) throws BaselineCreationException, MeasurementNotFoundException;
+
/**
* Unset the {@link MeasurementBaseline#setUserEntered(boolean) user-entered} property in baselines so that we can
* do autobaselines on it again.
@@ -105,19 +113,6 @@ public interface MeasurementBaselineManagerLocal {
*/
void enableAutoBaselineCalculation(Subject subject, Integer[] resourceIds, Integer[] definitionIds);
- /**
- * Returns the baseline for a measurement identified by its measurement definition and the resource whose
- * measurement it is.
- *
- * @param subject
- * @param resource
- * @param measurementDefinitionId
- *
- * @return baseline of the resource's measurement with the given definition
- */
- MeasurementBaseline findBaselineForResourceAndMeasurementDefinition(Subject subject, Integer resource,
- Integer measurementDefinitionId);
-
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// The following are shared with the Remote Interface
commit 85e65e6a60f04e58e33d1cd32ebaee32a9610b7b
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jul 27 15:17:52 2011 -0400
context menu on change set node
multiple select tree nodes
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
index 6085af1..8203361 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -47,7 +47,6 @@ import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
/**
@@ -67,7 +66,7 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
// fetch the top nodes at the inital onDraw()
setAutoFetchData(true);
setAnimateFolders(false);
- setSelectionType(SelectionStyle.SINGLE);
+ setSelectionType(SelectionStyle.MULTIPLE);
setShowRollOver(false);
setShowHeader(false);
setSortField(AbstractDriftChangeSetsTreeDataSource.ATTR_NAME);
@@ -96,9 +95,10 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
TreeNode eventNode = event.getNode();
if (eventNode instanceof ChangeSetTreeNode) {
- CoreGUI.getMessageCenter().notify(new Message("TODO [this will popup the changeset menu]"));
+ Menu menu = buildChangeSetTreeNodeContextMenu((ChangeSetTreeNode) eventNode);
+ menu.showContextMenu();
} else if (eventNode instanceof DriftTreeNode) {
- Menu menu = buildContextMenu((DriftTreeNode) eventNode);
+ Menu menu = buildDriftTreeNodeContextMenu((DriftTreeNode) eventNode);
menu.showContextMenu();
}
}
@@ -171,12 +171,12 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
* @param node the drift node whose menu is to be displayed
* @return the context menu to display
*/
- protected Menu buildContextMenu(final DriftTreeNode node) {
+ protected Menu buildDriftTreeNodeContextMenu(final DriftTreeNode node) {
Menu contextMenu = new Menu();
// title
- String titleName = node.getName();
+ String titleName = node.getTitle();
if (titleName.length() > 50) {
// make sure the title isn't really long so the menu is not abnormally wide
titleName = "..." + titleName.substring(titleName.length() - 50);
@@ -204,6 +204,36 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
}
/**
+ * Builds the right-mouse-click context menu for the given change set node
+ * @param node the change set node whose menu is to be displayed
+ * @return the context menu to display
+ */
+ protected Menu buildChangeSetTreeNodeContextMenu(final ChangeSetTreeNode node) {
+
+ Menu contextMenu = new Menu();
+
+ // title
+ String titleName = node.getTitle();
+ MenuItem titleItem = new MenuItem(titleName);
+ titleItem.setEnabled(false);
+ contextMenu.setItems(titleItem);
+
+ // separator
+ contextMenu.addItem(new MenuItemSeparator());
+
+ // item that links to the history details
+ MenuItem deleteItem = new MenuItem(MSG.common_button_delete());
+ deleteItem.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ // TODO: delete the change set
+ }
+ });
+ contextMenu.addItem(deleteItem);
+
+ return contextMenu;
+ }
+
+ /**
* We override this because we know all of our nodes will have titles. Without this,
* I could not get the title of change set nodes to show - it always fell back to using
* the name. This way is at least faster, since we don't do any conditional checking,
commit 19cf0266ba2d7b78c07c584512c1b0bb7813f3a7
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 27 14:50:44 2011 -0400
Making the active drift server plugin configurable via system settings
When a drift serer plugin is loaded or unloaded, it is added to or
removed from the systems settings. When the DriftServerBean (SLSB
layers) asks for the drift plugin, the DriftServerPlugin queries the
system settings to find the active drift server plugin. The drift-rhq
plugin is active by default.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 39f0798..e2a599d 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.111</db.schema.version>
+ <db.schema.version>2.112</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml b/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml
index 121e971..6d0e80a 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml
@@ -125,6 +125,12 @@
<data ID="56" PROPERTY_KEY="RESOURCE_GENERIC_PROPERTIES_UPGRADE" PROPERTY_VALUE="false"
DEFAULT_PROPERTY_VALUE="false" FREAD_ONLY="FALSE"/>
+ <!-- default drift server plugin settings -->
+ <data ID="57" PROPERTY_KEY="ACTIVE_DRIFT_PLUGIN" PROPERTY_VALUE="[drift-rhq$$Drift:RHQ]"
+ DEFAULT_PROPERTY_VALUE="[drift-rhq$$Drift:RHQ]" FREAD_ONLY="FALSE"/>
+ <data ID="58" PROPERTY_KEY="DRIFT_PLUGINS" PROPERTY_VALUE="" DEFAULT_PROPERTY_VALUE="[drift-rhq$$Drift:RHQ]"
+ FREAD_ONLY="FALSE"/>
+
</table>
</dbsetup>
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 7e38d96..2b1097d 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3586,6 +3586,22 @@
</schema-directSQL>
</schemaSpec>
+ <schemaSpec version="2.112">
+ <schema-directSQL>
+ <statement desc="Adding drift server plugin active plugin system configuration property">
+ INSERT INTO rhq_system_config (id, property_key, property_value, default_property_value)
+ VALUES (57, 'ACTIVE_DRIFT_PLUGIN', '[drift-rhq$$Drift:RHQ]', '[drift-rhq$$Drift:RHQ]')
+ </statement>
+ </schema-directSQL>
+
+ <schema-directSQL>
+ <statement desc="Adding drift server plugin plugins system configuration property">
+ INSERT INTO rhq_system_config (id, property_key, property_value, default_property_value)
+ VALUES (58, 'DRIFT_PLUGINS', '', '[drift-rhq$$Drift:RHQ]')
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
+
</dbupgrade>
</target>
</project>
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java
index 5e83850..ac861b0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java
@@ -19,8 +19,10 @@
package org.rhq.enterprise.gui.coregui.client.admin;
+import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -38,6 +40,7 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionEnumeration;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertyGroupDefinition;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
@@ -99,6 +102,9 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
String LDAPBaseDN = "CAM_LDAP_BASE_DN";
String LDAPBindDN = "CAM_LDAP_BIND_DN";
String LDAPBindPW = "CAM_LDAP_BIND_PW";
+
+ String ACTIVE_DRIFT_PLUGIN = "ACTIVE_DRIFT_PLUGIN";
+ String DRIFT_PLUGINS = "DRIFT_PLUGINS";
}
public SystemSettingsView(String locatorId) {
@@ -128,6 +134,7 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
canvas.addMember(getServerDetails());
Configuration config = new Configuration();
+ String[] driftPlugins = null;
for (Map.Entry<String, String> entry : result.entrySet()) {
String name = entry.getKey();
String value = (entry.getValue() == null) ? "" : entry.getValue();
@@ -166,6 +173,9 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
if (value.trim().length() == 0) {
value = "true";
}
+ } else if (Constant.DRIFT_PLUGINS.equals(name)) {
+ driftPlugins = value.split(",");
+ continue;
}
PropertySimple prop = new PropertySimple(name, value);
@@ -173,8 +183,8 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
}
// build our config definition and populate our config editor
- editor = new ConfigurationEditor(extendLocatorId("configEditor"), getSystemSettingsDefinition(config),
- config);
+ editor = new ConfigurationEditor(extendLocatorId("configEditor"), getSystemSettingsDefinition(config,
+ driftPlugins), config);
editor.addPropertyValueChangeListener(SystemSettingsView.this);
canvas.addMember(editor);
@@ -305,7 +315,7 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
*
* @return system settings config def
*/
- private ConfigurationDefinition getSystemSettingsDefinition(Configuration config) {
+ private ConfigurationDefinition getSystemSettingsDefinition(Configuration config, String[] driftPlugins) {
ConfigurationDefinition def = new ConfigurationDefinition("sysset", MSG.view_adminConfig_systemSettings());
///////////////////////////////////
@@ -519,6 +529,31 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
ldapBindPW.setDefaultValue("");
def.put(ldapBindPW);
+ ///////////////////////////////////////////
+ // Drift Server Configuration Properties //
+ ///////////////////////////////////////////
+ PropertyGroupDefinition driftGroup = new PropertyGroupDefinition("drift server");
+ driftGroup.setDisplayName("Drift Server Configuration Settings");
+ driftGroup.setOrder(4);
+ driftGroup.setDefaultHidden(false);
+
+ PropertyDefinitionSimple activeDriftServer = new PropertyDefinitionSimple("ACTIVE_DRIFT_PLUGIN",
+ "The drift server plugin that manages the persistence of drift-related entities and content", true,
+ PropertySimpleType.STRING);
+ activeDriftServer.setDisplayName("Active Drift Server Plugin");
+ activeDriftServer.setPropertyGroupDefinition(driftGroup);
+
+ List<PropertyDefinitionEnumeration> options = new ArrayList<PropertyDefinitionEnumeration>();
+ for (String plugin : driftPlugins) {
+ // plugin is of the form, [plugin_name$$plugin_display_name]]
+ String pluginName = plugin.substring(1, plugin.indexOf("$$"));
+ String pluginDisplayName = plugin.substring(pluginName.length() + 3, plugin.indexOf("]"));
+ options.add(new PropertyDefinitionEnumeration(pluginDisplayName, plugin));
+ }
+ activeDriftServer.setEnumeratedValues(options, false);
+
+ def.put(activeDriftServer);
+
//
// if the config is missing any properties for which we have defaults, set them to their defaults
//
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java
index e992271..63037c1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java
@@ -49,6 +49,10 @@ public class RHQConstants {
public static final String LDAPBindDN = "CAM_LDAP_BIND_DN";
public static final String LDAPBindPW = "CAM_LDAP_BIND_PW";
+ // DRIFT Server properties
+ public static final String ACTIVE_DRIFT_PLUGIN = "ACTIVE_DRIFT_PLUGIN";
+ public static final String DRIFT_PLUGINS = "DRIFT_PLUGINS";
+
// Base URL for the application - (i think this is only used for alert emails)
public static final String BaseURL = "CAM_BASE_URL";
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java
index 8e00b0c..9e405ec 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java
@@ -18,11 +18,23 @@
*/
package org.rhq.enterprise.server.plugin.pc.drift;
+import java.util.List;
+import java.util.Properties;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.plugin.pc.ServerPluginEnvironment;
import org.rhq.enterprise.server.plugin.pc.ServerPluginManager;
+import org.rhq.enterprise.server.system.SystemManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+import org.rhq.enterprise.server.xmlschema.generated.serverplugin.ServerPluginDescriptorType;
+
+import static org.rhq.core.domain.util.StringUtils.getListAsString;
+import static org.rhq.core.domain.util.StringUtils.getStringAsList;
+import static org.rhq.enterprise.server.RHQConstants.ACTIVE_DRIFT_PLUGIN;
+import static org.rhq.enterprise.server.RHQConstants.DRIFT_PLUGINS;
/**
* This loads in all drift server plugins that can be found. You can obtain a loaded plugin's
@@ -32,6 +44,7 @@ import org.rhq.enterprise.server.plugin.pc.ServerPluginManager;
* @author John Sanda
*/
public class DriftServerPluginManager extends ServerPluginManager {
+
private final Log log = LogFactory.getLog(this.getClass());
public DriftServerPluginManager(DriftServerPluginContainer pc) {
@@ -39,7 +52,76 @@ public class DriftServerPluginManager extends ServerPluginManager {
}
public DriftServerPluginFacet getDriftServerPluginComponent() {
- // TODO The name of the drift server plugin probably will need to be obtained from the system config
- return (DriftServerPluginFacet) getServerPluginComponent("drift-rhq");
+ Properties sysConfig = getSysConfig();
+ String value = sysConfig.getProperty(ACTIVE_DRIFT_PLUGIN);
+
+ if (value == null) {
+ throw new RuntimeException(ACTIVE_DRIFT_PLUGIN + " system configuration property is not set.");
+ }
+
+ return (DriftServerPluginFacet) getServerPluginComponent(value.substring(1, value.indexOf("$$")));
+ }
+
+ @Override
+ protected void loadPlugin(ServerPluginEnvironment env, boolean enabled) throws Exception {
+ super.loadPlugin(env, enabled);
+
+ String pluginName = env.getPluginKey().getPluginName();
+ List<String> plugins = getDriftPlugins();
+
+ int index = findPluginIndex(plugins, pluginName);
+ if (index == -1) {
+ plugins.add("[" + pluginName + "$$" + env.getPluginDescriptor().getDisplayName() + "]");
+ saveDriftPlugins(plugins);
+ }
+
+ }
+
+ @Override
+ protected void unloadPlugin(String pluginName) throws Exception {
+ super.unloadPlugin(pluginName);
+
+ List<String> plugins = getDriftPlugins();
+ int index = findPluginIndex(plugins, pluginName);
+
+ if (index != -1) {
+ plugins.remove(index);
+ saveDriftPlugins(plugins);
+ }
+ }
+
+ private List<String> getDriftPlugins() {
+ Properties sysConfig = getSysConfig();
+ return getStringAsList(sysConfig.getProperty(DRIFT_PLUGINS, ""), ",", true);
}
+
+ private void saveDriftPlugins(List<String> plugins) throws Exception {
+ SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
+ SystemManagerLocal systemMgr = LookupUtil.getSystemManager();
+
+ Properties sysConfig = systemMgr.getSystemConfiguration(subjectMgr.getOverlord());
+ sysConfig.put(DRIFT_PLUGINS, getListAsString(plugins, ","));
+ systemMgr.setSystemConfiguration(subjectMgr.getOverlord(), sysConfig, false);
+ }
+
+ private Properties getSysConfig() {
+ SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
+ SystemManagerLocal systemMgr = LookupUtil.getSystemManager();
+
+ return systemMgr.getSystemConfiguration(subjectMgr.getOverlord());
+ }
+
+ private int findPluginIndex(List<String> plugins, String name) {
+ int i = 0;
+ for (String value : plugins) {
+ // value is of the form, [plugin_name$$plugin_display_name]
+ if (name.equals(value.substring(1, value.indexOf("$$")))) {
+ return i;
+ }
+ ++i;
+ }
+ return -1;
+ }
+
+
}
\ No newline at end of file
diff --git a/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
index 349b84c..b385473 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
@@ -143,7 +143,7 @@ public class JPAUtils {
em.createNativeQuery("delete from rhq_measurement_sched");
em.createNativeQuery("delete from rhq_measurement_def");
em.createNativeQuery("delete from rhq_plugin");
- em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56)");
+ em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56, 57, 58)");
em.createNativeQuery("delete from rhq_alert_notification");
em.createNativeQuery("delete from rhq_alert_condition_log");
em.createNativeQuery("delete from rhq_alert");
commit d064e0516c87a1aa44d1f9f2231907279e9582dd
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 26 21:22:19 2011 -0400
Persist drift detection schedule across agent restarts
This commit add functionality for persisting drift detection schedules
across restarts. When the agent is shutting down and the inventory is
persisted to disk, the schedules are now written out to disk along with
the rest of the inventory.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java
index fe42744..ab5bac3 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java
@@ -1,8 +1,12 @@
package org.rhq.core.pc.drift;
+import java.io.Serializable;
+
import org.rhq.core.domain.drift.DriftConfiguration;
-public class DriftDetectionSchedule implements Comparable<DriftDetectionSchedule> {
+public class DriftDetectionSchedule implements Comparable<DriftDetectionSchedule>, Serializable {
+
+ private static final long serialVersionUID = 1L;
private int resourceId;
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
index f499697..879ceca 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
@@ -67,11 +67,36 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
driftDetector.setChangeSetManager(changeSetMgr);
driftDetector.setDriftClient(this);
+ InventoryManager inventoryMgr = PluginContainer.getInstance().getInventoryManager();
+ initSchedules(inventoryMgr.getPlatform(), inventoryMgr);
+
driftThreadPool = new ScheduledThreadPoolExecutor(5);
// TODO Make the drift detection rate configurable
driftThreadPool.scheduleAtFixedRate(driftDetector, 30, 60, TimeUnit.SECONDS);
}
+ private void initSchedules(Resource r, InventoryManager inventoryMgr) {
+ if (r.getId() == 0) {
+ log.debug("Will not reschedule drift detection schedules for " + r + ". It is not sync'ed yet.");
+ return;
+ }
+
+ ResourceContainer container = inventoryMgr.getResourceContainer(r.getId());
+ if (container == null) {
+ log.debug("No resource container found for " + r + ". Unable to reschedule drift detection schedules.");
+ return;
+ }
+
+ log.debug("Rescheduling drift detection schedules for " + r);
+ for (DriftDetectionSchedule schedule : container.getDriftSchedules()) {
+ schedulesQueue.addSchedule(schedule);
+ }
+
+ for (Resource child : r.getChildResources()) {
+ initSchedules(child, inventoryMgr);
+ }
+ }
+
@Override
public void shutdown() {
driftThreadPool.shutdown();
@@ -164,8 +189,8 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
}
@Override
- public boolean update(int resourceId, DriftConfiguration config) {
- return false;
+ public DriftDetectionSchedule update(int resourceId, DriftConfiguration config) {
+ return schedule;
}
@Override
@@ -208,9 +233,16 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
@Override
public void updateDriftDetection(int resourceId, DriftConfiguration driftConfiguration) {
- boolean updated = schedulesQueue.update(resourceId, driftConfiguration);
- if (!updated) {
- schedulesQueue.addSchedule(new DriftDetectionSchedule(resourceId, driftConfiguration));
+ DriftDetectionSchedule updatedSchedule = schedulesQueue.update(resourceId, driftConfiguration);
+ if (updatedSchedule == null) {
+ updatedSchedule = new DriftDetectionSchedule(resourceId, driftConfiguration);
+ schedulesQueue.addSchedule(updatedSchedule);
+ }
+
+ InventoryManager inventoryMgr = PluginContainer.getInstance().getInventoryManager();
+ ResourceContainer container = inventoryMgr.getResourceContainer(resourceId);
+ if (container != null) {
+ container.getDriftSchedules().add(updatedSchedule);
}
}
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 ca7edc5..374e27e 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
@@ -38,7 +38,7 @@ public interface ScheduleQueue {
* Adds a schedule to the queue for processing by the drift detector
*
* @param schedule A {@link DriftDetectionSchedule} object
- * @return true if the schedule is added, falsed otherwise
+ * @return true if the schedule is added, false otherwise
*/
boolean addSchedule(DriftDetectionSchedule schedule);
@@ -52,9 +52,9 @@ public interface ScheduleQueue {
*
* @param resourceId The resource id
* @param config A {@link DriftConfiguration} belonging the resource with the specified id
- * @return true if the schedule is updated, false otherwise.
+ * @return A copy of the updated schedule or null if no update was performed
*/
- boolean update(int resourceId, DriftConfiguration config);
+ DriftDetectionSchedule update(int resourceId, DriftConfiguration config);
/**
* Removes the schedule identified by the resource id and the drift configuration. More
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 499ad91..b4a2f00 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
@@ -112,20 +112,26 @@ public class ScheduleQueueImpl implements ScheduleQueue {
}
@Override
- public boolean update(int resourceId, DriftConfiguration config) {
+ public DriftDetectionSchedule update(int resourceId, DriftConfiguration config) {
try {
lock.writeLock().lock();
if (isActiveSchedule(resourceId, config)) {
update(activeSchedule, config);
- } else {
- DriftDetectionSchedule schedule = remove(resourceId, config);
- if (schedule == null) {
- return false;
- }
- update(schedule, config);
- queue.offer(schedule);
+ return activeSchedule.copy();
+ }
+
+ DriftDetectionSchedule schedule = remove(resourceId, config);
+ if (schedule == null) {
+ return null;
}
- return true;
+
+ update(schedule, config);
+
+ if (queue.offer(schedule)) {
+ return schedule.copy();
+ }
+
+ return null;
} finally {
lock.writeLock().unlock();
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
index ab8d30e..fcf1aea 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
@@ -52,6 +52,7 @@ import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.pc.drift.DriftDetectionSchedule;
import org.rhq.core.pc.util.FacetLockType;
import org.rhq.core.pc.util.LoggingThreadFactory;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
@@ -88,6 +89,7 @@ public class ResourceContainer implements Serializable {
private SynchronizationState synchronizationState = SynchronizationState.NEW;
private Set<MeasurementScheduleRequest> measurementSchedule = new HashSet<MeasurementScheduleRequest>();
private Set<ResourcePackageDetails> installedPackages = new HashSet<ResourcePackageDetails>();
+ private Set<DriftDetectionSchedule> driftSchedules = new HashSet<DriftDetectionSchedule>();
// transient fields
private transient ResourceComponent resourceComponent;
@@ -242,6 +244,16 @@ public class ResourceContainer implements Serializable {
}
}
+ public Set<DriftDetectionSchedule> getDriftSchedules() {
+ synchronized (this) {
+ return driftSchedules;
+ }
+ }
+
+ public void setDriftSchedules(Set<DriftDetectionSchedule> schedules) {
+ driftSchedules = schedules;
+ }
+
public ResourceComponentState getResourceComponentState() {
synchronized (this) {
return this.resourceComponentState;
commit d6e42c6a12a2a630a37fd3151fadb64848c24a30
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jul 26 18:31:39 2011 -0400
tweek folder icons for drift
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png
index fdda214..e728bc8 100644
Binary files a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png
index 358cf61..1ca204f 100644
Binary files a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png differ
commit 5024b757bdcf0b842d4c49fe58ca45890450e670
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 26 16:14:26 2011 -0400
Adding support for updating drift configs
When the server sends a request to the agent to update a drift
configuration, that config is attached to a schedule which is in one of
two places. It is either on the schedule queue or it is "active"
schedule currently being processed by the drift detector. The config
update will be applied such that the next time the drift detector
processes the schedule the update will take effect.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java
index a767b99..fe42744 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java
@@ -32,6 +32,13 @@ public class DriftDetectionSchedule implements Comparable<DriftDetectionSchedule
nextScan = System.currentTimeMillis() + (driftConfig.getInterval() * 1000);
}
+ public DriftDetectionSchedule copy() {
+ DriftDetectionSchedule copy = new DriftDetectionSchedule(resourceId,
+ new DriftConfiguration(driftConfig.getConfiguration().deepCopyWithoutProxies()));
+ copy.nextScan = nextScan;
+ return copy;
+ }
+
@Override
public int compareTo(DriftDetectionSchedule other) {
if (this.nextScan < other.nextScan) {
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 b92dd7c..153e5a9 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
@@ -47,52 +47,44 @@ public class DriftDetector implements Runnable {
@Override
public void run() {
- DriftDetectionSchedule schedule = scheduleQueue.dequeue();
+ DriftDetectionSchedule schedule = scheduleQueue.getNextSchedule();
if (schedule == null) {
return;
}
- if (schedule.getNextScan() > (System.currentTimeMillis() + 100L)) {
- scheduleQueue.enqueue(schedule);
- // TODO should we grab the schedule from the queue?
- // Maybe we should continue pulling schedules off the queue until
- // we find one that is ready to be processed.
- return;
- }
-
- if (!schedule.getDriftConfiguration().getEnabled()) {
- schedule.updateShedule();
- scheduleQueue.enqueue(schedule);
- // TODO should we grab the schedule from the queue?
- // Maybe we should continue pulling schedules off the queue until
- // we find one that is ready to be processed.
- return;
- }
-
- DriftConfiguration driftConfig = schedule.getDriftConfiguration();
- int resourceId = schedule.getResourceId();
- DriftChangeSetCategory changeSetType = null;
- int changes = 0;
-
try {
- if (changeSetMgr.changeSetExists(schedule.getResourceId(), new Headers(driftConfig.getName(),
- basedir(resourceId, driftConfig), COVERAGE))) {
- changeSetType = DRIFT;
- changes = generateDriftChangeSet(schedule);
- } else {
- changeSetType = COVERAGE;
- generateCoverageChangeSet(schedule);
+ if (schedule.getNextScan() > (System.currentTimeMillis() + 100L)) {
+ return;
}
- } catch (IOException e) {
- // TODO Call ChangeSetManager here to rollback any thing that was written to disk.
- log.error("An error occurred while scanning for drift", e);
- }
- schedule.updateShedule();
- scheduleQueue.enqueue(schedule);
+ if (!schedule.getDriftConfiguration().getEnabled()) {
+ return;
+ }
- if (changeSetType == COVERAGE || changes > 0) {
- driftClient.sendChangeSetToServer(schedule.getResourceId(), driftConfig, changeSetType);
+ DriftConfiguration driftConfig = schedule.getDriftConfiguration();
+ int resourceId = schedule.getResourceId();
+ DriftChangeSetCategory changeSetType = null;
+ int changes = 0;
+
+ try {
+ if (changeSetMgr.changeSetExists(schedule.getResourceId(), new Headers(driftConfig.getName(),
+ basedir(resourceId, driftConfig), COVERAGE))) {
+ changeSetType = DRIFT;
+ changes = generateDriftChangeSet(schedule);
+ } else {
+ changeSetType = COVERAGE;
+ generateCoverageChangeSet(schedule);
+ }
+ } catch (IOException e) {
+ // TODO Call ChangeSetManager here to rollback any thing that was written to disk.
+ log.error("An error occurred while scanning for drift", e);
+ }
+
+ if (changeSetType == COVERAGE || changes > 0) {
+ driftClient.sendChangeSetToServer(schedule.getResourceId(), driftConfig, changeSetType);
+ }
+ } finally {
+ scheduleQueue.deactivateSchedule();
}
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
index b688154..f499697 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
@@ -141,14 +141,14 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
DriftDetectionSchedule schedule;
@Override
- public DriftDetectionSchedule dequeue() {
+ public DriftDetectionSchedule getNextSchedule() {
DriftDetectionSchedule removedSchedule = schedule;
schedule = null;
return removedSchedule;
}
@Override
- public boolean enqueue(DriftDetectionSchedule schedule) {
+ public boolean addSchedule(DriftDetectionSchedule schedule) {
this.schedule = schedule;
return true;
}
@@ -157,8 +157,23 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
public void clear() {
schedule = null;
}
+
+ @Override
+ public void deactivateSchedule() {
+ schedule = null;
+ }
+
+ @Override
+ public boolean update(int resourceId, DriftConfiguration config) {
+ return false;
+ }
+
+ @Override
+ public DriftDetectionSchedule remove(int resourceId, DriftConfiguration config) {
+ return null;
+ }
};
- queue.enqueue(new DriftDetectionSchedule(resourceId, driftConfiguration));
+ queue.addSchedule(new DriftDetectionSchedule(resourceId, driftConfiguration));
DriftDetector driftDetector = new DriftDetector();
driftDetector.setChangeSetManager(changeSetMgr);
@@ -170,7 +185,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
@Override
public void scheduleDriftDetection(int resourceId, DriftConfiguration driftConfiguration) {
- schedulesQueue.enqueue(new DriftDetectionSchedule(resourceId, driftConfiguration));
+ schedulesQueue.addSchedule(new DriftDetectionSchedule(resourceId, driftConfiguration));
}
@Override
@@ -193,6 +208,10 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
@Override
public void updateDriftDetection(int resourceId, DriftConfiguration driftConfiguration) {
+ boolean updated = schedulesQueue.update(resourceId, driftConfiguration);
+ if (!updated) {
+ schedulesQueue.addSchedule(new DriftDetectionSchedule(resourceId, driftConfiguration));
+ }
}
/**
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 09b0aa5..ca7edc5 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
@@ -1,11 +1,79 @@
package org.rhq.core.pc.drift;
+import org.rhq.core.domain.drift.DriftConfiguration;
+
+/**
+ * Manages the drift detection schedules that are processed by the drift detector. The
+ * queue has a concept of the currently "active" schedule. This is identified simply as
+ * the schedule returned from {@link #getNextSchedule()} which is the previous head of the
+ * queue. A reference to the active schedule needs to be maintained because at any point in
+ * time the server can send a request to update the drift configuration that is attached to
+ * a schedule. That schedule will either be on the queue waiting to be processed or in the
+ * "active" state meaning it is currently being processed by the drift detector.
+ */
public interface ScheduleQueue {
- DriftDetectionSchedule dequeue();
+ /**
+ * Removes the head of the queue and returns a copy of the schedule that was removed.
+ * That schedule is also marked as the active schedule.
+ *
+ * @return A copy of the schedule that is removed from the head of the queue.
+ *
+ * @see DriftDetectionSchedule
+ *
+ * @throws IllegalStateException if there is already an active schedule. The active
+ * schedule must be deactivated before getting the next schedule.
+ */
+ DriftDetectionSchedule getNextSchedule();
+
+ /**
+ * This method does two things. First it updates the active schedule's nextScan
+ * property. Then it adds the schedule back onto the queue, allowing the next schedule
+ * at the head of the queue to become active. If there is no active schedule this
+ * method simply does nothing and returns.
+ */
+ void deactivateSchedule();
+
+ /**
+ * Adds a schedule to the queue for processing by the drift detector
+ *
+ * @param schedule A {@link DriftDetectionSchedule} object
+ * @return true if the schedule is added, falsed otherwise
+ */
+ boolean addSchedule(DriftDetectionSchedule schedule);
+
+ /**
+ * This method attempts to update the schedule identified by the resource id the and
+ * the drift configuration. More specifically, the schedule is identified by a
+ * combination of resource id and drift configuraiton name. If the schedule to be
+ * updated is the active schedule, it is immediately updated and then placed back on
+ * the queue the next time {@link #deactivateSchedule()} is called. If the schedule
+ * is on the queue, it is removed, updated, and then added back onto the queue.
+ *
+ * @param resourceId The resource id
+ * @param config A {@link DriftConfiguration} belonging the resource with the specified id
+ * @return true if the schedule is updated, false otherwise.
+ */
+ boolean update(int resourceId, DriftConfiguration config);
- boolean enqueue(DriftDetectionSchedule schedule);
+ /**
+ * Removes the schedule identified by the resource id and the drift configuration. More
+ * specifically, the schedule is identified by a combination of resource id drift
+ * configuration name. This method can remove either the active schedule or a schedule
+ * on the queue.
+ *
+ * @param resourceId The resource id
+ *
+ * @param config A {@link DriftConfiguration} belonging the resource with the specified id
+ *
+ * @return The {@link DriftDetectionSchedule} that is removed or null if no matching
+ * schedule is found.
+ */
+ DriftDetectionSchedule remove(int resourceId, DriftConfiguration config);
+ /**
+ * Removes all elements from the queue and deactivates the active schedule.
+ */
void clear();
}
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 7934c2d..499ad91 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
@@ -3,24 +3,54 @@ package org.rhq.core.pc.drift;
import java.util.PriorityQueue;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import org.rhq.core.domain.drift.DriftConfiguration;
+
public class ScheduleQueueImpl implements ScheduleQueue {
private PriorityQueue<DriftDetectionSchedule> queue = new PriorityQueue<DriftDetectionSchedule>();
private ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+ private DriftDetectionSchedule activeSchedule;
+
@Override
- public DriftDetectionSchedule dequeue() {
+ public DriftDetectionSchedule getNextSchedule() {
try {
lock.writeLock().lock();
- return queue.poll();
+ if (activeSchedule != null) {
+ throw new IllegalStateException("There is already an active schedule that must be deactivated " +
+ "before getting the next schedule.");
+ }
+ activeSchedule = queue.poll();
+ return activeSchedule == null ? null : activeSchedule.copy();
} finally {
lock.writeLock().unlock();
}
}
+ private boolean isActiveSchedule(int resourceId, DriftConfiguration config) {
+ return activeSchedule != null && activeSchedule.getResourceId() == resourceId &&
+ activeSchedule.getDriftConfiguration().getName().equals(config.getName());
+
+ }
+
@Override
- public boolean enqueue(DriftDetectionSchedule schedule) {
+ public void deactivateSchedule() {
+ try {
+ lock.writeLock().lock();
+ if (activeSchedule == null) {
+ return;
+ }
+ activeSchedule.updateShedule();
+ queue.offer(activeSchedule);
+ activeSchedule = null;
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
+ @Override
+ public boolean addSchedule(DriftDetectionSchedule schedule) {
boolean inserted = false;
try {
lock.writeLock().lock();
@@ -32,9 +62,85 @@ public class ScheduleQueueImpl implements ScheduleQueue {
}
@Override
+ public DriftDetectionSchedule remove(int resourceId, DriftConfiguration config) {
+ DriftDetectionSchedule scheduleToRemove = null;
+ try {
+ lock.readLock().lock();
+ if (isActiveSchedule(resourceId, config)) {
+ // The schedule to be removed is the currently active schedule so "upgrade"
+ // to the write lock and return the schedule while removing it from the queue
+ // at the same time.
+ try {
+ lock.writeLock().lock();
+ DriftDetectionSchedule removedSchedule = activeSchedule;
+ activeSchedule = null;
+ return removedSchedule;
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
+ for (DriftDetectionSchedule s : queue) {
+ if (s.getResourceId() == resourceId &&
+ s.getDriftConfiguration().getName().equals(config.getName())) {
+ scheduleToRemove = s;
+ break;
+ }
+ }
+
+ // The schedule was not found in the queue so we can simply return null without
+ // any additional processing.
+ if (scheduleToRemove == null) {
+ return null;
+ }
+
+ boolean removed = false;
+ // At this point, we found the target schedule in the queue. We "upgrade" to
+ // the write lock and remove it from the queue. If the schedule was successfully
+ // removed we return it; otherwise, return null.
+ try {
+ lock.writeLock().lock();
+ removed = queue.remove(scheduleToRemove);
+ } finally {
+ lock.writeLock().unlock();
+ }
+
+ return removed ? scheduleToRemove : null;
+ } finally {
+ lock.readLock().unlock();
+ }
+ }
+
+ @Override
+ public boolean update(int resourceId, DriftConfiguration config) {
+ try {
+ lock.writeLock().lock();
+ if (isActiveSchedule(resourceId, config)) {
+ update(activeSchedule, config);
+ } else {
+ DriftDetectionSchedule schedule = remove(resourceId, config);
+ if (schedule == null) {
+ return false;
+ }
+ update(schedule, config);
+ queue.offer(schedule);
+ }
+ return true;
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
+ private void update(DriftDetectionSchedule schedule, DriftConfiguration config) {
+ schedule.getDriftConfiguration().setEnabled(config.getEnabled());
+ schedule.getDriftConfiguration().setInterval(config.getInterval());
+ }
+
+ @Override
public void clear() {
try {
lock.writeLock().lock();
+ activeSchedule = null;
queue.clear();
} finally {
lock.writeLock().unlock();
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 9b62422..49dab54 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
@@ -58,7 +58,7 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration driftConfig = driftConfiguration("coverage-test", resourceDir.getAbsolutePath());
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), driftConfig));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), driftConfig));
detector.run();
File changeSet = changeSet(driftConfig.getName(), COVERAGE);
@@ -77,12 +77,12 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration driftConfig = driftConfiguration("basedir-entry-test", resourceDir.getAbsolutePath());
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), driftConfig));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), driftConfig));
detector.run();
DriftDetectionSchedule schedule = new DriftDetectionSchedule(resourceId(), driftConfig);
- scheduleQueue.enqueue(schedule);
+ scheduleQueue.addSchedule(schedule);
detector.run();
assertChangeSetContainsDirEntry(changeSet(driftConfig.getName(), COVERAGE),
@@ -102,7 +102,7 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration config = driftConfiguration("multiple-files-test", resourceDir.getAbsolutePath());
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File changeSet = changeSet(config.getName(), COVERAGE);
@@ -127,7 +127,7 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration config = driftConfiguration("sibling-dirs-test", resourceDir.getAbsolutePath());
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File changeSet = changeSet(config.getName(), COVERAGE);
@@ -153,7 +153,7 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration config = driftConfiguration("nested-dirs-test", resourceDir.getAbsolutePath());
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File changeSet = changeSet(config.getName(), COVERAGE);
@@ -188,7 +188,7 @@ public class DriftDetectorTest extends DriftTest {
File server1Conf = new File(confDir, "server-1.conf");
touch(server1Conf);
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
detector.run();
}
@@ -217,7 +217,7 @@ public class DriftDetectorTest extends DriftTest {
File server2Conf = new File(confDir, "server-2.conf");
touch(server2Conf);
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File driftChangeSet = changeSet(config.getName(), DRIFT);
@@ -266,7 +266,7 @@ public class DriftDetectorTest extends DriftTest {
// create some drift
server2Conf.delete();
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File driftChangeSet = changeSet(config.getName(), DRIFT);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
index 276c8b9..9de0966 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
@@ -145,7 +145,7 @@ public class DriftServerBean implements DriftServerLocal {
AgentClient agentClient = agentMgr.getAgentClient(subjectMgr.getOverlord(), resourceId);
DriftAgentService service = agentClient.getDriftAgentService();
try {
- service.scheduleDriftDetection(resourceId, driftConfig);
+ service.updateDriftDetection(resourceId, driftConfig);
} catch (Exception e) {
log.warn(" Unable to inform agent of unscheduled drift detection [" + driftConfig + "]", e);
}
commit f0ae8b1ff4a879e22116df404f51a526d0ca7583
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jul 26 16:05:42 2011 -0400
add sort direction
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
index 2d7205d..6085af1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -26,6 +26,7 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
@@ -70,6 +71,7 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
setShowRollOver(false);
setShowHeader(false);
setSortField(AbstractDriftChangeSetsTreeDataSource.ATTR_NAME);
+ setSortDirection(SortDirection.DESCENDING);
}
@Override
commit 061059a61f26ba172a6c5c0df837e8850ab1bf39
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jul 26 15:58:32 2011 -0400
sort the tree and provide a refresh button
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
index 7778084..2d7205d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -24,7 +24,9 @@ package org.rhq.enterprise.gui.coregui.client.drift;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
+import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
import com.smartgwt.client.widgets.menu.Menu;
@@ -67,6 +69,7 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
setSelectionType(SelectionStyle.SINGLE);
setShowRollOver(false);
setShowHeader(false);
+ setSortField(AbstractDriftChangeSetsTreeDataSource.ATTR_NAME);
}
@Override
@@ -198,6 +201,17 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
return contextMenu;
}
+ /**
+ * We override this because we know all of our nodes will have titles. Without this,
+ * I could not get the title of change set nodes to show - it always fell back to using
+ * the name. This way is at least faster, since we don't do any conditional checking,
+ * we always immediately use the getTitle results.
+ */
+ @Override
+ protected String getNodeTitle(Record node, int recordNum, ListGridField field) {
+ return ((TreeNode) node).getTitle();
+ }
+
@SuppressWarnings("unchecked")
static class ChangeSetTreeNode extends TreeNode {
public ChangeSetTreeNode(DriftChangeSet changeset) {
@@ -205,7 +219,8 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
setIcon("subsystems/drift/ChangeSet_16.png");
setShowOpenIcon(true);
setID(changeset.getId());
- setName(buildDriftChangeSetNodeName(changeset));
+ setName(padWithZeroes(changeset.getVersion())); // we sort on this column, hence we make sure the version # is padded
+ setTitle(buildDriftChangeSetNodeName(changeset));
}
private String buildDriftChangeSetNodeName(DriftChangeSet changeset) {
@@ -219,6 +234,14 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
str.append(')');
return str.toString();
}
+
+ private String padWithZeroes(int numberToPad) {
+ String stringToPad = String.valueOf(numberToPad);
+ char[] zeroes = new char[10 - stringToPad.length()];
+ for (int i = 0; i < zeroes.length; i++)
+ zeroes[i] = '0';
+ return new String(zeroes) + stringToPad;
+ }
}
@SuppressWarnings("unchecked")
@@ -229,7 +252,12 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
String parentID = drift.getChangeSet().getId();
setParentID(parentID);
setID(parentID + '_' + drift.getId());
- setName(drift.getPath());
+ setName(drift.getPath()); // we sort on this column
+ }
+
+ @Override
+ public String getTitle() {
+ return super.getName();
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
index 48f5bc8..56b4aa2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
@@ -19,7 +19,14 @@
*/
package org.rhq.enterprise.gui.coregui.client.drift;
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.toolbar.ToolStrip;
+
import org.rhq.core.domain.common.EntityContext;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableToolStrip;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
@@ -42,7 +49,23 @@ public class DriftChangeSetsView extends LocatableVLayout {
protected void onDraw() {
super.onDraw();
- addMember(new ResourceDriftChangeSetsTreeView(extendLocatorId("Tree"), this.hasWriteAccess, this.context));
+ final ResourceDriftChangeSetsTreeView tree = new ResourceDriftChangeSetsTreeView(extendLocatorId("Tree"),
+ this.hasWriteAccess, this.context);
+ addMember(tree);
+
+ ToolStrip toolStrip = new LocatableToolStrip(extendLocatorId("toolstrip"));
+ toolStrip.setBackgroundImage(null);
+ toolStrip.setWidth100();
+ toolStrip.setMembersMargin(3);
+ toolStrip.setPadding(3);
+ IButton refreshButton = new LocatableIButton(extendLocatorId("refreshButton"), MSG.common_button_refresh());
+ refreshButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ tree.refresh();
+ }
+ });
+ toolStrip.addMember(refreshButton);
+ addMember(toolStrip);
}
public EntityContext getContext() {
commit c09f53eb056db2db67bbac77138806e3240aea3a
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jul 26 13:34:42 2011 -0400
refactor so we can later put in group classes but still support indiv resources
fix query so we filter on resource ID for resource view
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java
new file mode 100644
index 0000000..50b4634
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java
@@ -0,0 +1,266 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.tree.TreeNode;
+
+import org.rhq.core.domain.criteria.BaseCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
+import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.criteria.DriftJPACriteria;
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.DriftGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * @author John Mazzitelli
+ */
+@SuppressWarnings("unchecked")
+public abstract class AbstractDriftChangeSetsTreeDataSource extends RPCDataSource<Object, BaseCriteria> {
+
+ public static final String ATTR_PARENT_ID = "parentId";
+ public static final String ATTR_ID = "id";
+ public static final String ATTR_NAME = "name";
+
+ private DriftGWTServiceAsync driftService = GWTServiceLookup.getDriftService();
+ private final boolean canManageDrift;
+
+ public AbstractDriftChangeSetsTreeDataSource(boolean canManageDrift) {
+ super();
+ this.canManageDrift = canManageDrift;
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ DataSourceField idDataField = new DataSourceTextField(ATTR_ID, MSG.common_title_id());
+ idDataField.setPrimaryKey(true);
+ fields.add(idDataField);
+
+ DataSourceTextField nameDataField = new DataSourceTextField(ATTR_NAME, MSG.common_title_name());
+ nameDataField.setCanEdit(false);
+ fields.add(nameDataField);
+
+ DataSourceTextField parentIdField = new DataSourceTextField(ATTR_PARENT_ID, MSG.common_title_id_parent());
+ parentIdField.setForeignKey(ATTR_ID);
+ fields.add(parentIdField);
+
+ return fields;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, final BaseCriteria unused) {
+
+ String parentId = request.getCriteria().getAttribute(ATTR_PARENT_ID);
+
+ if (parentId == null) {
+
+ // There is no parent - we are at the root of the tree.
+ // Get the top nodes (the change sets) but to be as fast as possible don't load their drifts.
+ // We will lazily load drifts when the these changeset tree nodes are opened
+ DriftChangeSetCriteria criteria = getDriftChangeSetCriteria(request);
+
+ driftService.findDriftChangeSetsByCriteria(criteria, new AsyncCallback<PageList<DriftChangeSet>>() {
+ public void onSuccess(PageList<DriftChangeSet> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ } else {
+ String changesetId = parentId;
+ DriftCriteria criteria = new DriftJPACriteria();
+ criteria.addFilterChangeSetId(changesetId);
+
+ driftService.findDriftsByCriteria(criteria, new AsyncCallback<PageList<Drift>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onSuccess(PageList<Drift> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
+
+ /*
+ * I am leaving this code commented for future reference. Because today the drit change set tree only
+ * shows simple changeset->drift tree, we don't need this. But if we need to have
+ * multiple types of child nodes, we'll need something like below to query
+ * for the different child node data. For example, we'd need this if we have a tree like:
+ * ChangeSet
+ * |____Resources
+ * | |____ My resource 1
+ * | |____ ...
+ * |_____Drifts
+ * |___ Drift #1
+ * |___ Drift #2
+ * |___ ...
+ * Today we only have Drifts child nodes, so we don't need to have that intermediate
+ * "Drifts" node. If we later want to introduce different node types (like Resources)
+ * we need additional code like below.
+ *
+
+ // we are at an inner node, being asked to get the children of it
+ if (p.endsWith("_drifts")) {
+ // ...load drift items like above in the real code...
+ } else if (p.endsWith("_resources")) {
+ // ...load resource items and put those nodes in the tree...
+ } else {
+ // This is an unknown type of node, so just log an error.
+ // Note that if, in the future, we have other types of nodes (like maybe resource nodes for group change sets?)
+ // we'll add more if-else statements above to process those different nodes.
+ CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure());
+ }
+
+ *
+ */
+ }
+
+ return;
+ }
+
+ /**
+ * Returns a criteria that will be used to obtain the root nodes for the tree - that is,
+ * the top level change set entries.
+ *
+ * Subclasses can override this method, or modify the returned criteria to further
+ * filter the change sets that are to be returned.
+ *
+ * @param request the request being made of the tree
+ *
+ * @return the criteria to use when querying for change setss
+ */
+ protected DriftChangeSetCriteria getDriftChangeSetCriteria(final DSRequest request) {
+ DriftChangeSetCriteria criteria = new DriftChangeSetJPACriteria();
+ criteria.addSortVersion(PageOrdering.DESC);
+ criteria.setPageControl(getPageControl(request));
+ return criteria;
+ }
+
+ @Override
+ protected BaseCriteria getFetchCriteria(DSRequest request) {
+ // our executeFetch will determine on its own what criteria to use based on what is to be fetched
+ // thus we don't return anything here and let the executeFetch do everything
+ return null;
+ }
+
+ @Override
+ public Object copyValues(Record from) {
+ return null; // don't need this method.
+ }
+
+ @Override
+ public ListGridRecord[] buildRecords(Collection dataObjects) {
+ return buildRecordsForKnownChangeSets(dataObjects, null);
+ }
+
+ public ListGridRecord[] buildRecordsForKnownChangeSets(Collection dataObjects, Integer changeSetId) {
+ if (dataObjects == null) {
+ return null;
+ }
+
+ final List<ListGridRecord> records = new ArrayList<ListGridRecord>();
+
+ for (Object item : dataObjects) {
+
+ // the resultant item is a direct node to build
+ records.add(copyValues(item));
+
+ // now build the children of the node
+ /*
+ * We do not have the need for building any intermeidate nodes today.
+ * There is nothing to do, but if in the future we have differnet node types,
+ * we'll probably want intermediate nodes that we create here. See BundleTreeDataSource
+ * for an example of where this is already done. Commenting this out just as an
+ * example of how this can be done.
+
+ if (item instanceof DriftChangeSet) {
+ DriftChangeSet changeset = (DriftChangeSet) item;
+
+ // each bundle has two direct children - the versions and destinations folders
+ TreeNode versionNode = new TreeNode(MSG.view_drift());
+ versionNode.setID(changeset.getId() + "_drifts");
+ versionNode.setParentID(changeset.getId());
+ versionNode.setName(MSG.view_drift());
+ versionNode.setAttribute("name", MSG.view_drift());
+ records.add(versionNode);
+ } else if (item instanceof Drift) {
+ if (canManageDrift) {
+ records.add(copyValuesForKnownDriftChangeSet(driftItem, changeSetId));
+ }
+ }
+
+ *
+ */
+ }
+
+ return records.toArray(new ListGridRecord[records.size()]);
+ }
+
+ @Override
+ public ListGridRecord copyValues(Object from) {
+ return copyValuesForKnownDriftChangeSet(from, null);
+ }
+
+ public ListGridRecord copyValuesForKnownDriftChangeSet(Object from, Integer changeSetId) {
+ TreeNode node;
+ if (from instanceof DriftChangeSet) {
+ DriftChangeSet changeset = (DriftChangeSet) from;
+ node = new AbstractDriftChangeSetsTreeView.ChangeSetTreeNode(changeset);
+ } else if (from instanceof Drift) {
+ Drift drift = (Drift) from;
+ node = new AbstractDriftChangeSetsTreeView.DriftTreeNode(drift);
+ } else {
+ throw new IllegalArgumentException("please report this bug - bad value: " + from);
+ }
+ // if, in the future, we add more node types, we'll add more else-if statements here
+
+ return node;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
index 50d787d..7778084 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -67,8 +67,6 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
setSelectionType(SelectionStyle.SINGLE);
setShowRollOver(false);
setShowHeader(false);
-
- setDataSource(new DriftChangeSetsTreeDataSource(canManageDrift));
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
deleted file mode 100644
index c6e9e65..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.drift;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.data.fields.DataSourceTextField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.tree.TreeNode;
-
-import org.rhq.core.domain.criteria.BaseCriteria;
-import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
-import org.rhq.core.domain.criteria.DriftCriteria;
-import org.rhq.core.domain.criteria.DriftJPACriteria;
-import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.DriftChangeSet;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.gwt.DriftGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-
-/**
- * @author John Mazzitelli
- */
-@SuppressWarnings("unchecked")
-public class DriftChangeSetsTreeDataSource extends RPCDataSource<Object, BaseCriteria> {
-
- private static final String ATTR_PARENT_ID = "parentId";
- public static final String ATTR_ID = "id";
- public static final String ATTR_NAME = "name";
-
- private DriftGWTServiceAsync driftService = GWTServiceLookup.getDriftService();
- private final boolean canManageDrift;
-
- public DriftChangeSetsTreeDataSource(boolean canManageDrift) {
- super();
- this.canManageDrift = canManageDrift;
- List<DataSourceField> fields = addDataSourceFields();
- addFields(fields);
- }
-
- @Override
- protected List<DataSourceField> addDataSourceFields() {
- List<DataSourceField> fields = super.addDataSourceFields();
-
- DataSourceField idDataField = new DataSourceTextField(ATTR_ID, MSG.common_title_id());
- idDataField.setPrimaryKey(true);
- fields.add(idDataField);
-
- DataSourceTextField nameDataField = new DataSourceTextField(ATTR_NAME, MSG.common_title_name());
- nameDataField.setCanEdit(false);
- fields.add(nameDataField);
-
- DataSourceTextField parentIdField = new DataSourceTextField(ATTR_PARENT_ID, MSG.common_title_id_parent());
- parentIdField.setForeignKey(ATTR_ID);
- fields.add(parentIdField);
-
- return fields;
- }
-
- @Override
- protected void executeFetch(final DSRequest request, final DSResponse response, final BaseCriteria unused) {
-
- String parentId = request.getCriteria().getAttribute(ATTR_PARENT_ID);
-
- if (parentId == null) {
-
- // There is no parent - we are at the root of the tree.
- // Get the top nodes (the change sets) but to be as fast as possible don't load their drifts.
- // We will lazily load drifts when the these changeset tree nodes are opened
- DriftChangeSetCriteria criteria = new DriftChangeSetJPACriteria();
- criteria.addSortVersion(PageOrdering.DESC);
- criteria.setPageControl(getPageControl(request));
-
- driftService.findDriftChangeSetsByCriteria(criteria, new AsyncCallback<PageList<DriftChangeSet>>() {
- public void onSuccess(PageList<DriftChangeSet> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
-
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure(), caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
- });
- } else {
- String changesetId = parentId;
- DriftCriteria criteria = new DriftJPACriteria();
- criteria.addFilterChangeSetId(changesetId);
-
- driftService.findDriftsByCriteria(criteria, new AsyncCallback<PageList<Drift>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure(), caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
-
- public void onSuccess(PageList<Drift> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
- });
-
- /*
- * I am leaving this code commented for future reference. Because today the drit change set tree only
- * shows simple changeset->drift tree, we don't need this. But if we need to have
- * multiple types of child nodes, we'll need something like below to query
- * for the different child node data. For example, we'd need this if we have a tree like:
- * ChangeSet
- * |____Resources
- * | |____ My resource 1
- * | |____ ...
- * |_____Drifts
- * |___ Drift #1
- * |___ Drift #2
- * |___ ...
- * Today we only have Drifts child nodes, so we don't need to have that intermediate
- * "Drifts" node. If we later want to introduce different node types (like Resources)
- * we need additional code like below.
- *
-
- // we are at an inner node, being asked to get the children of it
- if (p.endsWith("_drifts")) {
- // ...load drift items like above in the real code...
- } else if (p.endsWith("_resources")) {
- // ...load resource items and put those nodes in the tree...
- } else {
- // This is an unknown type of node, so just log an error.
- // Note that if, in the future, we have other types of nodes (like maybe resource nodes for group change sets?)
- // we'll add more if-else statements above to process those different nodes.
- CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure());
- }
-
- *
- */
- }
-
- return;
- }
-
- @Override
- protected BaseCriteria getFetchCriteria(DSRequest request) {
- // our executeFetch will determine on its own what criteria to use based on what is to be fetched
- // thus we don't return anything here and let the executeFetch do everything
- return null;
- }
-
- @Override
- public Object copyValues(Record from) {
- return null; // don't need this method.
- }
-
- @Override
- public ListGridRecord[] buildRecords(Collection dataObjects) {
- return buildRecordsForKnownChangeSets(dataObjects, null);
- }
-
- public ListGridRecord[] buildRecordsForKnownChangeSets(Collection dataObjects, Integer changeSetId) {
- if (dataObjects == null) {
- return null;
- }
-
- final List<ListGridRecord> records = new ArrayList<ListGridRecord>();
-
- for (Object item : dataObjects) {
-
- // the resultant item is a direct node to build
- records.add(copyValues(item));
-
- // now build the children of the node
- /*
- * We do not have the need for building any intermeidate nodes today.
- * There is nothing to do, but if in the future we have differnet node types,
- * we'll probably want intermediate nodes that we create here. See BundleTreeDataSource
- * for an example of where this is already done. Commenting this out just as an
- * example of how this can be done.
-
- if (item instanceof DriftChangeSet) {
- DriftChangeSet changeset = (DriftChangeSet) item;
-
- // each bundle has two direct children - the versions and destinations folders
- TreeNode versionNode = new TreeNode(MSG.view_drift());
- versionNode.setID(changeset.getId() + "_drifts");
- versionNode.setParentID(changeset.getId());
- versionNode.setName(MSG.view_drift());
- versionNode.setAttribute("name", MSG.view_drift());
- records.add(versionNode);
- } else if (item instanceof Drift) {
- if (canManageDrift) {
- records.add(copyValuesForKnownDriftChangeSet(driftItem, changeSetId));
- }
- }
-
- *
- */
- }
-
- return records.toArray(new ListGridRecord[records.size()]);
- }
-
- @Override
- public ListGridRecord copyValues(Object from) {
- return copyValuesForKnownDriftChangeSet(from, null);
- }
-
- public ListGridRecord copyValuesForKnownDriftChangeSet(Object from, Integer changeSetId) {
- TreeNode node;
- if (from instanceof DriftChangeSet) {
- DriftChangeSet changeset = (DriftChangeSet) from;
- node = new AbstractDriftChangeSetsTreeView.ChangeSetTreeNode(changeset);
- } else if (from instanceof Drift) {
- Drift drift = (Drift) from;
- node = new AbstractDriftChangeSetsTreeView.DriftTreeNode(drift);
- } else {
- throw new IllegalArgumentException("please report this bug - bad value: " + from);
- }
- // if, in the future, we add more node types, we'll add more else-if statements here
-
- return node;
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeDataSource.java
new file mode 100644
index 0000000..f5341e2
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeDataSource.java
@@ -0,0 +1,51 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import com.smartgwt.client.data.DSRequest;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+
+/**
+ * @author John Mazzitelli
+ */
+public class ResourceDriftChangeSetsTreeDataSource extends AbstractDriftChangeSetsTreeDataSource {
+
+ private final EntityContext context;
+
+ public ResourceDriftChangeSetsTreeDataSource(boolean canManageDrift, EntityContext context) {
+ super(canManageDrift);
+
+ if (context.type != EntityContext.Type.Resource) {
+ throw new IllegalArgumentException("wrong context: " + context);
+ }
+
+ this.context = context;
+ }
+
+ @Override
+ protected DriftChangeSetCriteria getDriftChangeSetCriteria(final DSRequest request) {
+ DriftChangeSetCriteria criteria = super.getDriftChangeSetCriteria(request);
+ criteria.addFilterResourceId(this.context.resourceId);
+ return criteria;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
index 3e368d5..3ee0b5f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
@@ -40,11 +40,13 @@ public class ResourceDriftChangeSetsTreeView extends AbstractDriftChangeSetsTree
}
this.context = context;
+
+ setDataSource(new ResourceDriftChangeSetsTreeDataSource(canManageDrift, context));
}
protected String getNodeTargetLink(TreeNode node) {
if (node instanceof DriftTreeNode) {
- String driftIdStr = node.getAttribute(DriftChangeSetsTreeDataSource.ATTR_ID).split("_")[1];
+ String driftIdStr = node.getAttribute(AbstractDriftChangeSetsTreeDataSource.ATTR_ID).split("_")[1];
String path = LinkManager.getDriftHistoryLink(this.context.resourceId, Integer.valueOf(driftIdStr));
return path;
}
commit 3796f35c8250ffc3b798ff7cb3dcd5b2f4204596
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 26 09:22:15 2011 -0400
Adding logic to check the enabled flag during drift detection
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 f2883b9..b92dd7c 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
@@ -54,6 +54,18 @@ public class DriftDetector implements Runnable {
if (schedule.getNextScan() > (System.currentTimeMillis() + 100L)) {
scheduleQueue.enqueue(schedule);
+ // TODO should we grab the schedule from the queue?
+ // Maybe we should continue pulling schedules off the queue until
+ // we find one that is ready to be processed.
+ return;
+ }
+
+ if (!schedule.getDriftConfiguration().getEnabled()) {
+ schedule.updateShedule();
+ scheduleQueue.enqueue(schedule);
+ // TODO should we grab the schedule from the queue?
+ // Maybe we should continue pulling schedules off the queue until
+ // we find one that is ready to be processed.
return;
}
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 fe15677..7934c2d 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,7 +1,6 @@
package org.rhq.core.pc.drift;
import java.util.PriorityQueue;
-import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
public class ScheduleQueueImpl implements ScheduleQueue {
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 4f27974..9b62422 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
@@ -16,6 +16,7 @@ import org.rhq.common.drift.ChangeSetReaderImpl;
import org.rhq.common.drift.DirectoryEntry;
import org.rhq.common.drift.FileEntry;
import org.rhq.common.drift.Headers;
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftConfiguration;
import static org.apache.commons.io.FileUtils.touch;
@@ -167,6 +168,32 @@ public class DriftDetectorTest extends DriftTest {
@SuppressWarnings("unchecked")
@Test
+ public void skipScheduledThatHasConfigDisabled() throws Exception {
+ detector.setDriftClient(new DriftClientTestStub() {
+ {
+ setBaseDir(resourceDir);
+ }
+
+ @Override
+ public void sendChangeSetToServer(int resourceId, DriftConfiguration driftConfiguration,
+ DriftChangeSetCategory type) {
+ throw new RuntimeException("Should not invoke drift client when drift configuration is disabled");
+ }
+ });
+
+ DriftConfiguration config = driftConfiguration("disabled-config-test", resourceDir.getAbsolutePath());
+ config.setEnabled(false);
+
+ File confDir = mkdir(resourceDir, "conf");
+ File server1Conf = new File(confDir, "server-1.conf");
+ touch(server1Conf);
+
+ scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ detector.run();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
public void includeAddedFileInDriftChangeSet() throws Exception {
DriftConfiguration config = driftConfiguration("file-added-drift-test", resourceDir.getAbsolutePath());
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftTest.java
index 97bfa45..98c421e 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftTest.java
@@ -81,6 +81,12 @@ public class DriftTest {
*/
protected File resourceDir;
+ /**
+ * The default interval assigned to drift configurations created using
+ * {@link #driftConfiguration(String, String)}
+ */
+ protected long defaultInterval = 1800L; // 30 minutes;
+
private MessageDigestGenerator digestGenerator;
/**
@@ -180,6 +186,7 @@ public class DriftTest {
/**
* Creates a {@link DriftConfiguration} with the specified basedir. The file system is
* used as the context for the basedir which means the path specified is used as is.
+ * The interval property is set to {@link #defaultInterval}.
*
* @param name The configuration name
* @param basedir An absolute path of the base directory
@@ -189,6 +196,8 @@ public class DriftTest {
DriftConfiguration config = new DriftConfiguration(new Configuration());
config.setName(name);
config.setBasedir(new DriftConfiguration.BaseDirectory(fileSystem, basedir));
+ config.setEnabled(true);
+ config.setInterval(defaultInterval);
return config;
}
commit 70fbc22e07246b5dd161c32877cfaf0cea4458ff
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jul 25 17:53:45 2011 -0400
sort the query in desc order, though the tree currently ignores this and has its own sorting.
need to fix that later
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
index fe8586a..c6e9e65 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
@@ -95,7 +95,7 @@ public class DriftChangeSetsTreeDataSource extends RPCDataSource<Object, BaseCri
// Get the top nodes (the change sets) but to be as fast as possible don't load their drifts.
// We will lazily load drifts when the these changeset tree nodes are opened
DriftChangeSetCriteria criteria = new DriftChangeSetJPACriteria();
- criteria.addSortVersion(PageOrdering.ASC);
+ criteria.addSortVersion(PageOrdering.DESC);
criteria.setPageControl(getPageControl(request));
driftService.findDriftChangeSetsByCriteria(criteria, new AsyncCallback<PageList<DriftChangeSet>>() {
commit ce318c437ea1a985679610191a0ceb6d3ebe5195
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jul 25 17:53:03 2011 -0400
default subtab view for drift is the change set tree
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 4efc189..0e63d8e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -243,13 +243,13 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
driftTab = new TwoLevelTab(getTabSet().extendLocatorId(Tab.DRIFT), new ViewName(Tab.DRIFT, MSG
.view_tabs_common_drift()), "subsystems/drift/Drift_16.png");
- this.driftHistory = new SubTab(driftTab.extendLocatorId(DriftSubTab.HISTORY), new ViewName(DriftSubTab.HISTORY,
- MSG.view_tabs_common_history()), null);
this.driftChangeSets = new SubTab(driftTab.extendLocatorId(DriftSubTab.CHANGE_SETS), new ViewName(
DriftSubTab.CHANGE_SETS, MSG.view_drift_changeSets()), null);
+ this.driftHistory = new SubTab(driftTab.extendLocatorId(DriftSubTab.HISTORY), new ViewName(DriftSubTab.HISTORY,
+ MSG.view_tabs_common_history()), null);
this.driftConfig = new SubTab(driftTab.extendLocatorId(DriftSubTab.CONFIGURATION), new ViewName(
DriftSubTab.CONFIGURATION, MSG.view_tabs_common_configuration()), null);
- driftTab.registerSubTabs(driftHistory, driftChangeSets, driftConfig);
+ driftTab.registerSubTabs(driftChangeSets, driftHistory, driftConfig);
tabs.add(driftTab);
contentTab = new TwoLevelTab(getTabSet().extendLocatorId("Content"), new ViewName("Content", MSG
@@ -519,17 +519,17 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
ResourcePermission resourcePermissions, Set<ResourceTypeFacet> facets) {
if (updateTab(this.driftTab, facets.contains(ResourceTypeFacet.DRIFT), resourcePermissions.isDrift())) {
- updateSubTab(this.driftTab, this.driftHistory, true, true, new ViewFactory() {
+ updateSubTab(this.driftTab, this.driftChangeSets, true, true, new ViewFactory() {
@Override
public Canvas createView() {
- return ResourceDriftHistoryView.get(driftHistory.extendLocatorId("View"), resourceComposite);
+ return ResourceDriftChangeSetsView.get(driftChangeSets.extendLocatorId("View"), resourceComposite);
}
});
- updateSubTab(this.driftTab, this.driftChangeSets, true, true, new ViewFactory() {
+ updateSubTab(this.driftTab, this.driftHistory, true, true, new ViewFactory() {
@Override
public Canvas createView() {
- return ResourceDriftChangeSetsView.get(driftChangeSets.extendLocatorId("View"), resourceComposite);
+ return ResourceDriftHistoryView.get(driftHistory.extendLocatorId("View"), resourceComposite);
}
});
commit 14da4c241edb1bb8116eaf1657ddda6746f258fb
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jul 25 17:49:19 2011 -0400
initial start of the context menu for the change set tree
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
index 521d7b2..50d787d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -27,14 +27,24 @@ import com.google.gwt.core.client.RunAsyncCallback;
import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
+import com.smartgwt.client.widgets.menu.Menu;
+import com.smartgwt.client.widgets.menu.MenuItem;
+import com.smartgwt.client.widgets.menu.MenuItemSeparator;
+import com.smartgwt.client.widgets.menu.events.ClickHandler;
+import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
import com.smartgwt.client.widgets.tree.Tree;
import com.smartgwt.client.widgets.tree.TreeNode;
-import com.smartgwt.client.widgets.tree.events.NodeClickEvent;
-import com.smartgwt.client.widgets.tree.events.NodeClickHandler;
+import com.smartgwt.client.widgets.tree.events.NodeContextClickEvent;
+import com.smartgwt.client.widgets.tree.events.NodeContextClickHandler;
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
/**
@@ -56,18 +66,9 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
setAnimateFolders(false);
setSelectionType(SelectionStyle.SINGLE);
setShowRollOver(false);
- setSortField(DriftChangeSetsTreeDataSource.ATTR_NAME);
setShowHeader(false);
setDataSource(new DriftChangeSetsTreeDataSource(canManageDrift));
-
- addNodeClickHandler(new NodeClickHandler() {
- public void onNodeClick(NodeClickEvent event) {
- TreeNode node = event.getNode();
- String link = getNodeTargetLink(node);
- CoreGUI.goToView(link);
- }
- });
}
@Override
@@ -76,13 +77,30 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
// We may need to wait for tree data to be fetched before we can complete processing the selected path.
// When the datasource pulls data keep processing the selectedPath if necessary.
- this.addDataArrivedHandler(new DataArrivedHandler() {
+ addDataArrivedHandler(new DataArrivedHandler() {
public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
if (null != pendingPath) {
selectPath(pendingPath);
}
}
});
+
+ addNodeContextClickHandler(new NodeContextClickHandler() {
+ public void onNodeContextClick(final NodeContextClickEvent event) {
+ // stop the browser right-click menu
+ event.cancel();
+
+ TreeNode eventNode = event.getNode();
+
+ if (eventNode instanceof ChangeSetTreeNode) {
+ CoreGUI.getMessageCenter().notify(new Message("TODO [this will popup the changeset menu]"));
+ } else if (eventNode instanceof DriftTreeNode) {
+ Menu menu = buildContextMenu((DriftTreeNode) eventNode);
+ menu.showContextMenu();
+ }
+ }
+ });
+
}
public void selectPath(ViewPath viewPath) {
@@ -144,4 +162,76 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
* @return the node's link
*/
protected abstract String getNodeTargetLink(TreeNode node);
+
+ /**
+ * Builds the right-mouse-click context menu for the given drift node
+ * @param node the drift node whose menu is to be displayed
+ * @return the context menu to display
+ */
+ protected Menu buildContextMenu(final DriftTreeNode node) {
+
+ Menu contextMenu = new Menu();
+
+ // title
+ String titleName = node.getName();
+ if (titleName.length() > 50) {
+ // make sure the title isn't really long so the menu is not abnormally wide
+ titleName = "..." + titleName.substring(titleName.length() - 50);
+ }
+ MenuItem titleItem = new MenuItem(titleName);
+ titleItem.setEnabled(false);
+ contextMenu.setItems(titleItem);
+
+ // separator
+ contextMenu.addItem(new MenuItemSeparator());
+
+ // item that links to the history details
+ MenuItem detailsItem = new MenuItem(MSG.common_title_details());
+ detailsItem.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ String link = getNodeTargetLink(node);
+ if (link != null) {
+ CoreGUI.goToView(link);
+ }
+ }
+ });
+ contextMenu.addItem(detailsItem);
+
+ return contextMenu;
+ }
+
+ @SuppressWarnings("unchecked")
+ static class ChangeSetTreeNode extends TreeNode {
+ public ChangeSetTreeNode(DriftChangeSet changeset) {
+ setIsFolder(true);
+ setIcon("subsystems/drift/ChangeSet_16.png");
+ setShowOpenIcon(true);
+ setID(changeset.getId());
+ setName(buildDriftChangeSetNodeName(changeset));
+ }
+
+ private String buildDriftChangeSetNodeName(DriftChangeSet changeset) {
+ StringBuilder str = new StringBuilder();
+ str.append(MSG.common_title_version());
+ str.append(' ');
+ str.append(changeset.getVersion());
+ str.append(" (");
+ str.append(TimestampCellFormatter.format(changeset.getCtime(),
+ TimestampCellFormatter.DATE_TIME_FORMAT_SHORT));
+ str.append(')');
+ return str.toString();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ static class DriftTreeNode extends TreeNode {
+ public DriftTreeNode(Drift drift) {
+ setIsFolder(false);
+ setIcon(ImageManager.getDriftCategoryIcon(drift.getCategory()));
+ String parentID = drift.getChangeSet().getId();
+ setParentID(parentID);
+ setID(parentID + '_' + drift.getId());
+ setName(drift.getPath());
+ }
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
index c609a1e..fe8586a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
@@ -39,9 +39,8 @@ import org.rhq.core.domain.criteria.DriftJPACriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.DriftGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
@@ -96,6 +95,7 @@ public class DriftChangeSetsTreeDataSource extends RPCDataSource<Object, BaseCri
// Get the top nodes (the change sets) but to be as fast as possible don't load their drifts.
// We will lazily load drifts when the these changeset tree nodes are opened
DriftChangeSetCriteria criteria = new DriftChangeSetJPACriteria();
+ criteria.addSortVersion(PageOrdering.ASC);
criteria.setPageControl(getPageControl(request));
driftService.findDriftChangeSetsByCriteria(criteria, new AsyncCallback<PageList<DriftChangeSet>>() {
@@ -233,38 +233,18 @@ public class DriftChangeSetsTreeDataSource extends RPCDataSource<Object, BaseCri
}
public ListGridRecord copyValuesForKnownDriftChangeSet(Object from, Integer changeSetId) {
- String parentID;
- TreeNode node = new TreeNode();
+ TreeNode node;
if (from instanceof DriftChangeSet) {
DriftChangeSet changeset = (DriftChangeSet) from;
- node.setIsFolder(true);
- node.setIcon("subsystems/drift/ChangeSet_16.png");
- node.setShowOpenIcon(true);
- node.setID(changeset.getId());
- node.setName(buildDriftChangeSetNodeName(changeset));
-
+ node = new AbstractDriftChangeSetsTreeView.ChangeSetTreeNode(changeset);
} else if (from instanceof Drift) {
Drift drift = (Drift) from;
- node.setIsFolder(false);
- node.setIcon(ImageManager.getDriftCategoryIcon(drift.getCategory()));
- parentID = drift.getChangeSet().getId();
- node.setParentID(parentID);
- node.setID(parentID + '_' + drift.getId());
- node.setName(drift.getPath());
+ node = new AbstractDriftChangeSetsTreeView.DriftTreeNode(drift);
+ } else {
+ throw new IllegalArgumentException("please report this bug - bad value: " + from);
}
// if, in the future, we add more node types, we'll add more else-if statements here
return node;
}
-
- private String buildDriftChangeSetNodeName(DriftChangeSet changeset) {
- StringBuilder str = new StringBuilder();
- str.append(MSG.common_title_version());
- str.append(' ');
- str.append(changeset.getVersion());
- str.append(" (");
- str.append(TimestampCellFormatter.format(changeset.getCtime(), TimestampCellFormatter.DATE_TIME_FORMAT_SHORT));
- str.append(')');
- return str.toString();
- }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
index dc2a22d..3e368d5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
@@ -43,9 +43,12 @@ public class ResourceDriftChangeSetsTreeView extends AbstractDriftChangeSetsTree
}
protected String getNodeTargetLink(TreeNode node) {
- String driftIdStr = node.getAttribute(DriftChangeSetsTreeDataSource.ATTR_ID).split("_")[1];
- String path = LinkManager.getDriftHistoryLink(this.context.resourceId, Integer.valueOf(driftIdStr));
- return path;
+ if (node instanceof DriftTreeNode) {
+ String driftIdStr = node.getAttribute(DriftChangeSetsTreeDataSource.ATTR_ID).split("_")[1];
+ String path = LinkManager.getDriftHistoryLink(this.context.resourceId, Integer.valueOf(driftIdStr));
+ return path;
+ }
+ return null;
}
}
commit 50215a85fb2c91627be9fb8c350c5222c3d57350
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jul 25 16:37:56 2011 -0400
the initial start of the drift change set tree view
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
index 30523b3..10c15e4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
@@ -458,4 +458,8 @@ public class LinkManager {
public static String getBundleDeploymentLink(int bundleId, int bundleDeploymentId) {
return "#Bundles/Bundle/" + bundleId + "/deployments/" + bundleDeploymentId;
}
+
+ public static String getDriftHistoryLink(int resourceId, int driftId) {
+ return "#Resource/" + resourceId + "/Drift/History/" + driftId;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
new file mode 100644
index 0000000..521d7b2
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -0,0 +1,147 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.RunAsyncCallback;
+import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
+import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
+import com.smartgwt.client.widgets.tree.Tree;
+import com.smartgwt.client.widgets.tree.TreeNode;
+import com.smartgwt.client.widgets.tree.events.NodeClickEvent;
+import com.smartgwt.client.widgets.tree.events.NodeClickHandler;
+
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ViewId;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
+
+/**
+ * @author John Mazzitelli
+ */
+public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid {
+
+ // We may need to wait for tree data to be fetched before we can complete processing the selected path.
+ // If so, hold it here and retry after the datasource pulls the data.
+ private ViewPath pendingPath = null;
+
+ public AbstractDriftChangeSetsTreeView(String locatorId, boolean canManageDrift) {
+ super(locatorId);
+ setWidth100();
+ setHeight100();
+ setLeaveScrollbarGap(false);
+ // fetch the top nodes at the inital onDraw()
+ setAutoFetchData(true);
+ setAnimateFolders(false);
+ setSelectionType(SelectionStyle.SINGLE);
+ setShowRollOver(false);
+ setSortField(DriftChangeSetsTreeDataSource.ATTR_NAME);
+ setShowHeader(false);
+
+ setDataSource(new DriftChangeSetsTreeDataSource(canManageDrift));
+
+ addNodeClickHandler(new NodeClickHandler() {
+ public void onNodeClick(NodeClickEvent event) {
+ TreeNode node = event.getNode();
+ String link = getNodeTargetLink(node);
+ CoreGUI.goToView(link);
+ }
+ });
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ // We may need to wait for tree data to be fetched before we can complete processing the selected path.
+ // When the datasource pulls data keep processing the selectedPath if necessary.
+ this.addDataArrivedHandler(new DataArrivedHandler() {
+ public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
+ if (null != pendingPath) {
+ selectPath(pendingPath);
+ }
+ }
+ });
+ }
+
+ public void selectPath(ViewPath viewPath) {
+ Tree theTree = getTree();
+
+ if (viewPath.viewsLeft() > 0) {
+ String key = "";
+ for (ViewId view : viewPath.getViewPath().subList(2, viewPath.getViewPath().size())) {
+ if (key.length() > 0) {
+ key += "_";
+ }
+
+ key += view.getPath();
+
+ TreeNode node = theTree.findById(key);
+
+ if (node != null) {
+ // open the node, this will force a fetch of child data if necessary
+ theTree.openFolder(node);
+ } else {
+ // wait for data to get loaded...
+ pendingPath = new ViewPath(viewPath.toString());
+ return;
+ }
+ }
+
+ // we found the node, so keep going
+ pendingPath = null;
+
+ final String finalKey = key;
+ GWT.runAsync(new RunAsyncCallback() {
+ public void onFailure(Throwable reason) {
+ }
+
+ public void onSuccess() {
+ TreeNode node = getTree().findById(finalKey);
+ if (node != null) {
+ deselectAllRecords();
+ selectRecord(node);
+ }
+ }
+ });
+ } else {
+ deselectAllRecords();
+ if (getTotalRows() > 0)
+ selectRecord(0);
+ }
+ }
+
+ public void refresh() {
+ invalidateCache();
+ }
+
+ /**
+ * Returns the link (as a string) that the client should be redirected to
+ * if the given node is clicked.
+ *
+ * @param node the node whose target link is to be returned
+ * @return the node's link
+ */
+ protected abstract String getNodeTargetLink(TreeNode node);
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
new file mode 100644
index 0000000..c609a1e
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
@@ -0,0 +1,270 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.tree.TreeNode;
+
+import org.rhq.core.domain.criteria.BaseCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
+import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.criteria.DriftJPACriteria;
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
+import org.rhq.enterprise.gui.coregui.client.gwt.DriftGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * @author John Mazzitelli
+ */
+@SuppressWarnings("unchecked")
+public class DriftChangeSetsTreeDataSource extends RPCDataSource<Object, BaseCriteria> {
+
+ private static final String ATTR_PARENT_ID = "parentId";
+ public static final String ATTR_ID = "id";
+ public static final String ATTR_NAME = "name";
+
+ private DriftGWTServiceAsync driftService = GWTServiceLookup.getDriftService();
+ private final boolean canManageDrift;
+
+ public DriftChangeSetsTreeDataSource(boolean canManageDrift) {
+ super();
+ this.canManageDrift = canManageDrift;
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ DataSourceField idDataField = new DataSourceTextField(ATTR_ID, MSG.common_title_id());
+ idDataField.setPrimaryKey(true);
+ fields.add(idDataField);
+
+ DataSourceTextField nameDataField = new DataSourceTextField(ATTR_NAME, MSG.common_title_name());
+ nameDataField.setCanEdit(false);
+ fields.add(nameDataField);
+
+ DataSourceTextField parentIdField = new DataSourceTextField(ATTR_PARENT_ID, MSG.common_title_id_parent());
+ parentIdField.setForeignKey(ATTR_ID);
+ fields.add(parentIdField);
+
+ return fields;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, final BaseCriteria unused) {
+
+ String parentId = request.getCriteria().getAttribute(ATTR_PARENT_ID);
+
+ if (parentId == null) {
+
+ // There is no parent - we are at the root of the tree.
+ // Get the top nodes (the change sets) but to be as fast as possible don't load their drifts.
+ // We will lazily load drifts when the these changeset tree nodes are opened
+ DriftChangeSetCriteria criteria = new DriftChangeSetJPACriteria();
+ criteria.setPageControl(getPageControl(request));
+
+ driftService.findDriftChangeSetsByCriteria(criteria, new AsyncCallback<PageList<DriftChangeSet>>() {
+ public void onSuccess(PageList<DriftChangeSet> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ } else {
+ String changesetId = parentId;
+ DriftCriteria criteria = new DriftJPACriteria();
+ criteria.addFilterChangeSetId(changesetId);
+
+ driftService.findDriftsByCriteria(criteria, new AsyncCallback<PageList<Drift>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onSuccess(PageList<Drift> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
+
+ /*
+ * I am leaving this code commented for future reference. Because today the drit change set tree only
+ * shows simple changeset->drift tree, we don't need this. But if we need to have
+ * multiple types of child nodes, we'll need something like below to query
+ * for the different child node data. For example, we'd need this if we have a tree like:
+ * ChangeSet
+ * |____Resources
+ * | |____ My resource 1
+ * | |____ ...
+ * |_____Drifts
+ * |___ Drift #1
+ * |___ Drift #2
+ * |___ ...
+ * Today we only have Drifts child nodes, so we don't need to have that intermediate
+ * "Drifts" node. If we later want to introduce different node types (like Resources)
+ * we need additional code like below.
+ *
+
+ // we are at an inner node, being asked to get the children of it
+ if (p.endsWith("_drifts")) {
+ // ...load drift items like above in the real code...
+ } else if (p.endsWith("_resources")) {
+ // ...load resource items and put those nodes in the tree...
+ } else {
+ // This is an unknown type of node, so just log an error.
+ // Note that if, in the future, we have other types of nodes (like maybe resource nodes for group change sets?)
+ // we'll add more if-else statements above to process those different nodes.
+ CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure());
+ }
+
+ *
+ */
+ }
+
+ return;
+ }
+
+ @Override
+ protected BaseCriteria getFetchCriteria(DSRequest request) {
+ // our executeFetch will determine on its own what criteria to use based on what is to be fetched
+ // thus we don't return anything here and let the executeFetch do everything
+ return null;
+ }
+
+ @Override
+ public Object copyValues(Record from) {
+ return null; // don't need this method.
+ }
+
+ @Override
+ public ListGridRecord[] buildRecords(Collection dataObjects) {
+ return buildRecordsForKnownChangeSets(dataObjects, null);
+ }
+
+ public ListGridRecord[] buildRecordsForKnownChangeSets(Collection dataObjects, Integer changeSetId) {
+ if (dataObjects == null) {
+ return null;
+ }
+
+ final List<ListGridRecord> records = new ArrayList<ListGridRecord>();
+
+ for (Object item : dataObjects) {
+
+ // the resultant item is a direct node to build
+ records.add(copyValues(item));
+
+ // now build the children of the node
+ /*
+ * We do not have the need for building any intermeidate nodes today.
+ * There is nothing to do, but if in the future we have differnet node types,
+ * we'll probably want intermediate nodes that we create here. See BundleTreeDataSource
+ * for an example of where this is already done. Commenting this out just as an
+ * example of how this can be done.
+
+ if (item instanceof DriftChangeSet) {
+ DriftChangeSet changeset = (DriftChangeSet) item;
+
+ // each bundle has two direct children - the versions and destinations folders
+ TreeNode versionNode = new TreeNode(MSG.view_drift());
+ versionNode.setID(changeset.getId() + "_drifts");
+ versionNode.setParentID(changeset.getId());
+ versionNode.setName(MSG.view_drift());
+ versionNode.setAttribute("name", MSG.view_drift());
+ records.add(versionNode);
+ } else if (item instanceof Drift) {
+ if (canManageDrift) {
+ records.add(copyValuesForKnownDriftChangeSet(driftItem, changeSetId));
+ }
+ }
+
+ *
+ */
+ }
+
+ return records.toArray(new ListGridRecord[records.size()]);
+ }
+
+ @Override
+ public ListGridRecord copyValues(Object from) {
+ return copyValuesForKnownDriftChangeSet(from, null);
+ }
+
+ public ListGridRecord copyValuesForKnownDriftChangeSet(Object from, Integer changeSetId) {
+ String parentID;
+ TreeNode node = new TreeNode();
+ if (from instanceof DriftChangeSet) {
+ DriftChangeSet changeset = (DriftChangeSet) from;
+ node.setIsFolder(true);
+ node.setIcon("subsystems/drift/ChangeSet_16.png");
+ node.setShowOpenIcon(true);
+ node.setID(changeset.getId());
+ node.setName(buildDriftChangeSetNodeName(changeset));
+
+ } else if (from instanceof Drift) {
+ Drift drift = (Drift) from;
+ node.setIsFolder(false);
+ node.setIcon(ImageManager.getDriftCategoryIcon(drift.getCategory()));
+ parentID = drift.getChangeSet().getId();
+ node.setParentID(parentID);
+ node.setID(parentID + '_' + drift.getId());
+ node.setName(drift.getPath());
+ }
+ // if, in the future, we add more node types, we'll add more else-if statements here
+
+ return node;
+ }
+
+ private String buildDriftChangeSetNodeName(DriftChangeSet changeset) {
+ StringBuilder str = new StringBuilder();
+ str.append(MSG.common_title_version());
+ str.append(' ');
+ str.append(changeset.getVersion());
+ str.append(" (");
+ str.append(TimestampCellFormatter.format(changeset.getCtime(), TimestampCellFormatter.DATE_TIME_FORMAT_SHORT));
+ str.append(')');
+ return str.toString();
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
index f610b8b..48f5bc8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
@@ -38,6 +38,13 @@ public class DriftChangeSetsView extends LocatableVLayout {
this.hasWriteAccess = hasWriteAccess;
}
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ addMember(new ResourceDriftChangeSetsTreeView(extendLocatorId("Tree"), this.hasWriteAccess, this.context));
+ }
+
public EntityContext getContext() {
return context;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
new file mode 100644
index 0000000..dc2a22d
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
@@ -0,0 +1,51 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import com.smartgwt.client.widgets.tree.TreeNode;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
+
+/**
+ * @author John Mazzitelli
+ */
+public class ResourceDriftChangeSetsTreeView extends AbstractDriftChangeSetsTreeView {
+
+ private final EntityContext context;
+
+ public ResourceDriftChangeSetsTreeView(String locatorId, boolean canManageDrift, EntityContext context) {
+
+ super(locatorId, canManageDrift);
+
+ if (context.type != EntityContext.Type.Resource) {
+ throw new IllegalArgumentException("wrong context: " + context);
+ }
+
+ this.context = context;
+ }
+
+ protected String getNodeTargetLink(TreeNode node) {
+ String driftIdStr = node.getAttribute(DriftChangeSetsTreeDataSource.ATTR_ID).split("_")[1];
+ String path = LinkManager.getDriftHistoryLink(this.context.resourceId, Integer.valueOf(driftIdStr));
+ return path;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index c7d6f91..ea8c956 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -1123,6 +1123,7 @@ view_drift_category_fileChanged = File Changed
view_drift_category_fileRemoved = File Removed
view_drift_changeSets = Change Sets
view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
view_drift_delete_confirm = Delete the selected drift(s)?
view_drift_delete_confirmAll = Delete all drifts from this source?
view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index 5fe14aa..a07568a 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -941,6 +941,7 @@ view_dashboards_title = Dashboard
##view_drift_category_fileRemoved = File Removed
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index 6bce847..6e68cff 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -1106,6 +1106,7 @@ view_dashboards_title = ããã·ã¥ããŒã
##view_drift = Drift
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
##view_drift_table_baseDir = Base Directory
##view_drift_table_changeSet = Change Set
##view_drift_table_newFile = New File
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index bd2b6fb..fa86006 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -1141,6 +1141,7 @@ view_dashboards_title = Dashboard~
##view_drift_category_fileRemoved = File Removed
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index 9fa9115..79816c5 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -1115,6 +1115,7 @@ view_dashboards_title = \u7edf\u8ba1\u8868\u76d8
##view_drift = Drift
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
##view_drift_table_baseDir = Base Directory
##view_drift_table_changeSet = Change Set
##view_drift_table_newFile = New File
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png
new file mode 100644
index 0000000..fdda214
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png
new file mode 100644
index 0000000..358cf61
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png differ
commit abb0a2caa37e9258b97957f4ac2acd78a6c13638
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jul 25 12:12:31 2011 -0400
drift change set criteria needs to support paging like everyone else.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BaseCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BaseCriteria.java
index edc436b..f377ade 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BaseCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BaseCriteria.java
@@ -3,8 +3,11 @@ package org.rhq.core.domain.criteria;
import org.rhq.core.domain.util.PageControl;
/**
- * Created by IntelliJ IDEA. User: jsanda Date: 7/19/11 Time: 5:30 PM To change this template use File | Settings | File
- * Templates.
+ * All criteria, regardless of the backend storage that will be queried with this criteria, needs
+ * to support certain base functionality (like paging).
+ * This base interface provides that common API.
+ *
+ * @author John Sanda
*/
public interface BaseCriteria {
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
index 1b3effc..b5f71b2 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
@@ -5,7 +5,7 @@ import java.io.Serializable;
import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.util.PageOrdering;
-public interface DriftChangeSetCriteria extends Serializable {
+public interface DriftChangeSetCriteria extends BaseCriteria, Serializable {
void addFilterId(String filterId);
commit bd1fd799e79a43d006f82d6e7ad5817a42486b8f
Author: John Sanda <jsanda(a)redhat.com>
Date: Sun Jul 24 21:13:24 2011 -0400
Adding createSnapshot method to drift server api
Also moving Snapshot and DiffReport classes to core/domain to make them
accessible to coregui.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DiffReport.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DiffReport.java
new file mode 100644
index 0000000..e0659d9
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DiffReport.java
@@ -0,0 +1,38 @@
+package org.rhq.core.domain.drift;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DiffReport<T> {
+
+ private List<T> notInLeft = new ArrayList<T>();
+
+ private List<T> notInRight = new ArrayList<T>();
+
+ private List<T> conflicts = new ArrayList<T>();
+
+ public List<T> getElementsNotInLeft() {
+ return notInLeft;
+ }
+
+ public void elementNotInLeft(T element) {
+ notInLeft.add(element);
+ }
+
+ public List<T> getElementsNotInRight() {
+ return notInRight;
+ }
+
+ public void elementNotInRight(T element) {
+ notInRight.add(element);
+ }
+
+ public List<T> getElementsInConflict() {
+ return conflicts;
+ }
+
+ public void elementInConflict(T element) {
+ conflicts.add(element);
+ }
+
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/Snapshot.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/Snapshot.java
new file mode 100644
index 0000000..91e5f50
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/Snapshot.java
@@ -0,0 +1,68 @@
+package org.rhq.core.domain.drift;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Map;
+import java.util.TreeMap;
+
+import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
+
+public class Snapshot implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private int version;
+
+ private Map<String, Drift> entries = new TreeMap<String, Drift>();
+
+ public int getVersion() {
+ return version;
+ }
+
+ public Collection<Drift> getEntries() {
+ return entries.values();
+ }
+
+ public <D extends Drift> Snapshot add(DriftChangeSet<D> changeSet) {
+ for (Drift entry : changeSet.getDrifts()) {
+ entries.remove(entry.getPath());
+ if (entry.getCategory() != FILE_REMOVED) {
+ entries.put(entry.getPath(), entry);
+ }
+ }
+ version = changeSet.getVersion();
+ return this;
+ }
+
+ public DiffReport diff(Snapshot right) {
+ Snapshot left = this;
+ DiffReport<Drift> diff = new DiffReport<Drift>();
+
+ for (Map.Entry<String, Drift> entry : left.entries.entrySet()) {
+ if (!right.entries.containsKey(entry.getKey())) {
+ diff.elementNotInRight(entry.getValue());
+ }
+ }
+
+ for (Map.Entry<String, Drift> entry : right.entries.entrySet()) {
+ if (!left.entries.containsKey(entry.getKey())) {
+ diff.elementNotInLeft(entry.getValue());
+ }
+ }
+
+ for (Map.Entry<String, Drift> entry : left.entries.entrySet()) {
+ Drift rightDrift = right.entries.get(entry.getKey());
+ if (rightDrift != null) {
+ DriftFile leftFile = entry.getValue().getNewDriftFile();
+ DriftFile rightFile = rightDrift.getNewDriftFile();
+
+ if (!leftFile.getHashId().equals(rightFile.getHashId())) {
+ diff.elementInConflict(entry.getValue());
+ }
+ }
+ }
+
+ return diff;
+ }
+
+}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java
new file mode 100644
index 0000000..93653b3
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java
@@ -0,0 +1,383 @@
+package org.rhq.core.domain.drift;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.testng.annotations.Test;
+
+import static java.util.Arrays.asList;
+import static org.rhq.core.domain.drift.DriftCategory.FILE_ADDED;
+import static org.rhq.core.domain.drift.DriftCategory.FILE_CHANGED;
+import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.DRIFT;
+import static org.rhq.core.domain.drift.DriftFileStatus.LOADED;
+import static org.rhq.test.AssertUtils.assertCollectionMatchesNoOrder;
+import static org.testng.Assert.assertEquals;
+
+public class SnapshotTest {
+
+ @Test
+ public void addChangeSetWithAddedFile() {
+ int configId = 1;
+
+ FakeDriftChangeSet changeSet = new FakeDriftChangeSet(0, COVERAGE, configId)
+ .add(new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt"));
+
+ Snapshot snapshot = new Snapshot().add(changeSet);
+
+ assertCollectionMatchesNoOrder(changeSet.getDrifts(), snapshot.getEntries(), "Failed to build " +
+ "a snapshot that contains a single change set");
+ assertEquals(snapshot.getVersion(), changeSet.getVersion(), "Snapshot version is wrong");
+ }
+
+ @Test
+ public void addChangeSetsWithAddedFiles() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
+
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("4a5b6c", 1024, LOADED), "/drift/2.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2);
+
+ Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
+
+ assertCollectionMatchesNoOrder(asSet(entry1, entry2), snapshot.getEntries(), "Failed to build snapshot " +
+ "with two change sets and file added in second change set");
+ assertEquals(snapshot.getVersion(), changeSet2.getVersion(), "Snapshot version is wrong");
+ }
+
+ @Test
+ public void replaceFileWithChangedVersion() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
+
+ Drift entry2 = new FakeDrift(FILE_CHANGED, new FakeDriftFile("a1b2c3", 1024, LOADED),
+ new FakeDriftFile("4d5e6f", 1024, LOADED), "/drift/1.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2);
+
+ Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
+
+ assertCollectionMatchesNoOrder(asSet(entry2), snapshot.getEntries(),
+ "Failed to build snapshot with file changed");
+ }
+
+ @Test
+ public void deleteFileThatHasBeenRemoved() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("d1f2a3", 1024, LOADED), "/drift/2.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1).add(entry2);
+
+ Drift entry3 = new FakeDrift(FILE_REMOVED, new FakeDriftFile("a1b2c3", 1024, LOADED), null, "/drift/1.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry3);
+
+ Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
+
+ assertCollectionMatchesNoOrder(asSet(entry2), snapshot.getEntries(),
+ "Failed to build snapshot with a file " +
+ "removed.");
+ }
+
+ @Test
+ public void diffShowsEntriesInLeftAndNotInRight() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
+ Snapshot right = new Snapshot().add(changeSet1);
+
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1).add(entry2);
+ Snapshot left = new Snapshot().add(changeSet1).add(changeSet2);
+
+ DiffReport diff = left.diff(right);
+
+ assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsNotInRight(),
+ "Diff report does not contain " +
+ "elements that are in the left but not in the right.");
+ }
+
+ @Test
+ public void diffShowsEntriesInRightAndNotInLeft() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
+ Snapshot right = new Snapshot().add(changeSet1);
+
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry2);
+ Snapshot left = new Snapshot().add(changeSet2);
+
+ DiffReport diff = left.diff(right);
+
+ assertCollectionMatchesNoOrder(asList(entry1), diff.getElementsNotInLeft(),
+ "Diff report does not contain " +
+ "elements that are in the left but not in the right");
+ }
+
+ @Test
+ public void diffShowsEntriesInLeftAndRightThatAreInConflict() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drfit/1.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
+ Snapshot right = new Snapshot().add(changeSet1);
+
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("c3b2a1", 1024, LOADED), "/drfit/1.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2);
+ Snapshot left = new Snapshot().add(changeSet2);
+
+ DiffReport diff = left.diff(right);
+
+ assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsInConflict(),
+ "Diff report does not contain " +
+ "element that are in both left and right and are in conflict");
+ }
+
+ <E> Set<E> asSet(E... elements) {
+ HashSet<E> set = new HashSet<E>();
+ for (E element : elements) {
+ set.add(element);
+ }
+ return set;
+ }
+
+ static class FakeDriftChangeSet implements DriftChangeSet {
+
+ private String id;
+ private int version;
+ private DriftChangeSetCategory category;
+ private int configId;
+ private Set<Drift> drifts = new HashSet<Drift>();
+ private long ctime = System.currentTimeMillis();
+
+ public FakeDriftChangeSet() {
+ }
+
+ public FakeDriftChangeSet(int version, DriftChangeSetCategory category, int configId) {
+ this.version = version;
+ this.category = category;
+ this.configId = configId;
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public Long getCtime() {
+ return ctime;
+ }
+
+ @Override
+ public int getVersion() {
+ return version;
+ }
+
+ @Override
+ public void setVersion(int version) {
+ this.version = version;
+ }
+
+ @Override
+ public DriftChangeSetCategory getCategory() {
+ return category;
+ }
+
+ @Override
+ public void setCategory(DriftChangeSetCategory category) {
+ this.category = category;
+ }
+
+ @Override
+ public int getDriftConfigurationId() {
+ return configId;
+ }
+
+ @Override
+ public void setDriftConfigurationId(int id) {
+ configId = id;
+ }
+
+ @Override
+ public int getResourceId() {
+ return 0;
+ }
+
+ @Override
+ public Set getDrifts() {
+ return drifts;
+ }
+
+ @Override
+ public void setDrifts(Set drifts) {
+ this.drifts = drifts;
+ }
+
+ public FakeDriftChangeSet add(Drift drift) {
+ drifts.add(drift);
+ return this;
+ }
+ }
+
+ static class FakeDrift implements Drift {
+
+ private String id;
+ private DriftCategory category;
+ private String path;
+ private DriftFile oldFile;
+ private DriftFile newFile;
+ private long ctime = System.currentTimeMillis();
+
+ public FakeDrift() {
+ }
+
+ public FakeDrift(DriftCategory category, DriftFile oldFile, DriftFile newFile, String path) {
+ this.category = category;
+ this.oldFile = oldFile;
+ this.newFile = newFile;
+ this.path = path;
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public Long getCtime() {
+ return ctime;
+ }
+
+ @Override
+ public DriftChangeSet getChangeSet() {
+ return null;
+ }
+
+ @Override
+ public void setChangeSet(DriftChangeSet changeSet) {
+
+ }
+
+ @Override
+ public DriftCategory getCategory() {
+ return category;
+ }
+
+ @Override
+ public void setCategory(DriftCategory category) {
+ this.category = category;
+ }
+
+ @Override
+ public String getPath() {
+ return path;
+ }
+
+ @Override
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ @Override
+ public DriftFile getOldDriftFile() {
+ return oldFile;
+ }
+
+ @Override
+ public void setOldDriftFile(DriftFile oldDriftFile) {
+ this.oldFile = oldDriftFile;
+ }
+
+ @Override
+ public DriftFile getNewDriftFile() {
+ return newFile;
+ }
+
+ @Override
+ public void setNewDriftFile(DriftFile newDriftFile) {
+ newFile = newDriftFile;
+ }
+
+ @Override
+ public String toString() {
+ return "Drift[category: " + category.code() + ", oldFile: " + oldFile + ", newFile: " + newFile +
+ ", path: " + path + "]";
+ }
+ }
+
+ static class FakeDriftFile implements DriftFile {
+
+ private String hash;
+ private long size;
+ private DriftFileStatus status;
+ private long ctime = System.currentTimeMillis();
+
+ public FakeDriftFile() {
+ }
+
+ public FakeDriftFile(String hash, long size, DriftFileStatus status) {
+ this.hash = hash;
+ this.size = size;
+ this.status = status;
+ }
+
+ @Override
+ public String getHashId() {
+ return hash;
+ }
+
+ @Override
+ public void setHashId(String hashId) {
+ hash = hashId;
+ }
+
+ @Override
+ public Long getCtime() {
+ return ctime;
+ }
+
+ @Override
+ public Long getDataSize() {
+ return size;
+ }
+
+ @Override
+ public void setDataSize(Long size) {
+ this.size = size;
+ }
+
+ @Override
+ public DriftFileStatus getStatus() {
+ return status;
+ }
+
+ @Override
+ public void setStatus(DriftFileStatus status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ return "DriftFile[hashId: " + hash + ", dataSize: " + size + ", status: " + status.ordinal() + "]";
+ }
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
index f69195d..10f72f5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
@@ -20,13 +20,16 @@ package org.rhq.enterprise.gui.coregui.client.gwt;
import com.google.gwt.user.client.rpc.RemoteService;
+import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.DriftConfiguration;
+import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.util.PageList;
/**
@@ -115,6 +118,8 @@ public interface DriftGWTService extends RemoteService {
PageList<DriftComposite> findDriftCompositesByCriteria(DriftCriteria criteria);
+ Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria);
+
/**
* Get the specified drift configuration for the specified context.
*
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
index 8d5beb9..b440ffd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
@@ -18,13 +18,16 @@
*/
package org.rhq.enterprise.gui.coregui.server.gwt;
+import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.DriftConfiguration;
+import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.gwt.DriftGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
@@ -122,6 +125,15 @@ public class DriftGWTServiceImpl extends AbstractGWTServiceImpl implements Drift
}
@Override
+ public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
+ try {
+ return driftServer.createSnapshot(subject, criteria);
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
+ }
+ }
+
+ @Override
public DriftConfiguration getDriftConfiguration(EntityContext entityContext, int driftConfigId)
throws RuntimeException {
try {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DiffReport.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DiffReport.java
deleted file mode 100644
index 89f3286..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DiffReport.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.rhq.enterprise.server.drift;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class DiffReport<T> {
-
- private List<T> notInLeft = new ArrayList<T>();
-
- private List<T> notInRight = new ArrayList<T>();
-
- private List<T> conflicts = new ArrayList<T>();
-
- public List<T> getElementsNotInLeft() {
- return notInLeft;
- }
-
- public void elementNotInLeft(T element) {
- notInLeft.add(element);
- }
-
- public List<T> getElementsNotInRight() {
- return notInRight;
- }
-
- public void elementNotInRight(T element) {
- notInRight.add(element);
- }
-
- public List<T> getElementsInConflict() {
- return conflicts;
- }
-
- public void elementInConflict(T element) {
- conflicts.add(element);
- }
-
-}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index 4c669e7..54eda95 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@ -71,6 +71,7 @@ import org.rhq.core.domain.drift.DriftFileBits;
import org.rhq.core.domain.drift.DriftFileStatus;
import org.rhq.core.domain.drift.RhqDrift;
import org.rhq.core.domain.drift.RhqDriftChangeSet;
+import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.ZipUtil;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
index 0fb077d..6939c7c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
@@ -33,6 +33,7 @@ import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.drift.RhqDrift;
import org.rhq.core.domain.drift.RhqDriftChangeSet;
import org.rhq.core.domain.drift.RhqDriftFile;
+import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.util.PageList;
@Local
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
index 0dd2aa8..276c8b9 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
@@ -19,11 +19,13 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.DriftConfiguration;
+import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.RHQConstants;
@@ -41,6 +43,13 @@ import static javax.ejb.TransactionAttributeType.NOT_SUPPORTED;
@Stateless
public class DriftServerBean implements DriftServerLocal {
+ // TODO Should security checks be handled here instead of delegating to the drift plugin?
+ // Currently any security checks that need to be performed are delegated to the plugin.
+ // This is fine *so far* since the only plugin is the default which is our existing SLSB
+ // layer backed by the RHQ database. If the plugins are only supposed to be responsible
+ // for persistence management of drift entities and content, then they should not be
+ // responsible for other concerns like security.
+
private Log log = LogFactory.getLog(DriftServerBean.class);
@PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
@@ -87,6 +96,13 @@ public class DriftServerBean implements DriftServerLocal {
driftServerPlugin.saveChangeSetFiles(changeSetFilesZip);
}
+ @Override
+ @TransactionAttribute(NOT_SUPPORTED)
+ public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
+ DriftServerPluginFacet driftServerPlugin = getServerPlugin();
+ return driftServerPlugin.createSnapshot(subject, criteria);
+ }
+
DriftServerPluginFacet getServerPlugin() {
MasterServerPluginContainer masterPC = LookupUtil.getServerPluginService().getMasterPluginContainer();
if (masterPC == null) {
@@ -201,4 +217,5 @@ public class DriftServerBean implements DriftServerLocal {
throw new IllegalArgumentException("Entity Context Type not supported [" + context + "]");
}
}
+
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
index 756f135..5046e83 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
@@ -7,11 +7,13 @@ import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.DriftConfiguration;
+import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.util.PageList;
@Local
@@ -33,4 +35,6 @@ public interface DriftServerLocal {
PageList<DriftComposite> findDriftCompositesByCriteria(Subject subject, DriftCriteria criteria);
+ Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria);
+
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
deleted file mode 100644
index 5dc18fa..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.rhq.enterprise.server.drift;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.DriftChangeSet;
-import org.rhq.core.domain.drift.DriftFile;
-
-import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
-
-public class Snapshot implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private int version;
-
- private Map<String, Drift> entries = new TreeMap<String, Drift>();
-
- public int getVersion() {
- return version;
- }
-
- public Collection<Drift> getEntries() {
- return entries.values();
- }
-
- public <D extends Drift> Snapshot add(DriftChangeSet<D> changeSet) {
- for (Drift entry : changeSet.getDrifts()) {
- entries.remove(entry.getPath());
- if (entry.getCategory() != FILE_REMOVED) {
- entries.put(entry.getPath(), entry);
- }
- }
- version = changeSet.getVersion();
- return this;
- }
-
- public DiffReport diff(Snapshot right) {
- Snapshot left = this;
- DiffReport<Drift> diff = new DiffReport<Drift>();
-
- for (Map.Entry<String, Drift> entry : left.entries.entrySet()) {
- if (!right.entries.containsKey(entry.getKey())) {
- diff.elementNotInRight(entry.getValue());
- }
- }
-
- for (Map.Entry<String, Drift> entry : right.entries.entrySet()) {
- if (!left.entries.containsKey(entry.getKey())) {
- diff.elementNotInLeft(entry.getValue());
- }
- }
-
- for (Map.Entry<String, Drift> entry : left.entries.entrySet()) {
- Drift rightDrift = right.entries.get(entry.getKey());
- if (rightDrift != null) {
- DriftFile leftFile = entry.getValue().getNewDriftFile();
- DriftFile rightFile = rightDrift.getNewDriftFile();
-
- if (!leftFile.getHashId().equals(rightFile.getHashId())) {
- diff.elementInConflict(entry.getValue());
- }
- }
- }
-
- return diff;
- }
-
-}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
index 890d2d8..867464d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
@@ -23,10 +23,12 @@ import java.io.File;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftComposite;
+import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
@@ -47,4 +49,6 @@ public interface DriftServerPluginFacet extends ServerPluginComponent {
void saveChangeSet(int resourceId, File changeSetZip) throws Exception;
void saveChangeSetFiles(File changeSetFilesZip) throws Exception;
+
+ Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria);
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java
deleted file mode 100644
index 47dbb73..0000000
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java
+++ /dev/null
@@ -1,385 +0,0 @@
-package org.rhq.enterprise.server.drift;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.testng.annotations.Test;
-
-import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.DriftCategory;
-import org.rhq.core.domain.drift.DriftChangeSet;
-import org.rhq.core.domain.drift.DriftChangeSetCategory;
-import org.rhq.core.domain.drift.DriftFile;
-import org.rhq.core.domain.drift.DriftFileStatus;
-
-import static java.util.Arrays.asList;
-import static org.rhq.core.domain.drift.DriftCategory.FILE_ADDED;
-import static org.rhq.core.domain.drift.DriftCategory.FILE_CHANGED;
-import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
-import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
-import static org.rhq.core.domain.drift.DriftChangeSetCategory.DRIFT;
-import static org.rhq.core.domain.drift.DriftFileStatus.LOADED;
-import static org.rhq.test.AssertUtils.assertCollectionMatchesNoOrder;
-import static org.testng.Assert.assertEquals;
-
-public class SnapshotTest {
-
- @Test
- public void addChangeSetWithAddedFile() {
- int configId = 1;
-
- FakeDriftChangeSet changeSet = new FakeDriftChangeSet(0, COVERAGE, configId)
- .add(new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt"));
-
- Snapshot snapshot = new Snapshot().add(changeSet);
-
- assertCollectionMatchesNoOrder(changeSet.getDrifts(), snapshot.getEntries(), "Failed to build " +
- "a snapshot that contains a single change set");
- assertEquals(snapshot.getVersion(), changeSet.getVersion(), "Snapshot version is wrong");
- }
-
- @Test
- public void addChangeSetsWithAddedFiles() {
- int configId = 1;
-
- Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
- FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
-
- Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("4a5b6c", 1024, LOADED), "/drift/2.txt");
- FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2);
-
- Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
-
- assertCollectionMatchesNoOrder(asSet(entry1, entry2), snapshot.getEntries(), "Failed to build snapshot " +
- "with two change sets and file added in second change set");
- assertEquals(snapshot.getVersion(), changeSet2.getVersion(), "Snapshot version is wrong");
- }
-
- @Test
- public void replaceFileWithChangedVersion() {
- int configId = 1;
-
- Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
- FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
-
- Drift entry2 = new FakeDrift(FILE_CHANGED, new FakeDriftFile("a1b2c3", 1024, LOADED),
- new FakeDriftFile("4d5e6f", 1024, LOADED), "/drift/1.txt");
- FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2);
-
- Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
-
- assertCollectionMatchesNoOrder(asSet(entry2), snapshot.getEntries(), "Failed to build snapshot with file changed");
- }
-
- @Test
- public void deleteFileThatHasBeenRemoved() {
- int configId = 1;
-
- Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
- Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("d1f2a3", 1024, LOADED), "/drift/2.txt");
- FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1).add(entry2);
-
- Drift entry3 = new FakeDrift(FILE_REMOVED, new FakeDriftFile("a1b2c3", 1024, LOADED), null, "/drift/1.txt");
- FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry3);
-
- Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
-
- assertCollectionMatchesNoOrder(asSet(entry2), snapshot.getEntries(), "Failed to build snapshot with a file " +
- "removed.");
- }
-
- @Test
- public void diffShowsEntriesInLeftAndNotInRight() {
- int configId = 1;
-
- Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
- FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
- Snapshot right = new Snapshot().add(changeSet1);
-
- Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt");
- FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1).add(entry2);
- Snapshot left = new Snapshot().add(changeSet1).add(changeSet2);
-
- DiffReport diff = left.diff(right);
-
- assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsNotInRight(), "Diff report does not contain " +
- "elements that are in the left but not in the right.");
- }
-
- @Test
- public void diffShowsEntriesInRightAndNotInLeft() {
- int configId = 1;
-
- Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
- FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
- Snapshot right = new Snapshot().add(changeSet1);
-
- Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt");
- FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry2);
- Snapshot left = new Snapshot().add(changeSet2);
-
- DiffReport diff = left.diff(right);
-
- assertCollectionMatchesNoOrder(asList(entry1), diff.getElementsNotInLeft(), "Diff report does not contain " +
- "elements that are in the left but not in the right");
- }
-
- @Test
- public void diffShowsEntriesInLeftAndRightThatAreInConflict() {
- int configId = 1;
-
- Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drfit/1.txt");
- FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
- Snapshot right = new Snapshot().add(changeSet1);
-
- Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("c3b2a1", 1024, LOADED), "/drfit/1.txt");
- FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2);
- Snapshot left = new Snapshot().add(changeSet2);
-
- DiffReport diff = left.diff(right);
-
- assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsInConflict(), "Diff report does not contain " +
- "element that are in both left and right and are in conflict");
- }
-
- <E> Set<E> asSet(E... elements) {
- HashSet<E> set = new HashSet<E>();
- for (E element : elements) {
- set.add(element);
- }
- return set;
- }
-
- static class FakeDriftChangeSet implements DriftChangeSet {
-
- private String id;
- private int version;
- private DriftChangeSetCategory category;
- private int configId;
- private Set<Drift> drifts = new HashSet<Drift>();
- private long ctime = System.currentTimeMillis();
-
- public FakeDriftChangeSet() {
- }
-
- public FakeDriftChangeSet(int version, DriftChangeSetCategory category, int configId) {
- this.version = version;
- this.category = category;
- this.configId = configId;
- }
-
- @Override
- public String getId() {
- return id;
- }
-
- @Override
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public Long getCtime() {
- return ctime;
- }
-
- @Override
- public int getVersion() {
- return version;
- }
-
- @Override
- public void setVersion(int version) {
- this.version = version;
- }
-
- @Override
- public DriftChangeSetCategory getCategory() {
- return category;
- }
-
- @Override
- public void setCategory(DriftChangeSetCategory category) {
- this.category = category;
- }
-
- @Override
- public int getDriftConfigurationId() {
- return configId;
- }
-
- @Override
- public void setDriftConfigurationId(int id) {
- configId = id;
- }
-
- @Override
- public int getResourceId() {
- return 0;
- }
-
- @Override
- public Set getDrifts() {
- return drifts;
- }
-
- @Override
- public void setDrifts(Set drifts) {
- this.drifts = drifts;
- }
-
- public FakeDriftChangeSet add(Drift drift) {
- drifts.add(drift);
- return this;
- }
- }
-
- static class FakeDrift implements Drift {
-
- private String id;
- private DriftCategory category;
- private String path;
- private DriftFile oldFile;
- private DriftFile newFile;
- private long ctime = System.currentTimeMillis();
-
- public FakeDrift() {
- }
-
- public FakeDrift(DriftCategory category, DriftFile oldFile, DriftFile newFile, String path) {
- this.category = category;
- this.oldFile = oldFile;
- this.newFile = newFile;
- this.path = path;
- }
-
- @Override
- public String getId() {
- return id;
- }
-
- @Override
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public Long getCtime() {
- return ctime;
- }
-
- @Override
- public DriftChangeSet getChangeSet() {
- return null;
- }
-
- @Override
- public void setChangeSet(DriftChangeSet changeSet) {
-
- }
-
- @Override
- public DriftCategory getCategory() {
- return category;
- }
-
- @Override
- public void setCategory(DriftCategory category) {
- this.category = category;
- }
-
- @Override
- public String getPath() {
- return path;
- }
-
- @Override
- public void setPath(String path) {
- this.path = path;
- }
-
- @Override
- public DriftFile getOldDriftFile() {
- return oldFile;
- }
-
- @Override
- public void setOldDriftFile(DriftFile oldDriftFile) {
- this.oldFile = oldDriftFile;
- }
-
- @Override
- public DriftFile getNewDriftFile() {
- return newFile;
- }
-
- @Override
- public void setNewDriftFile(DriftFile newDriftFile) {
- newFile = newDriftFile;
- }
-
- @Override
- public String toString() {
- return "Drift[category: " + category.code() + ", oldFile: " + oldFile + ", newFile: " + newFile +
- ", path: " + path + "]";
- }
- }
-
- static class FakeDriftFile implements DriftFile {
-
- private String hash;
- private long size;
- private DriftFileStatus status;
- private long ctime = System.currentTimeMillis();
-
- public FakeDriftFile() {
- }
-
- public FakeDriftFile(String hash, long size, DriftFileStatus status) {
- this.hash = hash;
- this.size = size;
- this.status = status;
- }
-
- @Override
- public String getHashId() {
- return hash;
- }
-
- @Override
- public void setHashId(String hashId) {
- hash = hashId;
- }
-
- @Override
- public Long getCtime() {
- return ctime;
- }
-
- @Override
- public Long getDataSize() {
- return size;
- }
-
- @Override
- public void setDataSize(Long size) {
- this.size = size;
- }
-
- @Override
- public DriftFileStatus getStatus() {
- return status;
- }
-
- @Override
- public void setStatus(DriftFileStatus status) {
- this.status = status;
- }
-
- @Override
- public String toString() {
- return "DriftFile[hashId: " + hash + ", dataSize: " + size + ", status: " + status.ordinal() + "]";
- }
- }
-
-}
diff --git a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
index 456c4a5..8d4cae4 100644
--- a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
@@ -33,6 +33,7 @@ import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftComposite;
+import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.drift.DriftManagerLocal;
import org.rhq.enterprise.server.plugin.pc.ServerPluginContext;
@@ -107,6 +108,12 @@ public class DriftServerPluginComponent implements DriftServerPluginFacet {
driftMgr.storeFiles(changeSetFilesZip);
}
+ @Override
+ public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
+ DriftManagerLocal driftMgr = getDriftManager();
+ return driftMgr.createSnapshot(subject, criteria);
+ }
+
private DriftJPACriteria toJPACriteria(DriftCriteria criteria) {
DriftJPACriteria jpaCriteria = new DriftJPACriteria();
jpaCriteria.addFilterId(criteria.getFilterId());
commit e0cdb9af1df636bcf0949da9a7a3eace650f7cb3
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat Jul 23 22:57:09 2011 -0400
First cut at createSnapshot method in DriftManagerBean
Also refactoring tests in server/jar to use the JPAUtils class for
resetting the db.
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
index c03e3e6..bc8d26a 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
@@ -38,24 +38,6 @@ public class RhqDriftChangeSetTest extends AbstractEJB3Test {
resource.setDriftConfigurations(driftConfigs);
-// executeInTransaction(new TransactionCallback() {
-// @Override
-// public void execute() throws Exception {
-// getEntityManager().createQuery("delete from RhqDriftChangeSet").executeUpdate();
-//
-// // Cascading deletes for Resource.driftConfigurations does not work, nor does it
-// // appear the orphan deletes work either. I came across https://hibernate.onjira.com/browse/HHH-1917
-// // and https://hibernate.onjira.com/browse/HHH-1917 which led me to using
-// // native SQL to perform the delete on the join table rhq_drift_config_map.
-// //
-// // jsanda
-// getEntityManager().createNativeQuery("delete from rhq_drift_config_map").executeUpdate();
-//
-// getEntityManager().createQuery("delete from Resource").executeUpdate();
-// getEntityManager().createQuery("delete from ResourceType").executeUpdate();
-// }
-// });
-
executeInTransaction(new TransactionCallback() {
@Override
public void execute() throws Exception {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index 65a6a55..4c669e7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@ -581,4 +581,17 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
throw new IllegalArgumentException("Entity Context Type not supported [" + context + "]");
}
}
+
+ @Override
+ public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
+ // TODO security checks
+ Snapshot snapshot = new Snapshot();
+ PageList<RhqDriftChangeSet> changeSets = findDriftChangeSetsByCriteria(subject, criteria);
+
+ for (RhqDriftChangeSet changeSet : changeSets) {
+ snapshot.add(changeSet);
+ }
+
+ return snapshot;
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
index 4a30952..0fb077d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
@@ -177,7 +177,7 @@ public interface DriftManagerLocal extends DriftManagerRemote {
* @return
* @throws Exception
*/
- public RhqDriftFile persistDriftFile(RhqDriftFile driftFile) throws Exception;
+ RhqDriftFile persistDriftFile(RhqDriftFile driftFile) throws Exception;
/**
* SUPPORTS DRIFT RHQ SERVER PLUGIN
@@ -185,6 +185,8 @@ public interface DriftManagerLocal extends DriftManagerRemote {
* @param data
* @throws Exception
*/
- public void persistDriftFileData(RhqDriftFile driftFile, InputStream data) throws Exception;
+ void persistDriftFileData(RhqDriftFile driftFile, InputStream data) throws Exception;
+
+ Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria);
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java
index f1934d7..7ffacbf 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java
@@ -1,7 +1,5 @@
package org.rhq.enterprise.server.resource.metadata;
-import static org.rhq.core.clientapi.shared.PluginDescriptorUtil.loadPluginDescriptor;
-
import java.io.File;
import java.net.URL;
import java.sql.Connection;
@@ -39,10 +37,17 @@ import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
+import static org.rhq.core.clientapi.shared.PluginDescriptorUtil.loadPluginDescriptor;
+
public class MetadataBeanTest extends AbstractEJB3Test {
private static List<String> plugins = new ArrayList<String>();
+ @Override
+ protected boolean isDBResetNeeded() {
+ return false;
+ }
+
@BeforeGroups(groups = { "plugin.metadata" }, dependsOnGroups = { "integration.ejb3" })
public void startMBeanServer() throws Exception {
setupDB();
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
index ee2a45f..5ed329f 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
@@ -28,7 +28,6 @@ import javax.management.MBeanServerFactory;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
import javax.transaction.TransactionManager;
import org.hibernate.SessionFactory;
@@ -36,6 +35,7 @@ import org.hibernate.stat.Statistics;
import org.testng.AssertJUnit;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
@@ -57,12 +57,28 @@ import org.rhq.enterprise.server.scheduler.SchedulerService;
import org.rhq.enterprise.server.scheduler.SchedulerServiceMBean;
import org.rhq.enterprise.server.util.LookupUtil;
+import static org.rhq.test.JPAUtils.clearDB;
+import static org.rhq.test.JPAUtils.lookupEntityManager;
+import static org.rhq.test.JPAUtils.lookupTransactionManager;
+
/**
* This is the abstract test base for server jar tests.
*
* @author Greg Hinkle
*/
public abstract class AbstractEJB3Test extends AssertJUnit {
+
+ @BeforeClass
+ public void resetDB() throws Exception {
+ if (isDBResetNeeded()) {
+ clearDB();
+ }
+ }
+
+ protected boolean isDBResetNeeded() {
+ return true;
+ }
+
//@BeforeSuite(groups = {"integration.ejb3","PERF"}) // TODO investigate again
@BeforeSuite(alwaysRun = true)
public static void startupEmbeddedJboss() throws Exception {
@@ -165,23 +181,11 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
private static Statistics stats;
public TransactionManager getTransactionManager() {
- try {
- tm = (TransactionManager) getInitialContext().lookup("java:/TransactionManager");
- return tm;
- } catch (NamingException e) {
- e.printStackTrace();
- throw new RuntimeException("Failed to load transaction manager", e);
- }
+ return lookupTransactionManager();
}
public static EntityManager getEntityManager() {
- try {
- return ((EntityManagerFactory) getInitialContext().lookup(RHQConstants.ENTITY_MANAGER_JNDI_NAME))
- .createEntityManager();
- } catch (NamingException e) {
- e.printStackTrace();
- throw new RuntimeException("Failed to load entity manager", e);
- }
+ return lookupEntityManager();
}
public static InitialContext getInitialContext() {
commit 20105a1abca72db2ef548f9b0a0e6a097a73024e
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat Jul 23 21:38:07 2011 -0400
Initial commit for JPAUtils
Refactoring some methods in AbstractEJB3Test to delegate to JPAUtils
with the intent to eliminate duplicate code in core/domain and
server/jar tests. Most importantly though, the method clearDB is now
part of JPAUtils making it accessible to any test. This provides a much
more robust way of resetting the entire database to a known, consistent
state.
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
index c9e61ef..c03e3e6 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
@@ -3,10 +3,6 @@ package org.rhq.core.domain.drift;
import java.util.HashSet;
import java.util.Set;
-import javax.persistence.EntityManager;
-import javax.transaction.SystemException;
-
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -16,6 +12,7 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.shared.ResourceBuilder;
import org.rhq.core.domain.test.AbstractEJB3Test;
+import org.rhq.test.TransactionCallback;
import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java b/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
index aa6e0e0..dc5319a 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
@@ -30,8 +30,6 @@ import java.util.Hashtable;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
import org.testng.AssertJUnit;
@@ -42,6 +40,13 @@ import org.testng.annotations.BeforeSuite;
import org.jboss.ejb3.embedded.EJB3StandaloneBootstrap;
import org.jboss.ejb3.embedded.EJB3StandaloneDeployer;
+import org.rhq.test.JPAUtils;
+import org.rhq.test.TransactionCallback;
+
+import static org.rhq.test.JPAUtils.clearDB;
+import static org.rhq.test.JPAUtils.lookupEntityManager;
+import static org.rhq.test.JPAUtils.lookupTransactionManager;
+
public abstract class AbstractEJB3Test extends AssertJUnit {
@BeforeClass
@@ -96,26 +101,12 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
EJB3StandaloneBootstrap.shutdown();
}
- private TransactionManager tm;
-
public TransactionManager getTransactionManager() {
- try {
- tm = (TransactionManager) getInitialContext().lookup("java:/TransactionManager");
- return tm;
- } catch (NamingException e) {
- e.printStackTrace();
- throw new RuntimeException("Failed to load transaction manager", e);
- }
+ return lookupTransactionManager();
}
public EntityManager getEntityManager() {
- try {
- return ((EntityManagerFactory) getInitialContext().lookup("java:/RHQEntityManagerFactory"))
- .createEntityManager();
- } catch (NamingException e) {
- e.printStackTrace();
- throw new RuntimeException("Failed to load entity manager", e);
- }
+ return lookupEntityManager();
}
public boolean isPostgres(EntityManager em) throws Exception {
@@ -148,171 +139,7 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
}
protected void executeInTransaction(TransactionCallback callback) {
- try {
- getTransactionManager().begin();
- callback.execute();
- getTransactionManager().commit();
- } catch (Throwable t) {
- try {
- getTransactionManager().rollback();
- } catch (SystemException e) {
- throw new RuntimeException("Failed to rollback transaction", e);
- }
- throw new RuntimeException(t.getCause());
- }
+ JPAUtils.executeInTransaction(callback);
}
- void clearDB() throws Exception {
- executeInTransaction(new TransactionCallback() {
- @Override
- public void execute() throws Exception {
- EntityManager em = getEntityManager();
-
- em.createNativeQuery("delete from jms_subscriptions");
- em.createNativeQuery("delete from jms_roles");
- em.createNativeQuery("delete from jms_users");
- em.createNativeQuery("delete from jms_transactions");
- em.createNativeQuery("delete from jms_messages");
- em.createNativeQuery("delete from rhq_drift_config_map");
- em.createNativeQuery("delete from rhq_drift_template_map");
- em.createNativeQuery("delete from rhq_delete_res_hist");
- em.createNativeQuery("delete from rhq_create_res_hist");
- em.createNativeQuery("delete from rhq_tagging_bundle_dest_map");
- em.createNativeQuery("delete from rhq_tagging_bundle_deploy_map");
- em.createNativeQuery("delete from rhq_tagging_bundle_version_map");
- em.createNativeQuery("delete from rhq_tagging_bundle_map");
- em.createNativeQuery("delete from rhq_bundle_res_dep_hist");
- em.createNativeQuery("delete from rhq_bundle_res_deploy");
- em.createNativeQuery("delete from rhq_bundle_deployment");
- em.createNativeQuery("delete from rhq_bundle_destination");
- em.createNativeQuery("delete from rhq_bundle_file");
- em.createNativeQuery("delete from rhq_bundle_version_repo");
- em.createNativeQuery("delete from rhq_bundle_version");
- em.createNativeQuery("delete from rhq_bundle");
- em.createNativeQuery("delete from rhq_bundle_type");
- em.createNativeQuery("delete from rhq_repo_advisory");
- em.createNativeQuery("delete from rhq_advisory_buglist");
- em.createNativeQuery("delete from rhq_advisory_cve");
- em.createNativeQuery("delete from rhq_cve");
- em.createNativeQuery("delete from rhq_advisory_package");
- em.createNativeQuery("delete from rhq_advisory");
- em.createNativeQuery("delete from rhq_distribution_file");
- em.createNativeQuery("delete from rhq_repo_distribution");
- em.createNativeQuery("delete from rhq_distribution where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_pkg_prd_map");
- em.createNativeQuery("delete from rhq_pkg_ver_content_src_map");
- em.createNativeQuery("delete from rhq_repo_pkg_version_map");
- em.createNativeQuery("delete from rhq_repo_repo_relation_map");
- em.createNativeQuery("delete from rhq_repo_repo_group_map");
- em.createNativeQuery("delete from rhq_repo_content_src_map");
- em.createNativeQuery("delete from rhq_repo_resource_map");
- em.createNativeQuery("delete from rhq_package_inst_step");
- em.createNativeQuery("delete from rhq_repo_sync");
- em.createNativeQuery("delete from rhq_content_src_sync");
- em.createNativeQuery("delete from rhq_installed_pkg_hist");
- em.createNativeQuery("delete from rhq_installed_package");
- em.createNativeQuery("delete from rhq_content_req");
- em.createNativeQuery("delete from rhq_package_version");
- em.createNativeQuery("delete from rhq_package_bits");
- em.createNativeQuery("delete from rhq_package");
- em.createNativeQuery("delete from rhq_package_type");
- em.createNativeQuery("delete from rhq_repo_relation");
- em.createNativeQuery("delete from rhq_repo_relation_type where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_repo");
- em.createNativeQuery("delete from rhq_repo_group");
- em.createNativeQuery("delete from rhq_repo_group_type where id <> 1");
- em.createNativeQuery("delete from rhq_archirtecture where id < 1 and id > 38");
- em.createNativeQuery("delete from rhq_meas_data_num_r14");
- em.createNativeQuery("delete from rhq_meas_data_num_r13");
- em.createNativeQuery("delete from rhq_meas_data_num_r12");
- em.createNativeQuery("delete from rhq_meas_data_num_r11");
- em.createNativeQuery("delete from rhq_meas_data_num_r10");
- em.createNativeQuery("delete from rhq_meas_data_num_r09");
- em.createNativeQuery("delete from rhq_meas_data_num_r08");
- em.createNativeQuery("delete from rhq_meas_data_num_r07");
- em.createNativeQuery("delete from rhq_meas_data_num_r06");
- em.createNativeQuery("delete from rhq_meas_data_num_r05");
- em.createNativeQuery("delete from rhq_meas_data_num_r04");
- em.createNativeQuery("delete from rhq_meas_data_num_r03");
- em.createNativeQuery("delete from rhq_meas_data_num_r02");
- em.createNativeQuery("delete from rhq_meas_data_num_r01");
- em.createNativeQuery("delete from rhq_meas_data_num_r00");
- em.createNativeQuery("delete from rhq_measurement_oob_tmp");
- em.createNativeQuery("delete rhq_measurement_oob");
- em.createNativeQuery("delete rhq_resource_avail");
- em.createNativeQuery("delete from rhq_availability");
- em.createNativeQuery("delete from rhq_calltime_data_value");
- em.createNativeQuery("delete from rhq_calltime_data_key");
- em.createNativeQuery("delete from rhq_measurement_data_trait");
- em.createNativeQuery("delete from rhq_measurement_data_num_1d");
- em.createNativeQuery("delete from rhq_measurement_data_num_6h");
- em.createNativeQuery("delete from rhq_measurement_data_num_1h");
- em.createNativeQuery("delete from rhq_measurement_bline");
- em.createNativeQuery("delete from rhq_measurement_sched");
- em.createNativeQuery("delete from rhq_measurement_def");
- em.createNativeQuery("delete from rhq_plugin");
- em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56)");
- em.createNativeQuery("delete from rhq_alert_notification");
- em.createNativeQuery("delete from rhq_alert_condition_log");
- em.createNativeQuery("delete from rhq_alert");
- em.createNativeQuery("delete from rhq_alert_condition");
- em.createNativeQuery("delete from rhq_alert_dampen_event");
- em.createNativeQuery("delete from rhq_alert_definition");
- em.createNativeQuery("delete from rhq_event");
- em.createNativeQuery("delete from rhq_event_source");
- em.createNativeQuery("delete from rhq_event_def");
- em.createNativeQuery("delete from rhq_operation_schedule");
- em.createNativeQuery("delete from rhq_operation_history");
- em.createNativeQuery("delete from rhq_operation_def");
- em.createNativeQuery("delete from rhq_dashboard_portlet");
- em.createNativeQuery("delete from rhq_dashboard");
- em.createNativeQuery("delete from rhq_saved_search");
- em.createNativeQuery("delete from rhq_subject_role_ldap_map");
- em.createNativeQuery("delete from rhq_subject_role_map where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_permission where role_id not in (1, 2)");
- em.createNativeQuery("delete from rhq_role_ldap_group");
- em.createNativeQuery("delete from rhq_role_resource_group_map");
- em.createNativeQuery("delete from rhq_role where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_tagging_res_group_map");
- em.createNativeQuery("delete from rhq_tagging_resource_map");
- em.createNativeQuery("delete from rhq_tagging");
- em.createNativeQuery("delete from rhq_config_update");
- em.createNativeQuery("delete from rhq_config_group_update");
- em.createNativeQuery("delete from rhq_resource_group_res_exp_map");
- em.createNativeQuery("delete from rhq_resource_group_res_imp_map");
- em.createNativeQuery("delete from rhq_resource_group");
- em.createNativeQuery("delete from rhq_group_def");
- em.createNativeQuery("delete from rhq_resource_error");
- em.createNativeQuery("delete from rhq_resource");
- em.createNativeQuery("delete from rhq_prd_ver");
- em.createNativeQuery("delete from rhq_process_scan");
- em.createNativeQuery("delete from rhq_resource_type_parents");
- em.createNativeQuery("delete from rhq_resource_subcat");
- em.createNativeQuery("delete from rhq_resource_type");
- em.createNativeQuery("delete from rhq_subject where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_principal where id <> 2");
- em.createNativeQuery("delete from rhq_failover_details");
- em.createNativeQuery("delete from rhq_failover_list");
- em.createNativeQuery("delete from rhq_partition_details");
- em.createNativeQuery("delete from rhq_partition_event");
- em.createNativeQuery("delete from rhq_agent");
- em.createNativeQuery("delete from rhq_server");
- em.createNativeQuery("delete from rhq_affinity_group");
- em.createNativeQuery("delete from rhq_raw_config");
- em.createNativeQuery("delete from rhq_config_template");
- em.createNativeQuery("delete from rhq_config_property");
- em.createNativeQuery("delete from rhq_config");
- em.createNativeQuery("delete from rhq_config_prop_constr");
- em.createNativeQuery("delete from rhq_conf_prop_def_enum");
- em.createNativeQuery("delete from rhq_config_pd_osrc");
- em.createNativeQuery("delete from rhq_config_prop_def");
- em.createNativeQuery("delete from rhq_config_prop_grp_def");
- em.createNativeQuery("delete from rhq_config_def");
- }
- });
- }
-
- public static interface TransactionCallback {
- void execute() throws Exception;
- }
}
\ No newline at end of file
diff --git a/modules/test-utils/pom.xml b/modules/test-utils/pom.xml
index 3ed6856..5c6e85c 100644
--- a/modules/test-utils/pom.xml
+++ b/modules/test-utils/pom.xml
@@ -15,6 +15,16 @@
<dependencies>
<dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
diff --git a/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
new file mode 100644
index 0000000..349b84c
--- /dev/null
+++ b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
@@ -0,0 +1,207 @@
+package org.rhq.test;
+
+import java.util.Hashtable;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
+
+public class JPAUtils {
+
+ public static InitialContext getInitialContext() {
+ Hashtable<String, String> env = new Hashtable<String, String>();
+ env.put("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
+ env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
+ try {
+ return new InitialContext(env);
+ } catch (NamingException e) {
+ throw new RuntimeException("Failed to load initial context", e);
+ }
+ }
+
+ public static EntityManager lookupEntityManager() {
+ try {
+ return ((EntityManagerFactory) getInitialContext().lookup("java:/RHQEntityManagerFactory"))
+ .createEntityManager();
+ } catch (NamingException e) {
+ throw new RuntimeException("Failed to load entity manager", e);
+ }
+ }
+
+ public static TransactionManager lookupTransactionManager() {
+ try {
+ return (TransactionManager) getInitialContext().lookup("java:/TransactionManager");
+ } catch (NamingException e) {
+ throw new RuntimeException("Failed to load transaction manager", e);
+ }
+ }
+
+ public static void executeInTransaction(TransactionCallback callback) {
+ try {
+ lookupTransactionManager().begin();
+ callback.execute();
+ lookupTransactionManager().commit();
+ } catch (Throwable t) {
+ try {
+ lookupTransactionManager().rollback();
+ } catch (SystemException e) {
+ throw new RuntimeException("Failed to rollback transaction", e);
+ }
+ throw new RuntimeException(t.getCause());
+ }
+ }
+
+ public static void clearDB() {
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ EntityManager em = lookupEntityManager();
+
+ em.createNativeQuery("delete from jms_subscriptions");
+ em.createNativeQuery("delete from jms_roles");
+ em.createNativeQuery("delete from jms_users");
+ em.createNativeQuery("delete from jms_transactions");
+ em.createNativeQuery("delete from jms_messages");
+ em.createNativeQuery("delete from rhq_drift_config_map");
+ em.createNativeQuery("delete from rhq_drift_template_map");
+ em.createNativeQuery("delete from rhq_delete_res_hist");
+ em.createNativeQuery("delete from rhq_create_res_hist");
+ em.createNativeQuery("delete from rhq_tagging_bundle_dest_map");
+ em.createNativeQuery("delete from rhq_tagging_bundle_deploy_map");
+ em.createNativeQuery("delete from rhq_tagging_bundle_version_map");
+ em.createNativeQuery("delete from rhq_tagging_bundle_map");
+ em.createNativeQuery("delete from rhq_bundle_res_dep_hist");
+ em.createNativeQuery("delete from rhq_bundle_res_deploy");
+ em.createNativeQuery("delete from rhq_bundle_deployment");
+ em.createNativeQuery("delete from rhq_bundle_destination");
+ em.createNativeQuery("delete from rhq_bundle_file");
+ em.createNativeQuery("delete from rhq_bundle_version_repo");
+ em.createNativeQuery("delete from rhq_bundle_version");
+ em.createNativeQuery("delete from rhq_bundle");
+ em.createNativeQuery("delete from rhq_bundle_type");
+ em.createNativeQuery("delete from rhq_repo_advisory");
+ em.createNativeQuery("delete from rhq_advisory_buglist");
+ em.createNativeQuery("delete from rhq_advisory_cve");
+ em.createNativeQuery("delete from rhq_cve");
+ em.createNativeQuery("delete from rhq_advisory_package");
+ em.createNativeQuery("delete from rhq_advisory");
+ em.createNativeQuery("delete from rhq_distribution_file");
+ em.createNativeQuery("delete from rhq_repo_distribution");
+ em.createNativeQuery("delete from rhq_distribution where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_pkg_prd_map");
+ em.createNativeQuery("delete from rhq_pkg_ver_content_src_map");
+ em.createNativeQuery("delete from rhq_repo_pkg_version_map");
+ em.createNativeQuery("delete from rhq_repo_repo_relation_map");
+ em.createNativeQuery("delete from rhq_repo_repo_group_map");
+ em.createNativeQuery("delete from rhq_repo_content_src_map");
+ em.createNativeQuery("delete from rhq_repo_resource_map");
+ em.createNativeQuery("delete from rhq_package_inst_step");
+ em.createNativeQuery("delete from rhq_repo_sync");
+ em.createNativeQuery("delete from rhq_content_src_sync");
+ em.createNativeQuery("delete from rhq_installed_pkg_hist");
+ em.createNativeQuery("delete from rhq_installed_package");
+ em.createNativeQuery("delete from rhq_content_req");
+ em.createNativeQuery("delete from rhq_package_version");
+ em.createNativeQuery("delete from rhq_package_bits");
+ em.createNativeQuery("delete from rhq_package");
+ em.createNativeQuery("delete from rhq_package_type");
+ em.createNativeQuery("delete from rhq_repo_relation");
+ em.createNativeQuery("delete from rhq_repo_relation_type where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_repo");
+ em.createNativeQuery("delete from rhq_repo_group");
+ em.createNativeQuery("delete from rhq_repo_group_type where id <> 1");
+ em.createNativeQuery("delete from rhq_archirtecture where id < 1 and id > 38");
+ em.createNativeQuery("delete from rhq_meas_data_num_r14");
+ em.createNativeQuery("delete from rhq_meas_data_num_r13");
+ em.createNativeQuery("delete from rhq_meas_data_num_r12");
+ em.createNativeQuery("delete from rhq_meas_data_num_r11");
+ em.createNativeQuery("delete from rhq_meas_data_num_r10");
+ em.createNativeQuery("delete from rhq_meas_data_num_r09");
+ em.createNativeQuery("delete from rhq_meas_data_num_r08");
+ em.createNativeQuery("delete from rhq_meas_data_num_r07");
+ em.createNativeQuery("delete from rhq_meas_data_num_r06");
+ em.createNativeQuery("delete from rhq_meas_data_num_r05");
+ em.createNativeQuery("delete from rhq_meas_data_num_r04");
+ em.createNativeQuery("delete from rhq_meas_data_num_r03");
+ em.createNativeQuery("delete from rhq_meas_data_num_r02");
+ em.createNativeQuery("delete from rhq_meas_data_num_r01");
+ em.createNativeQuery("delete from rhq_meas_data_num_r00");
+ em.createNativeQuery("delete from rhq_measurement_oob_tmp");
+ em.createNativeQuery("delete rhq_measurement_oob");
+ em.createNativeQuery("delete rhq_resource_avail");
+ em.createNativeQuery("delete from rhq_availability");
+ em.createNativeQuery("delete from rhq_calltime_data_value");
+ em.createNativeQuery("delete from rhq_calltime_data_key");
+ em.createNativeQuery("delete from rhq_measurement_data_trait");
+ em.createNativeQuery("delete from rhq_measurement_data_num_1d");
+ em.createNativeQuery("delete from rhq_measurement_data_num_6h");
+ em.createNativeQuery("delete from rhq_measurement_data_num_1h");
+ em.createNativeQuery("delete from rhq_measurement_bline");
+ em.createNativeQuery("delete from rhq_measurement_sched");
+ em.createNativeQuery("delete from rhq_measurement_def");
+ em.createNativeQuery("delete from rhq_plugin");
+ em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56)");
+ em.createNativeQuery("delete from rhq_alert_notification");
+ em.createNativeQuery("delete from rhq_alert_condition_log");
+ em.createNativeQuery("delete from rhq_alert");
+ em.createNativeQuery("delete from rhq_alert_condition");
+ em.createNativeQuery("delete from rhq_alert_dampen_event");
+ em.createNativeQuery("delete from rhq_alert_definition");
+ em.createNativeQuery("delete from rhq_event");
+ em.createNativeQuery("delete from rhq_event_source");
+ em.createNativeQuery("delete from rhq_event_def");
+ em.createNativeQuery("delete from rhq_operation_schedule");
+ em.createNativeQuery("delete from rhq_operation_history");
+ em.createNativeQuery("delete from rhq_operation_def");
+ em.createNativeQuery("delete from rhq_dashboard_portlet");
+ em.createNativeQuery("delete from rhq_dashboard");
+ em.createNativeQuery("delete from rhq_saved_search");
+ em.createNativeQuery("delete from rhq_subject_role_ldap_map");
+ em.createNativeQuery("delete from rhq_subject_role_map where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_permission where role_id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_role_ldap_group");
+ em.createNativeQuery("delete from rhq_role_resource_group_map");
+ em.createNativeQuery("delete from rhq_role where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_tagging_res_group_map");
+ em.createNativeQuery("delete from rhq_tagging_resource_map");
+ em.createNativeQuery("delete from rhq_tagging");
+ em.createNativeQuery("delete from rhq_config_update");
+ em.createNativeQuery("delete from rhq_config_group_update");
+ em.createNativeQuery("delete from rhq_resource_group_res_exp_map");
+ em.createNativeQuery("delete from rhq_resource_group_res_imp_map");
+ em.createNativeQuery("delete from rhq_resource_group");
+ em.createNativeQuery("delete from rhq_group_def");
+ em.createNativeQuery("delete from rhq_resource_error");
+ em.createNativeQuery("delete from rhq_resource");
+ em.createNativeQuery("delete from rhq_prd_ver");
+ em.createNativeQuery("delete from rhq_process_scan");
+ em.createNativeQuery("delete from rhq_resource_type_parents");
+ em.createNativeQuery("delete from rhq_resource_subcat");
+ em.createNativeQuery("delete from rhq_resource_type");
+ em.createNativeQuery("delete from rhq_subject where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_principal where id <> 2");
+ em.createNativeQuery("delete from rhq_failover_details");
+ em.createNativeQuery("delete from rhq_failover_list");
+ em.createNativeQuery("delete from rhq_partition_details");
+ em.createNativeQuery("delete from rhq_partition_event");
+ em.createNativeQuery("delete from rhq_agent");
+ em.createNativeQuery("delete from rhq_server");
+ em.createNativeQuery("delete from rhq_affinity_group");
+ em.createNativeQuery("delete from rhq_raw_config");
+ em.createNativeQuery("delete from rhq_config_template");
+ em.createNativeQuery("delete from rhq_config_property");
+ em.createNativeQuery("delete from rhq_config");
+ em.createNativeQuery("delete from rhq_config_prop_constr");
+ em.createNativeQuery("delete from rhq_conf_prop_def_enum");
+ em.createNativeQuery("delete from rhq_config_pd_osrc");
+ em.createNativeQuery("delete from rhq_config_prop_def");
+ em.createNativeQuery("delete from rhq_config_prop_grp_def");
+ em.createNativeQuery("delete from rhq_config_def");
+ }
+ });
+ }
+
+}
diff --git a/modules/test-utils/src/main/java/org/rhq/test/TransactionCallback.java b/modules/test-utils/src/main/java/org/rhq/test/TransactionCallback.java
new file mode 100644
index 0000000..711df43
--- /dev/null
+++ b/modules/test-utils/src/main/java/org/rhq/test/TransactionCallback.java
@@ -0,0 +1,7 @@
+package org.rhq.test;
+
+public interface TransactionCallback {
+
+ void execute() throws Exception;
+
+}
commit b8cf92971d297313e8853a73aa537fddf6742e57
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat Jul 23 07:09:35 2011 -0400
Adding support for version and date ranges in DriftChangeSetCriteria
Version and/or date ranges are needed in order to fetch multiple change
sets to build a snapshot. This commit also includes new set up code in
the base test class AbstractEJB3Test. It clears all database tables
which should be more robust than the approach taken with dbunit.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
index 6ba63df..1b3effc 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
@@ -15,6 +15,22 @@ public interface DriftChangeSetCriteria extends Serializable {
String getFilterVersion();
+ void addFilterStartVersion(String filterStartVersion);
+
+ String getFilterStartVersion();
+
+ void addFilterEndVersion(String filterEndVersion);
+
+ String getFilterEndVersion();
+
+ void addFilterCreatedAfter(Long filterCreatedAfter);
+
+ Long getFilterCreatedAfter();
+
+ void addFilterCreatedBefore(Long filterCreatedBefore);
+
+ Long getFilterCreatedBefore();
+
void addFilterResourceId(Integer filterResourceId);
Integer getFilterResourceId();
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
index 9b39cc3..6c17877 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
@@ -40,6 +40,10 @@ public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSe
private Integer filterInitial; // needs override
private Integer filterResourceId; // needs override
private String filterVersion;
+ private String filterStartVersion;
+ private String filterEndVersion;
+ private Long filterCreatedAfter;
+ private Long filterCreatedBefore;
private DriftChangeSetCategory filterCategory;
private boolean fetchDrifts;
@@ -48,6 +52,10 @@ public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSe
public DriftChangeSetJPACriteria() {
filterOverrides.put("initial", "version = 0");
filterOverrides.put("resourceId", "resource.id = ?");
+ filterOverrides.put("filterStartVersion", "version >= ?");
+ filterOverrides.put("filterEndVersion", "version <= ?");
+ filterOverrides.put("filterCreatedAfter", "ctime >= ?");
+ filterOverrides.put("filterCreatedBefore", "ctime <= ?");
}
@Override
@@ -75,6 +83,46 @@ public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSe
return filterVersion;
}
+ @Override
+ public void addFilterStartVersion(String filterStartVersion) {
+ this.filterStartVersion = filterStartVersion;
+ }
+
+ @Override
+ public String getFilterStartVersion() {
+ return filterStartVersion;
+ }
+
+ @Override
+ public void addFilterEndVersion(String filterEndVersion) {
+ this.filterEndVersion = filterEndVersion;
+ }
+
+ @Override
+ public String getFilterEndVersion() {
+ return filterEndVersion;
+ }
+
+ @Override
+ public void addFilterCreatedAfter(Long filterCreatedAfter) {
+ this.filterCreatedAfter = filterCreatedAfter;
+ }
+
+ @Override
+ public Long getFilterCreatedAfter() {
+ return filterCreatedAfter;
+ }
+
+ @Override
+ public void addFilterCreatedBefore(Long filterCreatedBefore) {
+ this.filterCreatedBefore = filterCreatedBefore;
+ }
+
+ @Override
+ public Long getFilterCreatedBefore() {
+ return filterCreatedBefore;
+ }
+
public void addFilterResourceId(Integer filterResourceId) {
this.filterResourceId = filterResourceId;
}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
index abc300d..c9e61ef 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
@@ -1,11 +1,12 @@
package org.rhq.core.domain.drift;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
+import javax.persistence.EntityManager;
import javax.transaction.SystemException;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -20,10 +21,6 @@ import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
public class RhqDriftChangeSetTest extends AbstractEJB3Test {
- static interface TransactionCallback {
- void execute() throws Exception;
- }
-
Resource resource;
DriftConfiguration driftConfig;
@@ -44,23 +41,23 @@ public class RhqDriftChangeSetTest extends AbstractEJB3Test {
resource.setDriftConfigurations(driftConfigs);
- executeInTransaction(new TransactionCallback() {
- @Override
- public void execute() throws Exception {
- getEntityManager().createQuery("delete from RhqDriftChangeSet").executeUpdate();
-
- // Cascading deletes for Resource.driftConfigurations does not work, nor does it
- // appear the orphan deletes work either. I came across https://hibernate.onjira.com/browse/HHH-1917
- // and https://hibernate.onjira.com/browse/HHH-1917 which led me to using
- // native SQL to perform the delete on the join table rhq_drift_config_map.
- //
- // jsanda
- getEntityManager().createNativeQuery("delete from rhq_drift_config_map").executeUpdate();
-
- getEntityManager().createQuery("delete from Resource").executeUpdate();
- getEntityManager().createQuery("delete from ResourceType").executeUpdate();
- }
- });
+// executeInTransaction(new TransactionCallback() {
+// @Override
+// public void execute() throws Exception {
+// getEntityManager().createQuery("delete from RhqDriftChangeSet").executeUpdate();
+//
+// // Cascading deletes for Resource.driftConfigurations does not work, nor does it
+// // appear the orphan deletes work either. I came across https://hibernate.onjira.com/browse/HHH-1917
+// // and https://hibernate.onjira.com/browse/HHH-1917 which led me to using
+// // native SQL to perform the delete on the join table rhq_drift_config_map.
+// //
+// // jsanda
+// getEntityManager().createNativeQuery("delete from rhq_drift_config_map").executeUpdate();
+//
+// getEntityManager().createQuery("delete from Resource").executeUpdate();
+// getEntityManager().createQuery("delete from ResourceType").executeUpdate();
+// }
+// });
executeInTransaction(new TransactionCallback() {
@Override
@@ -115,19 +112,4 @@ public class RhqDriftChangeSetTest extends AbstractEJB3Test {
});
}
- void executeInTransaction(TransactionCallback callback) {
- try {
- getTransactionManager().begin();
- callback.execute();
- getTransactionManager().commit();
- } catch (Throwable t) {
- try {
- getTransactionManager().rollback();
- } catch (SystemException e) {
- throw new RuntimeException("Failed to rollback transaction", e);
- }
- throw new RuntimeException(t.getCause());
- }
- }
-
}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java b/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
index 57ec318..aa6e0e0 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
@@ -31,20 +31,26 @@ import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
+import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
import org.testng.AssertJUnit;
import org.testng.annotations.AfterGroups;
-import org.testng.annotations.AfterSuite;
-import org.testng.annotations.BeforeGroups;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeSuite;
import org.jboss.ejb3.embedded.EJB3StandaloneBootstrap;
import org.jboss.ejb3.embedded.EJB3StandaloneDeployer;
public abstract class AbstractEJB3Test extends AssertJUnit {
-// @BeforeSuite(groups = "integration.ejb3")
- @BeforeGroups(groups = "integration.ejb3")
+
+ @BeforeClass
+ public void resetDB() throws Exception {
+ clearDB();
+ }
+
+ @BeforeSuite(groups = "integration.ejb3")
+ //@BeforeGroups(groups = "integration.ejb3")
public static void startupEmbeddedJboss() {
System.out.println("Starting ejb3...");
String classesDir = System.getProperty("ejbjarDirectory", "target/classes");
@@ -140,4 +146,173 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
referenceTime += offset;
return new Date(referenceTime);
}
+
+ protected void executeInTransaction(TransactionCallback callback) {
+ try {
+ getTransactionManager().begin();
+ callback.execute();
+ getTransactionManager().commit();
+ } catch (Throwable t) {
+ try {
+ getTransactionManager().rollback();
+ } catch (SystemException e) {
+ throw new RuntimeException("Failed to rollback transaction", e);
+ }
+ throw new RuntimeException(t.getCause());
+ }
+ }
+
+ void clearDB() throws Exception {
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ EntityManager em = getEntityManager();
+
+ em.createNativeQuery("delete from jms_subscriptions");
+ em.createNativeQuery("delete from jms_roles");
+ em.createNativeQuery("delete from jms_users");
+ em.createNativeQuery("delete from jms_transactions");
+ em.createNativeQuery("delete from jms_messages");
+ em.createNativeQuery("delete from rhq_drift_config_map");
+ em.createNativeQuery("delete from rhq_drift_template_map");
+ em.createNativeQuery("delete from rhq_delete_res_hist");
+ em.createNativeQuery("delete from rhq_create_res_hist");
+ em.createNativeQuery("delete from rhq_tagging_bundle_dest_map");
+ em.createNativeQuery("delete from rhq_tagging_bundle_deploy_map");
+ em.createNativeQuery("delete from rhq_tagging_bundle_version_map");
+ em.createNativeQuery("delete from rhq_tagging_bundle_map");
+ em.createNativeQuery("delete from rhq_bundle_res_dep_hist");
+ em.createNativeQuery("delete from rhq_bundle_res_deploy");
+ em.createNativeQuery("delete from rhq_bundle_deployment");
+ em.createNativeQuery("delete from rhq_bundle_destination");
+ em.createNativeQuery("delete from rhq_bundle_file");
+ em.createNativeQuery("delete from rhq_bundle_version_repo");
+ em.createNativeQuery("delete from rhq_bundle_version");
+ em.createNativeQuery("delete from rhq_bundle");
+ em.createNativeQuery("delete from rhq_bundle_type");
+ em.createNativeQuery("delete from rhq_repo_advisory");
+ em.createNativeQuery("delete from rhq_advisory_buglist");
+ em.createNativeQuery("delete from rhq_advisory_cve");
+ em.createNativeQuery("delete from rhq_cve");
+ em.createNativeQuery("delete from rhq_advisory_package");
+ em.createNativeQuery("delete from rhq_advisory");
+ em.createNativeQuery("delete from rhq_distribution_file");
+ em.createNativeQuery("delete from rhq_repo_distribution");
+ em.createNativeQuery("delete from rhq_distribution where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_pkg_prd_map");
+ em.createNativeQuery("delete from rhq_pkg_ver_content_src_map");
+ em.createNativeQuery("delete from rhq_repo_pkg_version_map");
+ em.createNativeQuery("delete from rhq_repo_repo_relation_map");
+ em.createNativeQuery("delete from rhq_repo_repo_group_map");
+ em.createNativeQuery("delete from rhq_repo_content_src_map");
+ em.createNativeQuery("delete from rhq_repo_resource_map");
+ em.createNativeQuery("delete from rhq_package_inst_step");
+ em.createNativeQuery("delete from rhq_repo_sync");
+ em.createNativeQuery("delete from rhq_content_src_sync");
+ em.createNativeQuery("delete from rhq_installed_pkg_hist");
+ em.createNativeQuery("delete from rhq_installed_package");
+ em.createNativeQuery("delete from rhq_content_req");
+ em.createNativeQuery("delete from rhq_package_version");
+ em.createNativeQuery("delete from rhq_package_bits");
+ em.createNativeQuery("delete from rhq_package");
+ em.createNativeQuery("delete from rhq_package_type");
+ em.createNativeQuery("delete from rhq_repo_relation");
+ em.createNativeQuery("delete from rhq_repo_relation_type where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_repo");
+ em.createNativeQuery("delete from rhq_repo_group");
+ em.createNativeQuery("delete from rhq_repo_group_type where id <> 1");
+ em.createNativeQuery("delete from rhq_archirtecture where id < 1 and id > 38");
+ em.createNativeQuery("delete from rhq_meas_data_num_r14");
+ em.createNativeQuery("delete from rhq_meas_data_num_r13");
+ em.createNativeQuery("delete from rhq_meas_data_num_r12");
+ em.createNativeQuery("delete from rhq_meas_data_num_r11");
+ em.createNativeQuery("delete from rhq_meas_data_num_r10");
+ em.createNativeQuery("delete from rhq_meas_data_num_r09");
+ em.createNativeQuery("delete from rhq_meas_data_num_r08");
+ em.createNativeQuery("delete from rhq_meas_data_num_r07");
+ em.createNativeQuery("delete from rhq_meas_data_num_r06");
+ em.createNativeQuery("delete from rhq_meas_data_num_r05");
+ em.createNativeQuery("delete from rhq_meas_data_num_r04");
+ em.createNativeQuery("delete from rhq_meas_data_num_r03");
+ em.createNativeQuery("delete from rhq_meas_data_num_r02");
+ em.createNativeQuery("delete from rhq_meas_data_num_r01");
+ em.createNativeQuery("delete from rhq_meas_data_num_r00");
+ em.createNativeQuery("delete from rhq_measurement_oob_tmp");
+ em.createNativeQuery("delete rhq_measurement_oob");
+ em.createNativeQuery("delete rhq_resource_avail");
+ em.createNativeQuery("delete from rhq_availability");
+ em.createNativeQuery("delete from rhq_calltime_data_value");
+ em.createNativeQuery("delete from rhq_calltime_data_key");
+ em.createNativeQuery("delete from rhq_measurement_data_trait");
+ em.createNativeQuery("delete from rhq_measurement_data_num_1d");
+ em.createNativeQuery("delete from rhq_measurement_data_num_6h");
+ em.createNativeQuery("delete from rhq_measurement_data_num_1h");
+ em.createNativeQuery("delete from rhq_measurement_bline");
+ em.createNativeQuery("delete from rhq_measurement_sched");
+ em.createNativeQuery("delete from rhq_measurement_def");
+ em.createNativeQuery("delete from rhq_plugin");
+ em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56)");
+ em.createNativeQuery("delete from rhq_alert_notification");
+ em.createNativeQuery("delete from rhq_alert_condition_log");
+ em.createNativeQuery("delete from rhq_alert");
+ em.createNativeQuery("delete from rhq_alert_condition");
+ em.createNativeQuery("delete from rhq_alert_dampen_event");
+ em.createNativeQuery("delete from rhq_alert_definition");
+ em.createNativeQuery("delete from rhq_event");
+ em.createNativeQuery("delete from rhq_event_source");
+ em.createNativeQuery("delete from rhq_event_def");
+ em.createNativeQuery("delete from rhq_operation_schedule");
+ em.createNativeQuery("delete from rhq_operation_history");
+ em.createNativeQuery("delete from rhq_operation_def");
+ em.createNativeQuery("delete from rhq_dashboard_portlet");
+ em.createNativeQuery("delete from rhq_dashboard");
+ em.createNativeQuery("delete from rhq_saved_search");
+ em.createNativeQuery("delete from rhq_subject_role_ldap_map");
+ em.createNativeQuery("delete from rhq_subject_role_map where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_permission where role_id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_role_ldap_group");
+ em.createNativeQuery("delete from rhq_role_resource_group_map");
+ em.createNativeQuery("delete from rhq_role where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_tagging_res_group_map");
+ em.createNativeQuery("delete from rhq_tagging_resource_map");
+ em.createNativeQuery("delete from rhq_tagging");
+ em.createNativeQuery("delete from rhq_config_update");
+ em.createNativeQuery("delete from rhq_config_group_update");
+ em.createNativeQuery("delete from rhq_resource_group_res_exp_map");
+ em.createNativeQuery("delete from rhq_resource_group_res_imp_map");
+ em.createNativeQuery("delete from rhq_resource_group");
+ em.createNativeQuery("delete from rhq_group_def");
+ em.createNativeQuery("delete from rhq_resource_error");
+ em.createNativeQuery("delete from rhq_resource");
+ em.createNativeQuery("delete from rhq_prd_ver");
+ em.createNativeQuery("delete from rhq_process_scan");
+ em.createNativeQuery("delete from rhq_resource_type_parents");
+ em.createNativeQuery("delete from rhq_resource_subcat");
+ em.createNativeQuery("delete from rhq_resource_type");
+ em.createNativeQuery("delete from rhq_subject where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_principal where id <> 2");
+ em.createNativeQuery("delete from rhq_failover_details");
+ em.createNativeQuery("delete from rhq_failover_list");
+ em.createNativeQuery("delete from rhq_partition_details");
+ em.createNativeQuery("delete from rhq_partition_event");
+ em.createNativeQuery("delete from rhq_agent");
+ em.createNativeQuery("delete from rhq_server");
+ em.createNativeQuery("delete from rhq_affinity_group");
+ em.createNativeQuery("delete from rhq_raw_config");
+ em.createNativeQuery("delete from rhq_config_template");
+ em.createNativeQuery("delete from rhq_config_property");
+ em.createNativeQuery("delete from rhq_config");
+ em.createNativeQuery("delete from rhq_config_prop_constr");
+ em.createNativeQuery("delete from rhq_conf_prop_def_enum");
+ em.createNativeQuery("delete from rhq_config_pd_osrc");
+ em.createNativeQuery("delete from rhq_config_prop_def");
+ em.createNativeQuery("delete from rhq_config_prop_grp_def");
+ em.createNativeQuery("delete from rhq_config_def");
+ }
+ });
+ }
+
+ public static interface TransactionCallback {
+ void execute() throws Exception;
+ }
}
\ No newline at end of file
commit ae72c575c529a40462ccb7495252c7a5cff6dbb8
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 22 16:09:08 2011 -0400
stub out the new drift change sets subtab
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
new file mode 100644
index 0000000..f610b8b
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
@@ -0,0 +1,48 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * A view that displays a tree of all change sets and their related drift trails.
+ *
+ * @author John Mazzitelli
+ */
+public class DriftChangeSetsView extends LocatableVLayout {
+
+ private EntityContext context;
+ private boolean hasWriteAccess;
+
+ protected DriftChangeSetsView(String locatorId, String tableTitle, EntityContext context, boolean hasWriteAccess) {
+ super(locatorId);
+ this.context = context;
+ this.hasWriteAccess = hasWriteAccess;
+ }
+
+ public EntityContext getContext() {
+ return context;
+ }
+
+ protected boolean hasWriteAccess() {
+ return this.hasWriteAccess;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsView.java
new file mode 100644
index 0000000..ab54e88
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsView.java
@@ -0,0 +1,40 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+
+/**
+ * @author John Mazzitelli
+ */
+public class ResourceDriftChangeSetsView extends DriftChangeSetsView {
+ public static ResourceDriftChangeSetsView get(String locatorId, ResourceComposite composite) {
+ String tableTitle = MSG.view_drift_changeSets_resourceViewTitle();
+ EntityContext context = EntityContext.forResource(composite.getResource().getId());
+ boolean hasWriteAccess = composite.getResourcePermission().isDrift();
+ return new ResourceDriftChangeSetsView(locatorId, tableTitle, context, hasWriteAccess);
+ }
+
+ private ResourceDriftChangeSetsView(String locatorId, String tableTitle, EntityContext context,
+ boolean hasWriteAccess) {
+ super(locatorId, tableTitle, context, hasWriteAccess);
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index b8031ea..4efc189 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -50,6 +50,7 @@ import org.rhq.enterprise.gui.coregui.client.components.tab.SubTab;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewFactory;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
+import org.rhq.enterprise.gui.coregui.client.drift.ResourceDriftChangeSetsView;
import org.rhq.enterprise.gui.coregui.client.drift.ResourceDriftConfigurationView;
import org.rhq.enterprise.gui.coregui.client.drift.ResourceDriftHistoryView;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -98,6 +99,7 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
public static class DriftSubTab {
public static final String CONFIGURATION = "Configuration";
public static final String HISTORY = "History";
+ public static final String CHANGE_SETS = "ChangeSets";
}
public static class OperationsSubTab {
@@ -143,6 +145,7 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
private SubTab configHistory;
private SubTab eventHistory;
private SubTab driftHistory;
+ private SubTab driftChangeSets;
private SubTab driftConfig;
private SubTab contentDeployed;
private SubTab contentNew;
@@ -242,9 +245,11 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
.view_tabs_common_drift()), "subsystems/drift/Drift_16.png");
this.driftHistory = new SubTab(driftTab.extendLocatorId(DriftSubTab.HISTORY), new ViewName(DriftSubTab.HISTORY,
MSG.view_tabs_common_history()), null);
+ this.driftChangeSets = new SubTab(driftTab.extendLocatorId(DriftSubTab.CHANGE_SETS), new ViewName(
+ DriftSubTab.CHANGE_SETS, MSG.view_drift_changeSets()), null);
this.driftConfig = new SubTab(driftTab.extendLocatorId(DriftSubTab.CONFIGURATION), new ViewName(
DriftSubTab.CONFIGURATION, MSG.view_tabs_common_configuration()), null);
- driftTab.registerSubTabs(driftHistory, driftConfig);
+ driftTab.registerSubTabs(driftHistory, driftChangeSets, driftConfig);
tabs.add(driftTab);
contentTab = new TwoLevelTab(getTabSet().extendLocatorId("Content"), new ViewName("Content", MSG
@@ -521,6 +526,13 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
}
});
+ updateSubTab(this.driftTab, this.driftChangeSets, true, true, new ViewFactory() {
+ @Override
+ public Canvas createView() {
+ return ResourceDriftChangeSetsView.get(driftChangeSets.extendLocatorId("View"), resourceComposite);
+ }
+ });
+
updateSubTab(this.driftTab, this.driftConfig, true, true, new ViewFactory() {
@Override
public Canvas createView() {
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 354e504..c7d6f91 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -1121,6 +1121,8 @@ view_drift_button_detectNow = Detect Now
view_drift_category_fileAdded = File Added
view_drift_category_fileChanged = File Changed
view_drift_category_fileRemoved = File Removed
+view_drift_changeSets = Change Sets
+view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
view_drift_delete_confirm = Delete the selected drift(s)?
view_drift_delete_confirmAll = Delete all drifts from this source?
view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index f117bdf..5fe14aa 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -939,6 +939,8 @@ view_dashboards_title = Dashboard
##view_drift_category_fileAdded = File Added
##view_drift_category_fileChanged = File Changed
##view_drift_category_fileRemoved = File Removed
+##view_drift_changeSets = Change Sets
+##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index f343153..6bce847 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -1104,6 +1104,8 @@ view_dashboards_portlets_refresh_success1 = ããŒãã¬ããã®èªåãªãã¬
view_dashboards_portlets_refresh_success2 = èªåãªãã¬ãã·ã¥ããããŒãã¬ããã®ãªããŒããåæ¢ããŠããŸã
view_dashboards_title = ããã·ã¥ããŒã
##view_drift = Drift
+##view_drift_changeSets = Change Sets
+##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
##view_drift_table_baseDir = Base Directory
##view_drift_table_changeSet = Change Set
##view_drift_table_newFile = New File
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index 516f235..bd2b6fb 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -1139,6 +1139,8 @@ view_dashboards_title = Dashboard~
##view_drift_category_fileAdded = File Added
##view_drift_category_fileChanged = File Changed
##view_drift_category_fileRemoved = File Removed
+##view_drift_changeSets = Change Sets
+##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index bcac425..9fa9115 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -1113,6 +1113,8 @@ view_dashboards_portlets_refresh_success1 = \u6210\u529f\u4fee\u6539portlets\u81
view_dashboards_portlets_refresh_success2 = \u6210\u529f\u505c\u7528portlets\u81ea\u52a8\u5237\u65b0\u7684\u91cd\u8f7d
view_dashboards_title = \u7edf\u8ba1\u8868\u76d8
##view_drift = Drift
+##view_drift_changeSets = Change Sets
+##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
##view_drift_table_baseDir = Base Directory
##view_drift_table_changeSet = Change Set
##view_drift_table_newFile = New File
commit 606ae34fc2e8d3ee88db8ae6904ef4a9cc914053
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 22 13:22:56 2011 -0400
Adding support for generating snapshot diffs
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DiffReport.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DiffReport.java
new file mode 100644
index 0000000..89f3286
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DiffReport.java
@@ -0,0 +1,38 @@
+package org.rhq.enterprise.server.drift;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DiffReport<T> {
+
+ private List<T> notInLeft = new ArrayList<T>();
+
+ private List<T> notInRight = new ArrayList<T>();
+
+ private List<T> conflicts = new ArrayList<T>();
+
+ public List<T> getElementsNotInLeft() {
+ return notInLeft;
+ }
+
+ public void elementNotInLeft(T element) {
+ notInLeft.add(element);
+ }
+
+ public List<T> getElementsNotInRight() {
+ return notInRight;
+ }
+
+ public void elementNotInRight(T element) {
+ notInRight.add(element);
+ }
+
+ public List<T> getElementsInConflict() {
+ return conflicts;
+ }
+
+ public void elementInConflict(T element) {
+ conflicts.add(element);
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
index 2efc8d8..5dc18fa 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
@@ -1,12 +1,13 @@
package org.rhq.enterprise.server.drift;
import java.io.Serializable;
-import java.util.Comparator;
-import java.util.Set;
-import java.util.TreeSet;
+import java.util.Collection;
+import java.util.Map;
+import java.util.TreeMap;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.DriftFile;
import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
@@ -16,30 +17,56 @@ public class Snapshot implements Serializable {
private int version;
- private Set<Drift> entries = new TreeSet<Drift>(new Comparator<Drift>() {
- @Override
- public int compare(Drift d1, Drift d2) {
- return d1.getPath().compareTo(d2.getPath());
- }
- });
+ private Map<String, Drift> entries = new TreeMap<String, Drift>();
public int getVersion() {
return version;
}
- public Set<Drift> getEntries() {
- return entries;
+ public Collection<Drift> getEntries() {
+ return entries.values();
}
public <D extends Drift> Snapshot add(DriftChangeSet<D> changeSet) {
for (Drift entry : changeSet.getDrifts()) {
- entries.remove(entry);
+ entries.remove(entry.getPath());
if (entry.getCategory() != FILE_REMOVED) {
- entries.add(entry);
+ entries.put(entry.getPath(), entry);
}
}
version = changeSet.getVersion();
return this;
}
+ public DiffReport diff(Snapshot right) {
+ Snapshot left = this;
+ DiffReport<Drift> diff = new DiffReport<Drift>();
+
+ for (Map.Entry<String, Drift> entry : left.entries.entrySet()) {
+ if (!right.entries.containsKey(entry.getKey())) {
+ diff.elementNotInRight(entry.getValue());
+ }
+ }
+
+ for (Map.Entry<String, Drift> entry : right.entries.entrySet()) {
+ if (!left.entries.containsKey(entry.getKey())) {
+ diff.elementNotInLeft(entry.getValue());
+ }
+ }
+
+ for (Map.Entry<String, Drift> entry : left.entries.entrySet()) {
+ Drift rightDrift = right.entries.get(entry.getKey());
+ if (rightDrift != null) {
+ DriftFile leftFile = entry.getValue().getNewDriftFile();
+ DriftFile rightFile = rightDrift.getNewDriftFile();
+
+ if (!leftFile.getHashId().equals(rightFile.getHashId())) {
+ diff.elementInConflict(entry.getValue());
+ }
+ }
+ }
+
+ return diff;
+ }
+
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java
index b646b19..47dbb73 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java
@@ -12,6 +12,7 @@ import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftFile;
import org.rhq.core.domain.drift.DriftFileStatus;
+import static java.util.Arrays.asList;
import static org.rhq.core.domain.drift.DriftCategory.FILE_ADDED;
import static org.rhq.core.domain.drift.DriftCategory.FILE_CHANGED;
import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
@@ -87,6 +88,60 @@ public class SnapshotTest {
"removed.");
}
+ @Test
+ public void diffShowsEntriesInLeftAndNotInRight() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
+ Snapshot right = new Snapshot().add(changeSet1);
+
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1).add(entry2);
+ Snapshot left = new Snapshot().add(changeSet1).add(changeSet2);
+
+ DiffReport diff = left.diff(right);
+
+ assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsNotInRight(), "Diff report does not contain " +
+ "elements that are in the left but not in the right.");
+ }
+
+ @Test
+ public void diffShowsEntriesInRightAndNotInLeft() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
+ Snapshot right = new Snapshot().add(changeSet1);
+
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry2);
+ Snapshot left = new Snapshot().add(changeSet2);
+
+ DiffReport diff = left.diff(right);
+
+ assertCollectionMatchesNoOrder(asList(entry1), diff.getElementsNotInLeft(), "Diff report does not contain " +
+ "elements that are in the left but not in the right");
+ }
+
+ @Test
+ public void diffShowsEntriesInLeftAndRightThatAreInConflict() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drfit/1.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
+ Snapshot right = new Snapshot().add(changeSet1);
+
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("c3b2a1", 1024, LOADED), "/drfit/1.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2);
+ Snapshot left = new Snapshot().add(changeSet2);
+
+ DiffReport diff = left.diff(right);
+
+ assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsInConflict(), "Diff report does not contain " +
+ "element that are in both left and right and are in conflict");
+ }
+
<E> Set<E> asSet(E... elements) {
HashSet<E> set = new HashSet<E>();
for (E element : elements) {
commit 8736df77b8eb3ff47484c6b0ca17a9a52aca8fb6
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 21 22:03:41 2011 -0400
Adding logic for removing files from a snapshot
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
index 35a4669..2efc8d8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
@@ -1,5 +1,6 @@
package org.rhq.enterprise.server.drift;
+import java.io.Serializable;
import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;
@@ -7,7 +8,11 @@ import java.util.TreeSet;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
-public class Snapshot {
+import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
+
+public class Snapshot implements Serializable {
+
+ private static final long serialVersionUID = 1L;
private int version;
@@ -29,7 +34,9 @@ public class Snapshot {
public <D extends Drift> Snapshot add(DriftChangeSet<D> changeSet) {
for (Drift entry : changeSet.getDrifts()) {
entries.remove(entry);
- entries.add(entry);
+ if (entry.getCategory() != FILE_REMOVED) {
+ entries.add(entry);
+ }
}
version = changeSet.getVersion();
return this;
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java
index 627bc2c..b646b19 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java
@@ -14,6 +14,7 @@ import org.rhq.core.domain.drift.DriftFileStatus;
import static org.rhq.core.domain.drift.DriftCategory.FILE_ADDED;
import static org.rhq.core.domain.drift.DriftCategory.FILE_CHANGED;
+import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
import static org.rhq.core.domain.drift.DriftChangeSetCategory.DRIFT;
import static org.rhq.core.domain.drift.DriftFileStatus.LOADED;
@@ -23,7 +24,7 @@ import static org.testng.Assert.assertEquals;
public class SnapshotTest {
@Test
- public void generateSnapshotForOneChangeSet() throws Exception {
+ public void addChangeSetWithAddedFile() {
int configId = 1;
FakeDriftChangeSet changeSet = new FakeDriftChangeSet(0, COVERAGE, configId)
@@ -37,7 +38,7 @@ public class SnapshotTest {
}
@Test
- public void generateSnapshotWithTwoChangeSetsAndFileAdded() {
+ public void addChangeSetsWithAddedFiles() {
int configId = 1;
Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
@@ -54,7 +55,7 @@ public class SnapshotTest {
}
@Test
- public void generateSnapshotWithFileChanged() {
+ public void replaceFileWithChangedVersion() {
int configId = 1;
Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
@@ -66,7 +67,24 @@ public class SnapshotTest {
Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
- assertCollectionMatchesNoOrder(asSet(entry2), snapshot.getEntries(), "Failed build snapshot with file changed");
+ assertCollectionMatchesNoOrder(asSet(entry2), snapshot.getEntries(), "Failed to build snapshot with file changed");
+ }
+
+ @Test
+ public void deleteFileThatHasBeenRemoved() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("d1f2a3", 1024, LOADED), "/drift/2.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1).add(entry2);
+
+ Drift entry3 = new FakeDrift(FILE_REMOVED, new FakeDriftFile("a1b2c3", 1024, LOADED), null, "/drift/1.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry3);
+
+ Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
+
+ assertCollectionMatchesNoOrder(asSet(entry2), snapshot.getEntries(), "Failed to build snapshot with a file " +
+ "removed.");
}
<E> Set<E> asSet(E... elements) {
commit 609a2aa1c541eb8f38b98c725d3e513c364653dc
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jul 27 10:03:45 2011 -0400
add peer-review warning
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index ea2e29d..b1d0bb1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -91,6 +91,12 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* A tabular view of set of data records from an {@link RPCDataSource}.
*
+ * WARNING! If you make _any_ changes to this class, no matter how seemingly
+ * trivial, you must get it peer reviewed. Send out your proposed changes
+ * to the dev mailing list and ask for comments. Any problems introduced to
+ * this class are magnified because it is used in so many UI views and problems
+ * are hard to detect due to the varies ways it is used.
+ *
* @author Greg Hinkle
* @author Ian Springer
*/
commit 23f8cf9f8417f0780b4019b885f9271288ecda05
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jul 26 22:29:16 2011 +0200
Add more properties for JBossWeb. Unfortunately they are read-only in AS7
Follow :read-resource output, as the resource description from AS7 is not up to date.
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index d9f79d1..6a8698e 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -614,6 +614,78 @@
<c:simple-property name="path" readOnly="true" default="subsystem=web"/>
</plugin-configuration>
+ <resource-configuration>
+ <c:simple-property name="default-virtual-server" required="false" type="string" readOnly="true" defaultValue="localhost"
+ description="The web container's default virtual server."/>
+ <c:simple-property name="native" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Add the native initialization listener to the web container."/>
+ <c:map-property name="configuration" description="The common web container configuration." >
+ <c:map-property name="static-resources" description="Configuration for static resources" >
+ <c:simple-property name="listings" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable folder listings."/>
+ <c:simple-property name="sendfile" required="false" type="integer" readOnly="true" defaultValue="49152"
+ description="Enable sendfile if possible, for files bigger than the specified byte size."/>
+ <c:simple-property name="read-only" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Allow write HTTP methods (PUT, DELETE)."/>
+ <c:simple-property name="webdav" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable WebDAV functionality."/>
+ <c:simple-property name="secret" required="false" type="string" readOnly="true" description="Secret for WebDAV locking operations."/>
+ <c:simple-property name="max-depth" required="false" type="integer" readOnly="true" defaultValue="3"
+ description="Maximum recursion for PROPFIND."/>
+ <c:simple-property name="disabled" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable the JSP container."/>
+ </c:map-property>
+ <c:map-property name="jsp-configuration" description="JSP container configuration">
+ <c:simple-property name="development" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable the development mode, which gives more information when an error occurs."/>
+ <c:simple-property name="file-encoding" required="false" type="string" readOnly="true" description="Force a file encoding."/>
+ <c:simple-property name="keep-generated" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Keep the generated Servlets."/>
+ <c:simple-property name="trim-spaces" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Trim some spaces from the generated Servlet."/>
+ <c:simple-property name="tag-pooling" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Enable tag pooling."/>
+ <c:simple-property name="mapped-file" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Map to the JSP source."/>
+ <c:simple-property name="check-interval" required="false" type="integer" readOnly="true" defaultValue="0"
+ description="Check interval for JSP updates using a background thread."/>
+ <c:simple-property name="modification-test-interval" required="false" type="integer" readOnly="true" defaultValue="4"
+ description="Minimum amount of time between two tests for updates, in seconds."/>
+ <c:simple-property name="recompile-on-fail" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Retry failed JSP compilations on each request."/>
+ <c:simple-property name="smap" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable SMAP."/>
+ <c:simple-property name="dump-smap" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Write SMAP data to a file."/>
+ <c:simple-property name="generate-strings-as-char-arrays" required="false" type="boolean" readOnly="true"
+ defaultValue="false"
+ description="Generate String constants as char arrays."/>
+ <c:simple-property name="error-on-use-bean-invalid-class-attribute" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable errors when using a bad class in useBean."/>
+ <c:simple-property name="scratch-dir" required="false" type="string" readOnly="true" description="Specify a different work directory."/>
+ <c:simple-property name="source-vm" required="false" type="string" readOnly="true" defaultValue="1.5"
+ description="Source VM level for compilation."/>
+ <c:simple-property name="target-vm" required="false" type="string" readOnly="true" defaultValue="1.5"
+ description="Target VM level for compilation."/>
+ <c:simple-property name="java-encoding" required="false" type="string" readOnly="true" defaultValue="UTF-8"
+ description="Specify the encoding used for Java sources."/>
+ <c:simple-property name="x-powered-by" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Enable advertising the JSP engine in x-powered-by."/>
+ <c:simple-property name="display-source-fragment" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="When a runtime error occurs, attempts to display corresponding JSP source fragment."/>
+ </c:map-property>
+ <c:list-property name="mime-mapping" description="A mime-mapping definition." >
+ <c:map-property name="mime-mapping" >
+ <c:simple-property name="name" description="A MIME mapping name"/>
+ <c:simple-property name="value" description="A MIME mapping value"/>
+ </c:map-property>
+ </c:list-property>
+ <c:list-property name="welcome-file" description="A welcome file declaration." >
+ <c:simple-property name="welcome-file" />
+ </c:list-property>
+ </c:map-property>
+ </resource-configuration>
+
<service name="Connector"
discovery="SubsystemDiscovery"
class="BaseComponent"
commit 13e821f0b60a26e6a4ea55cd8bacd523968d90f6
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jul 27 09:18:58 2011 +0200
Get rid of the explicit version number and let maven do the magic.
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 0927693..d9f79d1 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -48,7 +48,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin"
xmlns:c="urn:xmlns:rhq-configuration"
- version="4.0.0-SNAPSHOT"
>
<!-- <depends plugin="JMX" useClasses="true"/> -->
commit 0eb50dd5314086d110af46d614e3f607c1c1aac3
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jul 27 11:18:39 2011 +0200
Log the property being null and don't pollute stdout.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java
index e978962..c999be6 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java
@@ -269,8 +269,10 @@ public class ConfigurationLoadDelegate implements ConfigurationFacet {
if (property!=null)
propertyMap.put(property);
- else
- System.out.println("Property " + key + " was null");
+ else {
+ if (log.isDebugEnabled())
+ log.debug("Property " + key + " was null");
+ }
}
commit 43a1577fe5b8de22132fc2dbe3d2f58fb92a06d2
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jul 25 18:00:50 2011 +0200
Provide more connection properties for standalone servers as well as the version. Add start and restart operations for standalone servers.
Read the running instance name (i.e. standalone server name) from standalone.xml
Allow to start a domain/host controller.
Allow to shut down hosts in a domain.
Allow to shut down host controllers. Revert the ability to shutdown hosts - this needs to be done at HC level.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
index 63a4e45..c089b79 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
@@ -46,9 +46,15 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
protected Document hostXml;
protected final Log log = LogFactory.getLog(this.getClass());
-// private final Log log = LogFactory.getLog(AbstractBaseDiscovery.class);
- protected void readHostXml(ProcessInfo processInfo,boolean isDomainMode) {
+ /**
+ * Read the host.xml or standalone.xml file depending on isDomainMode. If isDomainMode is true,
+ * host.xml is read, otherwise standalone.xml.
+ * The xml file content is stored in the variable hostXml for future use.
+ * @param processInfo Process info to determine the base file location
+ * @param isDomainMode Indiates if host.xml should be read (true) or standalone.xml (false)
+ */
+ protected void readStandaloneOrHostXml(ProcessInfo processInfo, boolean isDomainMode) {
String hostXmlFile = getHostXmlFileLocation(processInfo,isDomainMode);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
@@ -61,7 +67,11 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
}
}
-
+ /**
+ * Determine the server home (=base) directory by parsing the passed command line
+ * @param commandLine command line arguments of the process
+ * @return The home dir if found or empty string otherwise
+ */
String getHomeDirFromCommandLine(String[] commandLine) {
for (String line: commandLine) {
if (line.startsWith(DJBOSS_SERVER_HOME_DIR))
@@ -70,6 +80,11 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
return "";
}
+ /**
+ * Determine the location of the boot log file of the server by parsing the command line
+ * @param commandLine command line arguments of the process
+ * @return The log file location or empty string otherwise
+ */
String getLogFileFromCommandLine(String[] commandLine) {
for (String line: commandLine) {
@@ -79,7 +94,14 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
return "";
}
+ /**
+ * Try to obtain the management IP and port from the already parsed host.xml or standalone.xml
+ * @return an Object containing host and port
+ * @see #readStandaloneOrHostXml(org.rhq.core.system.ProcessInfo, boolean) on how to obtain the parsed xml
+ */
protected HostPort getManagementPortFromHostXml() {
+ if (hostXml==null)
+ throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first.");
Element host = hostXml.getDocumentElement();
NodeList interfaceParent = host.getElementsByTagName("management-interfaces");
if (interfaceParent ==null || interfaceParent.getLength()==0) {
@@ -112,7 +134,15 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
return new HostPort();
}
+ /**
+ * Try to obtain the management interface IP from the host/standalone.xml files
+ * @param nIf Interface to look for
+ * @return IP address to use
+ */
private String getInterface(String nIf) {
+ if (hostXml==null)
+ throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first.");
+
Element host = hostXml.getDocumentElement();
NodeList interfaceParent = host.getElementsByTagName("interfaces");
if (interfaceParent ==null || interfaceParent.getLength()==0) {
@@ -155,12 +185,26 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
return null; // TODO: Customise this generated block
}
+ /**
+ * Try to determine the host name - that is the name of a standalone server or a
+ * host in domain mode by looking at the standalone/host.xml files
+ * @return server name
+ */
protected String findHostName() {
+ if (hostXml==null)
+ throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first.");
+
String hostName = hostXml.getDocumentElement().getAttribute("name");
return hostName;
}
+ /**
+ * Try to obtain the domain controller's location from looking at host.xml
+ * @return host and port of the domain controller
+ */
protected HostPort getDomainControllerFromHostXml() {
+ if (hostXml==null)
+ throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first.");
Element host = hostXml.getDocumentElement();
NodeList dcParent = host.getElementsByTagName("domain-controller");
@@ -211,6 +255,9 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
}
+ /**
+ * Helper class that holds information about the host,port tuple
+ */
protected static class HostPort {
String host;
int port;
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 8851706..776e5ef 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -79,7 +79,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
final Log log = LogFactory.getLog(this.getClass());
ResourceContext context;
- Configuration conf;
+ Configuration pluginConfiguration;
String myServerName;
ASConnection connection;
String path;
@@ -107,16 +107,16 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
*/
public void start(ResourceContext context) throws InvalidPluginConfigurationException, Exception {
this.context = context;
- conf = context.getPluginConfiguration();
+ pluginConfiguration = context.getPluginConfiguration();
String typeName = context.getResourceType().getName();
// TODO can we use parent's connection and only set this up for top level base component?
- host = conf.getSimpleValue("hostname", LOCALHOST);
- String portString = conf.getSimpleValue("port", DEFAULT_HTTP_MANAGEMENT_PORT);
+ host = pluginConfiguration.getSimpleValue("hostname", LOCALHOST);
+ String portString = pluginConfiguration.getSimpleValue("port", DEFAULT_HTTP_MANAGEMENT_PORT);
port = Integer.parseInt(portString);
connection = new ASConnection(host,port);
- path = conf.getSimpleValue("path", null);
+ path = pluginConfiguration.getSimpleValue("path", null);
key = context.getResourceKey();
myServerName = context.getResourceKey().substring(context.getResourceKey().lastIndexOf("/")+1);
@@ -445,16 +445,15 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>();
if (what.equals("server-group")) {
- String groupName = parameters.getSimpleValue("name",null);
+ String groupName = parameters.getSimpleValue("name","");
String profile = parameters.getSimpleValue("profile","default");
address.add(new PROPERTY_VALUE("server-group",groupName));
operation = new Operation(op,address,"profile",profile);
} else if (what.equals("server")) {
-
if (context.getResourceType().getName().equals("JBossAS-Managed")) {
- String host = conf.getSimpleValue("domainHost","local");
+ String host = pluginConfiguration.getSimpleValue("domainHost","local");
address.add(new PROPERTY_VALUE("host",host));
address.add(new PROPERTY_VALUE("server-config",myServerName));
operation = new Operation(op,address);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
index 2f71edb..475fd62 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
@@ -18,8 +18,11 @@
*/
package org.rhq.modules.plugins.jbossas7;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.List;
@@ -30,7 +33,6 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.mc4j.ems.connection.support.metadata.LocalVMTypeDescriptor;
import org.w3c.dom.Document;
import org.rhq.core.domain.configuration.Configuration;
@@ -43,8 +45,6 @@ import org.rhq.core.pluginapi.inventory.ProcessScanResult;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.core.system.ProcessInfo;
-import org.rhq.plugins.jmx.JMXDiscoveryComponent;
-
/**
* Discovery class
@@ -53,9 +53,10 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
{
- static final String DJBOSS_SERVER_BASE_DIR = "-Djboss.server.base.dir=";
+ static final String DJBOSS_HOME_DIR = "-Djboss.home.dir=";
static final String DORG_JBOSS_BOOT_LOG_FILE = "-Dorg.jboss.boot.log.file=";
static final String DLOGGING_CONFIGURATION = "-Dlogging.configuration=";
+ static final String DASH_DASH_SERVER_CONFIG = "--server-config=";
private final Log log = LogFactory.getLog(this.getClass());
/**
@@ -77,11 +78,13 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
String serverName;
String psName = psr.getProcessScan().getName();
String description = discoveryContext.getResourceType().getDescription();
+ String version = null;
+ String startScript;
if (psName.equals("ProcessController")) {
serverNameFull = "ProcessController";
serverName = "ProcessController";
} else if (psName.equals("HostController")) {
- readHostXml(psr.getProcessInfo(),true);
+ readStandaloneOrHostXml(psr.getProcessInfo(), true);
HostPort hp = getDomainControllerFromHostXml();
if (hp.isLocal) {
serverName = "DomainController";
@@ -92,11 +95,20 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
serverName = "HostController";
serverNameFull = "HostController";
}
- config.put(new PropertySimple("homedir",getHomeDirFromCommandLine(psr.getProcessInfo().getCommandLine())));
- // TODO add the start script
+ String homeDir = getHomeDirFromCommandLine(psr.getProcessInfo().getCommandLine());
+ config.put(new PropertySimple("baseDir", homeDir));
+ version = homeDir.substring(homeDir.lastIndexOf("-")+1);
+ config.put(new PropertySimple("startScript","bin/domain.sh"));
+ String host = findHost(psr.getProcessInfo(),true);
+ config.put(new PropertySimple("domainHost",host));
+
+ fillUserPassFromFile(config,"domain",homeDir);
+
+ // TODO provide running config
- } else {
- serverNameFull = getBaseDirFromCommandLine(commandLine);
+ } else { // Standalone server
+ serverNameFull = getHomeDirFromCommandLine(commandLine);
+ readStandaloneOrHostXml(psr.getProcessInfo(), false);
if (serverNameFull==null || serverNameFull.isEmpty()) {
// Try to obtain the server name
// -Dorg.jboss.boot.log.file=domain/servers/server-one/log/boot.log
@@ -111,10 +123,19 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
config.put(new PropertySimple("domainHost",host));
}
- serverName = serverNameFull.substring(serverNameFull.lastIndexOf("/")+1);
+ config.put(new PropertySimple("baseDir",serverNameFull));
+ serverName = findHostName();
if (serverName.isEmpty())
serverName = serverNameFull;
+ version = serverName.substring(serverName.lastIndexOf("-")+1);
+
+ String serverConfig = getServerConfigFromCommandLine(commandLine);
+ config.put(new PropertySimple("config",serverConfig));
+ config.put(new PropertySimple("startScript","bin/standalone.sh"));
+
+ fillUserPassFromFile(config,"standalone", serverNameFull);
+
}
String logFile = getLogFileFromCommandLine(commandLine);
initLogEventSourcesConfigProp(logFile,config);
@@ -139,7 +160,7 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
discoveryContext.getResourceType(), // ResourceType
serverNameFull, // key TODO distinguish per domain?
serverName, // Name
- null, // TODO real version ?
+ version, // TODO get via API ?Á
description, // Description
config,
psr.getProcessInfo()
@@ -155,6 +176,48 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
}
+ private void fillUserPassFromFile(Configuration config, String mode, String baseDir) {
+
+ String configDir = baseDir + File.separator + mode + File.separator + "configuration";
+
+ File file = new File(configDir ,"mgmt-users.properties");
+ if (!file.exists() || !file.canRead()) {
+ if (log.isDebugEnabled())
+ log.debug("No console user properties file found at [" + file.getAbsolutePath() + "] or file is not readable");
+ return;
+ }
+ BufferedReader br=null;
+ try {
+ FileReader fileReader = new FileReader(file);
+ br = new BufferedReader(fileReader);
+ String line;
+ while ((line = br.readLine())!=null) {
+ if (line.startsWith("#"))
+ continue;
+ if (line.isEmpty())
+ continue;
+ if (!line.contains("="))
+ continue;
+ // found a candidate
+ String user = line.substring(0,line.indexOf("="));
+ String pass = line.substring(line.indexOf("=")+1);
+ config.put(new PropertySimple("user",user));
+ config.put(new PropertySimple("password",pass));
+
+ }
+ } catch (IOException e) {
+ e.printStackTrace(); // TODO: Customise this generated block
+ } finally {
+ if (br!=null)
+ try {
+ br.close();
+ } catch (IOException e) {
+ // empty
+ }
+ }
+
+ }
+
private String findHost(ProcessInfo processInfo,boolean isDomain) {
String hostXmlFile = getHostXmlFileLocation(processInfo, isDomain);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@@ -173,12 +236,13 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
return hostName;
}
- String getBaseDirFromCommandLine(String[] commandLine) {
+
+ String getServerConfigFromCommandLine(String[] commandLine) {
for (String line: commandLine) {
- if (line.startsWith(DJBOSS_SERVER_BASE_DIR))
- return line.substring(DJBOSS_SERVER_BASE_DIR.length());
+ if (line.startsWith(DASH_DASH_SERVER_CONFIG))
+ return line.substring(DASH_DASH_SERVER_CONFIG.length());
}
- return "";
+ return "standalone.xml";
}
//-Dorg.jboss.boot.log.file=/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/log/server-manager/boot.log
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
new file mode 100644
index 0000000..c8703a6
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
@@ -0,0 +1,184 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.io.File;
+import java.net.ConnectException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.core.pluginapi.util.ProcessExecutionUtility;
+import org.rhq.core.system.ProcessExecution;
+import org.rhq.core.system.ProcessExecutionResults;
+import org.rhq.modules.plugins.jbossas7.json.Result;
+
+/**
+ * Base component for functionality that is common to Standalone AS and HostControllers
+ * @author Heiko W. Rupp
+ */
+public class BaseServerComponent extends BaseComponent {
+
+ private static final String STANDALONE_XML = "standalone.xml";
+ private static final String SEPARATOR = "\n-----------------------\n";
+ final Log log = LogFactory.getLog(BaseServerComponent.class);
+
+ /**
+ * Restart the server by first executing a 'shutdown' operation via its API. Then call
+ * the #startServer method to start it again.
+ *
+ * @param parameters Parameters to pass to the (recursive) invocation of #invokeOperation
+ * @param mode
+ * @return State of execution
+ * @throws Exception If anything goes wrong
+ */
+ protected OperationResult restartServer(Configuration parameters, Mode mode) throws Exception {
+ OperationResult tmp = invokeOperation("shutdown",parameters);
+
+ if (tmp.getErrorMessage()!=null) {
+ tmp.setErrorMessage("Restart failed while failing to shut down: " + tmp.getErrorMessage());
+ return tmp;
+ }
+ Thread.sleep(500); // Wait 0.5s -- this is plenty
+ return startServer(mode);
+ }
+
+ /**
+ * Start the server by calling the start script listed in the plugin configuration. If a different
+ * config is given, this is passed via --server-config
+ * @return State of Execution.
+ * @param mode
+ */
+ protected OperationResult startServer(Mode mode) {
+ OperationResult operationResult = new OperationResult();
+ Configuration conf = context.getPluginConfiguration();
+ String startScript = conf.getSimpleValue("startScript", mode.getStartScript());
+ String baseDir = conf.getSimpleValue("baseDir","");
+ if (baseDir.isEmpty()) {
+ operationResult.setErrorMessage("No base directory provided");
+ return operationResult;
+ }
+ String script = baseDir + File.separator + startScript;
+ String config = conf.getSimpleValue("config", mode.getXmlFile());
+
+ ProcessExecution processExecution;
+ processExecution = ProcessExecutionUtility.createProcessExecution(new File(script));
+ if (!config.equals(mode.getXmlFile())) {
+ processExecution.getArguments().add(mode.getConfigArg());
+ processExecution.getArguments().add(config);
+ }
+ processExecution.setWorkingDirectory(baseDir);
+ processExecution.setCaptureOutput(true);
+ processExecution.setWaitForCompletion(2000L); // 2 seconds // TODO: Should we wait longer than two seconds?
+ processExecution.setKillOnTimeout(false);
+
+
+ long start = System.currentTimeMillis();
+ if (log.isDebugEnabled()) {
+ log.debug("About to execute the following process: [" + processExecution + "]");
+ }
+ ProcessExecutionResults results = context.getSystemInformation().executeProcess(processExecution);
+ logExecutionResults(results);
+ if (results.getError()!=null) {
+ operationResult.setErrorMessage(results.getError().getMessage());
+ } else {
+ operationResult.setSimpleResult("Success");
+ }
+
+ return operationResult;
+
+ }
+
+ private void logExecutionResults(ProcessExecutionResults results) {
+ // Always log the output at info level. On Unix we could switch depending on a exitCode being !=0, but ...
+ log.info("Exit code from process execution: " + results.getExitCode());
+ log.info("Output from process execution: " + SEPARATOR + results.getCapturedOutput() + SEPARATOR);
+ }
+
+ /**
+ * Do some post processing of the Result - especially the 'shutdown' operation needs a special
+ * treatment.
+ * @param name Name of the operation
+ * @param res Result of the operation vs. AS7
+ * @return OperationResult filled in from values of res
+ */
+ protected OperationResult postProcessResult(String name, Result res) {
+ OperationResult operationResult = new OperationResult();
+ if (name.equals("shutdown")) {
+ /*
+ * Shutdown needs a special treatment, because after sending the operation, if shutdown suceeds,
+ * the server connection is closed and we can't read from it. So if we get connection refused for
+ * reading, this is a good sign.
+ */
+ if (!res.isSuccess()) {
+ if (res.getThrowable()!=null && (res.getThrowable() instanceof ConnectException || res.getThrowable().getMessage().equals("Connection refused")))
+ operationResult.setSimpleResult("Success");
+ else
+ operationResult.setErrorMessage(res.getFailureDescription());
+ }
+ }
+ else {
+ if (res.isSuccess()) {
+ if (res.getResult()!=null)
+ operationResult.setSimpleResult(res.getResult().toString());
+ else
+ operationResult.setSimpleResult("-None provided by server-");
+ }
+ else
+ operationResult.setErrorMessage(res.getFailureDescription());
+ }
+ return operationResult;
+ }
+
+ enum Mode {
+ STANDALONE(STANDALONE_XML,"standalone","--server-config","bin/standalone.sh"),
+ DOMAIN("domain.xml","domain", "--domain-config","bin/domain.sh"),
+ HOST("host.xml","domain", "--host-config","bin/domain.sh");
+
+ private String xmlFile;
+ private String baseDir;
+ private String configArg;
+ private String startScript;
+
+ private Mode(String xmlFile, String baseDir, String configArg, String startScript) {
+ this.xmlFile = xmlFile;
+ this.baseDir = baseDir;
+ this.configArg = configArg;
+ this.startScript = startScript;
+ }
+
+ public String getXmlFile() {
+ return xmlFile;
+ }
+
+ public String getBaseDir() {
+ return baseDir;
+ }
+
+ public String getConfigArg() {
+ return configArg;
+ }
+
+ public String getStartScript() {
+ return startScript;
+ }
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
deleted file mode 100644
index c25fe88..0000000
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.modules.plugins.jbossas7;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.codehaus.jackson.JsonNode;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.pluginapi.operation.OperationFacet;
-import org.rhq.core.pluginapi.operation.OperationResult;
-import org.rhq.modules.plugins.jbossas7.json.Operation;
-import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
-import org.rhq.modules.plugins.jbossas7.json.Result;
-
-/**
- * Common stuff for the Domain
- * @author Heiko W. Rupp
- */
-@SuppressWarnings("unused")
-public class DomainComponent extends BaseComponent implements OperationFacet{
-
- @Override
- public AvailabilityType getAvailability() {
-
- if (context.getResourceType().getName().equals("JBossAS-Managed")) {
- List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>(2);
- String host = conf.getSimpleValue("domainHost","local");
- address.add(new PROPERTY_VALUE("host",host));
- address.add(new PROPERTY_VALUE("server-config",myServerName));
- Operation getStatus = new Operation("read-attribute",address,"name","status");
- Result result = null;
- try {
- result = connection.execute(getStatus);
- } catch (Exception e) {
- log.warn(e.getMessage());
- return AvailabilityType.DOWN;
- }
- if (!result.isSuccess())
- return AvailabilityType.DOWN;
-
- String msg = result.getResult().toString();
- if (msg.contains("STARTED"))
- return AvailabilityType.UP;
- else
- return AvailabilityType.DOWN;
- }
-
- return super.getAvailability(); // TODO: Customise this generated block
- }
-
-}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java
new file mode 100644
index 0000000..73eb0bb
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java
@@ -0,0 +1,64 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.Result;
+
+/**
+ * Component class for host- and domain controller
+ * @author Heiko W. Rupp
+ */
+public class HostControllerComponent extends BaseServerComponent implements OperationFacet {
+
+ private final Log log = LogFactory.getLog(HostControllerComponent.class);
+
+ @Override
+ public OperationResult invokeOperation(String name,
+ Configuration parameters) throws InterruptedException, Exception {
+
+ if (name.equals("start")) {
+ return startServer(Mode.DOMAIN);
+ } else if (name.equals("restart")) {
+ return restartServer(parameters, Mode.DOMAIN);
+
+ } else if (name.equals("shutdown")) {
+ // This is a bit trickier, as it needs to be executed on the level on /host=xx
+ String domainHost = pluginConfiguration.getSimpleValue("domainHost","");
+ if (domainHost.isEmpty()) {
+ OperationResult result = new OperationResult();
+ result.setErrorMessage("No domain host found - can not continue");
+ return result;
+ }
+ Operation op = new Operation("shutdown","host",domainHost);
+ Result res = getASConnection().execute(op);
+
+ postProcessResult(name,res);
+ }
+
+ // Defer other stuff to the base component for now
+ return super.invokeOperation(name, parameters);
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java
index d0d3eee..951430c 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java
@@ -32,7 +32,6 @@ import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
-import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.resource.CreateResourceStatus;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
@@ -43,7 +42,7 @@ import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
* Component class for the JMS subsystem
* @author Heiko W. Rupp
*/
-public class JmsComponent extends DomainComponent {
+public class JmsComponent extends BaseComponent {
private final Log log = LogFactory.getLog(JmsComponent.class);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java
new file mode 100644
index 0000000..64ac2b6
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java
@@ -0,0 +1,70 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+import org.rhq.modules.plugins.jbossas7.json.Result;
+
+/**
+ * Common stuff for the Domain
+ * @author Heiko W. Rupp
+ */
+@SuppressWarnings("unused")
+public class ManagedASComponent extends BaseComponent {
+
+ /**
+ * Get the availability of the managed AS server. We can't just check if
+ * a connection succeeds, as the check runs against the API/HostController
+ * and the managed server may still be down even if the connection succeeds.
+ * @return Availability of the managed AS instance.
+ */
+ @Override
+ public AvailabilityType getAvailability() {
+
+ if (context.getResourceType().getName().equals("JBossAS-Managed")) {
+ List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>(2);
+ String host = pluginConfiguration.getSimpleValue("domainHost","local");
+ address.add(new PROPERTY_VALUE("host",host));
+ address.add(new PROPERTY_VALUE("server-config",myServerName));
+ Operation getStatus = new Operation("read-attribute",address,"name","status");
+ Result result = null;
+ try {
+ result = connection.execute(getStatus);
+ } catch (Exception e) {
+ log.warn(e.getMessage());
+ return AvailabilityType.DOWN;
+ }
+ if (!result.isSuccess())
+ return AvailabilityType.DOWN;
+
+ String msg = result.getResult().toString();
+ if (msg.contains("STARTED"))
+ return AvailabilityType.UP;
+ else
+ return AvailabilityType.DOWN;
+ }
+
+ return super.getAvailability();
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
index 3946dbe..fd1b65d 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
@@ -70,7 +70,7 @@ public class ManagedASDiscovery extends AbstractBaseDiscovery
// Now we have the host controller, lets get the host.xml file
// and obtain the servers from there.
ProcessInfo processInfo = psr.getProcessInfo();
- readHostXml(processInfo,true);
+ readStandaloneOrHostXml(processInfo, true);
String hostName = findHostName();
HostPort managementHostPort = getManagementPortFromHostXml();
@@ -105,13 +105,16 @@ public class ManagedASDiscovery extends AbstractBaseDiscovery
// TODO this fails for the downed servers.
// get from the domain or other place as soon as the domain provides it.
- initLogFile(scans, serverInfo.name, config, getHomeDirFromCommandLine(processInfo.getCommandLine()));
+ String homeDir = getHomeDirFromCommandLine(processInfo.getCommandLine());
+ initLogFile(scans, serverInfo.name, config, homeDir);
+
+ String version = homeDir.substring(homeDir.lastIndexOf("-")+1);
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
discoveryContext.getResourceType(), // ResourceType
hostName + "/" + serverInfo.name, // key
serverInfo.name, // Name
- null, // TODO real version - get from Domain as soon as it is provided
+ version, // TODO get from Domain as soon as it is provided
"Managed AS 7 instance", // Description
config,
null
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
index 15cb5d3..ad1109b 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
@@ -23,7 +23,6 @@ import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -38,12 +37,10 @@ import org.rhq.core.domain.content.transfer.DeployPackageStep;
import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
-import org.rhq.core.domain.resource.CreateResourceStatus;
import org.rhq.core.pluginapi.content.ContentContext;
import org.rhq.core.pluginapi.content.ContentFacet;
import org.rhq.core.pluginapi.content.ContentServices;
import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
-import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.modules.plugins.jbossas7.json.CompositeOperation;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
@@ -55,7 +52,7 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
* @author Heiko W. Rupp
*/
@SuppressWarnings("unused")
-public class ServerGroupComponent extends DomainComponent implements ContentFacet, CreateChildResourceFacet {
+public class ServerGroupComponent extends ManagedASComponent implements ContentFacet, CreateChildResourceFacet {
private static final String SUCCESS = "success";
private static final String OUTCOME = "outcome";
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
index 0281279..ebddf95 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
@@ -31,41 +31,25 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
* Component class for standalone AS7 servers
* @author Heiko W. Rupp
*/
-public class StandaloneASComponent extends BaseComponent implements OperationFacet {
-
+public class StandaloneASComponent extends BaseServerComponent implements OperationFacet {
@Override
public OperationResult invokeOperation(String name,
Configuration parameters) throws Exception {
- // reload, shutdown
+ if (name.equals("start")) {
+ return startServer(Mode.STANDALONE);
+ } else if (name.equals("restart")) {
+ return restartServer(parameters, Mode.STANDALONE);
+
+ }
+
+ // reload, shutdown go to the remote server
Operation op = new Operation(name,new Address());
Result res = getASConnection().execute(op);
- OperationResult operationResult = new OperationResult();
- if (name.equals("shutdown")) {
- /*
- * Shutdown needs a special treatment, because after sending the operation, if shutdown suceeds,
- * the server connection is closed and we can't read from it. So if we get connection refused for
- * reading, this is a good sign.
- */
- if (!res.isSuccess()) {
- if (res.getThrowable() instanceof ConnectException || res.getThrowable().getMessage().equals("Connection refused"))
- operationResult.setSimpleResult("Success");
- else
- operationResult.setErrorMessage(res.getFailureDescription());
- }
- }
- else {
- if (res.isSuccess()) {
- if (res.getResult()!=null)
- operationResult.setSimpleResult(res.getResult().toString());
- else
- operationResult.setSimpleResult("-None provided by server-");
- }
- else
- operationResult.setErrorMessage(res.getFailureDescription());
- }
+ OperationResult operationResult = postProcessResult(name, res);
return operationResult;
}
+
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
index ad91dac..d762485 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
@@ -51,6 +51,25 @@ public class Address {
path.addAll(other);
}
+ public Address(String path) {
+ this();
+ String[] components = path.split(",");
+ for (String component : components) {
+ String tmp = component.trim();
+
+ if (tmp.contains("=")) {
+ // strip / from the start of the key if it happens to be there
+ if (tmp.startsWith("/"))
+ tmp = tmp.substring(1);
+
+ String[] pair = tmp.split("=");
+ PROPERTY_VALUE valuePair = new PROPERTY_VALUE(pair[0], pair[1]);
+ this.path.add(valuePair);
+ }
+ }
+
+ }
+
public void add(String key, String value) {
path.add(new PROPERTY_VALUE(key,value));
}
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index c0e364d..0927693 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -58,6 +58,7 @@
~~ additional 'Personalities' for the kinds of servers (PM, SM, Standalone AS, Managed AS)
-->
+ <!-- TODO do we want to show the process controller at all? We have no benefit from it
<server name="ProcessController"
discovery="BaseProcessDiscovery"
class="BaseComponent"
@@ -68,27 +69,28 @@
<c:simple-property name="hostname" default="localhost" required="true"/>
<c:simple-property name="port" default="9990" type="integer" required="true"/>
- &logSources;
</plugin-configuration>
<process-scan name="ProcessController" query="process|basename|match=^java.*,arg|org.jboss.as.process-controller|match=.*"/>
- <operation name="dummyOperation">
- <!-- TODO supply parameters and return values -->
- </operation>
-
-
</server>
+ -->
<server name="HostController"
discovery="BaseProcessDiscovery"
- class="BaseComponent"
+ class="HostControllerComponent"
description="Domain controller (delegate) for this host"
>
<plugin-configuration>
- <c:simple-property name="hostname" default="localhost" required="true"/>
- <c:simple-property name="port" default="9990" type="integer" required="true"/>
+ <c:simple-property name="hostname" default="localhost" required="true" description="Host name of the domain API"/>
+ <c:simple-property name="port" default="9990" type="integer" required="true" description="Port of the domain API"/>
+ <c:simple-property name="user" type="string" description="Management user for a secured Host controller" required="false"/>
+ <c:simple-property name="password" type="password" description="Password for the management user" required="false"/>
+ <c:simple-property name="config" type="string" default="domain.xml" description="Running configuration" displayName="Configuration"/>
+ <c:simple-property name="baseDir" type="file" description="Base directory of the server installation" displayName="Base directory" readOnly="true" required="false"/>
+ <c:simple-property name="startScript" type="file" default="bin/domain.sh" description="Script used to start the server. If the path is not absolute, it is relative to the base directory"/>
+ <c:simple-property name="domainHost" type="string" readOnly="true" required="false" description="Host name within the AS7 domain"/>
&logSources;
</plugin-configuration>
@@ -96,8 +98,10 @@
<process-scan name="HostController" query="process|basename|match=^java.*,arg|org.jboss.as.host-controller|match=.*"/>
+<!-- Currently not provided by AS7
<operation name="domain:shutdown" displayName="Shutdown Domain" description="Shut this Host-/Domaincontroller down with all managed servers.">
</operation>
+-->
<operation name="server-group:add" displayName="Add ServerGroup" description="Add a server group to the Domain.">
<parameters>
@@ -146,6 +150,17 @@
</operation>
+ <operation name="start" description="Start this Host-/Domaincontroller" displayName="Start this host controller">
+ <results>
+ <c:simple-property name="operationResult" description="Outcome of the start operation"/>
+ </results>
+ </operation>
+ <operation name="shutdown" description="Stop this Host-/Domaincontroller" displayName="Shut down this host controller">
+ <results>
+ <c:simple-property name="operationResult" description="Outcome of the stop operation"/>
+ </results>
+ </operation>
+
<metric property="_internal:mgmtRequests" category="performance" dataType="measurement" defaultInterval="120000"
displayType="summary" measurementType="trendsup" description="Number of requests sent to the controller"
@@ -206,7 +221,7 @@
<resource-configuration>
<c:simple-property name="profile" description="The profile name" required="true"/>
<c:simple-property name="socket-binding-group" readOnly="false" required="true">
- <c:option-source target="resource" expression="type=SocketBindingGroup"/>
+ <c:option-source target="resource" expression="type=SocketBindingGroupDomain"/>
</c:simple-property>
<c:simple-property name="socket-binding-port-offset" required="false" defaultValue="0" type="integer"
description="The default offset to be added to the port values given by the socket binding group."/>
@@ -217,7 +232,7 @@
<server name="Host"
description="Host involved in this domain"
discovery="SubsystemDiscovery"
- class="DomainComponent"
+ class="BaseComponent"
>
<plugin-configuration>
<c:simple-property name="path" default="host" readOnly="true"/>
@@ -287,11 +302,17 @@
<server name="JBossAS7-Standalone"
discovery="BaseProcessDiscovery"
class="StandaloneASComponent"
+ description="Standalone AS7 server"
>
<plugin-configuration>
<c:simple-property name="hostname" default="localhost" required="true"/>
<c:simple-property name="port" default="9990" type="integer" required="true"/>
+ <c:simple-property name="user" type="string" description="Management user for a secured AS" required="false"/>
+ <c:simple-property name="password" type="password" description="Password for the management user" required="false"/>
+ <c:simple-property name="config" type="string" default="standalone.xml" description="Running configuration" displayName="Configuration"/>
+ <c:simple-property name="baseDir" type="file" description="Base directory of the server installation" displayName="Base directory" readOnly="true" required="false"/>
+ <c:simple-property name="startScript" type="file" default="bin/standalone.sh" description="Script used to start the server. If the path is not absolute, it is relative to the base directory"/>
<c:list-property name="system-properties">
<c:map-property name="system-property">
<c:simple-property name="key" readOnly="true"/>
@@ -303,7 +324,18 @@
<process-scan name="StandaloneAS" query="process|basename|match=^java.*,arg|org.jboss.as.standalone|match=.*"/>
- <operation name="reload" description="Make the server load the (changed) configuration." displayName="Reload">
+
+ <operation name="reload" description="Make the server re-load the (changed) configuration. To load a different startup config use 'restart'" displayName="Reload">
+ <results>
+ <c:simple-property name="operationResult"/>
+ </results>
+ </operation>
+ <operation name="start" description="Start the server by invoking its start script">
+ <results>
+ <c:simple-property name="operationResult"/>
+ </results>
+ </operation>
+ <operation name="restart" description="Restart the server by shutting it down and invoking its start script">
<results>
<c:simple-property name="operationResult"/>
</results>
@@ -353,14 +385,14 @@
<server name="JBossAS-Managed"
discovery="ManagedASDiscovery"
- class="DomainComponent"
+ class="ManagedASComponent"
>
<plugin-configuration>
<c:simple-property name="hostname" default="localhost" displayName="Management host" required="true"/>
<c:simple-property name="port" default="9990" type="integer" displayName="Management port" required="true"/>
<c:simple-property name="domainHost" readOnly="true" description="Hostname in the domain"/>
<c:simple-property name="group" readOnly="true" displayName="Server Group" description="Server Group this instance belongs to."/>
- <c:simple-property name="socket-binding-group" readOnly="true" displayName="Socket binding group" description="Socket bindngs to use"/>
+ <c:simple-property name="socket-binding-group" readOnly="true" displayName="Socket binding group" description="Socket bindings to use"/>
<c:simple-property name="socket-binding-port-offset" readOnly="true" displayName="Port Offset" type="integer" default="0" description="Offset to the base ports"/>
<c:simple-property name="path" readOnly="true" />
@@ -412,7 +444,7 @@
<server name="Messaging"
discovery="SubsystemDiscovery"
- class="DomainComponent"
+ class="BaseComponent"
description="The underlying HornetQ based messaging subsystem"
singleton="true"
>
@@ -1792,8 +1824,8 @@ working area for individual server instances</li></ul>"/>
<c:list-property name="includes" required="false">
<c:simple-property name="includes" displayName="Included bindings" description="Other bindings that are included in this one (only needed in Domain Mode)"/>
</c:list-property>
- <c:group name="children:socket.binding">
- <c:list-property name="socket-binding">
+ <c:group name="children:socket-binding:name" displayName="Individual socket bindings">
+ <c:list-property name="*">
<c:map-property name="binding">
<c:simple-property name="name" description="The name of the socket. Services which need to access the socket configuration information will find it using this name." readOnly="true"/>
<c:simple-property name="interface" description="Name of the interface to which the socket should be bound, or, for multicast sockets, the interface on which it should listen. This should be one of the declared interfaces."
commit 668586aa9445d9aee9f63fc8991da4477bb4031d
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 26 16:11:50 2011 -0500
Fully enable jvmRoute for context identification and discovery. Also, addressed all the compiler warnings in the plugin code.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
index 23d7d62..3545fa5 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
@@ -32,6 +32,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
*
* @author Stefan Negrea
*/
+@SuppressWarnings({ "rawtypes", "deprecation" })
public class ContextComponent extends MBeanResourceComponent<MBeanResourceComponent> {
@Override
protected EmsBean loadBean() {
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
index 35ecf30..5c9c3fd 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
@@ -57,10 +57,12 @@ public class ContextDiscoveryComponent implements ResourceDiscoveryComponent<MBe
Set<DiscoveredResourceDetails> entities = new HashSet<DiscoveredResourceDetails>();
for (ProxyInfo.Context availableContext : proxyInfo.getAvailableContexts()) {
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(context.getResourceType(),
- availableContext.createKey(), availableContext.createName(), null, "mod_cluster Webapp Context", null,
- null);
- entities.add(detail);
+ if (availableContext.getJvmRoute().equals(jvmRoute)) {
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(context.getResourceType(),
+ availableContext.createKey(), availableContext.createName(), null, "mod_cluster Webapp Context",
+ null, null);
+ entities.add(detail);
+ }
}
return entities;
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
index 4cca539..8614402 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
@@ -54,9 +54,9 @@ public class ProxyInfo {
identifier = identifier.substring(identifier.indexOf("[") + 1, identifier.indexOf("]"));
String jvmRoute = nodePieces[1];
- jvmRoute = jvmRoute.substring(jvmRoute.indexOf(':')).trim();
+ jvmRoute = jvmRoute.substring(jvmRoute.indexOf(':') + 1).trim();
- availableNodes.put(jvmRoute, new Node(jvmRoute, identifier));
+ availableNodes.put(identifier, new Node(jvmRoute, identifier));
}
}
@@ -90,13 +90,18 @@ public class ProxyInfo {
identifier = identifier.substring(identifier.indexOf("[") + 1, identifier.indexOf("]"));
identifier = identifier.substring(0, identifier.lastIndexOf(":"));
+ String nodeIdentifier = contextPieces[0];
+ nodeIdentifier = nodeIdentifier.substring(nodeIdentifier.indexOf("[") + 1, nodeIdentifier.indexOf("]"));
+ nodeIdentifier = nodeIdentifier.substring(0, nodeIdentifier.indexOf(":"));
+ String jvmRoute = availableNodes.get(nodeIdentifier).getJvmRoute();
+
String rawIsEnabled = contextPieces[2];
rawIsEnabled = rawIsEnabled.substring(rawIsEnabled.indexOf(':') + 1).trim();
boolean isEnabled = rawIsEnabled.equals("ENABLED") ? true : false;
Vhost relatedVhost = availableVhosts.get(identifier);
- availableContexts.add(new Context("", relatedVhost.getHost(), actualContext, isEnabled));
+ availableContexts.add(new Context(jvmRoute, relatedVhost.getHost(), actualContext, isEnabled));
}
}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 3c01b30..992c5b0 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -18,12 +18,12 @@
description="mod_cluster plugin"
singleton="true">
- <runs-inside>
+ <runs-inside>
<parent-resource-type name="JBossAS Server" plugin="JBossAS"/>
<parent-resource-type name="JBossAS5 Server" plugin="JBossAS5"/>
</runs-inside>
- <plugin-configuration>
+ <plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="Catalina:type=ModClusterListener,*"/>
<c:simple-property name="additionalConfigurationObjectName" readOnly="true" default="jboss.web:type=Engine"/>
<c:simple-property name="jvmRoute" readOnly="false"/>
@@ -34,12 +34,14 @@
<parameters>
<c:simple-property required="true" name="timeout" type="string" displayName="Session draining timeout"/>
<c:simple-property required="true" name="unit" default="MILLISECONDS" displayName="Time unit of the timeout parameter">
- <c:property-options allowCustomValue="false">
- <c:option value="MICROSECONDS" name="MICROSECONDS"/>
+ <c:property-options allowCustomValue="false">
+ <c:option value="MICROSECONDS" name="MICROSECONDS"/>
<c:option value="MILLISECONDS" name="MILLISECONDS"/>
<c:option value="NANOSECONDS" name="NANOSECONDS"/>
- <c:option value="SECONDS" name="SECONDS"/>
- </c:property-options>
+ <c:option value="SECONDS" name="SECONDS"/>
+ <c:option value="HOURS" name="HOURS"/>
+ <c:option value="DAYS" name="DAYS"/>
+ </c:property-options>
</c:simple-property>
</parameters>
<results>
@@ -56,7 +58,7 @@
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
- </operation>
+ </operation>
<operation name="reset" displayName="Reset the node" description="Move the node out of an error state." />
<operation name="disable" displayName="Disable all webpapps" description="Disable all webapps for all engines.">
<results>
@@ -71,7 +73,6 @@
</operation>
<operation name="refresh" displayName="Refresh configuration" description="Refresh configuration" />
-
<metric property="proxyConfiguration" displayName="Proxy Configuration" displayType="summary" dataType="trait" />
<metric property="modelerType" displayName="Type of the modeled resource" displayType="summary" dataType="trait" />
<metric property="className" displayName="Fully qualified class name of the managed object" displayType="summary" dataType="trait" />
@@ -87,7 +88,7 @@
<c:simple-property name="stickySessionForce" type="boolean" description="Return an error when the request cannot be routed to the right node."/>
<c:simple-property name="balancer" type="string" required="false" description="Name of the balancer."/>
<c:simple-property name="flushPackets" type="boolean" description="Allows controlling flusing of packets."/>
- <c:simple-property name="socketTimeout" type="integer" description="Connection timeout for communication with the proxy." />
+ <c:simple-property name="socketTimeout" type="integer" description="Connection timeout for communication with the proxy." />
<c:simple-property name="domain" type="string" required="false" description="Domain parameter, which allows tying a jvmRoute to a particular domain."/>
<c:simple-property name="advertisePort" type="integer" required="false" description="Multicast port for discovery" />
<c:simple-property name="advertiseGroupAddress" type="string" required="false" description="Multicast address for discovery."/>
@@ -130,6 +131,5 @@
</operation>
</service>
-
</service>
</plugin>
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index 57aed4d..0f644fc 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -53,6 +53,7 @@ import org.rhq.core.pluginapi.operation.OperationResult;
/**
* @author Stefan Negrea
*/
+@SuppressWarnings("rawtypes")
@Test(groups = "modcluster-plugin")
public class ModclusterPluginTest {
private Log log = LogFactory.getLog(this.getClass());
@@ -104,6 +105,8 @@ public class ModclusterPluginTest {
log.info("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
List<String> typeNames = new ArrayList<String>() {
+ private static final long serialVersionUID = 1L;
+
{
add(PLUGIN_NAME);
add(PLUGIN_NAME + " Webapp Context");
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
index df7d222..625d8d4 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
@@ -21,8 +21,6 @@ package org.rhq.plugins.modcluster.test;
import java.io.IOException;
import java.io.InputStream;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.testng.annotations.Test;
import org.rhq.plugins.modcluster.ProxyInfo;
@@ -32,7 +30,6 @@ import org.rhq.plugins.modcluster.ProxyInfo;
*/
@Test(groups = "modcluster-plugin")
public class ProxyInfoTest {
- private Log log = LogFactory.getLog(this.getClass());
@Test
public void testProxyInfo() throws Exception {
commit d1fe493616de40914e8708fa7497bcfac5b32498
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 26 15:08:59 2011 -0500
Adding jvmRoute in the mix for webapp context identification. jvmRoute uniquely identifies nodes in a cluster and will be used to decide which contexts run on the node monitored by RHQ.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
index 7cefa46..35ecf30 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
@@ -25,8 +25,10 @@ package org.rhq.plugins.modcluster;
import java.util.HashSet;
import java.util.Set;
+import org.mc4j.ems.connection.EmsConnection;
import org.mc4j.ems.connection.bean.EmsBean;
+import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
@@ -37,26 +39,78 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
*
* @author Stefan Negrea
*/
+@SuppressWarnings("rawtypes")
public class ContextDiscoveryComponent implements ResourceDiscoveryComponent<MBeanResourceComponent> {
+ private final String JVM_ROUTE_PROPERTY = "jvmRoute";
+ private final String PROXY_INFO_PROPERTY = "proxyInfo";
+ private final String ADDITIONAL_CONFIG_BEAN_PROPERTY = "additionalConfigurationObjectName";
+
/* (non-Javadoc)
* @see org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext)
*/
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<MBeanResourceComponent> context) {
- Set<DiscoveredResourceDetails> entities = new HashSet<DiscoveredResourceDetails>();
+ String jvmRoute = this.getJvmRoute(context);
+ String rawProxyInfo = this.getRawProxyInfo(context);
- EmsBean statsBean = context.getParentResourceComponent().getEmsBean();
-
- String rawProxyInfo = (String) statsBean.getAttribute("proxyInfo").refresh().toString();
ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+ Set<DiscoveredResourceDetails> entities = new HashSet<DiscoveredResourceDetails>();
for (ProxyInfo.Context availableContext : proxyInfo.getAvailableContexts()) {
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(context.getResourceType(),
- availableContext.toString(), availableContext.toString(), null, "mod_cluster Webapp Context", null,
+ availableContext.createKey(), availableContext.createName(), null, "mod_cluster Webapp Context", null,
null);
entities.add(detail);
}
return entities;
}
+
+ /**
+ * Retrieves the jvm route for the node from the parent context.
+ *
+ * @param context the discovery context
+ * @return node's jvm route
+ */
+ private String getJvmRoute(ResourceDiscoveryContext<MBeanResourceComponent> context) {
+ Configuration pluginConfig = context.getParentResourceComponent().getResourceContext().getPluginConfiguration();
+ String objectName = pluginConfig.getSimple(ADDITIONAL_CONFIG_BEAN_PROPERTY).getStringValue();
+ EmsBean engineBean = this.loadBean(objectName, context.getParentResourceComponent());
+
+ return (String) engineBean.getAttribute(JVM_ROUTE_PROPERTY).refresh().toString();
+ }
+
+ /**
+ * Retrieves raw proxy configuration from the parent context.
+ *
+ * @param context the discovery context
+ * @return raw proxy configuration
+ */
+ private String getRawProxyInfo(ResourceDiscoveryContext<MBeanResourceComponent> context) {
+ EmsBean statsBean = context.getParentResourceComponent().getEmsBean();
+ return (String) statsBean.getAttribute(PROXY_INFO_PROPERTY).refresh().toString();
+ }
+
+ /**
+ * Loads the bean with the given object name.
+ *
+ * Subclasses are free to override this method in order to load the bean.
+ *
+ * @param objectName the name of the bean to load
+ * @return the bean that is loaded
+ */
+ protected EmsBean loadBean(String objectName, MBeanResourceComponent context) {
+ EmsConnection emsConnection = context.getEmsConnection();
+ EmsBean bean = emsConnection.getBean(objectName);
+ if (bean == null) {
+ // In some cases, this resource component may have been discovered by some means other than querying its
+ // parent's EMSConnection (e.g. ApplicationDiscoveryComponent uses a filesystem to discover EARs and
+ // WARs that are not yet deployed). In such cases, getBean() will return null, since EMS won't have the
+ // bean in its cache. To cover such cases, make an attempt to query the underlying MBeanServer for the
+ // bean before giving up.
+ emsConnection.queryBeans(objectName);
+ bean = emsConnection.getBean(objectName);
+ }
+ return bean;
+ }
}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index 52dd287..591fef6 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -25,6 +25,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
* @author Stefan Negrea
*
*/
+@SuppressWarnings("rawtypes")
public class ModclusterServerComponent extends MBeanResourceComponent {
/* (non-Javadoc)
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
index 36f490d..4cca539 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
@@ -33,11 +33,35 @@ import java.util.regex.Pattern;
*/
public class ProxyInfo {
- private List<Context> availableContexts = new ArrayList<ProxyInfo.Context>();
+ private Map<String, Node> availableNodes = new HashMap<String, Node>();
private Map<String, Vhost> availableVhosts = new HashMap<String, Vhost>();
+ private List<Context> availableContexts = new ArrayList<ProxyInfo.Context>();
public ProxyInfo(String rawProxyInfo) {
- Pattern vhostPattern = Pattern.compile("Vhost.*\n");
+ parseNodes(rawProxyInfo);
+ parseVhosts(rawProxyInfo);
+ parseContexts(rawProxyInfo);
+ }
+
+ private void parseNodes(String rawProxyInfo) {
+ Pattern nodePattern = Pattern.compile("Node:.*\n");
+ Matcher nodeMatcher = nodePattern.matcher(rawProxyInfo);
+ while (nodeMatcher.find()) {
+ String rawNode = nodeMatcher.group();
+ String[] nodePieces = rawNode.split(",");
+
+ String identifier = nodePieces[0];
+ identifier = identifier.substring(identifier.indexOf("[") + 1, identifier.indexOf("]"));
+
+ String jvmRoute = nodePieces[1];
+ jvmRoute = jvmRoute.substring(jvmRoute.indexOf(':')).trim();
+
+ availableNodes.put(jvmRoute, new Node(jvmRoute, identifier));
+ }
+ }
+
+ private void parseVhosts(String rawProxyInfo) {
+ Pattern vhostPattern = Pattern.compile("Vhost:.*\n");
Matcher vhostMatcher = vhostPattern.matcher(rawProxyInfo);
while (vhostMatcher.find()) {
String rawVhost = vhostMatcher.group();
@@ -52,8 +76,10 @@ public class ProxyInfo {
availableVhosts.put(identifier, new Vhost(identifier, host));
}
+ }
- Pattern contextPattern = Pattern.compile("Context.*[\n|}]");
+ private void parseContexts(String rawProxyInfo) {
+ Pattern contextPattern = Pattern.compile("Context:.*[\n|}]");
Matcher contextMatcher = contextPattern.matcher(rawProxyInfo);
while (contextMatcher.find()) {
String rawContext = contextMatcher.group();
@@ -70,7 +96,7 @@ public class ProxyInfo {
Vhost relatedVhost = availableVhosts.get(identifier);
- availableContexts.add(new Context(relatedVhost.getHost(), actualContext, isEnabled));
+ availableContexts.add(new Context("", relatedVhost.getHost(), actualContext, isEnabled));
}
}
@@ -82,7 +108,60 @@ public class ProxyInfo {
return Collections.unmodifiableList(new ArrayList<Vhost>(availableVhosts.values()));
}
- private static class Vhost {
+ public List<Node> getAvailableNodes() {
+ return Collections.unmodifiableList(new ArrayList<Node>(availableNodes.values()));
+ }
+
+ public static class Node {
+ private String jvmRoute;
+ private String nodeId;
+
+ public Node(String jvmRoute, String nodeId) {
+ this.jvmRoute = jvmRoute;
+ this.nodeId = nodeId;
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public String getJvmRoute() {
+ return jvmRoute;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((jvmRoute == null) ? 0 : jvmRoute.hashCode());
+ result = prime * result + ((nodeId == null) ? 0 : nodeId.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Node other = (Node) obj;
+ if (jvmRoute == null) {
+ if (other.jvmRoute != null)
+ return false;
+ } else if (!jvmRoute.equals(other.jvmRoute))
+ return false;
+ if (nodeId == null) {
+ if (other.nodeId != null)
+ return false;
+ } else if (!nodeId.equals(other.nodeId))
+ return false;
+ return true;
+ }
+ }
+
+ public static class Vhost {
private String identifier;
private String host;
@@ -99,20 +178,52 @@ public class ProxyInfo {
return host;
}
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((host == null) ? 0 : host.hashCode());
+ result = prime * result + ((identifier == null) ? 0 : identifier.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Vhost other = (Vhost) obj;
+ if (host == null) {
+ if (other.host != null)
+ return false;
+ } else if (!host.equals(other.host))
+ return false;
+ if (identifier == null) {
+ if (other.identifier != null)
+ return false;
+ } else if (!identifier.equals(other.identifier))
+ return false;
+ return true;
+ }
}
public static class Context {
private String path;
private String host;
+ private String jvmRoute;
private boolean isEnabled;
- public Context(String host, String path) {
- this(path, host, false);
+ public Context(String jvmRoute, String host, String path) {
+ this(jvmRoute, host, path, false);
}
- public Context(String host, String path, boolean isEnabled) {
- this.path = path;
+ public Context(String jvmRoute, String host, String path, boolean isEnabled) {
+ this.jvmRoute = jvmRoute;
this.host = host;
+ this.path = path;
this.isEnabled = isEnabled;
}
@@ -124,13 +235,25 @@ public class ProxyInfo {
return host;
}
+ public String getJvmRoute() {
+ return jvmRoute;
+ }
+
public boolean isEnabled() {
return isEnabled;
}
+ public String createKey() {
+ return jvmRoute + ":" + host + ":" + path;
+ }
+
+ public String createName() {
+ return host + ":" + path;
+ }
+
@Override
public String toString() {
- return host + ":" + path;
+ return createKey();
}
@Override
@@ -138,6 +261,7 @@ public class ProxyInfo {
final int prime = 31;
int result = 1;
result = prime * result + ((host == null) ? 0 : host.hashCode());
+ result = prime * result + ((jvmRoute == null) ? 0 : jvmRoute.hashCode());
result = prime * result + ((path == null) ? 0 : path.hashCode());
return result;
}
@@ -156,6 +280,11 @@ public class ProxyInfo {
return false;
} else if (!host.equals(other.host))
return false;
+ if (jvmRoute == null) {
+ if (other.jvmRoute != null)
+ return false;
+ } else if (!jvmRoute.equals(other.jvmRoute))
+ return false;
if (path == null) {
if (other.path != null)
return false;
@@ -164,9 +293,13 @@ public class ProxyInfo {
return true;
}
- public static Context fromString(String stringRepresentation) {
- String part[] = stringRepresentation.trim().split(":");
- return new Context(part[1], part[0]);
+ public static Context fromString(String stringRepresentation) throws Exception {
+ String parts[] = stringRepresentation.trim().split(":");
+ if (parts.length < 3) {
+ throw new Exception("Parsing error. Not enough information to create a context.");
+ }
+
+ return new Context(parts[0], parts[1], parts[2]);
}
}
}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index b1a0f51..3c01b30 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -25,7 +25,9 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="Catalina:type=ModClusterListener,*"/>
- <c:simple-property name="nameTemplate" default="mod_cluster"/>
+ <c:simple-property name="additionalConfigurationObjectName" readOnly="true" default="jboss.web:type=Engine"/>
+ <c:simple-property name="jvmRoute" readOnly="false"/>
+ <c:simple-property name="nameTemplate" default="mod_cluster"/>
</plugin-configuration>
<operation name="stop" displayName="Stop all webapps" description="Gracefully stops all webapps for all engines.">
@@ -129,6 +131,5 @@
</service>
-
</service>
</plugin>
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
index 8c8c6f4..df7d222 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
@@ -35,7 +35,7 @@ public class ProxyInfoTest {
private Log log = LogFactory.getLog(this.getClass());
@Test
- public void testProxyInfo() throws IOException {
+ public void testProxyInfo() throws Exception {
String[] availableFiles = new String[] { "/proxy_config/proxy_config_1.txt", "/proxy_config/proxy_config_2.txt" };
for (String testConfigurationFile : availableFiles) {
commit 9933f0e155e2274864458e042614ae8216768f5e
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jul 25 17:25:23 2011 +0200
BZ 725417 - if the 'default' attribute is missing on a required property, throw a descriptive exception instead of a NPE.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginConfigurationMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginConfigurationMetadataManagerBean.java
index 9b2d1db..3963f9d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginConfigurationMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginConfigurationMetadataManagerBean.java
@@ -106,8 +106,14 @@ public class PluginConfigurationMetadataManagerBean implements PluginConfigurati
for (PropertyDefinition propertyDef : updateReport.getNewPropertyDefinitions()) {
if (propertyDef.isRequired()) {
Property templateProperty = templateConfiguration.get(propertyDef.getName());
- pluginConfiguration.put(templateProperty.deepCopy(false));
- modified = true;
+ if (templateProperty==null) {
+ throw new IllegalArgumentException("The property [" + propertyDef.getName()
+ + "] marked as required in the configuration definition of [" + propertyDef.getConfigurationDefinition().getName()
+ + "] has no attribute 'default'");
+ } else {
+ pluginConfiguration.put(templateProperty.deepCopy(false));
+ modified = true;
+ }
}
}
commit 98365fa7de2d2859473dd0e3bbd68004b837ee57
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jul 25 07:54:06 2011 +0200
Extract the deploy-to-server-magic from createChild() and add tests to use this extracted code to deploy to domain and server-group.
diff --git a/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/UploadAndDeployTest.java b/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/UploadAndDeployTest.java
index 8581ada..2010640 100644
--- a/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/UploadAndDeployTest.java
+++ b/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/UploadAndDeployTest.java
@@ -26,7 +26,17 @@ import java.util.Map;
import org.codehaus.jackson.JsonNode;
import org.testng.annotations.Test;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.content.PackageDetailsKey;
+import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
+import org.rhq.core.domain.resource.CreateResourceStatus;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.modules.plugins.jbossas7.ASConnection;
+import org.rhq.modules.plugins.jbossas7.BaseComponent;
+import org.rhq.modules.plugins.jbossas7.json.Address;
import org.rhq.modules.plugins.jbossas7.json.CompositeOperation;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
@@ -292,7 +302,7 @@ public class UploadAndDeployTest extends AbstractIntegrationTest {
/**
* Test uploading to domain only, but not to a server group
- * @throws Exception
+ * @throws Exception if anything goes wrong.
*/
@Test(timeOut = 60*1000L,enabled = isEnabled)
public void testUploadComposite2() throws Exception {
@@ -346,4 +356,77 @@ public class UploadAndDeployTest extends AbstractIntegrationTest {
}
+ /**
+ * Test the real API code for uploading - case 1: just upload to /deployment
+ * @throws Exception if anything goes wrong.
+ */
+ @Test
+ public void testUploadViaCreateChild1() throws Exception {
+
+ BaseComponent bc = new BaseComponent();
+ bc.setConnection(getASConnection());
+ bc.setPath("");
+ ResourceType rt = new ResourceType();
+ rt.setName("Deployment");
+ Resource resource = new Resource("deployment="+TEST_WAR,TEST_WAR,rt); // TODO resource key?
+ ResourceContext context = new ResourceContext(resource,null,null,null,null,null,null,null,null,null,null,null);
+ bc.start(context);
+
+ String bytes_value = uploadToAs(TEST_WAR);
+
+ ResourcePackageDetails details = new ResourcePackageDetails(new PackageDetailsKey(TEST_WAR,"1.0","deployment","all"));
+ CreateResourceReport report = new CreateResourceReport(TEST_WAR,rt,new Configuration(), new Configuration(),details);
+ try {
+ report = bc.runDeploymentMagicOnServer(report,TEST_WAR,TEST_WAR,bytes_value);
+ assert report != null;
+ assert report.getErrorMessage()==null: "Report contained an unexpected error: " + report.getErrorMessage();
+ assert report.getStatus()!=null : "Report did not contain a status";
+ assert report.getStatus()== CreateResourceStatus.SUCCESS : "Status was no success";
+ assert report.getResourceName().equals(TEST_WAR);
+ assert report.getResourceKey().equals("deployment=" + TEST_WAR);
+ } finally {
+ Remove r =new Remove("deployment",TEST_WAR);
+ getASConnection().execute(r);
+ }
+
+ }
+
+ /**
+ * Test the real API code for uploading - case 2: upload to /deployment and a server group
+ * @throws Exception if anything goes wrong.
+ */
+ @Test
+ public void testUploadViaCreateChild2() throws Exception {
+
+ BaseComponent bc = new BaseComponent();
+ bc.setConnection(getASConnection());
+ bc.setPath("server-group=main-server-group");
+ ResourceType rt = new ResourceType();
+ rt.setName("Deployment");
+ Resource resource = new Resource("server-group=main-server-group",TEST_WAR,rt);
+ ResourceContext context = new ResourceContext(resource,null,null,null,null,null,null,null,null,null,null,null);
+ bc.start(context);
+
+ String bytes_value = uploadToAs(TEST_WAR);
+
+ ResourcePackageDetails details = new ResourcePackageDetails(new PackageDetailsKey(TEST_WAR,"1.0","deployment","all"));
+ CreateResourceReport report = new CreateResourceReport(TEST_WAR,rt,new Configuration(), new Configuration(),details);
+ try {
+ report = bc.runDeploymentMagicOnServer(report,TEST_WAR,TEST_WAR,bytes_value);
+ assert report != null;
+ assert report.getErrorMessage()==null: "Report contained an unexpected error: " + report.getErrorMessage();
+ assert report.getStatus()!=null : "Report did not contain a status";
+ assert report.getStatus()== CreateResourceStatus.SUCCESS : "Status was no success";
+ assert report.getResourceName().equals(TEST_WAR);
+ assert report.getResourceKey().equals("server-group=main-server-group,deployment=" + TEST_WAR) : "Resource key was wrong";
+ } finally {
+ Address sgd = new Address("server-group","main-server-group");
+ sgd.add("deployment", TEST_WAR);
+ Remove r =new Remove(sgd);
+ getASConnection().execute(r);
+ r =new Remove("deployment",TEST_WAR);
+ getASConnection().execute(r);
+ }
+
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 83b221b..8851706 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -331,18 +331,34 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
fileName=fileName.substring("C:\\fakepath\\".length());
}
- boolean toServerGroup = context.getResourceKey().contains("server-group=");
- log.info("Deploying [" + fileName + "] to domain only= " + !toServerGroup + " ...");
String tmpName = fileName; // TODO figure out the tmp-name biz with the AS guys
JsonNode resultNode = uploadResult.get("result");
String hash = resultNode.get("BYTES_VALUE").getTextValue();
+ return runDeploymentMagicOnServer(report, fileName, tmpName, hash);
+
+ }
+
+ /**
+ * Do the actual fumbling with the domain api to deploy the uploaded content
+ * @param report CreateResourceReport to report the result
+ * @param runtimeName File name to use as runtime name
+ * @param deploymentName Name of the deployment
+ * @param hash Hash of the content bytes
+ * @return the passed report with success or failure settings
+ */
+ public CreateResourceReport runDeploymentMagicOnServer(CreateResourceReport report, String runtimeName,
+ String deploymentName, String hash) {
+
+ boolean toServerGroup = context.getResourceKey().contains("server-group=");
+ log.info("Deploying [" + runtimeName + "] to domain only= " + !toServerGroup + " ...");
+
ASConnection connection = getASConnection();
- Operation step1 = new Operation("add","deployment",tmpName);
+ Operation step1 = new Operation("add","deployment",deploymentName);
// step1.addAdditionalProperty("hash", new PROPERTY_VALUE("BYTES_VALUE", hash));
List<Object> content = new ArrayList<Object>(1);
Map<String,Object> contentValues = new HashMap<String,Object>();
@@ -350,8 +366,8 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
content.add(contentValues);
step1.addAdditionalProperty("content",content);
- step1.addAdditionalProperty("name", tmpName);
- step1.addAdditionalProperty("runtime-name", fileName);
+ step1.addAdditionalProperty("name", deploymentName);
+ step1.addAdditionalProperty("runtime-name", runtimeName);
String resourceKey;
Result result ;
@@ -379,7 +395,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>();
serverGroupAddress.addAll(pathToAddress(context.getResourceKey()));
- serverGroupAddress.add(new PROPERTY_VALUE("deployment", tmpName));
+ serverGroupAddress.add(new PROPERTY_VALUE("deployment", deploymentName));
Operation step2 = new Operation("add",serverGroupAddress);
cop.addStep(step2);
@@ -403,13 +419,12 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
}
else {
report.setStatus(CreateResourceStatus.SUCCESS);
- report.setResourceName(fileName);
+ report.setResourceName(runtimeName);
report.setResourceKey(resourceKey);
log.info(" ... with success and key [" + resourceKey + "]" );
}
return report;
-
}
@Override
commit 066fa71d4b3943ae6845d40c58c160e5c0c0631a
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Jul 22 14:31:38 2011 -0500
Added support for stopContext operation for webapp contexts. Updated service description. Added more complex integration tests for webapp context service.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
index 42a1d6e..23d7d62 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
@@ -18,6 +18,8 @@
*/
package org.rhq.plugins.modcluster;
+import java.util.concurrent.TimeUnit;
+
import org.mc4j.ems.connection.bean.EmsBean;
import org.rhq.core.domain.configuration.Configuration;
@@ -75,11 +77,14 @@ public class ContextComponent extends MBeanResourceComponent<MBeanResourceCompon
Object[] configuration = null;
if ("stopContext".equals(name)) {
configuration = new Object[] { context.getHost(), context.getPath(),
- parameters.getSimple("timeout").getLongValue(), parameters.getSimple("unit").getStringValue() };
+ parameters.getSimple("timeout").getLongValue(),
+ TimeUnit.valueOf(parameters.getSimple("unit").getStringValue()) };
} else {
configuration = new Object[] { context.getHost(), context.getPath() };
}
+ log.info(name + " - " + context.getHost() + " " + context.getPath());
+
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
index 4b3adcd..7cefa46 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
@@ -52,7 +52,8 @@ public class ContextDiscoveryComponent implements ResourceDiscoveryComponent<MBe
for (ProxyInfo.Context availableContext : proxyInfo.getAvailableContexts()) {
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(context.getResourceType(),
- availableContext.toString(), availableContext.toString(), null, "mod_cluster Context", null, null);
+ availableContext.toString(), availableContext.toString(), null, "mod_cluster Webapp Context", null,
+ null);
entities.add(detail);
}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 70a9f2b..b1a0f51 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -2,6 +2,7 @@
<plugin name="mod_cluster"
displayName="mod_cluster"
+ description="Monitoring and management of mod_cluster plugin."
version="1.0"
package="org.rhq.plugins.modcluster"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -77,7 +78,7 @@
<c:simple-property name="workerTimeout" type="integer" description="Timeout to wait for an available worker (default is no wait)" />
<c:simple-property name="stickySession" type="boolean" description="Enables sticky session for the cluster."/>
<c:simple-property name="stickySessionRemove" type="boolean" description="Remove session when the request cannot be routed to the right node."/>
- <c:simple-property name="advertise" type="boolean" description="Enable autodiscovery of httpd servers."/>
+ <!-- c:simple-property name="advertise" type="boolean" description="Enable autodiscovery of httpd servers."/-->
<c:simple-property name="smax" type="integer" description="Maximum time on seconds for idle connections above smax."/>
<c:simple-property name="maxAttempts" type="integer" description="Maximum number of attempts to send the request to the backend server."/>
<c:simple-property name="advertiseSecurityKey" type="string" required="false" description="Security key for discovery."/>
@@ -95,7 +96,7 @@
<service name="mod_cluster Webapp Context"
discovery="ContextDiscoveryComponent"
class="ContextComponent"
- description="A mod_cluster context">
+ description="mod_cluster webapp context">
<operation name="disableContext" displayName="Disable webapp" description="Disable this webapp.">
<results>
@@ -110,7 +111,9 @@
<c:option value="MICROSECONDS" name="MICROSECONDS"/>
<c:option value="MILLISECONDS" name="MILLISECONDS"/>
<c:option value="NANOSECONDS" name="NANOSECONDS"/>
- <c:option value="SECONDS" name="SECONDS"/>
+ <c:option value="SECONDS" name="SECONDS"/>
+ <c:option value="HOURS" name="HOURS"/>
+ <c:option value="DAYS" name="DAYS"/>
</c:property-options>
</c:simple-property>
</parameters>
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index 8bead55..57aed4d 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -33,6 +33,8 @@ import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import org.rhq.core.clientapi.server.discovery.InventoryReport;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.measurement.MeasurementData;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.MeasurementReport;
@@ -159,11 +161,23 @@ public class ModclusterPluginTest {
try {
OperationResult result = ((OperationFacet) resourceComponent).invokeOperation("enableContext", null);
log.info("Result of operation " + "enableContext" + " was: " + result.getSimpleResult());
+
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("timeout", "1000"));
+ config.put(new PropertySimple("unit", java.util.concurrent.TimeUnit.SECONDS));
+ result = ((OperationFacet) resourceComponent).invokeOperation("stopContext", config);
+ log.info("Result of operation stopContext was: " + result.getSimpleResult());
+
+ result = ((OperationFacet) resourceComponent).invokeOperation("enableContext", null);
+ log.info("Result of operation enableContext was: " + result.getSimpleResult());
+
+ result = ((OperationFacet) resourceComponent).invokeOperation("disableContext", null);
+ log.info("Result of operation disableContext was: " + result.getSimpleResult());
+
} catch (Exception e) {
- log.info("Operation failed");
+ log.info("Operation failed. ", e);
}
- /*result = ((OperationFacet) resourceComponent).invokeOperation("disable", null);
- log.info("Result of operation test was: " + result.getSimpleResult());*/
+
}
}
commit df80d823044c1566232df99540628507ac32e136
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 19 23:16:19 2011 -0500
Returning back to simple availability methods (no availability collectors) after getting clarifications from the mod_cluster team with regards to JMX attributes and node refresh operations.
The simple method to get availability now works correctly for mod_cluster resources.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
index 8512ed5..42a1d6e 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
@@ -42,15 +42,19 @@ public class ContextComponent extends MBeanResourceComponent<MBeanResourceCompon
try {
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
String rawProxyInfo = (String) getEmsBean().getAttribute("proxyInfo").refresh().toString();
+
ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
ProxyInfo.Context context = ProxyInfo.Context.fromString(resourceContext.getResourceKey());
- ProxyInfo.Context currentContext = proxyInfo.getAvailableContexts().get(
- proxyInfo.getAvailableContexts().indexOf(context));
+ int indexOfCurrentContext = proxyInfo.getAvailableContexts().indexOf(context);
+
+ if (indexOfCurrentContext != -1) {
+ ProxyInfo.Context currentContext = proxyInfo.getAvailableContexts().get(indexOfCurrentContext);
- if (currentContext.isEnabled()) {
- return AvailabilityType.UP;
+ if (currentContext.isEnabled()) {
+ return AvailabilityType.UP;
+ }
}
return AvailabilityType.DOWN;
@@ -68,12 +72,18 @@ public class ContextComponent extends MBeanResourceComponent<MBeanResourceCompon
ProxyInfo.Context context = ProxyInfo.Context.fromString(resourceContext.getResourceKey());
+ Object[] configuration = null;
+ if ("stopContext".equals(name)) {
+ configuration = new Object[] { context.getHost(), context.getPath(),
+ parameters.getSimple("timeout").getLongValue(), parameters.getSimple("unit").getStringValue() };
+ } else {
+ configuration = new Object[] { context.getHost(), context.getPath() };
+ }
+
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
-
- Object resultObject = getEmsBean().getOperation(name).invoke(
- new Object[] { context.getHost(), context.getPath() });
+ Object resultObject = getEmsBean().getOperation(name).invoke(configuration);
return new OperationResult(String.valueOf(resultObject));
} finally {
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index e6495a1..52dd287 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -18,13 +18,7 @@
*/
package org.rhq.plugins.modcluster;
-import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.pluginapi.availability.AvailabilityCollectorRunnable;
-import org.rhq.core.pluginapi.availability.AvailabilityFacet;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.plugins.jmx.MBeanResourceComponent;
/**
@@ -33,66 +27,18 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
*/
public class ModclusterServerComponent extends MBeanResourceComponent {
- private AvailabilityCollectorRunnable availabilityCollector;
-
- /* (non-Javadoc)
- * @see org.rhq.plugins.jmx.MBeanResourceComponent#start(org.rhq.core.pluginapi.inventory.ResourceContext)
- */
- @Override
- public void start(ResourceContext context) {
-
- availabilityCollector = context.createAvailabilityCollectorRunnable(new AvailabilityFacet() {
- public AvailabilityType getAvailability() {
- try {
- OperationResult result = ModclusterServerComponent.this.invokeOperation("refresh",
- new Configuration());
-
- int numberOfAttempts = 0;
-
- //The configuration should be loaded in less than 20 attempts.
- //Only in extraneous cases (like network overload or a huge list webapp contexts)
- //it can take more than this.
- while (numberOfAttempts < 20) {
- String rawProxyInfo = (String) getEmsBean().getAttribute("proxyInfo").refresh().toString();
- ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
-
- if (proxyInfo.getAvailableContexts().size() != 0) {
- break;
- }
-
- numberOfAttempts++;
- Thread.sleep(2000);
- }
- } catch (Exception e) {
- log.info("mod_cluster availability update failed. Node configuration could not be refreshed.", e);
- return AvailabilityType.DOWN;
- }
-
- return ModclusterServerComponent.super.getAvailability();
- }
- }, 60000L); // 1 minute - the minimum interval allowed
-
- // Now that you've created your availability collector, you must start it. Once started,
- // it is assigned a thread in a thread pool and begins periodically collecting availability.
- availabilityCollector.start();
-
- super.start(context);
- }
-
- /**
- * Cleans the old resource context and the old MBean.
- * @see ResourceComponent#stop()
- */
- public void stop() {
- availabilityCollector.stop();
- super.stop();
- }
-
/* (non-Javadoc)
* @see org.rhq.plugins.jmx.MBeanResourceComponent#getAvailability()
*/
@Override
public AvailabilityType getAvailability() {
- return availabilityCollector.getLastKnownAvailability();
+ String rawProxyInfo = (String) getEmsBean().getAttribute("proxyInfo").refresh().toString();
+ ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+
+ if (proxyInfo.getAvailableContexts().size() == 0) {
+ return AvailabilityType.DOWN;
+ }
+
+ return super.getAvailability();
}
}
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
index c517364..36f490d 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
@@ -34,7 +34,7 @@ import java.util.regex.Pattern;
public class ProxyInfo {
private List<Context> availableContexts = new ArrayList<ProxyInfo.Context>();
- private Map<String, Vhost> availableVHosts = new HashMap<String, Vhost>();
+ private Map<String, Vhost> availableVhosts = new HashMap<String, Vhost>();
public ProxyInfo(String rawProxyInfo) {
Pattern vhostPattern = Pattern.compile("Vhost.*\n");
@@ -50,7 +50,7 @@ public class ProxyInfo {
String host = vhostPieces[1].trim();
host = host.substring(host.indexOf(":") + 1).trim();
- availableVHosts.put(identifier, new Vhost(identifier, host));
+ availableVhosts.put(identifier, new Vhost(identifier, host));
}
Pattern contextPattern = Pattern.compile("Context.*[\n|}]");
@@ -68,7 +68,7 @@ public class ProxyInfo {
rawIsEnabled = rawIsEnabled.substring(rawIsEnabled.indexOf(':') + 1).trim();
boolean isEnabled = rawIsEnabled.equals("ENABLED") ? true : false;
- Vhost relatedVhost = availableVHosts.get(identifier);
+ Vhost relatedVhost = availableVhosts.get(identifier);
availableContexts.add(new Context(relatedVhost.getHost(), actualContext, isEnabled));
}
@@ -78,6 +78,10 @@ public class ProxyInfo {
return Collections.unmodifiableList(availableContexts);
}
+ public List<Vhost> getAvailableVhosts() {
+ return Collections.unmodifiableList(new ArrayList<Vhost>(availableVhosts.values()));
+ }
+
private static class Vhost {
private String identifier;
private String host;
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index b7322bd..8bead55 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -72,7 +72,7 @@ public class ModclusterPluginTest {
log.info("...Loaded plugin: " + plugin);
}
} catch (Exception e) {
- e.printStackTrace();
+ log.info("Error initializing the context", e);
}
}
@@ -93,19 +93,13 @@ public class ModclusterPluginTest {
public void testDiscovery() throws Exception {
InventoryReport report = PluginContainer.getInstance().getInventoryManager().executeServerScanImmediately();
assert report != null;
- System.out.println("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+ log.info("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
- Thread.sleep(10000);
+ Thread.sleep(1000);
report = PluginContainer.getInstance().getInventoryManager().executeServiceScanImmediately();
assert report != null;
- System.out.println("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
-
- Thread.sleep(10000);
-
- report = PluginContainer.getInstance().getInventoryManager().executeServiceScanImmediately();
- assert report != null;
- System.out.println("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+ log.info("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
List<String> typeNames = new ArrayList<String>() {
{
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
index fb1ccba..8c8c6f4 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
@@ -50,10 +50,21 @@ public class ProxyInfoTest {
+ ProxyInfo.Context.class.getCanonicalName();
}
- assert (proxyInfo.getAvailableContexts().size() != 0) : "Raw proxy info parsing failed!";
+ assert (proxyInfo.getAvailableContexts().size() != 0) : "Raw proxy info parsing failed to parse application contexts!";
+ assert (proxyInfo.getAvailableVhosts().size() != 0) : "Raw proxy info parsing failed to parse vhosts!";
}
}
+ @Test
+ public void testProxyInfoWithEmptyConfig() throws IOException {
+ String testConfigurationFile = "/proxy_config/proxy_config_empty.txt";
+ String testConfiguration = readConfigFile(testConfigurationFile);
+ ProxyInfo proxyInfo = new ProxyInfo(testConfiguration);
+
+ assert (proxyInfo.getAvailableContexts().size() == 0) : "Raw proxy info parsing failed to parse an empty proxy config.";
+ assert (proxyInfo.getAvailableVhosts().size() == 0) : "Raw proxy info parsing failed to parse an empty proxy config.";
+ }
+
private String readConfigFile(String filePath) throws IOException {
StringBuffer tempBuffer = new StringBuffer();
byte[] readBuffer = new byte[1024];
commit e7be518553e576305b16109aa4e98826ce7d00ae
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Jul 15 15:40:54 2011 -0500
Implemented getAvailability using the async collector because there is no guarantee when node full refreshes its configuration. The configuration is read from the httpd proxy and parsed; so network latency and number of loaded contexts influence the reload time.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index ef13143..e6495a1 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -20,6 +20,10 @@ package org.rhq.plugins.modcluster;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.pluginapi.availability.AvailabilityCollectorRunnable;
+import org.rhq.core.pluginapi.availability.AvailabilityFacet;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.plugins.jmx.MBeanResourceComponent;
@@ -29,14 +33,66 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
*/
public class ModclusterServerComponent extends MBeanResourceComponent {
+ private AvailabilityCollectorRunnable availabilityCollector;
+
+ /* (non-Javadoc)
+ * @see org.rhq.plugins.jmx.MBeanResourceComponent#start(org.rhq.core.pluginapi.inventory.ResourceContext)
+ */
@Override
- public AvailabilityType getAvailability() {
- try {
- OperationResult result = this.invokeOperation("refresh", new Configuration());
- } catch (Exception e) {
- log.info(e);
- }
+ public void start(ResourceContext context) {
+
+ availabilityCollector = context.createAvailabilityCollectorRunnable(new AvailabilityFacet() {
+ public AvailabilityType getAvailability() {
+ try {
+ OperationResult result = ModclusterServerComponent.this.invokeOperation("refresh",
+ new Configuration());
+
+ int numberOfAttempts = 0;
+
+ //The configuration should be loaded in less than 20 attempts.
+ //Only in extraneous cases (like network overload or a huge list webapp contexts)
+ //it can take more than this.
+ while (numberOfAttempts < 20) {
+ String rawProxyInfo = (String) getEmsBean().getAttribute("proxyInfo").refresh().toString();
+ ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+
+ if (proxyInfo.getAvailableContexts().size() != 0) {
+ break;
+ }
+
+ numberOfAttempts++;
+ Thread.sleep(2000);
+ }
+ } catch (Exception e) {
+ log.info("mod_cluster availability update failed. Node configuration could not be refreshed.", e);
+ return AvailabilityType.DOWN;
+ }
+
+ return ModclusterServerComponent.super.getAvailability();
+ }
+ }, 60000L); // 1 minute - the minimum interval allowed
- return super.getAvailability();
+ // Now that you've created your availability collector, you must start it. Once started,
+ // it is assigned a thread in a thread pool and begins periodically collecting availability.
+ availabilityCollector.start();
+
+ super.start(context);
+ }
+
+ /**
+ * Cleans the old resource context and the old MBean.
+ * @see ResourceComponent#stop()
+ */
+ public void stop() {
+ availabilityCollector.stop();
+ super.stop();
+ }
+
+ /* (non-Javadoc)
+ * @see org.rhq.plugins.jmx.MBeanResourceComponent#getAvailability()
+ */
+ @Override
+ public AvailabilityType getAvailability() {
+ return availabilityCollector.getLastKnownAvailability();
}
}
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index 874011a..b7322bd 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -87,7 +87,6 @@ public class ModclusterPluginTest {
PluginEnvironment pluginEnvironment = pluginManager.getPlugin(PLUGIN_NAME);
assert (pluginEnvironment != null) : "Null environment, plugin not loaded";
assert (pluginEnvironment.getPluginName().equals(PLUGIN_NAME));
-
}
@Test(dependsOnMethods = "testPluginLoad")
@@ -96,6 +95,14 @@ public class ModclusterPluginTest {
assert report != null;
System.out.println("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+ Thread.sleep(10000);
+
+ report = PluginContainer.getInstance().getInventoryManager().executeServiceScanImmediately();
+ assert report != null;
+ System.out.println("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+
+ Thread.sleep(10000);
+
report = PluginContainer.getInstance().getInventoryManager().executeServiceScanImmediately();
assert report != null;
System.out.println("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
@@ -103,7 +110,7 @@ public class ModclusterPluginTest {
List<String> typeNames = new ArrayList<String>() {
{
add(PLUGIN_NAME);
- add(PLUGIN_NAME + "_context");
+ add(PLUGIN_NAME + " Webapp Context");
}
};
diff --git a/modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_empty.txt b/modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_empty.txt
new file mode 100644
index 0000000..815b8a4
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_empty.txt
@@ -0,0 +1 @@
+{192.168.0.101/192.168.0.101:6666=null}
commit 19c02c04340a49aae6749166e175a96a4602f2d7
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 11 15:33:59 2011 -0500
A couple of small configuration and test corrections.
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index cf12b89..70a9f2b 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -60,7 +60,7 @@
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
</operation>
- <operation name="refreshProxy" displayName="Remove a proxy" description="Remove a proxy.">
+ <operation name="removeProxy" displayName="Remove a proxy" description="Remove a proxy.">
<parameters>
<c:simple-property required="true" name="host" type="string" displayName="Proxy address"/>
<c:simple-property required="true" name="port" type="string" displayName="Proxy port"/>
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
index 41bf26a..fb1ccba 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
@@ -36,7 +36,6 @@ public class ProxyInfoTest {
@Test
public void testProxyInfo() throws IOException {
-
String[] availableFiles = new String[] { "/proxy_config/proxy_config_1.txt", "/proxy_config/proxy_config_2.txt" };
for (String testConfigurationFile : availableFiles) {
@@ -44,10 +43,6 @@ public class ProxyInfoTest {
ProxyInfo proxyInfo = new ProxyInfo(testConfiguration);
for (ProxyInfo.Context context : proxyInfo.getAvailableContexts()) {
- log.info(context.toString() + " - " + context.isEnabled());
-
- log.info(proxyInfo.getAvailableContexts().indexOf(context));
-
assert (proxyInfo.getAvailableContexts().indexOf(context) != -1) : "Equals and hash functions not implemented correctly for "
+ ProxyInfo.Context.class.getCanonicalName();
commit 8f5f1559d0d45b7405334d588b5272254ac119c9
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 11 15:33:39 2011 -0500
The configuration needs to be refreshed before computing availability on all the contexts. Attempt to correctly invoke the operation.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index 783f579..ef13143 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -18,6 +18,9 @@
*/
package org.rhq.plugins.modcluster;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.plugins.jmx.MBeanResourceComponent;
/**
@@ -25,4 +28,15 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
*
*/
public class ModclusterServerComponent extends MBeanResourceComponent {
+
+ @Override
+ public AvailabilityType getAvailability() {
+ try {
+ OperationResult result = this.invokeOperation("refresh", new Configuration());
+ } catch (Exception e) {
+ log.info(e);
+ }
+
+ return super.getAvailability();
+ }
}
commit ae2f827b434bb95c2bcf76f7d5a3e1e07f910d90
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 11 13:23:22 2011 -0500
Added availability attribute for contexts. Also improved unit test and coverage.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
index 922197a..8512ed5 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
@@ -21,6 +21,7 @@ package org.rhq.plugins.modcluster;
import org.mc4j.ems.connection.bean.EmsBean;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.plugins.jmx.MBeanResourceComponent;
@@ -36,18 +37,43 @@ public class ContextComponent extends MBeanResourceComponent<MBeanResourceCompon
}
@Override
+ public AvailabilityType getAvailability() {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
+ String rawProxyInfo = (String) getEmsBean().getAttribute("proxyInfo").refresh().toString();
+ ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+
+ ProxyInfo.Context context = ProxyInfo.Context.fromString(resourceContext.getResourceKey());
+
+ ProxyInfo.Context currentContext = proxyInfo.getAvailableContexts().get(
+ proxyInfo.getAvailableContexts().indexOf(context));
+
+ if (currentContext.isEnabled()) {
+ return AvailabilityType.UP;
+ }
+
+ return AvailabilityType.DOWN;
+ } catch (Exception e) {
+ log.info(e);
+ return AvailabilityType.DOWN;
+ } finally {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
+
+ @Override
public OperationResult invokeOperation(String name, Configuration parameters) throws Exception {
if ("enableContext".equals(name) || "disableContext".equals(name) || "stopContext".equals(name)) {
ProxyInfo.Context context = ProxyInfo.Context.fromString(resourceContext.getResourceKey());
- System.out.println(context.toString());
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
Object resultObject = getEmsBean().getOperation(name).invoke(
- new Object[] { context.host, context.path });
+ new Object[] { context.getHost(), context.getPath() });
return new OperationResult(String.valueOf(resultObject));
} finally {
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
index 40b24f9..c517364 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
@@ -50,9 +50,7 @@ public class ProxyInfo {
String host = vhostPieces[1].trim();
host = host.substring(host.indexOf(":") + 1).trim();
- System.out.println(identifier + "--" + host);
availableVHosts.put(identifier, new Vhost(identifier, host));
-
}
Pattern contextPattern = Pattern.compile("Context.*[\n|}]");
@@ -65,9 +63,14 @@ public class ProxyInfo {
String identifier = contextPieces[0];
identifier = identifier.substring(identifier.indexOf("[") + 1, identifier.indexOf("]"));
identifier = identifier.substring(0, identifier.lastIndexOf(":"));
+
+ String rawIsEnabled = contextPieces[2];
+ rawIsEnabled = rawIsEnabled.substring(rawIsEnabled.indexOf(':') + 1).trim();
+ boolean isEnabled = rawIsEnabled.equals("ENABLED") ? true : false;
+
Vhost relatedVhost = availableVHosts.get(identifier);
- availableContexts.add(new Context(relatedVhost.getHost(), actualContext));
+ availableContexts.add(new Context(relatedVhost.getHost(), actualContext, isEnabled));
}
}
@@ -95,12 +98,18 @@ public class ProxyInfo {
}
public static class Context {
- String path;
- String host;
+ private String path;
+ private String host;
+ private boolean isEnabled;
public Context(String host, String path) {
+ this(path, host, false);
+ }
+
+ public Context(String host, String path, boolean isEnabled) {
this.path = path;
this.host = host;
+ this.isEnabled = isEnabled;
}
public String getPath() {
@@ -111,14 +120,49 @@ public class ProxyInfo {
return host;
}
+ public boolean isEnabled() {
+ return isEnabled;
+ }
+
@Override
public String toString() {
return host + ":" + path;
}
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((host == null) ? 0 : host.hashCode());
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Context other = (Context) obj;
+ if (host == null) {
+ if (other.host != null)
+ return false;
+ } else if (!host.equals(other.host))
+ return false;
+ if (path == null) {
+ if (other.path != null)
+ return false;
+ } else if (!path.equals(other.path))
+ return false;
+ return true;
+ }
+
public static Context fromString(String stringRepresentation) {
String part[] = stringRepresentation.trim().split(":");
- return new Context(part[0], part[1]);
+ return new Context(part[1], part[0]);
}
}
}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
index be5e987..41bf26a 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
@@ -37,15 +37,26 @@ public class ProxyInfoTest {
@Test
public void testProxyInfo() throws IOException {
- String testConfiguration = readConfigFile("/proxy_config/proxy_config_1.txt");
+ String[] availableFiles = new String[] { "/proxy_config/proxy_config_1.txt", "/proxy_config/proxy_config_2.txt" };
- ProxyInfo proxyInfo = new ProxyInfo(testConfiguration);
+ for (String testConfigurationFile : availableFiles) {
+ String testConfiguration = readConfigFile(testConfigurationFile);
+ ProxyInfo proxyInfo = new ProxyInfo(testConfiguration);
- for (ProxyInfo.Context context : proxyInfo.getAvailableContexts()) {
- log.info(context.toString());
- }
+ for (ProxyInfo.Context context : proxyInfo.getAvailableContexts()) {
+ log.info(context.toString() + " - " + context.isEnabled());
+
+ log.info(proxyInfo.getAvailableContexts().indexOf(context));
+
+ assert (proxyInfo.getAvailableContexts().indexOf(context) != -1) : "Equals and hash functions not implemented correctly for "
+ + ProxyInfo.Context.class.getCanonicalName();
- assert (proxyInfo.getAvailableContexts().size() != 0) : "Raw proxy info parsing failed!";
+ assert (context.equals(ProxyInfo.Context.fromString(context.toString())) == true) : "fromString and toString are not equivalent for:"
+ + ProxyInfo.Context.class.getCanonicalName();
+ }
+
+ assert (proxyInfo.getAvailableContexts().size() != 0) : "Raw proxy info parsing failed!";
+ }
}
private String readConfigFile(String filePath) throws IOException {
diff --git a/modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_2.txt b/modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_2.txt
new file mode 100644
index 0000000..573967a
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_2.txt
@@ -0,0 +1,16 @@
+{mobile-work/192.168.1.40:6666=Node: [1],Name: 4e6189af-0502-3305-8ff3-fad7fee8b516,Balancer: mycluster,LBGroup: ,Host: 127.0.0.1,Port: 8009,Type: ajp,Flushpackets: Off,Flushwait: 10,Ping: 10,Smax: 26,Ttl: 60,Elected: 3690,Read: 27864911,Transfered: 0,Connected: 0,Load: 100
+Node: [2],Name: node2,Balancer: mycluster,LBGroup: ,Host: 127.0.0.1,Port: 8009,Type: ajp,Flushpackets: Off,Flushwait: 10,Ping: 10,Smax: 26,Ttl: 60,Elected: 148,Read: 57994,Transfered: 0,Connected: 0,Load: 100
+Vhost: [1:1:1], Alias: test-agent-1
+Vhost: [2:1:2], Alias: remote-agent-2
+Context: [1:1:1], Context: /invoker, Status: DISABLED
+Context: [1:1:2], Context: /loaddemo, Status: DISABLED
+Context: [1:1:3], Context: /jbossws, Status: DISABLED
+Context: [1:1:4], Context: /juddi, Status: DISABLED
+Context: [1:1:5], Context: /jbossmq-httpil, Status: DISABLED
+Context: [1:1:6], Context: /web-console, Status: DISABLED
+Context: [1:1:7], Context: /jmx-console, Status: DISABLED
+Context: [1:1:8], Context: /, Status: DISABLED
+Context: [2:1:9], Context: /, Status: ENABLED
+Context: [2:1:10], Context: /loaddemo, Status: ENABLED
+Context: [2:1:11], Context: /juddi, Status: ENABLED
+Context: [2:1:12], Context: /invoker, Status: ENABLED}
\ No newline at end of file
commit 1ea6e2e37dd183c05072cbbc48e664deaa88da68
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 7 16:37:41 2011 -0500
Created separate unit test suite for proxy info parser. Also, the code now parses the vhost from the actual config property.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
index f2af2bc..40b24f9 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
@@ -20,7 +20,9 @@ package org.rhq.plugins.modcluster;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -32,17 +34,40 @@ import java.util.regex.Pattern;
public class ProxyInfo {
private List<Context> availableContexts = new ArrayList<ProxyInfo.Context>();
+ private Map<String, Vhost> availableVHosts = new HashMap<String, Vhost>();
public ProxyInfo(String rawProxyInfo) {
+ Pattern vhostPattern = Pattern.compile("Vhost.*\n");
+ Matcher vhostMatcher = vhostPattern.matcher(rawProxyInfo);
+ while (vhostMatcher.find()) {
+ String rawVhost = vhostMatcher.group();
+ String[] vhostPieces = rawVhost.split(",");
- Pattern test = Pattern.compile("Context.*\n");
- Matcher m = test.matcher(rawProxyInfo);
- while (m.find()) {
- String rawContext = m.group();
+ String identifier = vhostPieces[0].trim();
+ identifier = identifier.substring(identifier.indexOf("[") + 1, identifier.indexOf("]"));
+ identifier = identifier.substring(0, identifier.lastIndexOf(":"));
+
+ String host = vhostPieces[1].trim();
+ host = host.substring(host.indexOf(":") + 1).trim();
+
+ System.out.println(identifier + "--" + host);
+ availableVHosts.put(identifier, new Vhost(identifier, host));
+
+ }
+
+ Pattern contextPattern = Pattern.compile("Context.*[\n|}]");
+ Matcher contextMatcher = contextPattern.matcher(rawProxyInfo);
+ while (contextMatcher.find()) {
+ String rawContext = contextMatcher.group();
String[] contextPieces = rawContext.split(",");
String actualContext = contextPieces[1].substring(contextPieces[1].indexOf("/")).trim();
- availableContexts.add(new Context("localhost", actualContext));
+ String identifier = contextPieces[0];
+ identifier = identifier.substring(identifier.indexOf("[") + 1, identifier.indexOf("]"));
+ identifier = identifier.substring(0, identifier.lastIndexOf(":"));
+ Vhost relatedVhost = availableVHosts.get(identifier);
+
+ availableContexts.add(new Context(relatedVhost.getHost(), actualContext));
}
}
@@ -50,6 +75,25 @@ public class ProxyInfo {
return Collections.unmodifiableList(availableContexts);
}
+ private static class Vhost {
+ private String identifier;
+ private String host;
+
+ public Vhost(String identifier, String host) {
+ this.identifier = identifier;
+ this.host = host;
+ }
+
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ }
+
public static class Context {
String path;
String host;
@@ -63,18 +107,10 @@ public class ProxyInfo {
return path;
}
- public void setPath(String path) {
- this.path = path;
- }
-
public String getHost() {
return host;
}
- public void setHost(String host) {
- this.host = host;
- }
-
@Override
public String toString() {
return host + ":" + path;
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index 0d16e92..874011a 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -47,10 +47,9 @@ import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
-import org.rhq.plugins.modcluster.ProxyInfo;
/**
- * @author Fady Matar
+ * @author Stefan Negrea
*/
@Test(groups = "modcluster-plugin")
public class ModclusterPluginTest {
@@ -83,31 +82,6 @@ public class ModclusterPluginTest {
}
@Test
- public void testProxyInfo() {
- String test = "{mobile-work/192.168.1.40:6666=Node: [1],Name: 4e6189af-0502-3305-8ff3-fad7fee8b516,Balancer: mycluster,LBGroup: ,Host: 127.0.0.1,Port: 8009,Type: ajp,Flushpackets: Off,Flushwait: 10,Ping: 10,Smax: 26,Ttl: 60,Elected: 3233,Read: 7355619,Transfered: 0,Connected: 0,Load: 100\n"
- + "Node: [2],Name: node2,Balancer: mycluster,LBGroup: ,Host: 127.0.0.1,Port: 8009,Type: ajp,Flushpackets: Off,Flushwait: 10,Ping: 10,Smax: 26,Ttl: 60,Elected: 0,Read: 0,Transfered: 0,Connected: 0,Load: 99\n"
- + "Vhost: [1:1:1], Alias: localhost\n"
- + "Vhost: [2:1:2], Alias: localhost\n"
- + "Context: [1:1:1], Context: /invoker, Status: DISABLED\n"
- + "Context: [1:1:2], Context: /loaddemo, Status: DISABLED\n"
- + "Context: [1:1:3], Context: /jbossws, Status: DISABLED\n"
- + "Context: [1:1:4], Context: /juddi, Status: DISABLED\n"
- + "Context: [1:1:5], Context: /jbossmq-httpil, Status: DISABLED\n"
- + "Context: [1:1:6], Context: /web-console, Status: DISABLED\n"
- + "Context: [1:1:7], Context: /jmx-console, Status: DISABLED\n"
- + "Context: [1:1:8], Context: /, Status: DISABLED\n"
- + "Context: [2:1:9], Context: /loaddemo, Status: ENABLED\n" + "}";
-
- ProxyInfo proxyInfo = new ProxyInfo(test);
-
- for (ProxyInfo.Context context : proxyInfo.getAvailableContexts()) {
- log.info(context.toString());
- }
-
- assert (proxyInfo.getAvailableContexts().size() != 0) : "Raw proxy info parsing failed!";
- }
-
- @Test
public void testPluginLoad() {
PluginManager pluginManager = PluginContainer.getInstance().getPluginManager();
PluginEnvironment pluginEnvironment = pluginManager.getPlugin(PLUGIN_NAME);
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
new file mode 100644
index 0000000..be5e987
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
@@ -0,0 +1,66 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.testng.annotations.Test;
+
+import org.rhq.plugins.modcluster.ProxyInfo;
+
+/**
+ * @author Stefan Negrea
+ */
+@Test(groups = "modcluster-plugin")
+public class ProxyInfoTest {
+ private Log log = LogFactory.getLog(this.getClass());
+
+ @Test
+ public void testProxyInfo() throws IOException {
+
+ String testConfiguration = readConfigFile("/proxy_config/proxy_config_1.txt");
+
+ ProxyInfo proxyInfo = new ProxyInfo(testConfiguration);
+
+ for (ProxyInfo.Context context : proxyInfo.getAvailableContexts()) {
+ log.info(context.toString());
+ }
+
+ assert (proxyInfo.getAvailableContexts().size() != 0) : "Raw proxy info parsing failed!";
+ }
+
+ private String readConfigFile(String filePath) throws IOException {
+ StringBuffer tempBuffer = new StringBuffer();
+ byte[] readBuffer = new byte[1024];
+ int bytesRead = 0;
+
+ InputStream resourceStream = getClass().getResourceAsStream(filePath);
+
+ while ((bytesRead = resourceStream.read(readBuffer)) != -1) {
+ tempBuffer.append(new String(readBuffer, 0, bytesRead));
+ }
+
+ resourceStream.close();
+
+ return tempBuffer.toString();
+ }
+}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_1.txt b/modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_1.txt
new file mode 100644
index 0000000..c99edd3
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/test/resources/proxy_config/proxy_config_1.txt
@@ -0,0 +1,13 @@
+{mobile-work/192.168.1.40:6666=Node: [1],Name: 4e6189af-0502-3305-8ff3-fad7fee8b516,Balancer: mycluster,LBGroup: ,Host: 127.0.0.1,Port: 8009,Type: ajp,Flushpackets: Off,Flushwait: 10,Ping: 10,Smax: 26,Ttl: 60,Elected: 3233,Read: 7355619,Transfered: 0,Connected: 0,Load: 100
+Node: [2],Name: node2,Balancer: mycluster,LBGroup: ,Host: 127.0.0.1,Port: 8009,Type: ajp,Flushpackets: Off,Flushwait: 10,Ping: 10,Smax: 26,Ttl: 60,Elected: 0,Read: 0,Transfered: 0,Connected: 0,Load: 99
+Vhost: [1:1:1], Alias: localhost
+Vhost: [2:1:2], Alias: localhost
+Context: [1:1:1], Context: /invoker, Status: DISABLED
+Context: [1:1:2], Context: /loaddemo, Status: DISABLED
+Context: [1:1:3], Context: /jbossws, Status: DISABLED
+Context: [1:1:4], Context: /juddi, Status: DISABLED
+Context: [1:1:5], Context: /jbossmq-httpil, Status: DISABLED
+Context: [1:1:6], Context: /web-console, Status: DISABLED
+Context: [1:1:7], Context: /jmx-console, Status: DISABLED
+Context: [1:1:8], Context: /, Status: DISABLED
+Context: [2:1:9], Context: /loaddemo, Status: ENABLED}
\ No newline at end of file
commit 98d1af05eae3cd7013b6a2315c601a29b62ab641
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 7 13:27:01 2011 -0600
Fine tunning the plugin based on UI testing.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
index fb72b5f..f2af2bc 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
@@ -77,7 +77,7 @@ public class ProxyInfo {
@Override
public String toString() {
- return path + ":" + host;
+ return host + ":" + path;
}
public static Context fromString(String stringRepresentation) {
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 88357db..cf12b89 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -80,15 +80,14 @@
<c:simple-property name="advertise" type="boolean" description="Enable autodiscovery of httpd servers."/>
<c:simple-property name="smax" type="integer" description="Maximum time on seconds for idle connections above smax."/>
<c:simple-property name="maxAttempts" type="integer" description="Maximum number of attempts to send the request to the backend server."/>
- <c:simple-property name="advertiseSecurityKey" type="integer" description="Security key for discovery."/>
+ <c:simple-property name="advertiseSecurityKey" type="string" required="false" description="Security key for discovery."/>
<c:simple-property name="stickySessionForce" type="boolean" description="Return an error when the request cannot be routed to the right node."/>
- <c:simple-property name="balancer" type="string" description="Name of the balancer."/>
+ <c:simple-property name="balancer" type="string" required="false" description="Name of the balancer."/>
<c:simple-property name="flushPackets" type="boolean" description="Allows controlling flusing of packets."/>
- <c:simple-property name="socketTimeout" type="integer" description="Connection timeout for communication with the proxy." />
- <c:simple-property name="containerName" type="string" description="Object name of the container."/>
- <c:simple-property name="domain" type="string" description="Domain parameter, which allows tying a jvmRoute to a particular domain."/>
- <c:simple-property name="advertisePort" type="integer" description="Multicast port for discovery" />
- <c:simple-property name="advertiseGroupAddress" type="string" description="Multicast address for discovery."/>
+ <c:simple-property name="socketTimeout" type="integer" description="Connection timeout for communication with the proxy." />
+ <c:simple-property name="domain" type="string" required="false" description="Domain parameter, which allows tying a jvmRoute to a particular domain."/>
+ <c:simple-property name="advertisePort" type="integer" required="false" description="Multicast port for discovery" />
+ <c:simple-property name="advertiseGroupAddress" type="string" required="false" description="Multicast address for discovery."/>
<c:simple-property name="flushWait" type="integer" description="Time in ms to wait before flushing packets."/>
<c:simple-property name="ping" type="integer" description="Time in s to wait for a pong answer to a ping."/>
</resource-configuration>
commit 96a80b66d1a918c012cc3825ef151df87c42a0ec
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 7 10:38:53 2011 -0600
Changed the name of context objects to the proposed short notation.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
index 9cb6b86..fb72b5f 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
@@ -42,7 +42,7 @@ public class ProxyInfo {
String[] contextPieces = rawContext.split(",");
String actualContext = contextPieces[1].substring(contextPieces[1].indexOf("/")).trim();
- availableContexts.add(new Context(actualContext, "localhost"));
+ availableContexts.add(new Context("localhost", actualContext));
}
}
@@ -54,7 +54,7 @@ public class ProxyInfo {
String path;
String host;
- public Context(String path, String host) {
+ public Context(String host, String path) {
this.path = path;
this.host = host;
}
@@ -77,25 +77,12 @@ public class ProxyInfo {
@Override
public String toString() {
- return "Context [path=" + path + ", host=" + host + "]";
+ return path + ":" + host;
}
public static Context fromString(String stringRepresentation) {
- stringRepresentation = stringRepresentation.substring(stringRepresentation.indexOf('[') + 1);
- stringRepresentation = stringRepresentation.substring(0, stringRepresentation.indexOf(']'));
- stringRepresentation = stringRepresentation.trim();
-
- String host = null;
- String path = null;
- for (String part : stringRepresentation.split(",")) {
- part = part.trim();
- if (part.startsWith("path=")) {
- path = part.substring(5).trim();
- } else if (part.startsWith("host=")) {
- host = part.substring(5).trim();
- }
- }
- return new Context(path, host);
+ String part[] = stringRepresentation.trim().split(":");
+ return new Context(part[0], part[1]);
}
}
}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index ad23d34..88357db 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -74,7 +74,7 @@
<metric property="className" displayName="Fully qualified class name of the managed object" displayType="summary" dataType="trait" />
<resource-configuration>
- <c:simple-property name="workerTimeout" type="integer" description="Timeout to wait for an available worker (default is no wait)"
+ <c:simple-property name="workerTimeout" type="integer" description="Timeout to wait for an available worker (default is no wait)" />
<c:simple-property name="stickySession" type="boolean" description="Enables sticky session for the cluster."/>
<c:simple-property name="stickySessionRemove" type="boolean" description="Remove session when the request cannot be routed to the right node."/>
<c:simple-property name="advertise" type="boolean" description="Enable autodiscovery of httpd servers."/>
@@ -83,7 +83,7 @@
<c:simple-property name="advertiseSecurityKey" type="integer" description="Security key for discovery."/>
<c:simple-property name="stickySessionForce" type="boolean" description="Return an error when the request cannot be routed to the right node."/>
<c:simple-property name="balancer" type="string" description="Name of the balancer."/>
- <c:simple-property name="flushPackets" type="boolean" descritpion="Allows controlling flusing of packets."/>
+ <c:simple-property name="flushPackets" type="boolean" description="Allows controlling flusing of packets."/>
<c:simple-property name="socketTimeout" type="integer" description="Connection timeout for communication with the proxy." />
<c:simple-property name="containerName" type="string" description="Object name of the container."/>
<c:simple-property name="domain" type="string" description="Domain parameter, which allows tying a jvmRoute to a particular domain."/>
commit 109bdc7c6ce20c3b514679be08f1735955945aa3
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 7 10:23:06 2011 -0600
Added support for all the mod_cluster available operations.
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 17a4267..ad23d34 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -27,41 +27,70 @@
<c:simple-property name="nameTemplate" default="mod_cluster"/>
</plugin-configuration>
- <operation name="reset" displayName="Reset the node" description="Move the node out of an error state" />
- <operation name="refresh" displayName="Refresh configuration" description="Refresh configuration" />
- <operation name="enable" displayName="Enable all webapps" description="Enable all webapps for all engines">
+ <operation name="stop" displayName="Stop all webapps" description="Gracefully stops all webapps for all engines.">
+ <parameters>
+ <c:simple-property required="true" name="timeout" type="string" displayName="Session draining timeout"/>
+ <c:simple-property required="true" name="unit" default="MILLISECONDS" displayName="Time unit of the timeout parameter">
+ <c:property-options allowCustomValue="false">
+ <c:option value="MICROSECONDS" name="MICROSECONDS"/>
+ <c:option value="MILLISECONDS" name="MILLISECONDS"/>
+ <c:option value="NANOSECONDS" name="NANOSECONDS"/>
+ <c:option value="SECONDS" name="SECONDS"/>
+ </c:property-options>
+ </c:simple-property>
+ </parameters>
+ <results>
+ <c:simple-property name="result" type="boolean" description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="addProxy" displayName="Add a proxy" description="Add a proxy.">
+ <parameters>
+ <c:simple-property required="true" name="host" type="string" displayName="Proxy address"/>
+ <c:simple-property required="true" name="port" type="string" displayName="Proxy port"/>
+ </parameters>
+ </operation>
+ <operation name="enable" displayName="Enable all webapps" description="Enable all webapps for all engines">
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
- </operation>
- <operation name="disable" displayName="Disable all webpapps" description="Disable all webapps for all engines">
+ </operation>
+ <operation name="reset" displayName="Reset the node" description="Move the node out of an error state." />
+ <operation name="disable" displayName="Disable all webpapps" description="Disable all webapps for all engines.">
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
</operation>
+ <operation name="refreshProxy" displayName="Remove a proxy" description="Remove a proxy.">
+ <parameters>
+ <c:simple-property required="true" name="host" type="string" displayName="Proxy address"/>
+ <c:simple-property required="true" name="port" type="string" displayName="Proxy port"/>
+ </parameters>
+ </operation>
+ <operation name="refresh" displayName="Refresh configuration" description="Refresh configuration" />
+
<metric property="proxyConfiguration" displayName="Proxy Configuration" displayType="summary" dataType="trait" />
<metric property="modelerType" displayName="Type of the modeled resource" displayType="summary" dataType="trait" />
<metric property="className" displayName="Fully qualified class name of the managed object" displayType="summary" dataType="trait" />
<resource-configuration>
- <c:simple-property name="workerTimeout" type="int" description="Timeout to wait for an available worker (default is no wait)"
+ <c:simple-property name="workerTimeout" type="integer" description="Timeout to wait for an available worker (default is no wait)"
<c:simple-property name="stickySession" type="boolean" description="Enables sticky session for the cluster."/>
<c:simple-property name="stickySessionRemove" type="boolean" description="Remove session when the request cannot be routed to the right node."/>
<c:simple-property name="advertise" type="boolean" description="Enable autodiscovery of httpd servers."/>
- <c:simple-property name="smax" type="int" description="Maximum time on seconds for idle connections above smax."/>
- <c:simple-property name="maxAttempts" type="int" description="Maximum number of attempts to send the request to the backend server."/>
- <c:simple-property name="advertiseSecurityKey" type="int" description="Security key for discovery."/>
+ <c:simple-property name="smax" type="integer" description="Maximum time on seconds for idle connections above smax."/>
+ <c:simple-property name="maxAttempts" type="integer" description="Maximum number of attempts to send the request to the backend server."/>
+ <c:simple-property name="advertiseSecurityKey" type="integer" description="Security key for discovery."/>
<c:simple-property name="stickySessionForce" type="boolean" description="Return an error when the request cannot be routed to the right node."/>
<c:simple-property name="balancer" type="string" description="Name of the balancer."/>
<c:simple-property name="flushPackets" type="boolean" descritpion="Allows controlling flusing of packets."/>
- <c:simple-property name="socketTimeout" type="int" description="Connection timeout for communication with the proxy." />
+ <c:simple-property name="socketTimeout" type="integer" description="Connection timeout for communication with the proxy." />
<c:simple-property name="containerName" type="string" description="Object name of the container."/>
<c:simple-property name="domain" type="string" description="Domain parameter, which allows tying a jvmRoute to a particular domain."/>
- <c:simple-property name="advertisePort" type="int" description="Multicast port for discovery" />
+ <c:simple-property name="advertisePort" type="integer" description="Multicast port for discovery" />
<c:simple-property name="advertiseGroupAddress" type="string" description="Multicast address for discovery."/>
- <c:simple-property name="flushWait" type="int" description="Time in ms to wait before flushing packets."/>
- <c:simple-property name="ping" type="int" description="Time in s to wait for a pong answer to a ping"/>
+ <c:simple-property name="flushWait" type="integer" description="Time in ms to wait before flushing packets."/>
+ <c:simple-property name="ping" type="integer" description="Time in s to wait for a pong answer to a ping."/>
</resource-configuration>
<service name="mod_cluster Webapp Context"
@@ -69,19 +98,30 @@
class="ContextComponent"
description="A mod_cluster context">
- <operation name="enableContext" displayName="Enable webapp" description="Enable this webapp">
+ <operation name="disableContext" displayName="Disable webapp" description="Disable this webapp.">
<results>
- <c:simple-property name="result" type="boolean" description="The result of the operation" />
+ <c:simple-property name="result" type="boolean" description="The result of the operation."/>
</results>
</operation>
- <operation name="disableContext" displayName="Disable webapp" description="Disable this webapp">
+ <operation name="stopContext" displayName="Stop webapp" description="Gracefully stops this webapp.">
+ <parameters>
+ <c:simple-property required="true" name="timeout" type="integer" displayName="Session draining timeout"/>
+ <c:simple-property required="true" name="unit" default="MILLISECONDS" displayName="Time unit of the timeout parameter">
+ <c:property-options allowCustomValue="false">
+ <c:option value="MICROSECONDS" name="MICROSECONDS"/>
+ <c:option value="MILLISECONDS" name="MILLISECONDS"/>
+ <c:option value="NANOSECONDS" name="NANOSECONDS"/>
+ <c:option value="SECONDS" name="SECONDS"/>
+ </c:property-options>
+ </c:simple-property>
+ </parameters>
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
</operation>
- <operation name="stopContext" displayName="Stop webapp" description="Gracefully stops this webapp.">
+ <operation name="enableContext" displayName="Enable webapp" description="Enable this webapp.">
<results>
- <c:simple-property name="result" type="boolean" description="The result of the operation" />
+ <c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
</operation>
commit 9133ff50842297f30bed9fcb7553a66a38379d76
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 7 09:49:10 2011 -0600
Added all the properties available through the JMX interface to the plugin configuration.
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index b2179c3..17a4267 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -45,9 +45,23 @@
<metric property="className" displayName="Fully qualified class name of the managed object" displayType="summary" dataType="trait" />
<resource-configuration>
- <c:simple-property name="stickySessions" type="boolean" description="Enables sticky sessions."/>
+ <c:simple-property name="workerTimeout" type="int" description="Timeout to wait for an available worker (default is no wait)"
+ <c:simple-property name="stickySession" type="boolean" description="Enables sticky session for the cluster."/>
<c:simple-property name="stickySessionRemove" type="boolean" description="Remove session when the request cannot be routed to the right node."/>
<c:simple-property name="advertise" type="boolean" description="Enable autodiscovery of httpd servers."/>
+ <c:simple-property name="smax" type="int" description="Maximum time on seconds for idle connections above smax."/>
+ <c:simple-property name="maxAttempts" type="int" description="Maximum number of attempts to send the request to the backend server."/>
+ <c:simple-property name="advertiseSecurityKey" type="int" description="Security key for discovery."/>
+ <c:simple-property name="stickySessionForce" type="boolean" description="Return an error when the request cannot be routed to the right node."/>
+ <c:simple-property name="balancer" type="string" description="Name of the balancer."/>
+ <c:simple-property name="flushPackets" type="boolean" descritpion="Allows controlling flusing of packets."/>
+ <c:simple-property name="socketTimeout" type="int" description="Connection timeout for communication with the proxy." />
+ <c:simple-property name="containerName" type="string" description="Object name of the container."/>
+ <c:simple-property name="domain" type="string" description="Domain parameter, which allows tying a jvmRoute to a particular domain."/>
+ <c:simple-property name="advertisePort" type="int" description="Multicast port for discovery" />
+ <c:simple-property name="advertiseGroupAddress" type="string" description="Multicast address for discovery."/>
+ <c:simple-property name="flushWait" type="int" description="Time in ms to wait before flushing packets."/>
+ <c:simple-property name="ping" type="int" description="Time in s to wait for a pong answer to a ping"/>
</resource-configuration>
<service name="mod_cluster Webapp Context"
@@ -55,17 +69,17 @@
class="ContextComponent"
description="A mod_cluster context">
- <operation name="enableContext" displayName="Enable webapp" description="Enable the webapp">
+ <operation name="enableContext" displayName="Enable webapp" description="Enable this webapp">
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
</operation>
- <operation name="disableContext" displayName="Disable webpapp" description="Disable the webapp">
+ <operation name="disableContext" displayName="Disable webapp" description="Disable this webapp">
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
</operation>
- <operation name="stopContext" displayName="Stop webpapp" description="Gracefully stops the webapp">
+ <operation name="stopContext" displayName="Stop webapp" description="Gracefully stops this webapp.">
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
commit 93ac1b5c3ba6032e3c726f32e01d73e16d73e076
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Jul 6 15:28:48 2011 -0500
A couple more tweaks to make the user interface for mod_cluster display correct and proper text.
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index cdfa7fb..b2179c3 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -24,7 +24,7 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="Catalina:type=ModClusterListener,*"/>
- <c:simple-property name="nameTemplate" default="{application}"/>
+ <c:simple-property name="nameTemplate" default="mod_cluster"/>
</plugin-configuration>
<operation name="reset" displayName="Reset the node" description="Move the node out of an error state" />
@@ -50,22 +50,22 @@
<c:simple-property name="advertise" type="boolean" description="Enable autodiscovery of httpd servers."/>
</resource-configuration>
- <service name="mod_cluster_context"
+ <service name="mod_cluster Webapp Context"
discovery="ContextDiscoveryComponent"
class="ContextComponent"
description="A mod_cluster context">
- <operation name="enableContext" displayName="Enable webapp" description="Enable a single webapp">
+ <operation name="enableContext" displayName="Enable webapp" description="Enable the webapp">
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
</operation>
- <operation name="disableContext" displayName="Disable webpapp" description="Disable a single webapp">
+ <operation name="disableContext" displayName="Disable webpapp" description="Disable the webapp">
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
</operation>
- <operation name="stopContext" displayName="Stop webpapp" description="Gracefully stops a single webapp">
+ <operation name="stopContext" displayName="Stop webpapp" description="Gracefully stops the webapp">
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
commit bed08a054ca397b313d97022c29ad61f1b7e6a81
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Jul 6 13:19:07 2011 -0500
Fine tuning the plugin configuration based other plugin configuration and test deployment issues.
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml
index 74defeb..4536125 100644
--- a/modules/plugins/mod-cluster/pom.xml
+++ b/modules/plugins/mod-cluster/pom.xml
@@ -12,7 +12,7 @@
<artifactId>modcluster-plugin</artifactId>
<packaging>jar</packaging>
- <name>mod_cluster RHQ Plugin</name>
+ <name>RHQ mod_cluster Plugin</name>
<description>mod_cluster RHQ Agent plugin</description>
<dependencies>
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index be4b25b..cdfa7fb 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -14,11 +14,12 @@
discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
class="ModclusterServerComponent"
supportsManualAdd="true"
- description="mod_cluster plugin">
+ description="mod_cluster plugin"
+ singleton="true">
<runs-inside>
<parent-resource-type name="JBossAS Server" plugin="JBossAS"/>
- <parent-resource-type name="JBossAS Server" plugin="JBossAS5"/>
+ <parent-resource-type name="JBossAS5 Server" plugin="JBossAS5"/>
</runs-inside>
<plugin-configuration>
diff --git a/modules/plugins/pom.xml b/modules/plugins/pom.xml
index 02f6584..f32159e 100644
--- a/modules/plugins/pom.xml
+++ b/modules/plugins/pom.xml
@@ -125,10 +125,11 @@
<module>augeas</module>
<module>apache</module>
<module>tomcat</module>
- <module>jboss-as</module>
<module>hibernate</module>
+ <module>mod-cluster</module>
<module>rhq-server</module>
<module>jboss-cache</module>
+ <module>jboss-as</module>
<module>jboss-as-5</module>
<module>jboss-as-7</module>
<module>jboss-cache-v3</module>
commit af18d25dc8b66f9d95477e90356f6aecccf6077c
Merge: 7f4c0a9 67e6127
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Jul 6 10:01:46 2011 -0500
Merge branch 'master' into mod_cluster_plugin
commit 7f4c0a99bb2121fd3496d3bc1af3079f4e922c3a
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Jul 6 10:00:21 2011 -0500
Added dev profile for plugin deployment in the local plugin repo.
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml
index a19dfc0..74defeb 100644
--- a/modules/plugins/mod-cluster/pom.xml
+++ b/modules/plugins/mod-cluster/pom.xml
@@ -190,6 +190,82 @@
</plugins>
</build>
</profile>
+
+
+ <profile>
+ <id>dev</id>
+
+ <properties>
+ <rhq.rootDir>../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-plugins</rhq.deploymentDir>
+ </properties>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${rhq.deploymentDir}" />
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>deploy-jar-meta-inf</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating META-INF dir in ${deployment.file}...</echo>
+ <unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.outputDirectory}">
+ <patternset><include name="META-INF/**" /></patternset>
+ </unjar>
+ <jar destfile="${deployment.file}" manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF" update="true">
+ </jar>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+
</profiles>
</project>
commit 060cf8983b9230adf3f26c936d0fe6c8d1966bd1
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 5 23:31:24 2011 -0500
All the context dependent operations are now passed for execution to the parent MBean. The operation arguments are parsed from the proxyInfo MBean property.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
index f73a151..922197a 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
@@ -1,24 +1,20 @@
/*
- * Jopr Management Platform
+ * RHQ Management Platform
* Copyright (C) 2005-2008 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
+ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package org.rhq.plugins.modcluster;
@@ -29,10 +25,9 @@ import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.plugins.jmx.MBeanResourceComponent;
/**
- * Manages a Hibernate Entity.
+ * Manages a mod_cluster context entity.
*
- * @author Greg Hinkle
- * @author John Mazzitelli
+ * @author Stefan Negrea
*/
public class ContextComponent extends MBeanResourceComponent<MBeanResourceComponent> {
@Override
@@ -42,46 +37,24 @@ public class ContextComponent extends MBeanResourceComponent<MBeanResourceCompon
@Override
public OperationResult invokeOperation(String name, Configuration parameters) throws Exception {
- if ("enableContext".equals(name)) {
- //String[] queryStrings = (String[]) getEmsBean().getAttribute("Queries").refresh();
- OperationResult result = new OperationResult();
- result.setSimpleResult("This works!");
- /*PropertyList queries = new PropertyList("queries");
- result.getComplexResults().put(queries);*/
+ if ("enableContext".equals(name) || "disableContext".equals(name) || "stopContext".equals(name)) {
+
+ ProxyInfo.Context context = ProxyInfo.Context.fromString(resourceContext.getResourceKey());
+ System.out.println(context.toString());
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
- /*Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
- for (String queryString : queryStrings) {
- Object queryStatistics = getEmsBean().getOperation("getQueryStatistics").invoke(
- new Object[] { queryString });
-
- Long executionCount = (Long) queryStatistics.getClass().getMethod("getExecutionCount")
- .invoke(queryStatistics);
- Long executionRowCount = (Long) queryStatistics.getClass().getMethod("getExecutionRowCount")
- .invoke(queryStatistics);
- Long executionMinTime = (Long) queryStatistics.getClass().getMethod("getExecutionMinTime")
- .invoke(queryStatistics);
- Long executionMaxTime = (Long) queryStatistics.getClass().getMethod("getExecutionMaxTime")
- .invoke(queryStatistics);
- Long executionAvgTime = (Long) queryStatistics.getClass().getMethod("getExecutionAvgTime")
- .invoke(queryStatistics);
-
- PropertyMap query = new PropertyMap("query", new PropertySimple("query", queryString),
- new PropertySimple("executionCount", executionCount), new PropertySimple("executionRowCount",
- executionRowCount), new PropertySimple("executionMinTime", executionMinTime),
- new PropertySimple("executionMaxTime", executionMaxTime), new PropertySimple(
- "executionAvgTime", executionAvgTime));
+ Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
- queries.add(query);
- }*/
+ Object resultObject = getEmsBean().getOperation(name).invoke(
+ new Object[] { context.host, context.path });
- return result;
+ return new OperationResult(String.valueOf(resultObject));
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
}
- return super.invokeOperation(name, parameters);
+ throw new Exception("Operation " + name + " not available mod_cluster_context service");
}
}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
index 90e5c6b..4b3adcd 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
@@ -33,11 +33,15 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.jmx.MBeanResourceComponent;
/**
- * Discovers hibernate entities from a hibernate stats mbean
+ * Discovers mod_cluster contexts from the proxyInfo mbean property.
*
- * @author Greg Hinkle
+ * @author Stefan Negrea
*/
public class ContextDiscoveryComponent implements ResourceDiscoveryComponent<MBeanResourceComponent> {
+
+ /* (non-Javadoc)
+ * @see org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext)
+ */
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<MBeanResourceComponent> context) {
Set<DiscoveredResourceDetails> entities = new HashSet<DiscoveredResourceDetails>();
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
index 15a9a68..9cb6b86 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
@@ -16,7 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
package org.rhq.plugins.modcluster;
import java.util.ArrayList;
@@ -25,16 +24,17 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+/**
+ * Simple parser for the raw proxy information provided by mod_cluster.
+ *
+ * @author Stefan Negrea
+ */
public class ProxyInfo {
private List<Context> availableContexts = new ArrayList<ProxyInfo.Context>();
public ProxyInfo(String rawProxyInfo) {
- System.out.println("--------------------------------------");
- System.out.println(rawProxyInfo);
- System.out.println("--------------------------------------");
-
Pattern test = Pattern.compile("Context.*\n");
Matcher m = test.matcher(rawProxyInfo);
while (m.find()) {
@@ -42,7 +42,7 @@ public class ProxyInfo {
String[] contextPieces = rawContext.split(",");
String actualContext = contextPieces[1].substring(contextPieces[1].indexOf("/")).trim();
- availableContexts.add(new Context(actualContext, "localHost"));
+ availableContexts.add(new Context(actualContext, "localhost"));
}
}
@@ -50,12 +50,11 @@ public class ProxyInfo {
return Collections.unmodifiableList(availableContexts);
}
- public class Context {
+ public static class Context {
String path;
String host;
public Context(String path, String host) {
- super();
this.path = path;
this.host = host;
}
@@ -80,5 +79,23 @@ public class ProxyInfo {
public String toString() {
return "Context [path=" + path + ", host=" + host + "]";
}
+
+ public static Context fromString(String stringRepresentation) {
+ stringRepresentation = stringRepresentation.substring(stringRepresentation.indexOf('[') + 1);
+ stringRepresentation = stringRepresentation.substring(0, stringRepresentation.indexOf(']'));
+ stringRepresentation = stringRepresentation.trim();
+
+ String host = null;
+ String path = null;
+ for (String part : stringRepresentation.split(",")) {
+ part = part.trim();
+ if (part.startsWith("path=")) {
+ path = part.substring(5).trim();
+ } else if (part.startsWith("host=")) {
+ host = part.substring(5).trim();
+ }
+ }
+ return new Context(path, host);
+ }
}
}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 084165e..be4b25b 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -45,6 +45,8 @@
<resource-configuration>
<c:simple-property name="stickySessions" type="boolean" description="Enables sticky sessions."/>
+ <c:simple-property name="stickySessionRemove" type="boolean" description="Remove session when the request cannot be routed to the right node."/>
+ <c:simple-property name="advertise" type="boolean" description="Enable autodiscovery of httpd servers."/>
</resource-configuration>
<service name="mod_cluster_context"
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index deceb70..0d16e92 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -140,8 +140,14 @@ public class ModclusterPluginTest {
assert (resources.size() != 0) : "No mod_cluster or related instances found.";
if (resources.size() != 0) {
- testResourceMeasurement((Resource) resources.toArray()[0]);
- testContextOperations((Resource) resources.toArray()[1]);
+ for (Object objectResource : resources.toArray()) {
+ Resource resource = (Resource) objectResource;
+ if (resource.getResourceType().getName().equals("mod_cluster")) {
+ testResourceMeasurement(resource);
+ } else {
+ testContextOperations(resource);
+ }
+ }
}
}
@@ -175,9 +181,12 @@ public class ModclusterPluginTest {
.getResourceComponent(resource);
if (resourceComponent instanceof OperationFacet) {
- OperationResult result = ((OperationFacet) resourceComponent).invokeOperation("enableContext", null);
- log.info("Result of operation " + "enableContext" + " was: " + result.getSimpleResult());
-
+ try {
+ OperationResult result = ((OperationFacet) resourceComponent).invokeOperation("enableContext", null);
+ log.info("Result of operation " + "enableContext" + " was: " + result.getSimpleResult());
+ } catch (Exception e) {
+ log.info("Operation failed");
+ }
/*result = ((OperationFacet) resourceComponent).invokeOperation("disable", null);
log.info("Result of operation test was: " + result.getSimpleResult());*/
}
commit a23fc57dda98b70cb7c1b23af91b9e3e3597969a
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 5 18:43:06 2011 -0500
Added individual contexts as sub services to mod_cluster service.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
new file mode 100644
index 0000000..f73a151
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
@@ -0,0 +1,87 @@
+/*
+ * Jopr Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import org.mc4j.ems.connection.bean.EmsBean;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
+
+/**
+ * Manages a Hibernate Entity.
+ *
+ * @author Greg Hinkle
+ * @author John Mazzitelli
+ */
+public class ContextComponent extends MBeanResourceComponent<MBeanResourceComponent> {
+ @Override
+ protected EmsBean loadBean() {
+ return getResourceContext().getParentResourceComponent().getEmsBean();
+ }
+
+ @Override
+ public OperationResult invokeOperation(String name, Configuration parameters) throws Exception {
+ if ("enableContext".equals(name)) {
+ //String[] queryStrings = (String[]) getEmsBean().getAttribute("Queries").refresh();
+ OperationResult result = new OperationResult();
+ result.setSimpleResult("This works!");
+ /*PropertyList queries = new PropertyList("queries");
+ result.getComplexResults().put(queries);*/
+
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try {
+ /*Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
+ for (String queryString : queryStrings) {
+ Object queryStatistics = getEmsBean().getOperation("getQueryStatistics").invoke(
+ new Object[] { queryString });
+
+ Long executionCount = (Long) queryStatistics.getClass().getMethod("getExecutionCount")
+ .invoke(queryStatistics);
+ Long executionRowCount = (Long) queryStatistics.getClass().getMethod("getExecutionRowCount")
+ .invoke(queryStatistics);
+ Long executionMinTime = (Long) queryStatistics.getClass().getMethod("getExecutionMinTime")
+ .invoke(queryStatistics);
+ Long executionMaxTime = (Long) queryStatistics.getClass().getMethod("getExecutionMaxTime")
+ .invoke(queryStatistics);
+ Long executionAvgTime = (Long) queryStatistics.getClass().getMethod("getExecutionAvgTime")
+ .invoke(queryStatistics);
+
+ PropertyMap query = new PropertyMap("query", new PropertySimple("query", queryString),
+ new PropertySimple("executionCount", executionCount), new PropertySimple("executionRowCount",
+ executionRowCount), new PropertySimple("executionMinTime", executionMinTime),
+ new PropertySimple("executionMaxTime", executionMaxTime), new PropertySimple(
+ "executionAvgTime", executionAvgTime));
+
+ queries.add(query);
+ }*/
+
+ return result;
+ } finally {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
+
+ return super.invokeOperation(name, parameters);
+ }
+}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
new file mode 100644
index 0000000..90e5c6b
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
@@ -0,0 +1,57 @@
+/*
+ * Jopr Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.mc4j.ems.connection.bean.EmsBean;
+
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
+
+/**
+ * Discovers hibernate entities from a hibernate stats mbean
+ *
+ * @author Greg Hinkle
+ */
+public class ContextDiscoveryComponent implements ResourceDiscoveryComponent<MBeanResourceComponent> {
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<MBeanResourceComponent> context) {
+ Set<DiscoveredResourceDetails> entities = new HashSet<DiscoveredResourceDetails>();
+
+ EmsBean statsBean = context.getParentResourceComponent().getEmsBean();
+
+ String rawProxyInfo = (String) statsBean.getAttribute("proxyInfo").refresh().toString();
+ ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+
+ for (ProxyInfo.Context availableContext : proxyInfo.getAvailableContexts()) {
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(context.getResourceType(),
+ availableContext.toString(), availableContext.toString(), null, "mod_cluster Context", null, null);
+ entities.add(detail);
+ }
+
+ return entities;
+ }
+}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index a98792e..783f579 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -18,9 +18,6 @@
*/
package org.rhq.plugins.modcluster;
-import org.rhq.core.domain.operation.OperationDefinition;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.plugins.jmx.MBeanResourceComponent;
/**
@@ -28,16 +25,4 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
*
*/
public class ModclusterServerComponent extends MBeanResourceComponent {
-
- /**
- * Stores the context and loads the MBean.
- * @see ResourceComponent#start(ResourceContext)
- */
- @Override
- public void start(ResourceContext context) {
- super.start(context);
-
- OperationDefinition test = new OperationDefinition(context.getResourceType(), "Text");
- context.getResourceType().addOperationDefinition(test);
- }
}
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
new file mode 100644
index 0000000..15a9a68
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
@@ -0,0 +1,84 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.modcluster;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class ProxyInfo {
+
+ private List<Context> availableContexts = new ArrayList<ProxyInfo.Context>();
+
+ public ProxyInfo(String rawProxyInfo) {
+
+ System.out.println("--------------------------------------");
+ System.out.println(rawProxyInfo);
+ System.out.println("--------------------------------------");
+
+ Pattern test = Pattern.compile("Context.*\n");
+ Matcher m = test.matcher(rawProxyInfo);
+ while (m.find()) {
+ String rawContext = m.group();
+ String[] contextPieces = rawContext.split(",");
+ String actualContext = contextPieces[1].substring(contextPieces[1].indexOf("/")).trim();
+
+ availableContexts.add(new Context(actualContext, "localHost"));
+ }
+ }
+
+ public List<Context> getAvailableContexts() {
+ return Collections.unmodifiableList(availableContexts);
+ }
+
+ public class Context {
+ String path;
+ String host;
+
+ public Context(String path, String host) {
+ super();
+ this.path = path;
+ this.host = host;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ @Override
+ public String toString() {
+ return "Context [path=" + path + ", host=" + host + "]";
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index b8d7249..084165e 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -47,5 +47,29 @@
<c:simple-property name="stickySessions" type="boolean" description="Enables sticky sessions."/>
</resource-configuration>
+ <service name="mod_cluster_context"
+ discovery="ContextDiscoveryComponent"
+ class="ContextComponent"
+ description="A mod_cluster context">
+
+ <operation name="enableContext" displayName="Enable webapp" description="Enable a single webapp">
+ <results>
+ <c:simple-property name="result" type="boolean" description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="disableContext" displayName="Disable webpapp" description="Disable a single webapp">
+ <results>
+ <c:simple-property name="result" type="boolean" description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="stopContext" displayName="Stop webpapp" description="Gracefully stops a single webapp">
+ <results>
+ <c:simple-property name="result" type="boolean" description="The result of the operation" />
+ </results>
+ </operation>
+
+ </service>
+
+
</service>
</plugin>
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index da0303e..deceb70 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -19,8 +19,10 @@
package org.rhq.plugins.modcluster.test;
import java.io.File;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
+import java.util.List;
import java.util.Queue;
import java.util.Set;
@@ -45,6 +47,7 @@ import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.plugins.modcluster.ProxyInfo;
/**
* @author Fady Matar
@@ -80,6 +83,31 @@ public class ModclusterPluginTest {
}
@Test
+ public void testProxyInfo() {
+ String test = "{mobile-work/192.168.1.40:6666=Node: [1],Name: 4e6189af-0502-3305-8ff3-fad7fee8b516,Balancer: mycluster,LBGroup: ,Host: 127.0.0.1,Port: 8009,Type: ajp,Flushpackets: Off,Flushwait: 10,Ping: 10,Smax: 26,Ttl: 60,Elected: 3233,Read: 7355619,Transfered: 0,Connected: 0,Load: 100\n"
+ + "Node: [2],Name: node2,Balancer: mycluster,LBGroup: ,Host: 127.0.0.1,Port: 8009,Type: ajp,Flushpackets: Off,Flushwait: 10,Ping: 10,Smax: 26,Ttl: 60,Elected: 0,Read: 0,Transfered: 0,Connected: 0,Load: 99\n"
+ + "Vhost: [1:1:1], Alias: localhost\n"
+ + "Vhost: [2:1:2], Alias: localhost\n"
+ + "Context: [1:1:1], Context: /invoker, Status: DISABLED\n"
+ + "Context: [1:1:2], Context: /loaddemo, Status: DISABLED\n"
+ + "Context: [1:1:3], Context: /jbossws, Status: DISABLED\n"
+ + "Context: [1:1:4], Context: /juddi, Status: DISABLED\n"
+ + "Context: [1:1:5], Context: /jbossmq-httpil, Status: DISABLED\n"
+ + "Context: [1:1:6], Context: /web-console, Status: DISABLED\n"
+ + "Context: [1:1:7], Context: /jmx-console, Status: DISABLED\n"
+ + "Context: [1:1:8], Context: /, Status: DISABLED\n"
+ + "Context: [2:1:9], Context: /loaddemo, Status: ENABLED\n" + "}";
+
+ ProxyInfo proxyInfo = new ProxyInfo(test);
+
+ for (ProxyInfo.Context context : proxyInfo.getAvailableContexts()) {
+ log.info(context.toString());
+ }
+
+ assert (proxyInfo.getAvailableContexts().size() != 0) : "Raw proxy info parsing failed!";
+ }
+
+ @Test
public void testPluginLoad() {
PluginManager pluginManager = PluginContainer.getInstance().getPluginManager();
PluginEnvironment pluginEnvironment = pluginManager.getPlugin(PLUGIN_NAME);
@@ -98,12 +126,22 @@ public class ModclusterPluginTest {
assert report != null;
System.out.println("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+ List<String> typeNames = new ArrayList<String>() {
+ {
+ add(PLUGIN_NAME);
+ add(PLUGIN_NAME + "_context");
+ }
+ };
+
Set<Resource> resources = findResource(PluginContainer.getInstance().getInventoryManager().getPlatform(),
- PLUGIN_NAME);
- log.info("Found " + resources.size() + " mod_cluster instance(s).");
+ typeNames);
+ log.info("Found " + resources.size() + " mod_cluster and mod_cluster_context instance(s).");
+
+ assert (resources.size() != 0) : "No mod_cluster or related instances found.";
if (resources.size() != 0) {
testResourceMeasurement((Resource) resources.toArray()[0]);
+ testContextOperations((Resource) resources.toArray()[1]);
}
}
@@ -132,7 +170,20 @@ public class ModclusterPluginTest {
}
}
- private Set<Resource> findResource(Resource parent, String typeName) {
+ private void testContextOperations(Resource resource) throws Exception {
+ ResourceComponent resourceComponent = PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+
+ if (resourceComponent instanceof OperationFacet) {
+ OperationResult result = ((OperationFacet) resourceComponent).invokeOperation("enableContext", null);
+ log.info("Result of operation " + "enableContext" + " was: " + result.getSimpleResult());
+
+ /*result = ((OperationFacet) resourceComponent).invokeOperation("disable", null);
+ log.info("Result of operation test was: " + result.getSimpleResult());*/
+ }
+ }
+
+ private Set<Resource> findResource(Resource parent, List<String> typeNames) {
Set<Resource> found = new HashSet<Resource>();
Queue<Resource> discoveryQueue = new LinkedList<Resource>();
@@ -142,7 +193,7 @@ public class ModclusterPluginTest {
Resource currentResource = discoveryQueue.poll();
log.info("Discovered resource of type: " + currentResource.getResourceType().getName());
- if (currentResource.getResourceType().getName().equals(typeName)) {
+ if (typeNames.contains(currentResource.getResourceType().getName())) {
found.add(currentResource);
}
commit a78a8e8b90cb76cf3412732008870804c2210a6b
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 5 15:46:03 2011 -0500
Attempt to manually manipulate the operations list for mod_cluster to dynamically load the contexts.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index c70f53b..a98792e 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -18,6 +18,9 @@
*/
package org.rhq.plugins.modcluster;
+import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.plugins.jmx.MBeanResourceComponent;
/**
@@ -26,4 +29,15 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
*/
public class ModclusterServerComponent extends MBeanResourceComponent {
+ /**
+ * Stores the context and loads the MBean.
+ * @see ResourceComponent#start(ResourceContext)
+ */
+ @Override
+ public void start(ResourceContext context) {
+ super.start(context);
+
+ OperationDefinition test = new OperationDefinition(context.getResourceType(), "Text");
+ context.getResourceType().addOperationDefinition(test);
+ }
}
commit 302abb94355bf86db5f6e7cc419657d53210c7a5
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 5 15:45:23 2011 -0500
Added simple operations to the list of operations supported by the plugin. Complex operations to follow....
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterDiscoveryComponent.java
deleted file mode 100644
index fa807a3..0000000
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterDiscoveryComponent.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ManualAddFacet;
-import org.rhq.core.pluginapi.inventory.ProcessScanResult;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-
-/**
- * This can be the start of your own custom plugin's discovery component. Review the javadoc for
- * {@link ResourceDiscoveryComponent}.
- *
- * @author John Mazzitelli
- */
-@SuppressWarnings("unchecked")
-public class ModclusterDiscoveryComponent implements ResourceDiscoveryComponent, ManualAddFacet {
- private final Log log = LogFactory.getLog(ModclusterDiscoveryComponent.class);
-
- /**
- * This discovery method is the way the plugin supports "manual-add" capability. The plugin
- * descriptor must specify supportsManualAdd="true" to allow the resource to be manually added.
- * If that attribute is false, this method will never be used since it will not be possible to manually
- * add an instance of the resource.
- *
- * Review the javadoc for both {@link ManualAddFacet} and {@link ResourceDiscoveryContext} to learn what
- * you need to do in this method.
- *
- * @see ManualAddFacet#discoverResource(Configuration, ResourceDiscoveryContext)
- */
- @Override
- public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration,
- ResourceDiscoveryContext context) throws InvalidPluginConfigurationException {
-
- // pluginConfiguration contains information on a resource that was manually added by the user.
- // take it and build a details object that represents that resource.
-
- // key = this must be a unique string across all of your resources - see docs for uniqueness rules
- // name = this is the name you give the new resource; it does not necessarily have to be unique
- // version = this is any string that corresponds to the resource's version
- // description = this is any string that you want to assign as the default description for your resource
- String key = "My Manually Added Resource Key";
- String name = "My Resource";
- String version = "1.0";
- String description = "This describes My Resource";
-
- DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
- version, description, pluginConfiguration, null);
-
- return resource;
- }
-
- /**
- * Review the javadoc for both {@link ResourceDiscoveryComponent} and {@link ResourceDiscoveryContext} to learn what
- * you need to do in this method.
- *
- * @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext)
- */
- @Override
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
- log.info("Discovering my custom plugin's resources");
-
- // if your plugin descriptor defined one or more <process-scan>s, then see if the plugin container
- // auto-discovered processes using those process scan definitions. Process all those that were found.
- List<ProcessScanResult> autoDiscoveryResults = context.getAutoDiscoveredProcesses();
- for (ProcessScanResult autoDiscoveryResult : autoDiscoveryResults) {
- // determine if you want to include the result in this method's returned set of discovered resources
- }
-
- // now perform your own discovery mechanism, if you have one. For each resource discovered, you need to
- // create a details object that describe the resource that you discovered.
- HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
-
- // key = this must be a unique string across all of your resources - see docs for uniqueness rules
- // name = this is the name you give the new resource; it does not necessarily have to be unique
- // version = this is any string that corresponds to the resource's version
- // description = this is any string that you want to assign as the default description for your resource
- String key = "My Resource Key";
- String name = "My Resource";
- String version = "1.0";
- String description = "This describes My Resource";
-
- DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
- version, description, null, null);
-
- set.add(resource);
-
- return set;
- }
-}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index c924753..b8d7249 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -27,10 +27,25 @@
</plugin-configuration>
<operation name="reset" displayName="Reset the node" description="Move the node out of an error state" />
+ <operation name="refresh" displayName="Refresh configuration" description="Refresh configuration" />
+ <operation name="enable" displayName="Enable all webapps" description="Enable all webapps for all engines">
+ <results>
+ <c:simple-property name="result" type="boolean" description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="disable" displayName="Disable all webpapps" description="Disable all webapps for all engines">
+ <results>
+ <c:simple-property name="result" type="boolean" description="The result of the operation" />
+ </results>
+ </operation>
<metric property="proxyConfiguration" displayName="Proxy Configuration" displayType="summary" dataType="trait" />
<metric property="modelerType" displayName="Type of the modeled resource" displayType="summary" dataType="trait" />
<metric property="className" displayName="Fully qualified class name of the managed object" displayType="summary" dataType="trait" />
+ <resource-configuration>
+ <c:simple-property name="stickySessions" type="boolean" description="Enables sticky sessions."/>
+ </resource-configuration>
+
</service>
</plugin>
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index 5f68989..da0303e 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -43,6 +43,8 @@ import org.rhq.core.pc.plugin.PluginEnvironment;
import org.rhq.core.pc.plugin.PluginManager;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
/**
* @author Fady Matar
@@ -115,13 +117,19 @@ public class ModclusterPluginTest {
MeasurementReport report = new MeasurementReport();
((MeasurementFacet) resourceComponent).getValues(report, metricList);
- /*assert report.getNumericData().size() > 0 : "Measurement " + def.getName() + " not collected from "
- + resource;*/
MeasurementData data = report.getTraitData().iterator().next();
assert data != null : "Unable to collect trait [" + def.getName() + "] on " + resource;
log.info("Measurement: " + def.getName() + "=" + data.getValue());
}
}
+
+ if (resourceComponent instanceof OperationFacet) {
+ OperationResult result = ((OperationFacet) resourceComponent).invokeOperation("reset", null);
+ log.info("Result of operation test was: " + result);
+
+ result = ((OperationFacet) resourceComponent).invokeOperation("disable", null);
+ log.info("Result of operation test was: " + result.getSimpleResult());
+ }
}
private Set<Resource> findResource(Resource parent, String typeName) {
commit b6e3c85546af1faaac5e71ad6295a85e4b9d66b3
Merge: 3c46d2a 0ef2b57
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Jul 1 16:15:00 2011 -0500
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq into mod_cluster_plugin
commit 3c46d2aaa05a0b355624f758977ef766bd3e8c6f
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Jul 1 16:12:13 2011 -0500
Remove unused file.
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetric.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetric.java
deleted file mode 100644
index 1223508..0000000
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetric.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster;
-
-import org.rhq.plugins.jmx.MBeanResourceComponent;
-
-/**
- * @author Stefan Negrea
- *
- */
-public class LoadMetric extends MBeanResourceComponent {
-
-}
commit 727836e4eca968619ec5307db7332eb132ac5562
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Jul 1 15:11:36 2011 -0600
Added all the metrics proposed in the design document to the plugin with complete unit tests.
Also, corrected the cumbersome find resource code. No reason to have recursion when a simple queue can do the job more efficiently.
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml
index 869a25e..a19dfc0 100644
--- a/modules/plugins/mod-cluster/pom.xml
+++ b/modules/plugins/mod-cluster/pom.xml
@@ -69,6 +69,8 @@
<fileset dir="${settings.localRepository}/">
<include name="org/rhq/rhq-platform-plugin/${project.version}/rhq-platform-plugin-${project.version}.jar" />
<include name="org/rhq/rhq-jmx-plugin/${project.version}/rhq-jmx-plugin-${project.version}.jar" />
+ <include name="org/jboss/on/jopr-jboss-as-plugin/${project.version}/jopr-jboss-as-plugin-${project.version}.jar" />
+ <include name="org/jboss/on/jopr-jboss-as-5-plugin/${project.version}/jopr-jboss-as-5-plugin-${project.version}.jar" />
</fileset>
<fileset dir="${rhq.deploymentDir}">
<include name="${project.artifactId}-${project.version}.jar" />
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index 6d6998a..c70f53b 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2009 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -18,151 +18,12 @@
*/
package org.rhq.plugins.modcluster;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.MeasurementDataNumeric;
-import org.rhq.core.domain.measurement.MeasurementReport;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
-import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.core.pluginapi.measurement.MeasurementFacet;
-import org.rhq.core.pluginapi.operation.OperationFacet;
-import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
/**
- * This can be the start of your own custom plugin's server component. Review the javadoc for {@link ResourceComponent}
- * and all the facet interfaces to learn what you can do in your resource component. This component has a lot of methods
- * in it because it implements all possible facets. If your resource does not support, for example, configuration, you
- * can remove the {@link ConfigurationFacet} from the <code>implements</code> clause and remove all method
- * implementations that that facet required.
- *
- * <p>You should not only read the javadoc in each of this class' methods, but you should also read the javadocs linked
- * by their "see" javadoc tags since those additional javadocs will contain a good deal of additional information you
- * will need to know.</p>
+ * @author Stefan Negrea
*
- * @author John Mazzitelli
*/
-public class ModclusterServerComponent implements ResourceComponent, MeasurementFacet, OperationFacet,
- ConfigurationFacet {
- private final Log log = LogFactory.getLog(ModclusterServerComponent.class);
-
- /**
- * Represents the resource configuration of the custom product being managed.
- */
- private Configuration resourceConfiguration;
-
- /**
- * All AMPS plugins are stateful - this context contains information that your resource component can use when
- * performing its processing.
- */
- private ResourceContext resourceContext;
-
- /**
- * This is called when your component has been started with the given context. You normally initialize some internal
- * state of your component as well as attempt to make a stateful connection to your managed resource.
- *
- * @see ResourceComponent#start(ResourceContext)
- */
- public void start(ResourceContext context) {
- resourceContext = context;
- }
-
- /**
- * This is called when the component is being stopped, usually due to the plugin container shutting down. You can
- * perform some cleanup here; though normally not much needs to be done here.
- *
- * @see ResourceComponent#stop()
- */
- public void stop() {
- }
-
- /**
- * All resource components must be able to tell the plugin container if the managed resource is available or not.
- * This method is called by the plugin container when it needs to know if the managed resource is actually up and
- * available.
- *
- * @see ResourceComponent#getAvailability()
- */
- public AvailabilityType getAvailability() {
- // TODO: here you normally make some type of connection attempt to the managed resource
- // to determine if it is really up and running.
- return AvailabilityType.UP;
- }
-
- /**
- * The plugin container will call this method when your resource component has been scheduled to collect some
- * measurements now. It is within this method that you actually talk to the managed resource and collect the
- * measurement data that is has emitted.
- *
- * @see MeasurementFacet#getValues(MeasurementReport, Set)
- */
- public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) {
- for (MeasurementScheduleRequest request : requests) {
- String name = request.getName();
-
- // TODO: based on the request information, you must collect the requested measurement(s)
- // you can use the name of the measurement to determine what you actually need to collect
- try {
- Number value = new Integer(1); // dummy measurement value - this should come from the managed resource
- report.addData(new MeasurementDataNumeric(request, value.doubleValue()));
- } catch (Exception e) {
- log.error("Failed to obtain measurement [" + name + "]. Cause: " + e);
- }
- }
-
- return;
- }
-
- /**
- * The plugin container will call this method when it wants to invoke an operation on your managed resource. Your
- * plugin will connect to the managed resource and invoke the analogous operation in your own custom way.
- *
- * @see OperationFacet#invokeOperation(String, Configuration)
- */
- public OperationResult invokeOperation(String name, Configuration configuration) {
- return null;
- }
-
- /**
- * The plugin container will call this method and it needs to obtain the current configuration of the managed
- * resource. Your plugin will obtain the managed resource's configuration in your own custom way and populate the
- * returned Configuration object with the managed resource's configuration property values.
- *
- * @see ConfigurationFacet#loadResourceConfiguration()
- */
- public Configuration loadResourceConfiguration() {
- // here we simulate the loading of the managed resource's configuration
-
- if (resourceConfiguration == null) {
- // for this example, we will create a simple dummy configuration to start with.
- // note that it is empty, so we're assuming there are no required configs in the plugin descriptor.
- resourceConfiguration = new Configuration();
- }
-
- Configuration config = resourceConfiguration;
-
- return config;
- }
-
- /**
- * The plugin container will call this method when it has a new configuration for your managed resource. Your plugin
- * will re-configure the managed resource in your own custom way, setting its configuration based on the new values
- * of the given configuration.
- *
- * @see ConfigurationFacet#updateResourceConfiguration(ConfigurationUpdateReport)
- */
- public void updateResourceConfiguration(ConfigurationUpdateReport report) {
- // this simulates the plugin taking the new configuration and reconfiguring the managed resource
- resourceConfiguration = report.getConfiguration().deepCopy();
+public class ModclusterServerComponent extends MBeanResourceComponent {
- report.setStatus(ConfigurationUpdateStatus.SUCCESS);
- }
}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index fe6d1b3..c924753 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -12,21 +12,25 @@
<service name="mod_cluster"
discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
- class="LoadMetric"
+ class="ModclusterServerComponent"
supportsManualAdd="true"
description="mod_cluster plugin">
- <!-- runs-inside>
- <parent-resource-type name="JMX Server" plugin="JMX"/>
- </runs-inside-->
- <runs-inside>
- <parent-resource-type name="JMX Server" plugin="JMX"/>
- </runs-inside>
+ <runs-inside>
+ <parent-resource-type name="JBossAS Server" plugin="JBossAS"/>
+ <parent-resource-type name="JBossAS Server" plugin="JBossAS5"/>
+ </runs-inside>
- <plugin-configuration>
- <c:simple-property name="connectorAddress" default="http://192.168.1.56:6666"/>
- <c:simple-property name="objectName" readOnly="true" default="ModClusterServiceMBean"/>
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true" default="Catalina:type=ModClusterListener,*"/>
+ <c:simple-property name="nameTemplate" default="{application}"/>
</plugin-configuration>
-
+
+ <operation name="reset" displayName="Reset the node" description="Move the node out of an error state" />
+
+ <metric property="proxyConfiguration" displayName="Proxy Configuration" displayType="summary" dataType="trait" />
+ <metric property="modelerType" displayName="Type of the modeled resource" displayType="summary" dataType="trait" />
+ <metric property="className" displayName="Fully qualified class name of the managed object" displayType="summary" dataType="trait" />
+
</service>
</plugin>
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index 971ccb1..5f68989 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -20,6 +20,8 @@ package org.rhq.plugins.modcluster.test;
import java.io.File;
import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Queue;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -29,12 +31,18 @@ import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import org.rhq.core.clientapi.server.discovery.InventoryReport;
+import org.rhq.core.domain.measurement.MeasurementData;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.pc.PluginContainer;
import org.rhq.core.pc.PluginContainerConfiguration;
import org.rhq.core.pc.plugin.FileSystemPluginFinder;
import org.rhq.core.pc.plugin.PluginEnvironment;
import org.rhq.core.pc.plugin.PluginManager;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
/**
* @author Fady Matar
@@ -90,23 +98,53 @@ public class ModclusterPluginTest {
Set<Resource> resources = findResource(PluginContainer.getInstance().getInventoryManager().getPlatform(),
PLUGIN_NAME);
- log.info("Found " + resources.size() + "mod_cluster instance(s).");
+ log.info("Found " + resources.size() + " mod_cluster instance(s).");
+
+ if (resources.size() != 0) {
+ testResourceMeasurement((Resource) resources.toArray()[0]);
+ }
+ }
+
+ private void testResourceMeasurement(Resource resource) throws Exception {
+ ResourceComponent resourceComponent = PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+ if (resourceComponent instanceof MeasurementFacet) {
+ for (MeasurementDefinition def : resource.getResourceType().getMetricDefinitions()) {
+ Set<MeasurementScheduleRequest> metricList = new HashSet<MeasurementScheduleRequest>();
+ metricList.add(new MeasurementScheduleRequest(1, def.getName(), 1000, true, def.getDataType(), null));
+ MeasurementReport report = new MeasurementReport();
+ ((MeasurementFacet) resourceComponent).getValues(report, metricList);
+
+ /*assert report.getNumericData().size() > 0 : "Measurement " + def.getName() + " not collected from "
+ + resource;*/
+ MeasurementData data = report.getTraitData().iterator().next();
+ assert data != null : "Unable to collect trait [" + def.getName() + "] on " + resource;
+ log.info("Measurement: " + def.getName() + "=" + data.getValue());
+ }
+ }
}
private Set<Resource> findResource(Resource parent, String typeName) {
Set<Resource> found = new HashSet<Resource>();
- Resource platform = parent;
- for (Resource resource : platform.getChildResources()) {
- log.info("Discovered resource of type: " + resource.getResourceType().getName());
- if (resource.getResourceType().getName().equals(typeName)) {
- found.add(resource);
+
+ Queue<Resource> discoveryQueue = new LinkedList<Resource>();
+ discoveryQueue.add(parent);
+
+ while (!discoveryQueue.isEmpty()) {
+ Resource currentResource = discoveryQueue.poll();
+
+ log.info("Discovered resource of type: " + currentResource.getResourceType().getName());
+ if (currentResource.getResourceType().getName().equals(typeName)) {
+ found.add(currentResource);
}
- if (resource.getChildResources() != null) {
- for (Resource child : found) {
- found.addAll(findResource(child, typeName));
+
+ if (currentResource.getChildResources() != null) {
+ for (Resource child : currentResource.getChildResources()) {
+ discoveryQueue.add(child);
}
}
}
+
return found;
}
}
commit 5866fe5b6283debb6dfca115770301b1c1322489
Merge: 2884cc5 19558e1
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jun 28 09:31:15 2011 -0500
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq into mod_cluster_plugin
commit 2884cc5a209b7ab07f7fed6e8f38510c6c6683d5
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jun 28 09:21:49 2011 -0500
Attempts to make mod_cluster a simple derivation from JMX plugin.
diff --git a/.classpath b/.classpath
index 566c57d..6280671 100644
--- a/.classpath
+++ b/.classpath
@@ -266,5 +266,7 @@
<classpathentry excluding="**" kind="src" path="modules/enterprise/comm/src/test/resources"/>
<classpathentry excluding="**" kind="src" path="modules/enterprise/agent/src/main/resources"/>
<classpathentry excluding="**" kind="src" path="modules/enterprise/agent/src/test/resources"/>
+ <classpathentry kind="src" path="modules/plugins/mod-cluster/src/main/java"/>
+ <classpathentry kind="src" path="modules/plugins/mod-cluster/src/test/java"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml
index e22efc7..869a25e 100644
--- a/modules/plugins/mod-cluster/pom.xml
+++ b/modules/plugins/mod-cluster/pom.xml
@@ -1,5 +1,3 @@
-<?xml version="1.0"?>
-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -12,16 +10,11 @@
<groupId>org.rhq.plugins.modcluster</groupId>
<artifactId>modcluster-plugin</artifactId>
- <version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>mod_cluster RHQ Plugin</name>
<description>mod_cluster RHQ Agent plugin</description>
- <!--properties>
- <rhq.version>4.1.0-SNAPSHOT</rhq.version>
- </properties-->
-
<dependencies>
<dependency>
@@ -31,220 +24,170 @@
<scope>provided</scope>
</dependency>
- <!-- Below are the core modules that are required dependencies of all plugins -->
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <version>${rhq.version}</version>
- <scope>provided</scope> <!-- provided by the agent/plugin-container -->
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-plugin-api</artifactId>
- <version>${rhq.version}</version>
- <scope>provided</scope> <!-- provided by the agent/plugin-container -->
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-native-system</artifactId>
- <version>${rhq.version}</version>
- <scope>provided</scope> <!-- provided by the agent/plugin-container -->
- </dependency>
-
- <!-- Fix for the Javac bug requiring annotations to be available when compiling classes. (fixed in JDK 6) -->
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>1.0</version>
- <scope>provided</scope> <!-- provided by the agent/plugin-container -->
- </dependency>
-
- <!-- Fix for the Javac bug requiring annotations to be available when compiling classes. (fixed in JDK 6) -->
- <dependency>
- <groupId>hibernate-annotations</groupId>
- <artifactId>hibernate-annotations</artifactId>
- <version>3.2.1.GA</version>
- <scope>provided</scope> <!-- provided by the agent/plugin-container -->
- </dependency>
-
- <!-- Fix for the Javac bug requiring annotations to be available when compiling classes. (fixed in JDK 6) -->
- <dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
- <version>2.1</version>
- <scope>provided</scope> <!-- provided by the agent/plugin-container -->
- </dependency>
-
- <!--
- Uncomment the one of the three logging systems your plugin uses: log4j, commons-logging or i18nlog
- All three are provided to your plugin by the agent/plugin-container.
- -->
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1</version>
- <scope>provided</scope>
- </dependency>
-
-
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>provided</scope>
</dependency>
-
- <!--
- <dependency>
- <groupId>i18nlog</groupId>
- <artifactId>i18nlog</artifactId>
- <version>1.0.9</version>
- <scope>provided</scope>
- </dependency>
- -->
-
- <!-- Define any third-party dependencies your plugin has here. -->
- <!--
- <dependency>
- <groupId>group-id-of-dependency-goes-here</groupId>
- <artifactId>artifact-id-of-dependency-goes-here</artifactId>
- <version>version-of-dependency-goes-here</version>
- </dependency>
- -->
</dependencies>
- <build>
- <plugins>
-
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
-
- <!--
- If your plugin has third-party jar dependencies that are not already available when deployed in the plugin
- container, you can package these jars in your plugin. They go in your plugin jar's "lib" directory.
- Uncomment the maven plugin definition below and define one or more jar files (aka "artifactItem" elements)
- that you want to include in your plugin jar.
- -->
- <!--
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <phase>process-resources</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>your-third-party-dep-group</groupId>
- <artifactId>your-third-party-dep-artifact</artifactId>
- <version>your-third-party-dep-version</version>
- </artifactItem>
- </artifactItems>
- <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- -->
-
- </plugins>
- </build>
-
<profiles>
+
<profile>
- <id>dev</id>
+ <id>integration-tests</id>
+ <activation>
+ <property>
+ <name>maven.test.skip</name>
+ <value>!true</value>
+ </property>
+ </activation>
+
<properties>
- <!-- define the location of your RHQ root directory - typically rhq.rootDir is overridden in Maven's settings.xml -->
- <rhq.rootDir>/rhq/trunk</rhq.rootDir>
- <rhq.defaultDevContainerPath>dev-container</rhq.defaultDevContainerPath>
+ <rhq.rootDir>../../..</rhq.rootDir>
<rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
- <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/rhq.ear/rhq-downloads/rhq-plugins</rhq.deploymentDir>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-plugins</rhq.deploymentDir>
</properties>
+
<build>
<plugins>
+
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
- <version>1.1</version>
<executions>
<execution>
- <id>deploy</id>
- <phase>compile</phase>
+ <phase>process-test-resources</phase>
<configuration>
<tasks>
- <mkdir dir="${rhq.deploymentDir}" />
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Updating ${deployment.file}...</echo>
- <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ <echo>Setting up plugin dependencies...</echo>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository" />
+ <mkdir dir="target/testsetup" />
+
+ <mkdir dir="target/testsetup/plugins" />
+ <copy toDir="target/testsetup/plugins" flatten="true">
+ <fileset dir="${settings.localRepository}/">
+ <include name="org/rhq/rhq-platform-plugin/${project.version}/rhq-platform-plugin-${project.version}.jar" />
+ <include name="org/rhq/rhq-jmx-plugin/${project.version}/rhq-jmx-plugin-${project.version}.jar" />
+ </fileset>
+ <fileset dir="${rhq.deploymentDir}">
+ <include name="${project.artifactId}-${project.version}.jar" />
+ </fileset>
+ </copy>
+
+ <mkdir dir="target/testsetup/lib" />
+ <unzip dest="target/testsetup/lib">
+ <fileset dir="${settings.localRepository}/org/hyperic/sigar-dist/${sigar.version}" includes="*.zip" />
+ <patternset>
+ <include name="**/lib/sigar.jar" />
+ <include name="**/lib/bcel*.jar" />
+ <include name="**/lib/*.so" />
+ <include name="**/lib/*.sl" />
+ <include name="**/lib/*.dll" />
+ <include name="**/lib/*.dylib" />
+ </patternset>
+ </unzip>
+ <move todir="target/testsetup/lib" flatten="true">
+ <fileset dir="target/testsetup/lib">
+ <include name="**/lib/*" />
+ </fileset>
+ </move>
+ <delete dir="target/testsetup/lib/hyperic-sigar-${sigar.version}" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
+
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${rhq.deploymentDir}" />
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
<execution>
<id>deploy-jar-meta-inf</id>
<phase>package</phase>
<configuration>
- <tasks>
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Updating META-INF dir in ${deployment.file}...</echo>
- <unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.outputDirectory}">
- <patternset>
- <include name="META-INF/**" />
- </patternset>
- </unjar>
- <jar destfile="${deployment.file}"
- manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF"
- update="true">
- </jar>
- </tasks>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating META-INF dir in ${deployment.file}...</echo>
+ <unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.outputDirectory}">
+ <patternset><include name="META-INF/**" /></patternset>
+ </unjar>
+ <jar destfile="${deployment.file}" manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF" update="true">
+ </jar>
+ </tasks>
</configuration>
<goals>
- <goal>run</goal>
+ <goal>run</goal>
</goals>
</execution>
+
<execution>
<id>undeploy</id>
<phase>clean</phase>
<configuration>
- <tasks>
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Deleting ${deployment.file}...</echo>
- <delete file="${deployment.file}" />
- </tasks>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}" />
+ </tasks>
</configuration>
<goals>
- <goal>run</goal>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ <executions>
+ <execution>
+ <id>surefire-it</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
</goals>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
+ <useSystemClassLoader>false</useSystemClassLoader>
+ <argLine>-Dorg.hyperic.sigar.path=${basedir}/target/testsetup/lib</argLine>
+ <systemProperties>
+ <property>
+ <name>project.artifactId</name>
+ <value>${project.artifactId}</value>
+ </property>
+ <property>
+ <name>project.version</name>
+ <value>${project.version}</value>
+ </property>
+ </systemProperties>
+ </configuration>
</execution>
</executions>
</plugin>
+
</plugins>
</build>
</profile>
</profiles>
- <repositories>
- <repository>
- <id>jboss-public-repository-group</id>
- <name>JBoss Public Maven Repository Group</name>
- <url>https://repository.jboss.org/nexus/content/groups/public/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
-
</project>
-
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetric.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetric.java
new file mode 100644
index 0000000..1223508
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetric.java
@@ -0,0 +1,29 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import org.rhq.plugins.jmx.MBeanResourceComponent;
+
+/**
+ * @author Stefan Negrea
+ *
+ */
+public class LoadMetric extends MBeanResourceComponent {
+
+}
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterDiscoveryComponent.java
new file mode 100644
index 0000000..fa807a3
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterDiscoveryComponent.java
@@ -0,0 +1,116 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ManualAddFacet;
+import org.rhq.core.pluginapi.inventory.ProcessScanResult;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+
+/**
+ * This can be the start of your own custom plugin's discovery component. Review the javadoc for
+ * {@link ResourceDiscoveryComponent}.
+ *
+ * @author John Mazzitelli
+ */
+@SuppressWarnings("unchecked")
+public class ModclusterDiscoveryComponent implements ResourceDiscoveryComponent, ManualAddFacet {
+ private final Log log = LogFactory.getLog(ModclusterDiscoveryComponent.class);
+
+ /**
+ * This discovery method is the way the plugin supports "manual-add" capability. The plugin
+ * descriptor must specify supportsManualAdd="true" to allow the resource to be manually added.
+ * If that attribute is false, this method will never be used since it will not be possible to manually
+ * add an instance of the resource.
+ *
+ * Review the javadoc for both {@link ManualAddFacet} and {@link ResourceDiscoveryContext} to learn what
+ * you need to do in this method.
+ *
+ * @see ManualAddFacet#discoverResource(Configuration, ResourceDiscoveryContext)
+ */
+ @Override
+ public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration,
+ ResourceDiscoveryContext context) throws InvalidPluginConfigurationException {
+
+ // pluginConfiguration contains information on a resource that was manually added by the user.
+ // take it and build a details object that represents that resource.
+
+ // key = this must be a unique string across all of your resources - see docs for uniqueness rules
+ // name = this is the name you give the new resource; it does not necessarily have to be unique
+ // version = this is any string that corresponds to the resource's version
+ // description = this is any string that you want to assign as the default description for your resource
+ String key = "My Manually Added Resource Key";
+ String name = "My Resource";
+ String version = "1.0";
+ String description = "This describes My Resource";
+
+ DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
+ version, description, pluginConfiguration, null);
+
+ return resource;
+ }
+
+ /**
+ * Review the javadoc for both {@link ResourceDiscoveryComponent} and {@link ResourceDiscoveryContext} to learn what
+ * you need to do in this method.
+ *
+ * @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext)
+ */
+ @Override
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
+ log.info("Discovering my custom plugin's resources");
+
+ // if your plugin descriptor defined one or more <process-scan>s, then see if the plugin container
+ // auto-discovered processes using those process scan definitions. Process all those that were found.
+ List<ProcessScanResult> autoDiscoveryResults = context.getAutoDiscoveredProcesses();
+ for (ProcessScanResult autoDiscoveryResult : autoDiscoveryResults) {
+ // determine if you want to include the result in this method's returned set of discovered resources
+ }
+
+ // now perform your own discovery mechanism, if you have one. For each resource discovered, you need to
+ // create a details object that describe the resource that you discovered.
+ HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
+
+ // key = this must be a unique string across all of your resources - see docs for uniqueness rules
+ // name = this is the name you give the new resource; it does not necessarily have to be unique
+ // version = this is any string that corresponds to the resource's version
+ // description = this is any string that you want to assign as the default description for your resource
+ String key = "My Resource Key";
+ String name = "My Resource";
+ String version = "1.0";
+ String description = "This describes My Resource";
+
+ DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
+ version, description, null, null);
+
+ set.add(resource);
+
+ return set;
+ }
+}
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
new file mode 100644
index 0000000..6d6998a
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -0,0 +1,168 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
+
+/**
+ * This can be the start of your own custom plugin's server component. Review the javadoc for {@link ResourceComponent}
+ * and all the facet interfaces to learn what you can do in your resource component. This component has a lot of methods
+ * in it because it implements all possible facets. If your resource does not support, for example, configuration, you
+ * can remove the {@link ConfigurationFacet} from the <code>implements</code> clause and remove all method
+ * implementations that that facet required.
+ *
+ * <p>You should not only read the javadoc in each of this class' methods, but you should also read the javadocs linked
+ * by their "see" javadoc tags since those additional javadocs will contain a good deal of additional information you
+ * will need to know.</p>
+ *
+ * @author John Mazzitelli
+ */
+public class ModclusterServerComponent implements ResourceComponent, MeasurementFacet, OperationFacet,
+ ConfigurationFacet {
+ private final Log log = LogFactory.getLog(ModclusterServerComponent.class);
+
+ /**
+ * Represents the resource configuration of the custom product being managed.
+ */
+ private Configuration resourceConfiguration;
+
+ /**
+ * All AMPS plugins are stateful - this context contains information that your resource component can use when
+ * performing its processing.
+ */
+ private ResourceContext resourceContext;
+
+ /**
+ * This is called when your component has been started with the given context. You normally initialize some internal
+ * state of your component as well as attempt to make a stateful connection to your managed resource.
+ *
+ * @see ResourceComponent#start(ResourceContext)
+ */
+ public void start(ResourceContext context) {
+ resourceContext = context;
+ }
+
+ /**
+ * This is called when the component is being stopped, usually due to the plugin container shutting down. You can
+ * perform some cleanup here; though normally not much needs to be done here.
+ *
+ * @see ResourceComponent#stop()
+ */
+ public void stop() {
+ }
+
+ /**
+ * All resource components must be able to tell the plugin container if the managed resource is available or not.
+ * This method is called by the plugin container when it needs to know if the managed resource is actually up and
+ * available.
+ *
+ * @see ResourceComponent#getAvailability()
+ */
+ public AvailabilityType getAvailability() {
+ // TODO: here you normally make some type of connection attempt to the managed resource
+ // to determine if it is really up and running.
+ return AvailabilityType.UP;
+ }
+
+ /**
+ * The plugin container will call this method when your resource component has been scheduled to collect some
+ * measurements now. It is within this method that you actually talk to the managed resource and collect the
+ * measurement data that is has emitted.
+ *
+ * @see MeasurementFacet#getValues(MeasurementReport, Set)
+ */
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) {
+ for (MeasurementScheduleRequest request : requests) {
+ String name = request.getName();
+
+ // TODO: based on the request information, you must collect the requested measurement(s)
+ // you can use the name of the measurement to determine what you actually need to collect
+ try {
+ Number value = new Integer(1); // dummy measurement value - this should come from the managed resource
+ report.addData(new MeasurementDataNumeric(request, value.doubleValue()));
+ } catch (Exception e) {
+ log.error("Failed to obtain measurement [" + name + "]. Cause: " + e);
+ }
+ }
+
+ return;
+ }
+
+ /**
+ * The plugin container will call this method when it wants to invoke an operation on your managed resource. Your
+ * plugin will connect to the managed resource and invoke the analogous operation in your own custom way.
+ *
+ * @see OperationFacet#invokeOperation(String, Configuration)
+ */
+ public OperationResult invokeOperation(String name, Configuration configuration) {
+ return null;
+ }
+
+ /**
+ * The plugin container will call this method and it needs to obtain the current configuration of the managed
+ * resource. Your plugin will obtain the managed resource's configuration in your own custom way and populate the
+ * returned Configuration object with the managed resource's configuration property values.
+ *
+ * @see ConfigurationFacet#loadResourceConfiguration()
+ */
+ public Configuration loadResourceConfiguration() {
+ // here we simulate the loading of the managed resource's configuration
+
+ if (resourceConfiguration == null) {
+ // for this example, we will create a simple dummy configuration to start with.
+ // note that it is empty, so we're assuming there are no required configs in the plugin descriptor.
+ resourceConfiguration = new Configuration();
+ }
+
+ Configuration config = resourceConfiguration;
+
+ return config;
+ }
+
+ /**
+ * The plugin container will call this method when it has a new configuration for your managed resource. Your plugin
+ * will re-configure the managed resource in your own custom way, setting its configuration based on the new values
+ * of the given configuration.
+ *
+ * @see ConfigurationFacet#updateResourceConfiguration(ConfigurationUpdateReport)
+ */
+ public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ // this simulates the plugin taking the new configuration and reconfiguring the managed resource
+ resourceConfiguration = report.getConfiguration().deepCopy();
+
+ report.setStatus(ConfigurationUpdateStatus.SUCCESS);
+ }
+}
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java
deleted file mode 100644
index 2abd0ea..0000000
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ManualAddFacet;
-import org.rhq.core.pluginapi.inventory.ProcessScanResult;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-
-/**
- * This can be the start of your own custom plugin's discovery component. Review the javadoc for
- * {@link ResourceDiscoveryComponent}.
- *
- * @author John Mazzitelli
- */
-@SuppressWarnings("unchecked")
-public class SamplePluginDiscoveryComponent implements ResourceDiscoveryComponent, ManualAddFacet {
- private final Log log = LogFactory.getLog(SamplePluginDiscoveryComponent.class);
-
- /**
- * This discovery method is the way the plugin supports "manual-add" capability. The plugin
- * descriptor must specify supportsManualAdd="true" to allow the resource to be manually added.
- * If that attribute is false, this method will never be used since it will not be possible to manually
- * add an instance of the resource.
- *
- * Review the javadoc for both {@link ManualAddFacet} and {@link ResourceDiscoveryContext} to learn what
- * you need to do in this method.
- *
- * @see ManualAddFacet#discoverResource(Configuration, ResourceDiscoveryContext)
- */
- @Override
- public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration,
- ResourceDiscoveryContext context) throws InvalidPluginConfigurationException {
-
- // pluginConfiguration contains information on a resource that was manually added by the user.
- // take it and build a details object that represents that resource.
-
- // key = this must be a unique string across all of your resources - see docs for uniqueness rules
- // name = this is the name you give the new resource; it does not necessarily have to be unique
- // version = this is any string that corresponds to the resource's version
- // description = this is any string that you want to assign as the default description for your resource
- String key = "My Manually Added Resource Key";
- String name = "My Resource";
- String version = "1.0";
- String description = "This describes My Resource";
-
- DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
- version, description, pluginConfiguration, null);
-
- return resource;
- }
-
- /**
- * Review the javadoc for both {@link ResourceDiscoveryComponent} and {@link ResourceDiscoveryContext} to learn what
- * you need to do in this method.
- *
- * @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext)
- */
- @Override
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
- log.info("Discovering my custom plugin's resources");
-
- // if your plugin descriptor defined one or more <process-scan>s, then see if the plugin container
- // auto-discovered processes using those process scan definitions. Process all those that were found.
- List<ProcessScanResult> autoDiscoveryResults = context.getAutoDiscoveredProcesses();
- for (ProcessScanResult autoDiscoveryResult : autoDiscoveryResults) {
- // determine if you want to include the result in this method's returned set of discovered resources
- }
-
- // now perform your own discovery mechanism, if you have one. For each resource discovered, you need to
- // create a details object that describe the resource that you discovered.
- HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
-
- // key = this must be a unique string across all of your resources - see docs for uniqueness rules
- // name = this is the name you give the new resource; it does not necessarily have to be unique
- // version = this is any string that corresponds to the resource's version
- // description = this is any string that you want to assign as the default description for your resource
- String key = "My Resource Key";
- String name = "My Resource";
- String version = "1.0";
- String description = "This describes My Resource";
-
- DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
- version, description, null, null);
-
- set.add(resource);
-
- return set;
- }
-}
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java
deleted file mode 100644
index 0236532..0000000
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster;
-
-import java.io.InputStream;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
-import org.rhq.core.domain.content.PackageType;
-import org.rhq.core.domain.content.transfer.DeployPackageStep;
-import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
-import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
-import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.MeasurementDataNumeric;
-import org.rhq.core.domain.measurement.MeasurementReport;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
-import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
-import org.rhq.core.pluginapi.content.ContentFacet;
-import org.rhq.core.pluginapi.content.ContentServices;
-import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
-import org.rhq.core.pluginapi.inventory.CreateResourceReport;
-import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.core.pluginapi.measurement.MeasurementFacet;
-import org.rhq.core.pluginapi.operation.OperationFacet;
-import org.rhq.core.pluginapi.operation.OperationResult;
-
-/**
- * This can be the start of your own custom plugin's server component. Review the javadoc for {@link ResourceComponent}
- * and all the facet interfaces to learn what you can do in your resource component. This component has a lot of methods
- * in it because it implements all possible facets. If your resource does not support, for example, configuration, you
- * can remove the {@link ConfigurationFacet} from the <code>implements</code> clause and remove all method
- * implementations that that facet required.
- *
- * <p>You should not only read the javadoc in each of this class' methods, but you should also read the javadocs linked
- * by their "see" javadoc tags since those additional javadocs will contain a good deal of additional information you
- * will need to know.</p>
- *
- * @author John Mazzitelli
- */
-public class SamplePluginServerComponent implements ResourceComponent, MeasurementFacet, OperationFacet,
- ConfigurationFacet, ContentFacet, DeleteResourceFacet, CreateChildResourceFacet {
- private final Log log = LogFactory.getLog(SamplePluginServerComponent.class);
-
- /**
- * Represents the resource configuration of the custom product being managed.
- */
- private Configuration resourceConfiguration;
-
- /**
- * All AMPS plugins are stateful - this context contains information that your resource component can use when
- * performing its processing.
- */
- private ResourceContext resourceContext;
-
- /**
- * This is called when your component has been started with the given context. You normally initialize some internal
- * state of your component as well as attempt to make a stateful connection to your managed resource.
- *
- * @see ResourceComponent#start(ResourceContext)
- */
- public void start(ResourceContext context) {
- resourceContext = context;
- }
-
- /**
- * This is called when the component is being stopped, usually due to the plugin container shutting down. You can
- * perform some cleanup here; though normally not much needs to be done here.
- *
- * @see ResourceComponent#stop()
- */
- public void stop() {
- }
-
- /**
- * All resource components must be able to tell the plugin container if the managed resource is available or not.
- * This method is called by the plugin container when it needs to know if the managed resource is actually up and
- * available.
- *
- * @see ResourceComponent#getAvailability()
- */
- public AvailabilityType getAvailability() {
- // TODO: here you normally make some type of connection attempt to the managed resource
- // to determine if it is really up and running.
- return AvailabilityType.UP;
- }
-
- /**
- * The plugin container will call this method when your resource component has been scheduled to collect some
- * measurements now. It is within this method that you actually talk to the managed resource and collect the
- * measurement data that is has emitted.
- *
- * @see MeasurementFacet#getValues(MeasurementReport, Set)
- */
- public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) {
- for (MeasurementScheduleRequest request : requests) {
- String name = request.getName();
-
- // TODO: based on the request information, you must collect the requested measurement(s)
- // you can use the name of the measurement to determine what you actually need to collect
- try {
- Number value = new Integer(1); // dummy measurement value - this should come from the managed resource
- report.addData(new MeasurementDataNumeric(request, value.doubleValue()));
- } catch (Exception e) {
- log.error("Failed to obtain measurement [" + name + "]. Cause: " + e);
- }
- }
-
- return;
- }
-
- /**
- * The plugin container will call this method when it wants to invoke an operation on your managed resource. Your
- * plugin will connect to the managed resource and invoke the analogous operation in your own custom way.
- *
- * @see OperationFacet#invokeOperation(String, Configuration)
- */
- public OperationResult invokeOperation(String name, Configuration configuration) {
- return null;
- }
-
- /**
- * The plugin container will call this method and it needs to obtain the current configuration of the managed
- * resource. Your plugin will obtain the managed resource's configuration in your own custom way and populate the
- * returned Configuration object with the managed resource's configuration property values.
- *
- * @see ConfigurationFacet#loadResourceConfiguration()
- */
- public Configuration loadResourceConfiguration() {
- // here we simulate the loading of the managed resource's configuration
-
- if (resourceConfiguration == null) {
- // for this example, we will create a simple dummy configuration to start with.
- // note that it is empty, so we're assuming there are no required configs in the plugin descriptor.
- resourceConfiguration = new Configuration();
- }
-
- Configuration config = resourceConfiguration;
-
- return config;
- }
-
- /**
- * The plugin container will call this method when it has a new configuration for your managed resource. Your plugin
- * will re-configure the managed resource in your own custom way, setting its configuration based on the new values
- * of the given configuration.
- *
- * @see ConfigurationFacet#updateResourceConfiguration(ConfigurationUpdateReport)
- */
- public void updateResourceConfiguration(ConfigurationUpdateReport report) {
- // this simulates the plugin taking the new configuration and reconfiguring the managed resource
- resourceConfiguration = report.getConfiguration().deepCopy();
-
- report.setStatus(ConfigurationUpdateStatus.SUCCESS);
- }
-
- /**
- * When this is called, the plugin is responsible for scanning its managed resource and look for content that need
- * to be managed for that resource. This method should only discover packages of the given package type.
- *
- * @see ContentFacet#discoverDeployedPackages(PackageType)
- */
- public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) {
- return null;
- }
-
- /**
- * The plugin container calls this method when new packages need to be deployed/installed on resources.
- *
- * @see ContentFacet#deployPackages(Set, ContentServices)
- */
- public DeployPackagesResponse deployPackages(Set<ResourcePackageDetails> packages, ContentServices contentServices) {
- return null;
- }
-
- /**
- * When a remote client wants to see the actual data content for an installed package, this method will be called.
- * This method must return a stream of data containing the full content of the package.
- *
- * @see ContentFacet#retrievePackageBits(ResourcePackageDetails)
- */
- public InputStream retrievePackageBits(ResourcePackageDetails packageDetails) {
- return null;
- }
-
- /**
- * This is the method that is used when the component has to create the installation steps and their results.
- *
- * @see ContentFacet#generateInstallationSteps(ResourcePackageDetails)
- */
- public List<DeployPackageStep> generateInstallationSteps(ResourcePackageDetails packageDetails) {
- return null;
- }
-
- /**
- * This is called when the actual content of packages should be deleted from the managed resource.
- *
- * @see ContentFacet#removePackages(Set)
- */
- public RemovePackagesResponse removePackages(Set<ResourcePackageDetails> packages) {
- return null;
- }
-
- /**
- * When called, the plugin container is asking the plugin to create a new managed resource. The new resource's
- * details need to be added to the given report.
- *
- * @see CreateChildResourceFacet#createResource(CreateResourceReport)
- */
- public CreateResourceReport createResource(CreateResourceReport report) {
- return null;
- }
-
- /**
- * When called, the plugin container is asking the plugin to delete a managed resource.
- *
- * @see DeleteResourceFacet#deleteResource()
- */
- public void deleteResource() {
- }
-}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 1a99bf7..fe6d1b3 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -10,97 +10,23 @@
<depends plugin="JMX" />
- <!--
- CHANGE: The following is a sample server resource type. This entry is here to serve as a model and should
- be removed prior to deploying the plugin. Multiple resource types (either server or service) may be
- defined at this level.
- -->
- <server name="mod_cluster"
- discovery="SamplePluginDiscoveryComponent"
- class="SamplePluginServerComponent"
+ <service name="mod_cluster"
+ discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
+ class="LoadMetric"
supportsManualAdd="true"
description="mod_cluster plugin">
-
- <!--
- CHANGE: Categories are optional; this entire section may be removed if there is no need to further group
- related child resources. Categories defined at this level can carry metadata on the category itself,
- such as a display name and description.
- -->
- <subcategories>
- <subcategory name="Category1" displayName="Sample Category 1"
- description="This is a sample category that should be removed."/>
- <subcategory name="Category2" >
- <subcategory name="ChildCategory2a" />
- </subcategory>
- </subcategories>
-
- <!--
- CHANGE: The entire plugin configuration is optional. If there are properties specific to handling how the
- resource component will connect to the resource, they should be added here. If the plugin-configuration
- entity is specified, at least one property must be provided.
- -->
- <plugin-configuration>
- <c:simple-property name="SamplePluginProperty" displayName="Sample Plugin Property" default="Value" />
+
+ <!-- runs-inside>
+ <parent-resource-type name="JMX Server" plugin="JMX"/>
+ </runs-inside-->
+ <runs-inside>
+ <parent-resource-type name="JMX Server" plugin="JMX"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="connectorAddress" default="http://192.168.1.56:6666"/>
+ <c:simple-property name="objectName" readOnly="true" default="ModClusterServiceMBean"/>
</plugin-configuration>
- <!--
- CHANGE: The process-scan element requests the plugin container provide the discovery component for
- this resource type with the results of scanning the machine for running processes. If there is
- no use for this in a given resource type, this entry may be omitted.
- -->
- <process-scan name="ScanIdentifier" query="process|basename|match=^java.*,arg|org.jboss.Main|match=.*"/>
-
- <!--
- CHANGE: An operation element is added for each operation that may be executed against resources of this type.
- The parameters element is optional; properties defined within will be displayed to the user when
- invoking the operation. If the resource has no applicable operations, these elements may be omitted.
-
- REQUIRED INTERFACE: The resource component for this resource type must implement the OperationFacet interface
- if any operations are specified.
- -->
- <operation name="testSimple"
- description="Test simple-property configuration element for a resource operation">
- <parameters>
- <c:group name="required" displayName="Required Parameters" hiddenByDefault="false">
- <c:description>All of these properties are required</c:description>
- <c:simple-property name="aNumber" type="integer" required="true" default="42" displayName="A Number" description="A number between 1 and 100, inclusive">
- <c:constraint>
- <c:integer-constraint minimum="1" maximum="100"/>
- </c:constraint>
- </c:simple-property>
- </c:group>
- </parameters>
- <results>
- <c:simple-property name="results" />
- </results>
- </operation>
-
- <!--
- CHANGE: For each measurement that should be collected for resources of this type, a metric element is added.
- In addition to identifying the metric, a default collection interval and whether or not the
- metric is even collected by default are indicated. If the resource has no measurements to be
- collected, these elements may be omitted.
-
- REQUIRED INTERFACE: The resource component for this resource type must implement the MeasurementFacet interface
- if any metrics are specified.
- -->
- <metric property="MeasurementName"
- displayName="The Measurement Name"
- description="Describes what this measurement is actually telling you"
- defaultOn="true"
- defaultInterval="300000"
- category="performance" />
-
- <!--
- CHANGE: Resource configuration properties are used to configure resources themselves, as compared to the plugin
- configuration which refers to the connection to a resource. If the resource-configuration
- entity is specified, at least one property must be provided.
-
- REQUIRED INTERFACE: The resource component for this resource type must implement the ConfigurationFacet
- interface if a resource-configuration element is supplied.
- -->
- <resource-configuration>
- <c:simple-property name="port" type="integer" displayName="Port on which to listen" />
- </resource-configuration>
- </server>
+ </service>
</plugin>
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index bada521..971ccb1 100644
--- a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -24,6 +24,9 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.domain.resource.Resource;
@@ -32,22 +35,19 @@ import org.rhq.core.pc.PluginContainerConfiguration;
import org.rhq.core.pc.plugin.FileSystemPluginFinder;
import org.rhq.core.pc.plugin.PluginEnvironment;
import org.rhq.core.pc.plugin.PluginManager;
-import org.testng.annotations.AfterSuite;
-import org.testng.annotations.BeforeSuite;
-import org.testng.annotations.Test;
/**
* @author Fady Matar
*/
-@Test(groups = "tomcat-plugin")
+@Test(groups = "modcluster-plugin")
public class ModclusterPluginTest {
private Log log = LogFactory.getLog(this.getClass());
- private static final String PLUGIN_NAME = "Tomcat";
+ private static final String PLUGIN_NAME = "mod_cluster";
@BeforeSuite
public void start() {
try {
- File pluginDir = new File("target/itest/plugins");
+ File pluginDir = new File("target/testsetup/plugins");
PluginContainerConfiguration pcConfig = new PluginContainerConfiguration();
pcConfig.setPluginFinder(new FileSystemPluginFinder(pluginDir));
pcConfig.setPluginDirectory(pluginDir);
@@ -75,16 +75,22 @@ public class ModclusterPluginTest {
PluginEnvironment pluginEnvironment = pluginManager.getPlugin(PLUGIN_NAME);
assert (pluginEnvironment != null) : "Null environment, plugin not loaded";
assert (pluginEnvironment.getPluginName().equals(PLUGIN_NAME));
+
}
@Test(dependsOnMethods = "testPluginLoad")
public void testDiscovery() throws Exception {
InventoryReport report = PluginContainer.getInstance().getInventoryManager().executeServerScanImmediately();
assert report != null;
- log.info("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+ System.out.println("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+
+ report = PluginContainer.getInstance().getInventoryManager().executeServiceScanImmediately();
+ assert report != null;
+ System.out.println("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+
Set<Resource> resources = findResource(PluginContainer.getInstance().getInventoryManager().getPlatform(),
- "Tomcat");
- log.info("Found " + resources.size() + " ews / apache tomcat instance(s).");
+ PLUGIN_NAME);
+ log.info("Found " + resources.size() + "mod_cluster instance(s).");
}
private Set<Resource> findResource(Resource parent, String typeName) {
commit 82bacafdbd2cc892ad6e98a2a7362ae36cc61c57
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jun 23 11:09:56 2011 -0500
A couple of updates to modcluster plugin based on tomcat plugin (modified the initial template commit).
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml
index b72c93d..e22efc7 100644
--- a/modules/plugins/mod-cluster/pom.xml
+++ b/modules/plugins/mod-cluster/pom.xml
@@ -1,25 +1,36 @@
<?xml version="1.0"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.rhq.sample.skeletonplugin</groupId>
- <artifactId>skeleton-plugin</artifactId>
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-plugins-parent</artifactId>
+ <version>4.1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.rhq.plugins.modcluster</groupId>
+ <artifactId>modcluster-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
- <name>Skeleton RHQ Plugin Template</name>
- <description>A template for building a custom RHQ Agent plugin</description>
+ <name>mod_cluster RHQ Plugin</name>
+ <description>mod_cluster RHQ Agent plugin</description>
- <properties>
+ <!--properties>
<rhq.version>4.1.0-SNAPSHOT</rhq.version>
- </properties>
+ </properties-->
<dependencies>
+ <dependency>
+ <groupId>${rhq.groupId}</groupId>
+ <artifactId>rhq-jmx-plugin</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
<!-- Below are the core modules that are required dependencies of all plugins -->
<dependency>
<groupId>org.rhq</groupId>
@@ -77,15 +88,14 @@
<scope>provided</scope>
</dependency>
- <!--
+
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>provided</scope>
</dependency>
- -->
-
+
<!--
<dependency>
<groupId>i18nlog</groupId>
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java
index 2bb46e6..2abd0ea 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-package org.rhq.sample.skeletonplugin;
+package org.rhq.plugins.modcluster;
import java.util.HashSet;
import java.util.List;
@@ -113,4 +113,4 @@ public class SamplePluginDiscoveryComponent implements ResourceDiscoveryComponen
return set;
}
-}
\ No newline at end of file
+}
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java
index 701afb0..0236532 100644
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-package org.rhq.sample.skeletonplugin;
+package org.rhq.plugins.modcluster;
import java.io.InputStream;
import java.util.List;
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 2547af7..1a99bf7 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -1,36 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- See the rhq-plugin.xsd file for detailed documentatoin on the schema. The notes in this file are to
- facilitate using this file as a base plugin descriptor.
--->
-
-<!--
- CHANGE: The name (and optional displayName) should be changed to reflect the plugin being developed. Keep in mind
- the value for name must be unique across all other plugins that are deployed.
-
- The package attribute should be changed to reflect the package in which all of the component classes
- are built.
--->
-<plugin name="SkeletonPlugin"
- displayName="Skeleton Plugin"
+<plugin name="mod_cluster"
+ displayName="mod_cluster"
version="1.0"
- package="org.rhq.sample.skeletonplugin"
+ package="org.rhq.plugins.modcluster"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin"
xmlns:c="urn:xmlns:rhq-configuration">
+ <depends plugin="JMX" />
- <!--
+ <!--
CHANGE: The following is a sample server resource type. This entry is here to serve as a model and should
be removed prior to deploying the plugin. Multiple resource types (either server or service) may be
defined at this level.
-->
- <server name="Sample Plugin Server"
+ <server name="mod_cluster"
discovery="SamplePluginDiscoveryComponent"
class="SamplePluginServerComponent"
supportsManualAdd="true"
- description="This is a sample resource type and should be removed.">
+ description="mod_cluster plugin">
<!--
CHANGE: Categories are optional; this entire section may be removed if there is no need to further group
diff --git a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
new file mode 100644
index 0000000..bada521
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -0,0 +1,106 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster.test;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.clientapi.server.discovery.InventoryReport;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.pc.PluginContainer;
+import org.rhq.core.pc.PluginContainerConfiguration;
+import org.rhq.core.pc.plugin.FileSystemPluginFinder;
+import org.rhq.core.pc.plugin.PluginEnvironment;
+import org.rhq.core.pc.plugin.PluginManager;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
+
+/**
+ * @author Fady Matar
+ */
+@Test(groups = "tomcat-plugin")
+public class ModclusterPluginTest {
+ private Log log = LogFactory.getLog(this.getClass());
+ private static final String PLUGIN_NAME = "Tomcat";
+
+ @BeforeSuite
+ public void start() {
+ try {
+ File pluginDir = new File("target/itest/plugins");
+ PluginContainerConfiguration pcConfig = new PluginContainerConfiguration();
+ pcConfig.setPluginFinder(new FileSystemPluginFinder(pluginDir));
+ pcConfig.setPluginDirectory(pluginDir);
+
+ pcConfig.setInsideAgent(false);
+ PluginContainer.getInstance().setConfiguration(pcConfig);
+ PluginContainer.getInstance().initialize();
+ log.info("PC started.");
+ for (String plugin : PluginContainer.getInstance().getPluginManager().getMetadataManager().getPluginNames()) {
+ log.info("...Loaded plugin: " + plugin);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterSuite
+ public void stop() {
+ PluginContainer.getInstance().shutdown();
+ }
+
+ @Test
+ public void testPluginLoad() {
+ PluginManager pluginManager = PluginContainer.getInstance().getPluginManager();
+ PluginEnvironment pluginEnvironment = pluginManager.getPlugin(PLUGIN_NAME);
+ assert (pluginEnvironment != null) : "Null environment, plugin not loaded";
+ assert (pluginEnvironment.getPluginName().equals(PLUGIN_NAME));
+ }
+
+ @Test(dependsOnMethods = "testPluginLoad")
+ public void testDiscovery() throws Exception {
+ InventoryReport report = PluginContainer.getInstance().getInventoryManager().executeServerScanImmediately();
+ assert report != null;
+ log.info("Discovery took: " + (report.getEndTime() - report.getStartTime()) + "ms");
+ Set<Resource> resources = findResource(PluginContainer.getInstance().getInventoryManager().getPlatform(),
+ "Tomcat");
+ log.info("Found " + resources.size() + " ews / apache tomcat instance(s).");
+ }
+
+ private Set<Resource> findResource(Resource parent, String typeName) {
+ Set<Resource> found = new HashSet<Resource>();
+ Resource platform = parent;
+ for (Resource resource : platform.getChildResources()) {
+ log.info("Discovered resource of type: " + resource.getResourceType().getName());
+ if (resource.getResourceType().getName().equals(typeName)) {
+ found.add(resource);
+ }
+ if (resource.getChildResources() != null) {
+ for (Resource child : found) {
+ found.addAll(findResource(child, typeName));
+ }
+ }
+ }
+ return found;
+ }
+}
diff --git a/modules/plugins/mod-cluster/src/test/resources/log4j.xml b/modules/plugins/mod-cluster/src/test/resources/log4j.xml
new file mode 100644
index 0000000..9ac1be8
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/test/resources/log4j.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml 9973 2008-05-08 00:57:31Z ispringer $ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="INFO"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Messagen -->
+
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+
+ <!--<param name="ConversionPattern" value="%-5p %d{dd-MM HH:mm:ss,SSS} (%F:%M:%L) -%m%n"/>-->
+ </layout>
+ </appender>
+
+ <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
+ <param name="File" value="target/test.log"/>
+ <param name="Threshold" value="DEBUG"/>
+ <param name="Append" value="false"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Messagen -->
+ <!--
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ -->
+ <param name="ConversionPattern" value="%-5p %d{dd-MM HH:mm:ss,SSS} (%F:%M:%L) -%m%n"/>
+ </layout>
+ </appender>
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
commit 68ca76535a5aa082a5adbfa3adae1d49c9da2300
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Jun 22 15:52:27 2011 -0500
Start for mod_cluster plugin from skeleton-plugin template.
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml
new file mode 100644
index 0000000..b72c93d
--- /dev/null
+++ b/modules/plugins/mod-cluster/pom.xml
@@ -0,0 +1,240 @@
+<?xml version="1.0"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.rhq.sample.skeletonplugin</groupId>
+ <artifactId>skeleton-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>Skeleton RHQ Plugin Template</name>
+ <description>A template for building a custom RHQ Agent plugin</description>
+
+ <properties>
+ <rhq.version>4.1.0-SNAPSHOT</rhq.version>
+ </properties>
+
+ <dependencies>
+
+ <!-- Below are the core modules that are required dependencies of all plugins -->
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${rhq.version}</version>
+ <scope>provided</scope> <!-- provided by the agent/plugin-container -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-plugin-api</artifactId>
+ <version>${rhq.version}</version>
+ <scope>provided</scope> <!-- provided by the agent/plugin-container -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-native-system</artifactId>
+ <version>${rhq.version}</version>
+ <scope>provided</scope> <!-- provided by the agent/plugin-container -->
+ </dependency>
+
+ <!-- Fix for the Javac bug requiring annotations to be available when compiling classes. (fixed in JDK 6) -->
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope> <!-- provided by the agent/plugin-container -->
+ </dependency>
+
+ <!-- Fix for the Javac bug requiring annotations to be available when compiling classes. (fixed in JDK 6) -->
+ <dependency>
+ <groupId>hibernate-annotations</groupId>
+ <artifactId>hibernate-annotations</artifactId>
+ <version>3.2.1.GA</version>
+ <scope>provided</scope> <!-- provided by the agent/plugin-container -->
+ </dependency>
+
+ <!-- Fix for the Javac bug requiring annotations to be available when compiling classes. (fixed in JDK 6) -->
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope> <!-- provided by the agent/plugin-container -->
+ </dependency>
+
+ <!--
+ Uncomment the one of the three logging systems your plugin uses: log4j, commons-logging or i18nlog
+ All three are provided to your plugin by the agent/plugin-container.
+ -->
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!--
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>provided</scope>
+ </dependency>
+ -->
+
+ <!--
+ <dependency>
+ <groupId>i18nlog</groupId>
+ <artifactId>i18nlog</artifactId>
+ <version>1.0.9</version>
+ <scope>provided</scope>
+ </dependency>
+ -->
+
+ <!-- Define any third-party dependencies your plugin has here. -->
+ <!--
+ <dependency>
+ <groupId>group-id-of-dependency-goes-here</groupId>
+ <artifactId>artifact-id-of-dependency-goes-here</artifactId>
+ <version>version-of-dependency-goes-here</version>
+ </dependency>
+ -->
+
+ </dependencies>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+
+ <!--
+ If your plugin has third-party jar dependencies that are not already available when deployed in the plugin
+ container, you can package these jars in your plugin. They go in your plugin jar's "lib" directory.
+ Uncomment the maven plugin definition below and define one or more jar files (aka "artifactItem" elements)
+ that you want to include in your plugin jar.
+ -->
+ <!--
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>your-third-party-dep-group</groupId>
+ <artifactId>your-third-party-dep-artifact</artifactId>
+ <version>your-third-party-dep-version</version>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ -->
+
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>dev</id>
+ <properties>
+ <!-- define the location of your RHQ root directory - typically rhq.rootDir is overridden in Maven's settings.xml -->
+ <rhq.rootDir>/rhq/trunk</rhq.rootDir>
+ <rhq.defaultDevContainerPath>dev-container</rhq.defaultDevContainerPath>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/rhq.ear/rhq-downloads/rhq-plugins</rhq.deploymentDir>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${rhq.deploymentDir}" />
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>deploy-jar-meta-inf</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating META-INF dir in ${deployment.file}...</echo>
+ <unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.outputDirectory}">
+ <patternset>
+ <include name="META-INF/**" />
+ </patternset>
+ </unjar>
+ <jar destfile="${deployment.file}"
+ manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF"
+ update="true">
+ </jar>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <repositories>
+ <repository>
+ <id>jboss-public-repository-group</id>
+ <name>JBoss Public Maven Repository Group</name>
+ <url>https://repository.jboss.org/nexus/content/groups/public/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+</project>
+
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java
new file mode 100644
index 0000000..2bb46e6
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginDiscoveryComponent.java
@@ -0,0 +1,116 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.sample.skeletonplugin;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ManualAddFacet;
+import org.rhq.core.pluginapi.inventory.ProcessScanResult;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+
+/**
+ * This can be the start of your own custom plugin's discovery component. Review the javadoc for
+ * {@link ResourceDiscoveryComponent}.
+ *
+ * @author John Mazzitelli
+ */
+@SuppressWarnings("unchecked")
+public class SamplePluginDiscoveryComponent implements ResourceDiscoveryComponent, ManualAddFacet {
+ private final Log log = LogFactory.getLog(SamplePluginDiscoveryComponent.class);
+
+ /**
+ * This discovery method is the way the plugin supports "manual-add" capability. The plugin
+ * descriptor must specify supportsManualAdd="true" to allow the resource to be manually added.
+ * If that attribute is false, this method will never be used since it will not be possible to manually
+ * add an instance of the resource.
+ *
+ * Review the javadoc for both {@link ManualAddFacet} and {@link ResourceDiscoveryContext} to learn what
+ * you need to do in this method.
+ *
+ * @see ManualAddFacet#discoverResource(Configuration, ResourceDiscoveryContext)
+ */
+ @Override
+ public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration,
+ ResourceDiscoveryContext context) throws InvalidPluginConfigurationException {
+
+ // pluginConfiguration contains information on a resource that was manually added by the user.
+ // take it and build a details object that represents that resource.
+
+ // key = this must be a unique string across all of your resources - see docs for uniqueness rules
+ // name = this is the name you give the new resource; it does not necessarily have to be unique
+ // version = this is any string that corresponds to the resource's version
+ // description = this is any string that you want to assign as the default description for your resource
+ String key = "My Manually Added Resource Key";
+ String name = "My Resource";
+ String version = "1.0";
+ String description = "This describes My Resource";
+
+ DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
+ version, description, pluginConfiguration, null);
+
+ return resource;
+ }
+
+ /**
+ * Review the javadoc for both {@link ResourceDiscoveryComponent} and {@link ResourceDiscoveryContext} to learn what
+ * you need to do in this method.
+ *
+ * @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext)
+ */
+ @Override
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
+ log.info("Discovering my custom plugin's resources");
+
+ // if your plugin descriptor defined one or more <process-scan>s, then see if the plugin container
+ // auto-discovered processes using those process scan definitions. Process all those that were found.
+ List<ProcessScanResult> autoDiscoveryResults = context.getAutoDiscoveredProcesses();
+ for (ProcessScanResult autoDiscoveryResult : autoDiscoveryResults) {
+ // determine if you want to include the result in this method's returned set of discovered resources
+ }
+
+ // now perform your own discovery mechanism, if you have one. For each resource discovered, you need to
+ // create a details object that describe the resource that you discovered.
+ HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
+
+ // key = this must be a unique string across all of your resources - see docs for uniqueness rules
+ // name = this is the name you give the new resource; it does not necessarily have to be unique
+ // version = this is any string that corresponds to the resource's version
+ // description = this is any string that you want to assign as the default description for your resource
+ String key = "My Resource Key";
+ String name = "My Resource";
+ String version = "1.0";
+ String description = "This describes My Resource";
+
+ DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
+ version, description, null, null);
+
+ set.add(resource);
+
+ return set;
+ }
+}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java
new file mode 100644
index 0000000..701afb0
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/SamplePluginServerComponent.java
@@ -0,0 +1,245 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.sample.skeletonplugin;
+
+import java.io.InputStream;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.content.PackageType;
+import org.rhq.core.domain.content.transfer.DeployPackageStep;
+import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
+import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
+import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.pluginapi.content.ContentFacet;
+import org.rhq.core.pluginapi.content.ContentServices;
+import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
+
+/**
+ * This can be the start of your own custom plugin's server component. Review the javadoc for {@link ResourceComponent}
+ * and all the facet interfaces to learn what you can do in your resource component. This component has a lot of methods
+ * in it because it implements all possible facets. If your resource does not support, for example, configuration, you
+ * can remove the {@link ConfigurationFacet} from the <code>implements</code> clause and remove all method
+ * implementations that that facet required.
+ *
+ * <p>You should not only read the javadoc in each of this class' methods, but you should also read the javadocs linked
+ * by their "see" javadoc tags since those additional javadocs will contain a good deal of additional information you
+ * will need to know.</p>
+ *
+ * @author John Mazzitelli
+ */
+public class SamplePluginServerComponent implements ResourceComponent, MeasurementFacet, OperationFacet,
+ ConfigurationFacet, ContentFacet, DeleteResourceFacet, CreateChildResourceFacet {
+ private final Log log = LogFactory.getLog(SamplePluginServerComponent.class);
+
+ /**
+ * Represents the resource configuration of the custom product being managed.
+ */
+ private Configuration resourceConfiguration;
+
+ /**
+ * All AMPS plugins are stateful - this context contains information that your resource component can use when
+ * performing its processing.
+ */
+ private ResourceContext resourceContext;
+
+ /**
+ * This is called when your component has been started with the given context. You normally initialize some internal
+ * state of your component as well as attempt to make a stateful connection to your managed resource.
+ *
+ * @see ResourceComponent#start(ResourceContext)
+ */
+ public void start(ResourceContext context) {
+ resourceContext = context;
+ }
+
+ /**
+ * This is called when the component is being stopped, usually due to the plugin container shutting down. You can
+ * perform some cleanup here; though normally not much needs to be done here.
+ *
+ * @see ResourceComponent#stop()
+ */
+ public void stop() {
+ }
+
+ /**
+ * All resource components must be able to tell the plugin container if the managed resource is available or not.
+ * This method is called by the plugin container when it needs to know if the managed resource is actually up and
+ * available.
+ *
+ * @see ResourceComponent#getAvailability()
+ */
+ public AvailabilityType getAvailability() {
+ // TODO: here you normally make some type of connection attempt to the managed resource
+ // to determine if it is really up and running.
+ return AvailabilityType.UP;
+ }
+
+ /**
+ * The plugin container will call this method when your resource component has been scheduled to collect some
+ * measurements now. It is within this method that you actually talk to the managed resource and collect the
+ * measurement data that is has emitted.
+ *
+ * @see MeasurementFacet#getValues(MeasurementReport, Set)
+ */
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) {
+ for (MeasurementScheduleRequest request : requests) {
+ String name = request.getName();
+
+ // TODO: based on the request information, you must collect the requested measurement(s)
+ // you can use the name of the measurement to determine what you actually need to collect
+ try {
+ Number value = new Integer(1); // dummy measurement value - this should come from the managed resource
+ report.addData(new MeasurementDataNumeric(request, value.doubleValue()));
+ } catch (Exception e) {
+ log.error("Failed to obtain measurement [" + name + "]. Cause: " + e);
+ }
+ }
+
+ return;
+ }
+
+ /**
+ * The plugin container will call this method when it wants to invoke an operation on your managed resource. Your
+ * plugin will connect to the managed resource and invoke the analogous operation in your own custom way.
+ *
+ * @see OperationFacet#invokeOperation(String, Configuration)
+ */
+ public OperationResult invokeOperation(String name, Configuration configuration) {
+ return null;
+ }
+
+ /**
+ * The plugin container will call this method and it needs to obtain the current configuration of the managed
+ * resource. Your plugin will obtain the managed resource's configuration in your own custom way and populate the
+ * returned Configuration object with the managed resource's configuration property values.
+ *
+ * @see ConfigurationFacet#loadResourceConfiguration()
+ */
+ public Configuration loadResourceConfiguration() {
+ // here we simulate the loading of the managed resource's configuration
+
+ if (resourceConfiguration == null) {
+ // for this example, we will create a simple dummy configuration to start with.
+ // note that it is empty, so we're assuming there are no required configs in the plugin descriptor.
+ resourceConfiguration = new Configuration();
+ }
+
+ Configuration config = resourceConfiguration;
+
+ return config;
+ }
+
+ /**
+ * The plugin container will call this method when it has a new configuration for your managed resource. Your plugin
+ * will re-configure the managed resource in your own custom way, setting its configuration based on the new values
+ * of the given configuration.
+ *
+ * @see ConfigurationFacet#updateResourceConfiguration(ConfigurationUpdateReport)
+ */
+ public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ // this simulates the plugin taking the new configuration and reconfiguring the managed resource
+ resourceConfiguration = report.getConfiguration().deepCopy();
+
+ report.setStatus(ConfigurationUpdateStatus.SUCCESS);
+ }
+
+ /**
+ * When this is called, the plugin is responsible for scanning its managed resource and look for content that need
+ * to be managed for that resource. This method should only discover packages of the given package type.
+ *
+ * @see ContentFacet#discoverDeployedPackages(PackageType)
+ */
+ public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) {
+ return null;
+ }
+
+ /**
+ * The plugin container calls this method when new packages need to be deployed/installed on resources.
+ *
+ * @see ContentFacet#deployPackages(Set, ContentServices)
+ */
+ public DeployPackagesResponse deployPackages(Set<ResourcePackageDetails> packages, ContentServices contentServices) {
+ return null;
+ }
+
+ /**
+ * When a remote client wants to see the actual data content for an installed package, this method will be called.
+ * This method must return a stream of data containing the full content of the package.
+ *
+ * @see ContentFacet#retrievePackageBits(ResourcePackageDetails)
+ */
+ public InputStream retrievePackageBits(ResourcePackageDetails packageDetails) {
+ return null;
+ }
+
+ /**
+ * This is the method that is used when the component has to create the installation steps and their results.
+ *
+ * @see ContentFacet#generateInstallationSteps(ResourcePackageDetails)
+ */
+ public List<DeployPackageStep> generateInstallationSteps(ResourcePackageDetails packageDetails) {
+ return null;
+ }
+
+ /**
+ * This is called when the actual content of packages should be deleted from the managed resource.
+ *
+ * @see ContentFacet#removePackages(Set)
+ */
+ public RemovePackagesResponse removePackages(Set<ResourcePackageDetails> packages) {
+ return null;
+ }
+
+ /**
+ * When called, the plugin container is asking the plugin to create a new managed resource. The new resource's
+ * details need to be added to the given report.
+ *
+ * @see CreateChildResourceFacet#createResource(CreateResourceReport)
+ */
+ public CreateResourceReport createResource(CreateResourceReport report) {
+ return null;
+ }
+
+ /**
+ * When called, the plugin container is asking the plugin to delete a managed resource.
+ *
+ * @see DeleteResourceFacet#deleteResource()
+ */
+ public void deleteResource() {
+ }
+}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
new file mode 100644
index 0000000..2547af7
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!--
+ See the rhq-plugin.xsd file for detailed documentatoin on the schema. The notes in this file are to
+ facilitate using this file as a base plugin descriptor.
+-->
+
+<!--
+ CHANGE: The name (and optional displayName) should be changed to reflect the plugin being developed. Keep in mind
+ the value for name must be unique across all other plugins that are deployed.
+
+ The package attribute should be changed to reflect the package in which all of the component classes
+ are built.
+-->
+<plugin name="SkeletonPlugin"
+ displayName="Skeleton Plugin"
+ version="1.0"
+ package="org.rhq.sample.skeletonplugin"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration">
+
+
+ <!--
+ CHANGE: The following is a sample server resource type. This entry is here to serve as a model and should
+ be removed prior to deploying the plugin. Multiple resource types (either server or service) may be
+ defined at this level.
+ -->
+ <server name="Sample Plugin Server"
+ discovery="SamplePluginDiscoveryComponent"
+ class="SamplePluginServerComponent"
+ supportsManualAdd="true"
+ description="This is a sample resource type and should be removed.">
+
+ <!--
+ CHANGE: Categories are optional; this entire section may be removed if there is no need to further group
+ related child resources. Categories defined at this level can carry metadata on the category itself,
+ such as a display name and description.
+ -->
+ <subcategories>
+ <subcategory name="Category1" displayName="Sample Category 1"
+ description="This is a sample category that should be removed."/>
+ <subcategory name="Category2" >
+ <subcategory name="ChildCategory2a" />
+ </subcategory>
+ </subcategories>
+
+ <!--
+ CHANGE: The entire plugin configuration is optional. If there are properties specific to handling how the
+ resource component will connect to the resource, they should be added here. If the plugin-configuration
+ entity is specified, at least one property must be provided.
+ -->
+ <plugin-configuration>
+ <c:simple-property name="SamplePluginProperty" displayName="Sample Plugin Property" default="Value" />
+ </plugin-configuration>
+
+ <!--
+ CHANGE: The process-scan element requests the plugin container provide the discovery component for
+ this resource type with the results of scanning the machine for running processes. If there is
+ no use for this in a given resource type, this entry may be omitted.
+ -->
+ <process-scan name="ScanIdentifier" query="process|basename|match=^java.*,arg|org.jboss.Main|match=.*"/>
+
+ <!--
+ CHANGE: An operation element is added for each operation that may be executed against resources of this type.
+ The parameters element is optional; properties defined within will be displayed to the user when
+ invoking the operation. If the resource has no applicable operations, these elements may be omitted.
+
+ REQUIRED INTERFACE: The resource component for this resource type must implement the OperationFacet interface
+ if any operations are specified.
+ -->
+ <operation name="testSimple"
+ description="Test simple-property configuration element for a resource operation">
+ <parameters>
+ <c:group name="required" displayName="Required Parameters" hiddenByDefault="false">
+ <c:description>All of these properties are required</c:description>
+ <c:simple-property name="aNumber" type="integer" required="true" default="42" displayName="A Number" description="A number between 1 and 100, inclusive">
+ <c:constraint>
+ <c:integer-constraint minimum="1" maximum="100"/>
+ </c:constraint>
+ </c:simple-property>
+ </c:group>
+ </parameters>
+ <results>
+ <c:simple-property name="results" />
+ </results>
+ </operation>
+
+ <!--
+ CHANGE: For each measurement that should be collected for resources of this type, a metric element is added.
+ In addition to identifying the metric, a default collection interval and whether or not the
+ metric is even collected by default are indicated. If the resource has no measurements to be
+ collected, these elements may be omitted.
+
+ REQUIRED INTERFACE: The resource component for this resource type must implement the MeasurementFacet interface
+ if any metrics are specified.
+ -->
+ <metric property="MeasurementName"
+ displayName="The Measurement Name"
+ description="Describes what this measurement is actually telling you"
+ defaultOn="true"
+ defaultInterval="300000"
+ category="performance" />
+
+ <!--
+ CHANGE: Resource configuration properties are used to configure resources themselves, as compared to the plugin
+ configuration which refers to the connection to a resource. If the resource-configuration
+ entity is specified, at least one property must be provided.
+
+ REQUIRED INTERFACE: The resource component for this resource type must implement the ConfigurationFacet
+ interface if a resource-configuration element is supplied.
+ -->
+ <resource-configuration>
+ <c:simple-property name="port" type="integer" displayName="Port on which to listen" />
+ </resource-configuration>
+ </server>
+</plugin>
12 years, 10 months
[rhq] Branch 'as7plugin' - 102 commits - etc/cli-scripts modules/core modules/enterprise modules/integration-tests modules/plugins modules/test-utils
by Heiko W. Rupp
etc/cli-scripts/drift.js | 66 +
modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml | 6
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 9
modules/core/domain/src/main/java/org/rhq/core/domain/common/composite/SystemSettings.java | 39
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftChangeSetCriteria.java | 154 +++
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftCriteria.java | 135 +++
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java | 4
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java | 43 -
modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftComposite.java | 8
modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftChangeSetDTO.java | 91 ++
modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftDTO.java | 94 ++
modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftFileDTO.java | 50 +
modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java | 94 --
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java | 15
modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqFacade.java | 3
modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManagers.java | 2
modules/enterprise/binding/src/test/java/org/rhq/bindings/FakeRhqFacade.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java | 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/PopupWindow.java | 63 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java | 24
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java | 405 +++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java | 128 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java | 365 +-------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection2.java | 367 ++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java | 59 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java | 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java | 44 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/SystemGWTService.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java | 42
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java | 21
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java | 10
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties | 3
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_Coverage_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_Coverage_16_open.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/Drift_new_16.png |binary
modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java | 5
modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClient.java | 5
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java | 1
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java | 27
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java | 5
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerRemote.java | 18
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java | 66 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java | 47 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerLocal.java | 3
modules/enterprise/server/plugins/drift-mongodb/pom.xml | 290 ++++++
modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java | 244 +++++
modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java | 122 ++
modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java | 94 ++
modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBFile.java | 49 +
modules/enterprise/server/plugins/drift-mongodb/src/main/resources/META-INF/rhq-serverplugin.xml | 22
modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java | 95 ++
modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java | 30
modules/enterprise/server/plugins/pom.xml | 1
modules/integration-tests/apache-plugin-test/pom.xml | 37
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/PluginLocation.java | 33
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/AugeasReferenceLeakingTest.java | 241 +++++
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/CreateAndCloseTracker.java | 173 ++++
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestConfiguration.java | 77 +
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java | 372 ++++++++
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java | 420 ---------
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeNestedConfigurationFromRHQ1_3Test.java | 27
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java | 22
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeNestedConfigurationFromRHQ3_0_0Test.java | 73 -
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java | 53 -
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeNestedConfigurationFromRHQ3_0_1Test.java | 93 +-
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java | 81 -
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeNestedConfigurationFromRHQ3_0_2Test.java | 34
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java | 22
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/util/ResourceTypes.java | 66 +
modules/integration-tests/apache-plugin-test/src/test/resources/augeas-leak-test-config/httpd.conf | 64 +
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java | 122 +-
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java | 79 +
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java | 135 +--
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java | 65 -
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java | 60 -
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java | 61 -
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java | 428 +++++-----
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java | 223 +++--
modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasComponent.java | 52 +
modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java | 44 -
modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java | 190 ++--
modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java | 22
modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java | 78 +
modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java | 4
modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml | 12
modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml | 15
modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java | 21
modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java | 57 -
modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java | 17
modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java | 11
modules/test-utils/src/main/java/org/rhq/test/JMockTest.java | 63 -
120 files changed, 5259 insertions(+), 2008 deletions(-)
New commits:
commit 9ef7c0a44446f2a026fdae101eccff4fba6fe9dc
Merge: eb053ba cfd9223
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Aug 4 14:40:58 2011 +0200
Merge branch 'master' into as7plugin
commit cfd92234978464c9c724ade77627aa5fea6dcf5e
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Aug 4 13:50:09 2011 +0200
Prevent possible NPE that makes agent startup fail.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
index 879ceca..3f10089 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
@@ -7,6 +7,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
+import java.util.Set;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.zip.ZipEntry;
@@ -88,9 +89,11 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
}
log.debug("Rescheduling drift detection schedules for " + r);
- for (DriftDetectionSchedule schedule : container.getDriftSchedules()) {
- schedulesQueue.addSchedule(schedule);
- }
+ Set<DriftDetectionSchedule> driftSchedules = container.getDriftSchedules();
+ if (driftSchedules!=null)
+ for (DriftDetectionSchedule schedule : driftSchedules) {
+ schedulesQueue.addSchedule(schedule);
+ }
for (Resource child : r.getChildResources()) {
initSchedules(child, inventoryMgr);
@@ -252,7 +255,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
*
* @param resourceId The id of the resource to which the config belongs
* @param driftConfiguration describes what is to be monitored for drift
- *
+ *
* @return absolute directory location where the drift configuration base directory is referring
*/
@Override
@@ -323,7 +326,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
/**
* Returns the manager that can provide data on the inventory. This is a separate protected method
* so we can extend our manger class to have a mock manager for testing.
- *
+ *
* @return the inventory manager
*/
protected InventoryManager getInventoryManager() {
@@ -333,7 +336,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
/**
* Returns the manager that can provide data on the measurements/metrics. This is a separate protected method
* so we can extend our manger class to have a mock manager for testing.
- *
+ *
* @return the inventory manager
*/
protected MeasurementManager getMeasurementManager() {
commit 0ca1154d6f3f5e959d48f3c85ebd188c513c7f4c
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Aug 4 11:45:53 2011 +0200
New byteman-based tests for correct closing of the augeas native resources.
The original apache integration tests were refactored a bit so that the setup classes
can be reused outside of the UpgradeTestBase class hierarchy.
diff --git a/modules/integration-tests/apache-plugin-test/pom.xml b/modules/integration-tests/apache-plugin-test/pom.xml
index 7eea30d..0e67a19 100644
--- a/modules/integration-tests/apache-plugin-test/pom.xml
+++ b/modules/integration-tests/apache-plugin-test/pom.xml
@@ -23,6 +23,7 @@
<scm.module.path>modules/integration-tests/apache-plugin-test</scm.module.path>
<httpd.version>2.2.17</httpd.version>
<httpd.install.dir>${basedir}/target/itest/httpd</httpd.install.dir>
+ <byteman.version>1.5.2</byteman.version>
</properties>
<repositories>
@@ -94,6 +95,34 @@
<scope>test</scope>
<type>zip</type>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman</artifactId>
+ <version>${byteman.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman-install</artifactId>
+ <version>${byteman.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman-submit</artifactId>
+ <version>${byteman.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman-bmunit</artifactId>
+ <version>${byteman.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -253,13 +282,19 @@
<configuration>
<skip>${maven.test.skip}</skip>
<excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
- <useSystemClassLoader>false</useSystemClassLoader>
+ <useSystemClassLoader>true</useSystemClassLoader>
+
+ <additionalClasspathElements>
+ <additionalClasspathElement>${env.JAVA_HOME}/lib/tools.jar</additionalClasspathElement>
+ </additionalClasspathElements>
<!--<argLine>-Dorg.hyperic.sigar.path=${basedir}/target/itest/lib
-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine> -->
<environmentVariables>
<LD_LIBRARY_PATH>${basedir}/target/itest/lib:${env.LD_LIBRARY_PATH}</LD_LIBRARY_PATH>
</environmentVariables>
<systemPropertyVariables>
+ <!-- <org.jboss.byteman.verbose>true</org.jboss.byteman.verbose> -->
+ <AugeasReferenceLeakingTest.configurationReadingInvocationCount>10</AugeasReferenceLeakingTest.configurationReadingInvocationCount>
<org.hyperic.sigar.path>${basedir}/target/itest/lib</org.hyperic.sigar.path>
<project.artifactId>${project.artifactId}</project.artifactId>
<project.version>${project.version}</project.version>
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/PluginLocation.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/PluginLocation.java
new file mode 100644
index 0000000..16bbc8d
--- /dev/null
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/PluginLocation.java
@@ -0,0 +1,33 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.apache;
+
+/**
+ *
+ *
+ * @author Lukas Krejci
+ */
+public interface PluginLocation {
+
+ public static final String PLATFORM_PLUGIN = "file:target/itest/plugins/rhq-platform-plugin-for-apache-test.jar";
+ public static final String AUGEAS_PLUGIN = "file:target/itest/plugins/rhq-augeas-plugin-for-apache-test.jar";
+ public static final String APACHE_PLUGIN = "file:target/itest/plugins/rhq-apache-plugin-for-apache-test.jar";
+
+}
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/AugeasReferenceLeakingTest.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/AugeasReferenceLeakingTest.java
new file mode 100644
index 0000000..b297a18
--- /dev/null
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/AugeasReferenceLeakingTest.java
@@ -0,0 +1,241 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.apache.augeas;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jmock.Expectations;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Listeners;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+import org.jboss.byteman.contrib.bmunit.BMNGRunner;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+
+import org.rhq.core.clientapi.agent.PluginContainerException;
+import org.rhq.core.clientapi.server.discovery.InventoryReport;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.discovery.AvailabilityReport;
+import org.rhq.core.domain.resource.InventoryStatus;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pc.PluginContainer;
+import org.rhq.core.pc.ServerServices;
+import org.rhq.core.pc.configuration.ConfigurationManager;
+import org.rhq.core.pc.inventory.InventoryManager;
+import org.rhq.core.pc.inventory.ResourceContainer;
+import org.rhq.core.pc.upgrade.FakeServerInventory;
+import org.rhq.plugins.apache.PluginLocation;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
+import org.rhq.plugins.apache.setup.ApacheTestSetup;
+import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
+import org.rhq.plugins.apache.util.ResourceTypes;
+import org.rhq.plugins.apache.util.ApacheExecutionUtil.ExpectedApacheState;
+import org.rhq.test.pc.PluginContainerSetup;
+import org.rhq.test.pc.PluginContainerTest;
+
+/**
+ *
+ *
+ * @author Lukas Krejci
+ */
+(a)Listeners(PluginContainerTest.class)
+@Test
+public class AugeasReferenceLeakingTest extends BMNGRunner {
+
+ private ApacheTestSetup setup;
+
+ @BeforeMethod
+ public void clearCreateAndCloseTracker() {
+ CreateAndCloseTracker.clear();
+ }
+
+ @SuppressWarnings("unchecked")
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN,
+ PluginLocation.APACHE_PLUGIN })
+ @BMRules(
+ rules = {
+ @BMRule(name = "increment reference count on Augeas init", targetClass = "net.augeas.Augeas",
+ targetMethod = "<init>(String, String, int)",
+ helper = "org.rhq.plugins.apache.augeas.CreateAndCloseTracker",
+ action = "recordCreate($0, formatStack())"),
+ @BMRule(name = "decrement reference count on Augeas close", targetClass = "net.augeas.Augeas",
+ targetMethod = "close()", helper = "org.rhq.plugins.apache.augeas.CreateAndCloseTracker",
+ action = "recordClose($0, formatStack())") })
+ @Parameters({ "apache2.install.dir", "apache2.exe.path",
+ "AugeasReferenceLeakingTest.configurationReadingInvocationCount" })
+ public void testReadingConfigurationsDoesNotLeakAugeasReferences(final String installDir, final String exePath,
+ int configurationReadingInvocationCount) throws Exception {
+ final FakeServerInventory fakeInventory = new FakeServerInventory();
+ PluginContainerTest.getCurrentMockContext().checking(new Expectations() {
+ {
+ ServerServices ss = PluginContainerTest.getCurrentPluginContainerConfiguration().getServerServices();
+
+ allowing(ss.getDiscoveryServerService()).mergeInventoryReport(with(any(InventoryReport.class)));
+ will(fakeInventory.mergeInventoryReport(InventoryStatus.COMMITTED));
+
+ allowing(ss.getDiscoveryServerService()).getResources(with(any(Set.class)), with(any(boolean.class)));
+ will(fakeInventory.getResources());
+
+ allowing(ss.getDiscoveryServerService()).mergeAvailabilityReport(with(any(AvailabilityReport.class)));
+ allowing(ss.getDiscoveryServerService()).postProcessNewlyCommittedResources(with(any(Set.class)));
+
+ ignoring(ss.getBundleServerService());
+ ignoring(ss.getConfigurationServerService());
+ ignoring(ss.getContentServerService());
+ ignoring(ss.getCoreServerService());
+ ignoring(ss.getEventServerService());
+ ignoring(ss.getMeasurementServerService());
+ ignoring(ss.getOperationServerService());
+ ignoring(ss.getResourceFactoryServerService());
+ }
+ });
+
+ boolean apacheStarted = false;
+ try {
+ apacheStarted = startApache(installDir, exePath);
+
+ PluginContainerTest.startConfiguredPluginContainer();
+
+ configureApacheServerToUseAugeas();
+
+ PluginContainer pc = PluginContainer.getInstance();
+ Resource platform = pc.getInventoryManager().getPlatform();
+
+ for (int i = 0; i < configurationReadingInvocationCount; ++i) {
+ checkConfigurationRecursively(platform, pc.getConfigurationManager());
+ Thread.sleep(10000);
+ }
+
+ //wait a couple of seconds for the loadConfig calls to finish
+ Thread.sleep(60000);
+ } finally {
+ if (apacheStarted) {
+ stopApache();
+ }
+ }
+ }
+
+ @AfterMethod
+ public void checkForLeaksAndMultiCloses() {
+ List<String> leaks = CreateAndCloseTracker.getCreateLocationsWithoutClose();
+ Map<String, List<String>> multiCloses = CreateAndCloseTracker.getMultiplyClosingLocations();
+
+ assertEquals(leaks.size(), 0,
+ "There were Augeas instances without a close() call on them created at the following locations: " + leaks);
+
+ assertEquals(
+ multiCloses.size(),
+ 0,
+ "Each key in the map is a location where Augeas was created and the values are the lists of locations where that instance was closed: "
+ + multiCloses);
+ }
+
+ private boolean startApache(final String installDir, final String exePath) throws Exception {
+ ApacheTestConfiguration apacheConfig = new ApacheTestConfiguration() {
+ {
+ serverRoot = installDir;
+ binPath = exePath;
+ configurationName = "augeas-leak-test-config";
+ apacheConfigurationFiles = new String[] { "/augeas-leak-test-config/httpd.conf", "/snmpd.conf" };
+ inventoryFile = null;
+ }
+ };
+
+ setup = new ApacheTestSetup(apacheConfig.configurationName, PluginContainerTest.getCurrentMockContext(),
+ new ResourceTypes(PluginLocation.APACHE_PLUGIN));
+
+ Resource platform = UpgradeTestBase.discoverPlatform();
+
+ setup.withInventoryFrom(apacheConfig.inventoryFile).withPlatformResource(platform)
+ .withDefaultOverrides(apacheConfig.defaultOverrides).withApacheSetup()
+ .withConfigurationFiles(apacheConfig.apacheConfigurationFiles).withServerRoot(apacheConfig.serverRoot)
+ .withExePath(apacheConfig.binPath);
+
+ setup.setup();
+
+ return true;
+ }
+
+ private void stopApache() throws Exception {
+ if (setup != null) {
+ setup.withApacheSetup().getExecutionUtil().invokeOperation(ExpectedApacheState.STOPPED, "stop");
+ setup = null;
+ }
+ }
+
+ private void checkConfigurationRecursively(Resource resource, ConfigurationManager cm)
+ throws PluginContainerException {
+ if (resource.getResourceType().getResourceConfigurationDefinition() != null) {
+ cm.loadResourceConfiguration(resource.getId());
+ }
+
+ for (Resource child : resource.getChildResources()) {
+ checkConfigurationRecursively(child, cm);
+ }
+ }
+
+ private void configureApacheServerToUseAugeas() throws Exception {
+ ResourceTypes resourceTypes = new ResourceTypes(PluginLocation.APACHE_PLUGIN);
+
+ InventoryManager im = PluginContainer.getInstance().getInventoryManager();
+
+ ResourceContainer apacheServer = findResource(resourceTypes.findByName("Apache HTTP Server"));
+
+ Configuration config = apacheServer.getResourceContext().getPluginConfiguration();
+
+ config.getSimple("augeasEnabled").setValue("yes");
+
+ im.updatePluginConfiguration(apacheServer.getResource().getId(), config);
+
+ //and run discovery so that the new resources can go into inventory
+
+ im.executeServiceScanImmediately();
+ }
+
+ private ResourceContainer findResource(ResourceType resourceType) {
+ InventoryManager im = PluginContainer.getInstance().getInventoryManager();
+
+ return findResource(im, resourceType, im.getPlatform());
+ }
+
+ private ResourceContainer findResource(InventoryManager im, ResourceType rt, Resource root) {
+ if (root.getResourceType().equals(rt)) {
+ return im.getResourceContainer(root);
+ }
+
+ for (Resource child : root.getChildResources()) {
+ ResourceContainer rc = findResource(im, rt, child);
+ if (rc != null) {
+ return rc;
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/CreateAndCloseTracker.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/CreateAndCloseTracker.java
new file mode 100644
index 0000000..7ccc7b5
--- /dev/null
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/CreateAndCloseTracker.java
@@ -0,0 +1,173 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.apache.augeas;
+
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.byteman.rule.Rule;
+import org.jboss.byteman.rule.helper.Helper;
+
+/**
+ * This is a helper class to help us make sense of the augeas leaks.
+ *
+ * The byteman rules in the {@link AugeasReferenceLeakingTest} make use
+ * of this class to record the locations that create instances of augeas
+ * and match them with locations that close the instance.
+ * <p>
+ * We can then report on any locations that created an augeas instance
+ * that was never closed.
+ *
+ * @author Lukas Krejci
+ */
+public class CreateAndCloseTracker extends Helper {
+ private static class EqualableWeakReference<T> extends WeakReference<T> {
+
+ private final int hash;
+
+ public EqualableWeakReference(T referent, ReferenceQueue<? super T> q) {
+ super(referent, q);
+ hash = referent.hashCode();
+ }
+
+ public EqualableWeakReference(T referent) {
+ super(referent);
+ hash = referent.hashCode();
+ }
+
+ @Override
+ public int hashCode() {
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (!(other instanceof EqualableWeakReference)) {
+ return false;
+ }
+
+ Object ref = get();
+
+ if (ref == null) {
+ //the reference has been cleared. There is no telling
+ //on what this reference pointed to, so it is not
+ //possible to determine equality.
+ return false;
+ }
+
+ EqualableWeakReference<?> o = (EqualableWeakReference<?>) other;
+
+ Object oref = o.get();
+
+ //reference equality is what we're after here...
+ return ref == oref;
+ }
+ }
+
+ private static class CreateAndCloseLocations {
+ public String createLocation;
+ public List<String> closeLocations = new ArrayList<String>();
+ }
+
+ private static final HashMap<EqualableWeakReference<Object>, CreateAndCloseLocations> REFERENCES = new HashMap<CreateAndCloseTracker.EqualableWeakReference<Object>, CreateAndCloseLocations>();
+
+ /**
+ * @param rule
+ */
+ public CreateAndCloseTracker(Rule rule) {
+ super(rule);
+ }
+
+
+ private static synchronized void _recordCreate(Object object, String stackTrace) {
+ EqualableWeakReference<Object> ref = new EqualableWeakReference<Object>(object);
+
+ CreateAndCloseLocations locations = REFERENCES.get(ref);
+
+ if (locations == null) {
+ locations = new CreateAndCloseLocations();
+ REFERENCES.put(ref, locations);
+
+ locations.createLocation = stackTrace;
+ } else {
+ throw new IllegalStateException("Cannot record a create request on a single object twice. Object: " + object + ", Stacktrace: " + stackTrace);
+ }
+ }
+
+ public void recordCreate(Object object, String stackTrace) {
+ _recordCreate(object, stackTrace);
+ }
+
+ private static synchronized void _recordClose(Object object, String stackTrace) {
+ EqualableWeakReference<Object> ref = new EqualableWeakReference<Object>(object);
+
+ CreateAndCloseLocations locations = REFERENCES.get(ref);
+
+ if (locations == null) {
+ //weird, but actually track this so that we
+ //can report about an object not being
+ //recorded for create.
+ locations = new CreateAndCloseLocations();
+ REFERENCES.put(ref, locations);
+ }
+
+ locations.closeLocations.add(stackTrace);
+ }
+
+ public void recordClose(Object object, String stackTrace) {
+ _recordClose(object, stackTrace);
+ }
+
+ public static synchronized void clear() {
+ REFERENCES.clear();
+ }
+
+ public static synchronized List<String> getCreateLocationsWithoutClose() {
+ ArrayList<String> ret = new ArrayList<String>();
+
+ for(CreateAndCloseLocations l : REFERENCES.values()) {
+ if (l.closeLocations.isEmpty()) {
+ ret.add(l.createLocation);
+ }
+ }
+
+ return ret;
+ }
+
+ public static synchronized Map<String, List<String>> getMultiplyClosingLocations() {
+ HashMap<String, List<String>> ret = new HashMap<String, List<String>>();
+
+ for(CreateAndCloseLocations l : REFERENCES.values()) {
+ if (l.closeLocations.size() > 1) {
+ ret.put(l.createLocation, l.closeLocations);
+ }
+ }
+
+ return ret;
+ }
+}
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestConfiguration.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestConfiguration.java
new file mode 100644
index 0000000..fedffe6
--- /dev/null
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestConfiguration.java
@@ -0,0 +1,77 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.apache.setup;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.rhq.plugins.apache.ApacheVirtualHostServiceComponent;
+import org.rhq.plugins.apache.ApacheVirtualHostServiceDiscoveryComponent;
+import org.rhq.plugins.apache.util.VHostSpec;
+import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig;
+
+public class ApacheTestConfiguration {
+ public String[] apacheConfigurationFiles;
+ public String inventoryFile;
+ public String configurationName;
+ public String serverRoot;
+ public String binPath;
+ public Map<String, String> defaultOverrides = new HashMap<String, String>();
+
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
+
+ }
+
+ public void beforePluginContainerStart(ApacheTestSetup setup) throws Throwable {
+
+ }
+
+ public void beforeTests(ApacheTestSetup setup) throws Throwable {
+
+ }
+
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
+ return getFullSuccessfulUpgradeResourceKeys(setup);
+ }
+
+ public String[] getExpectedResourceKeysWithFailures(ApacheTestSetup setup) {
+ return null;
+ }
+
+ protected String[] getFullSuccessfulUpgradeResourceKeys(ApacheTestSetup setup) {
+ DeploymentConfig dc = setup.getDeploymentConfig();
+ Map<String, String> replacements = dc.getTokenReplacements();
+
+ VHostSpec vh1 = dc.vhost1.getVHostSpec(replacements);
+ VHostSpec vh2 = dc.vhost2.getVHostSpec(replacements);
+ VHostSpec vh3 = dc.vhost3.getVHostSpec(replacements);
+ VHostSpec vh4 = dc.vhost4.getVHostSpec(replacements);
+
+ String[] ret = new String[5];
+
+ ret[0] = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
+ ret[1] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh1.serverName, vh1.hosts);
+ ret[2] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh2.serverName, vh2.hosts);
+ ret[3] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh3.serverName, vh3.hosts);
+ ret[4] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh4.serverName, vh4.hosts);
+
+ return ret;
+ }
+}
\ No newline at end of file
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java
new file mode 100644
index 0000000..cb10807
--- /dev/null
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java
@@ -0,0 +1,372 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.apache.setup;
+
+import static org.testng.Assert.assertTrue;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+
+import org.rhq.core.clientapi.server.discovery.InventoryReport;
+import org.rhq.core.domain.discovery.AvailabilityReport;
+import org.rhq.core.domain.resource.InventoryStatus;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceError;
+import org.rhq.core.pc.ServerServices;
+import org.rhq.core.pc.upgrade.FakeServerInventory;
+import org.rhq.plugins.apache.ApacheVirtualHostServiceComponent;
+import org.rhq.plugins.apache.ApacheVirtualHostServiceDiscoveryComponent;
+import org.rhq.plugins.apache.parser.ApacheConfigReader;
+import org.rhq.plugins.apache.parser.ApacheDirectiveTree;
+import org.rhq.plugins.apache.parser.ApacheParser;
+import org.rhq.plugins.apache.parser.ApacheParserImpl;
+import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
+import org.rhq.plugins.apache.util.ApacheDeploymentUtil;
+import org.rhq.plugins.apache.util.ApacheExecutionUtil;
+import org.rhq.plugins.apache.util.HttpdAddressUtility;
+import org.rhq.plugins.apache.util.ResourceTypes;
+import org.rhq.plugins.apache.util.VHostSpec;
+import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig;
+import org.rhq.plugins.apache.util.ApacheExecutionUtil.ExpectedApacheState;
+import org.rhq.test.ObjectCollectionSerializer;
+import org.rhq.test.TokenReplacingReader;
+import org.rhq.test.pc.PluginContainerTest;
+
+public class ApacheTestSetup {
+ private String configurationName;
+ private FakeServerInventory fakeInventory = new FakeServerInventory();
+ private String inventoryFile;
+ private Resource platform;
+ private ApacheSetup apacheSetup = new ApacheSetup();
+ private DeploymentConfig deploymentConfig;
+ private Map<String, String> defaultOverrides = new HashMap<String, String>();
+ private Map<String, String> inventoryFileReplacements;
+ private Mockery context;
+ private ResourceTypes apacheResourceTypes;
+
+ public class ApacheSetup {
+ private String serverRoot;
+ private String exePath;
+ private Collection<String> configurationFiles;
+ private ApacheExecutionUtil execution;
+ private boolean deploy = true;
+
+ private ApacheSetup() {
+
+ }
+
+ public ApacheSetup withServerRoot(String serverRoot) {
+ this.serverRoot = serverRoot;
+ //auto-define the server root property as if it was passed on the commandline
+ System.getProperties().put(configurationName + ".server.root", serverRoot);
+ deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, defaultOverrides);
+ return this;
+ }
+
+ public ApacheSetup withExePath(String exePath) {
+ this.exePath = exePath;
+ return this;
+ }
+
+ public ApacheSetup withConfigurationFiles(String... classPathUris) {
+ return withConfigurationFiles(Arrays.asList(classPathUris));
+ }
+
+ public ApacheSetup withConfigurationFiles(Collection<String> classPathUris) {
+ this.configurationFiles = classPathUris;
+ return this;
+ }
+
+ public ApacheSetup withDeploymentOnSetup() {
+ this.deploy = true;
+ return this;
+ }
+
+ public ApacheSetup withNoDeploymentOnSetup() {
+ this.deploy = false;
+ return this;
+ }
+
+ public ApacheExecutionUtil getExecutionUtil() {
+ return execution;
+ }
+
+ public void init() throws Exception {
+ File serverRootDir = new File(serverRoot);
+
+ assertTrue(serverRootDir.exists(), "The configured server root denotes a non-existant directory: '"
+ + serverRootDir + "'.");
+
+ File confDir = new File(serverRootDir, "conf");
+
+ assertTrue(confDir.exists(),
+ "The configured server root denotes a directory that doesn't have a 'conf' subdirectory. This is unexpected.");
+
+ String confFilePath = confDir.getAbsolutePath() + File.separatorChar + "httpd.conf";
+
+ String snmpHost = null;
+ int snmpPort = 0;
+ String pingUrl = null;
+
+ if (configurationName != null) {
+ if (deploy) {
+ File binDir = new File(serverRootDir, "bin");
+ List<File> additionalFilesToProcess = Arrays.asList(
+ new File(binDir, "apachectl"),
+ new File(binDir, "envvars"),
+ new File(binDir, "envvars-std"));
+ ApacheDeploymentUtil.deployConfiguration(confDir, configurationFiles, additionalFilesToProcess, deploymentConfig);
+ }
+
+ //ok, now try to find the ping URL. The best thing is to actually invoke
+ //the same code the apache server discovery does.
+ ApacheDirectiveTree tree = new ApacheDirectiveTree();
+ ApacheParser parser = new ApacheParserImpl(tree, serverRootDir.getAbsolutePath());
+ ApacheConfigReader.buildTree(confFilePath, parser);
+
+ //XXX this hardcodes apache2 as the only option we have...
+ HttpdAddressUtility.Address addrToUse = HttpdAddressUtility.APACHE_2_x.getMainServerSampleAddress(tree, null, -1);
+ pingUrl = addrToUse.toString();
+
+ snmpHost = deploymentConfig.snmpHost;
+ snmpPort = deploymentConfig.snmpPort;
+ }
+
+ execution = new ApacheExecutionUtil(apacheResourceTypes.findByName("Apache HTTP Server"),
+ serverRoot, exePath, confFilePath, pingUrl,
+ snmpHost, snmpPort);
+ execution.init();
+ }
+
+ private void doSetup() throws Exception {
+ init();
+ execution.invokeOperation(ExpectedApacheState.RUNNING, "start");
+ }
+
+ public ApacheTestSetup setup() throws Exception {
+ return ApacheTestSetup.this.setup();
+ }
+ }
+
+ public ApacheTestSetup(String configurationName, Mockery context, ResourceTypes apacheResourceTypes) {
+ this.configurationName = configurationName;
+ this.context = context;
+ this.apacheResourceTypes = apacheResourceTypes;
+ deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, defaultOverrides);
+ }
+
+ public ApacheTestSetup withInventoryFrom(String classPathUri) {
+ inventoryFile = classPathUri;
+ return this;
+ }
+
+ public ApacheTestSetup withDefaultOverrides(Map<String, String> defaultOverrides) {
+ this.defaultOverrides = defaultOverrides == null ? new HashMap<String, String>() : defaultOverrides;
+ deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, this.defaultOverrides);
+ return this;
+ }
+
+ public ApacheTestSetup withPlatformResource(Resource platform) {
+ this.platform = platform;
+ return this;
+ }
+
+ public ApacheSetup withApacheSetup() {
+ return apacheSetup;
+ }
+
+ public ApacheTestSetup withDefaultExpectations() throws Exception {
+ context.checking(new Expectations() {
+ {
+ addDefaultExceptations(this);
+ }
+ });
+
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void addDefaultExceptations(Expectations expectations) throws Exception {
+ ServerServices ss = PluginContainerTest.getCurrentPluginContainerConfiguration().getServerServices();
+
+ expectations.allowing(ss.getDiscoveryServerService()).mergeInventoryReport(
+ expectations.with(Expectations.any(InventoryReport.class)));
+ expectations.will(fakeInventory.mergeInventoryReport(InventoryStatus.COMMITTED));
+
+ expectations.allowing(ss.getDiscoveryServerService()).upgradeResources(
+ expectations.with(Expectations.any(Set.class)));
+ expectations.will(fakeInventory.upgradeResources());
+
+ expectations.allowing(ss.getDiscoveryServerService()).getResources(
+ expectations.with(Expectations.any(Set.class)), expectations.with(Expectations.any(boolean.class)));
+ expectations.will(fakeInventory.getResources());
+
+ expectations.allowing(ss.getDiscoveryServerService()).setResourceError(expectations.with(Expectations.any(ResourceError.class)));
+ expectations.will(fakeInventory.setResourceError());
+
+ expectations.allowing(ss.getDiscoveryServerService()).mergeAvailabilityReport(
+ expectations.with(Expectations.any(AvailabilityReport.class)));
+
+ expectations.allowing(ss.getDiscoveryServerService()).postProcessNewlyCommittedResources(
+ expectations.with(Expectations.any(Set.class)));
+
+ expectations.allowing(ss.getDiscoveryServerService()).clearResourceConfigError(
+ expectations.with(Expectations.any(int.class)));
+
+ expectations.ignoring(ss.getBundleServerService());
+ expectations.ignoring(ss.getConfigurationServerService());
+ expectations.ignoring(ss.getContentServerService());
+ expectations.ignoring(ss.getCoreServerService());
+ expectations.ignoring(ss.getEventServerService());
+ expectations.ignoring(ss.getMeasurementServerService());
+ expectations.ignoring(ss.getOperationServerService());
+ expectations.ignoring(ss.getResourceFactoryServerService());
+ }
+
+ public FakeServerInventory getFakeInventory() {
+ return fakeInventory;
+ }
+
+ public DeploymentConfig getDeploymentConfig() {
+ return deploymentConfig;
+ }
+
+ public ApacheTestSetup setup() throws Exception {
+ apacheSetup.doSetup();
+
+ Map<String, String> replacements = deploymentConfig.getTokenReplacements();
+ replacements.put("server.root", apacheSetup.serverRoot);
+ replacements.put("exe.path", apacheSetup.exePath);
+
+ ApacheDeploymentUtil.addDefaultVariables(replacements, null);
+
+ HttpdAddressUtility addressUtility = apacheSetup.getExecutionUtil().getServerComponent()
+ .getAddressUtility();
+ ApacheDirectiveTree runtimeConfig = apacheSetup.getExecutionUtil().getRuntimeConfiguration();
+
+ replacements.put("snmp.identifier",
+ addressUtility.getHttpdInternalMainServerAddressRepresentation(runtimeConfig).toString(false, false));
+
+ replacements.put("main.rhq4.resource.key", ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY);
+
+ VHostSpec vhost1 = deploymentConfig.vhost1 == null ? null : deploymentConfig.vhost1.getVHostSpec(replacements);
+ VHostSpec vhost2 = deploymentConfig.vhost2 == null ? null : deploymentConfig.vhost2.getVHostSpec(replacements);
+ VHostSpec vhost3 = deploymentConfig.vhost3 == null ? null : deploymentConfig.vhost3.getVHostSpec(replacements);
+ VHostSpec vhost4 = deploymentConfig.vhost4 == null ? null : deploymentConfig.vhost4.getVHostSpec(replacements);
+
+ if (vhost1 != null) {
+ replacements.put(
+ "vhost1.snmp.identifier",
+ addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost1.hosts.get(0),
+ vhost1.serverName).toString(false, false));
+
+ replacements.put(
+ "vhost1.rhq4.resource.key",
+ ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
+ vhost1.serverName, vhost1.hosts));
+ }
+
+ if (vhost2 != null) {
+ replacements.put(
+ "vhost2.snmp.identifier",
+ addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost2.hosts.get(0),
+ vhost2.serverName).toString(false, false));
+
+ replacements.put(
+ "vhost2.rhq4.resource.key",
+ ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
+ vhost2.serverName, vhost2.hosts));
+ }
+
+ if (vhost3 != null) {
+ replacements.put(
+ "vhost3.snmp.identifier",
+ addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost3.hosts.get(0),
+ vhost3.serverName).toString(false, false));
+
+ replacements.put(
+ "vhost3.rhq4.resource.key",
+ ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
+ vhost3.serverName, vhost3.hosts));
+ }
+
+ if (vhost4 != null) {
+ replacements.put(
+ "vhost4.snmp.identifier",
+ addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost4.hosts.get(0),
+ vhost4.serverName).toString(false, false));
+
+ replacements.put(
+ "vhost4.rhq4.resource.key",
+ ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
+ vhost4.serverName, vhost4.hosts));
+ }
+
+ //let the user override everything we just did
+ replacements.putAll(defaultOverrides);
+
+ inventoryFileReplacements = replacements;
+
+ if (inventoryFile != null) {
+ InputStream dataStream = getClass().getResourceAsStream(inventoryFile);
+
+ Reader rdr = new TokenReplacingReader(new InputStreamReader(dataStream), replacements);
+
+ @SuppressWarnings("unchecked")
+ List<Resource> inventory = (List<Resource>) new ObjectCollectionSerializer().deserialize(rdr);
+
+ //fix up the parent relationships, because they might not be reconstructed correctly by
+ //JAXB - we're missing XmlID and XmlIDRef annotations in our model
+ fixupParent(null, inventory);
+
+ fakeInventory.prepopulateInventory(platform, inventory);
+ }
+ return this;
+ }
+
+ /**
+ * After the setup, this returns all the variables used to update the tokens in the inventory file.
+ *
+ * @return
+ */
+ public Map<String, String> getInventoryFileReplacements() {
+ return inventoryFileReplacements;
+ }
+
+ private void fixupParent(Resource parent, Collection<Resource> children) {
+ for (Resource child : children) {
+ child.setParentResource(parent);
+ if (child.getChildResources() != null) {
+ fixupParent(child, child.getChildResources());
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java
index ccbe42d..f86b095 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java
@@ -23,19 +23,13 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
-import java.io.File;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
import java.io.StringReader;
import java.net.InetAddress;
import java.net.URI;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -44,21 +38,15 @@ import java.util.UUID;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jmock.Expectations;
import org.testng.annotations.BeforeClass;
import org.rhq.core.clientapi.agent.metadata.PluginMetadataParser;
import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil;
import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
-import org.rhq.core.clientapi.server.discovery.InventoryReport;
-import org.rhq.core.domain.discovery.AvailabilityReport;
-import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceError;
import org.rhq.core.domain.resource.ResourceErrorType;
import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.pc.ServerServices;
-import org.rhq.core.pc.upgrade.FakeServerInventory;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.PluginContainerDeployment;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
@@ -70,20 +58,17 @@ import org.rhq.plugins.apache.ApacheServerComponent;
import org.rhq.plugins.apache.ApacheServerDiscoveryComponent;
import org.rhq.plugins.apache.ApacheVirtualHostServiceComponent;
import org.rhq.plugins.apache.ApacheVirtualHostServiceDiscoveryComponent;
-import org.rhq.plugins.apache.parser.ApacheConfigReader;
+import org.rhq.plugins.apache.PluginLocation;
import org.rhq.plugins.apache.parser.ApacheDirectiveTree;
-import org.rhq.plugins.apache.parser.ApacheParser;
-import org.rhq.plugins.apache.parser.ApacheParserImpl;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
+import org.rhq.plugins.apache.setup.ApacheTestSetup;
import org.rhq.plugins.apache.upgrade.UpgradeTestBase.ResourceKeyFormat;
-import org.rhq.plugins.apache.util.ApacheDeploymentUtil;
import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig;
import org.rhq.plugins.apache.util.ApacheExecutionUtil.ExpectedApacheState;
-import org.rhq.plugins.apache.util.ApacheExecutionUtil;
-import org.rhq.plugins.apache.util.HttpdAddressUtility;
+import org.rhq.plugins.apache.util.ResourceTypes;
import org.rhq.plugins.apache.util.RuntimeApacheConfiguration;
import org.rhq.plugins.apache.util.VHostSpec;
import org.rhq.plugins.apache.util.VirtualHostLegacyResourceKeyUtil;
-import org.rhq.test.ObjectCollectionSerializer;
import org.rhq.test.TokenReplacingReader;
import org.rhq.test.pc.PluginContainerTest;
@@ -101,390 +86,21 @@ public class UpgradeTestBase extends PluginContainerTest {
SNMP, RHQ3, RHQ4
};
- public class TestSetup {
- private String configurationName;
- private FakeServerInventory fakeInventory = new FakeServerInventory();
- private String inventoryFile;
- private Resource platform;
- private ApacheSetup apacheSetup = new ApacheSetup();
- private DeploymentConfig deploymentConfig;
- private Map<String, String> defaultOverrides = new HashMap<String, String>();
- private Map<String, String> inventoryFileReplacements;
-
- public class ApacheSetup {
- private String serverRoot;
- private String exePath;
- private Collection<String> configurationFiles;
- private ApacheExecutionUtil execution;
- private boolean deploy = true;
-
- private ApacheSetup() {
-
- }
-
- public ApacheSetup withServerRoot(String serverRoot) {
- this.serverRoot = serverRoot;
- //auto-define the server root property as if it was passed on the commandline
- System.getProperties().put(configurationName + ".server.root", serverRoot);
- deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, defaultOverrides);
- return this;
- }
-
- public ApacheSetup withExePath(String exePath) {
- this.exePath = exePath;
- return this;
- }
-
- public ApacheSetup withConfigurationFiles(String... classPathUris) {
- return withConfigurationFiles(Arrays.asList(classPathUris));
- }
-
- public ApacheSetup withConfigurationFiles(Collection<String> classPathUris) {
- this.configurationFiles = classPathUris;
- return this;
- }
-
- public ApacheSetup withDeploymentOnSetup() {
- this.deploy = true;
- return this;
- }
-
- public ApacheSetup withNoDeploymentOnSetup() {
- this.deploy = false;
- return this;
- }
-
- public ApacheExecutionUtil getExecutionUtil() {
- return execution;
- }
-
- public void init() throws Exception {
- File serverRootDir = new File(serverRoot);
-
- assertTrue(serverRootDir.exists(), "The configured server root denotes a non-existant directory: '"
- + serverRootDir + "'.");
-
- File confDir = new File(serverRootDir, "conf");
-
- assertTrue(confDir.exists(),
- "The configured server root denotes a directory that doesn't have a 'conf' subdirectory. This is unexpected.");
-
- String confFilePath = confDir.getAbsolutePath() + File.separatorChar + "httpd.conf";
-
- String snmpHost = null;
- int snmpPort = 0;
- String pingUrl = null;
-
- if (configurationName != null) {
- if (deploy) {
- File binDir = new File(serverRootDir, "bin");
- List<File> additionalFilesToProcess = Arrays.asList(
- new File(binDir, "apachectl"),
- new File(binDir, "envvars"),
- new File(binDir, "envvars-std"));
- ApacheDeploymentUtil.deployConfiguration(confDir, configurationFiles, additionalFilesToProcess, deploymentConfig);
- }
-
- //ok, now try to find the ping URL. The best thing is to actually invoke
- //the same code the apache server discovery does.
- ApacheDirectiveTree tree = new ApacheDirectiveTree();
- ApacheParser parser = new ApacheParserImpl(tree, serverRootDir.getAbsolutePath());
- ApacheConfigReader.buildTree(confFilePath, parser);
-
- //XXX this hardcodes apache2 as the only option we have...
- HttpdAddressUtility.Address addrToUse = HttpdAddressUtility.APACHE_2_x.getMainServerSampleAddress(tree, null, -1);
- pingUrl = addrToUse.toString();
-
- snmpHost = deploymentConfig.snmpHost;
- snmpPort = deploymentConfig.snmpPort;
- }
-
- execution = new ApacheExecutionUtil(findApachePluginResourceTypeByName("Apache HTTP Server"),
- serverRoot, exePath, confFilePath, pingUrl,
- snmpHost, snmpPort);
- execution.init();
- }
-
- private void doSetup() throws Exception {
- init();
- execution.invokeOperation(ExpectedApacheState.RUNNING, "start");
- }
-
- public TestSetup setup() throws Exception {
- return TestSetup.this.setup();
- }
- }
-
- public TestSetup(String configurationName) {
- this.configurationName = configurationName;
- deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, defaultOverrides);
- }
-
- public TestSetup withInventoryFrom(String classPathUri) {
- inventoryFile = classPathUri;
- return this;
- }
-
- public TestSetup withDefaultOverrides(Map<String, String> defaultOverrides) {
- this.defaultOverrides = defaultOverrides == null ? new HashMap<String, String>() : defaultOverrides;
- deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, this.defaultOverrides);
- return this;
- }
-
- public TestSetup withPlatformResource(Resource platform) {
- this.platform = platform;
- return this;
- }
-
- public ApacheSetup withApacheSetup() {
- return apacheSetup;
- }
-
- public TestSetup withDefaultExpectations() throws Exception {
- context.checking(new Expectations() {
- {
- addDefaultExceptations(this);
- }
- });
-
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public void addDefaultExceptations(Expectations expectations) throws Exception {
- ServerServices ss = getCurrentPluginContainerConfiguration().getServerServices();
-
- expectations.allowing(ss.getDiscoveryServerService()).mergeInventoryReport(
- expectations.with(Expectations.any(InventoryReport.class)));
- expectations.will(fakeInventory.mergeInventoryReport(InventoryStatus.COMMITTED));
-
- expectations.allowing(ss.getDiscoveryServerService()).upgradeResources(
- expectations.with(Expectations.any(Set.class)));
- expectations.will(fakeInventory.upgradeResources());
-
- expectations.allowing(ss.getDiscoveryServerService()).getResources(
- expectations.with(Expectations.any(Set.class)), expectations.with(Expectations.any(boolean.class)));
- expectations.will(fakeInventory.getResources());
-
- expectations.allowing(ss.getDiscoveryServerService()).setResourceError(expectations.with(Expectations.any(ResourceError.class)));
- expectations.will(fakeInventory.setResourceError());
-
- expectations.allowing(ss.getDiscoveryServerService()).mergeAvailabilityReport(
- expectations.with(Expectations.any(AvailabilityReport.class)));
-
- expectations.allowing(ss.getDiscoveryServerService()).postProcessNewlyCommittedResources(
- expectations.with(Expectations.any(Set.class)));
-
- expectations.allowing(ss.getDiscoveryServerService()).clearResourceConfigError(
- expectations.with(Expectations.any(int.class)));
-
- expectations.ignoring(ss.getBundleServerService());
- expectations.ignoring(ss.getConfigurationServerService());
- expectations.ignoring(ss.getContentServerService());
- expectations.ignoring(ss.getCoreServerService());
- expectations.ignoring(ss.getEventServerService());
- expectations.ignoring(ss.getMeasurementServerService());
- expectations.ignoring(ss.getOperationServerService());
- expectations.ignoring(ss.getResourceFactoryServerService());
- }
-
- public FakeServerInventory getFakeInventory() {
- return fakeInventory;
- }
-
- public DeploymentConfig getDeploymentConfig() {
- return deploymentConfig;
- }
-
- public TestSetup setup() throws Exception {
- apacheSetup.doSetup();
-
- Map<String, String> replacements = deploymentConfig.getTokenReplacements();
- replacements.put("server.root", apacheSetup.serverRoot);
- replacements.put("exe.path", apacheSetup.exePath);
-
- ApacheDeploymentUtil.addDefaultVariables(replacements, null);
-
- HttpdAddressUtility addressUtility = apacheSetup.getExecutionUtil().getServerComponent()
- .getAddressUtility();
- ApacheDirectiveTree runtimeConfig = apacheSetup.getExecutionUtil().getRuntimeConfiguration();
-
- replacements.put("snmp.identifier",
- addressUtility.getHttpdInternalMainServerAddressRepresentation(runtimeConfig).toString(false, false));
-
- replacements.put("main.rhq4.resource.key", ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY);
-
- VHostSpec vhost1 = deploymentConfig.vhost1 == null ? null : deploymentConfig.vhost1.getVHostSpec(replacements);
- VHostSpec vhost2 = deploymentConfig.vhost2 == null ? null : deploymentConfig.vhost2.getVHostSpec(replacements);
- VHostSpec vhost3 = deploymentConfig.vhost3 == null ? null : deploymentConfig.vhost3.getVHostSpec(replacements);
- VHostSpec vhost4 = deploymentConfig.vhost4 == null ? null : deploymentConfig.vhost4.getVHostSpec(replacements);
-
- if (vhost1 != null) {
- replacements.put(
- "vhost1.snmp.identifier",
- addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost1.hosts.get(0),
- vhost1.serverName).toString(false, false));
-
- replacements.put(
- "vhost1.rhq4.resource.key",
- ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
- vhost1.serverName, vhost1.hosts));
- }
-
- if (vhost2 != null) {
- replacements.put(
- "vhost2.snmp.identifier",
- addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost2.hosts.get(0),
- vhost2.serverName).toString(false, false));
-
- replacements.put(
- "vhost2.rhq4.resource.key",
- ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
- vhost2.serverName, vhost2.hosts));
- }
-
- if (vhost3 != null) {
- replacements.put(
- "vhost3.snmp.identifier",
- addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost3.hosts.get(0),
- vhost3.serverName).toString(false, false));
-
- replacements.put(
- "vhost3.rhq4.resource.key",
- ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
- vhost3.serverName, vhost3.hosts));
- }
-
- if (vhost4 != null) {
- replacements.put(
- "vhost4.snmp.identifier",
- addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost4.hosts.get(0),
- vhost4.serverName).toString(false, false));
-
- replacements.put(
- "vhost4.rhq4.resource.key",
- ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
- vhost4.serverName, vhost4.hosts));
- }
-
- //let the user override everything we just did
- replacements.putAll(defaultOverrides);
-
- inventoryFileReplacements = replacements;
-
- InputStream dataStream = getClass().getResourceAsStream(inventoryFile);
-
- Reader rdr = new TokenReplacingReader(new InputStreamReader(dataStream), replacements);
-
- @SuppressWarnings("unchecked")
- List<Resource> inventory = (List<Resource>) new ObjectCollectionSerializer().deserialize(rdr);
-
- //fix up the parent relationships, because they might not be reconstructed correctly by
- //JAXB - we're missing XmlID and XmlIDRef annotations in our model
- fixupParent(null, inventory);
-
- fakeInventory.prepopulateInventory(platform, inventory);
-
- return this;
- }
-
- /**
- * After the setup, this returns all the variables used to update the tokens in the inventory file.
- *
- * @return
- */
- public Map<String, String> getInventoryFileReplacements() {
- return inventoryFileReplacements;
- }
-
- private void fixupParent(Resource parent, Collection<Resource> children) {
- for (Resource child : children) {
- child.setParentResource(parent);
- if (child.getChildResources() != null) {
- fixupParent(child, child.getChildResources());
- }
- }
- }
- }
-
- public static class TestConfiguration {
- public String[] apacheConfigurationFiles;
- public String inventoryFile;
- public String configurationName;
- public String serverRoot;
- public String binPath;
- public Map<String, String> defaultOverrides = new HashMap<String, String>();
-
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
-
- }
-
- public void beforePluginContainerStart(TestSetup setup) throws Throwable {
-
- }
-
- public void beforeTests(TestSetup setup) throws Throwable {
-
- }
-
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
- return getFullSuccessfulUpgradeResourceKeys(setup);
- }
-
- public String[] getExpectedResourceKeysWithFailures(TestSetup setup) {
- return null;
- }
-
- protected String[] getFullSuccessfulUpgradeResourceKeys(TestSetup setup) {
- DeploymentConfig dc = setup.getDeploymentConfig();
- Map<String, String> replacements = dc.getTokenReplacements();
-
- VHostSpec vh1 = dc.vhost1.getVHostSpec(replacements);
- VHostSpec vh2 = dc.vhost2.getVHostSpec(replacements);
- VHostSpec vh3 = dc.vhost3.getVHostSpec(replacements);
- VHostSpec vh4 = dc.vhost4.getVHostSpec(replacements);
-
- String[] ret = new String[5];
-
- ret[0] = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
- ret[1] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh1.serverName, vh1.hosts);
- ret[2] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh2.serverName, vh2.hosts);
- ret[3] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh3.serverName, vh3.hosts);
- ret[4] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh4.serverName, vh4.hosts);
-
- return ret;
- }
- }
-
- protected static final String PLATFORM_PLUGIN = "file:target/itest/plugins/rhq-platform-plugin-for-apache-test.jar";
- protected static final String AUGEAS_PLUGIN = "file:target/itest/plugins/rhq-augeas-plugin-for-apache-test.jar";
- protected static final String APACHE_PLUGIN = "file:target/itest/plugins/rhq-apache-plugin-for-apache-test.jar";
-
protected static final String DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES = "simpleWithResolvableServerNames";
protected static final String DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES = "simpleWithUnresolvableServerNames";
protected static final String DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS = "simpleWithWildcardListens";
- private List<ResourceType> resourceTypesInApachePlugin;
+ private ResourceTypes apacheResourceTypes;
protected Resource platform;
@BeforeClass
public void parseResourceTypesFromApachePlugin() throws Exception {
- resourceTypesInApachePlugin = getResourceTypesInPlugin(APACHE_PLUGIN);
+ apacheResourceTypes = new ResourceTypes(PluginLocation.APACHE_PLUGIN);
platform = discoverPlatform();
}
- protected ResourceType findApachePluginResourceTypeByName(String resourceTypeName) {
- for (ResourceType rt : resourceTypesInApachePlugin) {
- if (resourceTypeName.equals(rt.getName())) {
- return rt;
- }
- }
-
- return null;
- }
-
- protected void testUpgrade(TestConfiguration testConfiguration) throws Throwable {
- final TestSetup setup = new TestSetup(testConfiguration.configurationName);
+ protected void testUpgrade(ApacheTestConfiguration testConfiguration) throws Throwable {
+ final ApacheTestSetup setup = new ApacheTestSetup(testConfiguration.configurationName, context, apacheResourceTypes);
boolean testFailed = false;
try {
@@ -507,8 +123,8 @@ public class UpgradeTestBase extends PluginContainerTest {
testConfiguration.beforeTests(setup);
//ok, now we should see the resources upgraded in the fake server inventory.
- ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server");
- ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host");
+ ResourceType serverResourceType = apacheResourceTypes.findByName("Apache HTTP Server");
+ ResourceType vhostResourceType = apacheResourceTypes.findByName("Apache Virtual Host");
Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType);
@@ -588,7 +204,7 @@ public class UpgradeTestBase extends PluginContainerTest {
}
}
- protected void defineRHQ3ResourceKeys(TestConfiguration testConfig, TestSetup setup) throws Exception {
+ protected void defineRHQ3ResourceKeys(ApacheTestConfiguration testConfig, ApacheTestSetup setup) throws Exception {
setup.withApacheSetup().init();
ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent();
ApacheDirectiveTree config = component.loadParser();
@@ -625,7 +241,7 @@ public class UpgradeTestBase extends PluginContainerTest {
return StreamUtil.slurp(new TokenReplacingReader(new StringReader(string), variables));
}
- protected static String[] getVHostRKs(TestSetup setup, int[] successfulUpgrades, int[] failedUpgrades, ResourceKeyFormat rkFormat) {
+ protected static String[] getVHostRKs(ApacheTestSetup setup, int[] successfulUpgrades, int[] failedUpgrades, ResourceKeyFormat rkFormat) {
int sucLen = successfulUpgrades == null ? 0 : successfulUpgrades.length;
int failLen = failedUpgrades == null ? 0 : failedUpgrades.length;
@@ -679,17 +295,9 @@ public class UpgradeTestBase extends PluginContainerTest {
return ret;
}
- private static List<ResourceType> getResourceTypesInPlugin(String pluginUri) throws Exception {
- PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(pluginUri).toURL());
- PluginMetadataParser parser = new PluginMetadataParser(descriptor,
- Collections.<String, PluginMetadataParser> emptyMap());
-
- return parser.getAllTypes();
- }
-
@SuppressWarnings({ "rawtypes", "unchecked" })
- private static Resource discoverPlatform() throws Exception {
- PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(PLATFORM_PLUGIN)
+ public static Resource discoverPlatform() throws Exception {
+ PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(PluginLocation.PLATFORM_PLUGIN)
.toURL());
PluginMetadataParser parser = new PluginMetadataParser(descriptor,
Collections.<String, PluginMetadataParser> emptyMap());
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeNestedConfigurationFromRHQ1_3Test.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeNestedConfigurationFromRHQ1_3Test.java
index 69d7e78..80efc67 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeNestedConfigurationFromRHQ1_3Test.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeNestedConfigurationFromRHQ1_3Test.java
@@ -24,6 +24,9 @@ import java.util.HashMap;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
+import org.rhq.plugins.apache.PluginLocation;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
+import org.rhq.plugins.apache.setup.ApacheTestSetup;
import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
import org.rhq.test.pc.PluginContainerSetup;
@@ -50,12 +53,12 @@ public class UpgradeNestedConfigurationFromRHQ1_3Test extends UpgradeTestBase {
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithResolvableServerNames(final String installPath, final String exePath)
throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
serverRoot = installPath;
binPath = exePath;
@@ -65,7 +68,7 @@ public class UpgradeNestedConfigurationFromRHQ1_3Test extends UpgradeTestBase {
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.SNMP);
}
});
@@ -88,10 +91,10 @@ public class UpgradeNestedConfigurationFromRHQ1_3Test extends UpgradeTestBase {
// }
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }, numberOfInitialDiscoveries = 2)
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN }, numberOfInitialDiscoveries = 2)
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithNonUniqueServerNames(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES;
apacheConfigurationFiles = configuredApacheConfigurationFiles;
@@ -107,17 +110,17 @@ public class UpgradeNestedConfigurationFromRHQ1_3Test extends UpgradeTestBase {
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.SNMP);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2)
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN}, numberOfInitialDiscoveries = 2)
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddress(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -135,17 +138,17 @@ public class UpgradeNestedConfigurationFromRHQ1_3Test extends UpgradeTestBase {
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.SNMP);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddress(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -163,7 +166,7 @@ public class UpgradeNestedConfigurationFromRHQ1_3Test extends UpgradeTestBase {
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.SNMP);
}
});
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java
index 167ba8d..fff3bab 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java
@@ -24,6 +24,8 @@ import java.util.HashMap;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
+import org.rhq.plugins.apache.PluginLocation;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
import org.rhq.test.pc.PluginContainerSetup;
@@ -52,12 +54,12 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase {
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithResolvableServerNames_Apache2(final String installPath, final String exePath)
throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
serverRoot = installPath;
binPath = exePath;
@@ -70,12 +72,12 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase {
@Test(enabled = false)
//ApacheServerOperationsDelegate doesn't work with apache 1.3
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache1.install.dir", "apache1.exe.path" })
public void testWithResolvableServerNames_Apache1(final String installPath, final String exePath)
throws Throwable {
- testUpgrade(new TestConfiguration() {{
+ testUpgrade(new ApacheTestConfiguration() {{
serverRoot = installPath;
binPath = exePath;
configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES;
@@ -85,10 +87,10 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase {
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithNonUniqueServerNames_Apache2(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES;
apacheConfigurationFiles = configuredApacheConfigurationFiles;
@@ -108,10 +110,10 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase {
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddress(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -130,10 +132,10 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase {
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddress(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeNestedConfigurationFromRHQ3_0_0Test.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeNestedConfigurationFromRHQ3_0_0Test.java
index 4e16208..67bedf4 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeNestedConfigurationFromRHQ3_0_0Test.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeNestedConfigurationFromRHQ3_0_0Test.java
@@ -22,6 +22,9 @@ package org.rhq.plugins.apache.upgrade.rhq3_0_0;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
+import org.rhq.plugins.apache.PluginLocation;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
+import org.rhq.plugins.apache.setup.ApacheTestSetup;
import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
import org.rhq.test.pc.PluginContainerSetup;
@@ -60,10 +63,10 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
* and therefore the vhost discovery wouldn't even take place.
*/
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }, numberOfInitialDiscoveries = 2)
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN }, numberOfInitialDiscoveries = 2)
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -78,17 +81,17 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }, numberOfInitialDiscoveries = 2)
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN }, numberOfInitialDiscoveries = 2)
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithUnresolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -107,17 +110,17 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }, numberOfInitialDiscoveries = 2)
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN }, numberOfInitialDiscoveries = 2)
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithNonUniqueNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -136,7 +139,7 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
@@ -154,10 +157,10 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
* @throws Throwable
*/
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -167,22 +170,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithUnresolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -203,22 +206,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithNonUniqueNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -239,22 +242,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -275,17 +278,17 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddressWithSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -302,22 +305,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -338,17 +341,17 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddressWithSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -365,12 +368,12 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java
index ececb12..9fceb54 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java
@@ -23,6 +23,9 @@ package org.rhq.plugins.apache.upgrade.rhq3_0_0;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
+import org.rhq.plugins.apache.PluginLocation;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
+import org.rhq.plugins.apache.setup.ApacheTestSetup;
import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
import org.rhq.test.pc.PluginContainerSetup;
@@ -67,10 +70,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
* and therefore the vhost discovery wouldn't even take place.
*/
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2)
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN}, numberOfInitialDiscoveries = 2)
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -87,10 +90,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2)
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN}, numberOfInitialDiscoveries = 2)
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithUnresolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -108,10 +111,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2)
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN}, numberOfInitialDiscoveries = 2)
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithNonUniqueNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -140,10 +143,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
* @throws Throwable
*/
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -153,17 +156,17 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithUnresolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -179,17 +182,17 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithNonUniqueNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -205,17 +208,17 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -251,10 +254,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
* @throws Throwable
*/
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddressWithSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -271,17 +274,17 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -304,10 +307,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddressWithSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -324,7 +327,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeNestedConfigurationFromRHQ3_0_1Test.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeNestedConfigurationFromRHQ3_0_1Test.java
index f8231a9..97c1c35 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeNestedConfigurationFromRHQ3_0_1Test.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeNestedConfigurationFromRHQ3_0_1Test.java
@@ -24,6 +24,9 @@ import java.util.Arrays;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
+import org.rhq.plugins.apache.PluginLocation;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
+import org.rhq.plugins.apache.setup.ApacheTestSetup;
import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
import org.rhq.test.pc.PluginContainerSetup;
@@ -68,10 +71,10 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -81,22 +84,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -111,22 +114,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithUnresolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -142,22 +145,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithUnresolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -181,22 +184,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithNonUniqueNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -212,22 +215,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithNonUniqueNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -250,12 +253,12 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
@@ -281,10 +284,10 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
* @throws Throwable
*/
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testDuplicateMainVhostsMarkedAsFailedUpgrade(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithDuplicateMain;
@@ -294,12 +297,12 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
//the inventory has main1, main2 and vhost4
//main2 and main1 would be upgraded to the same resource key (MainServer)
//the upgrade therefore fails and no discoveries are being made
@@ -317,7 +320,7 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysWithFailures(TestSetup setup) {
+ public String[] getExpectedResourceKeysWithFailures(ApacheTestSetup setup) {
String mainVhost1RK = setup.getInventoryFileReplacements().get("main.rhq3.resource.key");
String mainVhost2RK = setup.getInventoryFileReplacements().get("snmp.identifier");
return new String[] { mainVhost1RK, mainVhost2RK };
@@ -326,10 +329,10 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -352,12 +355,12 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
@@ -377,10 +380,10 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
* @throws Throwable
*/
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddressWithSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -397,22 +400,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -433,23 +436,23 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddressWithSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -466,12 +469,12 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java
index 4af1879..ffdc62d 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java
@@ -24,6 +24,9 @@ import java.util.Arrays;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
+import org.rhq.plugins.apache.PluginLocation;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
+import org.rhq.plugins.apache.setup.ApacheTestSetup;
import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
import org.rhq.test.pc.PluginContainerSetup;
@@ -68,10 +71,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -81,17 +84,17 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -106,12 +109,12 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
//the inventory has main, vhost1, vhost2, vhost3 and vhost4
//the main vhost uses the URL of the server resource as its RK which is
//setup to be the IP address, whereas vhost1 uses the 'normal'
@@ -125,7 +128,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysWithFailures(TestSetup setup) {
+ public String[] getExpectedResourceKeysWithFailures(ApacheTestSetup setup) {
String failedRK = setup.getInventoryFileReplacements().get("vhost1.rhq3.resource.key");
return new String[] { failedRK };
}
@@ -133,10 +136,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithUnresolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -152,17 +155,17 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithUnresolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -181,17 +184,17 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithNonUniqueNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -207,17 +210,17 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithNonUniqueNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -240,7 +243,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
@@ -266,10 +269,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
* @throws Throwable
*/
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testDuplicateMainVhostsMarkedAsFailedUpgrade(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithDuplicateMain;
@@ -279,12 +282,12 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
//the inventory has main1, main2, vhost2, vhost3 and vhost4
//vhost1 has the same resource key as the main vhost in RHQ 3.0.0
//because the upgrade failed for main (because of the ambiguity),
@@ -302,7 +305,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysWithFailures(TestSetup setup) {
+ public String[] getExpectedResourceKeysWithFailures(ApacheTestSetup setup) {
String mainVhost1RK = setup.getInventoryFileReplacements().get("main.rhq3.resource.key");
String mainVhost2RK = interpret("${localhost}:${port1}", setup.getInventoryFileReplacements());
return new String[] { mainVhost1RK, mainVhost2RK };
@@ -311,10 +314,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -337,7 +340,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
@@ -357,10 +360,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
* @throws Throwable
*/
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddressWithSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -377,7 +380,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
@@ -388,10 +391,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
* vhosts - it could be either a main vhost or vhost1.
*/
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -412,12 +415,12 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
//the inventory has main, vhost1, vhost2, vhost3 and vhost4
//the main vhost uses the URL of the server resource as its RK which is
//setup to be the IP address, whereas vhost1 uses the 'normal'
@@ -431,7 +434,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysWithFailures(TestSetup setup) {
+ public String[] getExpectedResourceKeysWithFailures(ApacheTestSetup setup) {
String failedRK = setup.getInventoryFileReplacements().get("vhost1.rhq3.resource.key");
return new String[] { failedRK };
}
@@ -439,10 +442,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddressWithSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -459,7 +462,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeNestedConfigurationFromRHQ3_0_2Test.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeNestedConfigurationFromRHQ3_0_2Test.java
index 2e31664..e911667 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeNestedConfigurationFromRHQ3_0_2Test.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeNestedConfigurationFromRHQ3_0_2Test.java
@@ -22,8 +22,10 @@ package org.rhq.plugins.apache.upgrade.rhq3_0_2;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
+import org.rhq.plugins.apache.PluginLocation;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
+import org.rhq.plugins.apache.setup.ApacheTestSetup;
import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
-import org.rhq.plugins.apache.upgrade.UpgradeTestBase.TestSetup;
import org.rhq.test.pc.PluginContainerSetup;
/**
@@ -57,10 +59,10 @@ public class UpgradeNestedConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithResolvableNames(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFile;
@@ -70,17 +72,17 @@ public class UpgradeNestedConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithUnresolvableNames(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFile;
@@ -101,17 +103,17 @@ public class UpgradeNestedConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithNonUniqueNames(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSingleVHost;
@@ -132,17 +134,17 @@ public class UpgradeNestedConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddress(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -163,7 +165,7 @@ public class UpgradeNestedConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
@@ -174,10 +176,10 @@ public class UpgradeNestedConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
* vhosts - it could be either a main vhost or vhost1.
*/
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddress(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -198,7 +200,7 @@ public class UpgradeNestedConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java
index 38b7368..3882f8f 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java
@@ -22,6 +22,8 @@ package org.rhq.plugins.apache.upgrade.rhq3_0_2;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
+import org.rhq.plugins.apache.PluginLocation;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
import org.rhq.test.pc.PluginContainerSetup;
@@ -56,10 +58,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithResolvableNames(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFile;
@@ -71,10 +73,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithUnresolvableNames(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFile;
@@ -97,10 +99,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithNonUniqueNames(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSingleVhost;
@@ -123,10 +125,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddress(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -153,10 +155,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
* vhosts - it could be either a main vhost or vhost1.
*/
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddress(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/util/ResourceTypes.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/util/ResourceTypes.java
new file mode 100644
index 0000000..fa8e8be
--- /dev/null
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/util/ResourceTypes.java
@@ -0,0 +1,66 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.apache.util;
+
+import java.net.URI;
+import java.util.Collections;
+import java.util.List;
+
+import org.rhq.core.clientapi.agent.metadata.PluginMetadataParser;
+import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil;
+import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
+import org.rhq.core.domain.resource.ResourceType;
+
+/**
+ *
+ *
+ * @author Lukas Krejci
+ */
+public class ResourceTypes {
+
+ private List<ResourceType> resourceTypes;
+
+ public ResourceTypes(String pluginUri) throws Exception {
+ this.resourceTypes = getResourceTypesInPlugin(pluginUri);
+ }
+
+ public List<ResourceType> getResourceTypes() {
+ return resourceTypes;
+ }
+
+ public ResourceType findByName(String resourceTypeName) {
+ for (ResourceType rt : resourceTypes) {
+ if (resourceTypeName.equals(rt.getName())) {
+ return rt;
+ }
+ }
+
+ return null;
+ }
+
+ private static List<ResourceType> getResourceTypesInPlugin(String pluginUri) throws Exception {
+ PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(pluginUri).toURL());
+ PluginMetadataParser parser = new PluginMetadataParser(descriptor,
+ Collections.<String, PluginMetadataParser> emptyMap());
+
+ return parser.getAllTypes();
+ }
+
+}
diff --git a/modules/integration-tests/apache-plugin-test/src/test/resources/augeas-leak-test-config/httpd.conf b/modules/integration-tests/apache-plugin-test/src/test/resources/augeas-leak-test-config/httpd.conf
new file mode 100644
index 0000000..c740459
--- /dev/null
+++ b/modules/integration-tests/apache-plugin-test/src/test/resources/augeas-leak-test-config/httpd.conf
@@ -0,0 +1,64 @@
+ServerRoot ${server.root}
+
+Listen ${listen1}
+Listen ${listen2}
+Listen ${listen3}
+Listen ${listen4}
+
+ServerAdmin root@localhost
+
+${servername.directive}
+
+DocumentRoot ${document.root}
+
+DefaultType text/plain
+
+ErrorLog logs/error_log
+
+LogLevel debug
+
+# Apache SNMP
+LoadModule snmpcommon_module modules/libsnmpcommon.so
+LoadModule snmpagt_module modules/libsnmpmonagt.so
+SNMPConf conf
+SNMPVar var
+# End of apache SNMP
+
+${additional.directives}
+
+<Directory "/var/www/html">
+</Directory>
+
+<IfModule not_loaded_module>
+ <VirtualHost ${vhost1.urls}>
+ ${vhost1.servername.directive}
+ ${vhost1.additional.directives}
+ </VirtualHost>
+</IfModule>
+
+LoadModule alias_module modules/mod_alias.so
+
+<IfModule snmpcommon_module>
+<IfModule mod_alias.c>
+ <Directory "/var/www/html2">
+ </Directory>
+ <VirtualHost ${vhost2.urls}>
+ ${vhost2.servername.directive}
+ ${vhost2.additional.directives}
+ </VirtualHost>
+</IfModule>
+
+<IfModule mod_unknown.c>
+ <VirtualHost ${vhost3.urls}>
+ ${vhost3.servername.directive}
+ ${vhost3.additional.directives}
+ </VirtualHost>
+</IfModule>
+</IfModule>
+
+<VirtualHost ${vhost4.urls}>
+ ${vhost4.servername.directive}
+ ${vhost4.additional.directives}
+ <Directory "/var/www/html3">
+ </Directory>
+</VirtualHost>
commit fd9d48ccc5b0eac0bd8e1cab216480d894969e05
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Aug 4 11:44:13 2011 +0200
JMockTest now behaves as originally intended when used as a Listener on a class.
By default any class specified in the @Listeners annotation is used as a listener on
ALL tests in ALL test classes in the current test suite.
The JMockTest to be of any use needs only to be applied on a class it is specified on, because
we certainly don't want all the test methods to use jmock.
diff --git a/modules/test-utils/src/main/java/org/rhq/test/JMockTest.java b/modules/test-utils/src/main/java/org/rhq/test/JMockTest.java
index 2088460..0cb5e22 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/JMockTest.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/JMockTest.java
@@ -30,6 +30,7 @@ import org.testng.IHookCallBack;
import org.testng.IHookable;
import org.testng.IInvokedMethod;
import org.testng.IInvokedMethodListener;
+import org.testng.ITestNGListener;
import org.testng.ITestResult;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -44,6 +45,13 @@ import org.testng.annotations.Listeners;
* field, while in the latter case (when JMockTest is specified as a {@link Listeners listener}
* of a test class), the JMock context is accessible using the {@link #getCurrentMockContext()}
* static method.
+ * <p>
+ * Unlike the default behavior of the Listeners annotation which makes the supplied classes
+ * the listeners on <b>ALL</b> test methods in <b>ALL</b> classes, this implementation behaves differntly.
+ * It checks whether the Listeners annotation is specified on the class that the current test
+ * method is being executed on (or its superclasses) and only if it does, the test method is
+ * "augmented". This means that the classes can specify if they want to be augmented by JMockTest
+ * by specifying it as their listener.
*
* @author John Sanda
* @author Lukas Krejci
@@ -54,9 +62,6 @@ public class JMockTest implements IHookable, IInvokedMethodListener {
private static final ThreadLocal<Mockery> STATICALLY_ACCESSIBLE_CONTEXT = new ThreadLocal<Mockery>();
- private boolean initRan;
- private boolean tearDownRan;
-
/**
* @return the JMock context of the current test or null if the calling test class doesn't have
* this class set as a listener or doesn't inherit from this class.
@@ -66,21 +71,13 @@ public class JMockTest implements IHookable, IInvokedMethodListener {
}
@BeforeMethod
- public void initMockContext(Method testMethod) {
- if (!initRan) {
- initBeforeTest(this, testMethod);
- }
- tearDownRan = false;
- initRan = true;
+ public final void initMockContext(Method testMethod) {
+ initBeforeTest(this, testMethod);
}
@AfterMethod
- public void tearDownMockContext(ITestResult testResult) {
- if (!tearDownRan) {
- tearDownAfterTest(testResult);
- }
- tearDownRan = true;
- initRan = false;
+ public final void tearDownMockContext(ITestResult testResult) {
+ tearDownAfterTest(testResult);
}
/**
@@ -101,12 +98,10 @@ public class JMockTest implements IHookable, IInvokedMethodListener {
*
* @see IInvokedMethodListener#beforeInvocation(IInvokedMethod, ITestResult)
*/
- public final void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
- if (!initRan) {
+ public final void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
+ if (!isUsedAsSubClass(method) && isListenerDefinedOnTestClass(method)) {
initBeforeTest(testResult.getInstance(), testResult.getMethod().getMethod());
}
- initRan = true;
- tearDownRan = false;
}
/**
@@ -115,11 +110,9 @@ public class JMockTest implements IHookable, IInvokedMethodListener {
* @see IInvokedMethodListener#afterInvocation(IInvokedMethod, ITestResult)
*/
public final void afterInvocation(IInvokedMethod method, ITestResult testResult) {
- if (!tearDownRan) {
+ if (!isUsedAsSubClass(method) && isListenerDefinedOnTestClass(method)) {
tearDownAfterTest(testResult);
}
- initRan = false;
- tearDownRan = true;
}
/**
@@ -164,4 +157,30 @@ public class JMockTest implements IHookable, IInvokedMethodListener {
//collect the no-longer used context.
STATICALLY_ACCESSIBLE_CONTEXT.set(null);
}
+
+ private boolean isUsedAsSubClass(IInvokedMethod method) {
+ Class<?> testMethodClass = method.getTestMethod().getTestClass().getRealClass();
+
+ return this.getClass().isAssignableFrom(testMethodClass);
+ }
+
+ private boolean isListenerDefinedOnTestClass(IInvokedMethod method) {
+ Class<?> cls = method.getTestMethod().getTestClass().getRealClass();
+
+ while (cls != null) {
+ Listeners annotation = cls.getAnnotation(Listeners.class);
+
+ if (annotation != null) {
+ for(Class<?> listener : annotation.value()) {
+ if (this.getClass().equals(listener)) {
+ return true;
+ }
+ }
+ }
+
+ cls = cls.getSuperclass();
+ }
+
+ return false;
+ }
}
commit ba3fcbe5cdea5c384743c0a90e71e73a48707b9f
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Aug 1 14:11:28 2011 +0200
BZ 721152 - fixing the augeas memory leak - cherrypicked over from release-3.0.0
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java
index 0c3f447..e828818 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java
@@ -23,17 +23,14 @@
package org.rhq.plugins.apache;
-import java.util.ArrayList;
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
-import org.rhq.core.domain.configuration.Property;
-import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
@@ -46,23 +43,24 @@ import org.rhq.plugins.apache.mapping.ApacheAugeasMapping;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
/**
- * Component for configuring the <Directory> and underlying directives inside
- * Apache configuration.
+ * Component for configuring the <Directory> and underlying directives
+ * inside Apache configuration.
*
* @author Lukas Krejci
*/
-public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtualHostServiceComponent>, ConfigurationFacet, DeleteResourceFacet {
-
- private final Log log = LogFactory.getLog(this.getClass());
+public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtualHostServiceComponent>,
+ ConfigurationFacet, DeleteResourceFacet {
+
+ private final Log log = LogFactory.getLog(this.getClass());
public static final String REGEXP_PROP = "regexp";
public static final String DIRECTORY_DIRECTIVE = "<Directory";
-
+
private ResourceContext<ApacheVirtualHostServiceComponent> resourceContext;
-
- public void start(ResourceContext<ApacheVirtualHostServiceComponent> context) throws InvalidPluginConfigurationException, Exception {
- resourceContext = context;
- }
-
+
+ public void start(ResourceContext<ApacheVirtualHostServiceComponent> context)
+ throws InvalidPluginConfigurationException, Exception {
+ resourceContext = context;
+ }
public void stop() {
}
@@ -73,20 +71,27 @@ public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtual
public Configuration loadResourceConfiguration() throws Exception {
ApacheVirtualHostServiceComponent parentVirtualHost = resourceContext.getParentResourceComponent();
- AugeasTree tree = parentVirtualHost.getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType().getResourceConfigurationDefinition();
-
- AugeasNode virtualHostNode = parentVirtualHost.getNode(tree);
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- return mapping.updateConfiguration(getNode(virtualHostNode), resourceConfigDef);
+
+ AugeasComponent comp = getAugeas();
+ try {
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
+
+ AugeasNode virtualHostNode = parentVirtualHost.getNode(tree);
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ return mapping.updateConfiguration(getNode(virtualHostNode), resourceConfigDef);
+ } finally {
+ comp.close();
+ }
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
- ApacheVirtualHostServiceComponent parentVirtualHost = resourceContext.getParentResourceComponent();
+ AugeasComponent comp = getAugeas();
AugeasTree tree = null;
try {
- tree = parentVirtualHost.getServerConfigurationTree();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
.getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
@@ -96,7 +101,7 @@ public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtual
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
log.info("Apache configuration was updated");
-
+
resourceContext.getParentResourceComponent().finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null)
@@ -104,27 +109,35 @@ public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtual
else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ } finally {
+ comp.close();
}
- }
-
+ }
public void deleteResource() throws Exception {
ApacheVirtualHostServiceComponent parentVirtualHost = resourceContext.getParentResourceComponent();
- AugeasTree tree = parentVirtualHost.getServerConfigurationTree();
- AugeasNode virtualHostNode = parentVirtualHost.getNode(tree);
-
- AugeasNode myNode = getNode(virtualHostNode);
-
- if (myNode != null) {
- tree.removeNode(myNode, true);
- tree.save();
-
- ApacheVirtualHostServiceComponent parentVhost = resourceContext.getParentResourceComponent();
-
- parentVhost.deleteEmptyFile(tree, myNode);
- parentVhost.conditionalRestart();
- } else {
- log.info("Could find the configuration corresponding to the directory " + resourceContext.getResourceKey() + ". Ignoring.");
+ AugeasComponent comp = getAugeas();
+
+ try {
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ AugeasNode virtualHostNode = parentVirtualHost.getNode(tree);
+
+ AugeasNode myNode = getNode(virtualHostNode);
+
+ if (myNode != null) {
+ tree.removeNode(myNode, true);
+ tree.save();
+
+ ApacheVirtualHostServiceComponent parentVhost = resourceContext.getParentResourceComponent();
+
+ parentVhost.deleteEmptyFile(tree, myNode);
+ parentVhost.conditionalRestart();
+ } else {
+ log.info("Could find the configuration corresponding to the directory "
+ + resourceContext.getResourceKey() + ". Ignoring.");
+ }
+ } finally {
+ comp.close();
}
}
@@ -132,35 +145,36 @@ public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtual
* Gets the node from under given node corresponding to the Directory this
* component is managing.
*
- * @param virtualHost the node of the parent virtualHost (or root node of the augeas tree)
+ * @param virtualHost
+ * the node of the parent virtualHost (or root node of the augeas
+ * tree)
* @return
*/
public AugeasNode getNode(AugeasNode virtualHost) {
AugeasNode directory = AugeasNodeSearch.findNodeById(virtualHost, resourceContext.getResourceKey());
-
+
return directory;
}
-
- public AugeasNode getNode(){
+
+ public AugeasNode getNode(AugeasTree tree) {
ApacheVirtualHostServiceComponent virtHost = resourceContext.getParentResourceComponent();
- AugeasTree tree = virtHost.getServerConfigurationTree();
AugeasNode virtHostNode = resourceContext.getParentResourceComponent().getNode(tree);
return getNode(virtHostNode);
}
-
- public AugeasTree getServerConfigurationTree(){
- return resourceContext.getParentResourceComponent().getServerConfigurationTree();
+
+ public AugeasComponent getAugeas() {
+ return resourceContext.getParentResourceComponent().getAugeas();
}
-
+
/**
* @see ApacheServerComponent#finishConfigurationUpdate(ConfigurationUpdateReport)
*/
public void finishConfigurationUpdate(ConfigurationUpdateReport report) {
resourceContext.getParentResourceComponent().finishConfigurationUpdate(report);
}
-
- public boolean isAugeasEnabled(){
+
+ public boolean isAugeasEnabled() {
ApacheVirtualHostServiceComponent parent = resourceContext.getParentResourceComponent();
- return parent.isAugeasEnabled();
+ return parent.isAugeasEnabled();
}
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java
index c407f34..97d14d5 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java
@@ -29,6 +29,7 @@ import java.util.Set;
import net.augeas.AugeasException;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
@@ -52,8 +53,8 @@ public class ApacheDirectoryDiscoveryComponent implements ResourceDiscoveryCompo
* @see org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext)
*/
public static final String DIRECTORY_DIRECTIVE = "<Directory";
- public static final String [] PARENT_DIRECTIVES = {"<IfModule"};
-
+ public static final String[] PARENT_DIRECTIVES = { "<IfModule" };
+
public Set<DiscoveredResourceDetails> discoverResources(
ResourceDiscoveryContext<ApacheVirtualHostServiceComponent> context)
throws InvalidPluginConfigurationException, Exception {
@@ -63,47 +64,55 @@ public class ApacheDirectoryDiscoveryComponent implements ResourceDiscoveryCompo
if (!context.getParentResourceComponent().isAugeasEnabled())
return discoveredResources;
-
+ AugeasComponent comp = context.getParentResourceComponent().getAugeas();
AugeasTree tree = null;
-
+
try {
- tree = context.getParentResourceComponent().getServerConfigurationTree();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
} catch (AugeasException e) {
//we depend on Augeas to do anything useful with directories.
- //give up, if Augeas isn't there.
+ //give up, if Augeas isn't there.
+ comp.close();
return discoveredResources;
}
- AugeasNode parentNode = context.getParentResourceComponent().getNode(tree);
- List<AugeasNode> directories = AugeasNodeSearch.searchNode(PARENT_DIRECTIVES, DIRECTORY_DIRECTIVE, parentNode);
-
- ResourceType resourceType = context.getResourceType();
-
- for (AugeasNode node : directories) {
- Configuration pluginConfiguration = new Configuration();
-
- String ifmoduleParams = AugeasNodeSearch.getNodeKey(node, parentNode);
- List<AugeasNode> params = node.getChildByLabel("param");
-
- String directoryParam;
- boolean isRegexp;
-
- if (params.size() > 1) {
- directoryParam = params.get(1).getValue();
- isRegexp = true;
- } else {
- directoryParam = params.get(0).getValue();
- isRegexp = false;
+ try {
+ AugeasNode parentNode = context.getParentResourceComponent().getNode(tree);
+ List<AugeasNode> directories = AugeasNodeSearch.searchNode(PARENT_DIRECTIVES, DIRECTORY_DIRECTIVE,
+ parentNode);
+
+ ResourceType resourceType = context.getResourceType();
+
+ for (AugeasNode node : directories) {
+ Configuration pluginConfiguration = new Configuration();
+
+ String ifmoduleParams = AugeasNodeSearch.getNodeKey(node, parentNode);
+ List<AugeasNode> params = node.getChildByLabel("param");
+
+ String directoryParam;
+ boolean isRegexp;
+
+ if (params.size() > 1) {
+ directoryParam = params.get(1).getValue();
+ isRegexp = true;
+ } else {
+ directoryParam = params.get(0).getValue();
+ isRegexp = false;
+ }
+
+ pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.REGEXP_PROP, isRegexp));
+
+ String resourceKey = ifmoduleParams;
+ String resourceName = AugeasNodeValueUtil.unescape(directoryParam);
+
+ discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null,
+ null, pluginConfiguration, null));
}
-
- pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.REGEXP_PROP, isRegexp));
-
- String resourceKey = ifmoduleParams;
- String resourceName = AugeasNodeValueUtil.unescape(directoryParam);
-
- discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null, null,
- pluginConfiguration, null));
+ return discoveredResources;
+
+ } finally {
+ if (comp != null)
+ comp.close();
}
- return discoveredResources;
}
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java
index b046f17..bd6b4ee 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java
@@ -22,19 +22,14 @@
*/
package org.rhq.plugins.apache;
-import java.util.ArrayList;
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
-import org.rhq.core.domain.configuration.Property;
-import org.rhq.core.domain.configuration.PropertyList;
-import org.rhq.core.domain.configuration.PropertyMap;
-import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
@@ -43,57 +38,64 @@ import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.plugins.apache.augeas.mappingImpl.MappingPositionToConfiguration;
import org.rhq.plugins.apache.mapping.ApacheAugeasMapping;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
-
-public class ApacheIfModuleComponent implements ResourceComponent<ApacheVirtualHostServiceComponent>, ConfigurationFacet, DeleteResourceFacet {
+public class ApacheIfModuleComponent implements ResourceComponent<ApacheVirtualHostServiceComponent>,
+ ConfigurationFacet, DeleteResourceFacet {
private AugeasTree tree;
private ResourceContext<ApacheVirtualHostServiceComponent> context;
- private ApacheVirtualHostServiceComponent parentComponent;
+ private ApacheVirtualHostServiceComponent parentComponent;
private final Log log = LogFactory.getLog(this.getClass());
- private static final String IFMODULE_DIRECTIVE_NAME="<IfModule";
-
+ private static final String IFMODULE_DIRECTIVE_NAME = "<IfModule";
+
public void start(ResourceContext<ApacheVirtualHostServiceComponent> context)
throws InvalidPluginConfigurationException, Exception {
-
- this.context = context;
- parentComponent = context.getParentResourceComponent();
+
+ this.context = context;
+ parentComponent = context.getParentResourceComponent();
}
- public void stop(){
+ public void stop() {
}
public AvailabilityType getAvailability() {
- return parentComponent.getAvailability();
+ return parentComponent.getAvailability();
}
- public Configuration loadResourceConfiguration() throws Exception {
- AugeasTree tree = parentComponent.getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
-
- AugeasNode virtualHostNode = parentComponent.getNode(tree);
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- return mapping.updateConfiguration(getNode(virtualHostNode), resourceConfigDef);
+ public Configuration loadResourceConfiguration() throws Exception {
+ AugeasComponent comp = null;
+ try {
+ comp = parentComponent.getAugeas();
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
+
+ AugeasNode virtualHostNode = parentComponent.getNode(tree);
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ return mapping.updateConfiguration(getNode(virtualHostNode), resourceConfigDef);
+ } finally {
+ if (comp != null)
+ comp.close();
+ }
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ AugeasComponent comp = null;
AugeasTree tree = null;
try {
- tree = parentComponent.getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = context.getResourceType()
- .getResourceConfigurationDefinition();
+ comp = parentComponent.getAugeas();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
-
+
AugeasNode directoryNode = getNode(parentComponent.getNode(tree));
mapping.updateAugeas(directoryNode, report.getConfiguration(), resourceConfigDef);
tree.save();
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
log.info("Apache configuration was updated");
-
+
context.getParentResourceComponent().finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null)
@@ -101,73 +103,30 @@ public class ApacheIfModuleComponent implements ResourceComponent<ApacheVirtualH
else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ } finally {
+ if (comp != null)
+ comp.close();
}
- }
+ }
+
public void deleteResource() throws Exception {
-
+
}
-
+
private AugeasNode getNode(AugeasNode virtualHost) {
AugeasNode directory = AugeasNodeSearch.findNodeById(virtualHost, context.getResourceKey());
return directory;
- }
-
- private void prepareNode(AugeasNode node,AugeasNode parentNode,AugeasTree tree,Configuration configuration){
- List<String> params = AugeasNodeSearch.getParams(node, parentNode);
-
- PropertyList list = (PropertyList)configuration.get(MappingPositionToConfiguration.LIST_PROPERTY_NAME);
- List<String> newParams = new ArrayList<String>();
- //get new list of params
- for (Property prop : list.getList()){
- if (prop instanceof PropertyMap)
- {
- PropertyMap propMap = (PropertyMap) prop;
- PropertySimple value = (PropertySimple) propMap.get(MappingPositionToConfiguration.SIMPLE_PROPERTY_NAME);
- newParams.add(value.getStringValue());
- }
- }
-
- int i = 0;
- int position = 0;
- AugeasNode tempNode = parentNode;
- boolean updated = true;
-
- while (updated){
- updated = false;
- List<AugeasNode> nodes = tempNode.getChildByLabel(IFMODULE_DIRECTIVE_NAME);
- for (AugeasNode nd : nodes){
- List<AugeasNode> paramNodes = nd.getChildByLabel("param");
- if (paramNodes.size()>0)
- {
- String value = paramNodes.get(0).getValue();
- if (value.equals(newParams.get(position)))
- {
- position = position + 1;
- tempNode = nd;
- updated = true;
- break;
- }
- }
- }
- }
-
- for(i=position;i<newParams.size();i++){
- int size = tempNode.getChildByLabel(IFMODULE_DIRECTIVE_NAME).size()+1;
- tempNode = tree.createNode(tempNode, IFMODULE_DIRECTIVE_NAME, null, size);
- tree.createNode(tempNode, "param", newParams.get(i), 1);
- }
}
-
- public void copy(AugeasNode a, AugeasNode b){
- for (AugeasNode nd : a.getChildNodes()){
+
+ public void copy(AugeasNode a, AugeasNode b) {
+ for (AugeasNode nd : a.getChildNodes()) {
AugeasNode tempNode = tree.createNode(b, nd.getLabel(), nd.getValue(), nd.getSeq());
- copy(nd,tempNode);
+ copy(nd, tempNode);
}
}
-
-
- public boolean isAugeasEnabled(){
- return parentComponent.isAugeasEnabled();
+
+ public boolean isAugeasEnabled() {
+ return parentComponent.isAugeasEnabled();
}
-
+
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java
index acb2572..dedcb3c 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java
@@ -24,6 +24,8 @@ package org.rhq.plugins.apache;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
@@ -38,51 +40,57 @@ import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.plugins.apache.mapping.ApacheAugeasMapping;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
-public class ApacheIfModuleDirectoryComponent implements ResourceComponent<ApacheDirectoryComponent>, ConfigurationFacet {
+public class ApacheIfModuleDirectoryComponent implements ResourceComponent<ApacheDirectoryComponent>,
+ ConfigurationFacet {
private ResourceContext<ApacheDirectoryComponent> context;
- private ApacheDirectoryComponent parentComponent;
+ private ApacheDirectoryComponent parentComponent;
private final Log log = LogFactory.getLog(this.getClass());
- private static final String IFMODULE_DIRECTIVE_NAME="<IfModule";
-
- public void start(ResourceContext<ApacheDirectoryComponent> context)
- throws InvalidPluginConfigurationException, Exception {
-
- this.context = context;
- parentComponent = context.getParentResourceComponent();
+ private static final String IFMODULE_DIRECTIVE_NAME = "<IfModule";
+
+ public void start(ResourceContext<ApacheDirectoryComponent> context) throws InvalidPluginConfigurationException,
+ Exception {
+ this.context = context;
+ parentComponent = context.getParentResourceComponent();
}
public void stop() {
}
public AvailabilityType getAvailability() {
- return parentComponent.getAvailability();
+ return parentComponent.getAvailability();
}
- public Configuration loadResourceConfiguration() throws Exception {
+ public Configuration loadResourceConfiguration() throws Exception {
ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
-
- AugeasNode directoryNode = parentComponent.getNode();
- AugeasTree tree = parentComponent.getServerConfigurationTree();
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- return mapping.updateConfiguration(getNode(directoryNode), resourceConfigDef);
+ AugeasComponent comp = parentComponent.getAugeas();
+ AugeasTree tree = null;
+ try {
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ AugeasNode directoryNode = parentComponent.getNode(tree);
+
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ return mapping.updateConfiguration(getNode(directoryNode), resourceConfigDef);
+ } finally {
+ comp.close();
+ }
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ AugeasComponent comp = parentComponent.getAugeas();
AugeasTree tree = null;
try {
- tree = parentComponent.getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = context.getResourceType()
- .getResourceConfigurationDefinition();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- AugeasNode directoryNode = getNode(parentComponent.getNode());
+ AugeasNode directoryNode = getNode(parentComponent.getNode(tree));
mapping.updateAugeas(directoryNode, report.getConfiguration(), resourceConfigDef);
tree.save();
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
log.info("Apache configuration was updated");
-
+
context.getParentResourceComponent().finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null)
@@ -90,16 +98,17 @@ public class ApacheIfModuleDirectoryComponent implements ResourceComponent<Apach
else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ } finally {
+ comp.close();
}
- }
-
+ }
+
private AugeasNode getNode(AugeasNode virtualHost) {
AugeasNode directory = AugeasNodeSearch.findNodeById(virtualHost, context.getResourceKey());
return directory;
- }
-
- public boolean isAugeasEnabled(){
- return parentComponent.isAugeasEnabled();
}
-}
+ public boolean isAugeasEnabled() {
+ return parentComponent.isAugeasEnabled();
+ }
+}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java
index 3d17f71..d3bbe15 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java
@@ -26,6 +26,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.resource.ResourceType;
@@ -36,39 +37,44 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
public class ApacheIfModuleDirectoryDiscoveryComponent implements ResourceDiscoveryComponent<ApacheDirectoryComponent> {
-
- private static final String [] parentRes = {"<IfModule"};
+
+ private static final String[] parentRes = { "<IfModule" };
private static final String IFMODULE_NODE_NAME = "<IfModule";
private AugeasTree tree;
private AugeasNode parentNode;
-
- public Set<DiscoveredResourceDetails> discoverResources(
- ResourceDiscoveryContext<ApacheDirectoryComponent> context)
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ApacheDirectoryComponent> context)
throws InvalidPluginConfigurationException, Exception {
-
- ApacheDirectoryComponent directory = context.getParentResourceComponent();
- Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
-
- if (!directory.isAugeasEnabled())
- return discoveredResources;
-
- parentNode = directory.getNode();
-
- List<AugeasNode> ifModuleNodes = AugeasNodeSearch.searchNode(parentRes, IFMODULE_NODE_NAME, parentNode);
-
- ResourceType resourceType = context.getResourceType();
+ ApacheDirectoryComponent directory = context.getParentResourceComponent();
+ Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
+
+ if (!directory.isAugeasEnabled())
+ return discoveredResources;
+
+ AugeasComponent comp = directory.getAugeas();
+ AugeasTree tree = null;
+ try {
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+
+ parentNode = directory.getNode(tree);
+
+ List<AugeasNode> ifModuleNodes = AugeasNodeSearch.searchNode(parentRes, IFMODULE_NODE_NAME, parentNode);
+
+ ResourceType resourceType = context.getResourceType();
+
+ for (AugeasNode node : ifModuleNodes) {
- for (AugeasNode node : ifModuleNodes) {
-
-
- String resourceKey = AugeasNodeSearch.getNodeKey(node,parentNode);
- String [] paramArray = resourceKey.split("\\|");
- String resourceName = paramArray[1];
+ String resourceKey = AugeasNodeSearch.getNodeKey(node, parentNode);
+ String[] paramArray = resourceKey.split("\\|");
+ String resourceName = paramArray[1];
- discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null, null,
- null, null));
+ discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null,
+ null, null, null));
+ }
+ return discoveredResources;
+ } finally {
+ comp.close();
}
- return discoveredResources;
- }
+ }
}
\ No newline at end of file
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java
index 708c198..e7165fd 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java
@@ -26,6 +26,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.resource.ResourceType;
@@ -35,41 +36,47 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
-public class ApacheIfModuleDiscoveryComponent implements ResourceDiscoveryComponent<ApacheVirtualHostServiceComponent> {
+public class ApacheIfModuleDiscoveryComponent implements ResourceDiscoveryComponent<ApacheVirtualHostServiceComponent> {
- private static final String [] parentRes = {"<IfModule"};
+ private static final String[] parentRes = { "<IfModule" };
private static final String IFMODULE_NODE_NAME = "<IfModule";
private AugeasTree tree;
private AugeasNode parentNode;
-
+
public Set<DiscoveredResourceDetails> discoverResources(
ResourceDiscoveryContext<ApacheVirtualHostServiceComponent> context)
throws InvalidPluginConfigurationException, Exception {
-
- Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
- ApacheVirtualHostServiceComponent virtualHost = context.getParentResourceComponent();
-
- if (!virtualHost.isAugeasEnabled()){
- return discoveredResources;
- }
-
- tree = virtualHost.getServerConfigurationTree();
- parentNode = virtualHost.getNode(tree);
-
- List<AugeasNode> ifModuleNodes = AugeasNodeSearch.searchNode(parentRes, IFMODULE_NODE_NAME, parentNode);
-
-
- ResourceType resourceType = context.getResourceType();
- for (AugeasNode node : ifModuleNodes) {
-
- String resourceKey = AugeasNodeSearch.getNodeKey(node,parentNode);
- String [] paramArray = resourceKey.split("\\|");
- String resourceName = paramArray[1];
+ Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
+ ApacheVirtualHostServiceComponent virtualHost = context.getParentResourceComponent();
- discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null, null,
- null, null));
+ if (!virtualHost.isAugeasEnabled()) {
+ return discoveredResources;
}
- return discoveredResources;
- }
+ AugeasComponent comp = virtualHost.getAugeas();
+ AugeasTree tree = null;
+ try {
+
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+
+ parentNode = virtualHost.getNode(tree);
+
+ List<AugeasNode> ifModuleNodes = AugeasNodeSearch.searchNode(parentRes, IFMODULE_NODE_NAME, parentNode);
+
+ ResourceType resourceType = context.getResourceType();
+
+ for (AugeasNode node : ifModuleNodes) {
+
+ String resourceKey = AugeasNodeSearch.getNodeKey(node, parentNode);
+ String[] paramArray = resourceKey.split("\\|");
+ String resourceName = paramArray[1];
+
+ discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null,
+ null, null, null));
+ }
+ return discoveredResources;
+ } finally {
+ comp.close();
+ }
+ }
}
\ No newline at end of file
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
index 92d51da..d180fe6 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
@@ -39,10 +39,13 @@ import org.apache.commons.logging.LogFactory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.rhq.augeas.AugeasProxy;
+import org.rhq.augeas.AugeasComponent;
+import org.rhq.augeas.config.AugeasConfiguration;
import org.rhq.augeas.config.AugeasModuleConfig;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
+import org.rhq.augeas.tree.AugeasTreeBuilder;
+import org.rhq.augeas.tree.AugeasTreeException;
import org.rhq.augeas.util.Glob;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
@@ -66,6 +69,7 @@ import org.rhq.core.pluginapi.event.log.LogFileEventPoller;
import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.pluginapi.operation.OperationFacet;
@@ -99,8 +103,8 @@ import org.rhq.rhqtransform.AugeasRHQComponent;
* @author Ian Springer
* @author Lukas Krejci
*/
-public class ApacheServerComponent implements AugeasRHQComponent<PlatformComponent>, MeasurementFacet, OperationFacet,
- ConfigurationFacet, CreateChildResourceFacet {
+public class ApacheServerComponent implements AugeasRHQComponent, ResourceComponent<PlatformComponent>,
+ MeasurementFacet, OperationFacet, ConfigurationFacet, CreateChildResourceFacet {
public static final String CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE = "Configuration is supported only for Apache version 2 and up using Augeas. You either have an old version of Apache or Augeas is not installed.";
@@ -111,6 +115,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
public static final String PLUGIN_CONFIG_PROP_CONTROL_SCRIPT_PATH = "controlScriptPath";
public static final String PLUGIN_CONFIG_PROP_URL = "url";
public static final String PLUGIN_CONFIG_PROP_HTTPD_CONF = "configFile";
+ public static final String AUGEAS_HTTP_MODULE_NAME = "Httpd";
public static final String PLUGIN_CONFIG_PROP_SNMP_AGENT_HOST = "snmpAgentHost";
public static final String PLUGIN_CONFIG_PROP_SNMP_AGENT_PORT = "snmpAgentPort";
@@ -122,9 +127,9 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
public static final String PLUGIN_CONFIG_PROP_ERROR_LOG_INCLUDES_PATTERN = "errorLogIncludesPattern";
public static final String PLUGIN_CONFIG_PROP_VHOST_FILES_MASK = "vhostFilesMask";
public static final String PLUGIN_CONFIG_PROP_VHOST_CREATION_POLICY = "vhostCreationPolicy";
-
+
public static final String PLUGIN_CONFIG_PROP_RESTART_AFTER_CONFIG_UPDATE = "restartAfterConfigurationUpdate";
-
+
public static final String PLUGIN_CONFIG_VHOST_IN_SINGLE_FILE_PROP_VALUE = "single-file";
public static final String PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE = "vhost-per-file";
@@ -148,7 +153,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
private static final String[] CONTROL_SCRIPT_PATHS = { "bin/apachectl", "sbin/apachectl", "bin/apachectl2",
"sbin/apachectl2" };
-
+
private ResourceContext<PlatformComponent> resourceContext;
private EventContext eventContext;
private SNMPClient snmpClient;
@@ -174,14 +179,13 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
SNMPSession snmpSession = getSNMPSession();
if (!snmpSession.ping()) {
- log
- .warn("Failed to connect to SNMP agent at "
- + snmpSession
- + "\n"
- + ". Make sure\n1) the managed Apache server has been instrumented with the JON SNMP module,\n"
- + "2) the Apache server is running, and\n"
- + "3) the SNMP agent host, port, and community are set correctly in this resource's connection properties.\n"
- + "The agent will not be able to record metrics from apache httpd without SNMP");
+ log.warn("Failed to connect to SNMP agent at "
+ + snmpSession
+ + "\n"
+ + ". Make sure\n1) the managed Apache server has been instrumented with the JON SNMP module,\n"
+ + "2) the Apache server is running, and\n"
+ + "3) the SNMP agent host, port, and community are set correctly in this resource's connection properties.\n"
+ + "The agent will not be able to record metrics from apache httpd without SNMP");
} else {
configured = true;
}
@@ -192,11 +196,10 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
try {
this.url = new URL(url);
if (this.url.getPort() == 0) {
- log
- .error("The 'url' connection property is invalid - 0 is not a valid port; please change the value to the "
- + "port the \"main\" Apache server is listening on. NOTE: If the 'url' property was set this way "
- + "after autodiscovery, you most likely did not include the port in the ServerName directive for "
- + "the \"main\" Apache server in httpd.conf.");
+ log.error("The 'url' connection property is invalid - 0 is not a valid port; please change the value to the "
+ + "port the \"main\" Apache server is listening on. NOTE: If the 'url' property was set this way "
+ + "after autodiscovery, you most likely did not include the port in the ServerName directive for "
+ + "the \"main\" Apache server in httpd.conf.");
} else {
configured = true;
}
@@ -213,15 +216,15 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
File executablePath = getExecutablePath();
try {
- this.binaryInfo = ApacheBinaryInfo.getInfo(executablePath.getPath(), this.resourceContext
- .getSystemInformation());
+ this.binaryInfo = ApacheBinaryInfo.getInfo(executablePath.getPath(),
+ this.resourceContext.getSystemInformation());
} catch (Exception e) {
throw new InvalidPluginConfigurationException("'" + executablePath
+ "' is not a valid Apache executable (" + e + ").");
}
- this.operationsDelegate = new ApacheServerOperationsDelegate(this, pluginConfig, this.resourceContext
- .getSystemInformation());
+ this.operationsDelegate = new ApacheServerOperationsDelegate(this, pluginConfig,
+ this.resourceContext.getSystemInformation());
//init the module names with the defaults
moduleNames = new HashMap<String, String>(ApacheServerDiscoveryComponent.getDefaultModuleNames(binaryInfo.getVersion()));
@@ -336,31 +339,38 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
}
public Configuration loadResourceConfiguration() throws Exception {
+
if (!isAugeasEnabled())
throw new RuntimeException(CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
+ AugeasComponent comp = getAugeas();
try {
ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
.getResourceConfigurationDefinition();
- AugeasTree tree = getAugeasTree();
+ AugeasTree tree = comp.getAugeasTree(AUGEAS_HTTP_MODULE_NAME);
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
return mapping.updateConfiguration(tree.getRootNode(), resourceConfigDef);
} catch (Exception e) {
log.error("Failed to load Apache configuration.", e);
throw e;
+ } finally {
+ comp.close();
}
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
- if (!isAugeasEnabled()){
+ if (!isAugeasEnabled()) {
report.setStatus(ConfigurationUpdateStatus.FAILURE);
return;
}
+
+ AugeasComponent comp = getAugeas();
+
Configuration originalConfig = report.getConfiguration().deepCopy(true);
AugeasTree tree = null;
try {
- tree = getAugeasTree();
+ tree = comp.getAugeasTree(AUGEAS_HTTP_MODULE_NAME);
ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
.getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
@@ -370,182 +380,198 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
log.info("Apache configuration was updated");
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
-
+
finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null) {
log.error("Augeas failed to save configuration " + tree.summarizeAugeasError());
e = new AugeasException("Failed to save configuration: " + tree.summarizeAugeasError() + " ", e);
- }
- else
+ } else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
report.setErrorMessageFromThrowable(e);
if (!originalConfig.equals(report.getConfiguration())) {
log.error("Configuration has changed");
- }
- else {
+ } else {
log.error("Configuratio has not changed");
}
+ } finally {
+ comp.close();
}
- }
-
- public AugeasProxy getAugeasProxy() throws AugeasException {
- File tempDir = resourceContext.getDataDirectory();
- if (!tempDir.exists())
- throw new RuntimeException("Loading of lens failed");
- AugeasConfigurationApache config = new AugeasConfigurationApache(tempDir.getAbsolutePath(),resourceContext.getPluginConfiguration());
- AugeasTreeBuilderApache builder = new AugeasTreeBuilderApache();
- AugeasProxy augeasProxy = new AugeasProxy(config, builder);
- augeasProxy.load();
- return augeasProxy;
- }
-
- public AugeasTree getAugeasTree() throws AugeasException {
- AugeasProxy proxy = getAugeasProxy();
- String module = ((AugeasConfigurationApache)proxy.getConfiguration()).getAugeasModuleName();
-
- return proxy.getAugeasTree(module, true);
}
-
+
+ public AugeasComponent getAugeas() throws AugeasTreeException {
+ return new AugeasComponent() {
+
+ public AugeasConfiguration initConfiguration() {
+ File tempDir = resourceContext.getDataDirectory();
+ if (!tempDir.exists())
+ throw new RuntimeException("Loading of lens failed");
+ AugeasConfigurationApache config = new AugeasConfigurationApache(tempDir.getAbsolutePath(),
+ resourceContext.getPluginConfiguration());
+ return config;
+ }
+
+ public AugeasTreeBuilder initTreeBuilder() {
+ AugeasTreeBuilderApache builder = new AugeasTreeBuilderApache();
+ return builder;
+ }
+
+ };
+ }
+
public CreateResourceReport createResource(CreateResourceReport report) {
- if (!isAugeasEnabled()){
+ if (!isAugeasEnabled()) {
report.setStatus(CreateResourceStatus.FAILURE);
report.setErrorMessage("Resources can be created only when augeas is enabled.");
return report;
}
if (ApacheVirtualHostServiceComponent.RESOURCE_TYPE_NAME.equals(report.getResourceType().getName())) {
Configuration vhostResourceConfig = report.getResourceConfiguration();
- ConfigurationDefinition vhostResourceConfigDef = report.getResourceType().getResourceConfigurationDefinition();
+ ConfigurationDefinition vhostResourceConfigDef = report.getResourceType()
+ .getResourceConfigurationDefinition();
Configuration vhostPluginConfig = report.getPluginConfiguration();
-
+
String vhostDef = report.getUserSpecifiedResourceName();
- String serverName = vhostResourceConfig.getSimpleValue(ApacheVirtualHostServiceComponent.SERVER_NAME_CONFIG_PROP, null);
-
+ String serverName = vhostResourceConfig.getSimpleValue(
+ ApacheVirtualHostServiceComponent.SERVER_NAME_CONFIG_PROP, null);
+
//determine the resource key
String resourceKey = vhostDef;
if (serverName != null) {
resourceKey = serverName + "|" + resourceKey;
}
-
- //determine the resource name
- AugeasProxy proxy = getAugeasProxy();
- AugeasTree tree = getAugeasTree();
+
String[] vhostDefs = vhostDef.split(" ");
- HttpdAddressUtility.Address addr;
- try{
+ HttpdAddressUtility.Address addr;
+ try {
ApacheDirectiveTree parserTree = new ApacheDirectiveTree();
- ApacheParser parser = new ApacheParserImpl(parserTree,getServerRoot().getAbsolutePath());
-
+ ApacheParser parser = new ApacheParserImpl(parserTree, getServerRoot().getAbsolutePath());
+
ApacheConfigReader.buildTree(getHttpdConfFile().getAbsolutePath(), parser);
+
Pattern virtualHostPattern = Pattern.compile(".+:([\\d]+|\\*)");
Matcher matcher = virtualHostPattern.matcher(vhostDefs[0]);
if (!matcher.matches())
- throw new Exception("Wrong format of virtual host resource name. The right format is Address:Port.");
-
+ throw new Exception("Wrong format of virtual host resource name. The right format is Address:Port.");
+
addr = getAddressUtility().getVirtualHostSampleAddress(parserTree, vhostDefs[0], serverName, false);
} catch (Exception e) {
- report.setStatus(CreateResourceStatus.FAILURE);
- report.setErrorMessage("Wrong format of virtual host resource name.");
- report.setException(e);
- return report;
- }
-
+ report.setStatus(CreateResourceStatus.FAILURE);
+ report.setErrorMessage("Wrong format of virtual host resource name.");
+ report.setException(e);
+ return report;
+ }
+
String resourceName;
if (serverName != null) {
resourceName = addr.host + ":" + addr.port;
} else {
resourceName = resourceKey;
}
-
+
report.setResourceKey(resourceKey);
report.setResourceName(resourceName);
- //fill in the plugin config
- String url = "http://" + addr.host + ":" + addr.port + "/";
- vhostPluginConfig.put(new PropertySimple(ApacheVirtualHostServiceComponent.URL_CONFIG_PROP, url));
-
- //determine the sequence number of the new vhost
- List<AugeasNode> existingVhosts = tree.matchRelative(tree.getRootNode(), "<VirtualHost");
- int seq = existingVhosts.size() + 1;
-
- Configuration pluginConfig = resourceContext.getPluginConfiguration();
- String creationType = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_VHOST_CREATION_POLICY,
- PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE);
+ AugeasComponent comp = getAugeas();
+ //determine the resource name
- AugeasNode vhost = null;
- String vhostFile = proxy.getConfiguration().getModules().get(0).getConfigFiles().get(0);
-
- if (PLUGIN_CONFIG_VHOST_IN_SINGLE_FILE_PROP_VALUE.equals(creationType)) {
- vhost = tree.createNode(tree.getRootNode(), "<VirtualHost", null, seq);
- } else if (PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE.equals(creationType)) {
- String mask = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_VHOST_FILES_MASK, null);
- if (mask == null) {
- report.setErrorMessage("No virtual host file mask configured.");
- } else {
- vhostFile = getNewVhostFileName(addr, mask);
- File vhostFileFile = new File(vhostFile);
-
- //we're creating a new file here, so we must ensure that Augeas does have this file
- //on its load path, otherwise it will refuse to create it.
- AugeasConfigurationApache config = (AugeasConfigurationApache) proxy.getConfiguration();
- AugeasModuleConfig moduleConfig = config.getModuleByName(config.getAugeasModuleName());
- boolean willPersist = false;
- for(String glob : moduleConfig.getIncludedGlobs()) {
- if (Glob.matches(getServerRoot(), glob, vhostFileFile)) {
- willPersist = true;
- break;
+ AugeasTree tree;
+ try {
+
+ tree = comp.getAugeasTree(AUGEAS_HTTP_MODULE_NAME);
+ //fill in the plugin config
+ String url = "http://" + addr.host + ":" + addr.port + "/";
+ vhostPluginConfig.put(new PropertySimple(ApacheVirtualHostServiceComponent.URL_CONFIG_PROP, url));
+
+ //determine the sequence number of the new vhost
+ List<AugeasNode> existingVhosts = tree.matchRelative(tree.getRootNode(), "<VirtualHost");
+ int seq = existingVhosts.size() + 1;
+
+ Configuration pluginConfig = resourceContext.getPluginConfiguration();
+ String creationType = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_VHOST_CREATION_POLICY,
+ PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE);
+
+ AugeasNode vhost = null;
+
+ String vhostFile = comp.getConfiguration().getModules().get(0).getConfigFiles().get(0);
+
+ if (PLUGIN_CONFIG_VHOST_IN_SINGLE_FILE_PROP_VALUE.equals(creationType)) {
+ vhost = tree.createNode(tree.getRootNode(), "<VirtualHost", null, seq);
+ } else if (PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE.equals(creationType)) {
+ String mask = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_VHOST_FILES_MASK, null);
+ if (mask == null) {
+ report.setErrorMessage("No virtual host file mask configured.");
+ } else {
+ vhostFile = getNewVhostFileName(addr, mask);
+ File vhostFileFile = new File(vhostFile);
+
+ //we're creating a new file here, so we must ensure that Augeas does have this file
+ //on its load path, otherwise it will refuse to create it.
+ AugeasConfigurationApache config = (AugeasConfigurationApache) comp.getConfiguration();
+ AugeasModuleConfig moduleConfig = config.getModuleByName(config.getAugeasModuleName());
+ boolean willPersist = false;
+ for (String glob : moduleConfig.getIncludedGlobs()) {
+ if (Glob.matches(getServerRoot(), glob, vhostFileFile)) {
+ willPersist = true;
+ break;
+ }
}
- }
-
- if (!willPersist) {
- //the file wouldn't be loaded by augeas
- moduleConfig.addIncludedGlob(vhostFile);
- }
-
- try {
- vhostFileFile.createNewFile();
- } catch (IOException e) {
- log.error("Failed to create a new vhost file: " + vhostFile, e);
- }
-
- proxy.load();
- tree = proxy.getAugeasTree(moduleConfig.getModuletName(), true);
-
- vhost = tree.createNode(AugeasTree.AUGEAS_DATA_PATH + vhostFile + "/<VirtualHost");
- ((ApacheAugeasNode)vhost).setParentNode(tree.getRootNode());
-
- if (!willPersist) {
- //this also means that there was no include
- //that would load the file, so we have to
- //add the include directive to the main conf.
- List<AugeasNode> includes = tree.matchRelative(tree.getRootNode(), "Include");
- AugeasNode include = tree.createNode(tree.getRootNode(), "Include", null, includes.size() + 1);
- tree.createNode(include, "param", vhostFile, 0);
+
+ if (!willPersist) {
+ //the file wouldn't be loaded by augeas
+ moduleConfig.addIncludedGlob(vhostFile);
+ //this also means that there was no include
+ //that would load the file, so we have to
+ //add the include directive to the main conf.
+ List<AugeasNode> includes = tree.matchRelative(tree.getRootNode(), "Include");
+ AugeasNode include = tree.createNode(tree.getRootNode(), "Include", null,
+ includes.size() + 1);
+ tree.createNode(include, "param", vhostFile, 0);
+ tree.save();
+ }
+
+ try {
+ vhostFileFile.createNewFile();
+ } catch (IOException e) {
+ log.error("Failed to create a new vhost file: " + vhostFile, e);
+ }
+
+ comp.close();
+ comp = getAugeas();
+ tree = comp.getAugeasTree(moduleConfig.getModuletName());
+
+ vhost = tree.createNode(AugeasTree.AUGEAS_DATA_PATH + vhostFile + "/<VirtualHost");
+ ((ApacheAugeasNode) vhost).setParentNode(tree.getRootNode());
+
}
}
- }
-
- if (vhost == null) {
- report.setStatus(CreateResourceStatus.FAILURE);
- } else {
- try {
- for(int i = 0; i < vhostDefs.length; ++i) {
- tree.createNode(vhost, "param", vhostDefs[i], i + 1);
- }
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- mapping.updateAugeas(vhost, vhostResourceConfig, vhostResourceConfigDef);
-
- tree.save();
- report.setStatus(CreateResourceStatus.SUCCESS);
-
- finishChildResourceCreate(report);
- } catch (Exception e) {
+
+ if (vhost == null) {
report.setStatus(CreateResourceStatus.FAILURE);
- report.setException(e);
+ } else {
+ try {
+ for (int i = 0; i < vhostDefs.length; ++i) {
+ tree.createNode(vhost, "param", vhostDefs[i], i + 1);
+ }
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ mapping.updateAugeas(vhost, vhostResourceConfig, vhostResourceConfigDef);
+
+ tree.save();
+ report.setStatus(CreateResourceStatus.SUCCESS);
+
+ finishChildResourceCreate(report);
+ } catch (Exception e) {
+ report.setStatus(CreateResourceStatus.FAILURE);
+ report.setException(e);
+ }
}
+ } finally {
+ if (comp != null)
+ comp.close();
}
}
+
return report;
}
@@ -604,14 +630,14 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
if (executablePath != null) {
executableFile = resolvePathRelativeToServerRoot(executablePath);
} else {
- String serverRoot=null;
-
- ApacheDirectiveTree tree = loadParser();
- List<ApacheDirective> directives = tree.search("/ServerRoot");
- if (!directives.isEmpty())
- if (!directives.get(0).getValues().isEmpty())
- serverRoot = directives.get(0).getValues().get(0);
-
+ String serverRoot = null;
+
+ ApacheDirectiveTree tree = loadParser();
+ List<ApacheDirective> directives = tree.search("/ServerRoot");
+ if (!directives.isEmpty())
+ if (!directives.get(0).getValues().isEmpty())
+ serverRoot = directives.get(0).getValues().get(0);
+
SystemInfo systemInfo = this.resourceContext.getSystemInformation();
if (systemInfo.getOperatingSystemType() != OperatingSystemType.WINDOWS) // UNIX
{
@@ -635,10 +661,11 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
/**
* @return The url the server is pinged for availability or null if the url is not set.
*/
- public @Nullable String getServerUrl() {
+ public @Nullable
+ String getServerUrl() {
return resourceContext.getPluginConfiguration().getSimpleValue(PLUGIN_CONFIG_PROP_URL, null);
}
-
+
/**
* Returns the httpd.conf file
* @return A File object that represents the httpd.conf file or null in case of error
@@ -691,19 +718,20 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
}
}
}
-
+
//only try harder on the control script path on OSes with UNIX file system layout
- if (!found && resourceContext.getSystemInformation().getOperatingSystemType() != OperatingSystemType.WINDOWS) {
+ if (!found
+ && resourceContext.getSystemInformation().getOperatingSystemType() != OperatingSystemType.WINDOWS) {
String executablePath = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_EXECUTABLE_PATH, null);
if (executablePath != null) {
// this is now something like /usr/sbin/httpd .. trim off the last 2 parts
int i = executablePath.lastIndexOf(File.separatorChar);
-
+
if (i >= 0) {
executablePath = executablePath.substring(0, i);
i = executablePath.lastIndexOf(File.separatorChar);
}
-
+
if (i >= 0) {
executablePath = executablePath.substring(0, i);
for (String path : CONTROL_SCRIPT_PATHS) {
@@ -713,10 +741,10 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
break;
}
}
- }
+ }
}
}
-
+
if (!found) {
controlScriptFile = getExecutablePath(); // fall back to the httpd binary
}
@@ -727,11 +755,11 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
@NotNull
public ConfigurationTimestamp getConfigurationTimestamp() {
- AugeasConfigurationApache config = new AugeasConfigurationApache(resourceContext.getTemporaryDirectory().getAbsolutePath(),
- resourceContext.getPluginConfiguration());
+ AugeasConfigurationApache config = new AugeasConfigurationApache(resourceContext.getTemporaryDirectory()
+ .getAbsolutePath(), resourceContext.getPluginConfiguration());
return new ConfigurationTimestamp(config.getAllConfigurationFiles());
}
-
+
/**
* This method is supposed to be called from {@link #updateResourceConfiguration(ConfigurationUpdateReport)}
* of this resource and any child resources.
@@ -748,7 +776,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
report.setErrorMessageFromThrowable(e);
}
}
-
+
/**
* This method is akin to {@link #finishConfigurationUpdate(ConfigurationUpdateReport)} but should
* be used in the {@link #createResource(CreateResourceReport)} method.
@@ -763,7 +791,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
report.setException(e);
}
}
-
+
/**
* Conditionally restarts the server based on the settings in the plugin configuration of the server.
*
@@ -776,7 +804,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
operationsDelegate.invokeOperation("graceful_restart", new Configuration());
}
}
-
+
/**
* This method checks whether the supplied node that has been deleted from the tree didn't leave
* the file it was contained in empty.
@@ -787,7 +815,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
public void deleteEmptyFile(AugeasTree tree, AugeasNode deletedNode) {
File file = tree.getFile(deletedNode);
List<AugeasNode> fileContents = tree.match(file.getAbsolutePath() + AugeasTree.PATH_SEPARATOR + "*");
-
+
if (fileContents.size() == 0) {
file.delete();
}
@@ -909,13 +937,13 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
String version = getVersion();
return HttpdAddressUtility.get(version);
}
-
+
private String getNewVhostFileName(HttpdAddressUtility.Address address, String mask) {
String filename = address.host + "_" + address.port;
String fullPath = mask.replace("*", filename);
-
+
File file = getFileRelativeToServerRoot(fullPath);
-
+
int i = 1;
while (file.exists()) {
filename = address.host + "_" + address.port + "-" + (i++);
@@ -924,40 +952,48 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
}
return file.getAbsolutePath();
}
-
+
private File getFileRelativeToServerRoot(String path) {
File f = new File(path);
if (f.isAbsolute()) {
return f;
} else {
return new File(getServerRoot(), path);
- }
+ }
}
-
- public ApacheDirectiveTree loadParser(){
+
+ public ApacheDirectiveTree loadParser() {
ApacheDirectiveTree tree = new ApacheDirectiveTree();
- ApacheParser parser = new ApacheParserImpl(tree,getServerRoot().getAbsolutePath());
+ ApacheParser parser = new ApacheParserImpl(tree, getServerRoot().getAbsolutePath());
ApacheConfigReader.buildTree(getHttpdConfFile().getAbsolutePath(), parser);
- return tree;
+ return tree;
}
-
+
public boolean isAugeasEnabled() {
-
+
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
PropertySimple prop = pluginConfig.getSimple(AUGEAS_ENABLED);
- if (prop == null || prop.getStringValue() == null)
- {
+ if (prop == null || prop.getStringValue() == null) {
return false;
- }
-
+ }
+
String val = prop.getStringValue();
-
- if (val.equals("yes")){
- try {
- Augeas ag = new Augeas();
- }catch(Exception e){
- log.error("Augeas is enabled in configuration but was not found on the system.");
- throw new RuntimeException(CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
+
+ if (val.equals("yes")) {
+ Augeas ag = null;
+ try {
+ ag = new Augeas();
+ } catch (Exception e) {
+ log.error("Augeas is enabled in configuration but was not found on the system.", e);
+ throw new RuntimeException(CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
+ } finally {
+ if (ag != null) {
+ try {
+ ag.close();
+ } catch (Exception e) {
+ }
+ ag = null;
+ }
}
String version = getVersion();
@@ -966,8 +1002,8 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
throw new RuntimeException(CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
}
return true;
- }else{
- return false;
+ } else {
+ return false;
}
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
index 922f943..c83c665 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
@@ -29,6 +29,7 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
@@ -93,7 +94,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
private int snmpWwwServiceIndex = -1;
public static final String RESOURCE_TYPE_NAME = "Apache Virtual Host";
-
+
public void start(ResourceContext<ApacheServerComponent> resourceContext) throws Exception {
this.resourceContext = resourceContext;
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
@@ -113,7 +114,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
+ "') is not a valid URL.");
}
}
-
+
ResponseTimeConfiguration responseTimeConfig = new ResponseTimeConfiguration(pluginConfig);
File logFile = responseTimeConfig.getLogFile();
if (logFile != null) {
@@ -155,20 +156,26 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
public Configuration loadResourceConfiguration() throws Exception {
ApacheServerComponent parent = resourceContext.getParentResourceComponent();
if (!parent.isAugeasEnabled())
- throw new Exception(ApacheServerComponent.CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
-
- AugeasTree tree = getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
- .getResourceConfigurationDefinition();
+ throw new Exception(ApacheServerComponent.CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
+
+ AugeasComponent comp = getAugeas();
+ try {
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- return mapping.updateConfiguration(getNode(tree), resourceConfigDef);
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ return mapping.updateConfiguration(getNode(tree), resourceConfigDef);
+ } finally {
+ comp.close();
+ }
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ AugeasComponent comp = getAugeas();
AugeasTree tree = null;
try {
- tree = getServerConfigurationTree();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
.getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
@@ -178,7 +185,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
log.info("Apache configuration was updated");
-
+
finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null)
@@ -186,31 +193,37 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ } finally {
+ comp.close();
}
}
public void deleteResource() throws Exception {
ApacheServerComponent parent = resourceContext.getParentResourceComponent();
if (!parent.isAugeasEnabled())
- throw new Exception(ApacheServerComponent.CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
-
+ throw new Exception(ApacheServerComponent.CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
+
if (MAIN_SERVER_RESOURCE_KEY.equals(resourceContext.getResourceKey())) {
- throw new IllegalArgumentException("Cannot delete the virtual host representing the main server configuration.");
+ throw new IllegalArgumentException(
+ "Cannot delete the virtual host representing the main server configuration.");
}
-
- AugeasTree tree = getServerConfigurationTree();
-
+
+ AugeasComponent comp = getAugeas();
+
try {
- AugeasNode myNode = getNode(getServerConfigurationTree());
-
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ AugeasNode myNode = getNode(tree);
+
tree.removeNode(myNode, true);
tree.save();
-
+
deleteEmptyFile(tree, myNode);
conditionalRestart();
} catch (IllegalStateException e) {
//this means we couldn't find the augeas node for this vhost.
//that error can be safely ignored in this situation.
+ } finally {
+ comp.close();
}
}
@@ -261,82 +274,106 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
}
public CreateResourceReport createResource(CreateResourceReport report) {
- if (!isAugeasEnabled()){
+ if (!isAugeasEnabled()) {
report.setStatus(CreateResourceStatus.FAILURE);
report.setErrorMessage("Resources can be created only when augeas is enabled.");
return report;
}
ResourceType resourceType = report.getResourceType();
-
- if (resourceType.equals(getDirectoryResourceType())) {
- Configuration resourceConfiguration = report.getResourceConfiguration();
- Configuration pluginConfiguration = report.getPluginConfiguration();
-
- String directoryName = report.getUserSpecifiedResourceName();
-
- //fill in the plugin configuration
-
- //get the directive index
- AugeasTree tree = getServerConfigurationTree();
- AugeasNode myNode = getNode(tree);
- List<AugeasNode> directories = myNode.getChildByLabel("<Directory");
- int seq = 1;
- /*
- * myNode will be parent node of the new Directory node.
- * We need to create a new node for directory node which will contain child nodes.
- * To create a node we can call method from AugeasTree which will create a node. In this method is
- * parameter sequence, if we will leave this parameter empty and there will be more nodes with
- * the same label, new node will be created but the method createNode will return node with index 0 resp 1.
- * If that will happen we can not update the node anymore because we are updating wrong node.
- * To avoid this situation we need to know what is the last sequence nr. of virtual host's child (directory) nodes.
- * We can not just count child nodes with the same label because some of the child nodes
- * could be stored in another file. So that in httpd configurationstructure they are child nodes of virtual host,
- * but in augeas configuration structure they can be child nodes of node Include[];.
- */
-
- for (AugeasNode n : directories) {
- String param = n.getFullPath();
- int end = param.lastIndexOf(File.separatorChar);
- if (end != -1)
- if (myNode.getFullPath().equals(param.substring(0,end)))
- seq++;
+ AugeasComponent comp = null;
+ try {
+ comp = getAugeas();
+ if (resourceType.equals(getDirectoryResourceType())) {
+ Configuration resourceConfiguration = report.getResourceConfiguration();
+ Configuration pluginConfiguration = report.getPluginConfiguration();
+
+ String directoryName = report.getUserSpecifiedResourceName();
+
+ //fill in the plugin configuration
+
+ //get the directive index
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ AugeasNode myNode = getNode(tree);
+ List<AugeasNode> directories = myNode.getChildByLabel("<Directory");
+ int seq = 1;
+ /*
+ * myNode will be parent node of the new Directory node.
+ * We need to create a new node for directory node which will contain child nodes.
+ * To create a node we can call method from AugeasTree which will create a node. In this method is
+ * parameter sequence, if we will leave this parameter empty and there will be more nodes with
+ * the same label, new node will be created but the method createNode will return node with index 0 resp 1.
+ * If that will happen we can not update the node anymore because we are updating wrong node.
+ * To avoid this situation we need to know what is the last sequence nr. of virtual host's child (directory) nodes.
+ * We can not just count child nodes with the same label because some of the child nodes
+ * could be stored in another file. So that in httpd configurationstructure they are child nodes of virtual host,
+ * but in augeas configuration structure they can be child nodes of node Include[];.
+ */
+
+ for (AugeasNode n : directories) {
+ String param = n.getFullPath();
+ int end = param.lastIndexOf(File.separatorChar);
+ if (end != -1)
+ if (myNode.getFullPath().equals(param.substring(0, end)))
+ seq++;
}
-
- //pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.DIRECTIVE_INDEX_PROP, seq));
- //we don't support this yet... need to figure out how...
- pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.REGEXP_PROP, false));
- String dirNameToSet = AugeasNodeValueUtil.escape(directoryName);
-
- //now actually create the data in augeas
- try {
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- AugeasNode directoryNode = tree.createNode(myNode, "<Directory", null, seq);
- tree.createNode(directoryNode, "param", dirNameToSet, 0);
- mapping.updateAugeas(directoryNode, resourceConfiguration, resourceType.getResourceConfigurationDefinition());
- tree.save();
-
-
- tree = getServerConfigurationTree();
- String key = AugeasNodeSearch.getNodeKey(myNode, directoryNode);
- report.setResourceKey(key);
- report.setResourceName(directoryName);
-
- report.setStatus(CreateResourceStatus.SUCCESS);
-
- resourceContext.getParentResourceComponent().finishChildResourceCreate(report);
- } catch (Exception e) {
- report.setException(e);
+
+ //pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.DIRECTIVE_INDEX_PROP, seq));
+ //we don't support this yet... need to figure out how...
+ pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.REGEXP_PROP, false));
+ String dirNameToSet = AugeasNodeValueUtil.escape(directoryName);
+
+ //now actually create the data in augeas
+ try {
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ AugeasNode directoryNode = tree.createNode(myNode, "<Directory", null, seq);
+ String myNodeKey = AugeasNodeSearch.getNodeKey(myNode, tree.getRootNode());
+ tree.createNode(directoryNode, "param", dirNameToSet, 0);
+ mapping.updateAugeas(directoryNode, resourceConfiguration,
+ resourceType.getResourceConfigurationDefinition());
+
+ tree.save();
+ comp.close();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+
+ AugeasNode parentNode;
+ if (myNodeKey.equals("")) {
+ parentNode = tree.getRootNode();
+ } else
+ parentNode = AugeasNodeSearch.findNodeById(tree.getRootNode(), myNodeKey);
+
+ List<AugeasNode> nodes = parentNode.getChildByLabel("<Directory");
+ if (nodes.size() < seq) {
+ report.setStatus(CreateResourceStatus.FAILURE);
+ report.setErrorMessage("Could not create directory node.");
+ }
+
+ AugeasNode nd = nodes.get(seq - 1);
+ String key = AugeasNodeSearch.getNodeKey(nd, parentNode);
+
+ report.setResourceKey(key);
+ report.setResourceName(directoryName);
+
+ report.setStatus(CreateResourceStatus.SUCCESS);
+
+ resourceContext.getParentResourceComponent().finishChildResourceCreate(report);
+ } catch (Exception e) {
+ log.error("Could not create httpd virtual host child resource.", e);
+ report.setException(e);
+ report.setStatus(CreateResourceStatus.FAILURE);
+ }
+ } else {
+ report.setErrorMessage("Unable to create resources of type " + resourceType.getName());
report.setStatus(CreateResourceStatus.FAILURE);
}
- } else {
- report.setErrorMessage("Unable to create resources of type " + resourceType.getName());
- report.setStatus(CreateResourceStatus.FAILURE);
+ } finally {
+ if (comp != null)
+ comp.close();
}
return report;
}
-
- public AugeasTree getServerConfigurationTree() {
- return resourceContext.getParentResourceComponent().getAugeasTree();
+
+ public AugeasComponent getAugeas() {
+ return resourceContext.getParentResourceComponent().getAugeas();
}
/**
@@ -398,7 +435,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
public void finishConfigurationUpdate(ConfigurationUpdateReport report) {
resourceContext.getParentResourceComponent().finishConfigurationUpdate(report);
}
-
+
/**
* @see ApacheServerComponent#conditionalRestart()
*
@@ -407,11 +444,11 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
public void conditionalRestart() throws Exception {
resourceContext.getParentResourceComponent().conditionalRestart();
}
-
+
public void deleteEmptyFile(AugeasTree tree, AugeasNode deletedNode) {
resourceContext.getParentResourceComponent().deleteEmptyFile(tree, deletedNode);
}
-
+
private void collectSnmpMetric(MeasurementReport report, int primaryIndex, SNMPSession snmpSession,
MeasurementScheduleRequest schedule) throws SNMPException {
SNMPValue snmpValue = null;
@@ -565,13 +602,13 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
private ResourceType getDirectoryResourceType() {
return resourceContext.getResourceType().getChildResourceTypes().iterator().next();
}
-
- public ApacheDirectiveTree loadParser() throws Exception{
+
+ public ApacheDirectiveTree loadParser() throws Exception {
return resourceContext.getParentResourceComponent().loadParser();
}
-
- public boolean isAugeasEnabled(){
+
+ public boolean isAugeasEnabled() {
ApacheServerComponent parent = resourceContext.getParentResourceComponent();
- return parent.isAugeasEnabled();
+ return parent.isAugeasEnabled();
}
}
\ No newline at end of file
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasComponent.java
new file mode 100644
index 0000000..d41490f
--- /dev/null
+++ b/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasComponent.java
@@ -0,0 +1,52 @@
+package org.rhq.augeas;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.augeas.config.AugeasConfiguration;
+import org.rhq.augeas.tree.AugeasTree;
+import org.rhq.augeas.tree.AugeasTreeBuilder;
+
+public abstract class AugeasComponent {
+
+ AugeasProxy augeasProxy;
+ boolean isClosed = true;
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public abstract AugeasConfiguration initConfiguration();
+
+ public abstract AugeasTreeBuilder initTreeBuilder();
+
+ protected void reloadAugeas() {
+ if (!isClosed)
+ close();
+
+ augeasProxy = new AugeasProxy(initConfiguration(), initTreeBuilder());
+ augeasProxy.load();
+ isClosed = false;
+ }
+
+ public AugeasTree getAugeasTree(String moduleName) {
+ reloadAugeas();
+ return augeasProxy.getAugeasTree(moduleName, true);
+ }
+
+ public void close() {
+ isClosed = true;
+ if (augeasProxy != null) {
+ try {
+ augeasProxy.close();
+ } catch (Exception e) {
+ log.error("Could not close augeas instance", e);
+ }
+ }
+ }
+
+ public AugeasConfiguration getConfiguration() {
+ if (augeasProxy == null)
+ throw new RuntimeException("Could not provide augeas configuration because augeas was not initialized yet.");
+
+ return augeasProxy.getConfiguration();
+ }
+
+}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java b/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java
index 262bf95..12403a5 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java
@@ -23,7 +23,6 @@
package org.rhq.augeas;
import java.io.File;
-import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@@ -32,13 +31,13 @@ import net.augeas.AugeasException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.rhq.augeas.config.AugeasConfiguration;
import org.rhq.augeas.config.AugeasModuleConfig;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.augeas.tree.AugeasTreeBuilder;
import org.rhq.augeas.tree.AugeasTreeException;
import org.rhq.augeas.tree.impl.DefaultAugeasTreeBuilder;
-import org.rhq.plugins.augeas.AugeasPluginLifecycleListener;
/**
* This is the main entry point for interfacing with Augeas.
@@ -53,13 +52,13 @@ import org.rhq.plugins.augeas.AugeasPluginLifecycleListener;
*
*/
public class AugeasProxy {
-
- private final Log log = LogFactory.getLog(this.getClass());
+
+ private final Log log = LogFactory.getLog(this.getClass());
private AugeasConfiguration config;
private Augeas augeas;
private List<String> modules;
private AugeasTreeBuilder augeasTreeBuilder;
-
+
/**
* Instantiates new proxy with supplied configuration and
* {@link DefaultAugeasTreeBuilder} as the tree builder.
@@ -99,13 +98,20 @@ public class AugeasProxy {
public void load() throws AugeasTreeException {
try {
config.loadFiles();
+ if (augeas != null) {
+ try {
+ augeas.close();
+ } catch (Exception e) {
+ log.error("Could not close augeas instance", e);
+ }
+ }
augeas = new Augeas(config.getRootPath(), config.getLoadPath(), config.getMode());
-
+
for (AugeasModuleConfig module : config.getModules()) {
-
+
modules.add(module.getModuletName());
augeas.set("/augeas/load/" + module.getModuletName() + "/lens", module.getLensPath());
-
+
int idx = 1;
for (String incl : module.getConfigFiles()) {
augeas.set("/augeas/load/" + module.getModuletName() + "/incl[" + (idx++) + "]", incl);
@@ -118,8 +124,6 @@ public class AugeasProxy {
throw new AugeasException(e);
}
}
-
-
/**
* Produces the Augeas tree by loading it from augeas (if {@link #load()} wasn't called already)
@@ -178,4 +182,24 @@ public class AugeasProxy {
public Augeas getAugeas() {
return augeas;
}
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#finalize()
+ */
+ @Override
+ protected void finalize() throws Throwable {
+ close();
+ super.finalize();
+ }
+
+ public void close() {
+ if (augeas != null) {
+ try {
+ augeas.close();
+ } catch (Exception e) {
+ log.error("Could not close augeas instance", e);
+ }
+ augeas = null;
+ }
+ }
}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
index 9cd2e50..ec0dee8 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
@@ -141,41 +141,45 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
public Configuration loadResourceConfiguration() throws Exception {
abortIfAugeasNotAvailable();
- // Load the config file from disk and build a tree representation of it.
- loadConfigurationFiles(this.augeas);
+ //augeas was initialized in abortIfAugeasNotAvailable();
+ try {
+ ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
+ Configuration resourceConfig = new Configuration();
+ resourceConfig.setNotes("Loaded from Augeas at " + new Date());
- ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
- .getResourceConfigurationDefinition();
- Configuration resourceConfig = new Configuration();
- resourceConfig.setNotes("Loaded from Augeas at " + new Date());
+ Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
- Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
+ for (PropertyDefinition propDef : propDefs) {
+ loadProperty(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
+ }
- for (PropertyDefinition propDef : propDefs) {
- loadProperty(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
+ // This will add error messages to any PropertySimples with invalid values, so they can be displayed by the GUI.
+ validateResourceConfiguration(new ConfigurationUpdateReport(resourceConfig));
+ return resourceConfig;
+ } finally {
+ close();
}
-
- // This will add error messages to any PropertySimples with invalid values, so they can be displayed by the GUI.
- validateResourceConfiguration(new ConfigurationUpdateReport(resourceConfig));
- return resourceConfig;
}
protected void updateStructuredConfiguration(Configuration config) throws Exception {
abortIfAugeasNotAvailable();
- // Load the config files from disk and build a tree representation of them in memory.
- loadConfigurationFiles(this.augeas);
+ //augeas was initialized in abortIfAugeasNotAvailable
+ try {
+ ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
- ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
- .getResourceConfigurationDefinition();
+ Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
+ for (PropertyDefinition propDef : propDefs) {
+ setNode(propDef, config, this.augeas, this.resourceConfigRootNode);
+ }
- Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
- for (PropertyDefinition propDef : propDefs) {
- setNode(propDef, config, this.augeas, this.resourceConfigRootNode);
+ // Write the updated tree out to the config file.
+ saveConfigurationFiles();
+ } finally {
+ close();
}
-
- // Write the updated tree out to the config file.
- saveConfigurationFiles();
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
@@ -190,26 +194,29 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
log.debug("Validation of updated Resource configuration for " + this.resourceDescription
+ " failed with the following errors: " + report.getErrorMessage());
report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ close();
return;
}
- // Load the config files from disk and build a tree representation of them in memory.
- loadConfigurationFiles(this.augeas);
-
- ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
- .getResourceConfigurationDefinition();
- Configuration resourceConfig = report.getConfiguration();
+ //augeas was initialized in abortIfAugeasNotAvailable();
+ try {
+ ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
+ Configuration resourceConfig = report.getConfiguration();
- Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
- for (PropertyDefinition propDef : propDefs) {
- setNode(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
- }
+ Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
+ for (PropertyDefinition propDef : propDefs) {
+ setNode(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
+ }
- // Write the updated tree out to the config file.
- saveConfigurationFiles();
+ // Write the updated tree out to the config file.
+ saveConfigurationFiles();
- // If we got this far, we've succeeded in our mission.
- report.setStatus(ConfigurationUpdateStatus.SUCCESS);
+ // If we got this far, we've succeeded in our mission.
+ report.setStatus(ConfigurationUpdateStatus.SUCCESS);
+ } finally {
+ close();
+ }
}
public CreateResourceReport createResource(CreateResourceReport report) {
@@ -217,37 +224,47 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
ConfigurationDefinition resourceConfigDef = report.getResourceType().getResourceConfigurationDefinition();
// First insert the root node corresponding to the new child Resource.
- String rootPath = getChildResourceConfigurationRootPath(report.getResourceType(), report
- .getResourceConfiguration());
- AugeasNode rootNode = new AugeasNode(rootPath);
- if (this.augeas.exists(rootNode.getPath())) {
- report.setStatus(CreateResourceStatus.FAILURE);
- report.setErrorMessage("An Augeas node already exists with path " + rootPath);
- return report;
- }
- String rootLabel = getChildResourceConfigurationRootLabel(report.getResourceType(), report
- .getResourceConfiguration());
- this.augeas.set(rootNode.getPath(), rootLabel);
-
- // Then set all its child nodes.
- Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
- for (PropertyDefinition propDef : propDefs) {
- setNode(propDef, resourceConfig, this.augeas, rootNode);
- }
+ String rootPath = getChildResourceConfigurationRootPath(report.getResourceType(),
+ report.getResourceConfiguration());
+ initAugeas();
+ try {
+ AugeasNode rootNode = new AugeasNode(rootPath);
+ if (this.augeas.exists(rootNode.getPath())) {
+ report.setStatus(CreateResourceStatus.FAILURE);
+ report.setErrorMessage("An Augeas node already exists with path " + rootPath);
+ return report;
+ }
+ String rootLabel = getChildResourceConfigurationRootLabel(report.getResourceType(),
+ report.getResourceConfiguration());
+ this.augeas.set(rootNode.getPath(), rootLabel);
+
+ // Then set all its child nodes.
+ Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
+ for (PropertyDefinition propDef : propDefs) {
+ setNode(propDef, resourceConfig, this.augeas, rootNode);
+ }
- // Write the updated tree out to the config file.
- saveConfigurationFiles();
+ // Write the updated tree out to the config file.
+ saveConfigurationFiles();
- // If we got this far, we've succeeded in our mission.
- report.setStatus(CreateResourceStatus.SUCCESS);
- return report;
+ // If we got this far, we've succeeded in our mission.
+ report.setStatus(CreateResourceStatus.SUCCESS);
+ return report;
+ } finally {
+ close();
+ }
}
public void deleteResource() throws Exception {
String rootPath = getResourceConfigurationRootPath();
- Augeas augeas = getAugeas();
- augeas.remove(rootPath);
- augeas.save();
+ initAugeas();
+ try {
+ Augeas augeas = getAugeas();
+ augeas.remove(rootPath);
+ augeas.save();
+ } finally {
+ close();
+ }
}
/**
@@ -328,7 +345,14 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
return files;
}
+ /**
+ * Returns initialized augeas instance. Augeas instance must be closed by calling method close on the Augeas instance
+ * or by calling method close on AugeasConfigurationComponent instance after use of augeas.
+ * @return
+ */
public Augeas getAugeas() {
+ if (this.augeas == null)
+ initAugeas();
return this.augeas;
}
@@ -354,7 +378,6 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
try {
augeas = new Augeas(this.augeasRootPath, augeasLoadPath, Augeas.NO_MODL_AUTOLOAD);
setupAugeasModules(augeas);
- loadConfigurationFiles(augeas);
checkModuleErrors(augeas);
} catch (RuntimeException e) {
augeas = null;
@@ -631,14 +654,6 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
return mapKeyNames.getSimpleValue(listName, null);
}
- private void loadConfigurationFiles(Augeas augeas) {
- try {
- augeas.load();
- } catch (AugeasException e) {
- throw new RuntimeException(summarizeAugeasError(augeas), e);
- }
- }
-
private void saveConfigurationFiles() {
// TODO: Backup original file.
try {
@@ -688,8 +703,8 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
List<String> nodePaths = augeas.match(errorNode.getPath() + "/*");
for (String path : nodePaths) {
String error = augeas.get(path);
- summary.append("File \"").append(path.substring(metadataNodePrefix.length(), path.length())).append(
- "\":\n").append(error).append("\n");
+ summary.append("File \"").append(path.substring(metadataNodePrefix.length(), path.length()))
+ .append("\":\n").append(error).append("\n");
}
}
@@ -697,7 +712,16 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
}
protected void initAugeas() {
+ if (this.augeas != null) {
+ try {
+ this.augeas.close();
+ } catch (Exception e) {
+ }
+ this.augeas = null;
+ }
this.augeas = createAugeas();
+ this.augeas.load();
+ checkModuleErrors(this.augeas);
String resourceConfigRootPath = getResourceConfigurationRootPath();
if (resourceConfigRootPath.indexOf(AugeasNode.SEPARATOR_CHAR) != 0) {
// root path is relative - make it absolute
@@ -707,6 +731,7 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
this.resourceConfigRootNode = new AugeasNode(resourceConfigRootPath);
}
log.debug("Resource Config Root Node = \"" + this.resourceConfigRootNode + "\"");
+
}
private void abortIfAugeasNotAvailable() throws Exception {
@@ -747,4 +772,23 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
throw new IllegalStateException("Augeas modules didn't load cleanly.\n" + errorMessage);
}
}
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#finalize()
+ */
+ @Override
+ protected void finalize() throws Throwable {
+ close();
+ super.finalize();
+ }
+
+ public void close() {
+ if (this.augeas != null) {
+ try {
+ this.augeas.close();
+ } catch (Exception e) {
+ }
+ this.augeas = null;
+ }
+ }
}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java
index 7660de2..05e7bc4 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java
@@ -23,11 +23,8 @@
package org.rhq.rhqtransform;
-import org.rhq.augeas.AugeasProxy;
-import org.rhq.augeas.tree.AugeasTree;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.tree.AugeasTreeException;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-
/**
* An interface the RHQ resource components can implement to provide access
@@ -36,20 +33,7 @@ import org.rhq.core.pluginapi.inventory.ResourceComponent;
* @author Filip Drabek
*
*/
-public interface AugeasRHQComponent<T extends ResourceComponent> extends ResourceComponent<T> {
-
- /**
- * @return the augeas tree for the component
- * @throws AugeasTreeException
- */
- public AugeasTree getAugeasTree() throws AugeasTreeException;
+public interface AugeasRHQComponent {
- /**
- * Provides access to the Augeas proxy configured in the way this component needs
- * so that users are able to perform non-trivial operations on it.
- *
- * @return
- * @throws AugeasTreeException
- */
- public AugeasProxy getAugeasProxy() throws AugeasTreeException;
+ public AugeasComponent getAugeas() throws AugeasTreeException;
}
diff --git a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
index a7cdba4..6c8a60b 100644
--- a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
+++ b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
@@ -25,6 +25,7 @@ import java.util.List;
import net.augeas.Augeas;
import net.augeas.AugeasException;
+import org.rhq.augeas.util.GlobFilter;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.Property;
@@ -41,7 +42,6 @@ import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.plugins.augeas.AugeasConfigurationComponent;
import org.rhq.plugins.augeas.AugeasConfigurationDiscoveryComponent;
import org.rhq.plugins.augeas.helper.AugeasNode;
-import org.rhq.augeas.util.GlobFilter;
import org.rhq.plugins.platform.PlatformComponent;
/**
@@ -53,7 +53,7 @@ import org.rhq.plugins.platform.PlatformComponent;
public class CronComponent extends AugeasConfigurationComponent<PlatformComponent> implements CreateChildResourceFacet {
private static final String HOURLY_JOBS_PROP = "hourlyJobs";
- private static final String HOURLY_JOBS_NODE = "entry[time/minute != \"*\" and time/hour = \"*\" and time/dayofmonth = \"*\" and time/month = \"*\" and time/dayofweek = \"*\"]";
+ private static final String HOURLY_JOBS_NODE = "entry[time/minute != \"*\" and time/hour = \"*\" and time/dayofmonth = \"*\" and time/month = \"*\" and time/dayofweek = \"*\"]";
private static final String DAILY_JOBS_PROP = "dailyJobs";
private static final String DAILY_JOBS_NODE = "entry[time/minute != \"*\" and time/hour != \"*\" and time/dayofmonth = \"*\" and time/month = \"*\" and time/dayofweek = \"*\"]";
private static final String WEEKLY_JOBS_PROP = "weeklyJobs";
@@ -67,7 +67,7 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
private static final String AUGEAS_FILES_PREFIX = "/files";
private static final int AUGEAS_FILES_PREFIX_LENGTH = AUGEAS_FILES_PREFIX.length();
private static final String CRONTAB_RESOURCE_TYPE_NAME = "Cron Tab";
-
+
@Override
protected String getResourceConfigurationRootPath() {
return "/files/"; //the trailing slash is intentional so that we can get the
@@ -77,7 +77,8 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
public CreateResourceReport createResource(CreateResourceReport report) {
if (CRONTAB_RESOURCE_TYPE_NAME.equals(report.getResourceType().getName())) {
try {
- String resourceKey = createCrontab(report.getUserSpecifiedResourceName(), report.getResourceType().getResourceConfigurationDefinition(), report.getResourceConfiguration());
+ String resourceKey = createCrontab(report.getUserSpecifiedResourceName(), report.getResourceType()
+ .getResourceConfigurationDefinition(), report.getResourceConfiguration());
report.setResourceName(resourceKey);
report.setResourceKey(resourceKey);
report.setStatus(CreateResourceStatus.SUCCESS);
@@ -130,7 +131,7 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
private String getEntryCrontabPath(AugeasNode crontabNode) {
//the node's path is /files/blah/blah/entry/..
//we want the /blah/blah part
- return crontabNode.getParent().getParent().getPath().substring(AUGEAS_FILES_PREFIX_LENGTH);
+ return crontabNode.getParent().getParent().getPath().substring(AUGEAS_FILES_PREFIX_LENGTH);
}
/**
@@ -139,65 +140,71 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
* @param resourceConfiguration
* @return the resource key of the crontab
*/
- private String createCrontab(String resourceName, ConfigurationDefinition configurationDefinition, Configuration resourceConfiguration) {
+ private String createCrontab(String resourceName, ConfigurationDefinition configurationDefinition,
+ Configuration resourceConfiguration) {
File crontabFile = new File(resourceName);
-
+
try {
if (!crontabFile.createNewFile()) {
- throw new RuntimeException("File " + resourceName + " already exists. Creating the crontab would overwrite it.");
+ throw new RuntimeException("File " + resourceName
+ + " already exists. Creating the crontab would overwrite it.");
}
} catch (IOException e) {
throw new RuntimeException("Failed to create the crontab file named: " + resourceName);
}
-
+
//check that the crontab's name passes the glob filters
Configuration pluginConfiguration = getResourceContext().getPluginConfiguration();
-
- List<String> includeGlobs = AugeasConfigurationDiscoveryComponent.getGlobList(pluginConfiguration.getSimple(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP));
- List<String> excludeGlobs = AugeasConfigurationDiscoveryComponent.getGlobList(pluginConfiguration.getSimple(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP));
+
+ List<String> includeGlobs = AugeasConfigurationDiscoveryComponent.getGlobList(pluginConfiguration
+ .getSimple(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP));
+ List<String> excludeGlobs = AugeasConfigurationDiscoveryComponent.getGlobList(pluginConfiguration
+ .getSimple(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP));
boolean isIncluded = false;
-
- for(String include : includeGlobs) {
+
+ for (String include : includeGlobs) {
if (new GlobFilter(include).accept(crontabFile)) {
isIncluded = true;
break;
}
}
-
- String errorText = "Given Cron tab file name would be created outside of mapped filters. See the Cron resource connection properties for the inclusion and exclusion filters set up.";
+
+ String errorText = "Given Cron tab file name would be created outside of mapped filters. See the Cron resource connection properties for the inclusion and exclusion filters set up.";
if (!isIncluded) {
throw new IllegalArgumentException(errorText);
}
-
- for(String exclude : excludeGlobs) {
+
+ for (String exclude : excludeGlobs) {
if (new GlobFilter(exclude).accept(crontabFile)) {
throw new IllegalArgumentException(errorText);
}
}
-
+
updateCrontab(resourceName, configurationDefinition, resourceConfiguration);
-
+
return resourceName;
}
-
- protected void updateCrontab(String crontabPath, ConfigurationDefinition crontabConfigurationDefinition, Configuration crontabConfiguration) {
- Augeas augeas = getAugeas();
+
+ protected void updateCrontab(String crontabPath, ConfigurationDefinition crontabConfigurationDefinition,
+ Configuration crontabConfiguration) {
+ Augeas augeas = null;
try {
- augeas.load();
-
+ augeas = getAugeas();
+
File crontabFile = new File(crontabPath);
String basePath = AUGEAS_FILES_PREFIX + crontabFile.getAbsolutePath();
AugeasNode baseNode = new AugeasNode(basePath);
-
+
PropertyList entries = crontabConfiguration.getList(CronTabComponent.ENTRIES_PROP);
- PropertyDefinitionList entriesDef = crontabConfigurationDefinition.getPropertyDefinitionList(CronTabComponent.ENTRIES_PROP);
+ PropertyDefinitionList entriesDef = crontabConfigurationDefinition
+ .getPropertyDefinitionList(CronTabComponent.ENTRIES_PROP);
setNodeFromPropertyList(entriesDef, entries, augeas, baseNode);
-
+
PropertyList settings = crontabConfiguration.getList(CronTabComponent.ENVIRONMENT_SETTINGS_PROP);
if (settings != null) {
- for(Property p : settings.getList()) {
- PropertyMap setting = (PropertyMap)p;
+ for (Property p : settings.getList()) {
+ PropertyMap setting = (PropertyMap) p;
String name = setting.getSimpleValue(CronTabComponent.NAME_PROP, null);
String value = setting.getSimpleValue(CronTabComponent.VALUE_PROP, "");
if (name != null) {
@@ -206,10 +213,15 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
}
}
}
-
+
augeas.save();
} catch (AugeasException e) {
- throw new RuntimeException(summarizeAugeasError(augeas), e);
+ if (augeas != null)
+ throw new RuntimeException(summarizeAugeasError(augeas), e);
+ else
+ throw new RuntimeException(e);
+ } finally {
+ close();
}
- }
+ }
}
diff --git a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
index dd29e6e..3f59718 100644
--- a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
+++ b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
@@ -78,7 +78,7 @@ public class HostsComponent extends AugeasConfigurationComponent {
@Override
public Configuration loadResourceConfiguration() throws Exception {
Configuration resourceConfig;
- if (getAugeas() != null) {
+ if (isAugeasAvailable()) {
resourceConfig = super.loadResourceConfiguration();
} else {
resourceConfig = new NonAugeasHostsConfigurationDelegate(this).loadResourceConfiguration();
@@ -90,7 +90,7 @@ public class HostsComponent extends AugeasConfigurationComponent {
@Override
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
- if (getAugeas() != null) {
+ if (isAugeasAvailable()) {
super.updateResourceConfiguration(report);
} else {
if (!validateResourceConfiguration(report)) {
diff --git a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java
index c123e86..7524a93 100644
--- a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java
+++ b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java
@@ -18,19 +18,18 @@ GNU General Public License for more details.
*/
package org.rhq.plugins.samba;
+import java.util.List;
+
import net.augeas.Augeas;
+
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.resource.CreateResourceHistory;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.plugins.augeas.AugeasConfigurationComponent;
import org.rhq.plugins.augeas.helper.AugeasNode;
-import java.util.List;
-
/**
* TODO
*/
@@ -52,7 +51,7 @@ public class SambaShareComponent extends AugeasConfigurationComponent<SambaServe
String targetPath = "/files/etc/samba/smb.conf/target[.='" + targetName + "']";
AugeasNode targetNode = new AugeasNode(targetPath);
Augeas augeas = getAugeas();
- augeas.load();
+
List<String> matches = augeas.match(targetNode.getPath());
return matches.get(0);
}
@@ -62,7 +61,7 @@ public class SambaShareComponent extends AugeasConfigurationComponent<SambaServe
}
public AvailabilityType getAvailability() {
- return super.getAvailability();
+ return super.getAvailability();
}
public Configuration loadResourceConfiguration() throws Exception {
@@ -78,7 +77,15 @@ public class SambaShareComponent extends AugeasConfigurationComponent<SambaServe
}
public void deleteResource() throws Exception {
- super.deleteResource();
+ initAugeas();
+ String rootPath = getResourceConfigurationRootPath();
+ try {
+ Augeas augeas = getAugeas();
+ augeas.remove(rootPath);
+ augeas.save();
+ } finally {
+ close();
+ }
}
}
diff --git a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java
index 67da318..34809b7 100644
--- a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java
+++ b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java
@@ -18,52 +18,47 @@
*/
package org.rhq.plugins.samba;
-import java.util.Set;
-import java.util.List;
import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import net.augeas.Augeas;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
public class SambaShareDiscoveryComponent implements ResourceDiscoveryComponent<SambaServerComponent> {
-
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<SambaServerComponent> discoveryContext)
- throws InvalidPluginConfigurationException, Exception {
+ public Set<DiscoveredResourceDetails> discoverResources(
+ ResourceDiscoveryContext<SambaServerComponent> discoveryContext) throws InvalidPluginConfigurationException,
+ Exception {
Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>();
SambaServerComponent serverComponent = discoveryContext.getParentResourceComponent();
- Augeas augeas = serverComponent.getAugeas();
- if (augeas==null) {
- return details; // No augeas no results
- }
- augeas.load();
+ Augeas augeas = null;
+ try {
+ augeas = serverComponent.getAugeas();
- List<String> matches = augeas.match("/files/etc/samba/smb.conf/target[. != 'global']");
- for (String match : matches) {
- String name = augeas.get(match);
- Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration();
- pluginConfig.put(new PropertySimple("targetName", name));
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- discoveryContext.getResourceType(),
- name,
- name + " share",
- null,
- "Samba Share [" + name + "]",
- pluginConfig,
- null
- );
- details.add(detail);
- }
+ List<String> matches = augeas.match("/files/etc/samba/smb.conf/target[. != 'global']");
+ for (String match : matches) {
+ String name = augeas.get(match);
+ Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration();
+ pluginConfig.put(new PropertySimple("targetName", name));
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(discoveryContext.getResourceType(),
+ name, name + " share", null, "Samba Share [" + name + "]", pluginConfig, null);
+ details.add(detail);
+ }
- return details;
+ return details;
+ } finally {
+ if (serverComponent != null)
+ serverComponent.close();
+ }
}
}
commit 601a57e20e12f6b2dd4e3c8816ab5c92225a4d2e
Merge: 36992e5 f416f35
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Aug 2 15:53:41 2011 -0500
Merge branch 'mod_cluster_plugin'
commit f416f3555271ae10f481662f5fef8448936258f2
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Aug 2 14:33:43 2011 -0500
Better descriptions for mod_cluster operations.
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 29b334f..4846490 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -26,9 +26,10 @@
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true" default="Catalina:type=ModClusterListener,*"/>
<c:simple-property name="engineObjectName" readOnly="true" default="jboss.web:type=Engine"/>
+ <c:simple-property name="nameTemplate" default="mod_cluster"/>
</plugin-configuration>
- <operation name="stop" displayName="Stop all webapps" description="Gracefully stops all webapps for all engines.">
+ <operation name="stop" displayName="Stop all webapps" description="Gracefully stops all webapps for all virtual hosts of this application server.">
<parameters>
<c:simple-property required="true" name="timeout" type="string" displayName="Session draining timeout"/>
<c:simple-property required="true" name="unit" default="MILLISECONDS" displayName="Time unit of the timeout parameter">
@@ -52,13 +53,13 @@
<c:simple-property required="true" name="port" type="string" displayName="Proxy port"/>
</parameters>
</operation>
- <operation name="enable" displayName="Enable all webapps" description="Enable all webapps for all engines">
+ <operation name="enable" displayName="Enable all webapps" description="Enable all webapps for all virtual hosts of this application server.">
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
</operation>
- <operation name="reset" displayName="Reset the node" description="Move the node out of an error state." />
- <operation name="disable" displayName="Disable all webpapps" description="Disable all webapps for all engines.">
+ <operation name="reset" displayName="Reset the node" description="Move this application server out of an error state." />
+ <operation name="disable" displayName="Disable all webpapps" description="Disable all webapps for all virtual hosts of this application server.">
<results>
<c:simple-property name="result" type="boolean" description="The result of the operation" />
</results>
@@ -69,7 +70,7 @@
<c:simple-property required="true" name="port" type="string" displayName="Proxy port"/>
</parameters>
</operation>
- <operation name="refresh" displayName="Refresh configuration" description="Refresh configuration" />
+ <operation name="refresh" displayName="Refresh configuration" description="Refresh configuration for this application server." />
<metric property="proxyConfiguration" displayName="Proxy Configuration" displayType="summary" dataType="trait" />
<metric property="modelerType" displayName="Type of the modeled resource" displayType="summary" dataType="trait" />
@@ -77,9 +78,9 @@
<metric property="advertise" displayName="Enable autodiscovery of httpd servers." displayType="summary" dataType="trait" />
<resource-configuration>
- <c:simple-property name="workerTimeout" type="integer" description="Timeout to wait for an available worker (default is no wait)" />
+ <c:simple-property name="workerTimeout" type="integer" description="Timeout to wait for an available worker (default is no wait)." />
<c:simple-property name="stickySession" type="boolean" description="Enables sticky session for the cluster."/>
- <c:simple-property name="stickySessionRemove" type="boolean" description="Remove session when the request cannot be routed to the right node."/>
+ <c:simple-property name="stickySessionRemove" type="boolean" description="Remove session when the request cannot be routed to the right node for this cluster."/>
<c:simple-property name="smax" type="integer" description="Maximum time on seconds for idle connections above smax."/>
<c:simple-property name="maxAttempts" type="integer" description="Maximum number of attempts to send the request to the backend server."/>
<c:simple-property name="advertiseSecurityKey" type="string" required="false" description="Security key for discovery."/>
commit 36992e5f56228c1582cbc757f763027c1eeebc53
Merge: 3d58037 0f7fc0f
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Aug 2 16:22:16 2011 -0400
Merge branch 'drift'
commit 0f7fc0f283c9c382f45881c84fe99caa16246439
Merge: 7e6fa99 24c7ecb
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Aug 2 14:58:52 2011 -0400
Merge branch 'master' into drift
Conflicts:
modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java
modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
commit 7e6fa990fa40f4585a286cf251b0f36643ac0a83
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Aug 2 14:06:12 2011 -0400
Updating query method to work with retrieving change sets
The mongodb plugin does not yet fully support criteria queries. As
different queries are implemented, I am attempting to update the plugin
to support those queries until the plugin better/fully implements the
criteria apis.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java
index 8453713..afb6345 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java
@@ -33,9 +33,9 @@ import com.smartgwt.client.widgets.tree.TreeNode;
import org.rhq.core.domain.criteria.BaseCriteria;
import org.rhq.core.domain.criteria.BasicDriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.BasicDriftCriteria;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
-import org.rhq.core.domain.criteria.DriftJPACriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.util.PageList;
@@ -111,7 +111,7 @@ public abstract class AbstractDriftChangeSetsTreeDataSource extends RPCDataSourc
});
} else {
String changesetId = parentId;
- DriftCriteria criteria = new DriftJPACriteria();
+ DriftCriteria criteria = new BasicDriftCriteria();
criteria.addFilterChangeSetId(changesetId);
driftService.findDriftsByCriteria(criteria, new AsyncCallback<PageList<Drift>>() {
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
index 17b9f16..d1115ba 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
@@ -145,12 +145,21 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
@Override
public PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria) {
- String[] idFields = criteria.getFilterId().split(":");
- ObjectId changeSetId = new ObjectId(idFields[0]);
- String path = idFields[1];
- Query<MongoDBChangeSet> query = ds.createQuery(MongoDBChangeSet.class)
- .filter("id = ", changeSetId)
- .filter("files.path = ", path);
+ Query<MongoDBChangeSet> query = ds.createQuery(MongoDBChangeSet.class);
+ boolean changeSetIdFiltered = false;
+
+ if (criteria.getFilterId() != null) {
+ String[] idFields = criteria.getFilterId().split(":");
+ ObjectId changeSetId = new ObjectId(idFields[0]);
+ String path = idFields[1];
+
+ query.filter("files.path = ", path);
+ query.filter("id = ", changeSetId);
+ }
+
+ if (!changeSetIdFiltered && criteria.getFilterChangeSetId() != null) {
+ query.filter("id = ", new ObjectId(criteria.getFilterChangeSetId()));
+ }
PageList results = new PageList<DriftDTO>();
commit 6b66f0483fb57be021a02de0ed25729e88ba87f7
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Aug 2 09:48:46 2011 -0400
Add support for specifying optional change set criteria filters
diff --git a/etc/cli-scripts/drift.js b/etc/cli-scripts/drift.js
index ee54191..cddd7de 100644
--- a/etc/cli-scripts/drift.js
+++ b/etc/cli-scripts/drift.js
@@ -12,6 +12,13 @@ function createSnapshot(rid, cname) {
criteria.addFilterResourceId(rid);
criteria.addFilterDriftConfigurationId(config.id);
+ if (arguments.length > 2) {
+ var filters = arguments[2];
+ for (key in filters) {
+ criteria['addFilter' + key[0].toUpperCase() + key.substring(1)](filters[key]);
+ }
+ }
+
return DriftServer.createSnapshot(criteria);
}
commit a3fe993d72bcb308b6d9bf25fbfc420b9d63a4a6
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Aug 1 22:43:51 2011 -0400
Initial commit for drift.js
This javascript file contains some helper functions for generating
snapshots and displays the results of snapshot diffs.
diff --git a/etc/cli-scripts/drift.js b/etc/cli-scripts/drift.js
new file mode 100644
index 0000000..ee54191
--- /dev/null
+++ b/etc/cli-scripts/drift.js
@@ -0,0 +1,59 @@
+// This script has a dependency on rhq/etc/cl-scripts/util.js. The following
+// command needs to be run in order to load the functions in util.js:
+//
+// exec -f /path/to/rhq/etc/cli-scripts/util.js
+//
+// Then the same exec command can be run to load functions in this script.
+
+function createSnapshot(rid, cname) {
+ var config = findDriftConfig(rid, function(c) { return cname.equals(c.name) });
+
+ var criteria = BasicDriftChangeSetCriteria();
+ criteria.addFilterResourceId(rid);
+ criteria.addFilterDriftConfigurationId(config.id);
+
+ return DriftServer.createSnapshot(criteria);
+}
+
+function findDriftConfig(rid, fn) {
+ var criteria = ResourceCriteria();
+ criteria.addFilterId(rid);
+ criteria.fetchDriftConfigurations(true);
+
+ var resources = ResourceManager.findResourcesByCriteria(criteria);
+ var resource = resources.get(0);
+
+ return find(resource.driftConfigurations, function(config) {
+ return fn(DriftConfiguration(config));
+ });
+}
+
+function diff(s1, s2) {
+ var theDiff = s1.diff(s2);
+
+ function printEntry(entry) {
+ println(entry.newDriftFile.hashId + '\t' + entry.path);
+ }
+
+ function report(header, elements) {
+ println(header + ':');
+ foreach(elements, printEntry);
+ println('\n');
+ }
+
+ report('elements in conflict', theDiff.elementsInConflict);
+ report('elements not in left', theDiff.elementsNotInLeft);
+ report('elements not in right', theDiff.elementsNotInRight);
+}
+
+function filterEntry(props) {
+ return function(entry) {
+ var filteredEntry = {};
+ foreach(props, function(prop) {
+ if (entry[prop]) {
+ filteredEntry[prop] = entry[prop];
+ }
+ });
+ return filteredEntry;
+ }
+}
commit 0dc48d31c12b4dbd6e6ca4b2bb67fb13f5b9f057
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Aug 1 22:41:01 2011 -0400
Initial attempt at fetch change sets
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
index bc88533..17b9f16 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
@@ -4,8 +4,10 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -123,7 +125,22 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
@Override
public PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria) {
- return new PageList<DriftChangeSet>();
+ Query<MongoDBChangeSet> query = ds.createQuery(MongoDBChangeSet.class)
+ .filter("resourceId =", criteria.getFilterResourceId());
+
+ PageList results = new PageList<DriftChangeSetDTO>();
+ for (MongoDBChangeSet changeSet : query) {
+ DriftChangeSetDTO changeSetDTO = toDTO(changeSet);
+ Set<DriftDTO> entries = new HashSet<DriftDTO>();
+ for (MongoDBChangeSetEntry entry : changeSet.getDrifts()) {
+ entries.add(toDTO(entry, changeSetDTO));
+ }
+ changeSetDTO.setDrifts(entries);
+ results.add(changeSetDTO);
+ }
+
+ return results;
+ //return new PageList<DriftChangeSet>();
}
@Override
@@ -189,6 +206,7 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
DriftChangeSetDTO toDTO(MongoDBChangeSet changeSet) {
DriftChangeSetDTO dto = new DriftChangeSetDTO();
dto.setId(changeSet.getId());
+ // TODO copy resource id
dto.setDriftConfigurationId(changeSet.getDriftConfigurationId());
dto.setVersion(changeSet.getVersion());
dto.setCtime(changeSet.getCtime());
commit efcf0c5f3ec664ee2899756cd45df7a591837d99
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Aug 1 16:18:28 2011 -0400
add change set menu item "show configuration" - not implemented yet until we get the proper composite query
added new icons for "coverage" change sets versus "drift"
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
index a513687..4c1c429 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
@@ -79,7 +79,21 @@ public class ImageManager {
return "[SKIN]/actions/undo.png";
}
+ /**
+ * Returns a drift icon given the category of the drift.
+ * Note that if the category is null, it will be assumed the drift icon
+ * should be one that indicates the file is "new" (presumably from
+ * a coverage change set report - that is, its the first time the file
+ * has been seen).
+ *
+ * @param category
+ * @return path to icon
+ */
public static String getDriftCategoryIcon(DriftCategory category) {
+ if (category == null) {
+ return "subsystems/drift/Drift_new_16.png";
+ }
+
switch (category) {
case FILE_ADDED:
return "subsystems/drift/Drift_add_16.png";
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/PopupWindow.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/PopupWindow.java
new file mode 100644
index 0000000..e72518a
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/PopupWindow.java
@@ -0,0 +1,63 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client;
+
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.events.CloseClientEvent;
+
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
+
+/**
+ * Generic window that you can use to popup details. Populate the popup
+ * window with any canvas.
+ *
+ * @author John Mazzitelli
+ */
+public class PopupWindow extends LocatableWindow {
+ /**
+ * Create the popup dialog window.
+ *
+ * @param locatorId
+ * @param canvas if not <code>null</code>, this will be added to the window.
+ */
+ public PopupWindow(String locatorId, Canvas canvas) {
+ super(locatorId);
+ setTitle(MSG.common_title_details());
+ setShowMinimizeButton(false);
+ setShowMaximizeButton(true);
+ setIsModal(true);
+ setShowModalMask(true);
+ setWidth(600);
+ setHeight(400);
+ setAutoCenter(true);
+ setShowResizer(true);
+ setCanDragResize(true);
+ centerInPage();
+ addCloseClickHandler(new CloseClickHandler() {
+ public void onCloseClick(CloseClientEvent event) {
+ markForDestroy();
+ }
+ });
+ if (canvas != null) {
+ addItem(canvas);
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
index 8203361..20e5bf1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -40,12 +40,17 @@ import com.smartgwt.client.widgets.tree.TreeNode;
import com.smartgwt.client.widgets.tree.events.NodeContextClickEvent;
import com.smartgwt.client.widgets.tree.events.NodeContextClickHandler;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.DriftConfigurationDefinition;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.PopupWindow;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
@@ -230,9 +235,42 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
});
contextMenu.addItem(deleteItem);
+ // item that shows the drift configuration
+ MenuItem configItem = new MenuItem(MSG.view_drift_changeset_tree_showConfiguration());
+ configItem.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ showDriftConfiguration(node.getChangeSetId());
+ }
+ });
+ contextMenu.addItem(configItem);
+
return contextMenu;
}
+ protected void showDriftConfiguration(final String changeSetId) {
+ ConfigurationDefinition def = DriftConfigurationDefinition.getInstance();
+ Configuration config = new Configuration();
+ ConfigurationEditor editor = new ConfigurationEditor(extendLocatorId("driftConfigEditor"), def, config);
+ editor.setReadOnly(true);
+ PopupWindow window = new PopupWindow("details", editor);
+ window.show();
+
+ // DriftChangeSetCriteria criteria = new BasicDriftChangeSetCriteria();
+ // criteria.addFilterId(changeSetId);
+ // criteria.fetchDriftConfiguration(true);
+ // GWTServiceLookup.getDriftService().findDriftChangeSetCompositesByCriteria(criteria,
+ // new AsyncCallback<PageList<DriftChangeSet>>() {
+ // public void onSuccess(PageList<DriftChangeSet> result) {
+ // // TODO
+ // }
+ //
+ // public void onFailure(Throwable t) {
+ // CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadConfigFailure(changeSetId),
+ // t);
+ // }
+ // });
+ }
+
/**
* We override this because we know all of our nodes will have titles. Without this,
* I could not get the title of change set nodes to show - it always fell back to using
@@ -248,11 +286,23 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
static class ChangeSetTreeNode extends TreeNode {
public ChangeSetTreeNode(DriftChangeSet changeset) {
setIsFolder(true);
- setIcon("subsystems/drift/ChangeSet_16.png");
setShowOpenIcon(true);
setID(changeset.getId());
setName(padWithZeroes(changeset.getVersion())); // we sort on this column, hence we make sure the version # is padded
setTitle(buildDriftChangeSetNodeName(changeset));
+
+ switch (changeset.getCategory()) {
+ case COVERAGE:
+ setIcon("subsystems/drift/ChangeSet_Coverage_16.png");
+ break;
+ case DRIFT:
+ setIcon("subsystems/drift/ChangeSet_16.png");
+ break;
+ }
+ }
+
+ public String getChangeSetId() {
+ return getAttribute("id");
}
private String buildDriftChangeSetNodeName(DriftChangeSet changeset) {
@@ -263,7 +313,7 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
str.append(" (");
str.append(TimestampCellFormatter.format(changeset.getCtime(),
TimestampCellFormatter.DATE_TIME_FORMAT_SHORT));
- str.append(')');
+ str.append(")");
return str.toString();
}
@@ -285,6 +335,11 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
setParentID(parentID);
setID(parentID + '_' + drift.getId());
setName(drift.getPath()); // we sort on this column
+ setAttribute("driftId", drift.getId());
+ }
+
+ public String getDriftId() {
+ return getAttribute("driftId");
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
index 0d59be8..8a6c448 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
@@ -63,6 +63,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
*/
public class DriftDataSource extends RPCDataSource<DriftComposite, DriftCriteria> {
+ public static final String CATEGORY_ICON_NEW = ImageManager.getDriftCategoryIcon(null);
public static final String CATEGORY_ICON_ADD = ImageManager.getDriftCategoryIcon(DriftCategory.FILE_ADDED);
public static final String CATEGORY_ICON_CHANGE = ImageManager.getDriftCategoryIcon(DriftCategory.FILE_CHANGED);
public static final String CATEGORY_ICON_REMOVE = ImageManager.getDriftCategoryIcon(DriftCategory.FILE_REMOVED);
@@ -121,6 +122,8 @@ public class DriftDataSource extends RPCDataSource<DriftComposite, DriftCriteria
return MSG.view_drift_category_fileChanged();
} else if (CATEGORY_ICON_REMOVE.equals(cat)) {
return MSG.view_drift_category_fileRemoved();
+ } else if (CATEGORY_ICON_NEW.equals(cat)) {
+ return MSG.view_drift_category_fileNew();
} else {
return ""; // will never get here
}
@@ -304,7 +307,14 @@ public class DriftDataSource extends RPCDataSource<DriftComposite, DriftCriteria
Drift drift = from.getDrift();
record.setAttribute(ATTR_ID, drift.getId());
record.setAttribute(ATTR_CTIME, new Date(drift.getCtime()));
- record.setAttribute(ATTR_CATEGORY, ImageManager.getDriftCategoryIcon(drift.getCategory()));
+ switch (drift.getChangeSet().getCategory()) {
+ case COVERAGE:
+ record.setAttribute(ATTR_CATEGORY, ImageManager.getDriftCategoryIcon(null));
+ break;
+ case DRIFT:
+ record.setAttribute(ATTR_CATEGORY, ImageManager.getDriftCategoryIcon(drift.getCategory()));
+ break;
+ }
record.setAttribute(ATTR_PATH, drift.getPath());
record.setAttribute(ATTR_CHANGESET_VERSION, drift.getChangeSet().getVersion());
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index ea8c956..0ba3347 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -1120,10 +1120,13 @@ view_drift = Drift
view_drift_button_detectNow = Detect Now
view_drift_category_fileAdded = File Added
view_drift_category_fileChanged = File Changed
+view_drift_category_fileNew = New Detection
view_drift_category_fileRemoved = File Removed
view_drift_changeSets = Change Sets
view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+view_drift_changeset_tree_loadConfigFailure = Failed to load drift configuration for change set id [{0}]
view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
+view_drift_changeset_tree_showConfiguration = Show Configuration
view_drift_delete_confirm = Delete the selected drift(s)?
view_drift_delete_confirmAll = Delete all drifts from this source?
view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index a07568a..977f4a4 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -938,10 +938,13 @@ view_dashboards_title = Dashboard
##view_drift_button_detectNow = Detect Now
##view_drift_category_fileAdded = File Added
##view_drift_category_fileChanged = File Changed
+##view_drift_category_fileNew = New Detection
##view_drift_category_fileRemoved = File Removed
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadConfigFailure = Failed to load drift configuration for change set id [{0}]
##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
+##view_drift_changeset_tree_showConfiguration = Show Configuration
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index 6e68cff..6af4be0 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -1104,9 +1104,12 @@ view_dashboards_portlets_refresh_success1 = ポートレットの自動リフレ
view_dashboards_portlets_refresh_success2 = 自動リフレッシュするポートレットのリロードを停止しています
view_dashboards_title = ダッシュボード
##view_drift = Drift
+##view_drift_category_fileNew = New Detection
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadConfigFailure = Failed to load drift configuration for change set id [{0}]
##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
+##view_drift_changeset_tree_showConfiguration = Show Configuration
##view_drift_table_baseDir = Base Directory
##view_drift_table_changeSet = Change Set
##view_drift_table_newFile = New File
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index fa86006..0d1e7c9 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -1138,10 +1138,13 @@ view_dashboards_title = Dashboard~
##view_drift_button_detectNow = Detect Now
##view_drift_category_fileAdded = File Added
##view_drift_category_fileChanged = File Changed
+##view_drift_category_fileNew = New Detection
##view_drift_category_fileRemoved = File Removed
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadConfigFailure = Failed to load drift configuration for change set id [{0}]
##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
+##view_drift_changeset_tree_showConfiguration = Show Configuration
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index 79816c5..a6c6880 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -1113,9 +1113,12 @@ view_dashboards_portlets_refresh_success1 = \u6210\u529f\u4fee\u6539portlets\u81
view_dashboards_portlets_refresh_success2 = \u6210\u529f\u505c\u7528portlets\u81ea\u52a8\u5237\u65b0\u7684\u91cd\u8f7d
view_dashboards_title = \u7edf\u8ba1\u8868\u76d8
##view_drift = Drift
+##view_drift_category_fileNew = New Detection
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadConfigFailure = Failed to load drift configuration for change set id [{0}]
##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
+##view_drift_changeset_tree_showConfiguration = Show Configuration
##view_drift_table_baseDir = Base Directory
##view_drift_table_changeSet = Change Set
##view_drift_table_newFile = New File
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_Coverage_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_Coverage_16.png
new file mode 100644
index 0000000..7ae8f52
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_Coverage_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_Coverage_16_open.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_Coverage_16_open.png
new file mode 100644
index 0000000..85e3cf4
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_Coverage_16_open.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/Drift_new_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/Drift_new_16.png
new file mode 100644
index 0000000..e3e4f97
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/Drift_new_16.png differ
commit 5a81800b803be0d83ebc18a91f763ad43d364b70
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Aug 1 15:23:33 2011 -0400
temporarily disabling test until mongodb server is available with hudson builds
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
index cfdc802..ac20ac4 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
@@ -45,7 +45,7 @@ public class MongoDBChangeSetTest {
ds.delete(deleteAll);
}
- @Test
+ @Test(enabled = false)
public void saveAndLoadEmptyChangeSet() throws Exception {
MongoDBChangeSet expected = new MongoDBChangeSet();
expected.setCategory(COVERAGE);
@@ -59,7 +59,7 @@ public class MongoDBChangeSetTest {
assertPropertiesMatch("Failed to save change set", expected, actual);
}
- @Test
+ @Test(enabled = false)
public void saveAndLoadChangeSetWithOneEntry() throws Exception {
MongoDBChangeSet expected = new MongoDBChangeSet();
expected.setResourceId(10001);
@@ -75,7 +75,7 @@ public class MongoDBChangeSetTest {
"changeSet");
}
- @Test
+ @Test(enabled = false)
public void saveAndFindChangeSetById() throws Exception {
MongoDBChangeSet expected = new MongoDBChangeSet();
expected.setCategory(COVERAGE);
commit 26bfa2034a6306ed941d6a1fd5f26840e32eef84
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Aug 1 15:17:18 2011 -0400
Add config id to drift change set criteria
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftChangeSetCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftChangeSetCriteria.java
index 2debece..ba46bc2 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftChangeSetCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftChangeSetCriteria.java
@@ -22,6 +22,8 @@ public class BasicDriftChangeSetCriteria implements DriftChangeSetCriteria {
private Integer filterResourceId;
+ private Integer filterDriftConfigId;
+
private DriftChangeSetCategory filterCategory;
private boolean fetchDrifts;
@@ -101,6 +103,16 @@ public class BasicDriftChangeSetCriteria implements DriftChangeSetCriteria {
}
@Override
+ public void addFilterDriftConfigurationId(Integer filterDriftConfigId) {
+ this.filterDriftConfigId = filterDriftConfigId;
+ }
+
+ @Override
+ public Integer getFilterDriftConfigurationId() {
+ return filterDriftConfigId;
+ }
+
+ @Override
public void addFilterCategory(DriftChangeSetCategory filterCategory) {
this.filterCategory = filterCategory;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
index b5f71b2..273db4b 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
@@ -35,6 +35,10 @@ public interface DriftChangeSetCriteria extends BaseCriteria, Serializable {
Integer getFilterResourceId();
+ void addFilterDriftConfigurationId(Integer filterDriftConfigId);
+
+ Integer getFilterDriftConfigurationId();
+
void addFilterCategory(DriftChangeSetCategory filterCategory);
DriftChangeSetCategory getFilterCategory();
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
index 7a7f78f..0ca1d36 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
@@ -39,6 +39,7 @@ public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSe
private Integer filterId;
private Integer filterInitial; // needs override
private Integer filterResourceId; // needs override
+ private Integer filterDriftConfigurationId;
private Integer filterVersion;
private Integer filterStartVersion;
private Integer filterEndVersion;
@@ -138,6 +139,16 @@ public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSe
return filterResourceId;
}
+ @Override
+ public void addFilterDriftConfigurationId(Integer filterDriftConfigId) {
+ this.filterDriftConfigurationId = filterDriftConfigId;
+ }
+
+ @Override
+ public Integer getFilterDriftConfigurationId() {
+ return filterDriftConfigurationId;
+ }
+
public void addFilterCategory(DriftChangeSetCategory filterCategory) {
this.filterCategory = filterCategory;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index 8e4d1f7..0479c4a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@ -147,11 +147,6 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
try {
- DriftChangeSetJPACriteria c = new DriftChangeSetJPACriteria();
- c.addFilterResourceId(resourceId);
- List<RhqDriftChangeSet> changeSets = findDriftChangeSetsByCriteria(subjectManager.getOverlord(), c);
- final int version = changeSets.size();
-
ZipUtil.walkZipFile(changeSetZip, new ChangeSetFileVisitor() {
@Override
@@ -165,6 +160,8 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
// store the new change set info (not the actual blob)
DriftConfiguration config = findDriftConfiguration(resource, reader.getHeaders());
+ int version = getChangeSetVersion(resource, config);
+
if (config == null) {
log.error("Unable to locate " + config.getClass().getSimpleName() + "[id: " +
config.getId() + ", name: " + config.getName() + "]. Change set cannot be saved.");
@@ -240,6 +237,24 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
}
+ /**
+ * This method only exists temporarily until the version header is added to the change
+ * set meta data file. This method determines the version by looking at the number of
+ * change sets in the database.
+ *
+ * @param r The resource
+ * @param c The drift configuration
+ * @return The next change set version number
+ */
+ int getChangeSetVersion(Resource r, DriftConfiguration c) {
+ DriftChangeSetJPACriteria criteria = new DriftChangeSetJPACriteria();
+ criteria.addFilterResourceId(r.getId());
+ criteria.addFilterDriftConfigurationId(c.getId());
+ List<RhqDriftChangeSet> changeSets = findDriftChangeSetsByCriteria(subjectManager.getOverlord(), criteria);
+
+ return changeSets.size();
+ }
+
DriftConfiguration findDriftConfiguration(Resource resource, Headers headers) {
for (Configuration config : resource.getDriftConfigurations()) {
DriftConfiguration driftConfig = new DriftConfiguration(config);
diff --git a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
index 1755d3e..c2520d5 100644
--- a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
@@ -111,6 +111,7 @@ public class DriftServerPluginComponent implements DriftServerPluginFacet {
DriftChangeSetJPACriteria jpaCriteria = new DriftChangeSetJPACriteria();
jpaCriteria.addFilterId(criteria.getFilterId());
jpaCriteria.addFilterResourceId(criteria.getFilterResourceId());
+ jpaCriteria.addFilterDriftConfigurationId(criteria.getFilterDriftConfigurationId());
jpaCriteria.addFilterCategory(criteria.getFilterCategory());
jpaCriteria.addFilterCreatedAfter(criteria.getFilterCreatedAfter());
jpaCriteria.addFilterCreatedBefore(criteria.getFilterCreatedBefore());
commit 608dffc9a54c653d6c27b560730fe939d72a0a0e
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Jul 29 17:20:11 2011 -0400
[BZ-726508 - Can't create alert condition on certain metrics]
Since metric def names may not be unique, they are duplicated
for the 'Per Minute' version of certain metrics, don't use them
for the value map keys in alert def drop downs.
- Also, some of these metric name lists are long, sort the
menu entries.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
index 2fd9400..44875d8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
@@ -24,9 +24,11 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Set;
+import java.util.TreeSet;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -572,7 +574,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
LinkedHashMap<String, String> traitsMap = new LinkedHashMap<String, String>();
for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
if (def.getDataType() == DataType.TRAIT) {
- traitsMap.put(def.getName(), def.getDisplayName());
+ traitsMap.put(String.valueOf(def.getId()), def.getDisplayName());
}
}
@@ -703,10 +705,21 @@ public class NewConditionEditor extends LocatableDynamicForm {
private SelectItem buildMetricDropDownMenu(String itemName, boolean dynamicOnly, FormItemIfFunction ifFunc) {
LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>();
- for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
+ TreeSet<MeasurementDefinition> sortedDefs = new TreeSet<MeasurementDefinition>(
+ new Comparator<MeasurementDefinition>() {
+
+ @Override
+ public int compare(MeasurementDefinition o1, MeasurementDefinition o2) {
+ return o1.getDisplayName().compareTo(o2.getDisplayName());
+ }
+ });
+ sortedDefs.addAll(this.resourceType.getMetricDefinitions());
+
+ for (MeasurementDefinition def : sortedDefs) {
if (def.getDataType() == DataType.MEASUREMENT) {
if (!dynamicOnly || def.getNumericType() == NumericType.DYNAMIC) {
- metricsMap.put(def.getName(), def.getDisplayName());
+ // use id as opposed to name for key, the name is not unique when per-minute metric is also used
+ metricsMap.put(String.valueOf(def.getId()), def.getDisplayName());
}
}
}
@@ -726,7 +739,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>();
for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
if (def.getDataType() == DataType.CALLTIME) {
- metricsMap.put(def.getName(), def.getDisplayName());
+ metricsMap.put(String.valueOf(def.getId()), def.getDisplayName());
}
}
@@ -790,9 +803,10 @@ public class NewConditionEditor extends LocatableDynamicForm {
return help;
}
- private MeasurementDefinition getMeasurementDefinition(String metricName) {
+ private MeasurementDefinition getMeasurementDefinition(String metricId) {
+ int id = Integer.valueOf(metricId).intValue();
for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
- if (metricName.equals(def.getName())) {
+ if (id == def.getId()) {
return def;
}
}
commit db8e0a195c7ef54dca2d137933d9f52b2bac9539
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Jul 29 13:28:33 2011 -0400
[BZ-726714 - Metric template creation generates NPE (null pointer exception)]
Fix a problem when trying to apply a metric template to a resource in a
"hidden" state like UNINVENTORIED.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
index 98110ac..03cd4bb 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
@@ -498,6 +498,17 @@ public class MeasurementScheduleManagerBean implements MeasurementScheduleManage
for (Integer resourceId : reqMap.keySet()) {
Agent agent = agentManager.getAgentByResourceId(subjectManager.getOverlord(), resourceId);
+ // Ignore resources that are not actually associated with an agent. For example,
+ // those with an UNINVENTORIED status.
+ if (null == agent) {
+ if (log.isDebugEnabled()) {
+ log.debug("Ignoring measurement schedule change for non-agent-related resource ["
+ + resourceId + "]. It is probably waiting to be uninventoried.");
+ }
+
+ continue;
+ }
+
Set<ResourceMeasurementScheduleRequest> agentUpdate = agentUpdates.get(agent);
if (agentUpdate == null) {
agentUpdate = new HashSet<ResourceMeasurementScheduleRequest>();
commit ff805de329d0aacfc2a9345987a1274a4e4d8930
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 29 16:54:51 2011 -0400
Adding a drift template
diff --git a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
index 21161fe..4cf5b2d 100644
--- a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
@@ -1191,6 +1191,18 @@
</configuration>
</content>
+ <drift-configuration name="Core Files">
+ <basedir>
+ <value-context>pluginConfiguration</value-context>
+ <value-name>jbossHomeDir</value-name>
+ </basedir>
+ <includes>
+ <include path="bin" />
+ <include path="lib" />
+ <include path="client" />
+ </includes>
+ </drift-configuration>
+
<bundle-target>
<destination-base-dir name="Install Directory" description="The top directory where the JBossAS Server is installed. (i.e. the value found in the 'JBoss Home Directory' connection property)">
<value-context>pluginConfiguration</value-context>
commit f7da51617e05e16c33791a92907e359c201e18ee
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 29 16:48:16 2011 -0400
emit a warning if the query returns us too much stuff
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
index aee99cf..c51806a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
@@ -35,6 +35,8 @@ import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -64,6 +66,12 @@ public class DriftDetailsView extends LocatableVLayout {
GWTServiceLookup.getDriftService().findDriftsByCriteria(criteria, new AsyncCallback<PageList<Drift>>() {
@Override
public void onSuccess(PageList<Drift> result) {
+ if (result.getTotalSize() != 1) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Got [" + result.getTotalSize()
+ + "] results. Should have been 1. The details shown here might not be correct.",
+ Severity.Warning));
+ }
Drift drift = result.get(0);
show(drift);
}
@@ -78,6 +86,7 @@ public class DriftDetailsView extends LocatableVLayout {
private void show(Drift drift) {
for (Canvas child : getMembers()) {
removeMember(child);
+ child.destroy();
}
// the change set to which the drift belongs
commit b7c8d2f78a437a375f250d38de47dc08aa0e633c
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 29 16:18:20 2011 -0400
make sure the URL id is prefexed with 0id_ so CoreGUI knows this is an ID
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
index 378350d..646c32f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
@@ -25,6 +25,7 @@ package org.rhq.enterprise.gui.coregui.client;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.enterprise.gui.coregui.client.admin.roles.RolesView;
import org.rhq.enterprise.gui.coregui.client.admin.users.UsersView;
+import org.rhq.enterprise.gui.coregui.client.components.table.StringIDTableSection;
/**
* @author Greg Hinkle
@@ -218,14 +219,6 @@ public class LinkManager {
return link;
}
- public static String getSubsystemDriftHistoryLink(int resourceId, String driftId) {
- return "#Resource/" + resourceId + "/Drift/History/" + driftId;
- }
-
- public static String getSubsystemDriftConfigLink(int resourceId, int driftConfigId) {
- return "#Resource/" + resourceId + "/Drift/Config/" + driftConfigId;
- }
-
public static String getAutodiscoveryQueueLink() {
if (GWT) {
return "#Administration/Security/Auto%20Discovery%20Queue";
@@ -459,7 +452,14 @@ public class LinkManager {
return "#Bundles/Bundle/" + bundleId + "/deployments/" + bundleDeploymentId;
}
- public static String getDriftHistoryLink(int resourceId, int driftId) {
+ public static String getDriftHistoryLink(int resourceId, String driftId) {
+ if (!driftId.startsWith(StringIDTableSection.ID_PREFIX)) {
+ driftId = StringIDTableSection.ID_PREFIX + driftId;
+ }
return "#Resource/" + resourceId + "/Drift/History/" + driftId;
}
+
+ public static String getDriftConfigLink(int resourceId, int driftConfigId) {
+ return "#Resource/" + resourceId + "/Drift/Config/" + driftConfigId;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java
index c4118af..1c5a333 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java
@@ -93,7 +93,7 @@ public abstract class StringIDTableSection<DS extends RPCDataSource> extends Abs
@Override
public void showDetails(String id) {
if (id != null && id.length() > 0) {
- History.newItem(getBasePath() + "/" + id);
+ History.newItem(getBasePath() + "/" + convertIDToCurrentViewPath(id));
} else {
String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), (id == null) ? "null" : id
.toString());
@@ -105,18 +105,24 @@ public abstract class StringIDTableSection<DS extends RPCDataSource> extends Abs
@Override
public abstract Canvas getDetailsView(String id);
- private static final String ID_PREFIX = "0id_"; // the prefix to be placed in front of the string IDs in URLs
+ // the main CoreGUI class will assume anything with a digit as the first character in a path segment in the URL is an ID.
+ public static final String ID_PREFIX = "0id_"; // the prefix to be placed in front of the string IDs in URLs
@Override
protected String convertCurrentViewPathToID(String path) {
+ if (!path.startsWith(ID_PREFIX)) {
+ return path; // prefixed has already been stripped
+ }
return path.substring(ID_PREFIX.length()); // skip the initial "0id_" - see convertIDToCurrentViewPath for what this is all about
}
@Override
protected String convertIDToCurrentViewPath(String id) {
- // the main CoreGUI class will assume anything with a digit as the first character in a path segment in the URL
- // is an ID. Because we aren't assured the given ID will be a digit, let's prepend the digit here and make it
+ // Because we aren't assured the given ID will be a digit, let's prepend the digit here and make it
// look like an ID to CoreGUI. We will strip this off when we convert this back to an ID - see convertCurrentViewPathToID
+ if (id.startsWith(ID_PREFIX)) {
+ return id; // it is already prefixed
+ }
return ID_PREFIX + id;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
index 6f4bbf2..aee99cf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
@@ -20,6 +20,8 @@
package org.rhq.enterprise.gui.coregui.client.drift;
+import static org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter.DATE_TIME_FORMAT_FULL;
+
import java.util.LinkedHashMap;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -30,34 +32,29 @@ import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import org.rhq.core.domain.criteria.BasicDriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import static org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter.DATE_TIME_FORMAT_FULL;
-
/**
* @author Jay Shaughnessy
*/
-public class DriftDetailsView extends LocatableVLayout implements BookmarkableView {
+public class DriftDetailsView extends LocatableVLayout {
private String driftId;
- private static DriftDetailsView INSTANCE = new DriftDetailsView("DriftDetailsView");
-
- public static DriftDetailsView getInstance() {
- return INSTANCE;
+ public DriftDetailsView(String locatorId, String driftId) {
+ super(locatorId);
+ this.driftId = driftId;
+ setMembersMargin(10);
}
- private DriftDetailsView(String id) {
- // access through the static singleton only (see renderView)
- super(id);
-
- setMembersMargin(10);
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ show(this.driftId);
}
private void show(String driftId) {
@@ -80,7 +77,7 @@ public class DriftDetailsView extends LocatableVLayout implements BookmarkableVi
private void show(Drift drift) {
for (Canvas child : getMembers()) {
- removeChild(child);
+ removeMember(child);
}
// the change set to which the drift belongs
@@ -157,11 +154,4 @@ public class DriftDetailsView extends LocatableVLayout implements BookmarkableVi
addMember(driftForm);
}
-
- @Override
- public void renderView(ViewPath viewPath) {
- driftId = viewPath.getCurrent().getPath();
- show(driftId);
- }
-
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
index 060c9d1..cf42485 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
@@ -156,7 +156,7 @@ public class DriftHistoryView extends StringIDTableSection<DriftDataSource> {
public String format(Object value, ListGridRecord record, int i, int i1) {
Integer resourceId = record.getAttributeAsInt(AncestryUtil.RESOURCE_ID);
String driftId = getId(record);
- String url = LinkManager.getSubsystemDriftHistoryLink(resourceId, driftId);
+ String url = LinkManager.getDriftHistoryLink(resourceId, driftId);
String formattedValue = TimestampCellFormatter.format(value);
return SeleniumUtility.getLocatableHref(url, formattedValue, null);
}
@@ -285,7 +285,7 @@ public class DriftHistoryView extends StringIDTableSection<DriftDataSource> {
@Override
public Canvas getDetailsView(String driftId) {
- return DriftDetailsView.getInstance();
+ return new DriftDetailsView(extendLocatorId("Details"), driftId);
}
public EntityContext getContext() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
index 3ee0b5f..51f2ec2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
@@ -47,7 +47,7 @@ public class ResourceDriftChangeSetsTreeView extends AbstractDriftChangeSetsTree
protected String getNodeTargetLink(TreeNode node) {
if (node instanceof DriftTreeNode) {
String driftIdStr = node.getAttribute(AbstractDriftChangeSetsTreeDataSource.ATTR_ID).split("_")[1];
- String path = LinkManager.getDriftHistoryLink(this.context.resourceId, Integer.valueOf(driftIdStr));
+ String path = LinkManager.getDriftHistoryLink(this.context.resourceId, driftIdStr);
return path;
}
return null;
commit 385db545221d5aa7bcbdca6abc23b3ffbb294d70
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 29 15:13:29 2011 -0400
factor TableSection to support string IDs
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
index 85f5e92..1c52477 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
@@ -53,8 +53,8 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceT
import org.rhq.enterprise.gui.coregui.client.menu.MenuBarView;
import org.rhq.enterprise.gui.coregui.client.report.ReportTopView;
import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView;
-import org.rhq.enterprise.gui.coregui.client.test.TestRemoteServiceStatisticsView;
import org.rhq.enterprise.gui.coregui.client.test.TestDataSourceResponseStatisticsView;
+import org.rhq.enterprise.gui.coregui.client.test.TestRemoteServiceStatisticsView;
import org.rhq.enterprise.gui.coregui.client.test.TestTopView;
import org.rhq.enterprise.gui.coregui.client.util.ErrorHandler;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
@@ -383,6 +383,11 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String>, Event.Na
} else {
if (view.matches(TREE_NAV_VIEW_PATTERN)) {
// e.g. "Resource/10001" or "Resource/AutoGroup/10003"
+ // TODO: need to support string IDs "Drift/History/0id_abcdefghijk"
+ // TODO: see StringIDTableSection.ID_PREFIX
+ // TODO: remember \D is a non-digit, and \d is a digit
+ // TODO: String suffix = currentViewPath.replaceFirst("\\D*[^/]*", ""); // this might be OK if 0id_ starts with a digit
+ // TODO: suffix = suffix.replaceFirst("((\\d.*)|(0id_[^/]*))", "");
if (!currentViewPath.startsWith(view)) {
// The Node that was selected is not the same Node that was previously selected - it
// may not even be the same node type. For example, the user could have moved from a
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
index 115d4a8..bfa9ae6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RolesView.java
@@ -26,9 +26,9 @@ import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-
import com.smartgwt.client.widgets.grid.events.CellClickEvent;
import com.smartgwt.client.widgets.grid.events.CellClickHandler;
+
import org.rhq.core.domain.authz.Permission;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
@@ -85,7 +85,7 @@ public class RolesView extends TableSection<RolesDataSource> implements Bookmark
addTableAction(extendLocatorId("New"), MSG.common_button_new(), createNewAction());
addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(), getDeleteConfirmMessage(),
- createDeleteAction());
+ createDeleteAction());
super.configureTable();
}
@@ -184,7 +184,7 @@ public class RolesView extends TableSection<RolesDataSource> implements Bookmark
}
@Override
- public Canvas getDetailsView(int roleId) {
+ public Canvas getDetailsView(Integer roleId) {
return new RoleEditView(extendLocatorId("Detail"), roleId);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
index 427b1c2..4fdd6e5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/users/UsersView.java
@@ -26,9 +26,9 @@ import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-
import com.smartgwt.client.widgets.grid.events.CellClickEvent;
import com.smartgwt.client.widgets.grid.events.CellClickHandler;
+
import org.rhq.core.domain.authz.Permission;
import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
@@ -211,7 +211,8 @@ public class UsersView extends TableSection<UsersDataSource> {
};
}
- public Canvas getDetailsView(int subjectId) {
+ @Override
+ public Canvas getDetailsView(Integer subjectId) {
return new UserEditView(extendLocatorId("Detail"), subjectId);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
index 45dd32c..3fa6202 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
@@ -277,7 +277,7 @@ public class AlertHistoryView extends TableSection<AlertDataSource> {
}
@Override
- public Canvas getDetailsView(int alertId) {
+ public Canvas getDetailsView(Integer alertId) {
return AlertDetailsView.getInstance();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
index c49fc4f..7f2cce0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
@@ -134,7 +134,7 @@ public abstract class AbstractAlertDefinitionsView extends TableSection<Abstract
}
@Override
- public SingleAlertDefinitionView getDetailsView(final int id) {
+ public SingleAlertDefinitionView getDetailsView(final Integer id) {
final SingleAlertDefinitionView singleAlertDefinitionView = new SingleAlertDefinitionView(this
.extendLocatorId("singleAlertDefinitionView"), this);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
index 9fa9c31..fc0dbb1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
@@ -93,7 +93,7 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- public SingleAlertDefinitionView getDetailsView(int id) {
+ public SingleAlertDefinitionView getDetailsView(Integer id) {
SingleAlertDefinitionView view = super.getDetailsView(id);
if (id == 0) {
// when creating a new alert def, make sure to set this in the new alert def
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
index ea41bc2..e31e554 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
@@ -93,7 +93,7 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- public SingleAlertDefinitionView getDetailsView(int id) {
+ public SingleAlertDefinitionView getDetailsView(Integer id) {
SingleAlertDefinitionView view = super.getDetailsView(id);
if (id == 0) {
// when creating a new alert def, make sure to set this in the new alert def
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
index 688dea4..755c8d7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
@@ -100,7 +100,7 @@ public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
- public SingleAlertDefinitionView getDetailsView(int id) {
+ public SingleAlertDefinitionView getDetailsView(Integer id) {
SingleAlertDefinitionView view = super.getDetailsView(id);
if (id == 0) {
// when creating a new alert def, make sure to set this in the new alert def
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java
index df8a406..7178269 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java
@@ -39,7 +39,6 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.DetailsView;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton;
@@ -49,10 +48,16 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
+ * Provides the typical table view with the additional ability of traversing to a "details" view
+ * when double-clicking a individual row in the table - a masters/detail view in effect.
+ *
+ * @param <DS> the datasource used to obtain data for the table
+ * @param <ID> the type used for IDs. This identifies the type used to uniquely refer to a row in the table
+ *
* @author Greg Hinkle
* @author John Mazzitelli
*/
-public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> implements BookmarkableView {
+public abstract class AbstractTableSection<DS extends RPCDataSource, ID> extends Table<DS> implements BookmarkableView {
private VLayout detailsHolder;
private Canvas detailsView;
@@ -60,38 +65,39 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
private boolean escapeHtmlInDetailsLinkColumn;
private boolean initialDisplay;
- protected TableSection(String locatorId, String tableTitle) {
+ protected AbstractTableSection(String locatorId, String tableTitle) {
super(locatorId, tableTitle);
}
- protected TableSection(String locatorId, String tableTitle, Criteria criteria) {
+ protected AbstractTableSection(String locatorId, String tableTitle, Criteria criteria) {
super(locatorId, tableTitle, criteria);
}
- protected TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
+ protected AbstractTableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
super(locatorId, tableTitle, sortSpecifiers);
}
- protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers) {
+ protected AbstractTableSection(String locatorId, String tableTitle, Criteria criteria,
+ SortSpecifier[] sortSpecifiers) {
super(locatorId, tableTitle, sortSpecifiers, criteria);
}
- protected TableSection(String locatorId, String tableTitle, boolean autoFetchData) {
+ protected AbstractTableSection(String locatorId, String tableTitle, boolean autoFetchData) {
super(locatorId, tableTitle, autoFetchData);
}
- protected TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers,
+ protected AbstractTableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers,
String[] excludedFieldNames) {
super(locatorId, tableTitle, null, sortSpecifiers, excludedFieldNames);
}
- protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
- String[] excludedFieldNames) {
+ protected AbstractTableSection(String locatorId, String tableTitle, Criteria criteria,
+ SortSpecifier[] sortSpecifiers, String[] excludedFieldNames) {
super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames);
}
- protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
- String[] excludedFieldNames, boolean autoFetchData) {
+ protected AbstractTableSection(String locatorId, String tableTitle, Criteria criteria,
+ SortSpecifier[] sortSpecifiers, String[] excludedFieldNames, boolean autoFetchData) {
super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames, autoFetchData);
}
@@ -177,8 +183,8 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
if (value == null) {
return "";
}
- Integer recordId = getId(record);
- String detailsUrl = "#" + getBasePath() + "/" + recordId;
+ ID recordId = getId(record);
+ String detailsUrl = "#" + getBasePath() + "/" + convertIDToCurrentViewPath(recordId);
String formattedValue = (escapeHtmlInDetailsLinkColumn) ? StringUtility.escapeHtml(value.toString())
: value.toString();
return SeleniumUtility.getLocatableHref(detailsUrl, formattedValue, null);
@@ -190,7 +196,7 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
* Shows the details view for the given record of the table.
*
* The default implementation of this method assumes there is an
- * id attribute on the record and passes it to {@link #showDetails(int)}.
+ * id attribute on the record and passes it to {@link #showDetails(Object)}.
* Subclasses are free to override this behavior. Subclasses usually
* will need to set the {@link #setDetailsView(Canvas) details view}
* explicitly.
@@ -202,7 +208,7 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
throw new IllegalArgumentException("'record' parameter is null.");
}
- Integer id = getId(record);
+ ID id = getId(record);
showDetails(id);
}
@@ -210,7 +216,7 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
* Returns the details canvas with information on the item given its list grid record.
*
* The default implementation of this method is to assume there is an
- * id attribute on the record and pass that ID to {@link #getDetailsView(int)}.
+ * id attribute on the record and pass that ID to {@link #getDetailsView(Object)}.
* Subclasses are free to override this - which you usually want to do
* if you know the full details of the item are stored in the record attributes
* and thus help avoid making a round trip to the DB.
@@ -218,66 +224,76 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
* @param record the record of the item whose details to be shown; ; null if empty details view should be shown.
*/
public Canvas getDetailsView(ListGridRecord record) {
- Integer id = getId(record);
+ ID id = getId(record);
return getDetailsView(id);
}
- protected Integer getId(ListGridRecord record) {
- Integer id = (record != null) ? record.getAttributeAsInt("id") : 0;
- if (id == null) {
- String msg = MSG.view_tableSection_error_noId(this.getClass().toString());
- CoreGUI.getErrorHandler().handleError(msg);
- throw new IllegalStateException(msg);
- }
- return id;
- }
+ /**
+ * Subclasses define how they want to format their identifiers. These uniquely identify
+ * rows in the table. Typical values/types for IDs are Integers or Strings.
+ *
+ * @param record the individual record that contains the ID to be extracted and returned
+ *
+ * @return the ID of the given row/record from the table.
+ */
+ protected abstract ID getId(ListGridRecord record);
/**
* Shows empty details for a new item being created.
* This method is usually called when a user clicks a 'New' button.
*
+ * Subclasses are free to override this if they need a custom way to show the details view.
+ *
* @see #showDetails(ListGridRecord)
*/
public void newDetails() {
- History.newItem(basePath + "/0");
+ History.newItem(basePath + "/0"); // assumes the subclasses will understand "0" means "new details page"
}
/**
- * Shows the details for an item has the given ID.
+ * Shows the details for an item that has the given ID.
* This method is usually called when a user goes to the details
* page via a bookmark, double-cick on a list view row, or direct link.
*
- * @param id the id of the row whose details are to be shown; Should be a valid id, > 0.
+ * @param id the id of the row whose details are to be shown; Must be a valid ID.
*
* @see #showDetails(ListGridRecord)
*
- * @throws IllegalArgumentException if id <= 0.
+ * @throws IllegalArgumentException if id is invalid
*/
- public void showDetails(int id) {
- if (id > 0) {
- History.newItem(basePath + "/" + id);
- } else {
- String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), Integer.toString(id));
- CoreGUI.getErrorHandler().handleError(msg);
- throw new IllegalArgumentException(msg);
- }
- }
+ public abstract void showDetails(ID id);
/**
* Returns the details canvas with information on the item that has the given ID.
* Note that an empty details view should be returned if the id passed in is 0 (as would
* be the case if a new item is to be created using the details view).
*
- * @param id the id of the details to be shown; will be 0 if an empty details view should be shown.
+ * @param id the id of the details to be shown; will be "0" if an empty details view should be shown.
+ */
+ public abstract Canvas getDetailsView(ID id);
+
+ /**
+ * Given the path from the URL that identifies the ID, this returns the ID represented by that path string.
+ * @param path the path as it was found in the current view path (i.e. in the URL)
+ * @return the ID that identifies the item referred to by the URL
+ */
+ protected abstract ID convertCurrentViewPathToID(String path);
+
+ /**
+ * Given the ID of a particular item, this returns a path string suitable for placement in a URL such that that URL will
+ * identify the particular item.
+ *
+ * @return how the ID can be represented within a view path (i.e. in a URL)
+ * @param id the ID that identifies the item to be referred by in a URL
*/
- public abstract Canvas getDetailsView(int id);
+ protected abstract String convertIDToCurrentViewPath(ID id);
@Override
public void renderView(ViewPath viewPath) {
this.basePath = viewPath.getPathToCurrent();
if (!viewPath.isEnd()) {
- int id = Integer.parseInt(viewPath.getCurrent().getPath());
+ ID id = convertCurrentViewPathToID(viewPath.getCurrent().getPath());
this.detailsView = getDetailsView(id);
if (this.detailsView instanceof BookmarkableView) {
((BookmarkableView) this.detailsView).renderView(viewPath);
@@ -325,7 +341,7 @@ public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> i
* detailsView in edit-mode, the content canvas will already be hidden, which means the
* animateHide would be a no-op (the event won't fire). this causes the detailsHolder
* to keep a reference to the previous detailsView (the one in create-mode) instead of the
- * newly returned reference from getDetailsView(int) that was called when the renderView
+ * newly returned reference from getDetailsView(ID) that was called when the renderView
* methods were called hierarchically down to render the new detailsView in edit-mode.
* therefore, we need to explicitly destroy what's already there (presumably the detailsView
* in create-mode), and then rebuild it (presumably the detailsView in edit-mode).
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java
new file mode 100644
index 0000000..c4118af
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/StringIDTableSection.java
@@ -0,0 +1,122 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.components.table;
+
+import com.google.gwt.user.client.History;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * The TableSection abstract implementation that supports IDs as basic Strings.
+ *
+ * Use this if you have tabular data whose rows are not identified with Integers but
+ * some other non-numeric string.
+ *
+ * If you have tabular data whose rows have integer IDs, use {@link TableSection}.
+ *
+ * @author John Mazzitelli
+ */
+public abstract class StringIDTableSection<DS extends RPCDataSource> extends AbstractTableSection<DS, String> {
+
+ public StringIDTableSection(String locatorId, String tableTitle, boolean autoFetchData) {
+ super(locatorId, tableTitle, autoFetchData);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames, boolean autoFetchData) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames, autoFetchData);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle, Criteria criteria) {
+ super(locatorId, tableTitle, criteria);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames) {
+ super(locatorId, tableTitle, sortSpecifiers, excludedFieldNames);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, sortSpecifiers);
+ }
+
+ public StringIDTableSection(String locatorId, String tableTitle) {
+ super(locatorId, tableTitle);
+ }
+
+ @Override
+ protected String getId(ListGridRecord record) {
+ String id = null;
+ if (record != null) {
+ id = record.getAttribute("id");
+ }
+
+ if (id == null || id.length() == 0) {
+ String msg = MSG.view_tableSection_error_noId(this.getClass().toString());
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalStateException(msg);
+ }
+ return id;
+ }
+
+ @Override
+ public void showDetails(String id) {
+ if (id != null && id.length() > 0) {
+ History.newItem(getBasePath() + "/" + id);
+ } else {
+ String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), (id == null) ? "null" : id
+ .toString());
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ @Override
+ public abstract Canvas getDetailsView(String id);
+
+ private static final String ID_PREFIX = "0id_"; // the prefix to be placed in front of the string IDs in URLs
+
+ @Override
+ protected String convertCurrentViewPathToID(String path) {
+ return path.substring(ID_PREFIX.length()); // skip the initial "0id_" - see convertIDToCurrentViewPath for what this is all about
+ }
+
+ @Override
+ protected String convertIDToCurrentViewPath(String id) {
+ // the main CoreGUI class will assume anything with a digit as the first character in a path segment in the URL
+ // is an ID. Because we aren't assured the given ID will be a digit, let's prepend the digit here and make it
+ // look like an ID to CoreGUI. We will strip this off when we convert this back to an ID - see convertCurrentViewPathToID
+ return ID_PREFIX + id;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
new file mode 100644
index 0000000..3eb65c5
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
@@ -0,0 +1,114 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.components.table;
+
+import com.google.gwt.user.client.History;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * The TableSection abstract implementation that supports IDs as Integers.
+ *
+ * Since most master/detail table views have Integers for IDs that uniquely identify
+ * rows in the table, this is the typical superclass implementation used for
+ * most of RHQ's concrete TableSection views.
+ *
+ * @author John Mazzitelli
+ */
+public abstract class TableSection<DS extends RPCDataSource> extends AbstractTableSection<DS, Integer> {
+
+ public TableSection(String locatorId, String tableTitle, boolean autoFetchData) {
+ super(locatorId, tableTitle, autoFetchData);
+ }
+
+ public TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames, boolean autoFetchData) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames, autoFetchData);
+ }
+
+ public TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames);
+ }
+
+ public TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers);
+ }
+
+ public TableSection(String locatorId, String tableTitle, Criteria criteria) {
+ super(locatorId, tableTitle, criteria);
+ }
+
+ public TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers, String[] excludedFieldNames) {
+ super(locatorId, tableTitle, sortSpecifiers, excludedFieldNames);
+ }
+
+ public TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, sortSpecifiers);
+ }
+
+ public TableSection(String locatorId, String tableTitle) {
+ super(locatorId, tableTitle);
+ }
+
+ @Override
+ protected Integer getId(ListGridRecord record) {
+ Integer id = (record != null) ? record.getAttributeAsInt("id") : 0;
+ if (id == null) {
+ String msg = MSG.view_tableSection_error_noId(this.getClass().toString());
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalStateException(msg);
+ }
+ return id;
+ }
+
+ @Override
+ public void showDetails(Integer id) {
+ if (id != null && id.intValue() > 0) {
+ History.newItem(getBasePath() + "/" + id);
+ } else {
+ String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), (id == null) ? "null" : id
+ .toString());
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ @Override
+ public abstract Canvas getDetailsView(Integer id);
+
+ @Override
+ protected Integer convertCurrentViewPathToID(String path) {
+ return Integer.valueOf(path);
+ }
+
+ @Override
+ protected String convertIDToCurrentViewPath(Integer id) {
+ if (id == null) {
+ return "0";
+ }
+ return id.toString();
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
index 071e2de..f090bd8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
@@ -226,7 +226,7 @@ public class DriftConfigurationView extends TableSection<DriftConfigurationDataS
}
@Override
- public Canvas getDetailsView(int driftConfigId) {
+ public Canvas getDetailsView(Integer driftConfigId) {
return new DriftConfigurationEditView(extendLocatorId("ConfigEdit"), context, driftConfigId, hasWriteAccess);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
index f00640a..060c9d1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
@@ -42,9 +42,9 @@ import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.components.form.EnumSelectItem;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.StringIDTableSection;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableSection2;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -62,7 +62,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
*
* @author Jay Shaughnessy
*/
-public class DriftHistoryView extends TableSection2<DriftDataSource> {
+public class DriftHistoryView extends StringIDTableSection<DriftDataSource> {
public static final ViewName SUBSYSTEM_VIEW_ID = new ViewName("RecentDrifts", MSG.common_title_recent_drifts());
@@ -283,7 +283,6 @@ public class DriftHistoryView extends TableSection2<DriftDataSource> {
// });
// }
-
@Override
public Canvas getDetailsView(String driftId) {
return DriftDetailsView.getInstance();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
index fa623f1..e146f0e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
@@ -211,7 +211,7 @@ public class EventCompositeHistoryView extends TableSection<EventCompositeDataso
}
@Override
- public Canvas getDetailsView(int eventId) {
+ public Canvas getDetailsView(Integer eventId) {
return EventCompositeDetailsView.getInstance();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
index 7e1d548..4a6db81 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java
@@ -128,26 +128,26 @@ public class GroupDefinitionListView extends TableSection<GroupDefinitionDataSou
nextCalculationTimeField);
addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(), MSG.common_msg_areYouSure(),
- new AbstractTableAction(TableActionEnablement.ANY) {
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- final int[] groupDefinitionIds = TableUtility.getIds(selection);
- ResourceGroupGWTServiceAsync groupManager = GWTServiceLookup.getResourceGroupService(60000);
- groupManager.deleteGroupDefinitions(groupDefinitionIds, new AsyncCallback<Void>() {
- @Override
- public void onSuccess(Void result) {
- CoreGUI.getMessageCenter().notify(
- new Message(MSG.view_dynagroup_deleteSuccessfulSelection(String
- .valueOf(groupDefinitionIds.length)), Severity.Info));
- GroupDefinitionListView.this.refresh();
- }
-
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_dynagroup_deleteFailureSelection(), caught);
- }
- });
- }
- });
+ new AbstractTableAction(TableActionEnablement.ANY) {
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ final int[] groupDefinitionIds = TableUtility.getIds(selection);
+ ResourceGroupGWTServiceAsync groupManager = GWTServiceLookup.getResourceGroupService(60000);
+ groupManager.deleteGroupDefinitions(groupDefinitionIds, new AsyncCallback<Void>() {
+ @Override
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_dynagroup_deleteSuccessfulSelection(String
+ .valueOf(groupDefinitionIds.length)), Severity.Info));
+ GroupDefinitionListView.this.refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_dynagroup_deleteFailureSelection(), caught);
+ }
+ });
+ }
+ });
addTableAction(extendLocatorId("New"), MSG.common_button_new(), null, new AbstractTableAction() {
public void executeAction(ListGridRecord[] selection, Object actionValue) {
@@ -180,7 +180,7 @@ public class GroupDefinitionListView extends TableSection<GroupDefinitionDataSou
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
final SingleGroupDefinitionView singleGroupDefinitionView = new SingleGroupDefinitionView(this
.extendLocatorId("Details"));
return singleGroupDefinitionView;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java
index f1c7cfa..10d2cb9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/traits/TraitsView.java
@@ -74,7 +74,7 @@ public class TraitsView extends AbstractMeasurementDataTraitListView {
}
@Override
- public Canvas getDetailsView(int definitionId) {
+ public Canvas getDetailsView(Integer definitionId) {
return new TraitsDetailView(extendLocatorId("Detail"), this.groupId, definitionId);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java
index b9eb6bb..03dde04 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java
@@ -80,7 +80,7 @@ public class GroupMemberResourceOperationHistoryListView extends
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
return new ResourceOperationHistoryDetailsView(extendLocatorId("DetailsView"), true);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
index 8ad3170..ecf55ca 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupOperationHistoryListView.java
@@ -45,7 +45,7 @@ public class GroupOperationHistoryListView extends AbstractOperationHistoryListV
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
return new GroupOperationHistoryDetailsView(extendLocatorId("DetailsView"), this.groupComposite);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java
index 7f9c2f1..6561291 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java
@@ -20,6 +20,7 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.schedule;
import com.smartgwt.client.widgets.Canvas;
+
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleListView;
@@ -45,9 +46,8 @@ public class GroupOperationScheduleListView extends AbstractOperationScheduleLis
}
@Override
- public Canvas getDetailsView(int scheduleId) {
- return new GroupOperationScheduleDetailsView(extendLocatorId("DetailsView"),
- this.groupComposite, scheduleId);
+ public Canvas getDetailsView(Integer scheduleId) {
+ return new GroupOperationScheduleDetailsView(extendLocatorId("DetailsView"), this.groupComposite, scheduleId);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
index c445d32..50fbc30 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
@@ -58,7 +58,7 @@ public class ConfigurationHistoryView extends AbstractConfigurationHistoryView<C
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
ConfigurationHistoryDetailView detailView = new ConfigurationHistoryDetailView(this.getLocatorId());
return detailView;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryView.java
index fdd6657..4fad987 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationHistoryView.java
@@ -60,7 +60,7 @@ public class PluginConfigurationHistoryView extends
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
PluginConfigurationHistoryDetailView detailView = new PluginConfigurationHistoryDetailView(this.getLocatorId());
return detailView;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java
index 55a6f99..fe7b9ec 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/traits/TraitsView.java
@@ -38,7 +38,7 @@ public class TraitsView extends AbstractMeasurementDataTraitListView {
}
@Override
- public Canvas getDetailsView(int definitionId) {
+ public Canvas getDetailsView(Integer definitionId) {
return new TraitsDetailView(extendLocatorId("Detail"), this.resourceId, definitionId);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
index 3d64039..a222b73 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
@@ -47,7 +47,7 @@ public class ResourceOperationHistoryListView extends OperationHistoryView {
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
return new ResourceOperationHistoryDetailsView(this.extendLocatorId("DetailsView"));
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
index 221390c..859747a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
@@ -46,9 +46,9 @@ public class ResourceOperationScheduleListView extends AbstractOperationSchedule
}
@Override
- public Canvas getDetailsView(int scheduleId) {
- return new ResourceOperationScheduleDetailsView(extendLocatorId("DetailsView"),
- this.resourceComposite, scheduleId);
+ public Canvas getDetailsView(Integer scheduleId) {
+ return new ResourceOperationScheduleDetailsView(extendLocatorId("DetailsView"), this.resourceComposite,
+ scheduleId);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java
index 70a5ff9..5461aa0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java
@@ -23,13 +23,9 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
-import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.data.DSCallback;
import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.SortSpecifier;
import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.widgets.Canvas;
@@ -191,7 +187,8 @@ public class OperationHistoryView extends TableSection<OperationHistoryDataSourc
final List<Integer> successIds = new ArrayList<Integer>();
final List<Integer> failureIds = new ArrayList<Integer>();
for (ListGridRecord record : recordsToBeDeleted) {
- final ResourceOperationHistory operationHistoryToRemove = new OperationHistoryDataSource().copyValues(record);
+ final ResourceOperationHistory operationHistoryToRemove = new OperationHistoryDataSource()
+ .copyValues(record);
GWTServiceLookup.getOperationService().deleteOperationHistory(operationHistoryToRemove.getId(), force,
new AsyncCallback<Void>() {
public void onSuccess(Void result) {
@@ -202,7 +199,7 @@ public class OperationHistoryView extends TableSection<OperationHistoryDataSourc
public void onFailure(Throwable caught) {
// TODO: i18n
CoreGUI.getErrorHandler().handleError("Failed to delete " + operationHistoryToRemove + ".",
- caught);
+ caught);
failureIds.add(operationHistoryToRemove.getId());
handleCompletion(successIds, failureIds, numberOfRecordsToBeDeleted);
}
@@ -214,10 +211,13 @@ public class OperationHistoryView extends TableSection<OperationHistoryDataSourc
if ((successIds.size() + failureIds.size()) == numberOfRecordsToBeDeleted) {
// TODO: i18n
if (successIds.size() == numberOfRecordsToBeDeleted) {
- CoreGUI.getMessageCenter().notify(new Message("Deleted " + numberOfRecordsToBeDeleted + " operation history items."));
+ CoreGUI.getMessageCenter().notify(
+ new Message("Deleted " + numberOfRecordsToBeDeleted + " operation history items."));
} else {
- CoreGUI.getMessageCenter().notify(new Message("Deleted " + successIds.size()
- + " operation history items, but failed to delete the items with the following IDs: " + failureIds));
+ CoreGUI.getMessageCenter().notify(
+ new Message("Deleted " + successIds.size()
+ + " operation history items, but failed to delete the items with the following IDs: "
+ + failureIds));
}
refresh();
}
@@ -228,7 +228,7 @@ public class OperationHistoryView extends TableSection<OperationHistoryDataSourc
}
@Override
- public Canvas getDetailsView(int id) {
+ public Canvas getDetailsView(Integer id) {
return new ResourceOperationHistoryDetailsView(extendLocatorId("Detail"));
}
@@ -237,5 +237,4 @@ public class OperationHistoryView extends TableSection<OperationHistoryDataSourc
return OperationHistoryDataSource.Field.OPERATION_NAME;
}
-
}
commit 66bcc38c099082f3077f7cf5f1b0429cb826f2d8
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 29 15:13:12 2011 -0400
rename TableSection to AbstractTableSection to prepare for refactoring of the TableSection hierarchy
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java
new file mode 100644
index 0000000..df8a406
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/AbstractTableSection.java
@@ -0,0 +1,389 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.components.table;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.History;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.types.AnimationEffect;
+import com.smartgwt.client.types.VerticalAlignment;
+import com.smartgwt.client.widgets.AnimationCallback;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.events.DoubleClickEvent;
+import com.smartgwt.client.widgets.events.DoubleClickHandler;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.DetailsView;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
+
+/**
+ * @author Greg Hinkle
+ * @author John Mazzitelli
+ */
+public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> implements BookmarkableView {
+
+ private VLayout detailsHolder;
+ private Canvas detailsView;
+ private String basePath;
+ private boolean escapeHtmlInDetailsLinkColumn;
+ private boolean initialDisplay;
+
+ protected TableSection(String locatorId, String tableTitle) {
+ super(locatorId, tableTitle);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, Criteria criteria) {
+ super(locatorId, tableTitle, criteria);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, sortSpecifiers);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, sortSpecifiers, criteria);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, boolean autoFetchData) {
+ super(locatorId, tableTitle, autoFetchData);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames) {
+ super(locatorId, tableTitle, null, sortSpecifiers, excludedFieldNames);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames);
+ }
+
+ protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames, boolean autoFetchData) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames, autoFetchData);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ this.initialDisplay = true;
+
+ detailsHolder = new LocatableVLayout(extendLocatorId("tableSection"));
+ detailsHolder.setAlign(VerticalAlignment.TOP);
+ //detailsHolder.setWidth100();
+ //detailsHolder.setHeight100();
+ detailsHolder.setMargin(4);
+ detailsHolder.hide();
+
+ addMember(detailsHolder);
+
+ // if the detailsView is already defined it means we want the details view to be rendered prior to
+ // the master view, probably due to a direct navigation or refresh (like F5 when sitting on the details page)
+ if (null != detailsView) {
+ switchToDetailsView();
+ }
+ }
+
+ /**
+ * The default implementation wraps the {@link #getDetailsLinkColumnCellFormatter()} column with the
+ * {@link #getDetailsLinkColumnCellFormatter()}. This is typically the 'name' column linking to the detail
+ * view, given the 'id'. Also, establishes a double click handler for the row which invokes
+ * {@link #showDetails(com.smartgwt.client.widgets.grid.ListGridRecord)}</br>
+ * </br>
+ * In general, in overrides, call super.configureTable *after* manipulating the ListGrid fields.
+ *
+ * @see org.rhq.enterprise.gui.coregui.client.components.table.Table#configureTable()
+ */
+ @Override
+ protected void configureTable() {
+ if (isDetailsEnabled()) {
+ ListGrid grid = getListGrid();
+
+ // Make the value of some specific field a link to the details view for the corresponding record.
+ ListGridField field = (grid != null) ? grid.getField(getDetailsLinkColumnName()) : null;
+ if (field != null) {
+ field.setCellFormatter(getDetailsLinkColumnCellFormatter());
+ }
+
+ setListGridDoubleClickHandler(new DoubleClickHandler() {
+ @Override
+ public void onDoubleClick(DoubleClickEvent event) {
+ ListGrid listGrid = (ListGrid) event.getSource();
+ ListGridRecord[] selectedRows = listGrid.getSelection();
+ if (selectedRows != null && selectedRows.length == 1) {
+ showDetails(selectedRows[0]);
+ }
+ }
+ });
+ }
+ }
+
+ protected boolean isDetailsEnabled() {
+ return true;
+ }
+
+ public void setEscapeHtmlInDetailsLinkColumn(boolean escapeHtmlInDetailsLinkColumn) {
+ this.escapeHtmlInDetailsLinkColumn = escapeHtmlInDetailsLinkColumn;
+ }
+
+ /**
+ * Override if you don't want FIELD_NAME to be wrapped ina link.
+ * @return the name of the field to be wrapped, or null if no field should be wrapped.
+ */
+ protected String getDetailsLinkColumnName() {
+ return FIELD_NAME;
+ }
+
+ /**
+ * Override if you don't want the detailsLinkColumn to have the default link wrapper.
+ * @return the desired CellFormatter.
+ */
+ protected CellFormatter getDetailsLinkColumnCellFormatter() {
+ return new CellFormatter() {
+ public String format(Object value, ListGridRecord record, int i, int i1) {
+ if (value == null) {
+ return "";
+ }
+ Integer recordId = getId(record);
+ String detailsUrl = "#" + getBasePath() + "/" + recordId;
+ String formattedValue = (escapeHtmlInDetailsLinkColumn) ? StringUtility.escapeHtml(value.toString())
+ : value.toString();
+ return SeleniumUtility.getLocatableHref(detailsUrl, formattedValue, null);
+ }
+ };
+ }
+
+ /**
+ * Shows the details view for the given record of the table.
+ *
+ * The default implementation of this method assumes there is an
+ * id attribute on the record and passes it to {@link #showDetails(int)}.
+ * Subclasses are free to override this behavior. Subclasses usually
+ * will need to set the {@link #setDetailsView(Canvas) details view}
+ * explicitly.
+ *
+ * @param record the record whose details are to be shown
+ */
+ public void showDetails(ListGridRecord record) {
+ if (record == null) {
+ throw new IllegalArgumentException("'record' parameter is null.");
+ }
+
+ Integer id = getId(record);
+ showDetails(id);
+ }
+
+ /**
+ * Returns the details canvas with information on the item given its list grid record.
+ *
+ * The default implementation of this method is to assume there is an
+ * id attribute on the record and pass that ID to {@link #getDetailsView(int)}.
+ * Subclasses are free to override this - which you usually want to do
+ * if you know the full details of the item are stored in the record attributes
+ * and thus help avoid making a round trip to the DB.
+ *
+ * @param record the record of the item whose details to be shown; ; null if empty details view should be shown.
+ */
+ public Canvas getDetailsView(ListGridRecord record) {
+ Integer id = getId(record);
+ return getDetailsView(id);
+ }
+
+ protected Integer getId(ListGridRecord record) {
+ Integer id = (record != null) ? record.getAttributeAsInt("id") : 0;
+ if (id == null) {
+ String msg = MSG.view_tableSection_error_noId(this.getClass().toString());
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalStateException(msg);
+ }
+ return id;
+ }
+
+ /**
+ * Shows empty details for a new item being created.
+ * This method is usually called when a user clicks a 'New' button.
+ *
+ * @see #showDetails(ListGridRecord)
+ */
+ public void newDetails() {
+ History.newItem(basePath + "/0");
+ }
+
+ /**
+ * Shows the details for an item has the given ID.
+ * This method is usually called when a user goes to the details
+ * page via a bookmark, double-cick on a list view row, or direct link.
+ *
+ * @param id the id of the row whose details are to be shown; Should be a valid id, > 0.
+ *
+ * @see #showDetails(ListGridRecord)
+ *
+ * @throws IllegalArgumentException if id <= 0.
+ */
+ public void showDetails(int id) {
+ if (id > 0) {
+ History.newItem(basePath + "/" + id);
+ } else {
+ String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), Integer.toString(id));
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ /**
+ * Returns the details canvas with information on the item that has the given ID.
+ * Note that an empty details view should be returned if the id passed in is 0 (as would
+ * be the case if a new item is to be created using the details view).
+ *
+ * @param id the id of the details to be shown; will be 0 if an empty details view should be shown.
+ */
+ public abstract Canvas getDetailsView(int id);
+
+ @Override
+ public void renderView(ViewPath viewPath) {
+ this.basePath = viewPath.getPathToCurrent();
+
+ if (!viewPath.isEnd()) {
+ int id = Integer.parseInt(viewPath.getCurrent().getPath());
+ this.detailsView = getDetailsView(id);
+ if (this.detailsView instanceof BookmarkableView) {
+ ((BookmarkableView) this.detailsView).renderView(viewPath);
+ }
+
+ switchToDetailsView();
+ } else {
+ switchToTableView();
+ }
+ }
+
+ protected String getBasePath() {
+ return this.basePath;
+ }
+
+ /**
+ * For use by subclasses that want to define their own details view.
+ *
+ * @param detailsView the new details view
+ */
+ protected void setDetailsView(Canvas detailsView) {
+ this.detailsView = detailsView;
+ }
+
+ /**
+ * Switches to viewing the details canvas, hiding the table. This does not
+ * do anything with reloading data or switching to the selected row in the table;
+ * this only changes the visibility of canvases.
+ */
+ protected void switchToDetailsView() {
+ Canvas contents = getTableContents();
+
+ // If the Table has not yet been initialized then ignore
+ if (contents != null) {
+ if (contents.isVisible()) {
+ contents.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
+ @Override
+ public void execute(boolean b) {
+ buildDetailsView();
+ }
+ });
+ } else {
+ /*
+ * if the programmer chooses to go directly from the detailView in create-mode to the
+ * detailsView in edit-mode, the content canvas will already be hidden, which means the
+ * animateHide would be a no-op (the event won't fire). this causes the detailsHolder
+ * to keep a reference to the previous detailsView (the one in create-mode) instead of the
+ * newly returned reference from getDetailsView(int) that was called when the renderView
+ * methods were called hierarchically down to render the new detailsView in edit-mode.
+ * therefore, we need to explicitly destroy what's already there (presumably the detailsView
+ * in create-mode), and then rebuild it (presumably the detailsView in edit-mode).
+ */
+ SeleniumUtility.destroyMembers(detailsHolder);
+
+ buildDetailsView();
+ }
+ }
+ }
+
+ private void buildDetailsView() {
+ detailsView.setWidth100();
+ detailsView.setHeight100();
+
+ boolean isEditable = (detailsView instanceof DetailsView && ((DetailsView) detailsView).isEditable());
+ if (!isEditable) {
+ // Only add the "Back to List" button if the details are definitely not editable, because if they are
+ // editable, a Cancel button should already be provided by the details view.
+ BackButton backButton = new BackButton(extendLocatorId("BackButton"), MSG.view_tableSection_backButton(),
+ basePath);
+ detailsHolder.addMember(backButton);
+ VLayout verticalSpacer = new LocatableVLayout(extendLocatorId("verticalSpacer"));
+ verticalSpacer.setHeight(8);
+ detailsHolder.addMember(verticalSpacer);
+ }
+
+ detailsHolder.addMember(detailsView);
+ detailsHolder.animateShow(AnimationEffect.WIPE);
+ }
+
+ /**
+ * Switches to viewing the table, hiding the details canvas.
+ */
+ protected void switchToTableView() {
+ final Canvas contents = getTableContents();
+ if (contents != null) {
+ // If this is not the initial display of the table, refresh the table's data. Otherwise, a refresh would be
+ // redundant, since the data was just loaded when the table was drawn.
+ if (this.initialDisplay) {
+ this.initialDisplay = false;
+ } else {
+ Log.debug("Refreshing data for Table [" + getClass().getName() + "]...");
+ refresh();
+ }
+ if (detailsHolder != null && detailsHolder.isVisible()) {
+ detailsHolder.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
+ @Override
+ public void execute(boolean b) {
+ SeleniumUtility.destroyMembers(detailsHolder);
+
+ contents.animateShow(AnimationEffect.WIPE);
+ }
+ });
+ } else {
+ contents.animateShow(AnimationEffect.WIPE);
+ }
+ }
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
deleted file mode 100644
index df8a406..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.components.table;
-
-import com.allen_sauer.gwt.log.client.Log;
-import com.google.gwt.user.client.History;
-import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.data.SortSpecifier;
-import com.smartgwt.client.types.AnimationEffect;
-import com.smartgwt.client.types.VerticalAlignment;
-import com.smartgwt.client.widgets.AnimationCallback;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.events.DoubleClickEvent;
-import com.smartgwt.client.widgets.events.DoubleClickHandler;
-import com.smartgwt.client.widgets.grid.CellFormatter;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.layout.VLayout;
-
-import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.DetailsView;
-import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
-
-/**
- * @author Greg Hinkle
- * @author John Mazzitelli
- */
-public abstract class TableSection<DS extends RPCDataSource> extends Table<DS> implements BookmarkableView {
-
- private VLayout detailsHolder;
- private Canvas detailsView;
- private String basePath;
- private boolean escapeHtmlInDetailsLinkColumn;
- private boolean initialDisplay;
-
- protected TableSection(String locatorId, String tableTitle) {
- super(locatorId, tableTitle);
- }
-
- protected TableSection(String locatorId, String tableTitle, Criteria criteria) {
- super(locatorId, tableTitle, criteria);
- }
-
- protected TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
- super(locatorId, tableTitle, sortSpecifiers);
- }
-
- protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers) {
- super(locatorId, tableTitle, sortSpecifiers, criteria);
- }
-
- protected TableSection(String locatorId, String tableTitle, boolean autoFetchData) {
- super(locatorId, tableTitle, autoFetchData);
- }
-
- protected TableSection(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers,
- String[] excludedFieldNames) {
- super(locatorId, tableTitle, null, sortSpecifiers, excludedFieldNames);
- }
-
- protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
- String[] excludedFieldNames) {
- super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames);
- }
-
- protected TableSection(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
- String[] excludedFieldNames, boolean autoFetchData) {
- super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames, autoFetchData);
- }
-
- @Override
- protected void onInit() {
- super.onInit();
-
- this.initialDisplay = true;
-
- detailsHolder = new LocatableVLayout(extendLocatorId("tableSection"));
- detailsHolder.setAlign(VerticalAlignment.TOP);
- //detailsHolder.setWidth100();
- //detailsHolder.setHeight100();
- detailsHolder.setMargin(4);
- detailsHolder.hide();
-
- addMember(detailsHolder);
-
- // if the detailsView is already defined it means we want the details view to be rendered prior to
- // the master view, probably due to a direct navigation or refresh (like F5 when sitting on the details page)
- if (null != detailsView) {
- switchToDetailsView();
- }
- }
-
- /**
- * The default implementation wraps the {@link #getDetailsLinkColumnCellFormatter()} column with the
- * {@link #getDetailsLinkColumnCellFormatter()}. This is typically the 'name' column linking to the detail
- * view, given the 'id'. Also, establishes a double click handler for the row which invokes
- * {@link #showDetails(com.smartgwt.client.widgets.grid.ListGridRecord)}</br>
- * </br>
- * In general, in overrides, call super.configureTable *after* manipulating the ListGrid fields.
- *
- * @see org.rhq.enterprise.gui.coregui.client.components.table.Table#configureTable()
- */
- @Override
- protected void configureTable() {
- if (isDetailsEnabled()) {
- ListGrid grid = getListGrid();
-
- // Make the value of some specific field a link to the details view for the corresponding record.
- ListGridField field = (grid != null) ? grid.getField(getDetailsLinkColumnName()) : null;
- if (field != null) {
- field.setCellFormatter(getDetailsLinkColumnCellFormatter());
- }
-
- setListGridDoubleClickHandler(new DoubleClickHandler() {
- @Override
- public void onDoubleClick(DoubleClickEvent event) {
- ListGrid listGrid = (ListGrid) event.getSource();
- ListGridRecord[] selectedRows = listGrid.getSelection();
- if (selectedRows != null && selectedRows.length == 1) {
- showDetails(selectedRows[0]);
- }
- }
- });
- }
- }
-
- protected boolean isDetailsEnabled() {
- return true;
- }
-
- public void setEscapeHtmlInDetailsLinkColumn(boolean escapeHtmlInDetailsLinkColumn) {
- this.escapeHtmlInDetailsLinkColumn = escapeHtmlInDetailsLinkColumn;
- }
-
- /**
- * Override if you don't want FIELD_NAME to be wrapped ina link.
- * @return the name of the field to be wrapped, or null if no field should be wrapped.
- */
- protected String getDetailsLinkColumnName() {
- return FIELD_NAME;
- }
-
- /**
- * Override if you don't want the detailsLinkColumn to have the default link wrapper.
- * @return the desired CellFormatter.
- */
- protected CellFormatter getDetailsLinkColumnCellFormatter() {
- return new CellFormatter() {
- public String format(Object value, ListGridRecord record, int i, int i1) {
- if (value == null) {
- return "";
- }
- Integer recordId = getId(record);
- String detailsUrl = "#" + getBasePath() + "/" + recordId;
- String formattedValue = (escapeHtmlInDetailsLinkColumn) ? StringUtility.escapeHtml(value.toString())
- : value.toString();
- return SeleniumUtility.getLocatableHref(detailsUrl, formattedValue, null);
- }
- };
- }
-
- /**
- * Shows the details view for the given record of the table.
- *
- * The default implementation of this method assumes there is an
- * id attribute on the record and passes it to {@link #showDetails(int)}.
- * Subclasses are free to override this behavior. Subclasses usually
- * will need to set the {@link #setDetailsView(Canvas) details view}
- * explicitly.
- *
- * @param record the record whose details are to be shown
- */
- public void showDetails(ListGridRecord record) {
- if (record == null) {
- throw new IllegalArgumentException("'record' parameter is null.");
- }
-
- Integer id = getId(record);
- showDetails(id);
- }
-
- /**
- * Returns the details canvas with information on the item given its list grid record.
- *
- * The default implementation of this method is to assume there is an
- * id attribute on the record and pass that ID to {@link #getDetailsView(int)}.
- * Subclasses are free to override this - which you usually want to do
- * if you know the full details of the item are stored in the record attributes
- * and thus help avoid making a round trip to the DB.
- *
- * @param record the record of the item whose details to be shown; ; null if empty details view should be shown.
- */
- public Canvas getDetailsView(ListGridRecord record) {
- Integer id = getId(record);
- return getDetailsView(id);
- }
-
- protected Integer getId(ListGridRecord record) {
- Integer id = (record != null) ? record.getAttributeAsInt("id") : 0;
- if (id == null) {
- String msg = MSG.view_tableSection_error_noId(this.getClass().toString());
- CoreGUI.getErrorHandler().handleError(msg);
- throw new IllegalStateException(msg);
- }
- return id;
- }
-
- /**
- * Shows empty details for a new item being created.
- * This method is usually called when a user clicks a 'New' button.
- *
- * @see #showDetails(ListGridRecord)
- */
- public void newDetails() {
- History.newItem(basePath + "/0");
- }
-
- /**
- * Shows the details for an item has the given ID.
- * This method is usually called when a user goes to the details
- * page via a bookmark, double-cick on a list view row, or direct link.
- *
- * @param id the id of the row whose details are to be shown; Should be a valid id, > 0.
- *
- * @see #showDetails(ListGridRecord)
- *
- * @throws IllegalArgumentException if id <= 0.
- */
- public void showDetails(int id) {
- if (id > 0) {
- History.newItem(basePath + "/" + id);
- } else {
- String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), Integer.toString(id));
- CoreGUI.getErrorHandler().handleError(msg);
- throw new IllegalArgumentException(msg);
- }
- }
-
- /**
- * Returns the details canvas with information on the item that has the given ID.
- * Note that an empty details view should be returned if the id passed in is 0 (as would
- * be the case if a new item is to be created using the details view).
- *
- * @param id the id of the details to be shown; will be 0 if an empty details view should be shown.
- */
- public abstract Canvas getDetailsView(int id);
-
- @Override
- public void renderView(ViewPath viewPath) {
- this.basePath = viewPath.getPathToCurrent();
-
- if (!viewPath.isEnd()) {
- int id = Integer.parseInt(viewPath.getCurrent().getPath());
- this.detailsView = getDetailsView(id);
- if (this.detailsView instanceof BookmarkableView) {
- ((BookmarkableView) this.detailsView).renderView(viewPath);
- }
-
- switchToDetailsView();
- } else {
- switchToTableView();
- }
- }
-
- protected String getBasePath() {
- return this.basePath;
- }
-
- /**
- * For use by subclasses that want to define their own details view.
- *
- * @param detailsView the new details view
- */
- protected void setDetailsView(Canvas detailsView) {
- this.detailsView = detailsView;
- }
-
- /**
- * Switches to viewing the details canvas, hiding the table. This does not
- * do anything with reloading data or switching to the selected row in the table;
- * this only changes the visibility of canvases.
- */
- protected void switchToDetailsView() {
- Canvas contents = getTableContents();
-
- // If the Table has not yet been initialized then ignore
- if (contents != null) {
- if (contents.isVisible()) {
- contents.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
- @Override
- public void execute(boolean b) {
- buildDetailsView();
- }
- });
- } else {
- /*
- * if the programmer chooses to go directly from the detailView in create-mode to the
- * detailsView in edit-mode, the content canvas will already be hidden, which means the
- * animateHide would be a no-op (the event won't fire). this causes the detailsHolder
- * to keep a reference to the previous detailsView (the one in create-mode) instead of the
- * newly returned reference from getDetailsView(int) that was called when the renderView
- * methods were called hierarchically down to render the new detailsView in edit-mode.
- * therefore, we need to explicitly destroy what's already there (presumably the detailsView
- * in create-mode), and then rebuild it (presumably the detailsView in edit-mode).
- */
- SeleniumUtility.destroyMembers(detailsHolder);
-
- buildDetailsView();
- }
- }
- }
-
- private void buildDetailsView() {
- detailsView.setWidth100();
- detailsView.setHeight100();
-
- boolean isEditable = (detailsView instanceof DetailsView && ((DetailsView) detailsView).isEditable());
- if (!isEditable) {
- // Only add the "Back to List" button if the details are definitely not editable, because if they are
- // editable, a Cancel button should already be provided by the details view.
- BackButton backButton = new BackButton(extendLocatorId("BackButton"), MSG.view_tableSection_backButton(),
- basePath);
- detailsHolder.addMember(backButton);
- VLayout verticalSpacer = new LocatableVLayout(extendLocatorId("verticalSpacer"));
- verticalSpacer.setHeight(8);
- detailsHolder.addMember(verticalSpacer);
- }
-
- detailsHolder.addMember(detailsView);
- detailsHolder.animateShow(AnimationEffect.WIPE);
- }
-
- /**
- * Switches to viewing the table, hiding the details canvas.
- */
- protected void switchToTableView() {
- final Canvas contents = getTableContents();
- if (contents != null) {
- // If this is not the initial display of the table, refresh the table's data. Otherwise, a refresh would be
- // redundant, since the data was just loaded when the table was drawn.
- if (this.initialDisplay) {
- this.initialDisplay = false;
- } else {
- Log.debug("Refreshing data for Table [" + getClass().getName() + "]...");
- refresh();
- }
- if (detailsHolder != null && detailsHolder.isVisible()) {
- detailsHolder.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
- @Override
- public void execute(boolean b) {
- SeleniumUtility.destroyMembers(detailsHolder);
-
- contents.animateShow(AnimationEffect.WIPE);
- }
- });
- } else {
- contents.animateShow(AnimationEffect.WIPE);
- }
- }
- }
-
-}
commit 276d4aa49f568399f5adb35134647e84a119aff9
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 29 15:23:28 2011 -0400
Need to copy resource id filer into jpa criteria object
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index 54eda95..8e4d1f7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@ -66,11 +66,11 @@ import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.drift.DriftFile;
-import org.rhq.core.domain.drift.RhqDriftFile;
import org.rhq.core.domain.drift.DriftFileBits;
import org.rhq.core.domain.drift.DriftFileStatus;
import org.rhq.core.domain.drift.RhqDrift;
import org.rhq.core.domain.drift.RhqDriftChangeSet;
+import org.rhq.core.domain.drift.RhqDriftFile;
import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
diff --git a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
index bed8bd5..1755d3e 100644
--- a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
@@ -110,6 +110,7 @@ public class DriftServerPluginComponent implements DriftServerPluginFacet {
private DriftChangeSetJPACriteria toJPACriteria(DriftChangeSetCriteria criteria) {
DriftChangeSetJPACriteria jpaCriteria = new DriftChangeSetJPACriteria();
jpaCriteria.addFilterId(criteria.getFilterId());
+ jpaCriteria.addFilterResourceId(criteria.getFilterResourceId());
jpaCriteria.addFilterCategory(criteria.getFilterCategory());
jpaCriteria.addFilterCreatedAfter(criteria.getFilterCreatedAfter());
jpaCriteria.addFilterCreatedBefore(criteria.getFilterCreatedBefore());
commit f557f05fa617968bd151a83765b0fa0dcf98a5e5
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 29 13:57:20 2011 -0400
fixing import
diff --git a/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java b/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java
index 622108f..da296f9 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java
@@ -6,7 +6,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import static junitx.util.Converter.asList;
+import static java.util.Arrays.asList;
public class CollectionMatchesChecker<T> {
commit 7e9ec31437b8b547bb1c048113081031b86a9721
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 29 13:47:51 2011 -0400
Fix filter overrides for range filters
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
index 6c17877..7a7f78f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
@@ -39,9 +39,9 @@ public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSe
private Integer filterId;
private Integer filterInitial; // needs override
private Integer filterResourceId; // needs override
- private String filterVersion;
- private String filterStartVersion;
- private String filterEndVersion;
+ private Integer filterVersion;
+ private Integer filterStartVersion;
+ private Integer filterEndVersion;
private Long filterCreatedAfter;
private Long filterCreatedBefore;
private DriftChangeSetCategory filterCategory;
@@ -52,10 +52,10 @@ public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSe
public DriftChangeSetJPACriteria() {
filterOverrides.put("initial", "version = 0");
filterOverrides.put("resourceId", "resource.id = ?");
- filterOverrides.put("filterStartVersion", "version >= ?");
- filterOverrides.put("filterEndVersion", "version <= ?");
- filterOverrides.put("filterCreatedAfter", "ctime >= ?");
- filterOverrides.put("filterCreatedBefore", "ctime <= ?");
+ filterOverrides.put("startVersion", "version >= ?");
+ filterOverrides.put("endVersion", "version <= ?");
+ filterOverrides.put("createdAfter", "ctime >= ?");
+ filterOverrides.put("createdBefore", "ctime <= ?");
}
@Override
@@ -75,32 +75,38 @@ public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSe
}
public void addFilterVersion(String filterVersion) {
- this.filterVersion = filterVersion;
+ if (filterVersion != null) {
+ this.filterVersion = Integer.parseInt(filterVersion);
+ }
}
@Override
public String getFilterVersion() {
- return filterVersion;
+ return filterVersion == null ? null : filterVersion.toString();
}
@Override
public void addFilterStartVersion(String filterStartVersion) {
- this.filterStartVersion = filterStartVersion;
+ if (filterStartVersion != null) {
+ this.filterStartVersion = Integer.parseInt(filterStartVersion);
+ }
}
@Override
public String getFilterStartVersion() {
- return filterStartVersion;
+ return filterStartVersion == null ? null : filterStartVersion.toString();
}
@Override
public void addFilterEndVersion(String filterEndVersion) {
- this.filterEndVersion = filterEndVersion;
+ if (filterEndVersion != null) {
+ this.filterEndVersion = Integer.parseInt(filterEndVersion);
+ }
}
@Override
public String getFilterEndVersion() {
- return filterEndVersion;
+ return filterEndVersion == null ? null : filterEndVersion.toString();
}
@Override
commit 921524020da4ac5149eafeea5cfd89ccc2ce849a
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 29 12:30:46 2011 -0400
Prepend directory in path of file entries
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
index c24099a..bc88533 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
@@ -37,6 +37,7 @@ import org.rhq.core.domain.drift.dto.DriftFileDTO;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.ZipUtil;
+import org.rhq.core.util.file.FileUtil;
import org.rhq.enterprise.server.plugin.pc.ServerPluginContext;
import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginFacet;
import org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSet;
@@ -100,9 +101,11 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
for (DirectoryEntry dirEntry : reader) {
for (FileEntry fileEntry : dirEntry) {
+ String path = new File(dirEntry.getDirectory(), fileEntry.getFile()).getPath();
+ path = FileUtil.useForwardSlash(path);
MongoDBChangeSetEntry entry = new MongoDBChangeSetEntry();
entry.setCategory(fileEntry.getType());
- entry.setPath(fileEntry.getFile());
+ entry.setPath(path);
changeSet.add(entry);
}
}
commit 7ac71a20e868119305be5afb400570a0ac3cbdf7
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 29 11:59:25 2011 -0400
Adding DriftServer to remote client for use from CLI
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqFacade.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqFacade.java
index a965cb9..8538d9a 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqFacade.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqFacade.java
@@ -32,6 +32,7 @@ import org.rhq.enterprise.server.content.ContentManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.drift.DriftManagerRemote;
+import org.rhq.enterprise.server.drift.DriftServerRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
import org.rhq.enterprise.server.install.remote.RemoteInstallManagerRemote;
import org.rhq.enterprise.server.measurement.AvailabilityManagerRemote;
@@ -89,6 +90,8 @@ public interface RhqFacade {
DiscoveryBossRemote getDiscoveryBoss();
+ DriftServerRemote getDriftServer();
+
DriftManagerRemote getDriftManager();
EventManagerRemote getEventManager();
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManagers.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManagers.java
index 473d95e..ff632d7 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManagers.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManagers.java
@@ -29,6 +29,7 @@ import org.rhq.enterprise.server.content.ContentManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.drift.DriftManagerRemote;
+import org.rhq.enterprise.server.drift.DriftServerRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
import org.rhq.enterprise.server.install.remote.RemoteInstallManagerRemote;
import org.rhq.enterprise.server.measurement.AvailabilityManagerRemote;
@@ -64,6 +65,7 @@ public enum RhqManagers {
ConfigurationManager(ConfigurationManagerRemote.class), //
ContentManager(ContentManagerRemote.class), //
DataAccessManager(DataAccessManagerRemote.class), //
+ DriftServer(DriftServerRemote.class),
DriftManager(DriftManagerRemote.class), //
DiscoveryBoss(DiscoveryBossRemote.class), //
EventManager(EventManagerRemote.class), //
diff --git a/modules/enterprise/binding/src/test/java/org/rhq/bindings/FakeRhqFacade.java b/modules/enterprise/binding/src/test/java/org/rhq/bindings/FakeRhqFacade.java
index 4fb2364..6060d9e 100644
--- a/modules/enterprise/binding/src/test/java/org/rhq/bindings/FakeRhqFacade.java
+++ b/modules/enterprise/binding/src/test/java/org/rhq/bindings/FakeRhqFacade.java
@@ -34,6 +34,7 @@ import org.rhq.enterprise.server.content.ContentManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.drift.DriftManagerRemote;
+import org.rhq.enterprise.server.drift.DriftServerRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
import org.rhq.enterprise.server.install.remote.RemoteInstallManagerRemote;
import org.rhq.enterprise.server.measurement.AvailabilityManagerRemote;
@@ -179,6 +180,10 @@ public class FakeRhqFacade implements RhqFacade {
return null;
}
+ public DriftServerRemote getDriftServer() {
+ return null;
+ }
+
@Override
public DriftManagerRemote getDriftManager() {
return null;
diff --git a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
index 0460864..2d9973d 100644
--- a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
+++ b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
@@ -44,6 +44,7 @@ import org.rhq.enterprise.server.content.ContentManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.drift.DriftManagerRemote;
+import org.rhq.enterprise.server.drift.DriftServerRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
import org.rhq.enterprise.server.install.remote.RemoteInstallManagerRemote;
import org.rhq.enterprise.server.measurement.AvailabilityManagerRemote;
@@ -275,6 +276,10 @@ public class RemoteClient implements RhqFacade {
return RemoteClientProxy.getProcessor(this, RhqManagers.CallTimeDataManager);
}
+ public DriftServerRemote getDriftServer() {
+ return RemoteClientProxy.getProcessor(this, RhqManagers.DriftServer);
+ }
+
public DriftManagerRemote getDriftManager() {
return RemoteClientProxy.getProcessor(this, RhqManagers.DriftManager);
}
diff --git a/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClient.java b/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClient.java
index 96778f9..b3c2b8c 100644
--- a/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClient.java
+++ b/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClient.java
@@ -41,6 +41,7 @@ import org.rhq.enterprise.server.content.ContentManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.drift.DriftManagerRemote;
+import org.rhq.enterprise.server.drift.DriftServerRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
import org.rhq.enterprise.server.install.remote.RemoteInstallManagerRemote;
import org.rhq.enterprise.server.measurement.AvailabilityManagerRemote;
@@ -132,6 +133,10 @@ public class LocalClient implements RhqFacade {
return getProxy(LookupUtil.getDiscoveryBoss(), DiscoveryBossRemote.class);
}
+ public DriftServerRemote getDriftServer() {
+ return getProxy(LookupUtil.getDriftServer(), DriftServerRemote.class);
+ }
+
public DriftManagerRemote getDriftManager() {
return getProxy(LookupUtil.getDriftManager(), DriftManagerRemote.class);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
index 005ed8b..f66c3ab 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
@@ -19,7 +19,6 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
@@ -41,7 +40,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
import static javax.ejb.TransactionAttributeType.NOT_SUPPORTED;
@Stateless
-public class DriftServerBean implements DriftServerLocal {
+public class DriftServerBean implements DriftServerLocal, DriftServerRemote {
// TODO Should security checks be handled here instead of delegating to the drift plugin?
// Currently any security checks that need to be performed are delegated to the plugin.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerRemote.java
new file mode 100644
index 0000000..a3dc30b
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerRemote.java
@@ -0,0 +1,18 @@
+package org.rhq.enterprise.server.drift;
+
+import javax.ejb.Remote;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.Snapshot;
+import org.rhq.core.domain.util.PageList;
+
+@Remote
+public interface DriftServerRemote {
+
+ PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria);
+
+ Snapshot createSnapshot(Subject subject, DriftChangeSetCriteria criteria);
+
+}
commit 4fc7ef6434bcfab86d8b2459e3f263106606267b
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 29 07:06:15 2011 -0400
createSnapshot method in drift server api needs to use criteria interfaces
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
index 10f72f5..cc7c6f0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
@@ -118,7 +118,7 @@ public interface DriftGWTService extends RemoteService {
PageList<DriftComposite> findDriftCompositesByCriteria(DriftCriteria criteria);
- Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria);
+ Snapshot createSnapshot(Subject subject, DriftChangeSetCriteria criteria);
/**
* Get the specified drift configuration for the specified context.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
index b440ffd..cb44a90 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
@@ -21,7 +21,6 @@ package org.rhq.enterprise.gui.coregui.server.gwt;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
@@ -125,7 +124,7 @@ public class DriftGWTServiceImpl extends AbstractGWTServiceImpl implements Drift
}
@Override
- public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
+ public Snapshot createSnapshot(Subject subject, DriftChangeSetCriteria criteria) {
try {
return driftServer.createSnapshot(subject, criteria);
} catch (Throwable t) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
index 9de0966..005ed8b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
@@ -98,7 +98,7 @@ public class DriftServerBean implements DriftServerLocal {
@Override
@TransactionAttribute(NOT_SUPPORTED)
- public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
+ public Snapshot createSnapshot(Subject subject, DriftChangeSetCriteria criteria) {
DriftServerPluginFacet driftServerPlugin = getServerPlugin();
return driftServerPlugin.createSnapshot(subject, criteria);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
index 5046e83..eda3a4f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
@@ -7,7 +7,6 @@ import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
@@ -35,6 +34,6 @@ public interface DriftServerLocal {
PageList<DriftComposite> findDriftCompositesByCriteria(Subject subject, DriftCriteria criteria);
- Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria);
+ Snapshot createSnapshot(Subject subject, DriftChangeSetCriteria criteria);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
index 867464d..5a57837 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
@@ -50,5 +50,5 @@ public interface DriftServerPluginFacet extends ServerPluginComponent {
void saveChangeSetFiles(File changeSetFilesZip) throws Exception;
- Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria);
+ Snapshot createSnapshot(Subject subject, DriftChangeSetCriteria criteria);
}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
index bc9feaa..c24099a 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
@@ -25,7 +25,6 @@ import org.rhq.common.drift.FileEntry;
import org.rhq.common.drift.Headers;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.drift.Drift;
@@ -165,7 +164,7 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
}
@Override
- public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
+ public Snapshot createSnapshot(Subject subject, DriftChangeSetCriteria criteria) {
return null;
}
diff --git a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
index 78d7843..bed8bd5 100644
--- a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
@@ -102,9 +102,9 @@ public class DriftServerPluginComponent implements DriftServerPluginFacet {
}
@Override
- public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
+ public Snapshot createSnapshot(Subject subject, DriftChangeSetCriteria criteria) {
DriftManagerLocal driftMgr = getDriftManager();
- return driftMgr.createSnapshot(subject, criteria);
+ return driftMgr.createSnapshot(subject, toJPACriteria(criteria));
}
private DriftChangeSetJPACriteria toJPACriteria(DriftChangeSetCriteria criteria) {
commit 0f7a3a150bc05d585706e0c059d5e09727298b40
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 29 00:44:28 2011 -0400
Updating drift-mongodb plugin to display drift details (still POC)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java
index 50b4634..8453713 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java
@@ -32,8 +32,8 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.tree.TreeNode;
import org.rhq.core.domain.criteria.BaseCriteria;
+import org.rhq.core.domain.criteria.BasicDriftChangeSetCriteria;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.criteria.DriftJPACriteria;
import org.rhq.core.domain.drift.Drift;
@@ -177,7 +177,7 @@ public abstract class AbstractDriftChangeSetsTreeDataSource extends RPCDataSourc
* @return the criteria to use when querying for change setss
*/
protected DriftChangeSetCriteria getDriftChangeSetCriteria(final DSRequest request) {
- DriftChangeSetCriteria criteria = new DriftChangeSetJPACriteria();
+ BasicDriftChangeSetCriteria criteria = new BasicDriftChangeSetCriteria();
criteria.addSortVersion(PageOrdering.DESC);
criteria.setPageControl(getPageControl(request));
return criteria;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
index 0e3f7ed..0d59be8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
@@ -37,8 +37,8 @@ import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.criteria.BasicDriftCriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
-import org.rhq.core.domain.criteria.DriftJPACriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.core.domain.drift.DriftComposite;
@@ -263,7 +263,7 @@ public class DriftDataSource extends RPCDataSource<DriftComposite, DriftCriteria
return null; // user didn't select any priorities - return null to indicate no data should be displayed
}
- DriftJPACriteria criteria = new DriftJPACriteria();
+ BasicDriftCriteria criteria = new BasicDriftCriteria();
criteria.fetchChangeSet(true);
criteria.addFilterCategories(categoriesFilter);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
index 2582a49..6f4bbf2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
@@ -27,8 +27,7 @@ import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import org.rhq.core.domain.criteria.DriftCriteria;
-import org.rhq.core.domain.criteria.DriftJPACriteria;
+import org.rhq.core.domain.criteria.BasicDriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
@@ -62,7 +61,7 @@ public class DriftDetailsView extends LocatableVLayout implements BookmarkableVi
}
private void show(String driftId) {
- DriftCriteria criteria = new DriftJPACriteria();
+ BasicDriftCriteria criteria = new BasicDriftCriteria();
criteria.addFilterId(driftId);
criteria.fetchChangeSet(true);
GWTServiceLookup.getDriftService().findDriftsByCriteria(criteria, new AsyncCallback<PageList<Drift>>() {
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
index c90594a..bc9feaa 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
@@ -16,6 +16,7 @@ import com.mongodb.Mongo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.bson.types.ObjectId;
import org.rhq.common.drift.ChangeSetReader;
import org.rhq.common.drift.ChangeSetReaderImpl;
@@ -33,6 +34,7 @@ import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.drift.dto.DriftChangeSetDTO;
import org.rhq.core.domain.drift.dto.DriftDTO;
+import org.rhq.core.domain.drift.dto.DriftFileDTO;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.ZipUtil;
@@ -124,7 +126,23 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
@Override
public PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria) {
- return new PageList<Drift>();
+ String[] idFields = criteria.getFilterId().split(":");
+ ObjectId changeSetId = new ObjectId(idFields[0]);
+ String path = idFields[1];
+ Query<MongoDBChangeSet> query = ds.createQuery(MongoDBChangeSet.class)
+ .filter("id = ", changeSetId)
+ .filter("files.path = ", path);
+
+ PageList results = new PageList<DriftDTO>();
+
+ for (MongoDBChangeSet changeSet : query) {
+ DriftChangeSetDTO changeSetDTO = toDTO(changeSet);
+ for (MongoDBChangeSetEntry entry : changeSet.getDrifts()) {
+ results.add((toDTO(entry, changeSetDTO)));
+ }
+ }
+
+ return (PageList<Drift>) results;
}
@Override
@@ -185,6 +203,13 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
dto.setPath(entry.getPath());
dto.setCategory(entry.getCategory());
+ DriftFileDTO fileDTO = new DriftFileDTO();
+ fileDTO.setHashId("1a2b3c4e5f");
+
+ dto.setOldDriftFile(fileDTO);
+ dto.setNewDriftFile(fileDTO);
+
return dto;
}
+
}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
index 6aff9aa..cfdc802 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
@@ -1,5 +1,7 @@
package org.rhq.enterprise.server.plugins.drift.mongodb.entities;
+import java.util.List;
+
import com.google.code.morphia.Datastore;
import com.google.code.morphia.Morphia;
import com.google.code.morphia.query.Query;
@@ -14,6 +16,7 @@ import org.rhq.core.domain.drift.DriftCategory;
import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
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.assertNotNull;
public class MongoDBChangeSetTest {
@@ -72,4 +75,21 @@ public class MongoDBChangeSetTest {
"changeSet");
}
+ @Test
+ public void saveAndFindChangeSetById() throws Exception {
+ MongoDBChangeSet expected = new MongoDBChangeSet();
+ expected.setCategory(COVERAGE);
+ expected.setVersion(1);
+ expected.setDriftConfigurationId(1);
+
+ ds.save(expected);
+
+ List<MongoDBChangeSet> results = ds.createQuery(MongoDBChangeSet.class)
+ .filter("id = ", expected.getObjectId())
+ .asList();
+
+ assertEquals(results.size(), 1, "Expected to get back one change set");
+
+ }
+
}
diff --git a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
index 8d4cae4..78d7843 100644
--- a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
@@ -73,15 +73,8 @@ public class DriftServerPluginComponent implements DriftServerPluginFacet {
@Override
public PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria) {
- DriftChangeSetJPACriteria jpaCriteria = new DriftChangeSetJPACriteria();
- jpaCriteria.addFilterId(criteria.getFilterId());
- jpaCriteria.addFilterResourceId(criteria.getFilterResourceId());
- jpaCriteria.addFilterVersion(criteria.getFilterVersion());
- jpaCriteria.addFilterCategory(criteria.getFilterCategory());
- jpaCriteria.fetchDrifts(criteria.isFetchDrifts());
-
PageList<? extends DriftChangeSet> results = getDriftManager().findDriftChangeSetsByCriteria(subject,
- jpaCriteria);
+ toJPACriteria(criteria));
return (PageList<DriftChangeSet>) results;
}
@@ -114,6 +107,21 @@ public class DriftServerPluginComponent implements DriftServerPluginFacet {
return driftMgr.createSnapshot(subject, criteria);
}
+ private DriftChangeSetJPACriteria toJPACriteria(DriftChangeSetCriteria criteria) {
+ DriftChangeSetJPACriteria jpaCriteria = new DriftChangeSetJPACriteria();
+ jpaCriteria.addFilterId(criteria.getFilterId());
+ jpaCriteria.addFilterCategory(criteria.getFilterCategory());
+ jpaCriteria.addFilterCreatedAfter(criteria.getFilterCreatedAfter());
+ jpaCriteria.addFilterCreatedBefore(criteria.getFilterCreatedBefore());
+ jpaCriteria.addFilterEndVersion(criteria.getFilterEndVersion());
+ jpaCriteria.addFilterStartVersion(criteria.getFilterStartVersion());
+ jpaCriteria.addFilterVersion(criteria.getFilterVersion());
+ jpaCriteria.addSortVersion(criteria.getSortVersion());
+ jpaCriteria.fetchDrifts(criteria.isFetchDrifts());
+
+ return jpaCriteria;
+ }
+
private DriftJPACriteria toJPACriteria(DriftCriteria criteria) {
DriftJPACriteria jpaCriteria = new DriftJPACriteria();
jpaCriteria.addFilterId(criteria.getFilterId());
commit 756469b8265282e85dd8405547ee3b6e3a06a625
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 28 21:48:04 2011 -0400
Initial commit for "basic" criteria classes
coregui needs to use the basic criteria classes and not the JPA criteria
classes. The JPA criteria classes convert string ids to integers, and
this results in an exception when using a drift server plugin other than
the default.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftChangeSetCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftChangeSetCriteria.java
new file mode 100644
index 0000000..2debece
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftChangeSetCriteria.java
@@ -0,0 +1,142 @@
+package org.rhq.core.domain.criteria;
+
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageOrdering;
+
+public class BasicDriftChangeSetCriteria implements DriftChangeSetCriteria {
+
+ private static final long serialVersionUID = 1L;
+
+ private String filterId;
+
+ private String filterVersion;
+
+ private String filterStartVersion;
+
+ private String filterEndVersion;
+
+ private Long filterCreatedAfter;
+
+ private Long filterCreatedBefore;
+
+ private Integer filterResourceId;
+
+ private DriftChangeSetCategory filterCategory;
+
+ private boolean fetchDrifts;
+
+ private PageOrdering sortVersion;
+
+ private PageControl pageControl;
+
+ @Override
+ public void addFilterId(String filterId) {
+ this.filterId = filterId;
+ }
+
+ @Override
+ public String getFilterId() {
+ return filterId;
+ }
+
+ @Override
+ public void addFilterVersion(String filterVersion) {
+ this.filterVersion = filterVersion;
+ }
+
+ @Override
+ public String getFilterVersion() {
+ return filterVersion;
+ }
+
+ @Override
+ public void addFilterStartVersion(String filterStartVersion) {
+ this.filterStartVersion = filterStartVersion;
+ }
+
+ @Override
+ public String getFilterStartVersion() {
+ return filterStartVersion;
+ }
+
+ @Override
+ public void addFilterEndVersion(String filterEndVersion) {
+ this.filterEndVersion = filterEndVersion;
+ }
+
+ @Override
+ public String getFilterEndVersion() {
+ return filterEndVersion;
+ }
+
+ @Override
+ public void addFilterCreatedAfter(Long filterCreatedAfter) {
+ this.filterCreatedAfter = filterCreatedAfter;
+ }
+
+ @Override
+ public Long getFilterCreatedAfter() {
+ return filterCreatedAfter;
+ }
+
+ @Override
+ public void addFilterCreatedBefore(Long filterCreatedBefore) {
+ this.filterCreatedBefore = filterCreatedBefore;
+ }
+
+ @Override
+ public Long getFilterCreatedBefore() {
+ return filterCreatedBefore;
+ }
+
+ @Override
+ public void addFilterResourceId(Integer filterResourceId) {
+ this.filterResourceId = filterResourceId;
+ }
+
+ @Override
+ public Integer getFilterResourceId() {
+ return filterResourceId;
+ }
+
+ @Override
+ public void addFilterCategory(DriftChangeSetCategory filterCategory) {
+ this.filterCategory = filterCategory;
+ }
+
+ @Override
+ public DriftChangeSetCategory getFilterCategory() {
+ return filterCategory;
+ }
+
+ @Override
+ public void fetchDrifts(boolean fetchDrifts) {
+ this.fetchDrifts = fetchDrifts;
+ }
+
+ @Override
+ public boolean isFetchDrifts() {
+ return fetchDrifts;
+ }
+
+ @Override
+ public void addSortVersion(PageOrdering sortVersion) {
+ this.sortVersion = sortVersion;
+ }
+
+ @Override
+ public PageOrdering getSortVersion() {
+ return sortVersion;
+ }
+
+ @Override
+ public PageControl getPageControlOverrides() {
+ return pageControl;
+ }
+
+ @Override
+ public void setPageControl(PageControl pageControl) {
+ this.pageControl = pageControl;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftCriteria.java
new file mode 100644
index 0000000..b1a5695
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BasicDriftCriteria.java
@@ -0,0 +1,135 @@
+package org.rhq.core.domain.criteria;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.rhq.core.domain.drift.DriftCategory;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageOrdering;
+
+import static org.rhq.core.domain.util.CriteriaUtils.getListIgnoringNulls;
+
+public class BasicDriftCriteria implements DriftCriteria {
+
+ private static final long serialVersionUID = 1L;
+
+ private String filterId;
+
+ private List<DriftCategory> filterCategories = new ArrayList<DriftCategory>();
+
+ private String filterChangeSetId;
+
+ private String filterPath;
+
+ private List<Integer> filterResourceIds = new ArrayList<Integer>();
+
+ private boolean fetchChangeSet;
+
+ private Long filterStartTime;
+
+ private Long filterEndTime;
+
+ private PageControl pageControl;
+
+ private PageOrdering sortCtime;
+
+ @Override
+ public void addFilterId(String filterId) {
+ this.filterId = filterId;
+ }
+
+ @Override
+ public String getFilterId() {
+ return filterId;
+ }
+
+ @Override
+ public void addFilterCategories(DriftCategory... filterCategories) {
+ this.filterCategories = getListIgnoringNulls(filterCategories);
+ }
+
+ @Override
+ public List<DriftCategory> getFilterCategories() {
+ return filterCategories;
+ }
+
+ @Override
+ public void addFilterChangeSetId(String filterChangeSetId) {
+ this.filterChangeSetId = filterChangeSetId;
+ }
+
+ @Override
+ public String getFilterChangeSetId() {
+ return filterChangeSetId;
+ }
+
+ @Override
+ public void addFilterPath(String filterPath) {
+ this.filterPath = filterPath;
+ }
+
+ @Override
+ public String getFilterPath() {
+ return filterPath;
+ }
+
+ @Override
+ public void addFilterResourceIds(Integer... filterResourceIds) {
+ this.filterResourceIds = getListIgnoringNulls(filterResourceIds);
+ }
+
+ @Override
+ public List<Integer> getFilterResourceIds() {
+ return filterResourceIds;
+ }
+
+ @Override
+ public void addFilterStartTime(Long filterStartTime) {
+ this.filterStartTime = filterStartTime;
+ }
+
+ @Override
+ public Long getFilterStartTime() {
+ return filterStartTime;
+ }
+
+ @Override
+ public void addFilterEndTime(Long filterEndTime) {
+ this.filterEndTime = filterEndTime;
+ }
+
+ @Override
+ public Long getFilterEndTime() {
+ return filterEndTime;
+ }
+
+ @Override
+ public void fetchChangeSet(boolean fetchChangeSet) {
+ this.fetchChangeSet = fetchChangeSet;
+ }
+
+ @Override
+ public boolean isFetchChangeSet() {
+ return fetchChangeSet;
+ }
+
+ @Override
+ public void addSortCtime(PageOrdering sortCtime) {
+ this.sortCtime = sortCtime;
+ }
+
+ @Override
+ public PageOrdering getSortCtime() {
+ return sortCtime;
+ }
+
+ @Override
+ public PageControl getPageControlOverrides() {
+ return pageControl;
+ }
+
+ @Override
+ public void setPageControl(PageControl pageControl) {
+ this.pageControl = pageControl;
+ }
+}
commit 956cbb899ed45301921c7ab3fc39a9e9eb67ce30
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 28 21:03:27 2011 -0400
Adding support in coregui for string ids
TableSection has a lot of code driven off of integer ids, and there are
a lots of subclasses. I started out trying to refactor it to support
string ids, but due to concerns over introducing regressions in existing
(and working) subclasses, I decided to introduce TableSection2 which
deals with string ids. After review, this code may get refactored or
altogether go away with the logic being merged into TableSection.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
index 10c15e4..378350d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
@@ -218,7 +218,7 @@ public class LinkManager {
return link;
}
- public static String getSubsystemDriftHistoryLink(int resourceId, int driftId) {
+ public static String getSubsystemDriftHistoryLink(int resourceId, String driftId) {
return "#Resource/" + resourceId + "/Drift/History/" + driftId;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection2.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection2.java
new file mode 100644
index 0000000..28beafe
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection2.java
@@ -0,0 +1,367 @@
+package org.rhq.enterprise.gui.coregui.client.components.table;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.History;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.types.AnimationEffect;
+import com.smartgwt.client.types.VerticalAlignment;
+import com.smartgwt.client.widgets.AnimationCallback;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.events.DoubleClickEvent;
+import com.smartgwt.client.widgets.events.DoubleClickHandler;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.DetailsView;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
+
+public abstract class TableSection2 <DS extends RPCDataSource> extends Table<DS> implements BookmarkableView {
+
+ private VLayout detailsHolder;
+ private Canvas detailsView;
+ private String basePath;
+ private boolean escapeHtmlInDetailsLinkColumn;
+ private boolean initialDisplay;
+
+ protected TableSection2(String locatorId, String tableTitle) {
+ super(locatorId, tableTitle);
+ }
+
+ protected TableSection2(String locatorId, String tableTitle, Criteria criteria) {
+ super(locatorId, tableTitle, criteria);
+ }
+
+ protected TableSection2(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, sortSpecifiers);
+ }
+
+ protected TableSection2(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers) {
+ super(locatorId, tableTitle, sortSpecifiers, criteria);
+ }
+
+ protected TableSection2(String locatorId, String tableTitle, boolean autoFetchData) {
+ super(locatorId, tableTitle, autoFetchData);
+ }
+
+ protected TableSection2(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames) {
+ super(locatorId, tableTitle, null, sortSpecifiers, excludedFieldNames);
+ }
+
+ protected TableSection2(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames);
+ }
+
+ protected TableSection2(String locatorId, String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
+ String[] excludedFieldNames, boolean autoFetchData) {
+ super(locatorId, tableTitle, criteria, sortSpecifiers, excludedFieldNames, autoFetchData);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ this.initialDisplay = true;
+
+ detailsHolder = new LocatableVLayout(extendLocatorId("tableSection"));
+ detailsHolder.setAlign(VerticalAlignment.TOP);
+ //detailsHolder.setWidth100();
+ //detailsHolder.setHeight100();
+ detailsHolder.setMargin(4);
+ detailsHolder.hide();
+
+ addMember(detailsHolder);
+
+ // if the detailsView is already defined it means we want the details view to be rendered prior to
+ // the master view, probably due to a direct navigation or refresh (like F5 when sitting on the details page)
+ if (null != detailsView) {
+ switchToDetailsView();
+ }
+ }
+
+ /**
+ * The default implementation wraps the {@link #getDetailsLinkColumnCellFormatter()} column with the
+ * {@link #getDetailsLinkColumnCellFormatter()}. This is typically the 'name' column linking to the detail
+ * view, given the 'id'. Also, establishes a double click handler for the row which invokes
+ * {@link #showDetails(com.smartgwt.client.widgets.grid.ListGridRecord)}</br>
+ * </br>
+ * In general, in overrides, call super.configureTable *after* manipulating the ListGrid fields.
+ *
+ * @see org.rhq.enterprise.gui.coregui.client.components.table.Table#configureTable()
+ */
+ @Override
+ protected void configureTable() {
+ if (isDetailsEnabled()) {
+ ListGrid grid = getListGrid();
+
+ // Make the value of some specific field a link to the details view for the corresponding record.
+ ListGridField field = (grid != null) ? grid.getField(getDetailsLinkColumnName()) : null;
+ if (field != null) {
+ field.setCellFormatter(getDetailsLinkColumnCellFormatter());
+ }
+
+ setListGridDoubleClickHandler(new DoubleClickHandler() {
+ @Override
+ public void onDoubleClick(DoubleClickEvent event) {
+ ListGrid listGrid = (ListGrid) event.getSource();
+ ListGridRecord[] selectedRows = listGrid.getSelection();
+ if (selectedRows != null && selectedRows.length == 1) {
+ showDetails(selectedRows[0]);
+ }
+ }
+ });
+ }
+ }
+
+ protected boolean isDetailsEnabled() {
+ return true;
+ }
+
+ public void setEscapeHtmlInDetailsLinkColumn(boolean escapeHtmlInDetailsLinkColumn) {
+ this.escapeHtmlInDetailsLinkColumn = escapeHtmlInDetailsLinkColumn;
+ }
+
+ /**
+ * Override if you don't want FIELD_NAME to be wrapped ina link.
+ * @return the name of the field to be wrapped, or null if no field should be wrapped.
+ */
+ protected String getDetailsLinkColumnName() {
+ return FIELD_NAME;
+ }
+
+ /**
+ * Override if you don't want the detailsLinkColumn to have the default link wrapper.
+ * @return the desired CellFormatter.
+ */
+ protected CellFormatter getDetailsLinkColumnCellFormatter() {
+ return new CellFormatter() {
+ public String format(Object value, ListGridRecord record, int i, int i1) {
+ if (value == null) {
+ return "";
+ }
+ String recordId = getId(record);
+ String detailsUrl = "#" + getBasePath() + "/" + recordId;
+ String formattedValue = (escapeHtmlInDetailsLinkColumn) ? StringUtility.escapeHtml(value.toString())
+ : value.toString();
+ return SeleniumUtility.getLocatableHref(detailsUrl, formattedValue, null);
+ }
+ };
+ }
+
+ /**
+ * Shows the details view for the given record of the table.
+ *
+ * The default implementation of this method assumes there is an
+ * id attribute on the record and passes it to {@link #showDetails(String)}.
+ * Subclasses are free to override this behavior. Subclasses usually
+ * will need to set the {@link #setDetailsView(Canvas) details view}
+ * explicitly.
+ *
+ * @param record the record whose details are to be shown
+ */
+ public void showDetails(ListGridRecord record) {
+ if (record == null) {
+ throw new IllegalArgumentException("'record' parameter is null.");
+ }
+
+ String id = getId(record);
+ showDetails(id);
+ }
+
+ /**
+ * Returns the details canvas with information on the item given its list grid record.
+ *
+ * The default implementation of this method is to assume there is an
+ * id attribute on the record and pass that ID to {@link #getDetailsView(String)}.
+ * Subclasses are free to override this - which you usually want to do
+ * if you know the full details of the item are stored in the record attributes
+ * and thus help avoid making a round trip to the DB.
+ *
+ * @param record the record of the item whose details to be shown; ; null if empty details view should be shown.
+ */
+ public Canvas getDetailsView(ListGridRecord record) {
+ String id = getId(record);
+ return getDetailsView(id);
+ }
+
+ protected String getId(ListGridRecord record) {
+ String id = null;
+ if (record != null) {
+ id = record.getAttribute("id");
+ }
+ if (id == null || id.length() == 0) {
+ String msg = MSG.view_tableSection_error_noId(this.getClass().toString());
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalStateException(msg);
+ }
+ return id;
+ }
+
+ /**
+ * Shows empty details for a new item being created.
+ * This method is usually called when a user clicks a 'New' button.
+ *
+ * @see #showDetails(ListGridRecord)
+ */
+ public void newDetails() {
+ History.newItem(basePath + "/0");
+ }
+
+ /**
+ * Shows the details for an item has the given ID.
+ * This method is usually called when a user goes to the details
+ * page via a bookmark, double-cick on a list view row, or direct link.
+ *
+ * @param id the id of the row whose details are to be shown; Should be a valid id.
+ *
+ * @see #showDetails(ListGridRecord)
+ *
+ * @throws IllegalArgumentException if id is null or empty string
+ */
+ public void showDetails(String id) {
+ if (id == null || id.length() == 0) {
+ History.newItem(basePath + "/" + id);
+ } else {
+ String msg = MSG.view_tableSection_error_badId(this.getClass().toString(), id);
+ CoreGUI.getErrorHandler().handleError(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ /**
+ * Returns the details canvas with information on the item that has the given ID.
+ * Note that an empty details view should be returned if the id passed in is 0 (as would
+ * be the case if a new item is to be created using the details view).
+ *
+ * @param id the id of the details to be shown; will be null if an empty details view should be shown.
+ */
+ public abstract Canvas getDetailsView(String id);
+
+ @Override
+ public void renderView(ViewPath viewPath) {
+ this.basePath = viewPath.getPathToCurrent();
+
+ if (!viewPath.isEnd()) {
+ String id = viewPath.getCurrent().getPath();
+ this.detailsView = getDetailsView(id);
+ if (this.detailsView instanceof BookmarkableView) {
+ ((BookmarkableView) this.detailsView).renderView(viewPath);
+ }
+ switchToDetailsView();
+ } else {
+ switchToTableView();
+ }
+ }
+
+ protected String getBasePath() {
+ return this.basePath;
+ }
+
+ /**
+ * For use by subclasses that want to define their own details view.
+ *
+ * @param detailsView the new details view
+ */
+ protected void setDetailsView(Canvas detailsView) {
+ this.detailsView = detailsView;
+ }
+
+ /**
+ * Switches to viewing the details canvas, hiding the table. This does not
+ * do anything with reloading data or switching to the selected row in the table;
+ * this only changes the visibility of canvases.
+ */
+ protected void switchToDetailsView() {
+ Canvas contents = getTableContents();
+
+ // If the Table has not yet been initialized then ignore
+ if (contents != null) {
+ if (contents.isVisible()) {
+ contents.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
+ @Override
+ public void execute(boolean b) {
+ buildDetailsView();
+ }
+ });
+ } else {
+ /*
+ * if the programmer chooses to go directly from the detailView in create-mode to the
+ * detailsView in edit-mode, the content canvas will already be hidden, which means the
+ * animateHide would be a no-op (the event won't fire). this causes the detailsHolder
+ * to keep a reference to the previous detailsView (the one in create-mode) instead of the
+ * newly returned reference from getDetailsView(String) that was called when the renderView
+ * methods were called hierarchically down to render the new detailsView in edit-mode.
+ * therefore, we need to explicitly destroy what's already there (presumably the detailsView
+ * in create-mode), and then rebuild it (presumably the detailsView in edit-mode).
+ */
+ SeleniumUtility.destroyMembers(detailsHolder);
+
+ buildDetailsView();
+ }
+ }
+ }
+
+ private void buildDetailsView() {
+ detailsView.setWidth100();
+ detailsView.setHeight100();
+
+ boolean isEditable = (detailsView instanceof DetailsView && ((DetailsView) detailsView).isEditable());
+ if (!isEditable) {
+ // Only add the "Back to List" button if the details are definitely not editable, because if they are
+ // editable, a Cancel button should already be provided by the details view.
+ BackButton backButton = new BackButton(extendLocatorId("BackButton"), MSG.view_tableSection_backButton(),
+ basePath);
+ detailsHolder.addMember(backButton);
+ VLayout verticalSpacer = new LocatableVLayout(extendLocatorId("verticalSpacer"));
+ verticalSpacer.setHeight(8);
+ detailsHolder.addMember(verticalSpacer);
+ }
+
+ detailsHolder.addMember(detailsView);
+ detailsHolder.animateShow(AnimationEffect.WIPE);
+ }
+
+ /**
+ * Switches to viewing the table, hiding the details canvas.
+ */
+ protected void switchToTableView() {
+ final Canvas contents = getTableContents();
+ if (contents != null) {
+ // If this is not the initial display of the table, refresh the table's data. Otherwise, a refresh would be
+ // redundant, since the data was just loaded when the table was drawn.
+ if (this.initialDisplay) {
+ this.initialDisplay = false;
+ } else {
+ Log.debug("Refreshing data for Table [" + getClass().getName() + "]...");
+ refresh();
+ }
+ if (detailsHolder != null && detailsHolder.isVisible()) {
+ detailsHolder.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
+ @Override
+ public void execute(boolean b) {
+ SeleniumUtility.destroyMembers(detailsHolder);
+
+ contents.animateShow(AnimationEffect.WIPE);
+ }
+ });
+ } else {
+ contents.animateShow(AnimationEffect.WIPE);
+ }
+ }
+ }
+
+
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
index 5563a8c..0e3f7ed 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
@@ -302,7 +302,7 @@ public class DriftDataSource extends RPCDataSource<DriftComposite, DriftCriteria
public static ListGridRecord convert(DriftComposite from) {
ListGridRecord record = new ListGridRecord();
Drift drift = from.getDrift();
- record.setAttribute(ATTR_ID, Integer.valueOf(drift.getId()));
+ record.setAttribute(ATTR_ID, drift.getId());
record.setAttribute(ATTR_CTIME, new Date(drift.getCtime()));
record.setAttribute(ATTR_CATEGORY, ImageManager.getDriftCategoryIcon(drift.getCategory()));
record.setAttribute(ATTR_PATH, drift.getPath());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
index a608f8f..f00640a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
@@ -44,7 +44,7 @@ import org.rhq.enterprise.gui.coregui.client.components.form.EnumSelectItem;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableSection2;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -62,7 +62,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
*
* @author Jay Shaughnessy
*/
-public class DriftHistoryView extends TableSection<DriftDataSource> {
+public class DriftHistoryView extends TableSection2<DriftDataSource> {
public static final ViewName SUBSYSTEM_VIEW_ID = new ViewName("RecentDrifts", MSG.common_title_recent_drifts());
@@ -155,7 +155,7 @@ public class DriftHistoryView extends TableSection<DriftDataSource> {
return new CellFormatter() {
public String format(Object value, ListGridRecord record, int i, int i1) {
Integer resourceId = record.getAttributeAsInt(AncestryUtil.RESOURCE_ID);
- Integer driftId = getId(record);
+ String driftId = getId(record);
String url = LinkManager.getSubsystemDriftHistoryLink(resourceId, driftId);
String formattedValue = TimestampCellFormatter.format(value);
return SeleniumUtility.getLocatableHref(url, formattedValue, null);
@@ -283,8 +283,9 @@ public class DriftHistoryView extends TableSection<DriftDataSource> {
// });
// }
+
@Override
- public Canvas getDetailsView(int driftId) {
+ public Canvas getDetailsView(String driftId) {
return DriftDetailsView.getInstance();
}
commit b6c8e5e261b4662afcd71dbdb99d1be2a50e3596
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 28 16:09:13 2011 -0400
Updating drift-mongodb plugin to use drift DTOs
The drift-mongodb plugin defines its own implementations of the Drift
entities. Those entities live inside the drift-mongodb plugin and
consequently are not known or usable from coregui. Drift server plugins
will have to go through the DTO layer to ensure compatibility with
coregui.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftChangeSetDTO.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftChangeSetDTO.java
index 68a5ff7..4ace8d1 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftChangeSetDTO.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftChangeSetDTO.java
@@ -1,12 +1,15 @@
package org.rhq.core.domain.drift.dto;
+import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftChangeSetCategory;
-public class DriftChangeSetDTO implements DriftChangeSet<DriftDTO> {
+public class DriftChangeSetDTO implements DriftChangeSet<DriftDTO>, Serializable {
+
+ private static final long serialVersionUID = 1L;
private String id;
@@ -37,6 +40,10 @@ public class DriftChangeSetDTO implements DriftChangeSet<DriftDTO> {
return ctime;
}
+ public void setCtime(Long ctime) {
+ this.ctime = ctime;
+ }
+
@Override
public int getVersion() {
return version;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftDTO.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftDTO.java
index adc5c52..a75858f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftDTO.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftDTO.java
@@ -1,9 +1,13 @@
package org.rhq.core.domain.drift.dto;
+import java.io.Serializable;
+
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
-public class DriftDTO implements Drift<DriftChangeSetDTO, DriftFileDTO> {
+public class DriftDTO implements Drift<DriftChangeSetDTO, DriftFileDTO>, Serializable {
+
+ private static final long serialVersionUID = 1L;
private String id;
@@ -34,6 +38,10 @@ public class DriftDTO implements Drift<DriftChangeSetDTO, DriftFileDTO> {
return ctime;
}
+ public void setCtime(Long ctime) {
+ this.ctime = ctime;
+ }
+
@Override
public DriftChangeSetDTO getChangeSet() {
return changeSet;
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
index 2b3aca0..c90594a 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
@@ -31,6 +31,8 @@ import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.Snapshot;
+import org.rhq.core.domain.drift.dto.DriftChangeSetDTO;
+import org.rhq.core.domain.drift.dto.DriftDTO;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.ZipUtil;
@@ -135,9 +137,9 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
Map<Integer, Resource> resources = loadResourceMap(subject, criteria.getFilterResourceIds());
for (MongoDBChangeSet changeSet : query) {
+ DriftChangeSetDTO changeSetDTO = toDTO(changeSet);
for (MongoDBChangeSetEntry entry : changeSet.getDrifts()) {
- entry.setChangeSet(changeSet);
- results.add(new DriftComposite(entry, resources.get(changeSet.getResourceId())));
+ results.add(new DriftComposite(toDTO(entry, changeSetDTO), resources.get(changeSet.getResourceId())));
}
}
@@ -163,4 +165,26 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
return map;
}
+
+ DriftChangeSetDTO toDTO(MongoDBChangeSet changeSet) {
+ DriftChangeSetDTO dto = new DriftChangeSetDTO();
+ dto.setId(changeSet.getId());
+ dto.setDriftConfigurationId(changeSet.getDriftConfigurationId());
+ dto.setVersion(changeSet.getVersion());
+ dto.setCtime(changeSet.getCtime());
+ dto.setCategory(changeSet.getCategory());
+
+ return dto;
+ }
+
+ DriftDTO toDTO(MongoDBChangeSetEntry entry, DriftChangeSetDTO changeSetDTO) {
+ DriftDTO dto = new DriftDTO();
+ dto.setChangeSet(changeSetDTO);
+ dto.setId(entry.getId());
+ dto.setCtime(entry.getCtime());
+ dto.setPath(entry.getPath());
+ dto.setCategory(entry.getCategory());
+
+ return dto;
+ }
}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java
index 2818b2c..bcf9f5c 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java
@@ -7,6 +7,7 @@ import java.util.Set;
import com.google.code.morphia.annotations.Embedded;
import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Id;
+import com.google.code.morphia.annotations.PostLoad;
import org.bson.types.ObjectId;
@@ -103,6 +104,7 @@ public class MongoDBChangeSet implements DriftChangeSet<MongoDBChangeSetEntry>,
public MongoDBChangeSet add(MongoDBChangeSetEntry entry) {
entries.add(entry);
+ entry.setChangeSet(this);
return this;
}
@@ -110,4 +112,11 @@ public class MongoDBChangeSet implements DriftChangeSet<MongoDBChangeSetEntry>,
public void setDrifts(Set<MongoDBChangeSetEntry> drifts) {
entries = drifts;
}
+
+ @PostLoad
+ void initEntries() {
+ for (MongoDBChangeSetEntry entry : entries) {
+ entry.setChangeSet(this);
+ }
+ }
}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java
index ced7bff..dddfb02 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java
@@ -3,6 +3,7 @@ package org.rhq.enterprise.server.plugins.drift.mongodb.entities;
import java.io.Serializable;
import com.google.code.morphia.annotations.Embedded;
+import com.google.code.morphia.annotations.Transient;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
@@ -18,6 +19,9 @@ public class MongoDBChangeSetEntry implements Drift<MongoDBChangeSet, MongoDBFil
private String path;
+ @Transient
+ private MongoDBChangeSet changeSet;
+
public MongoDBChangeSetEntry() {
}
@@ -28,7 +32,7 @@ public class MongoDBChangeSetEntry implements Drift<MongoDBChangeSet, MongoDBFil
@Override
public String getId() {
- return null;
+ return changeSet.getId() + ":" + path;
}
@Override
@@ -37,16 +41,17 @@ public class MongoDBChangeSetEntry implements Drift<MongoDBChangeSet, MongoDBFil
@Override
public Long getCtime() {
- return null;
+ return ctime;
}
@Override
public MongoDBChangeSet getChangeSet() {
- return null;
+ return changeSet;
}
@Override
public void setChangeSet(MongoDBChangeSet changeSet) {
+ this.changeSet = changeSet;
}
@Override
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
index b5b8306..6aff9aa 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
@@ -9,7 +9,8 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import static org.rhq.core.domain.drift.DriftCategory.FILE_ADDED;
+import org.rhq.core.domain.drift.DriftCategory;
+
import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
import static org.rhq.test.AssertUtils.assertCollectionMatchesNoOrder;
import static org.rhq.test.AssertUtils.assertPropertiesMatch;
@@ -32,7 +33,7 @@ public class MongoDBChangeSetTest {
.map(MongoDBChangeSetEntry.class)
.map(MongoDBFile.class);
- ds = morphia.createDatastore(connection, "rhq");
+ ds = morphia.createDatastore(connection, "rhqtest");
}
@BeforeMethod
@@ -59,7 +60,7 @@ public class MongoDBChangeSetTest {
public void saveAndLoadChangeSetWithOneEntry() throws Exception {
MongoDBChangeSet expected = new MongoDBChangeSet();
expected.setResourceId(10001);
- expected.getDrifts().add(new MongoDBChangeSetEntry("foo", FILE_ADDED));
+ expected.add(new MongoDBChangeSetEntry("foo", DriftCategory.FILE_ADDED));
ds.save(expected);
@@ -67,7 +68,8 @@ public class MongoDBChangeSetTest {
assertNotNull(expected, "Failed to load change set");
assertPropertiesMatch("Failed to save change set", expected, actual, "drifts");
- assertCollectionMatchesNoOrder(expected.getDrifts(), actual.getDrifts(), "Failed to save change set entries");
+ assertCollectionMatchesNoOrder("Failed to save change set entries", expected.getDrifts(), actual.getDrifts(),
+ "changeSet");
}
}
diff --git a/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java b/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java
index fc41623..7524fc8 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java
@@ -23,13 +23,14 @@
package org.rhq.test;
-import static org.testng.Assert.*;
-
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
public class AssertUtils {
/**
@@ -123,4 +124,16 @@ public class AssertUtils {
assertTrue(result.isMatch(), msg + " -- " + result.getDetails());
}
+ public static <T> void assertCollectionMatchesNoOrder(String msg, Collection<T> expected, Collection<T> actual,
+ String... ignoredProperties) {
+ CollectionMatchesChecker<T> checker = new CollectionMatchesChecker<T>();
+ checker.setExpected(expected);
+ checker.setActual(actual);
+ checker.setIgnoredProperties(ignoredProperties);
+
+ MatchResult result = checker.execute();
+
+ assertTrue(result.isMatch(), msg + " -- " + result.getDetails());
+ }
+
}
diff --git a/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java b/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java
index 26b75c9..622108f 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/CollectionMatchesChecker.java
@@ -2,7 +2,11 @@ package org.rhq.test;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+
+import static junitx.util.Converter.asList;
public class CollectionMatchesChecker<T> {
@@ -10,6 +14,8 @@ public class CollectionMatchesChecker<T> {
private Collection<T> actual;
+ private Set<String> ignoredProperties = new HashSet<String>();
+
public void setExpected(Collection<T> expected) {
this.expected = expected;
}
@@ -18,6 +24,10 @@ public class CollectionMatchesChecker<T> {
this.actual = actual;
}
+ public void setIgnoredProperties(String... ignoredProperties) {
+ this.ignoredProperties.addAll(asList(ignoredProperties));
+ }
+
public MatchResult execute() {
boolean isMatch = true;
StringBuilder details = new StringBuilder();
@@ -63,6 +73,7 @@ public class CollectionMatchesChecker<T> {
PropertyMatcher<T> matcher = new PropertyMatcher<T>();
matcher.setExpected(elementToSearchFor);
matcher.setActual(actual);
+ matcher.setIgnoredProperties(ignoredProperties);
MatchResult result = matcher.execute();
if (result.isMatch()) {
commit e3ac67735346a310e142e7ed28fb65126e26e440
Merge: 5d5f12b fb4f3a1
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 28 09:13:44 2011 -0400
Merge branch 'drift' into drift-mongodb
commit fb4f3a1cfdf55801cf74293fe05a626af98c33b9
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 28 09:11:14 2011 -0400
fix typo and remove gwt library that was only for prototyping
diff --git a/modules/enterprise/gui/coregui/lib/morphia-gwt-0.99-SNAPSHOT.jar b/modules/enterprise/gui/coregui/lib/morphia-gwt-0.99-SNAPSHOT.jar
deleted file mode 100644
index e8a10a6..0000000
Binary files a/modules/enterprise/gui/coregui/lib/morphia-gwt-0.99-SNAPSHOT.jar and /dev/null differ
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java
index 229183d..a039930 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java
@@ -201,7 +201,7 @@ public class SystemManagerBean implements SystemManagerLocal, SystemManagerRemot
}
private Map<String, String> getDriftServerPlugins() {
- DriftServerPluginManager pluginMgr = getDriftSererPluginManager();
+ DriftServerPluginManager pluginMgr = getDriftServerPluginManager();
Map<String, String> plugins = new HashMap<String, String>();
for (ServerPluginEnvironment env : pluginMgr.getPluginEnvironments()) {
@@ -211,7 +211,7 @@ public class SystemManagerBean implements SystemManagerLocal, SystemManagerRemot
return plugins;
}
- private DriftServerPluginManager getDriftSererPluginManager() {
+ private DriftServerPluginManager getDriftServerPluginManager() {
MasterServerPluginContainer masterPC = LookupUtil.getServerPluginService().getMasterPluginContainer();
if (masterPC == null) {
log.warn(MasterServerPluginContainer.class.getSimpleName() + " is not started yet");
commit 5d5f12b94c665c3c28841a56d58e633cd612d687
Merge: e753a90 b384576
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 28 09:07:41 2011 -0400
Merge branch 'drift' into drift-mongodb
commit b384576d06abbfea2a6263f528ddaa3d5b74a9df
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 28 08:51:03 2011 -0400
Need to use strings for ids and not integers
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
index 278a0d9..2582a49 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
@@ -20,8 +20,6 @@
package org.rhq.enterprise.gui.coregui.client.drift;
-import static org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter.DATE_TIME_FORMAT_FULL;
-
import java.util.LinkedHashMap;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -41,6 +39,8 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import static org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter.DATE_TIME_FORMAT_FULL;
+
/**
* @author Jay Shaughnessy
*/
@@ -161,7 +161,7 @@ public class DriftDetailsView extends LocatableVLayout implements BookmarkableVi
@Override
public void renderView(ViewPath viewPath) {
- driftId = Integer.toString(viewPath.getCurrentAsInt());
+ driftId = viewPath.getCurrent().getPath();
show(driftId);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java
index 63037c1..db51c99 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java
@@ -51,7 +51,6 @@ public class RHQConstants {
// DRIFT Server properties
public static final String ACTIVE_DRIFT_PLUGIN = "ACTIVE_DRIFT_PLUGIN";
- public static final String DRIFT_PLUGINS = "DRIFT_PLUGINS";
// Base URL for the application - (i think this is only used for alert emails)
public static final String BaseURL = "CAM_BASE_URL";
commit 6e60760d3f00f3498a02d6ecfb3547da9e5940e6
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jul 27 15:17:52 2011 -0400
context menu on change set node
multiple select tree nodes
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
index 6085af1..8203361 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -47,7 +47,6 @@ import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
/**
@@ -67,7 +66,7 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
// fetch the top nodes at the inital onDraw()
setAutoFetchData(true);
setAnimateFolders(false);
- setSelectionType(SelectionStyle.SINGLE);
+ setSelectionType(SelectionStyle.MULTIPLE);
setShowRollOver(false);
setShowHeader(false);
setSortField(AbstractDriftChangeSetsTreeDataSource.ATTR_NAME);
@@ -96,9 +95,10 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
TreeNode eventNode = event.getNode();
if (eventNode instanceof ChangeSetTreeNode) {
- CoreGUI.getMessageCenter().notify(new Message("TODO [this will popup the changeset menu]"));
+ Menu menu = buildChangeSetTreeNodeContextMenu((ChangeSetTreeNode) eventNode);
+ menu.showContextMenu();
} else if (eventNode instanceof DriftTreeNode) {
- Menu menu = buildContextMenu((DriftTreeNode) eventNode);
+ Menu menu = buildDriftTreeNodeContextMenu((DriftTreeNode) eventNode);
menu.showContextMenu();
}
}
@@ -171,12 +171,12 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
* @param node the drift node whose menu is to be displayed
* @return the context menu to display
*/
- protected Menu buildContextMenu(final DriftTreeNode node) {
+ protected Menu buildDriftTreeNodeContextMenu(final DriftTreeNode node) {
Menu contextMenu = new Menu();
// title
- String titleName = node.getName();
+ String titleName = node.getTitle();
if (titleName.length() > 50) {
// make sure the title isn't really long so the menu is not abnormally wide
titleName = "..." + titleName.substring(titleName.length() - 50);
@@ -204,6 +204,36 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
}
/**
+ * Builds the right-mouse-click context menu for the given change set node
+ * @param node the change set node whose menu is to be displayed
+ * @return the context menu to display
+ */
+ protected Menu buildChangeSetTreeNodeContextMenu(final ChangeSetTreeNode node) {
+
+ Menu contextMenu = new Menu();
+
+ // title
+ String titleName = node.getTitle();
+ MenuItem titleItem = new MenuItem(titleName);
+ titleItem.setEnabled(false);
+ contextMenu.setItems(titleItem);
+
+ // separator
+ contextMenu.addItem(new MenuItemSeparator());
+
+ // item that links to the history details
+ MenuItem deleteItem = new MenuItem(MSG.common_button_delete());
+ deleteItem.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ // TODO: delete the change set
+ }
+ });
+ contextMenu.addItem(deleteItem);
+
+ return contextMenu;
+ }
+
+ /**
* We override this because we know all of our nodes will have titles. Without this,
* I could not get the title of change set nodes to show - it always fell back to using
* the name. This way is at least faster, since we don't do any conditional checking,
commit 0dd75a22859b78cb31da25e14f986497d3a2b700
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 27 14:50:44 2011 -0400
Making the active drift server plugin configurable via system settings
When a drift serer plugin is loaded or unloaded, it is added to or
removed from the systems settings. When the DriftServerBean (SLSB
layers) asks for the drift plugin, the DriftServerPlugin queries the
system settings to find the active drift server plugin. The drift-rhq
plugin is active by default.
diff --git a/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
index 349b84c..b385473 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
@@ -143,7 +143,7 @@ public class JPAUtils {
em.createNativeQuery("delete from rhq_measurement_sched");
em.createNativeQuery("delete from rhq_measurement_def");
em.createNativeQuery("delete from rhq_plugin");
- em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56)");
+ em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56, 57, 58)");
em.createNativeQuery("delete from rhq_alert_notification");
em.createNativeQuery("delete from rhq_alert_condition_log");
em.createNativeQuery("delete from rhq_alert");
commit 9fb6a02ecb51d1caedd4e7c7567a8414c3294e7f
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 26 21:22:19 2011 -0400
Persist drift detection schedule across agent restarts
This commit add functionality for persisting drift detection schedules
across restarts. When the agent is shutting down and the inventory is
persisted to disk, the schedules are now written out to disk along with
the rest of the inventory.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
index f499697..879ceca 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
@@ -67,11 +67,36 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
driftDetector.setChangeSetManager(changeSetMgr);
driftDetector.setDriftClient(this);
+ InventoryManager inventoryMgr = PluginContainer.getInstance().getInventoryManager();
+ initSchedules(inventoryMgr.getPlatform(), inventoryMgr);
+
driftThreadPool = new ScheduledThreadPoolExecutor(5);
// TODO Make the drift detection rate configurable
driftThreadPool.scheduleAtFixedRate(driftDetector, 30, 60, TimeUnit.SECONDS);
}
+ private void initSchedules(Resource r, InventoryManager inventoryMgr) {
+ if (r.getId() == 0) {
+ log.debug("Will not reschedule drift detection schedules for " + r + ". It is not sync'ed yet.");
+ return;
+ }
+
+ ResourceContainer container = inventoryMgr.getResourceContainer(r.getId());
+ if (container == null) {
+ log.debug("No resource container found for " + r + ". Unable to reschedule drift detection schedules.");
+ return;
+ }
+
+ log.debug("Rescheduling drift detection schedules for " + r);
+ for (DriftDetectionSchedule schedule : container.getDriftSchedules()) {
+ schedulesQueue.addSchedule(schedule);
+ }
+
+ for (Resource child : r.getChildResources()) {
+ initSchedules(child, inventoryMgr);
+ }
+ }
+
@Override
public void shutdown() {
driftThreadPool.shutdown();
@@ -164,8 +189,8 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
}
@Override
- public boolean update(int resourceId, DriftConfiguration config) {
- return false;
+ public DriftDetectionSchedule update(int resourceId, DriftConfiguration config) {
+ return schedule;
}
@Override
@@ -208,9 +233,16 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
@Override
public void updateDriftDetection(int resourceId, DriftConfiguration driftConfiguration) {
- boolean updated = schedulesQueue.update(resourceId, driftConfiguration);
- if (!updated) {
- schedulesQueue.addSchedule(new DriftDetectionSchedule(resourceId, driftConfiguration));
+ DriftDetectionSchedule updatedSchedule = schedulesQueue.update(resourceId, driftConfiguration);
+ if (updatedSchedule == null) {
+ updatedSchedule = new DriftDetectionSchedule(resourceId, driftConfiguration);
+ schedulesQueue.addSchedule(updatedSchedule);
+ }
+
+ InventoryManager inventoryMgr = PluginContainer.getInstance().getInventoryManager();
+ ResourceContainer container = inventoryMgr.getResourceContainer(resourceId);
+ if (container != null) {
+ container.getDriftSchedules().add(updatedSchedule);
}
}
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 ca7edc5..374e27e 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
@@ -38,7 +38,7 @@ public interface ScheduleQueue {
* Adds a schedule to the queue for processing by the drift detector
*
* @param schedule A {@link DriftDetectionSchedule} object
- * @return true if the schedule is added, falsed otherwise
+ * @return true if the schedule is added, false otherwise
*/
boolean addSchedule(DriftDetectionSchedule schedule);
@@ -52,9 +52,9 @@ public interface ScheduleQueue {
*
* @param resourceId The resource id
* @param config A {@link DriftConfiguration} belonging the resource with the specified id
- * @return true if the schedule is updated, false otherwise.
+ * @return A copy of the updated schedule or null if no update was performed
*/
- boolean update(int resourceId, DriftConfiguration config);
+ DriftDetectionSchedule update(int resourceId, DriftConfiguration config);
/**
* Removes the schedule identified by the resource id and the drift configuration. More
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 499ad91..b4a2f00 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
@@ -112,20 +112,26 @@ public class ScheduleQueueImpl implements ScheduleQueue {
}
@Override
- public boolean update(int resourceId, DriftConfiguration config) {
+ public DriftDetectionSchedule update(int resourceId, DriftConfiguration config) {
try {
lock.writeLock().lock();
if (isActiveSchedule(resourceId, config)) {
update(activeSchedule, config);
- } else {
- DriftDetectionSchedule schedule = remove(resourceId, config);
- if (schedule == null) {
- return false;
- }
- update(schedule, config);
- queue.offer(schedule);
+ return activeSchedule.copy();
+ }
+
+ DriftDetectionSchedule schedule = remove(resourceId, config);
+ if (schedule == null) {
+ return null;
}
- return true;
+
+ update(schedule, config);
+
+ if (queue.offer(schedule)) {
+ return schedule.copy();
+ }
+
+ return null;
} finally {
lock.writeLock().unlock();
}
commit 9cbb6031b3327b953f2a235d149e73c2cfccc2b1
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jul 26 18:31:39 2011 -0400
tweek folder icons for drift
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png
index fdda214..e728bc8 100644
Binary files a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png
index 358cf61..1ca204f 100644
Binary files a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png differ
commit 1a9ff3317ece2ee10c8c0769174c165324785f8e
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 26 16:14:26 2011 -0400
Adding support for updating drift configs
When the server sends a request to the agent to update a drift
configuration, that config is attached to a schedule which is in one of
two places. It is either on the schedule queue or it is "active"
schedule currently being processed by the drift detector. The config
update will be applied such that the next time the drift detector
processes the schedule the update will take effect.
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 b92dd7c..153e5a9 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
@@ -47,52 +47,44 @@ public class DriftDetector implements Runnable {
@Override
public void run() {
- DriftDetectionSchedule schedule = scheduleQueue.dequeue();
+ DriftDetectionSchedule schedule = scheduleQueue.getNextSchedule();
if (schedule == null) {
return;
}
- if (schedule.getNextScan() > (System.currentTimeMillis() + 100L)) {
- scheduleQueue.enqueue(schedule);
- // TODO should we grab the schedule from the queue?
- // Maybe we should continue pulling schedules off the queue until
- // we find one that is ready to be processed.
- return;
- }
-
- if (!schedule.getDriftConfiguration().getEnabled()) {
- schedule.updateShedule();
- scheduleQueue.enqueue(schedule);
- // TODO should we grab the schedule from the queue?
- // Maybe we should continue pulling schedules off the queue until
- // we find one that is ready to be processed.
- return;
- }
-
- DriftConfiguration driftConfig = schedule.getDriftConfiguration();
- int resourceId = schedule.getResourceId();
- DriftChangeSetCategory changeSetType = null;
- int changes = 0;
-
try {
- if (changeSetMgr.changeSetExists(schedule.getResourceId(), new Headers(driftConfig.getName(),
- basedir(resourceId, driftConfig), COVERAGE))) {
- changeSetType = DRIFT;
- changes = generateDriftChangeSet(schedule);
- } else {
- changeSetType = COVERAGE;
- generateCoverageChangeSet(schedule);
+ if (schedule.getNextScan() > (System.currentTimeMillis() + 100L)) {
+ return;
}
- } catch (IOException e) {
- // TODO Call ChangeSetManager here to rollback any thing that was written to disk.
- log.error("An error occurred while scanning for drift", e);
- }
- schedule.updateShedule();
- scheduleQueue.enqueue(schedule);
+ if (!schedule.getDriftConfiguration().getEnabled()) {
+ return;
+ }
- if (changeSetType == COVERAGE || changes > 0) {
- driftClient.sendChangeSetToServer(schedule.getResourceId(), driftConfig, changeSetType);
+ DriftConfiguration driftConfig = schedule.getDriftConfiguration();
+ int resourceId = schedule.getResourceId();
+ DriftChangeSetCategory changeSetType = null;
+ int changes = 0;
+
+ try {
+ if (changeSetMgr.changeSetExists(schedule.getResourceId(), new Headers(driftConfig.getName(),
+ basedir(resourceId, driftConfig), COVERAGE))) {
+ changeSetType = DRIFT;
+ changes = generateDriftChangeSet(schedule);
+ } else {
+ changeSetType = COVERAGE;
+ generateCoverageChangeSet(schedule);
+ }
+ } catch (IOException e) {
+ // TODO Call ChangeSetManager here to rollback any thing that was written to disk.
+ log.error("An error occurred while scanning for drift", e);
+ }
+
+ if (changeSetType == COVERAGE || changes > 0) {
+ driftClient.sendChangeSetToServer(schedule.getResourceId(), driftConfig, changeSetType);
+ }
+ } finally {
+ scheduleQueue.deactivateSchedule();
}
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
index 879ceca..f499697 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
@@ -67,36 +67,11 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
driftDetector.setChangeSetManager(changeSetMgr);
driftDetector.setDriftClient(this);
- InventoryManager inventoryMgr = PluginContainer.getInstance().getInventoryManager();
- initSchedules(inventoryMgr.getPlatform(), inventoryMgr);
-
driftThreadPool = new ScheduledThreadPoolExecutor(5);
// TODO Make the drift detection rate configurable
driftThreadPool.scheduleAtFixedRate(driftDetector, 30, 60, TimeUnit.SECONDS);
}
- private void initSchedules(Resource r, InventoryManager inventoryMgr) {
- if (r.getId() == 0) {
- log.debug("Will not reschedule drift detection schedules for " + r + ". It is not sync'ed yet.");
- return;
- }
-
- ResourceContainer container = inventoryMgr.getResourceContainer(r.getId());
- if (container == null) {
- log.debug("No resource container found for " + r + ". Unable to reschedule drift detection schedules.");
- return;
- }
-
- log.debug("Rescheduling drift detection schedules for " + r);
- for (DriftDetectionSchedule schedule : container.getDriftSchedules()) {
- schedulesQueue.addSchedule(schedule);
- }
-
- for (Resource child : r.getChildResources()) {
- initSchedules(child, inventoryMgr);
- }
- }
-
@Override
public void shutdown() {
driftThreadPool.shutdown();
@@ -189,8 +164,8 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
}
@Override
- public DriftDetectionSchedule update(int resourceId, DriftConfiguration config) {
- return schedule;
+ public boolean update(int resourceId, DriftConfiguration config) {
+ return false;
}
@Override
@@ -233,16 +208,9 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
@Override
public void updateDriftDetection(int resourceId, DriftConfiguration driftConfiguration) {
- DriftDetectionSchedule updatedSchedule = schedulesQueue.update(resourceId, driftConfiguration);
- if (updatedSchedule == null) {
- updatedSchedule = new DriftDetectionSchedule(resourceId, driftConfiguration);
- schedulesQueue.addSchedule(updatedSchedule);
- }
-
- InventoryManager inventoryMgr = PluginContainer.getInstance().getInventoryManager();
- ResourceContainer container = inventoryMgr.getResourceContainer(resourceId);
- if (container != null) {
- container.getDriftSchedules().add(updatedSchedule);
+ boolean updated = schedulesQueue.update(resourceId, driftConfiguration);
+ if (!updated) {
+ schedulesQueue.addSchedule(new DriftDetectionSchedule(resourceId, driftConfiguration));
}
}
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 374e27e..ca7edc5 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
@@ -38,7 +38,7 @@ public interface ScheduleQueue {
* Adds a schedule to the queue for processing by the drift detector
*
* @param schedule A {@link DriftDetectionSchedule} object
- * @return true if the schedule is added, false otherwise
+ * @return true if the schedule is added, falsed otherwise
*/
boolean addSchedule(DriftDetectionSchedule schedule);
@@ -52,9 +52,9 @@ public interface ScheduleQueue {
*
* @param resourceId The resource id
* @param config A {@link DriftConfiguration} belonging the resource with the specified id
- * @return A copy of the updated schedule or null if no update was performed
+ * @return true if the schedule is updated, false otherwise.
*/
- DriftDetectionSchedule update(int resourceId, DriftConfiguration config);
+ boolean update(int resourceId, DriftConfiguration config);
/**
* Removes the schedule identified by the resource id and the drift configuration. More
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 b4a2f00..499ad91 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
@@ -112,26 +112,20 @@ public class ScheduleQueueImpl implements ScheduleQueue {
}
@Override
- public DriftDetectionSchedule update(int resourceId, DriftConfiguration config) {
+ public boolean update(int resourceId, DriftConfiguration config) {
try {
lock.writeLock().lock();
if (isActiveSchedule(resourceId, config)) {
update(activeSchedule, config);
- return activeSchedule.copy();
- }
-
- DriftDetectionSchedule schedule = remove(resourceId, config);
- if (schedule == null) {
- return null;
- }
-
- update(schedule, config);
-
- if (queue.offer(schedule)) {
- return schedule.copy();
+ } else {
+ DriftDetectionSchedule schedule = remove(resourceId, config);
+ if (schedule == null) {
+ return false;
+ }
+ update(schedule, config);
+ queue.offer(schedule);
}
-
- return null;
+ return true;
} finally {
lock.writeLock().unlock();
}
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 9b62422..49dab54 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
@@ -58,7 +58,7 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration driftConfig = driftConfiguration("coverage-test", resourceDir.getAbsolutePath());
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), driftConfig));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), driftConfig));
detector.run();
File changeSet = changeSet(driftConfig.getName(), COVERAGE);
@@ -77,12 +77,12 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration driftConfig = driftConfiguration("basedir-entry-test", resourceDir.getAbsolutePath());
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), driftConfig));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), driftConfig));
detector.run();
DriftDetectionSchedule schedule = new DriftDetectionSchedule(resourceId(), driftConfig);
- scheduleQueue.enqueue(schedule);
+ scheduleQueue.addSchedule(schedule);
detector.run();
assertChangeSetContainsDirEntry(changeSet(driftConfig.getName(), COVERAGE),
@@ -102,7 +102,7 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration config = driftConfiguration("multiple-files-test", resourceDir.getAbsolutePath());
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File changeSet = changeSet(config.getName(), COVERAGE);
@@ -127,7 +127,7 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration config = driftConfiguration("sibling-dirs-test", resourceDir.getAbsolutePath());
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File changeSet = changeSet(config.getName(), COVERAGE);
@@ -153,7 +153,7 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration config = driftConfiguration("nested-dirs-test", resourceDir.getAbsolutePath());
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File changeSet = changeSet(config.getName(), COVERAGE);
@@ -188,7 +188,7 @@ public class DriftDetectorTest extends DriftTest {
File server1Conf = new File(confDir, "server-1.conf");
touch(server1Conf);
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
detector.run();
}
@@ -217,7 +217,7 @@ public class DriftDetectorTest extends DriftTest {
File server2Conf = new File(confDir, "server-2.conf");
touch(server2Conf);
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File driftChangeSet = changeSet(config.getName(), DRIFT);
@@ -266,7 +266,7 @@ public class DriftDetectorTest extends DriftTest {
// create some drift
server2Conf.delete();
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File driftChangeSet = changeSet(config.getName(), DRIFT);
commit 3dbd0ceb341cf3ad9332c791ba8a3ebb3febdaff
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jul 26 16:05:42 2011 -0400
add sort direction
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
index 2d7205d..6085af1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -26,6 +26,7 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
@@ -70,6 +71,7 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
setShowRollOver(false);
setShowHeader(false);
setSortField(AbstractDriftChangeSetsTreeDataSource.ATTR_NAME);
+ setSortDirection(SortDirection.DESCENDING);
}
@Override
commit 2d57c8fcf6814de5199321b258abb8378ec75cff
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jul 26 15:58:32 2011 -0400
sort the tree and provide a refresh button
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
index 7778084..2d7205d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -24,7 +24,9 @@ package org.rhq.enterprise.gui.coregui.client.drift;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
+import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
import com.smartgwt.client.widgets.menu.Menu;
@@ -67,6 +69,7 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
setSelectionType(SelectionStyle.SINGLE);
setShowRollOver(false);
setShowHeader(false);
+ setSortField(AbstractDriftChangeSetsTreeDataSource.ATTR_NAME);
}
@Override
@@ -198,6 +201,17 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
return contextMenu;
}
+ /**
+ * We override this because we know all of our nodes will have titles. Without this,
+ * I could not get the title of change set nodes to show - it always fell back to using
+ * the name. This way is at least faster, since we don't do any conditional checking,
+ * we always immediately use the getTitle results.
+ */
+ @Override
+ protected String getNodeTitle(Record node, int recordNum, ListGridField field) {
+ return ((TreeNode) node).getTitle();
+ }
+
@SuppressWarnings("unchecked")
static class ChangeSetTreeNode extends TreeNode {
public ChangeSetTreeNode(DriftChangeSet changeset) {
@@ -205,7 +219,8 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
setIcon("subsystems/drift/ChangeSet_16.png");
setShowOpenIcon(true);
setID(changeset.getId());
- setName(buildDriftChangeSetNodeName(changeset));
+ setName(padWithZeroes(changeset.getVersion())); // we sort on this column, hence we make sure the version # is padded
+ setTitle(buildDriftChangeSetNodeName(changeset));
}
private String buildDriftChangeSetNodeName(DriftChangeSet changeset) {
@@ -219,6 +234,14 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
str.append(')');
return str.toString();
}
+
+ private String padWithZeroes(int numberToPad) {
+ String stringToPad = String.valueOf(numberToPad);
+ char[] zeroes = new char[10 - stringToPad.length()];
+ for (int i = 0; i < zeroes.length; i++)
+ zeroes[i] = '0';
+ return new String(zeroes) + stringToPad;
+ }
}
@SuppressWarnings("unchecked")
@@ -229,7 +252,12 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
String parentID = drift.getChangeSet().getId();
setParentID(parentID);
setID(parentID + '_' + drift.getId());
- setName(drift.getPath());
+ setName(drift.getPath()); // we sort on this column
+ }
+
+ @Override
+ public String getTitle() {
+ return super.getName();
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
index 48f5bc8..56b4aa2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
@@ -19,7 +19,14 @@
*/
package org.rhq.enterprise.gui.coregui.client.drift;
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.toolbar.ToolStrip;
+
import org.rhq.core.domain.common.EntityContext;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableToolStrip;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
@@ -42,7 +49,23 @@ public class DriftChangeSetsView extends LocatableVLayout {
protected void onDraw() {
super.onDraw();
- addMember(new ResourceDriftChangeSetsTreeView(extendLocatorId("Tree"), this.hasWriteAccess, this.context));
+ final ResourceDriftChangeSetsTreeView tree = new ResourceDriftChangeSetsTreeView(extendLocatorId("Tree"),
+ this.hasWriteAccess, this.context);
+ addMember(tree);
+
+ ToolStrip toolStrip = new LocatableToolStrip(extendLocatorId("toolstrip"));
+ toolStrip.setBackgroundImage(null);
+ toolStrip.setWidth100();
+ toolStrip.setMembersMargin(3);
+ toolStrip.setPadding(3);
+ IButton refreshButton = new LocatableIButton(extendLocatorId("refreshButton"), MSG.common_button_refresh());
+ refreshButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ tree.refresh();
+ }
+ });
+ toolStrip.addMember(refreshButton);
+ addMember(toolStrip);
}
public EntityContext getContext() {
commit c9a5c067500d221fe36d0438952b12a6e2c2b809
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jul 26 13:34:42 2011 -0400
refactor so we can later put in group classes but still support indiv resources
fix query so we filter on resource ID for resource view
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
index 50d787d..7778084 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -67,8 +67,6 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
setSelectionType(SelectionStyle.SINGLE);
setShowRollOver(false);
setShowHeader(false);
-
- setDataSource(new DriftChangeSetsTreeDataSource(canManageDrift));
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
deleted file mode 100644
index c6e9e65..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.drift;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.data.fields.DataSourceTextField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.tree.TreeNode;
-
-import org.rhq.core.domain.criteria.BaseCriteria;
-import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
-import org.rhq.core.domain.criteria.DriftCriteria;
-import org.rhq.core.domain.criteria.DriftJPACriteria;
-import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.DriftChangeSet;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.gwt.DriftGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-
-/**
- * @author John Mazzitelli
- */
-@SuppressWarnings("unchecked")
-public class DriftChangeSetsTreeDataSource extends RPCDataSource<Object, BaseCriteria> {
-
- private static final String ATTR_PARENT_ID = "parentId";
- public static final String ATTR_ID = "id";
- public static final String ATTR_NAME = "name";
-
- private DriftGWTServiceAsync driftService = GWTServiceLookup.getDriftService();
- private final boolean canManageDrift;
-
- public DriftChangeSetsTreeDataSource(boolean canManageDrift) {
- super();
- this.canManageDrift = canManageDrift;
- List<DataSourceField> fields = addDataSourceFields();
- addFields(fields);
- }
-
- @Override
- protected List<DataSourceField> addDataSourceFields() {
- List<DataSourceField> fields = super.addDataSourceFields();
-
- DataSourceField idDataField = new DataSourceTextField(ATTR_ID, MSG.common_title_id());
- idDataField.setPrimaryKey(true);
- fields.add(idDataField);
-
- DataSourceTextField nameDataField = new DataSourceTextField(ATTR_NAME, MSG.common_title_name());
- nameDataField.setCanEdit(false);
- fields.add(nameDataField);
-
- DataSourceTextField parentIdField = new DataSourceTextField(ATTR_PARENT_ID, MSG.common_title_id_parent());
- parentIdField.setForeignKey(ATTR_ID);
- fields.add(parentIdField);
-
- return fields;
- }
-
- @Override
- protected void executeFetch(final DSRequest request, final DSResponse response, final BaseCriteria unused) {
-
- String parentId = request.getCriteria().getAttribute(ATTR_PARENT_ID);
-
- if (parentId == null) {
-
- // There is no parent - we are at the root of the tree.
- // Get the top nodes (the change sets) but to be as fast as possible don't load their drifts.
- // We will lazily load drifts when the these changeset tree nodes are opened
- DriftChangeSetCriteria criteria = new DriftChangeSetJPACriteria();
- criteria.addSortVersion(PageOrdering.DESC);
- criteria.setPageControl(getPageControl(request));
-
- driftService.findDriftChangeSetsByCriteria(criteria, new AsyncCallback<PageList<DriftChangeSet>>() {
- public void onSuccess(PageList<DriftChangeSet> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
-
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure(), caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
- });
- } else {
- String changesetId = parentId;
- DriftCriteria criteria = new DriftJPACriteria();
- criteria.addFilterChangeSetId(changesetId);
-
- driftService.findDriftsByCriteria(criteria, new AsyncCallback<PageList<Drift>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure(), caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
-
- public void onSuccess(PageList<Drift> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
- });
-
- /*
- * I am leaving this code commented for future reference. Because today the drit change set tree only
- * shows simple changeset->drift tree, we don't need this. But if we need to have
- * multiple types of child nodes, we'll need something like below to query
- * for the different child node data. For example, we'd need this if we have a tree like:
- * ChangeSet
- * |____Resources
- * | |____ My resource 1
- * | |____ ...
- * |_____Drifts
- * |___ Drift #1
- * |___ Drift #2
- * |___ ...
- * Today we only have Drifts child nodes, so we don't need to have that intermediate
- * "Drifts" node. If we later want to introduce different node types (like Resources)
- * we need additional code like below.
- *
-
- // we are at an inner node, being asked to get the children of it
- if (p.endsWith("_drifts")) {
- // ...load drift items like above in the real code...
- } else if (p.endsWith("_resources")) {
- // ...load resource items and put those nodes in the tree...
- } else {
- // This is an unknown type of node, so just log an error.
- // Note that if, in the future, we have other types of nodes (like maybe resource nodes for group change sets?)
- // we'll add more if-else statements above to process those different nodes.
- CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure());
- }
-
- *
- */
- }
-
- return;
- }
-
- @Override
- protected BaseCriteria getFetchCriteria(DSRequest request) {
- // our executeFetch will determine on its own what criteria to use based on what is to be fetched
- // thus we don't return anything here and let the executeFetch do everything
- return null;
- }
-
- @Override
- public Object copyValues(Record from) {
- return null; // don't need this method.
- }
-
- @Override
- public ListGridRecord[] buildRecords(Collection dataObjects) {
- return buildRecordsForKnownChangeSets(dataObjects, null);
- }
-
- public ListGridRecord[] buildRecordsForKnownChangeSets(Collection dataObjects, Integer changeSetId) {
- if (dataObjects == null) {
- return null;
- }
-
- final List<ListGridRecord> records = new ArrayList<ListGridRecord>();
-
- for (Object item : dataObjects) {
-
- // the resultant item is a direct node to build
- records.add(copyValues(item));
-
- // now build the children of the node
- /*
- * We do not have the need for building any intermeidate nodes today.
- * There is nothing to do, but if in the future we have differnet node types,
- * we'll probably want intermediate nodes that we create here. See BundleTreeDataSource
- * for an example of where this is already done. Commenting this out just as an
- * example of how this can be done.
-
- if (item instanceof DriftChangeSet) {
- DriftChangeSet changeset = (DriftChangeSet) item;
-
- // each bundle has two direct children - the versions and destinations folders
- TreeNode versionNode = new TreeNode(MSG.view_drift());
- versionNode.setID(changeset.getId() + "_drifts");
- versionNode.setParentID(changeset.getId());
- versionNode.setName(MSG.view_drift());
- versionNode.setAttribute("name", MSG.view_drift());
- records.add(versionNode);
- } else if (item instanceof Drift) {
- if (canManageDrift) {
- records.add(copyValuesForKnownDriftChangeSet(driftItem, changeSetId));
- }
- }
-
- *
- */
- }
-
- return records.toArray(new ListGridRecord[records.size()]);
- }
-
- @Override
- public ListGridRecord copyValues(Object from) {
- return copyValuesForKnownDriftChangeSet(from, null);
- }
-
- public ListGridRecord copyValuesForKnownDriftChangeSet(Object from, Integer changeSetId) {
- TreeNode node;
- if (from instanceof DriftChangeSet) {
- DriftChangeSet changeset = (DriftChangeSet) from;
- node = new AbstractDriftChangeSetsTreeView.ChangeSetTreeNode(changeset);
- } else if (from instanceof Drift) {
- Drift drift = (Drift) from;
- node = new AbstractDriftChangeSetsTreeView.DriftTreeNode(drift);
- } else {
- throw new IllegalArgumentException("please report this bug - bad value: " + from);
- }
- // if, in the future, we add more node types, we'll add more else-if statements here
-
- return node;
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
index 3e368d5..3ee0b5f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
@@ -40,11 +40,13 @@ public class ResourceDriftChangeSetsTreeView extends AbstractDriftChangeSetsTree
}
this.context = context;
+
+ setDataSource(new ResourceDriftChangeSetsTreeDataSource(canManageDrift, context));
}
protected String getNodeTargetLink(TreeNode node) {
if (node instanceof DriftTreeNode) {
- String driftIdStr = node.getAttribute(DriftChangeSetsTreeDataSource.ATTR_ID).split("_")[1];
+ String driftIdStr = node.getAttribute(AbstractDriftChangeSetsTreeDataSource.ATTR_ID).split("_")[1];
String path = LinkManager.getDriftHistoryLink(this.context.resourceId, Integer.valueOf(driftIdStr));
return path;
}
commit aacd5bbe5c198d23ef5c775a473f4f68e54eea86
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 26 09:22:15 2011 -0400
Adding logic to check the enabled flag during drift detection
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 153e5a9..b92dd7c 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
@@ -47,44 +47,52 @@ public class DriftDetector implements Runnable {
@Override
public void run() {
- DriftDetectionSchedule schedule = scheduleQueue.getNextSchedule();
+ DriftDetectionSchedule schedule = scheduleQueue.dequeue();
if (schedule == null) {
return;
}
- try {
- if (schedule.getNextScan() > (System.currentTimeMillis() + 100L)) {
- return;
- }
+ if (schedule.getNextScan() > (System.currentTimeMillis() + 100L)) {
+ scheduleQueue.enqueue(schedule);
+ // TODO should we grab the schedule from the queue?
+ // Maybe we should continue pulling schedules off the queue until
+ // we find one that is ready to be processed.
+ return;
+ }
- if (!schedule.getDriftConfiguration().getEnabled()) {
- return;
- }
+ if (!schedule.getDriftConfiguration().getEnabled()) {
+ schedule.updateShedule();
+ scheduleQueue.enqueue(schedule);
+ // TODO should we grab the schedule from the queue?
+ // Maybe we should continue pulling schedules off the queue until
+ // we find one that is ready to be processed.
+ return;
+ }
- DriftConfiguration driftConfig = schedule.getDriftConfiguration();
- int resourceId = schedule.getResourceId();
- DriftChangeSetCategory changeSetType = null;
- int changes = 0;
-
- try {
- if (changeSetMgr.changeSetExists(schedule.getResourceId(), new Headers(driftConfig.getName(),
- basedir(resourceId, driftConfig), COVERAGE))) {
- changeSetType = DRIFT;
- changes = generateDriftChangeSet(schedule);
- } else {
- changeSetType = COVERAGE;
- generateCoverageChangeSet(schedule);
- }
- } catch (IOException e) {
- // TODO Call ChangeSetManager here to rollback any thing that was written to disk.
- log.error("An error occurred while scanning for drift", e);
- }
+ DriftConfiguration driftConfig = schedule.getDriftConfiguration();
+ int resourceId = schedule.getResourceId();
+ DriftChangeSetCategory changeSetType = null;
+ int changes = 0;
- if (changeSetType == COVERAGE || changes > 0) {
- driftClient.sendChangeSetToServer(schedule.getResourceId(), driftConfig, changeSetType);
+ try {
+ if (changeSetMgr.changeSetExists(schedule.getResourceId(), new Headers(driftConfig.getName(),
+ basedir(resourceId, driftConfig), COVERAGE))) {
+ changeSetType = DRIFT;
+ changes = generateDriftChangeSet(schedule);
+ } else {
+ changeSetType = COVERAGE;
+ generateCoverageChangeSet(schedule);
}
- } finally {
- scheduleQueue.deactivateSchedule();
+ } catch (IOException e) {
+ // TODO Call ChangeSetManager here to rollback any thing that was written to disk.
+ log.error("An error occurred while scanning for drift", e);
+ }
+
+ schedule.updateShedule();
+ scheduleQueue.enqueue(schedule);
+
+ if (changeSetType == COVERAGE || changes > 0) {
+ driftClient.sendChangeSetToServer(schedule.getResourceId(), driftConfig, changeSetType);
}
}
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 49dab54..9b62422 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
@@ -58,7 +58,7 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration driftConfig = driftConfiguration("coverage-test", resourceDir.getAbsolutePath());
- scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), driftConfig));
+ scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), driftConfig));
detector.run();
File changeSet = changeSet(driftConfig.getName(), COVERAGE);
@@ -77,12 +77,12 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration driftConfig = driftConfiguration("basedir-entry-test", resourceDir.getAbsolutePath());
- scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), driftConfig));
+ scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), driftConfig));
detector.run();
DriftDetectionSchedule schedule = new DriftDetectionSchedule(resourceId(), driftConfig);
- scheduleQueue.addSchedule(schedule);
+ scheduleQueue.enqueue(schedule);
detector.run();
assertChangeSetContainsDirEntry(changeSet(driftConfig.getName(), COVERAGE),
@@ -102,7 +102,7 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration config = driftConfiguration("multiple-files-test", resourceDir.getAbsolutePath());
- scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File changeSet = changeSet(config.getName(), COVERAGE);
@@ -127,7 +127,7 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration config = driftConfiguration("sibling-dirs-test", resourceDir.getAbsolutePath());
- scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File changeSet = changeSet(config.getName(), COVERAGE);
@@ -153,7 +153,7 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration config = driftConfiguration("nested-dirs-test", resourceDir.getAbsolutePath());
- scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File changeSet = changeSet(config.getName(), COVERAGE);
@@ -188,7 +188,7 @@ public class DriftDetectorTest extends DriftTest {
File server1Conf = new File(confDir, "server-1.conf");
touch(server1Conf);
- scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
detector.run();
}
@@ -217,7 +217,7 @@ public class DriftDetectorTest extends DriftTest {
File server2Conf = new File(confDir, "server-2.conf");
touch(server2Conf);
- scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File driftChangeSet = changeSet(config.getName(), DRIFT);
@@ -266,7 +266,7 @@ public class DriftDetectorTest extends DriftTest {
// create some drift
server2Conf.delete();
- scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File driftChangeSet = changeSet(config.getName(), DRIFT);
commit b2c361ccfb990323c384e2f109552864cc1f993a
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jul 25 17:53:45 2011 -0400
sort the query in desc order, though the tree currently ignores this and has its own sorting.
need to fix that later
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
index fe8586a..c6e9e65 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
@@ -95,7 +95,7 @@ public class DriftChangeSetsTreeDataSource extends RPCDataSource<Object, BaseCri
// Get the top nodes (the change sets) but to be as fast as possible don't load their drifts.
// We will lazily load drifts when the these changeset tree nodes are opened
DriftChangeSetCriteria criteria = new DriftChangeSetJPACriteria();
- criteria.addSortVersion(PageOrdering.ASC);
+ criteria.addSortVersion(PageOrdering.DESC);
criteria.setPageControl(getPageControl(request));
driftService.findDriftChangeSetsByCriteria(criteria, new AsyncCallback<PageList<DriftChangeSet>>() {
commit 3d5dcc8f08d9a11016d929f648cccf061c424ba7
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jul 25 17:53:03 2011 -0400
default subtab view for drift is the change set tree
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 4efc189..0e63d8e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -243,13 +243,13 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
driftTab = new TwoLevelTab(getTabSet().extendLocatorId(Tab.DRIFT), new ViewName(Tab.DRIFT, MSG
.view_tabs_common_drift()), "subsystems/drift/Drift_16.png");
- this.driftHistory = new SubTab(driftTab.extendLocatorId(DriftSubTab.HISTORY), new ViewName(DriftSubTab.HISTORY,
- MSG.view_tabs_common_history()), null);
this.driftChangeSets = new SubTab(driftTab.extendLocatorId(DriftSubTab.CHANGE_SETS), new ViewName(
DriftSubTab.CHANGE_SETS, MSG.view_drift_changeSets()), null);
+ this.driftHistory = new SubTab(driftTab.extendLocatorId(DriftSubTab.HISTORY), new ViewName(DriftSubTab.HISTORY,
+ MSG.view_tabs_common_history()), null);
this.driftConfig = new SubTab(driftTab.extendLocatorId(DriftSubTab.CONFIGURATION), new ViewName(
DriftSubTab.CONFIGURATION, MSG.view_tabs_common_configuration()), null);
- driftTab.registerSubTabs(driftHistory, driftChangeSets, driftConfig);
+ driftTab.registerSubTabs(driftChangeSets, driftHistory, driftConfig);
tabs.add(driftTab);
contentTab = new TwoLevelTab(getTabSet().extendLocatorId("Content"), new ViewName("Content", MSG
@@ -519,17 +519,17 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
ResourcePermission resourcePermissions, Set<ResourceTypeFacet> facets) {
if (updateTab(this.driftTab, facets.contains(ResourceTypeFacet.DRIFT), resourcePermissions.isDrift())) {
- updateSubTab(this.driftTab, this.driftHistory, true, true, new ViewFactory() {
+ updateSubTab(this.driftTab, this.driftChangeSets, true, true, new ViewFactory() {
@Override
public Canvas createView() {
- return ResourceDriftHistoryView.get(driftHistory.extendLocatorId("View"), resourceComposite);
+ return ResourceDriftChangeSetsView.get(driftChangeSets.extendLocatorId("View"), resourceComposite);
}
});
- updateSubTab(this.driftTab, this.driftChangeSets, true, true, new ViewFactory() {
+ updateSubTab(this.driftTab, this.driftHistory, true, true, new ViewFactory() {
@Override
public Canvas createView() {
- return ResourceDriftChangeSetsView.get(driftChangeSets.extendLocatorId("View"), resourceComposite);
+ return ResourceDriftHistoryView.get(driftHistory.extendLocatorId("View"), resourceComposite);
}
});
commit 9c2a1bd249ad2bd9d8de882ec806cc3e03d15c74
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jul 25 17:49:19 2011 -0400
initial start of the context menu for the change set tree
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
index 521d7b2..50d787d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -27,14 +27,24 @@ import com.google.gwt.core.client.RunAsyncCallback;
import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
+import com.smartgwt.client.widgets.menu.Menu;
+import com.smartgwt.client.widgets.menu.MenuItem;
+import com.smartgwt.client.widgets.menu.MenuItemSeparator;
+import com.smartgwt.client.widgets.menu.events.ClickHandler;
+import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
import com.smartgwt.client.widgets.tree.Tree;
import com.smartgwt.client.widgets.tree.TreeNode;
-import com.smartgwt.client.widgets.tree.events.NodeClickEvent;
-import com.smartgwt.client.widgets.tree.events.NodeClickHandler;
+import com.smartgwt.client.widgets.tree.events.NodeContextClickEvent;
+import com.smartgwt.client.widgets.tree.events.NodeContextClickHandler;
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
/**
@@ -56,18 +66,9 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
setAnimateFolders(false);
setSelectionType(SelectionStyle.SINGLE);
setShowRollOver(false);
- setSortField(DriftChangeSetsTreeDataSource.ATTR_NAME);
setShowHeader(false);
setDataSource(new DriftChangeSetsTreeDataSource(canManageDrift));
-
- addNodeClickHandler(new NodeClickHandler() {
- public void onNodeClick(NodeClickEvent event) {
- TreeNode node = event.getNode();
- String link = getNodeTargetLink(node);
- CoreGUI.goToView(link);
- }
- });
}
@Override
@@ -76,13 +77,30 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
// We may need to wait for tree data to be fetched before we can complete processing the selected path.
// When the datasource pulls data keep processing the selectedPath if necessary.
- this.addDataArrivedHandler(new DataArrivedHandler() {
+ addDataArrivedHandler(new DataArrivedHandler() {
public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
if (null != pendingPath) {
selectPath(pendingPath);
}
}
});
+
+ addNodeContextClickHandler(new NodeContextClickHandler() {
+ public void onNodeContextClick(final NodeContextClickEvent event) {
+ // stop the browser right-click menu
+ event.cancel();
+
+ TreeNode eventNode = event.getNode();
+
+ if (eventNode instanceof ChangeSetTreeNode) {
+ CoreGUI.getMessageCenter().notify(new Message("TODO [this will popup the changeset menu]"));
+ } else if (eventNode instanceof DriftTreeNode) {
+ Menu menu = buildContextMenu((DriftTreeNode) eventNode);
+ menu.showContextMenu();
+ }
+ }
+ });
+
}
public void selectPath(ViewPath viewPath) {
@@ -144,4 +162,76 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
* @return the node's link
*/
protected abstract String getNodeTargetLink(TreeNode node);
+
+ /**
+ * Builds the right-mouse-click context menu for the given drift node
+ * @param node the drift node whose menu is to be displayed
+ * @return the context menu to display
+ */
+ protected Menu buildContextMenu(final DriftTreeNode node) {
+
+ Menu contextMenu = new Menu();
+
+ // title
+ String titleName = node.getName();
+ if (titleName.length() > 50) {
+ // make sure the title isn't really long so the menu is not abnormally wide
+ titleName = "..." + titleName.substring(titleName.length() - 50);
+ }
+ MenuItem titleItem = new MenuItem(titleName);
+ titleItem.setEnabled(false);
+ contextMenu.setItems(titleItem);
+
+ // separator
+ contextMenu.addItem(new MenuItemSeparator());
+
+ // item that links to the history details
+ MenuItem detailsItem = new MenuItem(MSG.common_title_details());
+ detailsItem.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ String link = getNodeTargetLink(node);
+ if (link != null) {
+ CoreGUI.goToView(link);
+ }
+ }
+ });
+ contextMenu.addItem(detailsItem);
+
+ return contextMenu;
+ }
+
+ @SuppressWarnings("unchecked")
+ static class ChangeSetTreeNode extends TreeNode {
+ public ChangeSetTreeNode(DriftChangeSet changeset) {
+ setIsFolder(true);
+ setIcon("subsystems/drift/ChangeSet_16.png");
+ setShowOpenIcon(true);
+ setID(changeset.getId());
+ setName(buildDriftChangeSetNodeName(changeset));
+ }
+
+ private String buildDriftChangeSetNodeName(DriftChangeSet changeset) {
+ StringBuilder str = new StringBuilder();
+ str.append(MSG.common_title_version());
+ str.append(' ');
+ str.append(changeset.getVersion());
+ str.append(" (");
+ str.append(TimestampCellFormatter.format(changeset.getCtime(),
+ TimestampCellFormatter.DATE_TIME_FORMAT_SHORT));
+ str.append(')');
+ return str.toString();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ static class DriftTreeNode extends TreeNode {
+ public DriftTreeNode(Drift drift) {
+ setIsFolder(false);
+ setIcon(ImageManager.getDriftCategoryIcon(drift.getCategory()));
+ String parentID = drift.getChangeSet().getId();
+ setParentID(parentID);
+ setID(parentID + '_' + drift.getId());
+ setName(drift.getPath());
+ }
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
index c609a1e..fe8586a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
@@ -39,9 +39,8 @@ import org.rhq.core.domain.criteria.DriftJPACriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.DriftGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
@@ -96,6 +95,7 @@ public class DriftChangeSetsTreeDataSource extends RPCDataSource<Object, BaseCri
// Get the top nodes (the change sets) but to be as fast as possible don't load their drifts.
// We will lazily load drifts when the these changeset tree nodes are opened
DriftChangeSetCriteria criteria = new DriftChangeSetJPACriteria();
+ criteria.addSortVersion(PageOrdering.ASC);
criteria.setPageControl(getPageControl(request));
driftService.findDriftChangeSetsByCriteria(criteria, new AsyncCallback<PageList<DriftChangeSet>>() {
@@ -233,38 +233,18 @@ public class DriftChangeSetsTreeDataSource extends RPCDataSource<Object, BaseCri
}
public ListGridRecord copyValuesForKnownDriftChangeSet(Object from, Integer changeSetId) {
- String parentID;
- TreeNode node = new TreeNode();
+ TreeNode node;
if (from instanceof DriftChangeSet) {
DriftChangeSet changeset = (DriftChangeSet) from;
- node.setIsFolder(true);
- node.setIcon("subsystems/drift/ChangeSet_16.png");
- node.setShowOpenIcon(true);
- node.setID(changeset.getId());
- node.setName(buildDriftChangeSetNodeName(changeset));
-
+ node = new AbstractDriftChangeSetsTreeView.ChangeSetTreeNode(changeset);
} else if (from instanceof Drift) {
Drift drift = (Drift) from;
- node.setIsFolder(false);
- node.setIcon(ImageManager.getDriftCategoryIcon(drift.getCategory()));
- parentID = drift.getChangeSet().getId();
- node.setParentID(parentID);
- node.setID(parentID + '_' + drift.getId());
- node.setName(drift.getPath());
+ node = new AbstractDriftChangeSetsTreeView.DriftTreeNode(drift);
+ } else {
+ throw new IllegalArgumentException("please report this bug - bad value: " + from);
}
// if, in the future, we add more node types, we'll add more else-if statements here
return node;
}
-
- private String buildDriftChangeSetNodeName(DriftChangeSet changeset) {
- StringBuilder str = new StringBuilder();
- str.append(MSG.common_title_version());
- str.append(' ');
- str.append(changeset.getVersion());
- str.append(" (");
- str.append(TimestampCellFormatter.format(changeset.getCtime(), TimestampCellFormatter.DATE_TIME_FORMAT_SHORT));
- str.append(')');
- return str.toString();
- }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
index dc2a22d..3e368d5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
@@ -43,9 +43,12 @@ public class ResourceDriftChangeSetsTreeView extends AbstractDriftChangeSetsTree
}
protected String getNodeTargetLink(TreeNode node) {
- String driftIdStr = node.getAttribute(DriftChangeSetsTreeDataSource.ATTR_ID).split("_")[1];
- String path = LinkManager.getDriftHistoryLink(this.context.resourceId, Integer.valueOf(driftIdStr));
- return path;
+ if (node instanceof DriftTreeNode) {
+ String driftIdStr = node.getAttribute(DriftChangeSetsTreeDataSource.ATTR_ID).split("_")[1];
+ String path = LinkManager.getDriftHistoryLink(this.context.resourceId, Integer.valueOf(driftIdStr));
+ return path;
+ }
+ return null;
}
}
commit 36d7884b3f156c42b005be6c7c6d0b8907277dd7
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jul 25 16:37:56 2011 -0400
the initial start of the drift change set tree view
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
index 8203361..521d7b2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -24,29 +24,17 @@ package org.rhq.enterprise.gui.coregui.client.drift;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
-import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.SelectionStyle;
-import com.smartgwt.client.types.SortDirection;
-import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
-import com.smartgwt.client.widgets.menu.Menu;
-import com.smartgwt.client.widgets.menu.MenuItem;
-import com.smartgwt.client.widgets.menu.MenuItemSeparator;
-import com.smartgwt.client.widgets.menu.events.ClickHandler;
-import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
import com.smartgwt.client.widgets.tree.Tree;
import com.smartgwt.client.widgets.tree.TreeNode;
-import com.smartgwt.client.widgets.tree.events.NodeContextClickEvent;
-import com.smartgwt.client.widgets.tree.events.NodeContextClickHandler;
+import com.smartgwt.client.widgets.tree.events.NodeClickEvent;
+import com.smartgwt.client.widgets.tree.events.NodeClickHandler;
-import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
/**
@@ -66,11 +54,20 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
// fetch the top nodes at the inital onDraw()
setAutoFetchData(true);
setAnimateFolders(false);
- setSelectionType(SelectionStyle.MULTIPLE);
+ setSelectionType(SelectionStyle.SINGLE);
setShowRollOver(false);
+ setSortField(DriftChangeSetsTreeDataSource.ATTR_NAME);
setShowHeader(false);
- setSortField(AbstractDriftChangeSetsTreeDataSource.ATTR_NAME);
- setSortDirection(SortDirection.DESCENDING);
+
+ setDataSource(new DriftChangeSetsTreeDataSource(canManageDrift));
+
+ addNodeClickHandler(new NodeClickHandler() {
+ public void onNodeClick(NodeClickEvent event) {
+ TreeNode node = event.getNode();
+ String link = getNodeTargetLink(node);
+ CoreGUI.goToView(link);
+ }
+ });
}
@Override
@@ -79,31 +76,13 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
// We may need to wait for tree data to be fetched before we can complete processing the selected path.
// When the datasource pulls data keep processing the selectedPath if necessary.
- addDataArrivedHandler(new DataArrivedHandler() {
+ this.addDataArrivedHandler(new DataArrivedHandler() {
public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
if (null != pendingPath) {
selectPath(pendingPath);
}
}
});
-
- addNodeContextClickHandler(new NodeContextClickHandler() {
- public void onNodeContextClick(final NodeContextClickEvent event) {
- // stop the browser right-click menu
- event.cancel();
-
- TreeNode eventNode = event.getNode();
-
- if (eventNode instanceof ChangeSetTreeNode) {
- Menu menu = buildChangeSetTreeNodeContextMenu((ChangeSetTreeNode) eventNode);
- menu.showContextMenu();
- } else if (eventNode instanceof DriftTreeNode) {
- Menu menu = buildDriftTreeNodeContextMenu((DriftTreeNode) eventNode);
- menu.showContextMenu();
- }
- }
- });
-
}
public void selectPath(ViewPath viewPath) {
@@ -165,131 +144,4 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
* @return the node's link
*/
protected abstract String getNodeTargetLink(TreeNode node);
-
- /**
- * Builds the right-mouse-click context menu for the given drift node
- * @param node the drift node whose menu is to be displayed
- * @return the context menu to display
- */
- protected Menu buildDriftTreeNodeContextMenu(final DriftTreeNode node) {
-
- Menu contextMenu = new Menu();
-
- // title
- String titleName = node.getTitle();
- if (titleName.length() > 50) {
- // make sure the title isn't really long so the menu is not abnormally wide
- titleName = "..." + titleName.substring(titleName.length() - 50);
- }
- MenuItem titleItem = new MenuItem(titleName);
- titleItem.setEnabled(false);
- contextMenu.setItems(titleItem);
-
- // separator
- contextMenu.addItem(new MenuItemSeparator());
-
- // item that links to the history details
- MenuItem detailsItem = new MenuItem(MSG.common_title_details());
- detailsItem.addClickHandler(new ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- String link = getNodeTargetLink(node);
- if (link != null) {
- CoreGUI.goToView(link);
- }
- }
- });
- contextMenu.addItem(detailsItem);
-
- return contextMenu;
- }
-
- /**
- * Builds the right-mouse-click context menu for the given change set node
- * @param node the change set node whose menu is to be displayed
- * @return the context menu to display
- */
- protected Menu buildChangeSetTreeNodeContextMenu(final ChangeSetTreeNode node) {
-
- Menu contextMenu = new Menu();
-
- // title
- String titleName = node.getTitle();
- MenuItem titleItem = new MenuItem(titleName);
- titleItem.setEnabled(false);
- contextMenu.setItems(titleItem);
-
- // separator
- contextMenu.addItem(new MenuItemSeparator());
-
- // item that links to the history details
- MenuItem deleteItem = new MenuItem(MSG.common_button_delete());
- deleteItem.addClickHandler(new ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- // TODO: delete the change set
- }
- });
- contextMenu.addItem(deleteItem);
-
- return contextMenu;
- }
-
- /**
- * We override this because we know all of our nodes will have titles. Without this,
- * I could not get the title of change set nodes to show - it always fell back to using
- * the name. This way is at least faster, since we don't do any conditional checking,
- * we always immediately use the getTitle results.
- */
- @Override
- protected String getNodeTitle(Record node, int recordNum, ListGridField field) {
- return ((TreeNode) node).getTitle();
- }
-
- @SuppressWarnings("unchecked")
- static class ChangeSetTreeNode extends TreeNode {
- public ChangeSetTreeNode(DriftChangeSet changeset) {
- setIsFolder(true);
- setIcon("subsystems/drift/ChangeSet_16.png");
- setShowOpenIcon(true);
- setID(changeset.getId());
- setName(padWithZeroes(changeset.getVersion())); // we sort on this column, hence we make sure the version # is padded
- setTitle(buildDriftChangeSetNodeName(changeset));
- }
-
- private String buildDriftChangeSetNodeName(DriftChangeSet changeset) {
- StringBuilder str = new StringBuilder();
- str.append(MSG.common_title_version());
- str.append(' ');
- str.append(changeset.getVersion());
- str.append(" (");
- str.append(TimestampCellFormatter.format(changeset.getCtime(),
- TimestampCellFormatter.DATE_TIME_FORMAT_SHORT));
- str.append(')');
- return str.toString();
- }
-
- private String padWithZeroes(int numberToPad) {
- String stringToPad = String.valueOf(numberToPad);
- char[] zeroes = new char[10 - stringToPad.length()];
- for (int i = 0; i < zeroes.length; i++)
- zeroes[i] = '0';
- return new String(zeroes) + stringToPad;
- }
- }
-
- @SuppressWarnings("unchecked")
- static class DriftTreeNode extends TreeNode {
- public DriftTreeNode(Drift drift) {
- setIsFolder(false);
- setIcon(ImageManager.getDriftCategoryIcon(drift.getCategory()));
- String parentID = drift.getChangeSet().getId();
- setParentID(parentID);
- setID(parentID + '_' + drift.getId());
- setName(drift.getPath()); // we sort on this column
- }
-
- @Override
- public String getTitle() {
- return super.getName();
- }
- }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
new file mode 100644
index 0000000..c609a1e
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
@@ -0,0 +1,270 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.tree.TreeNode;
+
+import org.rhq.core.domain.criteria.BaseCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
+import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.criteria.DriftJPACriteria;
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
+import org.rhq.enterprise.gui.coregui.client.gwt.DriftGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * @author John Mazzitelli
+ */
+@SuppressWarnings("unchecked")
+public class DriftChangeSetsTreeDataSource extends RPCDataSource<Object, BaseCriteria> {
+
+ private static final String ATTR_PARENT_ID = "parentId";
+ public static final String ATTR_ID = "id";
+ public static final String ATTR_NAME = "name";
+
+ private DriftGWTServiceAsync driftService = GWTServiceLookup.getDriftService();
+ private final boolean canManageDrift;
+
+ public DriftChangeSetsTreeDataSource(boolean canManageDrift) {
+ super();
+ this.canManageDrift = canManageDrift;
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ DataSourceField idDataField = new DataSourceTextField(ATTR_ID, MSG.common_title_id());
+ idDataField.setPrimaryKey(true);
+ fields.add(idDataField);
+
+ DataSourceTextField nameDataField = new DataSourceTextField(ATTR_NAME, MSG.common_title_name());
+ nameDataField.setCanEdit(false);
+ fields.add(nameDataField);
+
+ DataSourceTextField parentIdField = new DataSourceTextField(ATTR_PARENT_ID, MSG.common_title_id_parent());
+ parentIdField.setForeignKey(ATTR_ID);
+ fields.add(parentIdField);
+
+ return fields;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, final BaseCriteria unused) {
+
+ String parentId = request.getCriteria().getAttribute(ATTR_PARENT_ID);
+
+ if (parentId == null) {
+
+ // There is no parent - we are at the root of the tree.
+ // Get the top nodes (the change sets) but to be as fast as possible don't load their drifts.
+ // We will lazily load drifts when the these changeset tree nodes are opened
+ DriftChangeSetCriteria criteria = new DriftChangeSetJPACriteria();
+ criteria.setPageControl(getPageControl(request));
+
+ driftService.findDriftChangeSetsByCriteria(criteria, new AsyncCallback<PageList<DriftChangeSet>>() {
+ public void onSuccess(PageList<DriftChangeSet> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ } else {
+ String changesetId = parentId;
+ DriftCriteria criteria = new DriftJPACriteria();
+ criteria.addFilterChangeSetId(changesetId);
+
+ driftService.findDriftsByCriteria(criteria, new AsyncCallback<PageList<Drift>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onSuccess(PageList<Drift> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
+
+ /*
+ * I am leaving this code commented for future reference. Because today the drit change set tree only
+ * shows simple changeset->drift tree, we don't need this. But if we need to have
+ * multiple types of child nodes, we'll need something like below to query
+ * for the different child node data. For example, we'd need this if we have a tree like:
+ * ChangeSet
+ * |____Resources
+ * | |____ My resource 1
+ * | |____ ...
+ * |_____Drifts
+ * |___ Drift #1
+ * |___ Drift #2
+ * |___ ...
+ * Today we only have Drifts child nodes, so we don't need to have that intermediate
+ * "Drifts" node. If we later want to introduce different node types (like Resources)
+ * we need additional code like below.
+ *
+
+ // we are at an inner node, being asked to get the children of it
+ if (p.endsWith("_drifts")) {
+ // ...load drift items like above in the real code...
+ } else if (p.endsWith("_resources")) {
+ // ...load resource items and put those nodes in the tree...
+ } else {
+ // This is an unknown type of node, so just log an error.
+ // Note that if, in the future, we have other types of nodes (like maybe resource nodes for group change sets?)
+ // we'll add more if-else statements above to process those different nodes.
+ CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure());
+ }
+
+ *
+ */
+ }
+
+ return;
+ }
+
+ @Override
+ protected BaseCriteria getFetchCriteria(DSRequest request) {
+ // our executeFetch will determine on its own what criteria to use based on what is to be fetched
+ // thus we don't return anything here and let the executeFetch do everything
+ return null;
+ }
+
+ @Override
+ public Object copyValues(Record from) {
+ return null; // don't need this method.
+ }
+
+ @Override
+ public ListGridRecord[] buildRecords(Collection dataObjects) {
+ return buildRecordsForKnownChangeSets(dataObjects, null);
+ }
+
+ public ListGridRecord[] buildRecordsForKnownChangeSets(Collection dataObjects, Integer changeSetId) {
+ if (dataObjects == null) {
+ return null;
+ }
+
+ final List<ListGridRecord> records = new ArrayList<ListGridRecord>();
+
+ for (Object item : dataObjects) {
+
+ // the resultant item is a direct node to build
+ records.add(copyValues(item));
+
+ // now build the children of the node
+ /*
+ * We do not have the need for building any intermeidate nodes today.
+ * There is nothing to do, but if in the future we have differnet node types,
+ * we'll probably want intermediate nodes that we create here. See BundleTreeDataSource
+ * for an example of where this is already done. Commenting this out just as an
+ * example of how this can be done.
+
+ if (item instanceof DriftChangeSet) {
+ DriftChangeSet changeset = (DriftChangeSet) item;
+
+ // each bundle has two direct children - the versions and destinations folders
+ TreeNode versionNode = new TreeNode(MSG.view_drift());
+ versionNode.setID(changeset.getId() + "_drifts");
+ versionNode.setParentID(changeset.getId());
+ versionNode.setName(MSG.view_drift());
+ versionNode.setAttribute("name", MSG.view_drift());
+ records.add(versionNode);
+ } else if (item instanceof Drift) {
+ if (canManageDrift) {
+ records.add(copyValuesForKnownDriftChangeSet(driftItem, changeSetId));
+ }
+ }
+
+ *
+ */
+ }
+
+ return records.toArray(new ListGridRecord[records.size()]);
+ }
+
+ @Override
+ public ListGridRecord copyValues(Object from) {
+ return copyValuesForKnownDriftChangeSet(from, null);
+ }
+
+ public ListGridRecord copyValuesForKnownDriftChangeSet(Object from, Integer changeSetId) {
+ String parentID;
+ TreeNode node = new TreeNode();
+ if (from instanceof DriftChangeSet) {
+ DriftChangeSet changeset = (DriftChangeSet) from;
+ node.setIsFolder(true);
+ node.setIcon("subsystems/drift/ChangeSet_16.png");
+ node.setShowOpenIcon(true);
+ node.setID(changeset.getId());
+ node.setName(buildDriftChangeSetNodeName(changeset));
+
+ } else if (from instanceof Drift) {
+ Drift drift = (Drift) from;
+ node.setIsFolder(false);
+ node.setIcon(ImageManager.getDriftCategoryIcon(drift.getCategory()));
+ parentID = drift.getChangeSet().getId();
+ node.setParentID(parentID);
+ node.setID(parentID + '_' + drift.getId());
+ node.setName(drift.getPath());
+ }
+ // if, in the future, we add more node types, we'll add more else-if statements here
+
+ return node;
+ }
+
+ private String buildDriftChangeSetNodeName(DriftChangeSet changeset) {
+ StringBuilder str = new StringBuilder();
+ str.append(MSG.common_title_version());
+ str.append(' ');
+ str.append(changeset.getVersion());
+ str.append(" (");
+ str.append(TimestampCellFormatter.format(changeset.getCtime(), TimestampCellFormatter.DATE_TIME_FORMAT_SHORT));
+ str.append(')');
+ return str.toString();
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
index f610b8b..48f5bc8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
@@ -38,6 +38,13 @@ public class DriftChangeSetsView extends LocatableVLayout {
this.hasWriteAccess = hasWriteAccess;
}
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ addMember(new ResourceDriftChangeSetsTreeView(extendLocatorId("Tree"), this.hasWriteAccess, this.context));
+ }
+
public EntityContext getContext() {
return context;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
index 3ee0b5f..dc2a22d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
@@ -40,17 +40,12 @@ public class ResourceDriftChangeSetsTreeView extends AbstractDriftChangeSetsTree
}
this.context = context;
-
- setDataSource(new ResourceDriftChangeSetsTreeDataSource(canManageDrift, context));
}
protected String getNodeTargetLink(TreeNode node) {
- if (node instanceof DriftTreeNode) {
- String driftIdStr = node.getAttribute(AbstractDriftChangeSetsTreeDataSource.ATTR_ID).split("_")[1];
- String path = LinkManager.getDriftHistoryLink(this.context.resourceId, Integer.valueOf(driftIdStr));
- return path;
- }
- return null;
+ String driftIdStr = node.getAttribute(DriftChangeSetsTreeDataSource.ATTR_ID).split("_")[1];
+ String path = LinkManager.getDriftHistoryLink(this.context.resourceId, Integer.valueOf(driftIdStr));
+ return path;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index c7d6f91..ea8c956 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -1123,6 +1123,7 @@ view_drift_category_fileChanged = File Changed
view_drift_category_fileRemoved = File Removed
view_drift_changeSets = Change Sets
view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
view_drift_delete_confirm = Delete the selected drift(s)?
view_drift_delete_confirmAll = Delete all drifts from this source?
view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index 5fe14aa..a07568a 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -941,6 +941,7 @@ view_dashboards_title = Dashboard
##view_drift_category_fileRemoved = File Removed
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index 6bce847..6e68cff 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -1106,6 +1106,7 @@ view_dashboards_title = ダッシュボード
##view_drift = Drift
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
##view_drift_table_baseDir = Base Directory
##view_drift_table_changeSet = Change Set
##view_drift_table_newFile = New File
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index bd2b6fb..fa86006 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -1141,6 +1141,7 @@ view_dashboards_title = Dashboard~
##view_drift_category_fileRemoved = File Removed
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index 9fa9115..79816c5 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -1115,6 +1115,7 @@ view_dashboards_title = \u7edf\u8ba1\u8868\u76d8
##view_drift = Drift
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
##view_drift_table_baseDir = Base Directory
##view_drift_table_changeSet = Change Set
##view_drift_table_newFile = New File
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png
index e728bc8..fdda214 100644
Binary files a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png
index 1ca204f..358cf61 100644
Binary files a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png differ
commit f92e6778c84c0ee2a8264ccfde321992fd23ef4d
Author: John Sanda <jsanda(a)redhat.com>
Date: Sun Jul 24 21:13:24 2011 -0400
Adding createSnapshot method to drift server api
Also moving Snapshot and DiffReport classes to core/domain to make them
accessible to coregui.
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java
index c32f053..93653b3 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java
@@ -1,5 +1,10 @@
package org.rhq.core.domain.drift;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.testng.annotations.Test;
+
import static java.util.Arrays.asList;
import static org.rhq.core.domain.drift.DriftCategory.FILE_ADDED;
import static org.rhq.core.domain.drift.DriftCategory.FILE_CHANGED;
@@ -10,24 +15,19 @@ import static org.rhq.core.domain.drift.DriftFileStatus.LOADED;
import static org.rhq.test.AssertUtils.assertCollectionMatchesNoOrder;
import static org.testng.Assert.assertEquals;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.testng.annotations.Test;
-
public class SnapshotTest {
@Test
public void addChangeSetWithAddedFile() {
int configId = 1;
- FakeDriftChangeSet changeSet = new FakeDriftChangeSet(0, COVERAGE, configId).add(new FakeDrift(FILE_ADDED,
- null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt"));
+ FakeDriftChangeSet changeSet = new FakeDriftChangeSet(0, COVERAGE, configId)
+ .add(new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt"));
Snapshot snapshot = new Snapshot().add(changeSet);
- assertCollectionMatchesNoOrder(changeSet.getDrifts(), snapshot.getEntries(), "Failed to build "
- + "a snapshot that contains a single change set");
+ assertCollectionMatchesNoOrder(changeSet.getDrifts(), snapshot.getEntries(), "Failed to build " +
+ "a snapshot that contains a single change set");
assertEquals(snapshot.getVersion(), changeSet.getVersion(), "Snapshot version is wrong");
}
@@ -43,8 +43,8 @@ public class SnapshotTest {
Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
- assertCollectionMatchesNoOrder(asSet(entry1, entry2), snapshot.getEntries(), "Failed to build snapshot "
- + "with two change sets and file added in second change set");
+ assertCollectionMatchesNoOrder(asSet(entry1, entry2), snapshot.getEntries(), "Failed to build snapshot " +
+ "with two change sets and file added in second change set");
assertEquals(snapshot.getVersion(), changeSet2.getVersion(), "Snapshot version is wrong");
}
@@ -55,8 +55,8 @@ public class SnapshotTest {
Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
- Drift entry2 = new FakeDrift(FILE_CHANGED, new FakeDriftFile("a1b2c3", 1024, LOADED), new FakeDriftFile(
- "4d5e6f", 1024, LOADED), "/drift/1.txt");
+ Drift entry2 = new FakeDrift(FILE_CHANGED, new FakeDriftFile("a1b2c3", 1024, LOADED),
+ new FakeDriftFile("4d5e6f", 1024, LOADED), "/drift/1.txt");
FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2);
Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
@@ -78,8 +78,9 @@ public class SnapshotTest {
Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
- assertCollectionMatchesNoOrder(asSet(entry2), snapshot.getEntries(), "Failed to build snapshot with a file "
- + "removed.");
+ assertCollectionMatchesNoOrder(asSet(entry2), snapshot.getEntries(),
+ "Failed to build snapshot with a file " +
+ "removed.");
}
@Test
@@ -96,8 +97,9 @@ public class SnapshotTest {
DiffReport diff = left.diff(right);
- assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsNotInRight(), "Diff report does not contain " +
- "elements that are in the left but not in the right.");
+ assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsNotInRight(),
+ "Diff report does not contain " +
+ "elements that are in the left but not in the right.");
}
@Test
@@ -114,8 +116,9 @@ public class SnapshotTest {
DiffReport diff = left.diff(right);
- assertCollectionMatchesNoOrder(asList(entry1), diff.getElementsNotInLeft(), "Diff report does not contain " +
- "elements that are in the left but not in the right");
+ assertCollectionMatchesNoOrder(asList(entry1), diff.getElementsNotInLeft(),
+ "Diff report does not contain " +
+ "elements that are in the left but not in the right");
}
@Test
@@ -132,8 +135,9 @@ public class SnapshotTest {
DiffReport diff = left.diff(right);
- assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsInConflict(), "Diff report does not contain " +
- "element that are in both left and right and are in conflict");
+ assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsInConflict(),
+ "Diff report does not contain " +
+ "element that are in both left and right and are in conflict");
}
<E> Set<E> asSet(E... elements) {
@@ -314,8 +318,8 @@ public class SnapshotTest {
@Override
public String toString() {
- return "Drift[category: " + category.code() + ", oldFile: " + oldFile + ", newFile: " + newFile
- + ", path: " + path + "]";
+ return "Drift[category: " + category.code() + ", oldFile: " + oldFile + ", newFile: " + newFile +
+ ", path: " + path + "]";
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DiffReport.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DiffReport.java
deleted file mode 100644
index 89f3286..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DiffReport.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.rhq.enterprise.server.drift;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class DiffReport<T> {
-
- private List<T> notInLeft = new ArrayList<T>();
-
- private List<T> notInRight = new ArrayList<T>();
-
- private List<T> conflicts = new ArrayList<T>();
-
- public List<T> getElementsNotInLeft() {
- return notInLeft;
- }
-
- public void elementNotInLeft(T element) {
- notInLeft.add(element);
- }
-
- public List<T> getElementsNotInRight() {
- return notInRight;
- }
-
- public void elementNotInRight(T element) {
- notInRight.add(element);
- }
-
- public List<T> getElementsInConflict() {
- return conflicts;
- }
-
- public void elementInConflict(T element) {
- conflicts.add(element);
- }
-
-}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
deleted file mode 100644
index 5dc18fa..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.rhq.enterprise.server.drift;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.DriftChangeSet;
-import org.rhq.core.domain.drift.DriftFile;
-
-import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
-
-public class Snapshot implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private int version;
-
- private Map<String, Drift> entries = new TreeMap<String, Drift>();
-
- public int getVersion() {
- return version;
- }
-
- public Collection<Drift> getEntries() {
- return entries.values();
- }
-
- public <D extends Drift> Snapshot add(DriftChangeSet<D> changeSet) {
- for (Drift entry : changeSet.getDrifts()) {
- entries.remove(entry.getPath());
- if (entry.getCategory() != FILE_REMOVED) {
- entries.put(entry.getPath(), entry);
- }
- }
- version = changeSet.getVersion();
- return this;
- }
-
- public DiffReport diff(Snapshot right) {
- Snapshot left = this;
- DiffReport<Drift> diff = new DiffReport<Drift>();
-
- for (Map.Entry<String, Drift> entry : left.entries.entrySet()) {
- if (!right.entries.containsKey(entry.getKey())) {
- diff.elementNotInRight(entry.getValue());
- }
- }
-
- for (Map.Entry<String, Drift> entry : right.entries.entrySet()) {
- if (!left.entries.containsKey(entry.getKey())) {
- diff.elementNotInLeft(entry.getValue());
- }
- }
-
- for (Map.Entry<String, Drift> entry : left.entries.entrySet()) {
- Drift rightDrift = right.entries.get(entry.getKey());
- if (rightDrift != null) {
- DriftFile leftFile = entry.getValue().getNewDriftFile();
- DriftFile rightFile = rightDrift.getNewDriftFile();
-
- if (!leftFile.getHashId().equals(rightFile.getHashId())) {
- diff.elementInConflict(entry.getValue());
- }
- }
- }
-
- return diff;
- }
-
-}
commit 859c811f28b8169cdc4137ef69ed74f8e1a6ef5f
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat Jul 23 22:57:09 2011 -0400
First cut at createSnapshot method in DriftManagerBean
Also refactoring tests in server/jar to use the JPAUtils class for
resetting the db.
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
index c03e3e6..bc8d26a 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
@@ -38,24 +38,6 @@ public class RhqDriftChangeSetTest extends AbstractEJB3Test {
resource.setDriftConfigurations(driftConfigs);
-// executeInTransaction(new TransactionCallback() {
-// @Override
-// public void execute() throws Exception {
-// getEntityManager().createQuery("delete from RhqDriftChangeSet").executeUpdate();
-//
-// // Cascading deletes for Resource.driftConfigurations does not work, nor does it
-// // appear the orphan deletes work either. I came across https://hibernate.onjira.com/browse/HHH-1917
-// // and https://hibernate.onjira.com/browse/HHH-1917 which led me to using
-// // native SQL to perform the delete on the join table rhq_drift_config_map.
-// //
-// // jsanda
-// getEntityManager().createNativeQuery("delete from rhq_drift_config_map").executeUpdate();
-//
-// getEntityManager().createQuery("delete from Resource").executeUpdate();
-// getEntityManager().createQuery("delete from ResourceType").executeUpdate();
-// }
-// });
-
executeInTransaction(new TransactionCallback() {
@Override
public void execute() throws Exception {
commit afe3a4879e6ea3de983caf34fc80d9eddcef86ce
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat Jul 23 21:38:07 2011 -0400
Initial commit for JPAUtils
Refactoring some methods in AbstractEJB3Test to delegate to JPAUtils
with the intent to eliminate duplicate code in core/domain and
server/jar tests. Most importantly though, the method clearDB is now
part of JPAUtils making it accessible to any test. This provides a much
more robust way of resetting the entire database to a known, consistent
state.
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
index c9e61ef..c03e3e6 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
@@ -3,10 +3,6 @@ package org.rhq.core.domain.drift;
import java.util.HashSet;
import java.util.Set;
-import javax.persistence.EntityManager;
-import javax.transaction.SystemException;
-
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -16,6 +12,7 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.shared.ResourceBuilder;
import org.rhq.core.domain.test.AbstractEJB3Test;
+import org.rhq.test.TransactionCallback;
import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java b/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
index aa6e0e0..dc5319a 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
@@ -30,8 +30,6 @@ import java.util.Hashtable;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
import org.testng.AssertJUnit;
@@ -42,6 +40,13 @@ import org.testng.annotations.BeforeSuite;
import org.jboss.ejb3.embedded.EJB3StandaloneBootstrap;
import org.jboss.ejb3.embedded.EJB3StandaloneDeployer;
+import org.rhq.test.JPAUtils;
+import org.rhq.test.TransactionCallback;
+
+import static org.rhq.test.JPAUtils.clearDB;
+import static org.rhq.test.JPAUtils.lookupEntityManager;
+import static org.rhq.test.JPAUtils.lookupTransactionManager;
+
public abstract class AbstractEJB3Test extends AssertJUnit {
@BeforeClass
@@ -96,26 +101,12 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
EJB3StandaloneBootstrap.shutdown();
}
- private TransactionManager tm;
-
public TransactionManager getTransactionManager() {
- try {
- tm = (TransactionManager) getInitialContext().lookup("java:/TransactionManager");
- return tm;
- } catch (NamingException e) {
- e.printStackTrace();
- throw new RuntimeException("Failed to load transaction manager", e);
- }
+ return lookupTransactionManager();
}
public EntityManager getEntityManager() {
- try {
- return ((EntityManagerFactory) getInitialContext().lookup("java:/RHQEntityManagerFactory"))
- .createEntityManager();
- } catch (NamingException e) {
- e.printStackTrace();
- throw new RuntimeException("Failed to load entity manager", e);
- }
+ return lookupEntityManager();
}
public boolean isPostgres(EntityManager em) throws Exception {
@@ -148,171 +139,7 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
}
protected void executeInTransaction(TransactionCallback callback) {
- try {
- getTransactionManager().begin();
- callback.execute();
- getTransactionManager().commit();
- } catch (Throwable t) {
- try {
- getTransactionManager().rollback();
- } catch (SystemException e) {
- throw new RuntimeException("Failed to rollback transaction", e);
- }
- throw new RuntimeException(t.getCause());
- }
+ JPAUtils.executeInTransaction(callback);
}
- void clearDB() throws Exception {
- executeInTransaction(new TransactionCallback() {
- @Override
- public void execute() throws Exception {
- EntityManager em = getEntityManager();
-
- em.createNativeQuery("delete from jms_subscriptions");
- em.createNativeQuery("delete from jms_roles");
- em.createNativeQuery("delete from jms_users");
- em.createNativeQuery("delete from jms_transactions");
- em.createNativeQuery("delete from jms_messages");
- em.createNativeQuery("delete from rhq_drift_config_map");
- em.createNativeQuery("delete from rhq_drift_template_map");
- em.createNativeQuery("delete from rhq_delete_res_hist");
- em.createNativeQuery("delete from rhq_create_res_hist");
- em.createNativeQuery("delete from rhq_tagging_bundle_dest_map");
- em.createNativeQuery("delete from rhq_tagging_bundle_deploy_map");
- em.createNativeQuery("delete from rhq_tagging_bundle_version_map");
- em.createNativeQuery("delete from rhq_tagging_bundle_map");
- em.createNativeQuery("delete from rhq_bundle_res_dep_hist");
- em.createNativeQuery("delete from rhq_bundle_res_deploy");
- em.createNativeQuery("delete from rhq_bundle_deployment");
- em.createNativeQuery("delete from rhq_bundle_destination");
- em.createNativeQuery("delete from rhq_bundle_file");
- em.createNativeQuery("delete from rhq_bundle_version_repo");
- em.createNativeQuery("delete from rhq_bundle_version");
- em.createNativeQuery("delete from rhq_bundle");
- em.createNativeQuery("delete from rhq_bundle_type");
- em.createNativeQuery("delete from rhq_repo_advisory");
- em.createNativeQuery("delete from rhq_advisory_buglist");
- em.createNativeQuery("delete from rhq_advisory_cve");
- em.createNativeQuery("delete from rhq_cve");
- em.createNativeQuery("delete from rhq_advisory_package");
- em.createNativeQuery("delete from rhq_advisory");
- em.createNativeQuery("delete from rhq_distribution_file");
- em.createNativeQuery("delete from rhq_repo_distribution");
- em.createNativeQuery("delete from rhq_distribution where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_pkg_prd_map");
- em.createNativeQuery("delete from rhq_pkg_ver_content_src_map");
- em.createNativeQuery("delete from rhq_repo_pkg_version_map");
- em.createNativeQuery("delete from rhq_repo_repo_relation_map");
- em.createNativeQuery("delete from rhq_repo_repo_group_map");
- em.createNativeQuery("delete from rhq_repo_content_src_map");
- em.createNativeQuery("delete from rhq_repo_resource_map");
- em.createNativeQuery("delete from rhq_package_inst_step");
- em.createNativeQuery("delete from rhq_repo_sync");
- em.createNativeQuery("delete from rhq_content_src_sync");
- em.createNativeQuery("delete from rhq_installed_pkg_hist");
- em.createNativeQuery("delete from rhq_installed_package");
- em.createNativeQuery("delete from rhq_content_req");
- em.createNativeQuery("delete from rhq_package_version");
- em.createNativeQuery("delete from rhq_package_bits");
- em.createNativeQuery("delete from rhq_package");
- em.createNativeQuery("delete from rhq_package_type");
- em.createNativeQuery("delete from rhq_repo_relation");
- em.createNativeQuery("delete from rhq_repo_relation_type where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_repo");
- em.createNativeQuery("delete from rhq_repo_group");
- em.createNativeQuery("delete from rhq_repo_group_type where id <> 1");
- em.createNativeQuery("delete from rhq_archirtecture where id < 1 and id > 38");
- em.createNativeQuery("delete from rhq_meas_data_num_r14");
- em.createNativeQuery("delete from rhq_meas_data_num_r13");
- em.createNativeQuery("delete from rhq_meas_data_num_r12");
- em.createNativeQuery("delete from rhq_meas_data_num_r11");
- em.createNativeQuery("delete from rhq_meas_data_num_r10");
- em.createNativeQuery("delete from rhq_meas_data_num_r09");
- em.createNativeQuery("delete from rhq_meas_data_num_r08");
- em.createNativeQuery("delete from rhq_meas_data_num_r07");
- em.createNativeQuery("delete from rhq_meas_data_num_r06");
- em.createNativeQuery("delete from rhq_meas_data_num_r05");
- em.createNativeQuery("delete from rhq_meas_data_num_r04");
- em.createNativeQuery("delete from rhq_meas_data_num_r03");
- em.createNativeQuery("delete from rhq_meas_data_num_r02");
- em.createNativeQuery("delete from rhq_meas_data_num_r01");
- em.createNativeQuery("delete from rhq_meas_data_num_r00");
- em.createNativeQuery("delete from rhq_measurement_oob_tmp");
- em.createNativeQuery("delete rhq_measurement_oob");
- em.createNativeQuery("delete rhq_resource_avail");
- em.createNativeQuery("delete from rhq_availability");
- em.createNativeQuery("delete from rhq_calltime_data_value");
- em.createNativeQuery("delete from rhq_calltime_data_key");
- em.createNativeQuery("delete from rhq_measurement_data_trait");
- em.createNativeQuery("delete from rhq_measurement_data_num_1d");
- em.createNativeQuery("delete from rhq_measurement_data_num_6h");
- em.createNativeQuery("delete from rhq_measurement_data_num_1h");
- em.createNativeQuery("delete from rhq_measurement_bline");
- em.createNativeQuery("delete from rhq_measurement_sched");
- em.createNativeQuery("delete from rhq_measurement_def");
- em.createNativeQuery("delete from rhq_plugin");
- em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56)");
- em.createNativeQuery("delete from rhq_alert_notification");
- em.createNativeQuery("delete from rhq_alert_condition_log");
- em.createNativeQuery("delete from rhq_alert");
- em.createNativeQuery("delete from rhq_alert_condition");
- em.createNativeQuery("delete from rhq_alert_dampen_event");
- em.createNativeQuery("delete from rhq_alert_definition");
- em.createNativeQuery("delete from rhq_event");
- em.createNativeQuery("delete from rhq_event_source");
- em.createNativeQuery("delete from rhq_event_def");
- em.createNativeQuery("delete from rhq_operation_schedule");
- em.createNativeQuery("delete from rhq_operation_history");
- em.createNativeQuery("delete from rhq_operation_def");
- em.createNativeQuery("delete from rhq_dashboard_portlet");
- em.createNativeQuery("delete from rhq_dashboard");
- em.createNativeQuery("delete from rhq_saved_search");
- em.createNativeQuery("delete from rhq_subject_role_ldap_map");
- em.createNativeQuery("delete from rhq_subject_role_map where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_permission where role_id not in (1, 2)");
- em.createNativeQuery("delete from rhq_role_ldap_group");
- em.createNativeQuery("delete from rhq_role_resource_group_map");
- em.createNativeQuery("delete from rhq_role where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_tagging_res_group_map");
- em.createNativeQuery("delete from rhq_tagging_resource_map");
- em.createNativeQuery("delete from rhq_tagging");
- em.createNativeQuery("delete from rhq_config_update");
- em.createNativeQuery("delete from rhq_config_group_update");
- em.createNativeQuery("delete from rhq_resource_group_res_exp_map");
- em.createNativeQuery("delete from rhq_resource_group_res_imp_map");
- em.createNativeQuery("delete from rhq_resource_group");
- em.createNativeQuery("delete from rhq_group_def");
- em.createNativeQuery("delete from rhq_resource_error");
- em.createNativeQuery("delete from rhq_resource");
- em.createNativeQuery("delete from rhq_prd_ver");
- em.createNativeQuery("delete from rhq_process_scan");
- em.createNativeQuery("delete from rhq_resource_type_parents");
- em.createNativeQuery("delete from rhq_resource_subcat");
- em.createNativeQuery("delete from rhq_resource_type");
- em.createNativeQuery("delete from rhq_subject where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_principal where id <> 2");
- em.createNativeQuery("delete from rhq_failover_details");
- em.createNativeQuery("delete from rhq_failover_list");
- em.createNativeQuery("delete from rhq_partition_details");
- em.createNativeQuery("delete from rhq_partition_event");
- em.createNativeQuery("delete from rhq_agent");
- em.createNativeQuery("delete from rhq_server");
- em.createNativeQuery("delete from rhq_affinity_group");
- em.createNativeQuery("delete from rhq_raw_config");
- em.createNativeQuery("delete from rhq_config_template");
- em.createNativeQuery("delete from rhq_config_property");
- em.createNativeQuery("delete from rhq_config");
- em.createNativeQuery("delete from rhq_config_prop_constr");
- em.createNativeQuery("delete from rhq_conf_prop_def_enum");
- em.createNativeQuery("delete from rhq_config_pd_osrc");
- em.createNativeQuery("delete from rhq_config_prop_def");
- em.createNativeQuery("delete from rhq_config_prop_grp_def");
- em.createNativeQuery("delete from rhq_config_def");
- }
- });
- }
-
- public static interface TransactionCallback {
- void execute() throws Exception;
- }
}
\ No newline at end of file
diff --git a/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
index 46611ed..349b84c 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
@@ -143,7 +143,7 @@ public class JPAUtils {
em.createNativeQuery("delete from rhq_measurement_sched");
em.createNativeQuery("delete from rhq_measurement_def");
em.createNativeQuery("delete from rhq_plugin");
- em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56, 57)");
+ em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56)");
em.createNativeQuery("delete from rhq_alert_notification");
em.createNativeQuery("delete from rhq_alert_condition_log");
em.createNativeQuery("delete from rhq_alert");
commit 82eafed13bb5e2f0e3e6bda0c59406ef38f29e55
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat Jul 23 07:09:35 2011 -0400
Adding support for version and date ranges in DriftChangeSetCriteria
Version and/or date ranges are needed in order to fetch multiple change
sets to build a snapshot. This commit also includes new set up code in
the base test class AbstractEJB3Test. It clears all database tables
which should be more robust than the approach taken with dbunit.
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
index bc8d26a..c9e61ef 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
@@ -3,6 +3,10 @@ package org.rhq.core.domain.drift;
import java.util.HashSet;
import java.util.Set;
+import javax.persistence.EntityManager;
+import javax.transaction.SystemException;
+
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -12,7 +16,6 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.shared.ResourceBuilder;
import org.rhq.core.domain.test.AbstractEJB3Test;
-import org.rhq.test.TransactionCallback;
import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
@@ -38,6 +41,24 @@ public class RhqDriftChangeSetTest extends AbstractEJB3Test {
resource.setDriftConfigurations(driftConfigs);
+// executeInTransaction(new TransactionCallback() {
+// @Override
+// public void execute() throws Exception {
+// getEntityManager().createQuery("delete from RhqDriftChangeSet").executeUpdate();
+//
+// // Cascading deletes for Resource.driftConfigurations does not work, nor does it
+// // appear the orphan deletes work either. I came across https://hibernate.onjira.com/browse/HHH-1917
+// // and https://hibernate.onjira.com/browse/HHH-1917 which led me to using
+// // native SQL to perform the delete on the join table rhq_drift_config_map.
+// //
+// // jsanda
+// getEntityManager().createNativeQuery("delete from rhq_drift_config_map").executeUpdate();
+//
+// getEntityManager().createQuery("delete from Resource").executeUpdate();
+// getEntityManager().createQuery("delete from ResourceType").executeUpdate();
+// }
+// });
+
executeInTransaction(new TransactionCallback() {
@Override
public void execute() throws Exception {
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java b/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
index dc5319a..aa6e0e0 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
@@ -30,6 +30,8 @@ import java.util.Hashtable;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
import org.testng.AssertJUnit;
@@ -40,13 +42,6 @@ import org.testng.annotations.BeforeSuite;
import org.jboss.ejb3.embedded.EJB3StandaloneBootstrap;
import org.jboss.ejb3.embedded.EJB3StandaloneDeployer;
-import org.rhq.test.JPAUtils;
-import org.rhq.test.TransactionCallback;
-
-import static org.rhq.test.JPAUtils.clearDB;
-import static org.rhq.test.JPAUtils.lookupEntityManager;
-import static org.rhq.test.JPAUtils.lookupTransactionManager;
-
public abstract class AbstractEJB3Test extends AssertJUnit {
@BeforeClass
@@ -101,12 +96,26 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
EJB3StandaloneBootstrap.shutdown();
}
+ private TransactionManager tm;
+
public TransactionManager getTransactionManager() {
- return lookupTransactionManager();
+ try {
+ tm = (TransactionManager) getInitialContext().lookup("java:/TransactionManager");
+ return tm;
+ } catch (NamingException e) {
+ e.printStackTrace();
+ throw new RuntimeException("Failed to load transaction manager", e);
+ }
}
public EntityManager getEntityManager() {
- return lookupEntityManager();
+ try {
+ return ((EntityManagerFactory) getInitialContext().lookup("java:/RHQEntityManagerFactory"))
+ .createEntityManager();
+ } catch (NamingException e) {
+ e.printStackTrace();
+ throw new RuntimeException("Failed to load entity manager", e);
+ }
}
public boolean isPostgres(EntityManager em) throws Exception {
@@ -139,7 +148,171 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
}
protected void executeInTransaction(TransactionCallback callback) {
- JPAUtils.executeInTransaction(callback);
+ try {
+ getTransactionManager().begin();
+ callback.execute();
+ getTransactionManager().commit();
+ } catch (Throwable t) {
+ try {
+ getTransactionManager().rollback();
+ } catch (SystemException e) {
+ throw new RuntimeException("Failed to rollback transaction", e);
+ }
+ throw new RuntimeException(t.getCause());
+ }
}
+ void clearDB() throws Exception {
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ EntityManager em = getEntityManager();
+
+ em.createNativeQuery("delete from jms_subscriptions");
+ em.createNativeQuery("delete from jms_roles");
+ em.createNativeQuery("delete from jms_users");
+ em.createNativeQuery("delete from jms_transactions");
+ em.createNativeQuery("delete from jms_messages");
+ em.createNativeQuery("delete from rhq_drift_config_map");
+ em.createNativeQuery("delete from rhq_drift_template_map");
+ em.createNativeQuery("delete from rhq_delete_res_hist");
+ em.createNativeQuery("delete from rhq_create_res_hist");
+ em.createNativeQuery("delete from rhq_tagging_bundle_dest_map");
+ em.createNativeQuery("delete from rhq_tagging_bundle_deploy_map");
+ em.createNativeQuery("delete from rhq_tagging_bundle_version_map");
+ em.createNativeQuery("delete from rhq_tagging_bundle_map");
+ em.createNativeQuery("delete from rhq_bundle_res_dep_hist");
+ em.createNativeQuery("delete from rhq_bundle_res_deploy");
+ em.createNativeQuery("delete from rhq_bundle_deployment");
+ em.createNativeQuery("delete from rhq_bundle_destination");
+ em.createNativeQuery("delete from rhq_bundle_file");
+ em.createNativeQuery("delete from rhq_bundle_version_repo");
+ em.createNativeQuery("delete from rhq_bundle_version");
+ em.createNativeQuery("delete from rhq_bundle");
+ em.createNativeQuery("delete from rhq_bundle_type");
+ em.createNativeQuery("delete from rhq_repo_advisory");
+ em.createNativeQuery("delete from rhq_advisory_buglist");
+ em.createNativeQuery("delete from rhq_advisory_cve");
+ em.createNativeQuery("delete from rhq_cve");
+ em.createNativeQuery("delete from rhq_advisory_package");
+ em.createNativeQuery("delete from rhq_advisory");
+ em.createNativeQuery("delete from rhq_distribution_file");
+ em.createNativeQuery("delete from rhq_repo_distribution");
+ em.createNativeQuery("delete from rhq_distribution where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_pkg_prd_map");
+ em.createNativeQuery("delete from rhq_pkg_ver_content_src_map");
+ em.createNativeQuery("delete from rhq_repo_pkg_version_map");
+ em.createNativeQuery("delete from rhq_repo_repo_relation_map");
+ em.createNativeQuery("delete from rhq_repo_repo_group_map");
+ em.createNativeQuery("delete from rhq_repo_content_src_map");
+ em.createNativeQuery("delete from rhq_repo_resource_map");
+ em.createNativeQuery("delete from rhq_package_inst_step");
+ em.createNativeQuery("delete from rhq_repo_sync");
+ em.createNativeQuery("delete from rhq_content_src_sync");
+ em.createNativeQuery("delete from rhq_installed_pkg_hist");
+ em.createNativeQuery("delete from rhq_installed_package");
+ em.createNativeQuery("delete from rhq_content_req");
+ em.createNativeQuery("delete from rhq_package_version");
+ em.createNativeQuery("delete from rhq_package_bits");
+ em.createNativeQuery("delete from rhq_package");
+ em.createNativeQuery("delete from rhq_package_type");
+ em.createNativeQuery("delete from rhq_repo_relation");
+ em.createNativeQuery("delete from rhq_repo_relation_type where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_repo");
+ em.createNativeQuery("delete from rhq_repo_group");
+ em.createNativeQuery("delete from rhq_repo_group_type where id <> 1");
+ em.createNativeQuery("delete from rhq_archirtecture where id < 1 and id > 38");
+ em.createNativeQuery("delete from rhq_meas_data_num_r14");
+ em.createNativeQuery("delete from rhq_meas_data_num_r13");
+ em.createNativeQuery("delete from rhq_meas_data_num_r12");
+ em.createNativeQuery("delete from rhq_meas_data_num_r11");
+ em.createNativeQuery("delete from rhq_meas_data_num_r10");
+ em.createNativeQuery("delete from rhq_meas_data_num_r09");
+ em.createNativeQuery("delete from rhq_meas_data_num_r08");
+ em.createNativeQuery("delete from rhq_meas_data_num_r07");
+ em.createNativeQuery("delete from rhq_meas_data_num_r06");
+ em.createNativeQuery("delete from rhq_meas_data_num_r05");
+ em.createNativeQuery("delete from rhq_meas_data_num_r04");
+ em.createNativeQuery("delete from rhq_meas_data_num_r03");
+ em.createNativeQuery("delete from rhq_meas_data_num_r02");
+ em.createNativeQuery("delete from rhq_meas_data_num_r01");
+ em.createNativeQuery("delete from rhq_meas_data_num_r00");
+ em.createNativeQuery("delete from rhq_measurement_oob_tmp");
+ em.createNativeQuery("delete rhq_measurement_oob");
+ em.createNativeQuery("delete rhq_resource_avail");
+ em.createNativeQuery("delete from rhq_availability");
+ em.createNativeQuery("delete from rhq_calltime_data_value");
+ em.createNativeQuery("delete from rhq_calltime_data_key");
+ em.createNativeQuery("delete from rhq_measurement_data_trait");
+ em.createNativeQuery("delete from rhq_measurement_data_num_1d");
+ em.createNativeQuery("delete from rhq_measurement_data_num_6h");
+ em.createNativeQuery("delete from rhq_measurement_data_num_1h");
+ em.createNativeQuery("delete from rhq_measurement_bline");
+ em.createNativeQuery("delete from rhq_measurement_sched");
+ em.createNativeQuery("delete from rhq_measurement_def");
+ em.createNativeQuery("delete from rhq_plugin");
+ em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56)");
+ em.createNativeQuery("delete from rhq_alert_notification");
+ em.createNativeQuery("delete from rhq_alert_condition_log");
+ em.createNativeQuery("delete from rhq_alert");
+ em.createNativeQuery("delete from rhq_alert_condition");
+ em.createNativeQuery("delete from rhq_alert_dampen_event");
+ em.createNativeQuery("delete from rhq_alert_definition");
+ em.createNativeQuery("delete from rhq_event");
+ em.createNativeQuery("delete from rhq_event_source");
+ em.createNativeQuery("delete from rhq_event_def");
+ em.createNativeQuery("delete from rhq_operation_schedule");
+ em.createNativeQuery("delete from rhq_operation_history");
+ em.createNativeQuery("delete from rhq_operation_def");
+ em.createNativeQuery("delete from rhq_dashboard_portlet");
+ em.createNativeQuery("delete from rhq_dashboard");
+ em.createNativeQuery("delete from rhq_saved_search");
+ em.createNativeQuery("delete from rhq_subject_role_ldap_map");
+ em.createNativeQuery("delete from rhq_subject_role_map where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_permission where role_id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_role_ldap_group");
+ em.createNativeQuery("delete from rhq_role_resource_group_map");
+ em.createNativeQuery("delete from rhq_role where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_tagging_res_group_map");
+ em.createNativeQuery("delete from rhq_tagging_resource_map");
+ em.createNativeQuery("delete from rhq_tagging");
+ em.createNativeQuery("delete from rhq_config_update");
+ em.createNativeQuery("delete from rhq_config_group_update");
+ em.createNativeQuery("delete from rhq_resource_group_res_exp_map");
+ em.createNativeQuery("delete from rhq_resource_group_res_imp_map");
+ em.createNativeQuery("delete from rhq_resource_group");
+ em.createNativeQuery("delete from rhq_group_def");
+ em.createNativeQuery("delete from rhq_resource_error");
+ em.createNativeQuery("delete from rhq_resource");
+ em.createNativeQuery("delete from rhq_prd_ver");
+ em.createNativeQuery("delete from rhq_process_scan");
+ em.createNativeQuery("delete from rhq_resource_type_parents");
+ em.createNativeQuery("delete from rhq_resource_subcat");
+ em.createNativeQuery("delete from rhq_resource_type");
+ em.createNativeQuery("delete from rhq_subject where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_principal where id <> 2");
+ em.createNativeQuery("delete from rhq_failover_details");
+ em.createNativeQuery("delete from rhq_failover_list");
+ em.createNativeQuery("delete from rhq_partition_details");
+ em.createNativeQuery("delete from rhq_partition_event");
+ em.createNativeQuery("delete from rhq_agent");
+ em.createNativeQuery("delete from rhq_server");
+ em.createNativeQuery("delete from rhq_affinity_group");
+ em.createNativeQuery("delete from rhq_raw_config");
+ em.createNativeQuery("delete from rhq_config_template");
+ em.createNativeQuery("delete from rhq_config_property");
+ em.createNativeQuery("delete from rhq_config");
+ em.createNativeQuery("delete from rhq_config_prop_constr");
+ em.createNativeQuery("delete from rhq_conf_prop_def_enum");
+ em.createNativeQuery("delete from rhq_config_pd_osrc");
+ em.createNativeQuery("delete from rhq_config_prop_def");
+ em.createNativeQuery("delete from rhq_config_prop_grp_def");
+ em.createNativeQuery("delete from rhq_config_def");
+ }
+ });
+ }
+
+ public static interface TransactionCallback {
+ void execute() throws Exception;
+ }
}
\ No newline at end of file
commit df923540908f8e8c0b4c8b32e839a33956bde646
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 22 16:09:08 2011 -0400
stub out the new drift change sets subtab
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
index 56b4aa2..f610b8b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
@@ -19,14 +19,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.drift;
-import com.smartgwt.client.widgets.IButton;
-import com.smartgwt.client.widgets.events.ClickEvent;
-import com.smartgwt.client.widgets.events.ClickHandler;
-import com.smartgwt.client.widgets.toolbar.ToolStrip;
-
import org.rhq.core.domain.common.EntityContext;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableToolStrip;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
@@ -45,29 +38,6 @@ public class DriftChangeSetsView extends LocatableVLayout {
this.hasWriteAccess = hasWriteAccess;
}
- @Override
- protected void onDraw() {
- super.onDraw();
-
- final ResourceDriftChangeSetsTreeView tree = new ResourceDriftChangeSetsTreeView(extendLocatorId("Tree"),
- this.hasWriteAccess, this.context);
- addMember(tree);
-
- ToolStrip toolStrip = new LocatableToolStrip(extendLocatorId("toolstrip"));
- toolStrip.setBackgroundImage(null);
- toolStrip.setWidth100();
- toolStrip.setMembersMargin(3);
- toolStrip.setPadding(3);
- IButton refreshButton = new LocatableIButton(extendLocatorId("refreshButton"), MSG.common_button_refresh());
- refreshButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent event) {
- tree.refresh();
- }
- });
- toolStrip.addMember(refreshButton);
- addMember(toolStrip);
- }
-
public EntityContext getContext() {
return context;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 0e63d8e..4efc189 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -243,13 +243,13 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
driftTab = new TwoLevelTab(getTabSet().extendLocatorId(Tab.DRIFT), new ViewName(Tab.DRIFT, MSG
.view_tabs_common_drift()), "subsystems/drift/Drift_16.png");
- this.driftChangeSets = new SubTab(driftTab.extendLocatorId(DriftSubTab.CHANGE_SETS), new ViewName(
- DriftSubTab.CHANGE_SETS, MSG.view_drift_changeSets()), null);
this.driftHistory = new SubTab(driftTab.extendLocatorId(DriftSubTab.HISTORY), new ViewName(DriftSubTab.HISTORY,
MSG.view_tabs_common_history()), null);
+ this.driftChangeSets = new SubTab(driftTab.extendLocatorId(DriftSubTab.CHANGE_SETS), new ViewName(
+ DriftSubTab.CHANGE_SETS, MSG.view_drift_changeSets()), null);
this.driftConfig = new SubTab(driftTab.extendLocatorId(DriftSubTab.CONFIGURATION), new ViewName(
DriftSubTab.CONFIGURATION, MSG.view_tabs_common_configuration()), null);
- driftTab.registerSubTabs(driftChangeSets, driftHistory, driftConfig);
+ driftTab.registerSubTabs(driftHistory, driftChangeSets, driftConfig);
tabs.add(driftTab);
contentTab = new TwoLevelTab(getTabSet().extendLocatorId("Content"), new ViewName("Content", MSG
@@ -519,17 +519,17 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
ResourcePermission resourcePermissions, Set<ResourceTypeFacet> facets) {
if (updateTab(this.driftTab, facets.contains(ResourceTypeFacet.DRIFT), resourcePermissions.isDrift())) {
- updateSubTab(this.driftTab, this.driftChangeSets, true, true, new ViewFactory() {
+ updateSubTab(this.driftTab, this.driftHistory, true, true, new ViewFactory() {
@Override
public Canvas createView() {
- return ResourceDriftChangeSetsView.get(driftChangeSets.extendLocatorId("View"), resourceComposite);
+ return ResourceDriftHistoryView.get(driftHistory.extendLocatorId("View"), resourceComposite);
}
});
- updateSubTab(this.driftTab, this.driftHistory, true, true, new ViewFactory() {
+ updateSubTab(this.driftTab, this.driftChangeSets, true, true, new ViewFactory() {
@Override
public Canvas createView() {
- return ResourceDriftHistoryView.get(driftHistory.extendLocatorId("View"), resourceComposite);
+ return ResourceDriftChangeSetsView.get(driftChangeSets.extendLocatorId("View"), resourceComposite);
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index ea8c956..c7d6f91 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -1123,7 +1123,6 @@ view_drift_category_fileChanged = File Changed
view_drift_category_fileRemoved = File Removed
view_drift_changeSets = Change Sets
view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
-view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
view_drift_delete_confirm = Delete the selected drift(s)?
view_drift_delete_confirmAll = Delete all drifts from this source?
view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index a07568a..5fe14aa 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -941,7 +941,6 @@ view_dashboards_title = Dashboard
##view_drift_category_fileRemoved = File Removed
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
-##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index 6e68cff..6bce847 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -1106,7 +1106,6 @@ view_dashboards_title = ダッシュボード
##view_drift = Drift
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
-##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
##view_drift_table_baseDir = Base Directory
##view_drift_table_changeSet = Change Set
##view_drift_table_newFile = New File
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index fa86006..bd2b6fb 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -1141,7 +1141,6 @@ view_dashboards_title = Dashboard~
##view_drift_category_fileRemoved = File Removed
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
-##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index 79816c5..9fa9115 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -1115,7 +1115,6 @@ view_dashboards_title = \u7edf\u8ba1\u8868\u76d8
##view_drift = Drift
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
-##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
##view_drift_table_baseDir = Base Directory
##view_drift_table_changeSet = Change Set
##view_drift_table_newFile = New File
commit 5e82ab5e7794b3b0ee9a2dcbefb407dbbfda48c0
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 22 13:22:56 2011 -0400
Adding support for generating snapshot diffs
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java
index 2543bf8..c32f053 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java
@@ -1,5 +1,6 @@
package org.rhq.core.domain.drift;
+import static java.util.Arrays.asList;
import static org.rhq.core.domain.drift.DriftCategory.FILE_ADDED;
import static org.rhq.core.domain.drift.DriftCategory.FILE_CHANGED;
import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
@@ -81,6 +82,60 @@ public class SnapshotTest {
+ "removed.");
}
+ @Test
+ public void diffShowsEntriesInLeftAndNotInRight() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
+ Snapshot right = new Snapshot().add(changeSet1);
+
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1).add(entry2);
+ Snapshot left = new Snapshot().add(changeSet1).add(changeSet2);
+
+ DiffReport diff = left.diff(right);
+
+ assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsNotInRight(), "Diff report does not contain " +
+ "elements that are in the left but not in the right.");
+ }
+
+ @Test
+ public void diffShowsEntriesInRightAndNotInLeft() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
+ Snapshot right = new Snapshot().add(changeSet1);
+
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry2);
+ Snapshot left = new Snapshot().add(changeSet2);
+
+ DiffReport diff = left.diff(right);
+
+ assertCollectionMatchesNoOrder(asList(entry1), diff.getElementsNotInLeft(), "Diff report does not contain " +
+ "elements that are in the left but not in the right");
+ }
+
+ @Test
+ public void diffShowsEntriesInLeftAndRightThatAreInConflict() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drfit/1.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
+ Snapshot right = new Snapshot().add(changeSet1);
+
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("c3b2a1", 1024, LOADED), "/drfit/1.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2);
+ Snapshot left = new Snapshot().add(changeSet2);
+
+ DiffReport diff = left.diff(right);
+
+ assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsInConflict(), "Diff report does not contain " +
+ "element that are in both left and right and are in conflict");
+ }
+
<E> Set<E> asSet(E... elements) {
HashSet<E> set = new HashSet<E>();
for (E element : elements) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DiffReport.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DiffReport.java
new file mode 100644
index 0000000..89f3286
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DiffReport.java
@@ -0,0 +1,38 @@
+package org.rhq.enterprise.server.drift;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DiffReport<T> {
+
+ private List<T> notInLeft = new ArrayList<T>();
+
+ private List<T> notInRight = new ArrayList<T>();
+
+ private List<T> conflicts = new ArrayList<T>();
+
+ public List<T> getElementsNotInLeft() {
+ return notInLeft;
+ }
+
+ public void elementNotInLeft(T element) {
+ notInLeft.add(element);
+ }
+
+ public List<T> getElementsNotInRight() {
+ return notInRight;
+ }
+
+ public void elementNotInRight(T element) {
+ notInRight.add(element);
+ }
+
+ public List<T> getElementsInConflict() {
+ return conflicts;
+ }
+
+ public void elementInConflict(T element) {
+ conflicts.add(element);
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
index 2efc8d8..5dc18fa 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
@@ -1,12 +1,13 @@
package org.rhq.enterprise.server.drift;
import java.io.Serializable;
-import java.util.Comparator;
-import java.util.Set;
-import java.util.TreeSet;
+import java.util.Collection;
+import java.util.Map;
+import java.util.TreeMap;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.DriftFile;
import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
@@ -16,30 +17,56 @@ public class Snapshot implements Serializable {
private int version;
- private Set<Drift> entries = new TreeSet<Drift>(new Comparator<Drift>() {
- @Override
- public int compare(Drift d1, Drift d2) {
- return d1.getPath().compareTo(d2.getPath());
- }
- });
+ private Map<String, Drift> entries = new TreeMap<String, Drift>();
public int getVersion() {
return version;
}
- public Set<Drift> getEntries() {
- return entries;
+ public Collection<Drift> getEntries() {
+ return entries.values();
}
public <D extends Drift> Snapshot add(DriftChangeSet<D> changeSet) {
for (Drift entry : changeSet.getDrifts()) {
- entries.remove(entry);
+ entries.remove(entry.getPath());
if (entry.getCategory() != FILE_REMOVED) {
- entries.add(entry);
+ entries.put(entry.getPath(), entry);
}
}
version = changeSet.getVersion();
return this;
}
+ public DiffReport diff(Snapshot right) {
+ Snapshot left = this;
+ DiffReport<Drift> diff = new DiffReport<Drift>();
+
+ for (Map.Entry<String, Drift> entry : left.entries.entrySet()) {
+ if (!right.entries.containsKey(entry.getKey())) {
+ diff.elementNotInRight(entry.getValue());
+ }
+ }
+
+ for (Map.Entry<String, Drift> entry : right.entries.entrySet()) {
+ if (!left.entries.containsKey(entry.getKey())) {
+ diff.elementNotInLeft(entry.getValue());
+ }
+ }
+
+ for (Map.Entry<String, Drift> entry : left.entries.entrySet()) {
+ Drift rightDrift = right.entries.get(entry.getKey());
+ if (rightDrift != null) {
+ DriftFile leftFile = entry.getValue().getNewDriftFile();
+ DriftFile rightFile = rightDrift.getNewDriftFile();
+
+ if (!leftFile.getHashId().equals(rightFile.getHashId())) {
+ diff.elementInConflict(entry.getValue());
+ }
+ }
+ }
+
+ return diff;
+ }
+
}
commit 951c7a25098e8f9a572de19d2ce830cb3cc93a8a
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 21 22:03:41 2011 -0400
Adding logic for removing files from a snapshot
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java
index 93653b3..2543bf8 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java
@@ -1,11 +1,5 @@
package org.rhq.core.domain.drift;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.testng.annotations.Test;
-
-import static java.util.Arrays.asList;
import static org.rhq.core.domain.drift.DriftCategory.FILE_ADDED;
import static org.rhq.core.domain.drift.DriftCategory.FILE_CHANGED;
import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
@@ -15,19 +9,24 @@ import static org.rhq.core.domain.drift.DriftFileStatus.LOADED;
import static org.rhq.test.AssertUtils.assertCollectionMatchesNoOrder;
import static org.testng.Assert.assertEquals;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.testng.annotations.Test;
+
public class SnapshotTest {
@Test
public void addChangeSetWithAddedFile() {
int configId = 1;
- FakeDriftChangeSet changeSet = new FakeDriftChangeSet(0, COVERAGE, configId)
- .add(new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt"));
+ FakeDriftChangeSet changeSet = new FakeDriftChangeSet(0, COVERAGE, configId).add(new FakeDrift(FILE_ADDED,
+ null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt"));
Snapshot snapshot = new Snapshot().add(changeSet);
- assertCollectionMatchesNoOrder(changeSet.getDrifts(), snapshot.getEntries(), "Failed to build " +
- "a snapshot that contains a single change set");
+ assertCollectionMatchesNoOrder(changeSet.getDrifts(), snapshot.getEntries(), "Failed to build "
+ + "a snapshot that contains a single change set");
assertEquals(snapshot.getVersion(), changeSet.getVersion(), "Snapshot version is wrong");
}
@@ -43,8 +42,8 @@ public class SnapshotTest {
Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
- assertCollectionMatchesNoOrder(asSet(entry1, entry2), snapshot.getEntries(), "Failed to build snapshot " +
- "with two change sets and file added in second change set");
+ assertCollectionMatchesNoOrder(asSet(entry1, entry2), snapshot.getEntries(), "Failed to build snapshot "
+ + "with two change sets and file added in second change set");
assertEquals(snapshot.getVersion(), changeSet2.getVersion(), "Snapshot version is wrong");
}
@@ -55,8 +54,8 @@ public class SnapshotTest {
Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
- Drift entry2 = new FakeDrift(FILE_CHANGED, new FakeDriftFile("a1b2c3", 1024, LOADED),
- new FakeDriftFile("4d5e6f", 1024, LOADED), "/drift/1.txt");
+ Drift entry2 = new FakeDrift(FILE_CHANGED, new FakeDriftFile("a1b2c3", 1024, LOADED), new FakeDriftFile(
+ "4d5e6f", 1024, LOADED), "/drift/1.txt");
FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2);
Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
@@ -78,66 +77,8 @@ public class SnapshotTest {
Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
- assertCollectionMatchesNoOrder(asSet(entry2), snapshot.getEntries(),
- "Failed to build snapshot with a file " +
- "removed.");
- }
-
- @Test
- public void diffShowsEntriesInLeftAndNotInRight() {
- int configId = 1;
-
- Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
- FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
- Snapshot right = new Snapshot().add(changeSet1);
-
- Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt");
- FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1).add(entry2);
- Snapshot left = new Snapshot().add(changeSet1).add(changeSet2);
-
- DiffReport diff = left.diff(right);
-
- assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsNotInRight(),
- "Diff report does not contain " +
- "elements that are in the left but not in the right.");
- }
-
- @Test
- public void diffShowsEntriesInRightAndNotInLeft() {
- int configId = 1;
-
- Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
- FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
- Snapshot right = new Snapshot().add(changeSet1);
-
- Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt");
- FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry2);
- Snapshot left = new Snapshot().add(changeSet2);
-
- DiffReport diff = left.diff(right);
-
- assertCollectionMatchesNoOrder(asList(entry1), diff.getElementsNotInLeft(),
- "Diff report does not contain " +
- "elements that are in the left but not in the right");
- }
-
- @Test
- public void diffShowsEntriesInLeftAndRightThatAreInConflict() {
- int configId = 1;
-
- Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drfit/1.txt");
- FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
- Snapshot right = new Snapshot().add(changeSet1);
-
- Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("c3b2a1", 1024, LOADED), "/drfit/1.txt");
- FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2);
- Snapshot left = new Snapshot().add(changeSet2);
-
- DiffReport diff = left.diff(right);
-
- assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsInConflict(),
- "Diff report does not contain " +
- "element that are in both left and right and are in conflict");
+ assertCollectionMatchesNoOrder(asSet(entry2), snapshot.getEntries(), "Failed to build snapshot with a file "
+ + "removed.");
}
<E> Set<E> asSet(E... elements) {
@@ -318,8 +259,8 @@ public class SnapshotTest {
@Override
public String toString() {
- return "Drift[category: " + category.code() + ", oldFile: " + oldFile + ", newFile: " + newFile +
- ", path: " + path + "]";
+ return "Drift[category: " + category.code() + ", oldFile: " + oldFile + ", newFile: " + newFile
+ + ", path: " + path + "]";
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
new file mode 100644
index 0000000..2efc8d8
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
@@ -0,0 +1,45 @@
+package org.rhq.enterprise.server.drift;
+
+import java.io.Serializable;
+import java.util.Comparator;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftChangeSet;
+
+import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
+
+public class Snapshot implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private int version;
+
+ private Set<Drift> entries = new TreeSet<Drift>(new Comparator<Drift>() {
+ @Override
+ public int compare(Drift d1, Drift d2) {
+ return d1.getPath().compareTo(d2.getPath());
+ }
+ });
+
+ public int getVersion() {
+ return version;
+ }
+
+ public Set<Drift> getEntries() {
+ return entries;
+ }
+
+ public <D extends Drift> Snapshot add(DriftChangeSet<D> changeSet) {
+ for (Drift entry : changeSet.getDrifts()) {
+ entries.remove(entry);
+ if (entry.getCategory() != FILE_REMOVED) {
+ entries.add(entry);
+ }
+ }
+ version = changeSet.getVersion();
+ return this;
+ }
+
+}
commit f76ba9bc7af51217da7d0ea38a06df8367b3ce31
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jul 27 10:03:45 2011 -0400
add peer-review warning
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index ea2e29d..b1d0bb1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -91,6 +91,12 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* A tabular view of set of data records from an {@link RPCDataSource}.
*
+ * WARNING! If you make _any_ changes to this class, no matter how seemingly
+ * trivial, you must get it peer reviewed. Send out your proposed changes
+ * to the dev mailing list and ask for comments. Any problems introduced to
+ * this class are magnified because it is used in so many UI views and problems
+ * are hard to detect due to the varies ways it is used.
+ *
* @author Greg Hinkle
* @author Ian Springer
*/
commit 6a0bcbf60c4484bca23650b5f277b7936941ff05
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Jul 25 14:30:15 2011 +0200
Configuration.PropertiesProxy now delegates equals(), hashCode() and toString() to the configuration properties values as it should.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
index 5182b09..e8c0bc3 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
@@ -228,6 +228,26 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM
public void clear() {
properties.clear();
}
+
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (!(obj instanceof Collection)) {
+ return false;
+ }
+
+ return properties.values().equals(obj);
+ }
+
+ public int hashCode() {
+ return properties.values().hashCode();
+ }
+
+ public String toString() {
+ return properties.values().toString();
+ }
}
private transient PropertiesProxy propertiesProxy;
commit 50de13949aa26f52c2f276d6035a9a6f32ed520e
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Jul 22 17:41:52 2011 +0200
BZ 724929 - get domain deployment to work again.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 920de9f..83b221b 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -338,6 +338,8 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
JsonNode resultNode = uploadResult.get("result");
String hash = resultNode.get("BYTES_VALUE").getTextValue();
+
+
ASConnection connection = getASConnection();
Operation step1 = new Operation("add","deployment",tmpName);
@@ -362,9 +364,12 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
*/
if (!toServerGroup) {
+
// if standalone, then :deploy the deployment anyway
- Operation step2 = new Operation("deploy",step1.getAddress());
- cop.addStep(step2);
+ if (context.getResourceType().getName().contains("Standalone")) {
+ Operation step2 = new Operation("deploy",step1.getAddress());
+ cop.addStep(step2);
+ }
result = connection.execute(cop);
resourceKey = addressToPath(step1.getAddress());
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
index 6911931..0281279 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
@@ -28,7 +28,7 @@ import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.Result;
/**
- * Component class for stanalone AS7 servers
+ * Component class for standalone AS7 servers
* @author Heiko W. Rupp
*/
public class StandaloneASComponent extends BaseComponent implements OperationFacet {
commit 4c399fea59c926d14df13c2d327e6d5f2f293b20
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Jul 22 16:36:33 2011 +0200
Implement :reload and :shutdown for standalone servers.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 87a0a5a..b55fc8a 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -154,6 +154,7 @@ public class ASConnection {
Result failure = new Result();
failure.setFailureDescription(e.getMessage());
failure.setOutcome("failure");
+ failure.setThrowable(e);
JsonNode ret = mapper.valueToTree(failure);
return ret;
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 389bed7..920de9f 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -455,6 +455,9 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
operation = new Operation(op,address,props);
}
+ else {
+ operation = new Operation(op,address);
+ }
} else if (what.equals("destination")) {
address.addAll(pathToAddress(getPath()));
String newName = parameters.getSimpleValue("name","");
@@ -532,7 +535,12 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
operationResult.setErrorMessage(result.getFailureDescription());
}
else {
- operationResult.setSimpleResult(result.getResult().toString());
+ String tmp;
+ if (result.getResult()==null)
+ tmp = "-none provided by the server-";
+ else
+ tmp = result.getResult().toString();
+ operationResult.setSimpleResult(tmp);
}
}
else {
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
new file mode 100644
index 0000000..6911931
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
@@ -0,0 +1,71 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.net.ConnectException;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.modules.plugins.jbossas7.json.Address;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.Result;
+
+/**
+ * Component class for stanalone AS7 servers
+ * @author Heiko W. Rupp
+ */
+public class StandaloneASComponent extends BaseComponent implements OperationFacet {
+
+
+ @Override
+ public OperationResult invokeOperation(String name,
+ Configuration parameters) throws Exception {
+
+ // reload, shutdown
+ Operation op = new Operation(name,new Address());
+ Result res = getASConnection().execute(op);
+
+ OperationResult operationResult = new OperationResult();
+ if (name.equals("shutdown")) {
+ /*
+ * Shutdown needs a special treatment, because after sending the operation, if shutdown suceeds,
+ * the server connection is closed and we can't read from it. So if we get connection refused for
+ * reading, this is a good sign.
+ */
+ if (!res.isSuccess()) {
+ if (res.getThrowable() instanceof ConnectException || res.getThrowable().getMessage().equals("Connection refused"))
+ operationResult.setSimpleResult("Success");
+ else
+ operationResult.setErrorMessage(res.getFailureDescription());
+ }
+ }
+ else {
+ if (res.isSuccess()) {
+ if (res.getResult()!=null)
+ operationResult.setSimpleResult(res.getResult().toString());
+ else
+ operationResult.setSimpleResult("-None provided by server-");
+ }
+ else
+ operationResult.setErrorMessage(res.getFailureDescription());
+ }
+ return operationResult;
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
index c8868d6..42ffee7 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
@@ -41,13 +41,16 @@ public class Result {
@JsonProperty("rolled-back")
private boolean rolledBack = false;
+ /** Record throwsables during low level processing */
+ @JsonIgnore
+ private Throwable throwable;
+
public Object getResponseHeaders() {
return responseHeaders;
}
public void setResponseHeaders(Object responseHeaders) {
this.responseHeaders = responseHeaders;
- System.err.println("Response headers: " + responseHeaders);
}
@JsonProperty("response-headers")
@@ -95,6 +98,15 @@ public class Result {
this.rolledBack = rolledBack;
}
+ public Throwable getThrowable() {
+ return throwable;
+ }
+
+ public void setThrowable(Throwable throwable) {
+ this.throwable = throwable;
+ }
+
+
@Override
public String toString() {
return "Result{" +
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index d47b24c..c0e364d 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -286,7 +286,7 @@
<server name="JBossAS7-Standalone"
discovery="BaseProcessDiscovery"
- class="BaseComponent"
+ class="StandaloneASComponent"
>
<plugin-configuration>
@@ -303,6 +303,18 @@
<process-scan name="StandaloneAS" query="process|basename|match=^java.*,arg|org.jboss.as.standalone|match=.*"/>
+ <operation name="reload" description="Make the server load the (changed) configuration." displayName="Reload">
+ <results>
+ <c:simple-property name="operationResult"/>
+ </results>
+ </operation>
+ <operation name="shutdown" description="Shut down the server." displayName="Shutdown">
+ <results>
+ <c:simple-property name="operationResult"/>
+ </results>
+ </operation>
+
+
<metric property="_internal:mgmtRequests" category="performance" dataType="measurement" defaultInterval="120000"
displayType="summary" measurementType="trendsup" description="Number of requests sent to the controller"
displayName="Number of management requests"/>
commit 0ed85a444ed491d623956600209041df6272398e
Author: Elias Ross <genman(a)noderunner.net>
Date: Fri Jul 22 12:04:46 2011 +0200
BZ 723800 - support SNMP inform messages and improve testing.
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/AgentPluginDescriptorUtil.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/AgentPluginDescriptorUtil.java
index bdfdd84..3148d09 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/AgentPluginDescriptorUtil.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/AgentPluginDescriptorUtil.java
@@ -36,6 +36,7 @@ import java.util.jar.Manifest;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.ValidationEvent;
import javax.xml.bind.ValidationEventLocator;
@@ -58,6 +59,7 @@ import org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor;
import org.rhq.core.clientapi.descriptor.plugin.ServiceDescriptor;
import org.rhq.core.domain.plugin.Plugin;
import org.rhq.core.util.exception.WrappedRemotingException;
+import org.xml.sax.SAXException;
/**
* Utilities for agent plugin descriptors.
@@ -125,7 +127,7 @@ public abstract class AgentPluginDescriptorUtil {
* is searched for an implementation version string and if one is found that is the version
* of the plugin. If the manifest entry is also not found, the plugin does not have a version
* associated with it, which causes this method to throw an exception.
- *
+ *
* @param pluginFile the plugin jar
* @param descriptor the plugin descriptor as found in the plugin jar (if <code>null</code>,
* the plugin file will be read and the descriptor parsed from it)
@@ -163,7 +165,7 @@ public abstract class AgentPluginDescriptorUtil {
* Obtains the manifest of the plugin file represented by the given deployment info.
* Use this method rather than calling deploymentInfo.getManifest()
* (workaround for https://jira.jboss.org/jira/browse/JBAS-6266).
- *
+ *
* @param pluginFile the plugin file
* @return the deployed plugin's manifest
*/
@@ -184,7 +186,7 @@ public abstract class AgentPluginDescriptorUtil {
/**
* Given an existing dependency graph and a plugin descriptor, this will add that plugin and its dependencies
* to the dependency graph.
- *
+ *
* @param dependencyGraph
* @param descriptor
*/
@@ -283,9 +285,9 @@ public abstract class AgentPluginDescriptorUtil {
/**
* Loads a plugin descriptor from the given plugin jar and returns it.
- *
+ *
* This is a static method to provide a convenience method for others to be able to use.
- *
+ *
* @param pluginJarFileUrl URL to a plugin jar file
* @return the plugin descriptor found in the given plugin jar file
* @throws PluginContainerException if failed to find or parse a descriptor file in the plugin jar
@@ -301,13 +303,6 @@ public abstract class AgentPluginDescriptorUtil {
testPluginJarIsReadable(pluginJarFileUrl);
- JAXBContext jaxbContext;
- try {
- jaxbContext = JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);
- } catch (Exception e) {
- throw new PluginContainerException("Failed to create JAXB Context.", new WrappedRemotingException(e));
- }
-
JarInputStream jis = null;
JarEntry descriptorEntry = null;
ValidationEventCollector validationEventCollector = new ValidationEventCollector();
@@ -327,18 +322,7 @@ public abstract class AgentPluginDescriptorUtil {
throw new Exception("The plugin descriptor does not exist");
}
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
-
- // Enable schema validation
- URL pluginSchemaURL = AgentPluginDescriptorUtil.class.getClassLoader().getResource(PLUGIN_SCHEMA_PATH);
- Schema pluginSchema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(
- pluginSchemaURL);
- unmarshaller.setSchema(pluginSchema);
- unmarshaller.setEventHandler(validationEventCollector);
-
- PluginDescriptor pluginDescriptor = (PluginDescriptor) unmarshaller.unmarshal(jis);
-
- return pluginDescriptor;
+ return parsePluginDescriptor(jis, validationEventCollector);
} catch (Exception e) {
throw new PluginContainerException("Could not successfully parse the plugin descriptor ["
+ PLUGIN_DESCRIPTOR_PATH + "] found in plugin jar at [" + pluginJarFileUrl + "].",
@@ -356,6 +340,50 @@ public abstract class AgentPluginDescriptorUtil {
}
}
+ /**
+ * Parses a descriptor from InputStream without a validator.
+ * @param is input to check
+ * @return parsed PluginDescriptor
+ * @throws PluginContainerException if validation fails
+ */
+ public static PluginDescriptor parsePluginDescriptor(InputStream is) throws PluginContainerException {
+ return parsePluginDescriptor(is, new ValidationEventCollector());
+ }
+
+ /**
+ * Parses a descriptor from InputStream without a validator.
+ * @param is input to check
+ * @return parsed PluginDescriptor
+ * @throws PluginContainerException if validation fails
+ */
+ public static PluginDescriptor parsePluginDescriptor(InputStream is,
+ ValidationEventCollector validationEventCollector) throws PluginContainerException {
+ JAXBContext jaxbContext;
+ try {
+ jaxbContext = JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);
+ } catch (Exception e) {
+ throw new PluginContainerException("Failed to create JAXB Context.", new WrappedRemotingException(e));
+ }
+
+ Unmarshaller unmarshaller;
+ try {
+ unmarshaller = jaxbContext.createUnmarshaller();
+ // Enable schema validation
+ URL pluginSchemaURL = AgentPluginDescriptorUtil.class.getClassLoader().getResource(PLUGIN_SCHEMA_PATH);
+ Schema pluginSchema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(
+ pluginSchemaURL);
+ unmarshaller.setSchema(pluginSchema);
+ unmarshaller.setEventHandler(validationEventCollector);
+
+ PluginDescriptor pluginDescriptor = (PluginDescriptor) unmarshaller.unmarshal(is);
+ return pluginDescriptor;
+ } catch (JAXBException e) {
+ throw new PluginContainerException(e);
+ } catch (SAXException e) {
+ throw new PluginContainerException(e);
+ }
+ }
+
private static void logValidationEvents(URL pluginJarFileUrl, ValidationEventCollector validationEventCollector,
Log logger) {
for (ValidationEvent event : validationEventCollector.getEvents()) {
diff --git a/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/ExtensionModelTest.java b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/ExtensionModelTest.java
index 3d9fb10..9fbba96 100644
--- a/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/ExtensionModelTest.java
+++ b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/ExtensionModelTest.java
@@ -313,12 +313,7 @@ public class ExtensionModelTest {
URL descriptorUrl = this.getClass().getClassLoader().getResource(file);
System.out.println("Loading plugin descriptor at: " + descriptorUrl);
- JAXBContext jaxbContext = JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);
-
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- ValidationEventCollector vec = new ValidationEventCollector();
- unmarshaller.setEventHandler(vec);
- pluginDescriptor = (PluginDescriptor) unmarshaller.unmarshal(descriptorUrl.openStream());
+ pluginDescriptor = (PluginDescriptor) AgentPluginDescriptorUtil.parsePluginDescriptor(descriptorUrl.openStream());
this.metadataManager.loadPlugin(pluginDescriptor);
@@ -360,4 +355,4 @@ public class ExtensionModelTest {
outputType(child, depth + 1);
}
}
-}
\ No newline at end of file
+}
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/EventContext.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/EventContext.java
index e137cd8..f9bb654 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/EventContext.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/EventContext.java
@@ -33,8 +33,9 @@ import org.rhq.core.domain.event.Event;
public interface EventContext {
/**
* Minimum polling interval, in seconds.
+ * Used to be 1 minute, but since poll intervals are configurable it stands that 1 second will suffice.
*/
- int MINIMUM_POLLING_INTERVAL = 60; // 1 minute
+ int MINIMUM_POLLING_INTERVAL = 1; // 1 second
/**
* Publishes the specified Event. This means the Plugin Container will queue the Event to be sent to the Server.
diff --git a/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapEventPoller.java b/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapEventPoller.java
index 6bc790d..15a7ce6 100644
--- a/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapEventPoller.java
+++ b/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapEventPoller.java
@@ -27,11 +27,15 @@ import java.util.Properties;
import java.util.Set;
import java.util.Vector;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.event.Event;
+import org.rhq.core.domain.event.EventSeverity;
+import org.rhq.core.pluginapi.event.EventPoller;
import org.snmp4j.CommandResponder;
import org.snmp4j.CommandResponderEvent;
import org.snmp4j.PDU;
import org.snmp4j.PDUv1;
-import org.snmp4j.ScopedPDU;
import org.snmp4j.smi.Address;
import org.snmp4j.smi.IpAddress;
import org.snmp4j.smi.OID;
@@ -39,10 +43,6 @@ import org.snmp4j.smi.TimeTicks;
import org.snmp4j.smi.Variable;
import org.snmp4j.smi.VariableBinding;
-import org.rhq.core.domain.event.Event;
-import org.rhq.core.domain.event.EventSeverity;
-import org.rhq.core.pluginapi.event.EventPoller;
-
/**
* Polls the individual traps
* @author Heiko W. Rupp
@@ -50,9 +50,10 @@ import org.rhq.core.pluginapi.event.EventPoller;
*/
public class SnmpTrapEventPoller implements EventPoller, CommandResponder {
- List<Event> events = new Vector<Event>();
- OID severityOid;
- Properties translation;
+ private final List<Event> events = new Vector<Event>();
+ private OID severityOid;
+ private Properties translation;
+ private Log log = LogFactory.getLog(SnmpTrapEventPoller.class);
public SnmpTrapEventPoller() {
severityOid = null;
@@ -68,8 +69,7 @@ public class SnmpTrapEventPoller implements EventPoller, CommandResponder {
in.close();
}
} catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ throw new RuntimeException(e);
}
}
@@ -79,16 +79,10 @@ public class SnmpTrapEventPoller implements EventPoller, CommandResponder {
severityOid = new OID(severityOidString);
}
- /* (non-Javadoc)
- * @see org.rhq.core.pluginapi.event.EventPoller#getEventType()
- */
public String getEventType() {
return SnmpTrapdComponent.TRAP_TYPE;
}
- /* (non-Javadoc)
- * @see org.rhq.core.pluginapi.event.EventPoller#poll()
- */
public Set<Event> poll() {
Set<Event> eventSet = new HashSet<Event>();
synchronized (events) {
@@ -103,6 +97,8 @@ public class SnmpTrapEventPoller implements EventPoller, CommandResponder {
*/
public void processPdu(CommandResponderEvent cre) {
+ if (log.isDebugEnabled())
+ log.debug("recv: " + cre);
PDU pdu = cre.getPDU();
String sourceAddr;
Address addr = cre.getPeerAddress();
@@ -117,7 +113,6 @@ public class SnmpTrapEventPoller implements EventPoller, CommandResponder {
}
if (pdu != null) {
StringBuffer payload = new StringBuffer();
- // System.out.println("=>PDU: " + pdu);
// SNMP v1
if (pdu instanceof PDUv1) {
PDUv1 v1pdu = (PDUv1) pdu;
@@ -127,10 +122,6 @@ public class SnmpTrapEventPoller implements EventPoller, CommandResponder {
payload.append("Timestamp: " + new TimeTicks(timeTicks).toString());
payload.append("\n");
}
- // SNMP v3
- else if (pdu instanceof ScopedPDU) {
- ScopedPDU spdu = (ScopedPDU) pdu;
- }
SnmpTrapdComponent.trapCount++;
EventSeverity severity = EventSeverity.INFO;
@@ -168,6 +159,8 @@ public class SnmpTrapEventPoller implements EventPoller, CommandResponder {
Event event = new Event(getEventType(), sourceAddr, System.currentTimeMillis(), severity, payload
.toString());
+ if (log.isDebugEnabled())
+ log.debug("queue event " + event);
synchronized (events) {
events.add(event);
diff --git a/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdComponent.java b/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdComponent.java
index f6c6df5..9e0de67 100644
--- a/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdComponent.java
+++ b/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdComponent.java
@@ -25,7 +25,7 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.snmp4j.Snmp;
-import org.snmp4j.TransportMapping;
+import org.snmp4j.log.Log4jLogFactory;
import org.snmp4j.smi.UdpAddress;
import org.snmp4j.transport.DefaultUdpTransportMapping;
@@ -57,6 +57,9 @@ public class SnmpTrapdComponent implements ResourceComponent, MeasurementFacet {
private Snmp snmp;
private SnmpTrapEventPoller snmpTrapEventPoller;
public static int trapCount = 0;
+ static {
+ org.snmp4j.log.LogFactory.setLogFactory(new Log4jLogFactory());
+ }
/* (non-Javadoc)
* @see org.rhq.core.pluginapi.inventory.ResourceComponent#getAvailability()
@@ -65,7 +68,7 @@ public class SnmpTrapdComponent implements ResourceComponent, MeasurementFacet {
return AvailabilityType.UP;
}
- /**
+ /**
* Start the event polling mechanism and the actual trap listener.
* @see org.rhq.core.pluginapi.inventory.ResourceComponent#start(org.rhq.core.pluginapi.inventory.ResourceContext)
*/
@@ -78,19 +81,22 @@ public class SnmpTrapdComponent implements ResourceComponent, MeasurementFacet {
String community = ps.getStringValue();
ps = conf.getSimple("eventSeverityOid");
String severityOid = ps.getStringValue();
+ ps = conf.getSimple("pollInterval");
+ int pollInterval = ps.getIntegerValue();
eventContext = context.getEventContext();
- snmpTrapEventPoller = new SnmpTrapEventPoller(severityOid);
- eventContext.registerEventPoller(snmpTrapEventPoller, 60);
// TODO: check if the engine is already alive
try {
UdpAddress targetAddress = new UdpAddress(port);
- TransportMapping transport = new DefaultUdpTransportMapping(targetAddress);
- snmp = new Snmp(transport);
+ // TransportMapping transport = new DefaultUdpTransportMapping(targetAddress);
+ snmp = new Snmp(new DefaultUdpTransportMapping());
+ snmpTrapEventPoller = new SnmpTrapEventPoller(severityOid);
+ eventContext.registerEventPoller(snmpTrapEventPoller, pollInterval);
// TODO set up the community here
- snmp.addCommandResponder(snmpTrapEventPoller);
- transport.listen();
+ if (!snmp.addNotificationListener(targetAddress, snmpTrapEventPoller))
+ throw new IOException("cannot attach to " + targetAddress);
+ //transport.listen();
} catch (IOException e) {
log.error("Cannot start snmp engine. Cause: " + ThrowableUtil.getAllMessages(e));
}
diff --git a/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdDiscovery.java b/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdDiscovery.java
index aab6d6e..2858082 100644
--- a/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdDiscovery.java
+++ b/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdDiscovery.java
@@ -38,7 +38,7 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
public class SnmpTrapdDiscovery implements ResourceDiscoveryComponent<SnmpTrapdComponent>, ManualAddFacet<SnmpTrapdComponent> {
private static final String PORT_PROPERTY = "port";
-
+
/*
* Autodiscovery is not supported.
*/
@@ -54,7 +54,7 @@ public class SnmpTrapdDiscovery implements ResourceDiscoveryComponent<SnmpTrapdC
*/
public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration,
ResourceDiscoveryContext<SnmpTrapdComponent> ctx) throws InvalidPluginConfigurationException {
-
+
String port = pluginConfiguration.getSimpleValue(PORT_PROPERTY, null);
String key = "Trapd " + port;
String name = key;
diff --git a/modules/plugins/snmptrapd/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/snmptrapd/src/main/resources/META-INF/rhq-plugin.xml
index 3b5f442..1846bb7 100644
--- a/modules/plugins/snmptrapd/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/snmptrapd/src/main/resources/META-INF/rhq-plugin.xml
@@ -17,6 +17,9 @@
<c:simple-property name="port"
description="The port to listen on (Note: ports less than 1024 require root access on unixoids)"
required="true" default="11162" type="integer"/>
+ <c:simple-property name="pollInterval"
+ description="Number of seconds between waiting for SNMP trap events and sending them upstream"
+ required="true" default="10" type="integer"/>
<c:simple-property name="community" description="The community string for SNMP v1 and v2c"
required="false"/>
<c:simple-property name="eventSeverityOid"
diff --git a/modules/plugins/snmptrapd/src/test/java/org/rhq/plugins/snmptrapd/ComponentTest.java b/modules/plugins/snmptrapd/src/test/java/org/rhq/plugins/snmptrapd/ComponentTest.java
new file mode 100644
index 0000000..944b0c1
--- /dev/null
+++ b/modules/plugins/snmptrapd/src/test/java/org/rhq/plugins/snmptrapd/ComponentTest.java
@@ -0,0 +1,116 @@
+package org.rhq.plugins.snmptrapd;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.Set;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.clientapi.agent.metadata.PluginMetadataManager;
+import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil;
+import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pc.PluginContainer;
+import org.rhq.core.pc.PluginContainerConfiguration;
+import org.rhq.core.pc.content.ContentContextImpl;
+import org.rhq.core.pc.event.EventContextImpl;
+import org.rhq.core.pc.event.EventManager;
+import org.rhq.core.pc.operation.OperationContextImpl;
+import org.rhq.core.pc.upgrade.plugins.multi.base.NothingDiscoveringDiscoveryComponent;
+import org.rhq.core.pluginapi.content.ContentContext;
+import org.rhq.core.pluginapi.event.EventContext;
+import org.rhq.core.pluginapi.inventory.PluginContainerDeployment;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.operation.OperationContext;
+import org.rhq.core.system.SystemInfo;
+import org.rhq.core.system.SystemInfoFactory;
+import org.testng.Assert;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+
+/**
+ * Base class for RHQ Component Testing.
+ * @author elias
+ */
+public abstract class ComponentTest {
+
+ protected final Log log = LogFactory.getLog(getClass());
+ private static File temp = new File(System.getProperty("java.io.tmpdir"));
+
+ protected ResourceComponent component;
+
+ /**
+ * Constructs a new component test.
+ */
+ protected ComponentTest(ResourceComponent component) {
+ this.component = component;
+ }
+
+ protected EventManager eventManager;
+ protected Configuration configuration;
+
+ @BeforeTest
+ protected void before() throws Exception {
+
+ InputStream is = getClass().getResourceAsStream("/META-INF/rhq-plugin.xml");
+ PluginDescriptor pd = AgentPluginDescriptorUtil.parsePluginDescriptor(is);
+ PluginMetadataManager pmm = new PluginMetadataManager();
+ pmm.addTestPlatformType();
+ Set<ResourceType> rts = pmm.loadPlugin(pd);
+ ResourceType resourceType = rts.iterator().next();
+ configuration = resourceType.getPluginConfigurationDefinition().getDefaultTemplate().createConfiguration();
+
+ setConfiguration();
+
+ // Speed up propagation of events by adjusting delay/period to 1 second
+ PluginContainerConfiguration pcc = new PluginContainerConfiguration();
+ pcc.setEventSenderInitialDelay(1);
+ pcc.setEventSenderPeriod(1);
+
+ PluginContainer.getInstance().setConfiguration(pcc);
+ PluginContainer.getInstance().initialize();
+ eventManager = PluginContainer.getInstance().getEventManager();
+
+ Resource resource = new Resource();
+ resource.setResourceType(resourceType);
+
+ resource.setPluginConfiguration(configuration);
+ ResourceComponent parentResourceComponent = null;
+ ResourceDiscoveryComponent resourceDiscoveryComponent = new NothingDiscoveringDiscoveryComponent();
+ SystemInfo systemInfo = SystemInfoFactory.createSystemInfo();
+ File temporaryDirectory = temp;
+ File dataDirectory = temp;
+ String pluginContainerName = "rhq";
+ EventContext eventContext = new EventContextImpl(resource);
+ OperationContext operationContext = new OperationContextImpl(0);
+ ContentContext contentContext = new ContentContextImpl(0);
+ Executor availCollectorThreadPool = Executors.newCachedThreadPool();
+ PluginContainerDeployment pluginContainerDeployment = null;
+ ResourceContext context = new ResourceContext(resource, parentResourceComponent,
+ resourceDiscoveryComponent, systemInfo, temporaryDirectory, dataDirectory,
+ pluginContainerName, eventContext, operationContext, contentContext,
+ availCollectorThreadPool, pluginContainerDeployment);
+ Assert.assertNotNull(context.getEventContext());
+ component.start(context);
+ }
+
+ /**
+ * Called before the configuration is processed; override to set specific plugin parameters.
+ * @see #configuration
+ */
+ protected void setConfiguration() {
+ }
+
+ @AfterTest
+ public void stop() {
+ component.stop();
+ PluginContainer.getInstance().shutdown();
+ }
+
+}
diff --git a/modules/plugins/snmptrapd/src/test/java/org/rhq/plugins/snmptrapd/SnmpTrapdComponentTest.java b/modules/plugins/snmptrapd/src/test/java/org/rhq/plugins/snmptrapd/SnmpTrapdComponentTest.java
new file mode 100644
index 0000000..143f8c0
--- /dev/null
+++ b/modules/plugins/snmptrapd/src/test/java/org/rhq/plugins/snmptrapd/SnmpTrapdComponentTest.java
@@ -0,0 +1,116 @@
+package org.rhq.plugins.snmptrapd;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.Map;
+import java.util.Set;
+
+import org.rhq.core.domain.event.Event;
+import org.rhq.core.domain.event.EventSource;
+import org.rhq.core.domain.event.transfer.EventReport;
+import org.rhq.core.pc.event.EventSenderRunner;
+import org.snmp4j.CommunityTarget;
+import org.snmp4j.PDU;
+import org.snmp4j.Snmp;
+import org.snmp4j.TransportMapping;
+import org.snmp4j.mp.SnmpConstants;
+import org.snmp4j.smi.OID;
+import org.snmp4j.smi.OctetString;
+import org.snmp4j.smi.UdpAddress;
+import org.snmp4j.smi.VariableBinding;
+import org.snmp4j.transport.DefaultUdpTransportMapping;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+import static org.testng.AssertJUnit.*;
+
+public class SnmpTrapdComponentTest extends ComponentTest {
+
+
+ private Snmp snmp;
+ private TransportMapping peer;
+ private InetAddress address;
+ private int port;
+ public static final OctetString community = new OctetString("public");
+
+ static final OID alertName = oid("1.3.6.1.4.1.18016.2.1.1");
+ // private static final OID alertResourceName = oid("1.3.6.1.4.1.18016.2.1.2");
+ // private static final OID alertPlatformName = oid("1.3.6.1.4.1.18016.2.1.3");
+ private static final OID alertSeverity = oid("1.3.6.1.4.1.18016.2.1.5");
+ // private static final OID alertUrl = oid("1.3.6.1.4.1.18016.2.1.6");
+
+ private static OID oid(String string) {
+ return new OID(string);
+ }
+
+ public SnmpTrapdComponentTest() {
+ super(new SnmpTrapdComponent());
+ }
+
+ @BeforeTest
+ @Override
+ protected void before() throws Exception {
+ super.before();
+ port = configuration.getSimple("port").getIntegerValue();
+ try {
+ address = InetAddress.getLocalHost();
+ peer = new DefaultUdpTransportMapping(); //new UdpAddress(address, getPort()));
+ snmp = new Snmp(peer);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ protected void setConfiguration() {
+ configuration.getSimple("pollInterval").setIntegerValue(1);
+ }
+
+ private void add(PDU pdu, OID oid, Object message) {
+ String s = String.valueOf(message);
+ pdu.add(new VariableBinding(oid, new OctetString(s)));
+ }
+
+ enum Severity {
+ high, medium, info;
+ }
+
+ protected void sendTrap(String message) {
+ PDU pdu = new PDU();
+ pdu.setType(PDU.TRAP);
+ add(pdu, alertName, message);
+ add(pdu, alertSeverity, Severity.medium);
+
+ CommunityTarget target = new CommunityTarget();
+ target.setCommunity(community);
+ target.setVersion(SnmpConstants.version2c);
+ target.setAddress(new UdpAddress(address, port));
+ target.setTimeout(1000);
+ target.setRetries(2);
+
+ try {
+ snmp.send(pdu, target);
+ } catch (IOException e) {
+ log.error(e.getMessage(), e);
+ }
+ }
+
+ @Test
+ public void test() throws Exception {
+ log.info("listening");
+ sendTrap("hello, world");
+ boolean success = false;
+ for (int i = 0; i < 4; i++) {
+ Thread.sleep(500);
+ EventSenderRunner esr = new EventSenderRunner(eventManager);
+ EventReport eventReport = esr.call();
+ Map<EventSource, Set<Event>> events = eventReport.getEvents();
+ log.info("events " + events);
+ if (events.size() > 0) {
+ success = true;
+ break;
+ }
+ }
+ assertTrue("Did not get event (in time)", success);
+ }
+
+}
diff --git a/modules/plugins/snmptrapd/src/test/resources/log4j.xml b/modules/plugins/snmptrapd/src/test/resources/log4j.xml
new file mode 100644
index 0000000..69a897c
--- /dev/null
+++ b/modules/plugins/snmptrapd/src/test/resources/log4j.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- tests configuration that only dumps WARN or higher messages due to appender threadhold -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Threshold" value="ERROR"/>
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t] (%c{5}) - %m%n"/>
+ </layout>
+ </appender>
+
+ <appender name="FILE" class="org.apache.log4j.FileAppender">
+ <param name="File" value="target/test.log"/>
+ <param name="Threshold" value="DEBUG"/>
+ <param name="Append" value="false"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%-5p %d{dd-MM HH:mm:ss,SSS} (%F:%M:%L) -%m%n"/>
+ </layout>
+ </appender>
+
+ <category name="org.jboss.on">
+ <priority value="DEBUG"/>
+ </category>
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
commit f21c17bd73b45c070ceeae982365ff8f75c3a41c
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 21 15:38:59 2011 -0400
Removing scratch files that shouldn't have been included in previous commit
diff --git a/modules/core/domain/snapshot.txt b/modules/core/domain/snapshot.txt
deleted file mode 100644
index 1f810c8..0000000
--- a/modules/core/domain/snapshot.txt
+++ /dev/null
@@ -1,3000 +0,0 @@
-93e92c0f415aa66a55ccd0e49d859348d27d5d54367813621979ef0d54e45f9a test1/0 0
-94fbd899459fb6e4939410ee2b0e1bc6bd53a57b2af8032b4a5c0b109d06b84e test1/1 0
-adf3039689ccebf34ec400c347703f17452a9ed9379b99624aa27c0005993731 test1/2 0
-b0879da6fe67fa0b6a9c022362924b13df977c13b25bf7d74c3738e33c398360 test1/3 0
-06656dbb054c912063afd0352d4aa72a071d1a9a4d4183e005a46a09750219de test1/4 0
-8564725d5ef522c04028c8d4ab89455b10913e59332dedd05c5bb7ed7cf80d1e test1/5 0
-251aec9aece7a45263e3f3243930006435dde5c5c0b0bdbea6c5e2304063b9f6 test1/6 0
-f4c7f75e564e53fb29af07c612dd4a5232de603e13a884e058b1e1bd0e909d3e test1/7 0
-77c4d70241d8eed431c5ad1ec4ec83eb7c4c252085aeb411308a3854ede664b2 test1/8 0
-4448f50b3b02039c6162be7ad939db59ff9f43fcd7e5a75aaa5607158d26cc77 test1/9 0
-e283683f6b3cf52ea745d0f2edb9d9dc74da0c0eee06531b5347f4ebecc44723 test1/10 0
-34b6be50f854b805c49be45268fb2ed20d11905b483f260bd9196bff1b1bfa80 test1/11 0
-2bfa9f61b309bc41df4d999e6bde2c3328576b8391421784ae652d5720b93c32 test1/12 0
-5407ab5878fc10dc5254c967b5fe3cf66299d231eb36ac27af1d75c04308162d test1/13 0
-999fc4c84b0440ef6d24c679fe9468f7af41e0875b3a5ba193f54ec824c8466d test1/14 0
-161bd4017bbb689b55d621f9ec7658a5f1f43cb18eb48a96f4b27f31f12a685b test1/15 0
-1ed8304b6f5b888b636438da8ec5134a3a8b373271ad29c55c8a65ee5fad5b8e test1/16 0
-9af92b2dc57f984a7d0f5923e480f509b9f1da52ba0c13ccddbec533104cb5a7 test1/17 0
-c714103b46f3bb4f94aacd14f974a2fd40e968b6fb95d2eba2984992e4914312 test1/18 0
-ad092783b1a1a1efb8dede88a14a83ce57dd72ef9c0220aeeec6a1c54bbf86fe test1/19 0
-ca4ef5ea3f763a7dd58e2d1450212ca8700266e288267b4b44bc07330af9fd69 test1/20 0
-09d3fb328873594a11c77e1100655c891c20aa345ebe836fa8f7f9ebd96b94c8 test1/21 0
-55b174d7c19288f5f7674ce43aa3347cb1602b7df23ea2f249eab97db76e900b test1/22 0
-9555f6f19843fe04312cf23957d408dae400eb3163002b4f1c26945470dbf8d6 test1/23 0
-c6b6c34ac0eba6ac68ce7853942f210fc9aa8702380f53b06d9f8f3eebc017c8 test1/24 0
-0be678fa48e2df02a07d358724ecd00b19ece5653c0c06103367d094815d099e test1/25 0
-d4db7b380bf91f238c03b0165616a201b4a29e70bb40fefb1cd53b1be0c6f6b0 test1/26 0
-11a342df1c98476f73b327c6f7e3e4a419edd3af467eca5180c547aeb6637e20 test1/27 0
-25979869cbf179dd7b91650804438984d53d11591514a1097241a21ce62cfee3 test1/28 0
-095d48e67dea734b4c1e390214cce1fade148df00a03a54ae25fb3ae94e6e717 test1/29 0
-6fc81ff946f393a4da640c4ffc18cc0c79c9c24da1b7a50bfa566342ba853e38 test1/30 0
-f1ace3f1502b144e2badc189bc2b5177a0dee8afe85603775516845e31b4762f test1/31 0
-15270686d4dd3baee620394e99a2b72fd573239787c7a536b0a524922e415de1 test1/32 0
-73fa027929a5eb3eb62b3e2df0e78ecf2196a3df5f2de74d1155a1d867f4eaf0 test1/33 0
-e1cdbaa01ace490fe2d1142550a390310c64e95e7f1b21b4ffd2fd35749971c1 test1/34 0
-f0fa8b8146c6c92350fd9b54a7dc8faf62d8fc4362a4286a07d28b4cb05810bf test1/35 0
-550254395e0d3b832cd0992c480018559965ff4ed2459c17aacf4ccd010e2f5a test1/36 0
-a6691b97eb734822f1c0510474e50b3a6b71ad34c486440787e583b1b47d0747 test1/37 0
-f3852cacd73f6d7b778358aba919912f74b5d473fd055523e6968c846880a68e test1/38 0
-5da6f03a018430a595536d93b439680da6d6a823f44a1623144ebca84581f353 test1/39 0
-6b2571c109ecd5b64c8f1be509c8d7fec3f8dbb422b6c407851311025468283e test1/40 0
-963c1597d2de24b553aa972914c5bd3f19d303067c0ffe38357c2199f9056986 test1/41 0
-68042243d98c62f6705bdc0020eef4ebe5ebd6b7832cf330f022498aa8dcc186 test1/42 0
-9912c7acbf6c86e256ed95e469e859ac9cc5d8fde114abf9ffd02739c8d7dbf3 test1/43 0
-1e335a18dc9d46e1545bc8916c6635f9b0327a2b12552d3b5df01bd6fe9fe7f2 test1/44 0
-497579028dc956d13b353842d4de2303e4300bf82a3107583891ad8888e85039 test1/45 0
-f82d24a260858763fc4650303cd96e8e40f4ec0aa030c9c14b6cbf2056cb44e1 test1/46 0
-4c1f7272a19fe0a3099ef6f4d91762e6a7e12449f62124cbd11d15de911714e1 test1/47 0
-38e403db8d756191973a2f1716d0a8a5e082ea583511fde6cb6f1abb078ee4f3 test1/48 0
-b6556279774a38f8938e7f334eb3633be51916f3051675b048843c8e8ecbf1b2 test1/49 0
-5766243d4d6ffbea18772d0b5926d2886d66b8cbfc6dc00ed8b0069a28a7cac6 test1/50 0
-17fa3dc16a1a190c515fafe9a26f13596dfb5a7a7c5be5ba92bb80d8c738cc21 test1/51 0
-e79c2470c6a8f4e6f59d035ae848b6bd8d941bca899f6156defd5a418a1aa91b test1/52 0
-1425c79446b2e32cc0fd1c919bb1f409844a994756d03bba38bd4669b3cbe94b test1/53 0
-470cacc611b10026a736c639ce709a61bc843c8e947ad40149c29c4384f7623b test1/54 0
-fbf74352f9ad3469810b0360f08903562bf2ee6d7660f8651d37e2f5c09a7d78 test1/55 0
-a6d051dee582e7278bf6fe8a4fd7cf97073b18bef3d5547ace46cdcfeb3b7a63 test1/56 0
-74b6dd40c4d95ef3444d82e536d5dfb3253fcb7d2831318e489881bc967712c0 test1/57 0
-594889b32d366e79a545e487f11a44102b4d4329c04e437904c01beadd1a87a6 test1/58 0
-7ad8d06191419c19a3aa868e5fd0f2ea79e1d2fa37a9ddcbfea584e98583170d test1/59 0
-00a6f54df08ae6720654bb8c4c0a2fb669f362b4d903cccb759f4c3f8b541dab test1/60 0
-c62c7ab4188c70d6b7dfe3127a0f7f1771ec075835f31215fbf74e334299eb11 test1/61 0
-77f54c9394c4d8594421eded4b592a747b346c6cc8f8fee893a7b0db62fb892b test1/62 0
-207d63144c7e3de618fe7f96f4346543d32af8fb1f370b8943da7c5b015c187d test1/63 0
-0c17895edd30ac98a9cea894d1f2ad8b23635302fa1ff0c972bb0778468db22c test1/64 0
-fbe0fc1dab31f0510e6a0da5ad46f0542145bd4efd63f1633b87f24de1aaa3e3 test1/65 0
-88be069fdb3bd08e9284a9fef1e64b828091b83672dd8a2343c369be76880957 test1/66 0
-b674ad594f54f8ef2cc4dbbb84b998f08d2076cc6e9d23591a0dc4cc609adf9b test1/67 0
-8a7c9216ac8d02a31ebd65186d06e88add4720585d408e9808f587c44cea6283 test1/68 0
-89c2acb2a6ff43f1bffb336cc33c9baf8ebc543dc73097d1fb0a9556ac410c56 test1/69 0
-2ae0a4bb528fb450ce4ca0e8208a4c50a86483281f2efc13e1da2918462680ca test1/70 0
-9afc0398b28a4d8a219ba9b4107d3e954237b7d1d80f2dd58942fda25087480a test1/71 0
-402ffa8422932a3e6b4b4ea82e3d849c9fe2d8dd6fbcd974ac6dfd67db97e816 test1/72 0
-51b336dabe9b06c6f4bf0b8ab4beb01d812b5e802d8c562003fef1feb04b5594 test1/73 0
-e3e4209781a43a0cc686d9671d1d13adc8c93a11bf3899185385db69593f1fcb test1/74 0
-ccf800357850ed899d0c20fcbd80d21885a2028de34bc16d786311ee9a9d72cd test1/75 0
-3c994225d1972baa6f97af6455161c3c726ce3b77dad02c4891c6928eb8ae825 test1/76 0
-53d40b96a7bac33f80d966898489de15967b508d60992facbfa8c46c1abad85e test1/77 0
-5383dd2af3479ea61550e0c0fc5ac8d61f6385a5ff9eb3c3a52285aa8a5e2be9 test1/78 0
-ce351ec9efb46ba40dad01e093c14905d8a5dfb1af7a129f6bb22c04fa30fac1 test1/79 0
-e4db5bd0eb3ba46dea729d9bcdc30b23b3b51a0a70847b52a7cd95f296693657 test1/80 0
-5910feacfafedb664c2877588ee39d6a77ff2a0a4ba2be0718d7446f14b64624 test1/81 0
-c8e67ee213c49a9e36da81fa0b0e46732b5ae5fa06993301b42b4acb665c5c68 test1/82 0
-422e2d7728625507190c74fbc5debf436e3214a52bfe81b112e355600dca178b test1/83 0
-ff9ba5727d94a8617a08eec78d5bbe7aff135eb494ddef63d4cab8d8311daea6 test1/84 0
-1038418d653e66633089f1dfbc69be9f92d387a90ef610dcb646f0da6eedf2bb test1/85 0
-248257e12f51227dbb52f96c287e11635f51a520d998587ba481dbe90968cc83 test1/86 0
-6080687a2defc3e4a72ed29137e0a3676395d60e8f9257f14d411eab4034ce09 test1/87 0
-e9c3fe77b8dea071ac40261c8d47270041ad4b0c3d1fc4bda5e3ccfb93318f5c test1/88 0
-b448227cb7726d8d80a9618ad2d237985f14db129816d8cb685de061ef69c197 test1/89 0
-e155e014d4a431498316277e0b8ed4b2d9ae2d581923cace35d5a01d62a7063b test1/90 0
-bd8424f48f00e2ea2a14dd879684a9c46cdd8ed47ea9884163fafbb2c3b29075 test1/91 0
-153b230dcac0bca526235389b061f0053766fb7d0ea8b61d91cee65f7b71b523 test1/92 0
-3c32fa4ee56a4cd9bc186343adea7d61be5f931bd144cd60f691cace1d49634f test1/93 0
-fe6c21de3fe5957810d88a7c5efc9c9b194c3b3a022ac2efc29d8f4af7d2d9ba test1/94 0
-277c096d5578aa103fa518463958625c5379d4bdb200d91f949f8a6f62906d07 test1/95 0
-fe8d978cfa8a5eba2a58ceb811e5e7ad9ef287b2d864e2f4bfe7c26561038785 test1/96 0
-8a2d435818a7d70d9419d0b4e7c78692d960c75376d4eeccf920f772e059edbd test1/97 0
-0180a90589f021bddb305dfa1767de34a9b60988576c6a7e061065b32d2875da test1/98 0
-791799f9931e2f0e464f037625152b7fd9b86fd3aa55aae2f36c58260a0caa1d test1/99 0
-0ddf02f95d3abd712f36e5a9fb83239538ddb461dcd192558b63110a12d9db8d test1/100 0
-770d7e0e31ecfda0a49e85e5b046758c1c620527c102a732b073312944dee44c test1/101 0
-d14b5a9a6e02051e6ffc5e9a7b7e6c8db099737ad3da005b04ae9baf90ed7961 test1/102 0
-5cadf94a6f5e1cc161b8075c676fcc6fee5f314a3496fcf3a864ddb1f2693cf0 test1/103 0
-6e4bae160b599363563699b4acec4ece274ba0f1ecefdc9c7ca6ba85b1046f39 test1/104 0
-cd0af0e0a55ebc613e454e7fd158120daf1b0ccd88238a0d7e638303b6441bf5 test1/105 0
-45b48ed72b11b51b80995659720ab53d1497561e4fb994702709e774f9bce9fb test1/106 0
-1fc332cc25fa971aacc06e498b424ba2f30bbfd5af5c2671de9939fc8be6efec test1/107 0
-da325fb1d76bda85a7bcc51408b37def38abd9cb24181933aa208e689de9b6b0 test1/108 0
-d8992471d36fbb0f6b75221ba3c28bf47e5d3724ba532057234261ed8d445c51 test1/109 0
-5872e099caa22aac444d2c0c7df36656a609bf7ff88a5f2e07ab57e8ab3e8463 test1/110 0
-17fa8d710a7932a2d85f02c19d895db6af85ef8ca09ce0ad2320938c056c1222 test1/111 0
-f90298cd8bbc7f6d9875bd7dbda303726eac9e71657b5b3b6b9ff69722c76cf1 test1/112 0
-34057cce56e528ce18d36b9f30619722041b2268d35c7632a2a60b1c820ab6a9 test1/113 0
-4a019913e772c3d19d02241c38709b1a5d678111f9626b3ff6158470e658cc34 test1/114 0
-384d91d9b6be2058e45daad7a71e8b6b86570e7f7f28f979654b263e1ed3716a test1/115 0
-383caf2e6cec05028ab202d910420ad9b685c425494e775327366292520f7464 test1/116 0
-a68c1833375189b696f757079bb0e965bef7a594749bdfe09179b8f76884cc67 test1/117 0
-33f761834cff416a2e7a9c50476d6e61a20b848b65af354b21277db4bafa79f7 test1/118 0
-cdf4c617bb008e5af0b6177ad7890745aeb7d6681b249af05e62901ff8d10312 test1/119 0
-f245f42b6abdaa9fd4989f6690078d2724569caa14f8f2901e664dafa6739b92 test1/120 0
-69db96dbca51faa3d39492366195ea8854f90365800ed83ea07cb766cbd7c6e3 test1/121 0
-ac32dee0e4bb11fb45378d206075b8aeaadb3781cf1cb9abb3ae92952dc1ddbe test1/122 0
-9da59f7b3a447ebcc335165c33a68b97764396e47b2834f2ce395538a7987b07 test1/123 0
-daa858953cdcc274947de320f347e94e5fbabd1cce8b92efbec322858eb3749d test1/124 0
-d18db683b454fb9ef6214e36de234cc727f5ffcf4dd33cf611c26ef7c114d17a test1/125 0
-f3b79bff4905ee97d05eab0706935b11e2855356fb37277664071ac87bfdb9ad test1/126 0
-8b394a7dc0d99416633f392f0e8a8928a44b4932c4d046fdac01f7fbf07de777 test1/127 0
-5cf8e7acc88ed2ece93a7ee46764da376ce276e15b381066d77654ca76fdca77 test1/128 0
-1722133bc958ed2842fa020b95cc386d10ff7bacf145f1caca65f6b17f79740c test1/129 0
-da60c35db70f29db0fcfefa17fcc014b373cb09fbec8020be0f2422874eaadee test1/130 0
-57612e7db907f0084488969c6724682a32cc016454f457718f3b72abba0d7893 test1/131 0
-c886768d92d40dce485b891db8f9aa5f89fc17d0f7f644634eef7f159ad024b5 test1/132 0
-8fb0955a700af97ec8cbc82740eae78baf0461b095dfb55ea13aa8de1011fe09 test1/133 0
-5ad5dcfe4b6c8f20892fde0f7757ae9902aada719edab50fcf2a9e15b3fd62b3 test1/134 0
-7dd7cda0e4f0ba79022c98ce81b8f813af24fcc92222032014fdc4130dcc7bc6 test1/135 0
-4b71114b12d341aaf9eaf360546fb63f92bad2101b913bf401c96a8c9d699ee4 test1/136 0
-4f8910c3ba4565454ed5e74fd55ab65e21445727734966943fe903e368b612c0 test1/137 0
-83416c194860e8da17d02195703b3d1184c7bb36de16e699e19465e4f693fdb8 test1/138 0
-ac165a46ada013f19aa5a60639f3a778c859a0ee6b259f138c7f0712e79af473 test1/139 0
-ea32e9da4de879a76c2fea22a988fe989405fcd3761a0fa424e9baf78a7391fa test1/140 0
-9bfda524db57a43177e496bc15706972702329a7b3bb1238aa8f9ade65ff32c8 test1/141 0
-f684cf1a93b5b941bbad51258888a692ac20c5297f0fa5cdf8776f72346ffeb3 test1/142 0
-ab516ab86adbcfe94b667cbbda805465bf8b5f424907c06a85966bb7ce2541c9 test1/143 0
-cb8a06068dc9ae497258cdae37761e2b1ba8805d05af0413c88cb1d16a59a46b test1/144 0
-82fed2aaa147eccb99c68a477bf3ca43972d059849bf05bbbec1b8ae18ed8ad0 test1/145 0
-6e29f3b832ff4038cd9524214d5c1820f56c8ae418ab76fd3c78143087a50c8b test1/146 0
-71d61d69f51542c2ca875191bd2d61d5ec7df1ce92dd31003cf47ef009e827a4 test1/147 0
-04290b88ec21383feaf55898062edc5d2b3c658bbee39266679c503f836c584c test1/148 0
-81dd1d834c012a3750357e5f1f3a39c749b1e18d4d64e8da0bc7363f2087d5f5 test1/149 0
-0e573b27ad926a33fafbb626b30597c04e392097842b8ef669ec417ce0d9f2e1 test1/150 0
-0b0e85aefa5254f269278dee2bcf93db170a440b40c309977ed8afc6a177e0b8 test1/151 0
-6cd0e02dfc568762301f861066909f9fab58f8fc4031eb1080203becd192ae66 test1/152 0
-3a6fbb67464fbac9a994f8dc9e9ca24ffdb54d58505ae9161ad7fd198917ce2e test1/153 0
-a8552d2203a95cb65c635e46492a5d65601d349a5beb1527233ac10da7f50948 test1/154 0
-6779dc33d4b85cfa305cbda029b1e30b4f891939b7a5d6a2a397ec13e761eece test1/155 0
-54b4359607d170039b1ae03eb4f1cc38ca6bdc69cd9beb6ea7e795b8977b19d7 test1/156 0
-0af05fe135509e38d8e2c6b86b87377ea9396af869789eb4ad5a5a8976aa588a test1/157 0
-84279e23e4e9fd2b1a88551df8a18c2d8ff5a39acc46f7d7f6c578b70f55c981 test1/158 0
-60069413fe3f3cabdf456781de01186ece1c949906f4ac942882e781ebaae52f test1/159 0
-67dc50fcedcc925248b63b9d6c721eace74bf155dac344ae713c75596c20cdbb test1/160 0
-982335f8f17cd8bd18090830b24cc42ae428b4d11d9096f95ab300d9238ceab8 test1/161 0
-39ce96539abf446780feb4a8ad9708190e8b5660f7f1d0afb76222523b2d65b3 test1/162 0
-54b8f2944628f886aa9fc2b841e2fe98dede8eeb8dde17fed40fd775e23d5811 test1/163 0
-7d3050aed86f48b5691a465829d0aa04d57ff8054c059171be94f02d103d849b test1/164 0
-93fa34cc08bbe366bb115d54f1106fd453fdfe0f6ed0e85250337292d2129f22 test1/165 0
-00c813c05a9629778e1d816d7d488dc12b392d71049812105e611e718a51bf85 test1/166 0
-454324976eddc61634d0df8fba87caa9909cb42cf2b609046f496488565baf82 test1/167 0
-c8efa92bb16ffd454fb00e27e95a0c06d88263f3fd86d95bd1c0a6792a12f755 test1/168 0
-79851af11d1df1ca3491b68bb0062816de488b3fa4f6f1d1b9fe81b85cb971dd test1/169 0
-96cff0601698066d018c84bf96d697c03d1f362e5a407a970de247881f7d0303 test1/170 0
-60b5bdab53b06c6d30f71415e95153aaa87216bc77bc2e3bce7d63199e9cc8c5 test1/171 0
-11ebf3b1eab102a5f42d1fedc90cdfb3745972e74625d1c9d5d3d98f82ca22db test1/172 0
-d302457c4892782536ea2bb3e8088329b5c7c1357b867c91be98740147f3689e test1/173 0
-8275087150cd752cb053f31283a84a8b97d599bd02d0c13c38f6a7ba38aa6d96 test1/174 0
-65e9d252536a0d6b173a8bb22e64d308e9ce4196b58e953de2947ef3e95adc12 test1/175 0
-3c99ff06797305c697787820eb233580638a96c0cbf6877610dd0e7cfa128363 test1/176 0
-e44d0d8a2163e03b1726048862e915ff835b0b3176dd05c32f4e66037dda6b51 test1/177 0
-1995d7eacf17ebcad42731682716b6b66f8ec344c5c070a3d88aa134558e656f test1/178 0
-4f53ec03261b3c38b5dc7889dd4e75836457eac7970a04325f86ecc3f54f6cc4 test1/179 0
-4af3940149a94d212dd91cb1b8e3536b9dcfa58fa533027fde2ade5be43a1285 test1/180 0
-d03494cc1b59ce51d280067998dfac92958223fc21c384bf09a10f575ce92cf2 test1/181 0
-1eab0f69a763f8188da6ab7d0096b0ae6b0607a382c8afadc9247207a0486234 test1/182 0
-018eb8a2a0a6d847b9a2dea900651705a46fbc5cd5c78011a4c4f6f52e6a2ae0 test1/183 0
-23cd6b98474be38d060491b6fe58b7cf053b7a6104669327b952e4f09aebdbd1 test1/184 0
-23cc76a6aafb07b2bfceb6ccf42f21ee20d814ddc15617bcb402f69b7688607a test1/185 0
-82844821edeca06ea5f4a64b08aee16e929c2391ad0275ca7cf28759f986dc00 test1/186 0
-940cccec4de2a2f97d295a3b19adad06594e40d613f55cb9ae5aa5ace61e083c test1/187 0
-0edcb4db3ade1cf50e18cd26d23b765f3ab1a60337b5ed99b39f1fbbe58a0dca test1/188 0
-4892e828d1c7eadf1429e51486740476f885341151a01e83093e7c923c034aaa test1/189 0
-9ed66f2564883f596d838b8b41d37630e9ca47cf8d5db1c2450f5cb8e0b346ad test1/190 0
-74fc7e95f051fa265ad1f2e84bd5e4e7ab0d827b669439f6700ae4235c0649f1 test1/191 0
-8bfc5db387157a1116eccb9993c68b093d777c217da1441e5c792e1ad981691b test1/192 0
-725d03feb739c44f326b363128eedeca6eb690d8983c50729aa9fc6b36a8afa0 test1/193 0
-a65800838a06a63d7cc37d2a7bef131f74a3da961ea6baf5885937f6de7d0f89 test1/194 0
-8aca1fb937f64450a12701b6cb3753bd411b463f20b50ccbbb78b304cb7d752a test1/195 0
-cb414ccb9c08c48972607504c99c0d86b2c65e4787921b1667a54f678a6f5c36 test1/196 0
-92cfbc0578f889690e475fea3b8a17903584e31d9feea20db7bb0bd38e5a83ac test1/197 0
-dcf9046cce111eaeb8b1ba3c608947cc3d4e34930ab101487c79c22b559c6b58 test1/198 0
-ee11c873cc9993f887b2da86962a434070ce19217b2502d72fe902d55c075f83 test1/199 0
-684b2acc5ffa90f58c1662ae6515903b43017a97697ad89fe16f24f3985ec1bb test1/200 0
-51901b446f300d0161a64cea30b38a6f9634c58d47d82390aa99c92c51b09c69 test1/201 0
-23f39e274b83f9e9f2e51de9987a4f4633255bed5209ffe45c644ffa81aaaf2a test1/202 0
-7c5d4f20d81ef4c03603acbefa71c044b76612b268cf9e0692b7a5f820c73fad test1/203 0
-d543c31d78ecdff1c6acec653f0952aebe5b35a0f4c646ebc14a8c6317036767 test1/204 0
-59779c0306fb51d7c13389ab87d89e6e4a79132df1f39a4550f81001a1b28b8d test1/205 0
-b1f1d14dbe1bc1ad593f78ae05beed534ed3356acfe4fc242b4b097ce6c047c0 test1/206 0
-b1ce7edcfd936fa33bbc2dae079d8a81c3cdb67d7146a651b9262a6dfbcaad33 test1/207 0
-c090f591cf936a9bee230f83b38638ec6ea175d5a9403b0e8ef4ade8f7c55383 test1/208 0
-527cfe0aeafa72ccfa3253063a600e1b13948f22846268015dbe435b3208e91c test1/209 0
-74238407c20c98a53e4e042d08b52fb1b3575cb226aae4c6d3021bba6d5a8343 test1/210 0
-d9cd5da16389aa1920984e72937d01657a8d7f1a3f8169104ab1eb900eb56c59 test1/211 0
-530ecbf3d591e4bae5388a293d17a7eb62ef25cc9f66e151c73f502ffb3a52ec test1/212 0
-32541fc9519ba3cc2abc9d304934bcb831b2983503281f1f667e2c10870c765d test1/213 0
-a9b81fa1fee8c597389c2499ed07fcc9eeafbaa5a0041d7d9a91a2b545728cf4 test1/214 0
-2d6e33a39655b75fcd67943e08c8c8e51160edc5de0b148408385134c3f65b02 test1/215 0
-05820e4d257b3112fd55e14c0f28163d22d692398575143de90402b693def880 test1/216 0
-d0af57caf143b7b10a31509383b949345ff9bafb78a8fc3e2c66852a2392e65c test1/217 0
-a151353f9969a97629eff1eb21c56dd5c7563a656b48a7488e8717640c854bf3 test1/218 0
-385883c6f59ec676a5a341397408864094a8c352faf140f7551b0432996d4809 test1/219 0
-5a054f41189cd4896157f7dc75f17f3b40f702a8e0d18f2179e53758be7093db test1/220 0
-90b315afcae7a39071264d2eec0294fcbff8167c3ea13d42ba76e730b41cd74a test1/221 0
-7b8dcd748eef3b385d8d013d0575ccffb09018f56ba288651ef9ff2ea48b114e test1/222 0
-13429f3587ee37a731f7d8c04f7bcb5e32b1f53dffdb970b50b0c8a937bd5d8e test1/223 0
-a27f7fd552acbb5797a9f18ccba573c95c08a61c782a381c64c794b4aba8e1f7 test1/224 0
-fde97705a3dc755ca8e8ef37233053817dc6565799cae6859e095459f1eb82e9 test1/225 0
-e0b46e6227f70ceb65c5ffcc5666d39dcbb2c4abadcc857c201ff893567754d5 test1/226 0
-8318fbefd7cb2d2883e956f325bf3de78da1ad4a6970dc6e6158d4575caf9898 test1/227 0
-0d9747eb0d1226ce7b8c67405ebf8b80497c5de69b6daeaf5083dc3d44997dbe test1/228 0
-d9d765fa97e69a14c645e5ebff5522f9fd53bb996a9143e0181c815b2857f520 test1/229 0
-3ad451cf379c4c8006ac292ff12d5493884daa5bc7a9b9ba46172aa54878dc1e test1/230 0
-3348c3bf0602f5b869f53c0c9957a80a94517c88645099291b66c792e439318a test1/231 0
-bf543efd95d944e25e6ac76ae3bc5af3f88f215d5ff0a8d504f7163c9e4ac6f5 test1/232 0
-de57bfeb7b43def7402035c670456ea018e786e2c7a7880b0768d8fc840a1150 test1/233 0
-6537a4b6649c50a0691b230072cdff3325d7a903e51c12015688516e8705aa0e test1/234 0
-a852a1e6bc44b49dcb17984ad443131fc4ffe2d661939578b11cd67c48b7db22 test1/235 0
-b05deba4c8922ba21631bef140a286484aa691f15308758f458841513c88913e test1/236 0
-f2201eb7dfb00362ed8d4712abc1ed9b73323c46e1911c56e7d2c2c35aacf381 test1/237 0
-28ff52b5666e5974af2df51445eca3f5a37f5bf67218305b8bf6ddb5337cf245 test1/238 0
-e1fe35146d3a36763646b5cf7c91aa7725aea507128c70f56ec2bb4a0207ef65 test1/239 0
-5b91f0790e0c58e102f528f3568c4bd1e9c253b0af7f70c78dba4c2d55c20c44 test1/240 0
-ad793a544dcc74c1d7122692312d7321be0a40347138a9a3d5cf81326486afec test1/241 0
-c16dc1e017f5e8bf20418c7370395a805c78b058149903b36c481302df1a2b33 test1/242 0
-37ea7110bf4f151c9b6490d6e69e03c2679c88cabc700422d1e2a9331bbfe2a6 test1/243 0
-c400a6b6560e46dd48159a8b2268a42784bdb4a730cfad9552077ac83377c6ef test1/244 0
-c705bb491cad1d0b2df518ce07c99df006a1083e5316c3db6ace5dee3cf58c6a test1/245 0
-96ec71d9070d5d70049d10ab788936f539987e6c6fe51ea368df0c74988b536e test1/246 0
-4e89cc8390901451b84a8c31bf00656c05b2bcc2c088ffca0efcfecb3f86f900 test1/247 0
-35f9ea26d5d80cf319e5155125b056b935d83dc1ccfae8d6497e49c6cb5c391e test1/248 0
-0d5d224abf69d50155ffea82f921c5d31fbb8a464376d852684216c8c161c4f6 test1/249 0
-d84efa203e1b7dc194f8f5c34ccbfa113e0d939ce91589bc00fa41e6eae2c36b test1/250 0
-00131158266a252f1e6ba89f1781df1ebb456ee4caf54bfd8b45c7f598ec8114 test1/251 0
-2cfbba4e46922afcae35a7bca5e2f69cdb82e84fba32f6e4ac6ff7d49ee5fc04 test1/252 0
-b03d290c6c16ba06d12dd9a3653a35cc44828a2f54f6dfeb8b3e85aebfef95c2 test1/253 0
-7030e6997946b4f9e1c960e7a2e9b39cde64f9a13aed52b3f6b67e229beccfec test1/254 0
-902339529ca71b9017aa732d215d7745597fb8a03aaa209faabe9f248c18d505 test1/255 0
-84666f8c171facec0339181ef1ddb63e1536fe6774b0245bae8f27a6a750d2ec test1/256 0
-56d270e5ddd17a2f18624d5b824e92cd2ca192a8bb5e8775e2863a9264f1616f test1/257 0
-a19f26b29a37805689c0eb32bd65a4f6f19aa00563faa6b1101bd3d342dcfe6e test1/258 0
-06e874ea0fbf7b3bcc55fd8d1f6b5009dbd6cfbe2f8731519d01b0819e7dbc93 test1/259 0
-e669ba7053fc4acea8ddc4e3192b512e85236f8f09455087e73d968e79a163f8 test1/260 0
-1f47704f57c6bf16116fb341c110eb68b8df2d334415c642c5ff9cbb04ca886c test1/261 0
-de7b7a259fa981fffe1d366a463e54107b64c74847ce13f54098823215de8c09 test1/262 0
-a2e67d4b28b5b6e6cd0ac98f45839d59e3909ca664db822304a2dad94ce430a1 test1/263 0
-411b148139d235469139eab1e3edef142faf76b9fda81a0665599a6a305e0b9b test1/264 0
-f2b10ee09207f01e74a93431bc293a5d833d214254587001f351f11828cf1a6a test1/265 0
-ff0c2f2e88c5bdc31e524fe05dcb4f33ab4a725f8bea6d71ebf48719c1a87728 test1/266 0
-8701191d7a6ba17032aeea57dd89fa08f191ef40cc6cb8fa247452f41c9b3864 test1/267 0
-a6f27b7dd81c319d830c0c44c20aa71f1dc58144c8a476c3b254ca199f3483eb test1/268 0
-38c6d602bb215dc695b7d7b10845b6fc5ccdb1b91467509679d84d0ce8f13ff2 test1/269 0
-6d97f1daf76f2018914da7673d0beb8ad17657d74676c7f5405a14cd64cfc609 test1/270 0
-c7246b0540ed67a36cd4334f34a192932d30ddab470072ccce8ac13070752af8 test1/271 0
-7f3b2432a8a6d3f14ef45ffd6f59db2d5435d85bc97da0ac721e4a07a57f98af test1/272 0
-f361e33dc6b3868045b08a45cdf5580d39e3b178ffdd6748f33e19c05f6c5f16 test1/273 0
-a83292a76edc4dc392666367c674780ee113e9c63801960b8b5f012b8bfbbfff test1/274 0
-39f7f4eb1b7daa3c6ce96182a3a0c2e341c42364b011e680e414999692138bb0 test1/275 0
-202f29fb93567c3946b1e8e37dc5f9090cb46e29311aa570ad82a46505dd7138 test1/276 0
-5cfce21a501faaf353036d66f8af69d924a2f56d850967242aa1b469805c821a test1/277 0
-e94eb1e20a56f2f3110285629998a6716b582faf4ba85bb45db0c97c9f702343 test1/278 0
-306e4b3c970ff6bed8997bb9ca3efd9d72c621a7ad6507474345a5109d02edd5 test1/279 0
-73375ca05ee267bae48fb96ef001e37c6bf64f4ad20f03b5f23fc74c3edbf289 test1/280 0
-2aa9e71cd488cb1e07d32277095726a965fd2adc1e0ae5fc24a22580960ec712 test1/281 0
-ba970b44ad9a2bc0875c01adfd01c147951c82b6a264f9bf8bae522a97795a5b test1/282 0
-d3e2333ec5abec1550f124ee6cb3cceaaf5c8e89037d31984eebd69738d8720f test1/283 0
-b7f4c82bdc02b1ed1777726983809d6bab128dc9a7871f1da663a11d05779b67 test1/284 0
-4d7191b579657cbc396f67b92934469291d43144a2ec6cefec9a48b1dd7e0ffc test1/285 0
-a76bac4b9b4750d9e78d0e4b8471738563d009e48c4f26993ff681c7ac97e4b7 test1/286 0
-c75a6137986a0e5c9ba67f14d31784791e082a62ddd54226b29ad95c386d0887 test1/287 0
-75f761587e28759223410b402b6b381c0b6d20e1c36735d026b95109d3c48c0a test1/288 0
-0169c7602293314eded31f10f8f25e54bdf82e3e083e52c308deaf0bbf148781 test1/289 0
-95a9f1ca86d4e84a6acaf1278ab749735752941d085bd4e7c3c96d6487c6c9bb test1/290 0
-be38afdcabd7b1c1c6ecdaea03b55264b43fcbf08ebc57d98dc2215c5a9de046 test1/291 0
-a2bdd93e7d8f1e557b3db395072128b74dc76b8d3ae1ca49c26435aefa46526d test1/292 0
-712ed4f936672d1c4a6ebdd68ecbcd335291fde8e881ac96a56090ccdb389117 test1/293 0
-cfdc1eec3ab1b78c4ba548c673b4465f048da83bc62691b00bf47b53f4075483 test1/294 0
-5b6dc0cfc2fbe1c954d8167e34858c4569c034975ac034584e1b86dfd55270ac test1/295 0
-eda796f4f1ff71b81c78db79b9b97f543e91437ae19269d0761703ad50260e73 test1/296 0
-d197fd3bf891f51c2b9abe54965eb13b044597d05f1a14e0bb2a38222109f5ce test1/297 0
-3c536320f63057722a2e40db4077d1148bb4fa471b85f887809326e59053b339 test1/298 0
-442c2e6b539fe81fca5a358a5d3b0ef4fc99285d3d36c45c8ff0ad2ab6ab6583 test1/299 0
-2351a94ce525382f5d82a5b0535c4a33ccd4a13474dfa56e515c99fa8c64aaf0 test1/300 0
-9d84d46e39d2565b5c0bead466d5b41257dc4706ea8e91ff51c0dd5278ad98d1 test1/301 0
-753cf0af7209b4c4204fb392daa5f471d19378e4453f3f151febc8beaa7b0896 test1/302 0
-b4ac34a73520a01857c472b346fccf1a3b7c83b7f3b022b9dab1b2579a3cd303 test1/303 0
-8695c9c0379029795157d83b6370458f35e4487852f63279a4b4b35b3e635740 test1/304 0
-c0594f71741e25f9d938d904a2956e71a3f1ad97b311cc580ba73718d74d33e7 test1/305 0
-eca4b309e2375d5faa5a1f571deaebbf27442c7f71274acc4eb7555341017952 test1/306 0
-613aff2c4e6c1a42e98ebccacc5e709118e34447e1090e977d5a6d013d087a8c test1/307 0
-066d0787cebc539ee8af45e904403d0e256ec3c275bb422d55f820a96ee62fa9 test1/308 0
-cfd7796101cdb382ccad79238e0fc0213094b18ed6f9a977fd3fb828cdbbb585 test1/309 0
-f15c21cf62872373c6ae822d5c4117e3372b6c72882013be58f611c988c340eb test1/310 0
-bf71160902e4c4ef75e70d06ea0bdf64ed4f9e47620cb0f284aea284b66b66f9 test1/311 0
-8922211f9c4b277fe23ed1275a7217a856bb8c9c1b878ff42c9d2ef73caa1ae2 test1/312 0
-9e8953a822fc89c84a1946d72f81494ac97408d5c747883cb76835e6d93cdc94 test1/313 0
-d103b9fb0b396b9e629e980a4c1db48baa02ec2052c63182a1fc46741783853c test1/314 0
-30089ac20ab6922024c7344cdbc2388feac545406dea3927607191b2287dac40 test1/315 0
-0af133327ee01fa05d9e8f2ca6e297067214521e9d7b1ea289444d06ae7f855d test1/316 0
-8e1e611320d2483b344b4aabcf5b5712ab79a833911e951ff8ff40fe1fa8def7 test1/317 0
-f52c50ed7b66dc6b0a07a23ffb871f8df60ef5d7b117d3d25f985c9d07bb6189 test1/318 0
-d86a333161165f77d89f436ffd10318000e29a27f6ff6f0cbb457353356fe295 test1/319 0
-53d9c8b5a49e50798bbc9066a877b45143716767e391ad18848bc221ecbcfda7 test1/320 0
-78834b1036a57fdc0ef30465371e8b2620e7b3a4caa3ef34a71fbffe1eecc4c5 test1/321 0
-9ceb0ff15f372d01680cb7ee28acd02c5d6731660fa5fad8724997d7c4884f53 test1/322 0
-e6419cc523eca3fad3616a6952afbaee4bd8a856d25e12b0db50fdcebc91b734 test1/323 0
-6679328ff16a96aded463dfac30ce00edf3342f40973bc741fdc9ecf4a83083a test1/324 0
-dfdb929839749f6ab4f0f4641fdcc8eaaddf9bd5ca698f86e2b2f729a48042fa test1/325 0
-0d4b2edb22037bdaa668a22d904fce3e9154f2a712d6d2bd59616ef0e3840c3f test1/326 0
-f05d1d5cab51b012f529724a6786234a83d70779941897167b8ae6d4138d3250 test1/327 0
-e476cabf2d06a0ace700063664f52e967e859bb28478c29b9867c47841a9910c test1/328 0
-14fb583a38c545bd5d76f337366f7231b3bf30372a9661bf9adb1d37ed7d7436 test1/329 0
-dbb8348cac4dc1734ce75beaa7340d90386be6dc82516915e8b29c55e2e58c68 test1/330 0
-c98eb705ef5130b99b4ee8507826645263edb353187385d57308be31a3dd8433 test1/331 0
-2a3ca6493f8b95449966f5a4644f588ea0b3a462d53d75f889751f2e3dfe5326 test1/332 0
-570bdaa2596d14017fe34b0da2a461eb911f6f991cc85258f2f5512c291acfd5 test1/333 0
-0c1650e727431fbbf1e8c8888135e7dbea5ee3324aaf0266c57e22f89564c0c5 test1/334 0
-3e5b370ed29e1b31aea2dfb0c5b9d69829590c248478a550c386c2a152a9325b test1/335 0
-062f8b0d6c8df91b0268d73aed7ecb54b282190583b485b69f9a929f41098ea9 test1/336 0
-cb400a609c0d1bdb107b1ed5f19d8c2810e6073328b3a55e77fc54243cb3b3fe test1/337 0
-3fb594c0f31786c2f3c68a00dad342ea96c5b9fe54c968b278353b0d7e4bf1bb test1/338 0
-7d5c9d6ce5c2dd1e9e3a06a5cb33e552de63d8d67b1ba5a942d64b458eef86df test1/339 0
-4088231c65b4872cec53f038dd490df6393603e78f6f3675a3be2789ff3f25c7 test1/340 0
-3458d73435b807eac03118dd13a643ae256b0871fb2ee59283fea62eea5085bf test1/341 0
-274dad9b5bda82921bde7c6e8f75127878f5ae213d1b35d625cf04f5ffcf9f32 test1/342 0
-c2985cae86bba3fffc7bee7eeff99acda6ef7c197745bcecf023e8e40f4962ab test1/343 0
-988d71d71ec75923221a140f33b995c663d994828a119a510285a37e92eca30e test1/344 0
-cb092b261a0f9c614b5fd1b465dce38bc80e629d917841a0ec70969faa1faa2f test1/345 0
-846dd105c0b5b8ffad1cedc991994f94f3b0b6642d98f8e406e719b5ee293c2e test1/346 0
-20581dcbad4b0d43ca8884f027e7c055a97527cd1057bf1e0af82d5959c1c98a test1/347 0
-316386885985a759c9418aeee6f47879035af63aae2b755ef2ee4df0ea897cba test1/348 0
-9d21d1e6e1a8c3ca458174a798987c2177d2f4044bc4a7942ef14d608d0357c2 test1/349 0
-2c24c1a8556deec0334bab02601c988db56cad3ef7dfbe603043bba82745164c test1/350 0
-184026503a166c498960d0ada7da533efc9df74f7deea6142b6047cf03db8000 test1/351 0
-1d76c356f8ba580b45397adfb7bcfa5291d86701baba3199ebe2673af9e7931b test1/352 0
-65cc650f92aacddde4e3c950b5e056c2e119d9a54fdba944d19a4254402230ad test1/353 0
-6a7fdc3031d46d17feff57d26402023d723bf6574cfcc0fe4d8a2ecf70ca7aae test1/354 0
-aabeac13bbdeaa56796942635a57dbda65955ef42b54b381ebdc824cef419b7a test1/355 0
-cb7e0c337bf6117c9e31fa61772f39b4a25e89db11480d5f1266c2be5de5248c test1/356 0
-040a482deb9d11a1a9095bec64dcf6c1b20ce3b3ff1db4d17759d95f1f7711ae test1/357 0
-f0ddbc0607f574f6218c09ddd38c50e98c4a576010a4402acc730090d74e4dd9 test1/358 0
-9c9ee7ebfc9c0c7850ac352b6b24e9c899e3e64648aebdf58a06c4afa9186932 test1/359 0
-b82fa41e27eb5dbf03643e4cc0838b5c1cf2071686b92814c5cfad719fb61994 test1/360 0
-73c4b7e130244268fde7fb3df4f186db4d5b2f0474545e3edbf198e9fdf095c0 test1/361 0
-9eb0fc18a7432b389a066b6b3ae2ccf514b993ce23603800cf417539570a1387 test1/362 0
-248de4278686d75bb53caeded3737bbf3b6c8daee1939c350eb7804e35d9616e test1/363 0
-7ec756671cfbf0047c806ae7196104f18785b4da9b4c21468d00c61e602167a3 test1/364 0
-216c0341188ce2d6fe5c298b9e21940acafa6cf9260ec509f32af46ba8d61dc5 test1/365 0
-75ee1bf4464487a684f86bc129b636a09b3e04ff471145710e6125fee6429ae5 test1/366 0
-0edc533721d12945e037484b7be911d001e8a16ec60e114bf95ddee2548ecfa8 test1/367 0
-3cfa4e929f7336ae8b1b73cd373d03c6a3775a26e807c6a96e3fc6d9ce8656df test1/368 0
-d1add6c0468708807249b7a5ef975978dfb97cb8e477e1ac5b04a723d9aa8d22 test1/369 0
-5a17642581b658f53bb07594954a4e6cbbcfa847529059bd927bd2f1ee36f33f test1/370 0
-f549c72c1b440bb0bcf53f5bd5fc9fc11729d720da28da1a2f54be35f15040c2 test1/371 0
-7a6af70f159a14abfa38b1cdb3cd77a2879a223f56fa4c361e8facce9c7c563d test1/372 0
-2973c6c4fc20e448c27dc1c25fe5134b06aa596f7eacc1ae75110a6659c84b3a test1/373 0
-3be688148a3bc7b0dfcd7096ff20c422442b4da005268e92676756c8bbc8cf8f test1/374 0
-2f8d02b663f01de203f17a85562e9ba3e1e73760114a694f636f2389caf9924b test1/375 0
-88f725d0902a165e49a16379340e0d9ad522604200b734b8b2483714745ee006 test1/376 0
-ea7f141f1e6c197aa5760c2b17be56b64eb1fcb0013ba11dfa6a1e3ba03c9ca2 test1/377 0
-6955290f2751465172034e9bbb612bd0d4a59eeaca9d9d97a23ddd258ec585e2 test1/378 0
-ace05d1883480a1188e123fdd9b1631fb829d01e4cc1c09b5b24b5f2ec9ced7d test1/379 0
-4ae2fc3fcbad24e2392c9f9862a9041ecbe390635dce8a55ca3dc7a31d114616 test1/380 0
-31db7d925f03c26b52727449713f1aaa0bf63e991295c1ca79bca1197e3e3ca8 test1/381 0
-47c6c230d305ea92da956b48ed825a8018d8192f165befdbac73aab2ebe344ed test1/382 0
-547bcf9cf5212cf2d97696ef7f0c6cfe1d32693a8b7602a64b742657d1cc1b2a test1/383 0
-fdea6074514194f47712cf998613aeee1f6d112743cfbd15c3c57320da60f281 test1/384 0
-055befcd3b6edb5929f1da67261c56df6f5b17d47e60abb6f7f660ed07d03f10 test1/385 0
-985668e90c560521f0f5bf4288dbe50f722390a3d5d09d654f6768fec067c238 test1/386 0
-c0a1b9a650ad9b8fb5cc8b8e30463b16e2c10c31b4815b3a93b59517547b319d test1/387 0
-8161899d45b88e029369025b1837c91fd23b159c34c6b67b51282469cef76a91 test1/388 0
-1aa6ec0176eb5069e4b45c61c1c91b9d7f93f85006127dbb1a772536a1ee6a4c test1/389 0
-4ca4ab9b9fb1174a7abfd85b1690d9113ba2eccc40f70166674c971c0bacedc2 test1/390 0
-8a255ad12d3b9cba5de3b4b8aad3603729b503b36de07ff96ec9a141aafb4709 test1/391 0
-f83bef82c3811cde4913f6ab2f6038be91d3071b866e7eba127b3f38e56c435a test1/392 0
-92721b3dfd0ced1ef80db31e261ca946c2b1cf459a353a5677f9f7a52cc58627 test1/393 0
-10c95c6ad1af2d228f70830e7f498e7a6cbcc03188b4953c3d79550aa2a7371d test1/394 0
-c09a62446b9fc0af75a14ae9896781293db4e92d097acd6fa5889b16926e232b test1/395 0
-7cbf3b31d4cf3a40d40e4b558e26fedaaf8ee08c0140a8a1624766984cf23c8b test1/396 0
-ae582fd36c3d1ef27a3606318627aa0df48f11dca3bb2291fd648397b492d873 test1/397 0
-071a040edad8dceabbc69df52f57f232e696b50b76d58d5793b9580b7dc80c14 test1/398 0
-48c2d25c71c0ff82d408833907a425179f161af0b7a5483f792f6dce592ae7ce test1/399 0
-ea5a3a1c3ea12edc5740b0b25bc4df9596b39e0d62ea4c0bd7166b85e936fa89 test1/400 0
-3c21d72558cb594ab6ea458b1462bed66390b9eac44fc47005b9464488b966b0 test1/401 0
-c6f561f0394814f53f2c5020e9ba1320a248a306dc6b383019f91b02f261cb3f test1/402 0
-d03479f014756ac8f1918a0c72055f3e74fd58ceac301c48389c4a5b12cd886d test1/403 0
-a74c4437449250f892e76efe22e396130fbada34470be233d9400c72e914dea8 test1/404 0
-b90fce3b327825bd7c13326f61f159fb9be77cd6762256835cd5e17b49e3f8a9 test1/405 0
-d051405dc58a35af00658b0e8d2c00d263ecf2f5fb37a354ee1522709213e726 test1/406 0
-93b9b28739e690c74b767d7bee37f89320d75ed53e8d1fd2b8f14954f5fefd3f test1/407 0
-a6707c063ae2e3a1b2051716126937c48b8f86a9e9dabb2ea3fcb5bceb0a9fca test1/408 0
-652b39c5511ac2c700cf8c36e28b214fa965cd287c76a7b01f7aaa58db674098 test1/409 0
-6bf7d4dd1867fc7d60cce3ccc702f7856975f45275b53c7e165495006476ccc1 test1/410 0
-07a7d35badf5e4783e769be16598ec7746fd5fc3e2f3532206e3520c6c1fd460 test1/411 0
-3b0b4e5045521ad89fd10254553bb07a82eb46fcaabe77bf2c402568b8c415cf test1/412 0
-37486c0c87bfb34f479b619ce19fb00fd4521275b9eab8ec4925e4cc167f51c0 test1/413 0
-e1be95bf97dab89ba0d6c5f9ca88dabb6d85558c83741132c285a70a22bd0b83 test1/414 0
-cc1b11248247c0b7853237386a6c15ebbc97fe13efdbeeece50afdc0052ed10f test1/415 0
-05c61917f3bdb4d25cb109bbad895a72966825aa3afbaa4a0858d6f3989e775c test1/416 0
-86d8da5ac89e37772b4c7a1cefd6af779ffe209ee96f3288628224907cacfc1e test1/417 0
-46e0e05de4ce0543e222f712324adc9002648bb64a2d434cdec252fa50acab15 test1/418 0
-38713d08a5fd56b39f24b32896c70f4ae16e3e9b889e0b02a60ca5d25e7d4182 test1/419 0
-f6489e52a938e6b18b605f749c93b9ae297db3e2d531ca42f674274b5c5e5bb5 test1/420 0
-2cadcc4f341ceffef5ac0f413bdbe1382380bf59d9ce4b17db531a402cfdf52b test1/421 0
-3047e4441ff2c0da119116a2f952786fcbbb9f845696297adfd6d5317b645588 test1/422 0
-7843747e05ec0ea8dfb8b0bdc27d4a06d3ed6b569dab0b1af8cb4bb13f026a4c test1/423 0
-3a95acbf27884860d057a436d29f2e0fc8974f1a03398e0627faa6483875fb60 test1/424 0
-0b0fe35de0c91cadf85e0e5c36fc1a1d3af12c1ffee93cbe8e7e1fe4ed327464 test1/425 0
-bac8e3aa6a880a8a0866c5074a2d11b1530952890a8748028ecfedd9881f37db test1/426 0
-8c86c1d05a96a41b45e71bd6395d0791f1d7425708b1687a86d6b68b17946438 test1/427 0
-3a11175239220d704dbe7718aa07930821b52d377ebfc6c7b6d9be07f3c495ef test1/428 0
-6f757f68f259ee6ec0702dd4a6a86541c7fce54d586dda2333a55bfdccee7edf test1/429 0
-bdb683547287702789e64b437a8255fe89cb58414cab25daa031244cac97d40a test1/430 0
-5e80e76fa21b52373370a02550a9bb7091f7a67a1d9b90406bdedddc337e1397 test1/431 0
-cba7b7c57ec8b9816c22781cda36836ade12f79a24c284cda64ab1ddc534645e test1/432 0
-87b60f281bb9e990496c93062b7ae3991dcedd08c251c58de3780d2fcb8c551b test1/433 0
-0d4d2dfdff9a5e69cd97fca305a0c4ec5444f1b0ed4fb4ace54b2089016df222 test1/434 0
-15805734cb1953a639e576aee695c66100ed0017d8e21b1cceffa53ee3ea5f41 test1/435 0
-b31d21080c47ccb84e35f7dac599e5eaf10251ad33c2801e7869ece911b39809 test1/436 0
-cdecbe7084544381e81d9e5acd80f8bbbd50758b3beef575b28dcf26c5b32e63 test1/437 0
-e45dd819eae60c21039c93c6887fe013f81fe0eb10933fcebc633148e6548c76 test1/438 0
-267a902cd89ed61e3e746995a28f6a684324434af52c0dc894639cba3e736428 test1/439 0
-bb4e75150c8b6cc667b00e1e922868a2bd30d73398d3d4048f1f0d12541eee06 test1/440 0
-b79bcc25ec98192129950622804276e63048b7ff270475954941c452a32fb091 test1/441 0
-8eb8949990691f97567e698d32678632519ee9e871be8d7868fff3ca8a0af0aa test1/442 0
-1e087804ea134e658d208cad9134f345f45137ead6b636189f4d6d89f288802d test1/443 0
-cf9fad7bc3555b2f37f416217b88fe8bb3c84f51cd372d0e547c5e0082aca728 test1/444 0
-2695482158d069afdd9e6006abf1a9149c011e95eb1489933a523f0044575c3b test1/445 0
-d9cdcc5dd250a070a0fd844ed994579a12deb4f6ea4d4d51e03c1853e3bfa6bf test1/446 0
-cb1c0427f6b874af03f4e2e151c70034c91f59d69abbc9b2bcf205718c0bf958 test1/447 0
-786fa44e7cd8564a96d5c5bdd1f460a04d4e712fbfabac81e086924dbde5e1da test1/448 0
-7b1eb65e82cef9d7bc9d5e1c0652a4e305265068621e3bc8e09eea618d6ef832 test1/449 0
-5af9e74a61605b88c3049199e6aab8f174a4273e211d76053dea5878db9149d1 test1/450 0
-57ab0c5102cbb95a95a89bb3992745926228f0c9a910c5f54b907ec17a222584 test1/451 0
-a79837c820987895ca236c61c7c29103a3d20b42f253618333d8d6f1a860b767 test1/452 0
-369ffbcbfee3b361f0796f5fe670864cae41815a3da5c3a32de27154d06e28f1 test1/453 0
-ff1c006b631e53d6d7ddefc3ea7ae28c4024f3810085f75a7ab8ecf9ce3fc1cf test1/454 0
-7d02eebce2d153525c0c3758add22ba75afac29b7a5446d04810baa9f47b1084 test1/455 0
-26009641d0a8fcca6eba691d7fc284084ff06cdf4a466e0ad4ec4a0fc146ba2b test1/456 0
-60e208f94a35a11fe0cf857d104485461cfb84df65c583b7553a2927260e9e37 test1/457 0
-e52188a9646889e1444a8b1203b0609997b3e2eb8bd0c92356b3251d97fb110f test1/458 0
-4a624726bee3a76da7709af0ce228c0355bd6dca921a50d0844f2db18bbfe455 test1/459 0
-d917cb3c78f449434afcb21bd9ffbe5594b2ed9e34c254e40a981656352503f2 test1/460 0
-f0f5f8781638f703ddfe3e66db01265a2710a52eaeb0c0a41fe0b9e3cfdb349e test1/461 0
-125380f75fc8119a6c9c219cd1546b74f2113f36a94884a71365cb2e7d9240df test1/462 0
-2a27ca0707f3ea676123f052b386f19b7757892f3de58b5b00b53f41f1b9882d test1/463 0
-0bbc654de15becb7a8d6e02e1fa6f1add8cd445bc9137fa63907c3f6663bdefe test1/464 0
-9aada2dc2e05020837b9ddcf2749c73d87531fb7bda7fa2d262029b49ece1106 test1/465 0
-81cc1123390fdcaaaca7015a30d2a64ae7ee54c111fda4715a674557507d7762 test1/466 0
-efdeda2601d6872cbc20d340a39b18e13e9b1cf306f212d76d1e4aac7ffe1447 test1/467 0
-c77a1fae105f5ed5485b35f2295ecdfa89050f4663b78d1a02392edf937d9b15 test1/468 0
-dfcfc0bf9b64a1b44f795c459a965aec032453a812d693aed8298dcc711a70f3 test1/469 0
-134405275c2091b63374dfa903271f0a93878acb3e9f17063013193ae66aec70 test1/470 0
-634a7206ab6c204b11f49e67910e6e439b5274f00785916fe459bbd1bbc053cc test1/471 0
-85a5b5846aaba30a578ec445893fc688433066abef0a6f16f08f3ca4cb553a30 test1/472 0
-e30fd385345e1900783973913d865f80aa056f421c7a2ad9b91d96d82fbe87d1 test1/473 0
-42751fc328cc4d5da826aa20b4b412acc445bbae352a3679537c8b6c2af01332 test1/474 0
-9f3cb99b06921de4dea2c49aac935f85a500e72dce01dc6dbc7b668ea64ce6d8 test1/475 0
-f403f0cd92bf77a9fed63bf4160d0fb4ab8c8559a3a9e31dc820665c72d2df43 test1/476 0
-a1784653a210f5c700caacba07f48c55af34c77aa27a2e2a6e61b2cbe30e0699 test1/477 0
-771446592de6e481f97b420e341aaffb76cf4e922df67466923d6f02b5524453 test1/478 0
-59e178a497cc2ad3e19a22d0f9a6adf1d6cbdd44c79e864dbb03a015b747a410 test1/479 0
-12a25610aa08b833cb929ef33e3ec1e822394594999f75640d7269abcf8e616f test1/480 0
-aa5e75732bb87a197970352bf8f1a011ca3e9d1205850332fffb5fe1593fe420 test1/481 0
-1163fcf62cb2011d75b16c686b01297a211244e91557b7569272e5ebd57dc48f test1/482 0
-5a8498b0b8141b8477620d59e99ae67f33aba8ea7ba4165df805c331b1837a6e test1/483 0
-38ff4392851dc6208e207dd562acb2f32ea1e14a7e555ee45561b3a34c15378c test1/484 0
-2034cb697bec724a5d0606f6c76073cb2d239b64e0bfc6811aa9d882ac6372a9 test1/485 0
-d3f199cad7ae5dccd44bc028aa0d2927e004dc1524b69af14a7c9bd11d477f6c test1/486 0
-3ef4640e48af1bfb4334c7e049fe91d59ce98eeeab779ecf4bbb44b2b11f48e4 test1/487 0
-42f8e33028070018f00908a0e82eef7bd6e47a79e4b35aaf2e4aa0f4139a94ab test1/488 0
-4c337f5fbafc7744ab9a0aedaaa10470cf1baef807d3838c8647d3e063e7b504 test1/489 0
-fdc3bdf0ef8a15d2ed0fa0ca0858a877f38700385416673930b22234bb5f24ae test1/490 0
-6e61464a3fbd6a41d2486e2fa7ada9aab21f4c59e6a0e103bb7f7c7dfbd243ba test1/491 0
-5c05e4892cf18c5edd1b355eea329d0bf65432a73ffb7229a7329c5c9b83c5a1 test1/492 0
-bb152622b87c5a2f653940e9ec0370acf8b2b4ca3c59c8cfd8e32637ce33b74b test1/493 0
-6356da68f52c6136de776e72ab821fe501455e1036fec305d1c3385508379360 test1/494 0
-c51330d35c30394a5ac86452ab8d46f2e3d8ec8e950263e910b9f1d6dc2b0943 test1/495 0
-9b1787096ef897aa2c6a673e99eb0ad00c108ff1da77cdc2a59ab55a4e51867d test1/496 0
-accf2527bd51439651dd6efa1e58d4753c71ee5409a8f4eea31e33cf1ed28633 test1/497 0
-8d7003273bf256fc6fe0d6a7e29ac4dd076793686ede306810d7ea847c34192f test1/498 0
-5ce1f2861f337eb1164065b1183ba66533946b7bcb7bb1b71daa516b6350bff9 test1/499 0
-99faf192d9602ef426f97fc62a8074a9bd3f935b0de553569919158aed765332 test1/500 0
-9bc8752eef4199d0154420db1c8d1d33821277be011541d040c6db8a003e5691 test1/501 0
-06ab5524febb3866b5ac9b53c092ba1d555ad24273c6c376f563f99f67db3263 test1/502 0
-d5d3df3310eac34d52559d0e4c3837080eeb0200d9eb89c57ba60574476eeeaf test1/503 0
-265d1c08e6bc4495c5e940afa216a79e6889e52405887ec58b6f78a6c9d266c2 test1/504 0
-d10e1b107173a1081a5df7e54393c12439737892064e22538a0ef78ec30b0ed5 test1/505 0
-3711c236244da1715d67fb5f90266494b21f59cc6dbf0b8cdc97392e265fa1b9 test1/506 0
-3de00a809d5c97fcd31d7a587ac23c759504764687307695179c9337d7f78ab9 test1/507 0
-06cb2a1672ef72c92785733de750549f67599133385a71265501e559e323c513 test1/508 0
-ce1175146bba8770b0034c7fb3bb938f5e47b3e9d4636d4d0d22903f4fcf2277 test1/509 0
-f52272ce4b0d9ca958cf483cbfb5406820de750db97c3e8d809a32e1f1ef5fa7 test1/510 0
-c33fbe0688e569d19a2a5f6cccd2d5b887b22caa410fe4a2c8790f31bb907f1e test1/511 0
-b2b3e4adec1da175d3085d52f02e99c3e86b47abab60cb0dcac070044ebac775 test1/512 0
-7fe8799cebc13c3db8be9595df041d6043e3b2dd0f349b5f4e52d6e798acd286 test1/513 0
-9024a152b84a458e08d13ab422d4977dfa1b4a7ba69c010d0bda0c92d3a7a8c7 test1/514 0
-57688ca17700b42fc35845ecef3969cf0f75c86724325075a565dad0cf4429a6 test1/515 0
-0a5f035ac810ff68919d03a81795f3f40d240dbe0388c9e68d6d07a8b4fc9de1 test1/516 0
-cbb04fa890cc68d5e57a49d91b0e931991f673e38ba08bc63aeb3807c5e70bbd test1/517 0
-a422f4592446ac6bd5a3cba91fb12150843caed2b3027ec167a22042a640e3b2 test1/518 0
-19a24d9b9590f8a42f8ad85cbdca7c99be559097b82e7cb8a50d2adadb3a3b88 test1/519 0
-497eb09bd567e2c85b383ae6d58449b06e82d3634f81b61ae1844d2df89581ca test1/520 0
-8c1acc6f962b8ba0b3e0e884e5c779df664dfec0aafe879edfa7ed70da64f7c3 test1/521 0
-ebc5430c7b1495706f79cf836d95111c29a6d1881d4421c61f987c130b9dd7a4 test1/522 0
-9783aeaac9272ad26888c540d6bf3af93b010272a97d1e61dedb2fe94c9fb784 test1/523 0
-cb0906d5d12cee7f2b2e615f5c50a2ddd00a6f2c7f95204d52f7b6d1f65787e1 test1/524 0
-745075a3e59affac081f05c1ccf1aa832a8cab641dc7ca9b6bde80c14f9c7805 test1/525 0
-a818821765a67a23392bb293c3dc79fb99bb1c4303fed6d6ff5c9bd51d388a48 test1/526 0
-43abdd0aa8ee5ec8850b26be7aa95645e65b75a4c41391b11839e6f032e18608 test1/527 0
-f1f970e8dbd00329246322659a3946f542db588761cf7fc2702df2fd6ad325e9 test1/528 0
-43953f0a8488cacb611b4079c847e3bece4e0eb8908ac7cfe1902eafdcf94bf4 test1/529 0
-7a32d469da9591471052bac1307fb74488f28a555e9b328fbf671922b2e85c03 test1/530 0
-45eb32f682814393ed3487ee5f610f5fac344d4fa56ce111071e5596bcddb44e test1/531 0
-c9d1e01328bce57a878e85afcd9dfdc109d75af6f19e469276b2cf6d6c4a26cb test1/532 0
-25239e3822d53cd8490f24407fa10518b79b270db5b1a090f03769aa9d399be1 test1/533 0
-7f1b2dd8dc594a9679209225e516d280cfb5ba8f94f56b2e10e2f195ff828d69 test1/534 0
-6fbe5a0f3f0c95023a60f505f7f8c011d30d695172a37bcc6dc77ae6925cc04d test1/535 0
-a1e20874db952a63f38a5758719a9b0c5c501645296f9636e6aa520c195a7587 test1/536 0
-7e5db79598346a3bd77249b9ab46532b426465c815897bbb0cbf21b4004a6788 test1/537 0
-11a7fdff7237d13e975c6a999d7a08cff58f0a7e4936c7d4431dc5a61e2c8c4f test1/538 0
-b39f50273db250af58808d566f53c09d000b8e7eee3a76aadf0d825057e48f2f test1/539 0
-20e0e01ff6d6847704a5c30ae7cc4324ad4fdc567d976c7f040e368a4dd22490 test1/540 0
-1725685148ef54508ac8bab44c9235e0caca651b1c7253bd532d191325625e54 test1/541 0
-51ee82409a9ff9cbc6828a6ad8c643dbff49fdfa42118b5f5516f6c4bd5259f4 test1/542 0
-2b97d88684e2b6bae5b4a9fb6bc607698df6e259599ca9f2c7b8bd4db7e3b4af test1/543 0
-4f2b8d32bd474ea9a9cae40d90ffe14c5651ba27d09fbf0eee267d9080be062f test1/544 0
-bed219c39e7bf60463d22bc4b7dedb542cdaf78a67f330f0ec7948ce9c19e6e5 test1/545 0
-2cd826ae0b681e7a08a997c6ca3c5f1c91af3dbba24aa8e9fb52ae450608c0ab test1/546 0
-eb129c3bf22048339142ad4f6e3a0728a5d95720577bb03012bffe0ba1717afb test1/547 0
-c363f6f0db57910e8f665f82c5e6e427739dc2ef7f6f3c5a1ad0a438c89fb4fa test1/548 0
-6bfc1e5d98c90877d2175b9f4c0a1fd21b0dcf3f528d254bb44a2c8086c63143 test1/549 0
-2e478151393e5c7fa5d85104cc85425049afd61981111bea60986f4cb8501509 test1/550 0
-ca3fb813759a14f2cc4e46b40823f1fd3248df9b53a3ea07113c2a5285ee73af test1/551 0
-551f29aa39139add5cb8f6ed7831dbc6c8c017133284e358123e3d507ad719c0 test1/552 0
-184c6ad9a16b102399fdaae54efd42ecd4b41ea0121b1066339cfae1b6cba980 test1/553 0
-278f0a2417c8c93a52a6b99c452865bcbc375c5f44be1f2ed870d96d4a41e008 test1/554 0
-fcb90b4404b0db7a8f3228222283eb46b7d0b26fc88b8e0946d7d32a709857d5 test1/555 0
-a1894ef1b329498a60aebff25f2d46713bcb43e5ff1448a48ff746b928a121f1 test1/556 0
-3c7ffe66c48e0db4337366ac58928fa7e7ea5db1bab6bdaa02b8ed4aea1ebdd4 test1/557 0
-c3ffc4dc78bc3bfdf2b9074c8d14d2d94aea6581dced00a954d2ec5a340bea0f test1/558 0
-d8f06948b68be28ff8bd2ff83056411f5676f9d9444c89f14f57bcab03f7304c test1/559 0
-1b418ead01346808aceba27216a516070f5da3c2074c729e2aa0e97a3486729a test1/560 0
-37d8fad8e00d664612c54eb4189dcfc15d77e7dfa706b041886c3c34c89bf107 test1/561 0
-189a9b7eb27ac923ccec29d51c47caec92757b2594f5469f73983909615674ee test1/562 0
-431be88ac4e67a6237a688016154a41566afe70cc3091115efdb62a2f320623c test1/563 0
-a6b442f2c169414ee0e1c367f82da09d92a0a6d098fb01076c4395ab37ae1488 test1/564 0
-93b79ae2ee1bcba61f1205d388e1b24f8da13ca73919139dfaaa8989171bcaf5 test1/565 0
-73fb66a6bb6afde0fd28da92df2dc3e91d519146d50ccf0116563caede819147 test1/566 0
-e0c6ebeb43f10d4d1955c27ccb56916f45439b33284f4b8cf15a53ab6bbb6102 test1/567 0
-fb544896dd80805e90be4a69a37380b2d60942d8761d03a681de8ea10cddba4d test1/568 0
-023859a3dfd98b211fa663bb099832eeafdb5ea787f16d52564c824375e64fff test1/569 0
-503d524f408b709791766fc42311854e7e87cc6b6eb370128b0e9eb159334be9 test1/570 0
-a2d42b10420c1a947430603c91af2e5339d41bcc43975207ca24106637c47e15 test1/571 0
-92f55001db15d5c1692408b2d543e3e0fc0ac3b257f8081bcb9ee26fb2b56fb9 test1/572 0
-5035106e79744468d177457f5a22a6e9d3db914f3b09fbc599281422d5755140 test1/573 0
-051ebc7b0acc01ea5fc2c81b6ead1241cddecedd88e5c3331706b7f87b6d4139 test1/574 0
-fb72968c5ab91c357b153ee56360933941e7549055b8b6cd75be8b4539079781 test1/575 0
-0e9e45f5bac0fb5332a0dc4e0bcbbbb04afb49c24dc4c27b252f34414262db92 test1/576 0
-96c1c2eabe397c9e029b0464fe21e896cec917bd299d2424b967f40a78eb89a5 test1/577 0
-b5aaf10a9ce27e2e9947d161cbab2151afb2343d5c2baa043f00f4a45d6faf3d test1/578 0
-f271698dcb33763b4efb8b99e60425e95382cd348d1b7e200239d1c22e573df0 test1/579 0
-7553677cc946ff5123f657933a4dba2700cc593cf2a88bbba7c67e37e4babf0f test1/580 0
-19f8427e6049c049e329c38c38b0e750618750c55b1fbce131ce6def9dfd2807 test1/581 0
-02691f69542348d21da7b1207320559c5a72e8a59232266214aedb8f16335ddb test1/582 0
-dacc4544821a465c5fda9750ceddd104b3db58be2cec48775ba22434fb714602 test1/583 0
-9daeabf60a246297b71b30e294b79d695876b345edae46b38bbae5bab737be41 test1/584 0
-bc3002b7548a038b320b72ef818a2aefe568a866795517637769788781e6bd4e test1/585 0
-4d74b803c720e4f4b5e2d127a1ddfa1d58a1a24b072d36a2aa228d327aa2f7e3 test1/586 0
-ee5e5ab42c307951567b4db4a71f382a37013e4db4f99193b99d6506150c0bb5 test1/587 0
-2b3ed7e25574a4001484a5d738ebc33bba4358430b9307adc90035527a45e58b test1/588 0
-038b96624a4d80316dc52672d65790a0f2ef17430dfcc9bb624d3dbbc56c526c test1/589 0
-ee82698e9734d114651a9953b2f3e7e5dfa33038ed2ffce7ebfaebdf948aaecc test1/590 0
-310126601a6ec8b46b28af666b64a3a513d63ab6931995266a948d412b30b4cc test1/591 0
-a88b648ef30197101bb817b3e68942d3fe492adc8ab2f6bc84b04048597d2e9c test1/592 0
-f91fa554dc0ba2c273a9c74115a671164b5f1384aa95a87a456c189306ba9405 test1/593 0
-f0c918bce32571c2261e4778128852da8e0d276a901edab27373d18c0a04c841 test1/594 0
-50664d4d93bd4a555a62c2cd27fcef4eeba24b5296d4fe4d77fdfa907f1ed191 test1/595 0
-f8ac7b7fdcefd8daaacc0fa566c58a66365194cf891dbf45e8c2293b885f0385 test1/596 0
-3e05978da3beaef54cfe2e572482b706f57c7cbe2db12391468074e65af54926 test1/597 0
-b7c43a706ed88cb6c6864f0623f348cd095d3cbcc5fc6634c3b6ea77d84692f4 test1/598 0
-ad632e5cbc06a2bfd6f23695ff13e0e513ad8119e6b25aa1301a2f7dd115ed7a test1/599 0
-5c213db2b5ac423f8816b5c7f3ab24e8f9054ddc9a61bf9a357d49d622e4bc94 test1/600 0
-a1d89bcd8db8e1254ef05f25aae594f466158412782433db9ec6b4f918a7f75e test1/601 0
-660b5a97b58648fb0ed3d491879e9bdcebe30d55f929de18a944c270eab8b16c test1/602 0
-72353b829a13c431b0def97f11be3cf02d3bbdca4abd3ef455ab90bc4e3a0687 test1/603 0
-3c244be5994062923b6467be1f50a41bc722d38fde3bf796d8e0770b77b5ed7a test1/604 0
-dd2ba34cf843fa8d0027c8d8b8cc0a2fab15128880cad9b23b6ff3128ba848a3 test1/605 0
-2d6050e1e4201d5376ee592791996d5a7b0d2e9321e3dd76163565a110f7c9f5 test1/606 0
-8e34b0353f968149bd5e4833fc2f3519d8a3fd58212c8652250d16157a47a2b0 test1/607 0
-bc19ccf937ea25f9b4fc770cd7f0fe8784d92f2dc2061d3c3587ba02f7d3bf1c test1/608 0
-fd5b0756cce8252d011776b0f78ab8dd3fa666e20a7e80a4543f2820920738f1 test1/609 0
-c634686adfc3cbf017711174c28620ad3e1c9e52b68890e61e439db8623d1f38 test1/610 0
-790e2dd20d31280219ee7d5b5d642cde8f73265c314c7e5e1be593b3630b24f8 test1/611 0
-d4ccc5f8a8333fcb5e6d6ad9ad6c73d121fa54badb2a2698b2ab250d1458195e test1/612 0
-eeb5f85699d1d69d0042dc821f7872ead1a34be7ac96606b38725cc464256db2 test1/613 0
-e214803afff199fc978afe1960abd1fd6309effd8fc8c45d58936a3fd4fa2e7f test1/614 0
-1824d601644fbdd78f35f9aa68ddfce7332409f2bf9048b0eb51fd95936e89b6 test1/615 0
-b5cd988115f9ddd4b4fc9356a0b2e3de4ca9171842e2a3f90cf55cafe4758c33 test1/616 0
-1d7c9402adadfd73e29c519d9e3402f208c4f4dca764a830401cc6cd202a9476 test1/617 0
-38218ef197dd4d615e402e247f9cd9f40110a231008da580cdc0a87e16a66834 test1/618 0
-37908be1e5b0006b10a37ecb59a82a61df8ee3dce6f9c268862dca2cffa6455a test1/619 0
-c476b3ec7ab5e83f383f6cd15fec5998e394587dd49c970f553622163cf18c77 test1/620 0
-d7703e33a81a951b271c00168fc91962f915e24aed9d1860806d9d08572add5b test1/621 0
-04cb7b53a6bd906df38a9bcab348aa3271a1aef5cf42331f9e61f5ed81963618 test1/622 0
-c56e85e4005f3d961c2006e36bdd7f37546d4fba6d3761aa123cb556226d1895 test1/623 0
-cabe5810e9c4d17bfee8b41ba465d2cf2e8e435972c0f78de1e89ec71b6707f3 test1/624 0
-2d35be2f4334d1356e153bc27cb21afdf587f67178fec84c635b0bfe95c71cec test1/625 0
-23e80e6224e5b0aeb5cf3143670f71f7c2e6a3e5cf06fb5d995cec02916e7b76 test1/626 0
-a52d6320677e76f45b461f2ddc7d75b31e847ee846320c256e35c2c4ed222614 test1/627 0
-d430693ccffd53000aeae4b23bd3b01bf8983c7d87bd1e4cfdbade7b40b60b55 test1/628 0
-bf97de1f95d716898b255d2f01d8ad4c68d25a27d4f5a5e7ec12ab75a5de4035 test1/629 0
-7b44ab86d817bd51e6bb197db2ff1497a7708901362d50999127009de930538a test1/630 0
-9166610cfd404d2de2ef5c513c39d301bb622dc93c8d1051f42f3c04481cb8cf test1/631 0
-dc5e86bf83e6bf307d74a774cb2ed7c9e7f999ac5377e877f646431b061bd9e5 test1/632 0
-3942e90e330c3d2cbb90f6dc6c6cea90e8ef7e647d3d7c48437b929ac5fe2474 test1/633 0
-6271588af5689099296c752e946db1d1c5f61db469629b6b47172c65f7822fa7 test1/634 0
-1bd2e8690fe3bc11e7e960caee8d752b49442c4a8624df8d0f3f231deeac7b6f test1/635 0
-ddb8b363938fb4ef92ac995dfa8e7480891a42733c917e7626a504cd20ab8c6b test1/636 0
-4fdf4a2e7e02da689074363a7cc791a7efcdb51c3e0127d81e9fba9609de6431 test1/637 0
-9802b11d09f747c545f53c46da02edb83de0ee8029b65ce1c81c4574d7372126 test1/638 0
-e910be00aec2863d85cc7d5a94580a75a5122a710ec305b5cb8297607e2cc628 test1/639 0
-fd62f4325a31ceb1aaadd318fb6333f8174896d911eb924ea167dc0b91cb20b6 test1/640 0
-295673b7feb51275c704065fc887794ca3911b1014b1c9f2a89dfbddb5b2e477 test1/641 0
-8039b1832488c8b241b4fa57b0b4024c423f0c6b9e9df0023dc36cc9bd930651 test1/642 0
-4ba213a60b77610b260c1e1f97c2c7d6925262e3899b20d09c17d85be6976f78 test1/643 0
-0e376572c980b6dabd80d80bfa74265e69f907d040015b05fe012ed2b7eac939 test1/644 0
-5d61b2a58f7a801b060a9cb6f909250340379db7a070781bc6209b8e1f931edd test1/645 0
-b6ca7c52ef10f7d1f1efd5adcd020ddbd455cabb8e7473a053b46cf76de17f25 test1/646 0
-28f9ce90a93b6289c25fcd4cc4420155c7010111e959f59e16321f6c0c1a4301 test1/647 0
-28e38647097a5af37d5bfed2eca849df9a63a28ef09b041be04ac767a8f11c75 test1/648 0
-08b7abff70be25e851375d06d75d1bbdbe316812ac95a48778971008ef58d329 test1/649 0
-517b660a5398678c6367404442b6c06a08c3b889f593e807f796d2be378e3f32 test1/650 0
-855a30c83ef2cdfb05a326c07265beb87b9f5551f2a8d877fe9719f7ba93a57e test1/651 0
-6390e890d7d63b36aaa4f619248091ce1e3ed615eaa2d924cd93cb87f38836af test1/652 0
-740254753e5a22152b9864e9f224dc6e16b1352c8b0910d94239c7cc8ef14cd0 test1/653 0
-c92fcc0a7d2f6cf6c22a56ecd0893968538e6566ee07c1b469b9b2969e4d627d test1/654 0
-a3fe2a9a7027a3bc1cbf7d97be678fd2855c8441f6dfb278b044b433b75159af test1/655 0
-11280946d9f6fbb0cccfb21f93827782395c4961e3e4b805f93eb25b19b17c57 test1/656 0
-1a9e236eaed6fdaf851620fc860687eca30c50fc19277a6297623c5dafd403af test1/657 0
-5daaa394c941772d5af2eed5b60057b4ec2383a68bcc4d1395212e6474b0394f test1/658 0
-37ac3b0ea262b5787e3ef50f6aefe841ef54b10ea98c07e4e67e0e2b340d579e test1/659 0
-4fcc747787e3ebc16ce912730fd0af7666d2066ee516c8d544d28782de468b60 test1/660 0
-4827bca363e8191e8d936e0a1a47a47f85cbe5525fd651ea2a3ce191a45a294f test1/661 0
-a4356d8b84cc8c6afd06fb76e3bfe4de012e717b851cf9391d12e4c6384a1edd test1/662 0
-200c6bcadb44b5e426034eeafdbe30b454ab447962d1063c0ca3ea3a27406dd5 test1/663 0
-c0fffb44d9beec5292a52f27fa701154fb12acf82e2dbf71660a6b6519c2c37e test1/664 0
-80da1008f8ad9d5e5aff17ad141e84d2499997cb9af6f3bfc33f789e81adcaa9 test1/665 0
-00843f3ac4a6cd52d1fc0513a887321229b40d5c801f94a7b54613f7f376c04e test1/666 0
-2a2815b9c8cc8a348c679ffe74cee401ebb02c011f0c4873eefdc416ee217582 test1/667 0
-f1f9adc27210da769bb64d2425d32a83a51abc62bafb2c4ffbdc7296ae67579a test1/668 0
-fc87e46da6bc96e6e2f59586b3ca52544b4792157920ef09f05c420ae0799622 test1/669 0
-356ef03f9ef7675f5b72133ee16cfe402a43f4ed55f7fcac309b4a1b51793835 test1/670 0
-23ccd4b56036582d90d2d8240a4db6cc4ff52681328700a97c86e2b4bbf59b84 test1/671 0
-bd256fe976a9f8eb6cf19e8bcea22e22da341f3a1a3524b332bafe0484680ed1 test1/672 0
-23627aad82bb6354435f258cdc319c68f56e39652b69e63873ecf6e06edd7b1d test1/673 0
-380ecf19e28f9eec5388adda6b2e3b3880087531e418dd19a71c88d16c654646 test1/674 0
-74c3fcede66191e1f6f9a2bc4775bb8b5684194cea39c97d7c151e472621f846 test1/675 0
-38b74487e520f2976e79081dc534946cc26c361f310b7a5f50aabb9ee3c472d6 test1/676 0
-61ec3fb74d990e303a67c6deebb7110e286eba30654cdd29ae2bf40fa3c5bf9b test1/677 0
-3dbe8108c7bcd01354ef5b6db60527858b45fb07bdf594737d0052da1ea5b9d7 test1/678 0
-0233b20a0737da97e8aa77eb085d3e470381e5e332c1c05b5dcd10d6370521c8 test1/679 0
-17f38a26179ade384e33d50b0a772ce912bb6f9031e57a6fadbb22c5bddaa53e test1/680 0
-0bdd1248b74b81461b0038838decc005411c62d11054f8283f0c28d33eb3dc16 test1/681 0
-0b9c92dba83ba8c2daf10052159af316776d1a4d04bd865184966bc1b26b6290 test1/682 0
-25307469d74364427d7693ebbcf28b5843de134693966dc7d67456c73c0df2f6 test1/683 0
-2d5dcd85b584f9cebe511168ad17dfc5731adc7bc9dfd868967e752fe6a3c8f9 test1/684 0
-94a97ea9143c6d280c15a8fb356edd6f2078613c47309e162067183eb9ef5e52 test1/685 0
-3b3bc20d193143f9b6ed4cf7da30b1dbcb91f8af4d473debf626c59bc5d6c0d9 test1/686 0
-6bd4963d1d6591acee7d65878cdf5307062cd338ebabf53365da473c6bffc05d test1/687 0
-748e278b9968ef59e47618cd432b78e7c96a36ccd3bbb79c4344f6bc14df16a9 test1/688 0
-05febe274a53dcff3e16f47c65965ecdcf4b7a0f5b36dd72888ed0b5e48198fa test1/689 0
-837980d21aeeaa8b758085ae1f672e696f66dbeeaed17fce3800eb4ea96b38ea test1/690 0
-197e6ed5064124c7bbdf520b42ec87c539e6ad449f56ea1f64c166f21514419d test1/691 0
-04bd43bc0bde11e6d57bafd836e3ad404bbd63012d11f52334a21cbb298aeffb test1/692 0
-728ed44971d5cab517dfe06d8d354d82d79677535ed957417cf5c5f794b4ea47 test1/693 0
-f663a97e5ae55456d0dabf66714d824a9d6b765d0d18cf44a21dcb297550b629 test1/694 0
-5d2b18cffaba1e00cf91195ff85627b2a67ac35367fa98292a548cda41c1ee3c test1/695 0
-3fe4c99ed2571a3b90549ec9fe9415fa53a2c5d6f5caed165597767302662994 test1/696 0
-f3708530765def56d155da53daac64af7c0b3e225864c4e71c30004030904000 test1/697 0
-4d52ce0059a2ae6d28ae335a429e2ab775cd78ad4bd857c3749b40084b94229c test1/698 0
-325c9c5ef0e88e633fc4ab84f064831bffa1f9f77339d4a6a5f7fe1c52e4eaeb test1/699 0
-87ae6ea5dff2323d56a3d474740aae298a507f6124c73a3a0d5a96a82f7019ba test1/700 0
-a5b430b746e182fab095f9b71f22fe30d36083a72e64c39c0108ff19a45c67bd test1/701 0
-b3f878a9fe25cfdb88ab0c0486b6fe20a69020ce354f7d2c30855342e640be65 test1/702 0
-bccba8d1dc8a5172c89b27e111a0b7e465b0ddbe6c25a8f75b203d4aa0817794 test1/703 0
-5756819d56824e6662e5b7ffa564b4f709183e8d7d399b1ef7f25cd8b338b7be test1/704 0
-2be1bd4b48e6f4cae6e97a7a4d4625b3d9f170832f74538969d88836bd944a20 test1/705 0
-da836ea4bb98c828562eae30139b0057154c9ff37740c38794e390d6f740bcc2 test1/706 0
-42de3aa86f575c8244a8383aae253127c5bb330c8d3ee70b3465f34e695ef4e7 test1/707 0
-4460e11116970577d2ae2f4b9ed0ab915beaa6884b860adf22f9cc7a420d658a test1/708 0
-d8c5ff360784e6eb6f25912e46c3d0020f4bd2cdf4184e3e5bf6f178d00157bc test1/709 0
-2a9ce289a14d9a7355f9ac3ef7133ae38ba51178024501a82f9b0fee1fe52db5 test1/710 0
-6e20670c7497ec4104b1477387b83d8787863148f157b13e680c01adfc75b6ee test1/711 0
-1c1af21e5e5554caff5ec45d227b0cd7cbdae77c9112f54efeb151853376cc6f test1/712 0
-a326bc91116897d0442677fc109e4b898f929ce8676b3d1ddde995fafba92632 test1/713 0
-e7184a3aef754be39f3a46e40b3958dd9ca649ed2f7fd16a5d4e36aba99e3011 test1/714 0
-26a6e57ecaf9e61804205482147ca7a54aaaec7b8ac266bd8efb39952dce9e2b test1/715 0
-b73daac85e4660bc280147560eff04487259a6a273651951fe1e1257f0e2dad6 test1/716 0
-50b71f46b4e43784d9fdb849bde02ef5f21435b76e2670ce2bbf92655cc9115b test1/717 0
-79f07e464ec075ca220d082429fa4327688b4ca551be188482a3d21eb17d36ca test1/718 0
-06437546b0751a0514d729ece433f51d74d72abc00b7be8b74959ca78377163f test1/719 0
-6a8e941b1fa55b8b5fabf953cc915fb0a39bf436a3cce9c6d6f8d3582ce6cd11 test1/720 0
-499c3bd7bdcb1f47806bebea0d67a36a0e2437851a3309b0f8da10407ac8052e test1/721 0
-1c9eafeb6e35ce785771ba1d560c66ab7f6bc392d752a17fffc45c756243a15e test1/722 0
-64521261c51d22ffc26da060e03c5bbf998f135e2fda2c4e7352cb7771019636 test1/723 0
-8a028be24d0dcc4fe415976522f31afda78a97795ba77b5fee28009d75a3d484 test1/724 0
-6fe553aecc8b628284c8a678713a6f996c995a8c6d960d4c7a7e7562eeeb4ca4 test1/725 0
-61c14a02b445d666f14b0f4e9bc091eb62ff6f66220a7c56d62bacc6a63d830b test1/726 0
-251a9e2bd4c58e4f2014628d456ceb308f12dd847b8f614df8c85ba5640b7159 test1/727 0
-b9b7f1604233e46c190d994931fa9634576c6c90de579a520827962b95acad68 test1/728 0
-e4b15ad8f7276557788e5ca39946d8a7d36418dd617724251e9a8f33e3a43743 test1/729 0
-ab2c301f32447db2c269660b08669eec182982efa0916e0fae3267eb4dd4f86e test1/730 0
-55ad4fed3f558b4d5fb28c2b666e311b181f86b7950f9b56462dadbf41d86c90 test1/731 0
-a7ee16a740be1141c86c0cc57189783f3b32faa89ee6b1b914bd14b0cf2be6b5 test1/732 0
-c33f82f8438f8dd2758564648e7339dcc49e09ea62e9ca6e2aff27c0c5fc0f20 test1/733 0
-3db77f4f06cf07e8df1df5a233bba01ac54f05bc714ffcb6c2112a3ba4b9c386 test1/734 0
-d3b84cfb82a94f76bc25093947b4562ba915e9b83719b2fda44b49a94b45f666 test1/735 0
-f9843f2e1cfb282a2822aff486a540c9b724f876ce9183c818c6f14619315961 test1/736 0
-dbad7733d39b670ed5efccf3595881e75d6c48de73fcbb80d988f33b5ca21d76 test1/737 0
-ea918c07cf4b1c8f3828c291d4ed06c13e002bc4652c8abe9f27a23272ed8c90 test1/738 0
-76a3024c75dc97ea3dada72781033081e7b70356b00fd36a2c217180043a1f5a test1/739 0
-a89344f72b86d4cae723015dc760456d06405ba1e8f46bf4f2ceb922b872bbc2 test1/740 0
-ad29b9d34218824453eaed7d104968465950fbacc7edf00ea0f28ad0dc8b3b42 test1/741 0
-f251a76a9196e7b3e6a125da2a9ea79c700e75ec61ecff491fa54dd93195a2a9 test1/742 0
-44758aacb401717fafdf9b02eb495d14089caf15552bf2c208b17a0c50b1efb5 test1/743 0
-da6af1c6672f86e9f709e1a1b59d670f4c35489ede3df1ef492340dc6da7ed4d test1/744 0
-6f9776fba5d20bc980360b5041d1b64911dbe667db68f4549472deeedc1458eb test1/745 0
-4f5ed0808a5ae55799b88816e4c56d82e4d2504edd8a876a34930275a0ea806c test1/746 0
-ade4d53d50a2d4a4d8db150d61ca85338eb3675eae85cbfb0c9614595b33a084 test1/747 0
-80010bcf79ea468bd398313d10252cd4882abe9c38d46e1ed49e07fabb05df46 test1/748 0
-999d2dad264823b5d5141ea1c5a6d2cc19cbcffdfb28501652eb01f9380cdc66 test1/749 0
-4e10d4c739ec8fe046a128e1c4f74042933b6b2acedd0bee111ae08322a891fe test1/750 0
-5921de6ac57c3f327858928954279871a682baf974dc0d3151321078cc5ffb0b test1/751 0
-2b95e864a4d85d55bc4c7179cbf3a5b2db3bf0ef44700a83e458132a46f75b23 test1/752 0
-7c83e5a0dd52bdc3649d7f697c2d92f0e4cbdfc98e67c4921f7a3ae0fe3bfd7e test1/753 0
-b84aaf77b44497811ce9f312a44c1f70a78ca81762fcecd68b3ed2ee66192fa9 test1/754 0
-8a4723b1dabd232e1970470789695f53f1e3429deac3b6e2409866b2f9310084 test1/755 0
-0822cdbaa990d38c63aef91ca55abcdf898041043b5e79ec6bd99a4d61f2db3f test1/756 0
-c3c43e5118a99e44b6eb189ac9ac9fc727505f69de6e399246fe1750974edffd test1/757 0
-3f5091cfab8d43a2c51ba68f6041e7b649d455d01fce5feca18587ae42c9d0c8 test1/758 0
-a47bb78172fa36d7299ad9b38ddb5eb9e056a8365d80dca2098e578d692a3163 test1/759 0
-753dab26e0c8b0e98f6356c901cd24b6f310058997ef8da8ba382c1e714217ff test1/760 0
-372729d30008aa1e1326486453f5fc2b1eaaba220ca03f63d23e9e17b3ddfa36 test1/761 0
-f2fe7c8b23ecc445047dedb584f23a159b93cdb70d99e9f5bc2be7394d4d0b23 test1/762 0
-afb008f8dcac59c3e386d008c2bd1b0e7f584aee8e941a1fa33d66ebaa097104 test1/763 0
-b8a3ae30a8ff5234c1fe268d4e4d740154b35dc20d7236fef714dd27f1036246 test1/764 0
-04eddeb48112c2bc34bc032c56503fca373cbba9e8cdf1c59dd19ad6890b2730 test1/765 0
-0ffa6b31796107fb5ba384eda13a4baaace7af42dce549fd58bf8b0f55cba65e test1/766 0
-f156e009e85ffbc4f4e0637046d2f913f83ede991be70dff615082878bf45e70 test1/767 0
-774393d55e3bae28d8a58e91c3ad532464dfc20d9648cba58624672741c248ea test1/768 0
-dc4a1a9f034679a1640c58b1d5c519f1841901e29a4eb2e7d360de4b69cb08ef test1/769 0
-1b5c66e31ecfb92232ba59eb3d4c42ccc28315c174f8c0be105df762e54e7fc9 test1/770 0
-53776b9062a6bc86015f7b5a2896dbe9305a0e6f991bbb2e56396d4b6c5439be test1/771 0
-4197248b0e5d07df4187fbeebf335ae8525779fc00b5282578e34472b3b7e28f test1/772 0
-5965a56db632146439c5c0b75fc2424f5143868dc4860574d81944f47fd6eb3d test1/773 0
-4b9243d811aa8720958c1fb4d6484f82d65edac4f4fb60d118cabcfd11666461 test1/774 0
-6a7acfd37ed13554b45984aac2e565bbd22c69a6094474b1bf27c013c29515c4 test1/775 0
-6859cac4fc4d13bb217583603ad09e17e8558790e114f704ca3d73242c995109 test1/776 0
-59d193a7f23b38023d8f2795b20283b7f270fa464d655bd59c607881778432e0 test1/777 0
-93ab24b4d02a6c8d580ddeefc7fd89f631d7f3d655aa58c34a865712d1d59f5d test1/778 0
-9d80acce029d132d3017caee92d5cb1e015055afc3fb206d6e81263c6868347f test1/779 0
-c2a6dfb343e25fdd88cda7de430270434d4dce11ed57ed01699dd39476846b8f test1/780 0
-0c898c68e18d054cd6ea4e6a5aa25ef57419410d6ebaa97762c6f0ff160f9142 test1/781 0
-b5b2564ab1d462898e72866def5a23c1a9cc55d1ec83b7efa972ef12e1b6cf83 test1/782 0
-bd64dc532fe2798d0c37417a5bdd1234b567b9aa681f437ce117ac0739bac4bf test1/783 0
-e1f1661507607b255845f592d79b9e2085db7c10759ff21e8dd8afbddadae74d test1/784 0
-da4509bb842eecda020bbe08f1b8bfa283ed25a162a54d8e0e7329644b6702b2 test1/785 0
-8bdaa5abd3294c0ebc20731ef7e7da9f5409ae05b54ea84df0209890e3962cec test1/786 0
-954f11c612e3f1e23ac8a9d1c1260c28f1ed52cf59ac1f4d6c886f7170d9c865 test1/787 0
-ef95e95a595a2a2e67f32d1637e7223ee8003c127e803a60faaa6b5b205e5f3b test1/788 0
-5ffb660930c1ec1c4f3393cadb4e7dd0a286ee77fc628e1452a6a55c4b1d3efe test1/789 0
-340911241768236de6595b808cba8c47dfb9d69ee902f5edf93eb7ee3d932d23 test1/790 0
-770a1a07c5ae4488ebe08750d8e66129b562d9fda66e7a96f82e655e48687088 test1/791 0
-c057eb441663955358d26574dbbb8b7fe2f86c67e89ab8df20e47089e4af01f4 test1/792 0
-33d8ea3c1a85796f423fecde8929d8f5d21ec9c9108a6543521fb3623cf10a1c test1/793 0
-d18623ac4fe75fd03b338b48c214a033dd2aa49a03ce85f873d5afe9bb601fb1 test1/794 0
-33b1c07ff7c98e53fd4da9f4dee838a3b1897bbd4ce38ee0f04b265733687e20 test1/795 0
-5fe8262bc78b6270142a5fc8bbd7ce5b2da2f67d38a4acea89451951c62500f3 test1/796 0
-d181d66e976f9f8d9b9137f6e70fda90d8cc607c3453c8022ac9609b1c8c458e test1/797 0
-1e9807ae3170d04710cc5f1edf5970e75e170ff88f5a362a5780db29a29c6356 test1/798 0
-2eae1482b8111990595b112f5f9b0ec7aa117a11dd63e67db0ee6b09ee2294e0 test1/799 0
-e1ce48a5b47a6fbe1f316992929853735bc8cd41eca49fa96b4c0aad87ccdc10 test1/800 0
-70a93e9c567fea572dda42c20471938ec7658b79eaecc82594877f1af14d8165 test1/801 0
-36a702919591ba29ef2c93bd8be9baa0d5a57597f1dfdbb7539830c9fb9f638e test1/802 0
-16780f7190dbdde5f18bf3ad7b6232ad5db70c0353e675dc320f46aeaa8022dd test1/803 0
-0481a1ede79240e84fa4b885b3190fa61407eb5ddfa0c2af5e6b6a4129fc368f test1/804 0
-82000e92787a94d7482d85cf257a5b0d06d0daf53e742911e7ddc173011406ee test1/805 0
-5eb8fa70692cd00e836d034294c6dc84724982b968c8c82a36cffae3656a1d55 test1/806 0
-842f67a9036316f00872a8e4b142673733c070b4d56c9489f0dab22bcceb8621 test1/807 0
-b69908946aaa468ad2c25ddd3de95dfb8391c3f0d9c191121459aa414d1ded2c test1/808 0
-48aee682850086a1d37c5f8b4c94667ff4a61627a70b9ee57b49b332c30d6058 test1/809 0
-b00ec3b9ca3b95dc9db743558cc53cbce9f520eb7c129c0ad9babdb5e058cd7c test1/810 0
-63ec907cefabe52eb686f2bf7c541e877644776bd7c539e884c321bc58de5970 test1/811 0
-ab78adef75ea92bad305892391ae74576de83051d418736ad423494198ae05b6 test1/812 0
-4c76cfa27a67d0d6849df72030fd4be0db42fa80cbefbe817105b71ffcaeeedc test1/813 0
-7d8442cca7f5a78a00d673b50fdf08a61893aef1c5a9b5c98411964033adf961 test1/814 0
-d304db740820e34015bbe4785bd203fd9057628ff3d74ddc11158352af36306f test1/815 0
-ec340bfba18fd92963d1a3ee230138784fcdf4e60ce1d43dd14d6646d9ad1571 test1/816 0
-8312c6518d44cc21db9502f6d0ab78dd4804b459ffdd84a30cd46d23452b356d test1/817 0
-00402b5da7c961ee537785a32e625103b50d86620b31233fa9694db6998e3668 test1/818 0
-293c6c125b80e5375ad1fb03f690416e0ff057c5b5916deb0b7126b71795c263 test1/819 0
-4ec401a62bce0c60cb76f1688003f520a0e6f440e441a5c58913c8237ee95dd3 test1/820 0
-63d637ecfaaeeca4f3482c07bd607b1e54eba1a269637a258729c5eebace5a64 test1/821 0
-393cfebe5cbc091f1f9ebaf870da5bffd3374d4dbb8dca1687a0f03434506456 test1/822 0
-278b809894a5a12425f73234379e92763ec02e7df44c1da92dfdcc3f214367ab test1/823 0
-495d2ca3a2cb15c8cb1c9aed0f8c6933985365b2c4163f05073ecd589e721e15 test1/824 0
-98890e1db80bcb6cb5dd6f40d05c32b0104f18c5d644e1f8c3149d257701a6e1 test1/825 0
-e3390f6cc1b5bca016cf1f1fce058e885282f8b4f01bd6dbdb39506e34be71df test1/826 0
-bcba752cbcc095320becf6b98c1752cbdb987721310d207584f3993384cceb40 test1/827 0
-503c26e27a16d1c4ea7b0feefa61762de8f39a5549f7344b98788501be2a5bff test1/828 0
-0d0d5666285a9c6d33a935b215753f3cc967dc7edc052cb214de8a695ed7448b test1/829 0
-ee7a5b14b7ded9d44ca98b1867351fa71268ac2e88175c82bd84d5179d06ccc3 test1/830 0
-0aecc460c83133c297051796b9e17e536c33ac0517c11badc294128557f7bd1f test1/831 0
-431010caaba4ad817291f75240380912b62cfaef1ebf6e85fb6e15032da90174 test1/832 0
-21b5ee719c2c2df4fcb510edd747c6bdab66a34266c9d5173060fa4b6b83f2ee test1/833 0
-3035f5446b4f2702448594a70970edd76c040e153f761adf27fd30e1dfba1f8e test1/834 0
-739c2be39060ae0677f694f80de6996886838d629fd9b43af477291ad803d944 test1/835 0
-1020185a0a5c570b95eefd1e1d3e3ef22aa5e86df8d3057e13c697e0be0ac631 test1/836 0
-e9dfac81c75101cbe6f2f36d381467336ce4108a2bfc191a145296e9ac4a975b test1/837 0
-1888923ca06b4ee8c1d4e279208f18c8d8a7d21949e1edc62a0094975439b139 test1/838 0
-22148d77711be0268b4ca607b75bf7d972b09c73d546e99426fccc75617fad0f test1/839 0
-70ab0fd162bccde605319904797f62376f09ba056b206fd9a50ae72f6fcec5d4 test1/840 0
-e7fa35130840b68d919222dbeb361cb9119e99c3cb69140a38bdc4c4a3630603 test1/841 0
-0d67fbc1aecb496a9da9ea7408b27734a78fe5634abffddaf4fc9409902bbfca test1/842 0
-e473b8cce99598d4342607b3bd2eab39f2c7fae325a915e72cd3776ea44c8ba2 test1/843 0
-c873608a150ca310bda42b0920afe3d7498e1ee986bf89189fe42b8bc4a8121f test1/844 0
-288b079c21168d6e33aa52b731300e602ccec57ff9ef5abae967aee6ea5ac74f test1/845 0
-d9bac38b31d37fc6924527c73ffa4e032c4ad968c8d788e505d5b3c547a09271 test1/846 0
-358ae02992946b3d98cfb9e922ef785a1ce2b7d75e411b6d456b99d3f1351a2d test1/847 0
-35caa024a36c89f9a0328dae8ce3842763f1d9ed1a99edbb01c28f73096117b3 test1/848 0
-9489936a6b3d3a0c283564b7d1d04b4c4a56d9db18c138aab3bb5349cb61b925 test1/849 0
-e529d305f5fc3f51711b6ad9bc488a29539b4706830711f7ecf0066dca7b6daa test1/850 0
-ee4be7668aa7d2217ba3140b9d587593c4954b192b80f411506110f37c7e503c test1/851 0
-4abb1f62635cabb6b6a9b26f768b5e382a374f00c6cc6c5632905581268c4e14 test1/852 0
-df30d010a8077d3911c6928ffa620924bc62d34c6ae264369de9e7922f6ae445 test1/853 0
-b12c3bb791f94e2fea005ca4e94ad1e5b3ef9df65a14afd0c339edc049f48c8e test1/854 0
-80c7cdae300c065de1b85308f50d3e64db640de127d1f3ff06b5a3388aea4f77 test1/855 0
-5196688c8362e328404cd292ed8889e6098591bf2eb37c868048a4dbbe4cee3a test1/856 0
-9570ada06479ced96792842ffc9c69f26c7872a96a07033e420aa18ca2bbb585 test1/857 0
-4f05b489b7f890984ec182b1b08297e6b4909203b98d03feca13e0cb53abee79 test1/858 0
-949696d89d21ed4956e40cd6b4810c0d7c5b2950e07fccaf3ad07cc98a1bd52c test1/859 0
-03e776e62eb63fd3ef84d4eb3fea885ee092c9c45a8bccdaa1c54d50fb8f6f17 test1/860 0
-d24a0358e2485aa527e674acad1858bd932d40128341788cfe1dff26fe55a074 test1/861 0
-325c3b7dee4bbeb9a0ed4244aede9fbebdf1b293b6d51d702879116de0e7a21b test1/862 0
-b36b74bb84508ea89055345af32f739976d3f39f5b59165399174f9d3278bebe test1/863 0
-8283ec0b4c9f26e964922d176293818ff4971d31814041cf12cd758fc32eecfe test1/864 0
-65a5ed5ae98ad878c5ed43f084eaf5b746b01112455009f4ad3370537d10467b test1/865 0
-5f1d5ec0bde8374ec289b931bcceb16cf32a8a78c9051f0dbd2b8913710782e7 test1/866 0
-6d07e6aae985d31b37416d275536edf46a2feb436ec14e90ebd8872e8cc381e7 test1/867 0
-8ebd4cf105364452db0405f2d424023159ac6479a5d87bf603a0aae9a17ac24b test1/868 0
-3857a51bc8ad2d09d7410a804a2f8bb7971d778b42280ac11c32ad6517b7ddb7 test1/869 0
-db704bb5fd36956528a027b8e25c7e13443aca5736589e3e4fd244b3dfcb0ee2 test1/870 0
-57302ba0136da74ae1fc033ed1b63c9775de74c595f2c4b361d2a8acfba6f8a0 test1/871 0
-c7d772f7048fdd4dad9ff68f5ea293ce700738f655a0967003c3da78d4bbc94e test1/872 0
-0ddbe3627d2652e6352d4c2c66d25036d3f80f8250210825a01f29b5a81144da test1/873 0
-5252a08836b92af4ef04548aebf0b407d7c2ad04874c2b1cf4da3ef13bda6da9 test1/874 0
-d6ba333cd171bb75441c6494a98aaf943f7e89a36b88d338d943c4244e099039 test1/875 0
-1100ed72be88ab6814d0007493ccb2607cd1b2a431f75894a93c2774888b69f1 test1/876 0
-208abc0d2ba522025c1dc6feefc028b2e94967cb68eb7d2a192a4afdd7209ba6 test1/877 0
-68149250f84a8b7d0c5cea2bf2bc8888dea2cf29307413ea0a078644b747eb6a test1/878 0
-c1af374ff53cecfb8f89a3d4c9f5f8922296d32b3c49073b498b6f5cf6f7bcd9 test1/879 0
-bced8fec7183eb9e43591f8ea1a4f567cf2d4615fb292f3cfa2e6aa429a75552 test1/880 0
-8abb0adecd8dbfde769d9c9138263e60d8ba07078e3a724a795facb268b2862f test1/881 0
-edc7ee486ce42a36e9563670871ba7f97e3a33660e69f23463f7853798a2fdc2 test1/882 0
-d0d2e11f12762587c7a6b8622d68830231df2e332af59ec6613a6faafd65c55a test1/883 0
-857c7ffd9fed61cf4737e19a85cad4d33d182e16d52fb35aa7eeaa19086bf8bf test1/884 0
-fc7489c9c9c1b343a816b736e157ccdbcd07caaf2fb73ddedab5674511154214 test1/885 0
-ffad883c5ba6f814433b4d34b72be8b697eec721641bd63ccf829258858b4b06 test1/886 0
-5d94fa600efac14b9c21bce1c62591ebea295df155b7e791e712f2c1b017eb97 test1/887 0
-9f7cd7cc3b4ec282ea469db7e9574fcf034eafec84d33f9010fb6d116d9eb2f6 test1/888 0
-d5249ae6592fb9827dad81559200c21eff968dcaa3d716b0350e44b2bb27d3db test1/889 0
-a898ec863a83c6f13ef1f7ab4bd53ed7701385ef8563ea5aaf74a8d21046203e test1/890 0
-1edcc328802dec721390dfae092b0ca1cdd7cbac7429f111f24c60e883d483c7 test1/891 0
-96672b92badc8c357f801830a482c4ba0b30f9107651d2c36a436ca5e4cd84df test1/892 0
-03ff404b5c052581c0348bc65b81a923e81aed4d7d5a94fc2622361d04c3f7f1 test1/893 0
-0bd23d87e03a6ad8fdd59592e6b21954415ae669bf2dec7dcf75c4144f5808ac test1/894 0
-860eea9a3bf1598e9149370dec3b36fee80ccd4ad3f9a58fc989169bdf34794b test1/895 0
-55eef36a58c543a04ce89dcb704ccf4aa6244a14a62bba8a1fb28e10b0b89073 test1/896 0
-2b8f5338b77fd8f0d5becdb6b3cdd0eec01f5eaa788d6b969b34c2f77630519f test1/897 0
-cd3816c7023f73f2f3e3082e1bb55de671e227d63a982353373f27f52b493aef test1/898 0
-0ac91380d72ddacfb36b72125cda1be3a27caa115b3da488430414ddb171b62d test1/899 0
-7cc59565f435a84e51d7d5ced95246052b12530dc316c0578fcf012efc99c15a test1/900 0
-b7f369d3cedf19685cad6049196f074a20e0f56464060d8645534d3795e7b332 test1/901 0
-7488814f75a5645c647794974ec93d2c66308c207bd48511249e7aacb5931e6e test1/902 0
-017da69352342f15351aa2221fa030e431e091f78c68135032dede94eccb4d91 test1/903 0
-4851fd8ad15d7f3c6d494d19fa5c87415b75a910f4437f24735b15a181db441d test1/904 0
-17d0c578bcde1ccc53a344deda6f09b36a3a4f419b829a1f2cd0e42a3f6b0415 test1/905 0
-5eb800a69e560b1c1b1a9dddcf85eb664d78095d0f4bca620dd722cb5f5e5576 test1/906 0
-1c4f58382ae6ba79cc29a4358e3ed24f50c746a390c00fc5921c76346aace0fc test1/907 0
-967d6f5e884ccc5d510f16fbaa9510eec1d8859b60fcc296114f30c6960a733a test1/908 0
-2b7db0c2821e1a90a4c66702d8937caf1329cbf99dd7b8355168ae15c6459066 test1/909 0
-900a4dd01bf33ba965c841846b3bda45c6eba9b419c112342bb9ac87016b5ccc test1/910 0
-51e795c805c1503ebe55e76836d5a66e38017370ed7a439d19642df4f91077c2 test1/911 0
-b98550d0696418e5a3310d069d7caa8f0a74e6fcb61b11fb4324f4010b8e3eab test1/912 0
-29c57e321c154d020af9ee4d594c8ab35496f7a3057f0a79db8b2908086b7d27 test1/913 0
-9ded8c6abaac06ff5a266e9ddd429675dead3816c9613db59f49a215455f5e46 test1/914 0
-73e47c0d9fab1b98f6f22bea075e95a3028a9476a488b44d992e1af607e18c0f test1/915 0
-14beb0b06800b147c1e89524a5d4c6d734c61da376768a0075a01c7881bbb150 test1/916 0
-61f5bd3084445d0c33def4ea1c9cfbda07b74ad08481bcf71f5855dadd9561ab test1/917 0
-ff46dfcba8afdd8af4781a98a629129c3c6e3b954c37763937bc9f2821b08c36 test1/918 0
-891568b9ea605d0ce3bda904c758e48e8a857d06a6bb715c002e433142f9f67f test1/919 0
-ceec962ea95d7e491354872f30da34193837d9c5b9cfe53d965ae68350d18a19 test1/920 0
-72d0ea267da8ca75d8dc6e093c41f731d0eb91db2bc9435912281b86dc5b2ed7 test1/921 0
-acaaa643e3504f2d69bf12fa43d99df587033d75023f2f740735a80a01e25a64 test1/922 0
-2da115e128c16feaa386f9e4fe3391f3259ba514c23803248b6effac42e040df test1/923 0
-bb268aff11dc0707e4365aa738e5e4703d921b473f0dcb40d7791670694636f6 test1/924 0
-b8d8207aaeceb6914ebb8f7750a9b77cd85327515e2ef59e50eac2c3210470d3 test1/925 0
-95795dcf4d2ba7aacad8c2d7b93378a874afde5a03edca2f6ae7ce153b83a0bb test1/926 0
-6273e84971ce0ffbdd25724b78680aabddc85d99d376953050c95b8d5c86caa6 test1/927 0
-e0fc7d9d0e82a7e6f3f4dd8a7e0cd1a75a5e13353efa3e94da8eae292d30a9bd test1/928 0
-0f065e4730a4e50706c401b674148b0dc596a6ab5147ad729a5f3f034f583e60 test1/929 0
-d8a3b6be92697e6b3630c6993dc78e290078c76fc3f3f99029220f6a2b799fa3 test1/930 0
-fa0c4f50cb3b317a348aa46432af36c2f8bb3c7f4bb25393745b35dcba09de0e test1/931 0
-fcb43527a929bc2ebc1fa00ace9921c6609d2f389e140b4a266ad93d1ce8246a test1/932 0
-e820b23e5200d9230b8b4cb72898348b0c6c7fff4b7695a73d19689a6fc49a3f test1/933 0
-c2a546684b4271a8bc5369e877fb7b85060214a6c7a7076b729b977682933460 test1/934 0
-b434ee2bd453117892797a16594313ff3c62ef9c3d6e2dcd83377fd7c91f8d96 test1/935 0
-288b935b0369a24429d40446d142999a22b8917ae05ce2da7eaeca5b88a774ae test1/936 0
-e66819b6cbbaea5a82b5e4f2c4cf0dffc1ef82d34c4b0c2b496ff07fd9bcf346 test1/937 0
-eb988fac9fd03aa068df72fc2e59f8431be0c4b436ffa781d94fb42bb840be58 test1/938 0
-d13635d27272e9c8dcdedbab9ca7ffbfe2d0bc2f9b6a70b8bd05b58b5ca50a0a test1/939 0
-2df840c2ef8711ffd21ef8739427c621ed7e7998f892d505d1e3e24f1c83fa82 test1/940 0
-0b10ec6b91677b91465fa6c274178c1b3230b3c64865f6fea07fdd12a814936b test1/941 0
-1f6cf2abcd3297b1711417b83abc248e2598489091e340cbc60993c1bf8aed6a test1/942 0
-fbe99d7dfe48d79c525aeb71fbf7cb54a0327e0f34b5cb0205370a4aa72295f5 test1/943 0
-c40c024b084c32d43f3ca5ca47323b4f2ba8d2409d66bf83385598c174e2dfa5 test1/944 0
-dfd1774771336f9e39330227b8a47ed19be022162e3bb8a2f1bc2d90f7562bff test1/945 0
-9d6a75bc483062b60a879779ebfe2f7ba3dcb547f51e4c7116b56b5f5b31607f test1/946 0
-75149da7465f79c6641ed15835124a414351f47060bed002b3a167df08481d1d test1/947 0
-5bd3f20d4ccec44841e78b1e31db69694440106ce596a3a9ed38daf2e42098a2 test1/948 0
-f25a68aa95237e9c5d47449b332f8d5f65c3a5cde4d26de5caed4dd465204486 test1/949 0
-2cb93590abaf6f20463a9ceacac618efefa41cf3044deab572746e8b995ec90d test1/950 0
-e62f46d2c1fe261fb64064a46e7f784fec52fc5e7186e745af8398e7e4884a5c test1/951 0
-4cb7791c2ab18537723e5baa6993f00eb389a9720f4cbf35a55b8799ddcf9f35 test1/952 0
-f3e73444c848570dc3e2d3026648ff1e654665b0edfcf9456e8962057012d1dc test1/953 0
-2f68b873db3d68cbcdbfbc0c3497e899cccbaa3c9e8afdf8e2ffe0efd01651b2 test1/954 0
-865355492c5bdba98e05c0841204715973ba32d93155386d6794355e6e38096c test1/955 0
-fd3c0e22f220a55d96a7120facafd852bd55a6d8c67444ab751da299257c7072 test1/956 0
-11d845b1de621f1a34f2f11739269c38d4f77070684903f52556ee0022b5aeb6 test1/957 0
-231e8c04e114ce555c336717c28d801cd194030ce7effd0a5696a1ca497b9aff test1/958 0
-ac7decf59b2d810220acec5819141e901acf651c756e73f92ea145f26fc2880c test1/959 0
-f239cb132010391c6da157b52b6ff093079c4b60a4a0308da52e484e33561ee2 test1/960 0
-cc1d49447cdf5b28711ee1f3044a0731a9e4a6fa0091b311e9ca6e613438a8be test1/961 0
-f94e1a9f00b4076c95ae0bc15bba7237ab7f4a00863e3d02443d6e4eec96eb59 test1/962 0
-4107e1533f6cbd84b813f6bbdf7d0e162f1442847fcfd6a641908fb68657c4ab test1/963 0
-1805c6a10cb02da647954ec37fcbcf0b9b01234abe4db8978e201d0c1283168c test1/964 0
-8d7734523802c4914067c47991f022151340d2be161e11cac33963b2e83726c9 test1/965 0
-efce5e5f596918e846aa14f85d85e4b733ac47acdeaf84dcc427e410f18e2bc9 test1/966 0
-ad71e728035da9e9c4afa5f03e6c94de3ebac7f489efc8f0a82ed9d06ec33aff test1/967 0
-725460acd36098e7ab60b9d0862985f6b78bf2ea72b3ae61593c8fc93240cf26 test1/968 0
-9e3dcfb57ed973c51b2763f46fd01625c4858dd007c1fbb022f6d36e288ec2ff test1/969 0
-43bde0452c32c36bb6c24334ff779b5ed87b3b606f80f69ecfc2faf6679c302a test1/970 0
-002af63965bf58ba78fea496f0c52319b339b72887a2aeccc1bc7ad09dfe0ca8 test1/971 0
-1c5f6b86c86bb75fc01f3cb95a1c5d42c7a908c7d7d56af73c067657c71e497d test1/972 0
-275bc70b5ccb96cc449bfab4f7114b035b30a740ecc974741f6980cec4f63218 test1/973 0
-1a1484b3b9518adbfc74c002cb10311368f6b5a0eaa346945346c87c286e8bd3 test1/974 0
-f6095fcfdff6945c4c91018ae1d37607aa7c0db38282f528e57c98f2cbd8f9ff test1/975 0
-b6c7c373330d4383f1c23df4d369f8edfe72efb5ee9dd47624e91fb5ee19d7c3 test1/976 0
-84ff745c2a4034a995f64090ec02c702cddf0160713de5f16eb5ecc86f1382ee test1/977 0
-a4fe6c84c0f4cc66eacf3ecd630eddc16cd7abd768c240c416a594cb9a8d98fc test1/978 0
-edb60a0970872ebacbab7f03bf0376f860282a74273d87ca13b56954569b3331 test1/979 0
-8be76520415458a0d9fc6ace634dfe9d672f06c386858568c6188989223bc8b9 test1/980 0
-ecd3300db7f84b512376a2e352d7f91a6a16d33b1eb9196ac18f7165cbe5fa87 test1/981 0
-a422e30426de8d986e95901fd5d0c37ecce38ab0726020634aade60dcd82fdf6 test1/982 0
-5c63a6ae605ea9a42b49404d287eac0ba745fa4097d19aa0e744cea2f2491b32 test1/983 0
-a6140385e675a3e6c6578550457052088f4787d32135518c0088d680585fdb45 test1/984 0
-574eb0186b4577e6cd2e06247b6b37d0cfbbf4733228aed42e7bcd1df3598b38 test1/985 0
-a9e2c29553061ebd20a71fdf8cfe572e3f9d5df722570f14acb3df2111de7ddf test1/986 0
-c99164dfc3f6d1df91916fb4fd63f4a17174ccf2457ac8453d3ce09b0299d218 test1/987 0
-d34fef98c0235ea1b66b453ec6ec8ad7d8598d8c4361e27f91f75784089a9a1c test1/988 0
-1c3f0994175adab4a438f17bdd2e4d2e131e1a2a41890ff6b6d7142dbe0765d9 test1/989 0
-deb1ee8a3adbc1189add68b263e513a05ecd9b65e5861a35af4c271943e26bf8 test1/990 0
-181b72c0dad97d9b42d4d6b76799c4128e8d34cfe1327bd50e663d13d12c6329 test1/991 0
-9ad6ceca7ce297cf9fdbc6d47a84b368833c30a58cb5e751668001a713690020 test1/992 0
-f066e0c5ef0c109ed41f21ff737112938fda386abc41588fae53a8e7021215db test1/993 0
-f86b3848d6f5b67a29350b46928825baabf880f097b76682f3fac7bcaf589ca2 test1/994 0
-5a42200434e5ceb78b4d4917b7ebe7dcdeb7a4a307566f46c42890bbfa36a145 test1/995 0
-f87b04562fda7c576f314304d85627bd9ab37371c637b052096258c4e7132a86 test1/996 0
-42d2fadfdb1b4ee3c7d3c254ed880728b07fafcdadabb2a60bb2ea7d2bc1692c test1/997 0
-e1bb8021402887881cf2b32ac5c32516e4ef7b55f152346f7ce3e29189d4bc6a test1/998 0
-00674dadda85a075bedc2bad8e9ed6a74bdaf813cc2b7203cdfec1680658cc18 test1/999 0
-1935e54646d6e353ca808a1e902eb7661024183e9d947ac3bfe5d3615c1b9c9d test1/1000 0
-96264bb6d39f00edff80701fcc823b2991b2d8b96f86460d26727ad2bf103be2 test1/1001 0
-c667f2dfe2d862b732e6f69cd2134f0330321599a7c9bca34ee0ad15875d6e27 test1/1002 0
-95d4b5e8575fb7b2633b309194961ba87df3d07a17412a5ea74d943e117af5d6 test1/1003 0
-b7c4067f278f93d92043878fb8699ea613510014b0e7a5e73b422517724ae7f9 test1/1004 0
-644d870975f2550370768fd9d32c046a14aec8fbf97b608da1d64f0631d6f3d7 test1/1005 0
-cfea72d8c858b37aeb3be45719b107f09a58eeca0064664c478c36bacbeecfa1 test1/1006 0
-dabe77ee10fb4a23d6bd0d36a4d4687d811f7a7cb981ab30f885d20e58f37c2c test1/1007 0
-8c84f7553f3d517852b4e91de89de194e6ce0a9b465d19e127f8090def7f44d5 test1/1008 0
-1eefe47c568624a6c0fb293d50de9bb6d8e169d32aae3e4eb729bb400017ad49 test1/1009 0
-b89bff2ba399297ab594ffdb32cc7543a843c18f390fb8104cf0c750eaf7df33 test1/1010 0
-7f35fc4f10acd3bea75f17707723b69fe756a5ffd74e48f374cc7b0365e6d736 test1/1011 0
-ec1b9243b62f653d83daf3ef8c3db0bb28be5ca6848c7aa9989c35f677221f32 test1/1012 0
-dee826290600a55996c3f672a9b4bf9178538f24244883e420d39885f2ba549d test1/1013 0
-94bd2d6bda44d7bb29ef55e496b75c68faa0fec3d2224b98514cb862933b8d7b test1/1014 0
-350fcbbdc351f7e75854c350212095e618d50b94236353440009e2d4e4f21aa0 test1/1015 0
-39d8a57630df7bfb031c13093b1cdb6abf7281b53c6df54b15d3c1928a427199 test1/1016 0
-a425cd2b4a74967c677fc9aee0a68c20bae73401bbea685174295315debed56b test1/1017 0
-3f075217a562d86abe3b53dff94e09e6b0c5ca6e76f8697e7812aefdb127092a test1/1018 0
-30a37d84527467f12685f2deab37010a85ca6e2368d8d52c7781ced2b5d12138 test1/1019 0
-2e3b67e52111e15c61a32bfb49d425116014741452c1cb86621c7e6fdff662c4 test1/1020 0
-711a7118646c11eaeb5fde1b0daf72e7391ade404e12dc0d38d0ad572faafd10 test1/1021 0
-ccc80c7f328bbb992d5b349490ebcee0c756beb477535971d0310cf9802fc573 test1/1022 0
-722cbf25dd50ae693534f6b76e5c52b72cbe1abdb7e817f2b0bb10bcdb4976f9 test1/1023 0
-5efae2362ee75bc500a9970296b6b66dcbcf69b457d4df9e5c8509cff9a592d1 test1/1024 0
-1731cf651d88f5e1f59cff2ca103371389225955ca96e363b842ffa3b372245e test1/1025 0
-4b1055c1bb421e5235d86f430741446d91e243d6a2f386a3699e9ebe12577278 test1/1026 0
-aba5c34af60c02028119deef9e44db99411bcb5b542722e91377827c910781b3 test1/1027 0
-8fc681e41878f1588720b713a2a03da0f6234c7ea19e69067a30a97429bdc0c0 test1/1028 0
-30ca2234bc002c28deafcc8d68efcc9d7ed57043c7e7f4257aaf6dd4747da5ce test1/1029 0
-dde405d58316b1dd09b5a2fe1da6d5de7de4d2aedf0a90a5c0fd4356b4b4f1cd test1/1030 0
-cb6d6b7643ee8085b80edd001eb9ac7c735efe5fdc335063293f34c7811a370e test1/1031 0
-704ee88b017ec614e9c3d3486bb699d24d299f9a82bb887ff1e61e0bfb449cdc test1/1032 0
-b3334fcb422342e911e0cabb283712dfb58cd53414ad1e544ef2747773e82356 test1/1033 0
-211fd845880f913002dfbf18700d60d1736145b29631e7b789530e54971f1ce6 test1/1034 0
-86677149918462ebed4c4592d09e803709306082c5ef92bf0e99cbc17c541aef test1/1035 0
-595eaaca9cc6346bdb8ebf11325af7eec847f772a344e57d5adc1ef540f1b865 test1/1036 0
-578e7835dd90a1cf1ee92b0f37c590a3343712e3ce7452afa7f966d05e124a8b test1/1037 0
-15cfe5108ce418a8485509674548265684152a6101cc09715923ed8216bcce47 test1/1038 0
-aaa4efde9bda5a0573699751a90891dbb39fc0bdd38225326b1090ed0cf7e0cb test1/1039 0
-c0bf11c82256e46e1a38b0dd2abb16c4e7c4dee34cd7bba4e089180e4c5c0a02 test1/1040 0
-06f7c72b209f0f1d275b5ffa47c31f509f488ab464ecea1ee47a2a5da81f504f test1/1041 0
-56bc351cf244f365e45adc5df7663bfe0fed8146d3a52bea2741630c0cd46819 test1/1042 0
-391fce6144e13745ff5d17b2be5c6e06174143a68ff2a48fbca1cb338d9ef676 test1/1043 0
-78280eb92b5594d2248339b76d910badb43697605dd82655e14b61165203341e test1/1044 0
-3bd6232f0a401aac5b633bdc53cb15d52fc5ce66223f1b5ed139f858b3e1f0e1 test1/1045 0
-77e94c29ed3efd3af87d60d176d4e5ab74eabbb70f8f6b4d1de02306bbe9ffd9 test1/1046 0
-8ddec863715441c1b8d8f160fcd29649638d8d1233a23483a768f4790713c211 test1/1047 0
-b7546707c8ee33d95a2955407d230bc72a74506e0476fe765ade4dbaaa45307b test1/1048 0
-482b47db3aab28436dbfd585fae94fc89d98aa711661424eb25849c720b1b03f test1/1049 0
-4a9b613a3af3286cb10c80e815aeca37a884f67aff502730d2b68eab55f86391 test1/1050 0
-fd8f7047f52b1bf25d132750a30a98b901c0b6c529b23f7f16bd463187b24eb6 test1/1051 0
-76b70dd53adb6aebae017cd510898dea2be2d023a11acc8f9c213ba2fe9960ab test1/1052 0
-c593f7e086810a50e4acf185236793791316fbdfbeb1481f40386ca427ec59ac test1/1053 0
-365632237ecd36a6de395381f7cf6d352dbdb08874ab67d00e6b316d4caf0110 test1/1054 0
-04eff89737818952d7bfd08387bb84a7a4234b4aff3df4e23dea42ebe10863b8 test1/1055 0
-9fcbc46e63fc212d353a010689864d423890bcf0ac7da6a06234311ea729daf1 test1/1056 0
-87b15617b28b815bbcd83de86ce89af83becf5f9eae94b1118ae541ffb6b4b87 test1/1057 0
-cbcf88355ccf79fd59cf6d97a3e9661e2062f1f1a86026850e55900311a709fe test1/1058 0
-185a2ef5b5abc6fedae431bee445607b6a606cd5291e17fa6105742dc921a2a7 test1/1059 0
-02959f2ef4e6274a821481eba4dd5e3bececb11eaa9fcd2efc560623ba5a20e1 test1/1060 0
-8161679219bb92b90b6afae872aff39e672b889c8bfb355c16005e95ee1c50ee test1/1061 0
-bf431025cfed599b18e5490c996c909ad51d5266630b4398f42a773a96908313 test1/1062 0
-715ddfd7d925a6c5da6c8a969ef96bdc7f32f531be9d06b4a9a67144fb9d2cb3 test1/1063 0
-ecd1c2fec0f2f8c185c89543812b94ea2a985b6c57348aa4f31cf9659a5fd2d4 test1/1064 0
-8828aea0e43d9d7876cdd0d93599ae80bd4bdc9d6972ab1bec76d51b01604e8f test1/1065 0
-fd868d64851d1523ec66527e075416d077e2af588bf4f5770c8bbf7ca02523a2 test1/1066 0
-9ab5851c6f071c57633f48fe21f6121037e3d8642003ef7aad696710f0971097 test1/1067 0
-3324b31b12fea37e560fa98789ed1f4853bdeaac3aefcd1fa954f6645323f53f test1/1068 0
-67fe99c3890c9fe3bb7634ea087321c2ac6e6a9172bff6135db40ee4bd154d96 test1/1069 0
-614710c834c908668749aba41ccab5e3455925baba7f8ba73c645e1ba78fada3 test1/1070 0
-695f8868be3b324fa9278610d7ba0e96bd1f6be808fd285b7e6caae2614aa035 test1/1071 0
-562152e12028476e6b1a394e347d7f4ebe0df934acbc317f08811655e1352b6b test1/1072 0
-e247efd9d6dde20883ee3a6596a11b2267e9fabda290fab92473c24f589373d8 test1/1073 0
-cc9cd26962d87d773b58b16b02a6dbbfb6a98f5efee33ae2147565352db65246 test1/1074 0
-6fd974b740949d19b356d4b84638b3c025e82f7a3484a85eccf30e981f2b8166 test1/1075 0
-a2bfb68bedcbef46ef119e3a99ad1279c5d3c2f7debaaf362090b27e04789d23 test1/1076 0
-cb3d1926cbc204266af7c655e41fc26cbe7adc1cdc20a9af184641d49f27c2e9 test1/1077 0
-30a38efc513515d14c5242cd39bf53f1a6135c8f2c284df058386d461e9f6ee4 test1/1078 0
-0a20170c9124d7197559d671b197c0eec13319960fd980395e560878c0675ec5 test1/1079 0
-a4c5ff15649629dcfa7da9f87974e59f83f971aa42064ae84b187cfec2c21d1d test1/1080 0
-56b2b68c4be6af76e893ff2da07fcae0b9bd793b13c7ed8ffee6fb3568a7e1dc test1/1081 0
-0843be3a34fbf85511f20c71a0ab6548b349ec24fe784a5270d265e9b7a0489e test1/1082 0
-7f0c70fffc35d0f94b6e119ef22991bda3742149e772d1b4c5269a5d9afc2cf5 test1/1083 0
-337d1b4112cb3dbce7018e253e8130da2ed50a812c290a75b23c0acf0246f9d6 test1/1084 0
-b08bdc03bcafd6b27cccd87e822ddded6b517f924baa4a7397e3a64e936b054b test1/1085 0
-c19e19e59cac4aac7f3ecec93848398b9e13246e5c864cf85c381854c3e6d2e4 test1/1086 0
-882b807e6e9f67869998d6e0fea438d80ad9a582066357b85e1b77661d307327 test1/1087 0
-f12d1d575b218bdcf7a80ff49b15235efc855610ad0391f2f3edcf67bc447c1d test1/1088 0
-edeb8cccec09aed5203bb1e330ef849ec36de4f64faa5d78aaef05c508e9eda6 test1/1089 0
-4937c4708f6b45eb4d04d286250521036fe6f3b14f253a7ddd22a79b2d458669 test1/1090 0
-250c8e78ebb647faab24fa91964bfebfcd0e3be4cef50075492b6c8e8477477d test1/1091 0
-2a20f6dc13988681056c2d4c31bbccea0b76efcaac11157ed21a454c8e7ff5b3 test1/1092 0
-406383af1c5f3dd765b3fa82e3a045dbcdd01fcf23503fda8b8efb77cacedeee test1/1093 0
-5e4523967784b470f0ac0308e42b9434e657e4e17abec989cd87f8f1e61edfa1 test1/1094 0
-269039d7ebacac02e67fb5f1e9f241505956fcf3595166563476e9714c65a297 test1/1095 0
-4a829e9edc7db10934b4bd3f346505c8bb7255a53c5a6a86ec9cd7aacbf63276 test1/1096 0
-28471d06f30c728fff0c25d2e2e79aa451dd44aa187709c6d404123bd6693b9b test1/1097 0
-33a7f3a751634f16f3d816a6084455c3ce78678993ecc380e6596dc77728a5c2 test1/1098 0
-260a020a47ab118f4c1d8add8655af76effd6f990273063fcaf11c22a9fe96bf test1/1099 0
-8477ee48e08ef8c6d042729013c9170e90cf42727a31cf4a70eb82cc5a0889a3 test1/1100 0
-95f6e0f118bec3615dc09207786e9cd74fbf0cce92b61085a3573df189b5dc70 test1/1101 0
-ece1241839bf05aad4638b8828fb091f5b228330de06b6abbd2bd6dd114359b7 test1/1102 0
-ea21ec02d8d4529967d44d66e020b652c12401f528fbad3226909862d6fb1d51 test1/1103 0
-a41d7671fd78cefac178da785ad26257a6a4b8c71a67104ae0f4d00a1ec8fe07 test1/1104 0
-9ff3675eaefeed08922c582d30ee6a66afc0a4826efd331949e0a26db4ac8723 test1/1105 0
-bc1da177898569ff73d4e7f6d41cc6b4b05c14adb561709b6a146e65396f5411 test1/1106 0
-c222ebc0103ffdc1e26d3f66f273424f1af4ea41e289ad6ccf63a4a188aa81b1 test1/1107 0
-87d27dccfb684919923bd2c324c3db4ff4c56c1d88dee4f08b1bf6f97a5cea03 test1/1108 0
-00dc51d8dafc64b4a4d29dfbfa5db825dd3cdae0b8200193259ee62ac09bda20 test1/1109 0
-65f38e24d2470cf64dfd41c9e77a1bbcf167be02afd82d53ae2b67d0d876ece8 test1/1110 0
-e5a8d2d4a043bee424aa33965dba02ce9e91e815708313da1781c1cfa4614037 test1/1111 0
-d19790a36a1cb7b9c06e8d80ee0f8d4abfd9b88cd64bc67bc9af566c25bbfcaf test1/1112 0
-7781a25192a77c68bdf07a5e515d8c5f4386d8518623eb8f44caea3e4945057f test1/1113 0
-616a1408f69c85dda3f909c43fcae911c72455adf097b6a7f4b889dd3bb96a04 test1/1114 0
-61728a111e00940c36bee71f4706fd71d2a56ecc8aaeeed00a9e07d5b03d55d3 test1/1115 0
-f1cea93ac181efabf8d8c683ebf16693d0077407e2299b302f750acdd9bbcab4 test1/1116 0
-235f62e3a2db9b3729dab346492e666022bdbace878ecb9bd47217d7bfe7a1af test1/1117 0
-9501b06abce156940e346e44f000295e01984fc10859f9b0919409af7b220afa test1/1118 0
-f762556c82b449fcf4b25c11e7497166500e6fc3ec333352cb8b5dd198f088fc test1/1119 0
-727c9f8eb5047afa2e57d8090abb39dc0048f6f7a94ad4bc5142ac1ec256d948 test1/1120 0
-acb050484d3d33b69c3416fb3a86d4fab68cb72e2ba81661a4bb3439c3057f37 test1/1121 0
-803080c34d1f8ce7d16bd8d5cc7a131c027b6424d171547e538811c1bcc5f6c0 test1/1122 0
-8c3f9eb0a4df8972ae8b4612b70826293040b0e9e6526606847957e7439f1579 test1/1123 0
-a2f132da7a7285403eed6a814c2914a2066a69404e7e8b3e5bc7fee8f1586d48 test1/1124 0
-528aa043de9d6509c1734bca3f571e7c5662fe487057f99937909c86bac73072 test1/1125 0
-92d83c2ff4481c86d6333679e50d2f187af9266027ffaa55348095e189b2b7ca test1/1126 0
-872f94bde14a5cfa7ba3e97bf0de08570814e515534564b4b26b9ea117755ce8 test1/1127 0
-88e7b1b48e6d8b94317853402b45ce4de9fa6ca2ed1781e484f8f7c7a503426e test1/1128 0
-abdeaafb8d1366e70211687a99e77965181e95931f26c68adcf9b49d05dec92b test1/1129 0
-7f5111868a769cb8d33eaa991f82cbb696a1bf603f866d4d49f2d61154fd7724 test1/1130 0
-fcd3e869a8e54a6a0ab27dfedec044788f057ae8dbb99edb620242cf8bdc4fe5 test1/1131 0
-75fcf5cbda74d484039c58d1cf83faf0d466acc54b5335409eb245d3120831c5 test1/1132 0
-2089e371afd8cff90e44f4c8bf0f04f24cbf792cf2904c85801870066e4769d1 test1/1133 0
-0be03680bb3529431b8e03f4ad3d112017942ceee73127dc2125089e31f6b9a2 test1/1134 0
-d32441e746a43f5400a04337e276fd23cf46e6feccdfc5b929ac6744257132ce test1/1135 0
-bb6116d44c58ee4ba03e2bd322868c1697189e8761d1bfee08effa1be4d7098b test1/1136 0
-bde5d0ebd82cb750148208f7db310c603a5d36518058d814c527fa514daff8ae test1/1137 0
-5bb1d371caa448a52e8ec58b7810e8cb5ff71d823db8aa9ce958018e9d24f63a test1/1138 0
-5e907f5e871c704a885c4e1df2ab5ef00704eed1e04a3d661ddfd6a7d6838cd7 test1/1139 0
-514e0013983b74ca6dd20e0bab7c30f337ae8dc4fdf6afded3ff82265881b59b test1/1140 0
-c94e6b3dc51da04cad4d4de98641f796168d2e1062836fa333f45ad79c8ca85b test1/1141 0
-d0c94d509054fcff1bd2288ad360d45aca946d06242245ca50b5ded66f763319 test1/1142 0
-0d464b3ef0322e9b966c97f4f713b19af1c86ee055d7231660a41c244b1e54dd test1/1143 0
-82d19214ac90695bb0618a30996424806b4b5596508534aaaf0a55f346da52d9 test1/1144 0
-3db339491d83c9468101d2b628c59c295f0d1a5734325999b090eee91dc13438 test1/1145 0
-e3aa3564d47471f083b948d65781ead5a820b708a0e43792eb9ffc2d55bebdc5 test1/1146 0
-3d49f22fbadedc85eebbb8a817e2a204b39a43d8dbe54100c06b1b57061c88d6 test1/1147 0
-c27cf204d5f1e99d1c1d1ea883ab36bce4d586e9a050af23bfde7cd7d67c4162 test1/1148 0
-a5c014c4aa93d89ce33c6bcbf53a6b709b8022297234f95f9a3883c8a69b3854 test1/1149 0
-490961a48a31fbf6bde0338363e9a4be93c08dd5fc7b14a76d94dbece1855947 test1/1150 0
-332241c53114737ec978f25f17b49e510aea6de0c73da709ced85a2f4877d007 test1/1151 0
-64c8bc36d57ab97eb649d2a7dedca286889894bda8c81aa290e8b302188af00a test1/1152 0
-f1d9a2701f4bd0b75aeae65853754a1c93481881e42defd08fe0f92610955de6 test1/1153 0
-12fd81791429a4403588be0096b2cc8fc9f66c405b0e9af761169cb239858387 test1/1154 0
-0000b876f6a999528ab835c287f6e7617c267b435a7c031dce37d2af506b5a44 test1/1155 0
-6a4d7e65973728c89a0d40c72b58d1b6704d60fe017ab6b529ae9197e50d879a test1/1156 0
-f270c1a1848d291dc2f326e82d0082df70a5a31ac958b2dc7a10d641f66fa69a test1/1157 0
-e8c5348b510593c74658122b5c1d59bd404855d194a29ba789839476e8015119 test1/1158 0
-3be577e1bbc920e0396150fe6bc619a5ded0183fb153746ad793e76e1da9dd7c test1/1159 0
-2b66ffd9232061af92112317cc6f977b07bb2595c3cffdf5ba7cf29eb51dbd73 test1/1160 0
-de93644bbb8148cc75c32c9c8f0cba2616ec6d8b3138b4210e9109ab7e8a4f9d test1/1161 0
-3cb424e7577b18e7e8c6412e3a80076edd773b226b16da25ad14ec554a5c4029 test1/1162 0
-0f357c163debf6ec4496747a71e6617cee0e07d8c3f7b6fa346da96e88b3406d test1/1163 0
-ca89b2c09360104ac71dea16e541eedb63d03152b4b273c2d9ca3e74adee53d5 test1/1164 0
-7064c546c401b42e7a6ebdb776698ca51d10688a21e8eb7d5e5201460316d6c3 test1/1165 0
-ec081d1e826dd0198d7c690fc8b303043ba7ec16c8ab92d07d134b64380ff68c test1/1166 0
-b33f566881a776828bc7e0a3b0dc5eeed5081521b49d4994eb243b2df020f8b0 test1/1167 0
-521c8c26b2b71c45d1b5c928b1bb5999cbfe2c8aeb13109566b81e44578f63ac test1/1168 0
-d197042cc4715bec0105a26479d1267af3f40dc20ee36e48edc8f5d703bdc6a4 test1/1169 0
-ba9df39167bcc9814db2d1144d803b1b0cb77060bcbf2544b8ca6256a6ad1370 test1/1170 0
-3df248efcd0cb3189c40bceb388fd56e6ac25bd78f59b1f52f3f81ff325d493e test1/1171 0
-e3690e40f0482dc5f86ca841e23eb021014c668f48826939a9cf7d5dc8daf054 test1/1172 0
-224b77ae9ea08cf991ccf7126050e11dbe0cfcea1b1422b14a6ead19eac51ba5 test1/1173 0
-daab81e659a24a90276fa1d7b0adbbb3bf7c47a6b5294e638edfd5ef3be5c795 test1/1174 0
-ef6ec5ccdd07cec1dc8bd4a105439fd1ae54d2a5b6ba7407be3d85f91112ac04 test1/1175 0
-aaebcb46a3a9829b6d886c4c161bf22ff72d359264983ecb8fb9de79a0310ea4 test1/1176 0
-955ae1bf1030e828afc363cd6585992ded8c99bc932019e5e13a81cfb54e3b7d test1/1177 0
-e5e8a30b250306d0ddcf72c3826aed0573c506dbe69249b085011f5bb040bf46 test1/1178 0
-31a0ae718df395bc131370ce4576fb8ad6a7569b3e2d132c63b850d7991d5f88 test1/1179 0
-286bf8c355d462fd7811296beced6ac30bf457cbce1a196fc53d05d7fde9596a test1/1180 0
-881f6292cb5a6e29c72a4524d71bf5d49f75ff90fa8812105821d720a71c2b5d test1/1181 0
-a16d7f8f848fffbc5de8a916d6379a35db2e5ba81296f8a3ec641e7816514c86 test1/1182 0
-966e4b669a2a1b761a41ec787ead394bfddf6d8e57024cb7c1fb538293f64b3a test1/1183 0
-0309f63632b182d51623905088c020da5296a52ee8f81cd1218204d960f7fdb8 test1/1184 0
-ef96d7460c8ba3178ba55b1a199a45ccf4729ac172f8cabe956ed2e19bd6f8f7 test1/1185 0
-ac300399b42775d56bbb26b5e28cdefa3bc5ac67754afb6dd0bfa5c959203dfa test1/1186 0
-144620c2de89cbb22aaff1c2c2e7aa62eda90c32e50c0aa6a0e293af41ac7bba test1/1187 0
-414a25ca4e9b6996c8168d48f34e39f8cc891297f43b24872e2932188ac24a25 test1/1188 0
-efb14020c94e4bc59a303401ed1928a35db381ea9d429bac5218a7b7da3b48f7 test1/1189 0
-be39846fd644423a64f5c822f0d4f55e125fe8d93e1fd202f7ffd83e3f38ef99 test1/1190 0
-669d0f82df0701cbe9474378dca273ce02c82f48179c86ec0f452dae6f6198de test1/1191 0
-e9d93ab7c4ebe2e246398c4bcb78a913fb9759add79b4e04c484866a384a30db test1/1192 0
-20d6377d2928c56ce356d7e7f28e5f9672c5a8bdb01d17c29e553211fc9b1134 test1/1193 0
-1389cc029dffacf76851f9a11937db4e21261fa3881a0d5c5c2562feeaf416f0 test1/1194 0
-092f78a33e30d85a3acbdb0bccf769d9ec0bf0c4b4921384140e5f620424c86b test1/1195 0
-ba72ba689cccd010e100be69387111f54255864c2752f550b137e6473c98204b test1/1196 0
-245194c70e73a239d9bb6ab7ed2c956cceeb5a6fc353946c461aea9b61f8b06c test1/1197 0
-80b2c2364a683b3dadc85e39405b05d35917544f026f3383671e823708a6714c test1/1198 0
-eff1c7bed4e6ed556095c9171049bc62803f363e21554fef2ad0989adfc96d27 test1/1199 0
-de12f658fdb0cf214aa241a34fde17f9a1a2c2e428e7b26497ed69d4fed552d6 test1/1200 0
-1dcc6c1994f610d2db4a7aa468dfa23c9a5db60680775a57a951c89ed8c4bd9a test1/1201 0
-fbf76fb27fc5e3127e8ffe5bc2329c7b605783e8ef0b60b1892918ec393a932b test1/1202 0
-140101494f011376774826a381ee669fa7273bee69f218d634b900750441c84a test1/1203 0
-fd3782a5060d76cc34c2c799847b3308782b0135ff27d796e8ab62d145c35864 test1/1204 0
-312c3fefc93e62804fbf17f0cde77ca4c2a6e7703d67767c9c74c8a0b67c2ffd test1/1205 0
-c8dc80b5d19370dc0460eebbaccb5f7e75cdd50e1f42a6489bee6f4276d5ff62 test1/1206 0
-7e3ec09e47a320f4c17e10de379255bfce0782dd788f1bed4b36abeef9ac6a45 test1/1207 0
-65d16f05ac77d41b2298e733d759fc21678d8df319b31a2dff129faa93c553b6 test1/1208 0
-5071cc9f22f3b60c4c3ae020021dc1ad07c26593ca48ea915a7fcbb67fa27d51 test1/1209 0
-6f15da36ed4fafcbf6ff95d47a6b14ebd947f9fcaf9bdb32d502db388c2de29c test1/1210 0
-e27a090051c2f30d095a772bbe44e09f4ae96c6de6614ade517b9f76ce7fb2bc test1/1211 0
-c3c9fc4dcc1848b1e860c18343d6cbd1d03d5bad4bee9f580321a907945baf7d test1/1212 0
-bb8fc6d869959cfc53b6808c76312b3cee3d3c66e50ed238515156d06a0c2134 test1/1213 0
-c13df81d0f1fd5c4679842ecf030572df880e961fe7102a58f323e5b1c162d0b test1/1214 0
-7553d55908f9ff460b2acabc54da619d2007dd490abc42f47e8d7f2757646ff4 test1/1215 0
-702e28ddac74bdc7c048dfc620c5e7d7c71bfb23b10bed8cf8d2122517d0b0c3 test1/1216 0
-078401296157da2b10e674cfc0e1f98ba3feaa5e1ba191ae9218b6ee5113b068 test1/1217 0
-944389a6643bc2357cf27ddb883dad678c77476751f18876997ba4b3a4e7d8d1 test1/1218 0
-5545088d2f1d9c5c8ab32793bf2ff148eb967e816384628093271f85e423cb19 test1/1219 0
-d475b39e44d8fe2aed222c2dc20f058849b566892e102e7623eac3dda1492359 test1/1220 0
-dd926c73d76f2143693360abddf82ee5d47abbeaa13bba92870ba84b23ccc106 test1/1221 0
-b9a0105f25a3087bdd4e432b03d3daae6d39c39b2b092756685470a55b89f002 test1/1222 0
-6d3b501dc1f5b6ff5c9786b3f01ad782ef8c3448403e745b380c7ac6170f5c93 test1/1223 0
-0c743b3af8744dd9a524bcc08027593d94e7cbea37fcca01dded10623a2f50e9 test1/1224 0
-a0d58c34e634441df1f1c3552844667ddf2dc76cc3aef8f22ed6aa9c37e3f725 test1/1225 0
-83ad58edaa79c19939a4714980726ceb79d68d9c52d497cca1b597e19b57da93 test1/1226 0
-cfd8ffa0f11e60e7bec0799136faf77741af92b65936f84e9790982b6f29a8e3 test1/1227 0
-f4fc94aa1274184cd70d26418c0d80abc3c6f058e0da5c2a94bb9b58fc59aa27 test1/1228 0
-546fb5e87ab623d4c980ae36e685a5246a57ea1d48c3688e7ea7544f1c562c82 test1/1229 0
-683dda45efc77fc3f9dd70669a4d0adf31d7b4d543d6e236ccdc68568b17b87c test1/1230 0
-e064a4bca34ec02f19724d14107ceecc92c16497600d83a088dd1c5e0e450c96 test1/1231 0
-588666122321c6e4fabd7bca928a77eb38a2771cce0c83b00b578ddd62b23aaf test1/1232 0
-b62be0fafcabb3141ca55cff8fbdb0c75c8819f666caedde14b64b3a7b41a648 test1/1233 0
-f38ad96df4c17d8fb5e79ae99761efc7df6e252ddda06412d4cf84e5fdc1e893 test1/1234 0
-e9819a6d908610c8ac699d31cff53cd42ed8c2a17e5b109b5cf2950146364f51 test1/1235 0
-c51a2b4faef1187152fc0894f667e22be8ee479ac99d0778e704b515b8764c1c test1/1236 0
-12439e607a61e581f571678c0e9f04088083088192f4e703abb22d5308cdf0dd test1/1237 0
-b34bec8123037166930541d5f466df7b6e27e2c6c98ae954e92415626c66389c test1/1238 0
-5d34a476f2ba8b95651aa2c5b713271d213a6016c270f6b65e8f68b2c82bda37 test1/1239 0
-688a4fb38900f3a238a2f3f0be4d972bc0b1126ece302fcc5c2f28455a4d6d9b test1/1240 0
-ca5da3989bcab4db6ce8f1c95cf636d2d8fa5671d31f76eb7f163241f52c142c test1/1241 0
-c14071715cf63947d14eaaa931d6d9c130d83c4ec4d8d65a0223caff562f4db8 test1/1242 0
-819c7d15ffd75c826d095935959b21bcf78354961b0df0225be653f4ff6cf1f4 test1/1243 0
-229e10125f2e6559b9bc93d4f3cd2bc8e4c673bacc63df7a1e2c181db75dd10c test1/1244 0
-2b7bddf44b266e1d6b19c63c14bf629dafc0f2bc1716f76cba5256efbaf69558 test1/1245 0
-d595015cc6a1047122427d3a53167fa6c17a5422a742621e190b2666016782eb test1/1246 0
-bea09fbee51477acdd11b63a65d5e237bb04633b31b25f32867a85fdf4eaef5e test1/1247 0
-e24a01640f219dfe1969588055c756adc775d43b316160c7fe45feb721fda270 test1/1248 0
-4491a2c6ec2f5aca8dd3913a81d3fa2cbe95f358f2df34a16e790d472cc0a254 test1/1249 0
-52de62c21375b4e812479442ef91c17d09f9b59a42aa724ac22a9ec0a1b8c963 test1/1250 0
-be035c09f05b05e3300cfe472832d70e50606797590e872d2a3c251eee7ba6a9 test1/1251 0
-275b91a0e2ec57c88b4b3704596fe0c358557645855caf0825b9e3d853fee8e1 test1/1252 0
-07ba0687ccf118d12f7d68bd152ec1163dc3aa8207cb755bbe98507d931ccfc4 test1/1253 0
-8b708a7450eb884eabcafbf9750e1e79d005288c4344876c2b6f3d2128c959ad test1/1254 0
-aa924a41bcf7b2b17d82e3fb0f22cb7ae949be44141209b52c3e81f0aa70aea4 test1/1255 0
-f63a51d5a3445b0f5cbf287e870bc74b21d05892d972eca80c4f29a840a969b1 test1/1256 0
-43d00c2fbda0d316048e7fa3682263824ebbeb3ea813022e9ba07cf6f6aafada test1/1257 0
-86daf9761622de8e36eb0d09ed57cb0745679e957df5824af251b1ff2c393402 test1/1258 0
-aef60ea51133ddbdff04c724ec6ef55fcee96e8736b6aa664aabfee01a54b3c8 test1/1259 0
-49abf7194fb12bb1e17e8345a26cc8152e93fe8f449324406d7bce02ea21eacd test1/1260 0
-32925f10aa8bd580808534d36fcae9ef260e1c05139826ec1274c44f056a4ea8 test1/1261 0
-13b81e520e987a56ca35f7065af83f7333a33451cf94ab7747bcefb66a065628 test1/1262 0
-264f33fdd8204005ea60887ee7d7ec8218629878d15b9d17ff4960dccfe64168 test1/1263 0
-6441300db19ba7589dc4eb2eedbccd57a7a4bca0784fd010f144c6c6d29aa85a test1/1264 0
-01c5f35db1c9931bfd5c9de66a4098992c0538c56a15783a7c345e5ce6a99df9 test1/1265 0
-f255306eaeaa308d58002150517f13739a3a855b615dfe685ca294a8adb1f6fa test1/1266 0
-dd806b512e1431187c2dc4f5a991b32a51795e3651e2c91246a5ffdb92981a9e test1/1267 0
-8a28958c001c48920259f419b87b6743caf73fe869422b84018a30406d2eab59 test1/1268 0
-e968c31852e8155b0f94b09629cdb295b882f692960664e4ab63ab5433bd01f6 test1/1269 0
-0d7594024b26066ec3555ce89b8bbbe0ecf572a67e40c719d60afef077d44e73 test1/1270 0
-1ed29d030d82a399af3c882367b303e3c8d59ea599a495a27151369880a7cbda test1/1271 0
-7aff1f30885b6312b5aa49f0db1cf5eba8ed8e0a5611c142b4078ca5c0126d13 test1/1272 0
-21be1d718c07e8667b937c4e2b60d3eed7b70aee6d31c2c6c0fd293efc3c20e9 test1/1273 0
-5209200aaf856f333dcd9377540441ddc0f26b246a863d56ac01ee3e6d310575 test1/1274 0
-eb86a13d3aabc8c7a7dfb27fd9d1eca1df6f7f8f8ee1d63cbbd7ee9fe326305a test1/1275 0
-a2db91d4ca9d416df2f96a8c51c9ff969b7644cc5c8451843d8a8865fae227b9 test1/1276 0
-b7c88723adbbdfb07e3aec5513954f92e18ac02596f054fdbee5369517c8969e test1/1277 0
-8fef27f6bd3f70bca924f4492e94ba85f7ffecf2d9433129960564ae6a84e168 test1/1278 0
-3bc98fd29f8b39bcb695595285df47c9a9c3b07efea61d87ff264e80d5cb1c2e test1/1279 0
-3511c7330002a3ef2031c8439686fc616f594c15469415582590cdf6e75f2a6a test1/1280 0
-bf9e7fc1c4102f9b495617250011b607e8acb22cb61aa981152a026d8d8ce114 test1/1281 0
-7936b3f32a4b769e17554ca751f3d8744ea4a96d57ea37660fe8686c4cb1d25e test1/1282 0
-35694961b327eb87eb958ab67137603032b633a8fa0776df343dfa81cd538611 test1/1283 0
-26ee638a967f9563592b8a055b20649665aabdde81ff62ded1eaf7250b764c66 test1/1284 0
-d0000e3ddf04197cd5b3324f05d002198eb62100cb2b0eadd2d20615cbc225ae test1/1285 0
-f7b1459e0b49789743be08057056910e39824966cb912789abcfab35688bb8cf test1/1286 0
-3de1d4ef7a87c2e79a7dc5e10deeed3c807f60812f179dca38955f5977585281 test1/1287 0
-b1b95b4cd7915e17540202ce4fe9d31dd49b9fb156b2277f33b262630bda7a1e test1/1288 0
-1a25600e0ce85db83f4bd416b40ec1f0d9ae89b7dc968fa149e4f436879fd4d7 test1/1289 0
-15177b5a4870e076d79e5fae1b00b2852b5e79509cbc5efd3856d9d368ae5039 test1/1290 0
-6f6a740c5c0e69ba5a8c46685bb7c31133c9d766540fa6c43ee2d1afd868a4ee test1/1291 0
-819912a0380344045aac26c30e4bec24b7a97e28ac90acfa1f42f0344891bb19 test1/1292 0
-33587a7eddda06804dd8b14791ca47f9add580a242f3eef550c95f5b449995eb test1/1293 0
-3949f91975fea3acf8cc4478a86536e28a98427e1ad343558108870e1b34c51f test1/1294 0
-9ad89e4ac046f8fa9efb159ed780f1545f02d4049f747817015f380163a5cf01 test1/1295 0
-212f514435444f4f3caa9b9da46f6beb5f2f45c4f37bbeb3c78b393a5ef57f97 test1/1296 0
-13a260ab81211339de1c35fa20edc905771f93668b636c0b8ad0a2419bf0b65c test1/1297 0
-ce73829e804ef5c80e54e6a646ec11548371bd3e3cead6566a52c748aab90050 test1/1298 0
-ec459c405fe427a9b6b14b9b41947d61bc9109cb5800025d1c94d82b9b379306 test1/1299 0
-8e71d97c2903a622bb613523d99a12d6c3f98e9356f3a632b6ee97dbd7f898fd test1/1300 0
-741a5fb21dfac65c00d77d5f789614fd2c8b9b4f5c004ef3fd431cbf3ce2add9 test1/1301 0
-aff08950faeb1abc747dac1ff3e4ee519aa438f1962590122d8249f744e057a6 test1/1302 0
-557bf8aa121a5aa7cd62ef42df5d757f92329271a2444747e566dedf5bafb41f test1/1303 0
-d32574ece36d199669b069e01a932ea335983c5dcba0e613b29098f8a396681b test1/1304 0
-e83b17d19463a0d59bee2146b4877912dd5dec4aab7027559979548683cb60a8 test1/1305 0
-9d3d077d5eac3930cd62083a1a63468db25bb96748c3926bc8d81b9aef1fe83b test1/1306 0
-4c61d712d0827ccabf61cb8f4f3db3d2ba657a31c9dc5e6a660199bfd3faee6f test1/1307 0
-8cb553f9d84d1105181101eadd56a1f0feec27ef33a10cd7dc82852a2c72efb5 test1/1308 0
-70f5df24ec8120d34a11b7e9d66b5ced78298ab767da9deec9ea6224cd7e2f07 test1/1309 0
-99ccc170473c23c968f031cb630cd57f36823807ef46fd338c19ca785ab0677b test1/1310 0
-1886b5bf375343a92073f0a345e1415851e9e8d8cc43e2ebccdcb0caa7a19892 test1/1311 0
-9526ac73bef9376e5cb566bc02508f67da34342c24d8e75ef1080e009092639f test1/1312 0
-709a7085e3de6e86fb2d0648d56beba1bae715bf4e95e9dc659c8ebcc9e3a4ad test1/1313 0
-f0990b4db699b292e36e390172c9307602f2a49f40ebd695ae6251a58cd91023 test1/1314 0
-bcc2cbfb4e6867f805b79017421bb502ad53e5e9f7b8d0457e2247c7928993f2 test1/1315 0
-3254beee2c782aea5478976750fda914f38402a544c37d3122d460b0cd7c2fc7 test1/1316 0
-5463c52d17da05d80201247921b5cc76b80daef82e1b344125f4ef7add2074dd test1/1317 0
-4d8f49146bfb65b5a7ef465e1b2e15cc419d6aa3266949959a53b5fbcc9c0ec0 test1/1318 0
-bb9440d9b35796c3b63446dd9676a6748d24b9b389782f5b7b477797e684c0d9 test1/1319 0
-b7acec529401ac97b585870e9d22bc023c4aab8ac0ee8c0bd33e3b9901340fe5 test1/1320 0
-b28e995837407eef24051952bda07fd6540f27bdcfb52d865b07fe39809b4286 test1/1321 0
-5c432ddc0dd2bcf0740f9d4feea73e145b81150838fa3230dd0d5536ff9afb90 test1/1322 0
-ee3e2b01635f2f59db91b5ede66909a00c6462a2e85cdc25fa80a6e3301ba6e9 test1/1323 0
-d6cb9e1d4343c3b9566a3f74eee2f421d05460f68e4ac9c9d9bef1dd06da8315 test1/1324 0
-ab3c6d74748ef7e05505c3458b943440307d61e1eb91c49b90466d3ff85e5ef3 test1/1325 0
-30caba90fce994016ad5d0e2100e346bf3c12a901cb9dadb5ef311b05301a25e test1/1326 0
-b97850f985fd5bf09a35c9bc68f93f7e5cda73e366b81407af8bc3e763f145cd test1/1327 0
-68d5462ec3673c423d4e3ad44c2df1c67f5ba283506cd35e0b3545c8811fad80 test1/1328 0
-8ec2ac087d87163f4c9730ef0ddeeca25c2be16e1575949a8943ab0b137cb0a9 test1/1329 0
-8300af681982443516e3c294ff586382dbdc5578209ada6b9a37ae604ee708ff test1/1330 0
-056ff744185c8990d99dceb604f4b7accd74a64ab986608acd0ea51fb07a7ccf test1/1331 0
-7cf0707027b7d32ba745190aac5386b1ece20625a50645044a985403bd3a8757 test1/1332 0
-ad39309f50e7cb5f511d5aeaab67e30904bc65115c77e4edf8fca1b670630c10 test1/1333 0
-0e5e21d08fdcae8548d6406fe8d1674fd3359413818de762b9131abf3e9520d0 test1/1334 0
-39893f5405f8a34f7395dbd70b673514aba535ccba624b48ee9607ba42964723 test1/1335 0
-0ad89e69433bd1434081f578735a00092954f3b4270879fd3d4f6973734d2926 test1/1336 0
-7cbabb6d82eb1fb4a6951790519ba38659bc37658f83c4e8145490fcdd3a52e9 test1/1337 0
-64b1842360401306713d667c8b3ff8156b2b6f581f83e471c2a0931271c3df36 test1/1338 0
-4b89c9d6ab74f56755b10bc241f29a60440bff13b406aebaee52856a64a0513b test1/1339 0
-71102258b7053a2bb1810b65bb2dce97cd90b98a50683bdb17fc031b81f30f1b test1/1340 0
-61b0d6a2ce19754cde973cdd110ffb86242e42bef59889c664cf1677625b1638 test1/1341 0
-4c8e3bfc0171e77f453077b947c118878c2046df22dfecb47d850d3ce9904474 test1/1342 0
-adb5dc2f4517631b1069826ab865327e16de960580a6cfb5d2ef9a9474ed2892 test1/1343 0
-6ddfb0405944666395000991cd5a1ab03e8c69f8affebd144039713324407282 test1/1344 0
-f2df108a7052ba559e5ee33050428b4e2e723777e3a8b78574fbeb8bdda612b1 test1/1345 0
-6a9ad7e52ba6c5ff1022b3b7ae1cf729b8c8f914d46a58b0e83b967db01e7054 test1/1346 0
-f3cd11e7b09b12b758d3c3f1c46292037c107ac2e5f2aada1219a8b28cf9d314 test1/1347 0
-194aebbeaeb01a07fa98fcd234540c013fb5bc7becb64fb480908363a9eb526e test1/1348 0
-c29b92a5adc1f9bac1a65e29020c652a9feade1f6bb1a682db02fa11a73f77a3 test1/1349 0
-d33ca144fcc51ffa50de417916369e63eb24f932799679adf60b91672e269662 test1/1350 0
-41d761aa4973696f285406e97856fad2b17b69ac90ce9f64589afbd1d1c49a44 test1/1351 0
-49eee93696379ba51e3a25028b5738008ff22cf5c9526793687c87f559bdfab0 test1/1352 0
-e671ab56c5fb8dd59e76ee7ffb72bd29e789eb28c229a7bcce94f76a1e9f871d test1/1353 0
-68012450415f9a6e8bb362003cb26ae714e4419c9bf2ff4a9713c72e2b6c72af test1/1354 0
-bd382be24e23fbacd9e5dbff2abf71a02dbf15fe50e8ae5e4705b0f370da1560 test1/1355 0
-8b07997cd3a1a3b1a338665a4f5e9c203152c31e78fead1182e54b9e47721b9d test1/1356 0
-6023e92f4611e210de706b52d70de327199dcefd7b95114ac0f7adefb1c0311d test1/1357 0
-175a67a76902abcaf6b389cfb4e28798c40c03dc039524c74fa96c890006e8e6 test1/1358 0
-53ac1a28c89882654c1678293c88427422b1fa42bb67f0b1682a70646ea673db test1/1359 0
-0093066aed91d1b0375af630a97fd5b2be233c8849a0b45a527f77edc1b60dda test1/1360 0
-bfeabfeb7a32c7ef2750896cdfb29d239bf44bb0698022d16c04a2ee8196d3e6 test1/1361 0
-8ad19a3dae9285fd60fc6dede702183ec31ae2ddce11c31cef5ba88a8356ca88 test1/1362 0
-6bbc3de5dc435f8a98dc81173c0b9844d71487fdcf17b4ae9b2e9b03d454ef6b test1/1363 0
-308ac99fbe409bd07066e483c67af24a5cee534cea6d19cc5de00b49f4f12660 test1/1364 0
-a70683e6120649ffe9e36e7eade004f6e39d508d9d8f96d595a4ddc6df010c66 test1/1365 0
-92340b16ca4a7adb4ea356f617aaa51c5d3ffbb058b273ed3d4848a9f2411431 test1/1366 0
-1c1473cadc97455fb059329019548f64f6a6b45e3f965fb2e80ed6ef51ce5634 test1/1367 0
-72fd7240b4e90c84f7355c8489c7f692ea5cc861248847304c2e8901d863897f test1/1368 0
-a2c25e7dc2e54fc8f0c7831538f2613f24a57ba76b7d74650d699520e27feb0d test1/1369 0
-f188ce344c17109797d50c341322bb57114a60d11571f670a94e9158c6f452ad test1/1370 0
-e9106cf056f0c23d79c7c28c8dd6eefd0095ac279045fce72723109546e008a6 test1/1371 0
-106779ed4353b7588b28d386d25af17743585a1e2bf923dd1472ceab5ed83177 test1/1372 0
-d6e037bf0758ceee14b3c37fb959b359403460ddb1628c15ae4ca3196d03af89 test1/1373 0
-3014497d7f11ba8da65e96a3252d896f951dc2e2a78c1e16a403c25841d5e697 test1/1374 0
-f5af96ad1eac71dfab626d24f7fd22cd6417c3cf1719153da0029ce6da7a3c72 test1/1375 0
-5ea67043f50168ddd4e18d17bd166e39d82b8a7f43a38f615f25e100645c1569 test1/1376 0
-e87f77d49657444971ee0b1cedf13cbb79ce80a46f2f39bfbee8d69236e3f3b8 test1/1377 0
-a4381ccdbd2e5ef4104267a35a8fce05cb31b852e6fa165b78b4d88289324442 test1/1378 0
-991e7d31ce6abbea4af2bffacbef430044fb6a7695f288e8b08a61bdb92ca688 test1/1379 0
-c2640de545855b99f2ee50ca05f009446d877971a2fe7120f3d2f08d93db9b69 test1/1380 0
-2d1c7690eddeb7aa8bbfefe9eeaab26a85336646466b7b1020a396c5ae35f8ad test1/1381 0
-f3b63246422b5593c918b95067bb6a2dd082c7d474b224975fac3c374d02e179 test1/1382 0
-74c99218ac2b6db2885ff6300bbc817b844ccc1a6ba778e3b3ed633198d1c650 test1/1383 0
-e42e43e11a4c8e51b30e9800907e310c809ce171b1f0145c0a0f4dbdc9960700 test1/1384 0
-dadce04e7b7f47a5653550b9b3630abd5807d4e48746cbe3d2c4439ad014b6a1 test1/1385 0
-9beacad5c01b755d1a1f3d4509da9187ba9c42f3c4a917f701a29b4e1a68cb8d test1/1386 0
-4e43fb427a63723167c693fb7bca7cb67fa92f92981382e578ba1e583d52e6bf test1/1387 0
-be874d2f39a5128ca4e8b664cb2139f95205daa2fe858dc6b4e8d15abbbc2e4f test1/1388 0
-bb41fef6a05095fff1f2d494575b4a96d0c9fe69c5776aa1a5bf7d25a1c28404 test1/1389 0
-cfafcecba78aea9bd84d46a3eb11154ba4e06286f1190e872aeee8bd52ca904d test1/1390 0
-a1536cff37fe0305bce9ab70b7146be280dfb09af24555d3697b9ca2bf7bf175 test1/1391 0
-4d0d8fc3a0a6f824efa2ce91648b643332f899923ffc6cbb4c1225cad8bbd2bb test1/1392 0
-60ce8ffe04a3ccb5e23f4ed2e27c098d346eb90a09211c72e52bc23a9be5aee2 test1/1393 0
-9117ed7a3abd75762c92a01bd2e6c1b19973a435704d0438c3c52e80deb8d6a9 test1/1394 0
-a2fe6e26505e3523bdde1f1931a253e1edb6254f7f7fba5e6730ec91b554e920 test1/1395 0
-6cd6f7201d63c267c790df96a60165fc7756619950651294d3dffbafec9a24fe test1/1396 0
-0ce7e82df09956ad07c3636e147a6d2775f1a2630f01866e82bc961a461be89e test1/1397 0
-9986bbef9e4f2768b7fa3028b87d93e2a7111bf96d0c736e178b211fda5d68c8 test1/1398 0
-de6133a79491d7630c45f0d682e2ea85b2630f7c35d1ca85d8c55896543911c4 test1/1399 0
-6c62420136c4c03b090665397d6119890dd23971faeda9848c6622aa62231a2c test1/1400 0
-3fc45f865933e6a4be256992bf92cbaec801b4dcade31a614a4dbef94b3f214c test1/1401 0
-87b12d352c7cbc32c956a6254c3c6a61280e4d6db286088dbf08072f1c5b90ab test1/1402 0
-2c9f8c33f0177afa87ea71caa5f86b3d1f0f2e6e60bb4a16a3c2d97afd638040 test1/1403 0
-ec7dcead057aa19900f85e8dd8e8ec4305d089bfa7c8fe377bd3b4d1ef23279a test1/1404 0
-6b04b2c1ba7cdb7b043e04afd613a37be245d5ef4c2e90da73674c4c95308d2f test1/1405 0
-7c68da7e9ae283c65abd0bae4c90aebd34c3830bf34b8278dcd677824b6c1c67 test1/1406 0
-f52ba7be6ca7c0c6f401a7839b3ec91862f8b9649c96c95c5041563b978ff682 test1/1407 0
-02dd852f6aab102930bc1048628f6dc8214b999e2a9aa60f11240ae067b9f7e8 test1/1408 0
-69c2a39d95bcd3acdfea04381347f3ee5113851297731f859da11de83915f3b6 test1/1409 0
-7050d05826970ca688b1ae43f5398c636c19f7bd4d02a998602f32bc2e57af26 test1/1410 0
-a36745fa64ff56514cec6cf07d46e4de8ba1419288563afa7ac2a90924ab178e test1/1411 0
-f5f13dcef4f99599d3178de37a49bed28551fbbe1f9f60140d292784d9698a40 test1/1412 0
-bdfb31561a448d044b5e94730cec62399a600e8324a844e9b0f6a945f2ad4acb test1/1413 0
-18e1b8bd35403166ca0ba2b1c7c6ffe9b6ac6fb4d15dfa4d6200bc0d6a21d877 test1/1414 0
-acf4216add925cf2986d7333d68ac23c47818550d9b416cfa5947f0933d000e0 test1/1415 0
-7adf5d72833be1d8e0cd31ccfb3835386082a03c881b1212ff0ce765d1f888c0 test1/1416 0
-5fd1ef32b5bba5426c30347c40cc89a2b5ad3c6b28cbef99d7424cee2df156f1 test1/1417 0
-8e69f113d8a7f58a3075ac825eefcc4e84b8837d7d97449d36bed0a3882d4e9e test1/1418 0
-8cda60d4e29a44649b1b0ddbccb5af97d65c6f82db6ae4745e75fbb452004580 test1/1419 0
-ab7737b30ee65b6169b52e7a629deb922cc9593fbaecafcd210bbd408d20b41a test1/1420 0
-281bcfebc5b1055f98fea03905ba5b21b8e9c8b6f50443adc1e2c7ac30f832b4 test1/1421 0
-11555062f14686d17c4d4cb1d290a1700b6863b417722fcdaaa475eceb297e88 test1/1422 0
-1163d22e6b1a6c396dadfbbfdcc5ff50a194a2e6309e59c70e5367597fec8e9a test1/1423 0
-14e7f662b761e16d9d0e0ce306bd3e6b52198382fa7e376ed5f65dcd70eaf165 test1/1424 0
-456c635868a682cc473af5d24d1adc958955efe6b75601abe804f526ab76a425 test1/1425 0
-9af86888e3e5d463d30bbad54f8c2c2e2563ffe8c57a172d19ca6ce81321d587 test1/1426 0
-6eca17e24f9722c1af27c99318623a32678f7db870119a704bd998a6cd4ec0d0 test1/1427 0
-5f0991b5610dbf83796c007c9f866adbfccdeabd92b3b1a7faeb3dcc6dfa3275 test1/1428 0
-b1135318cd357c5b6bdc78dd5c0b0c0589e8e27c9c4522c226a70105d997b8b2 test1/1429 0
-bcb05aaf1236a7178e86425d99c761e04f72c6799067e45d9219150a3c701371 test1/1430 0
-dd02dbd11d589e98d10c87950abc06a918ad3cb6a8356b8672c5002609281b8c test1/1431 0
-e3402cb67955a3078e180269618b405d076a0e118249e30b5ea625133e8987aa test1/1432 0
-90bb60e6e7b741105a948df61bcc5c0fb02aea2e6f7582f55d7908d00af60be5 test1/1433 0
-1e3c676620fcb018825ea20b45399713e75867ac3e50b76c205e222f5a0f58af test1/1434 0
-5aad2fd5755d4e9d694e8ba6363cb43a728061f0b7c0984b6d92c10b9288ce2f test1/1435 0
-c5fc8cd229ffb08539dd3c0a5513da7cf20f60dfe67803eff2ffe9f92014ef0a test1/1436 0
-602a1e09014806ec648846074e85eb21046caa702a63cb9344355c3eff8d543f test1/1437 0
-29ba6a064865cd558c5fc358e4cc3568fa34728e4c881a3cbe935684b61f14ad test1/1438 0
-7b11d27cc2f62ae2c1d7d2de81d30c83f5ebcf3662960ad0917e694aa913b2de test1/1439 0
-01aebe2e8d0b21ce1a9217498cae20171907950f33136eb190872f760d51ceba test1/1440 0
-6ada5f02145ff6c3206e9c03b6afb6d248846956dc64e901fc316cdc49dd6fd3 test1/1441 0
-e023d395c6236a575208f05fc5d64f15014f721c0336b7ec8fe9ab462a544198 test1/1442 0
-0f0ee73cf515ef01b82c516a9ab7b2b6855c16110219924f0209ab9982f57b94 test1/1443 0
-03dfa088535cad316fe1834f6025c832fa26012df8732d6f466009164639c18a test1/1444 0
-2cbd96e243ba787cafc837cc82da90edba34094f881c3319e733508f488f8982 test1/1445 0
-8802cb9daea68309971ebe332cace9f39e25f9a55a5255b18b898b47fe433d07 test1/1446 0
-945787baf3373bde6cdff8136c2aeca9a354d9dbac394a8fdba1cb8123b25230 test1/1447 0
-26c412e9e94a657e8f56cee883ef6ba2c0f758fa9f0420d722b813e6bdd2e6c7 test1/1448 0
-58cce67f37244e11c98ff0fb44541f6a64d5a9cc329e3fef6e33a74f23520c4d test1/1449 0
-b0c936797fef6595f1b9e1261002bfe1cff27d05e4980b5710bf8f942f98bc5f test1/1450 0
-bf26018b664326884499037e7648e82f73c47910d5a18ca1543356dd909b489b test1/1451 0
-9bd1ef3f79eef85f8d99ef9d3c7a00a37d5981c714ab98c27b2eaca087fed3b1 test1/1452 0
-69aefe9c74e69fbdc21c854edb9ebfdaf19caf5833d13119fc4818fd77a7061f test1/1453 0
-3f5a42634eae022b18556d8d3f460e1636894958289b31b62936b6a72b594d97 test1/1454 0
-540ca613781221ee9041dc718e6bdb6f1b60d0b54d49b2a6ae42f72170f7a66a test1/1455 0
-5904508a526963ecce499e1ff137c2bd712bac6b454c70f42c1a2e5c543388e9 test1/1456 0
-ce8b0f3343da4fe445b929a948dfc0fb3df8e48d39a1bb484b0411a8c3e880b8 test1/1457 0
-c977b4429abd029bbba331142742a7cc6d2cbf3451894a106d3ffaaf56e2768d test1/1458 0
-53f15be7430d211fe7f3f35e219541f5442eae4bf67f29c55567787ab7731bbf test1/1459 0
-d35ec9d54e293bd1246d65730b9ba7912ac814f6f77be18346658402696b02c8 test1/1460 0
-9ecbc4dcaf3e077f1228adade47f04e46317e90b6e5610a3722be19d9d85fb02 test1/1461 0
-bdfe5540d8486018cbd35936d9e188da5ff08c0913b11a17844e3679b91a1a4b test1/1462 0
-136d27e959ba011ca211cc679338395c92aecb690a6b386bfe0ee76a1df3d56f test1/1463 0
-bcd33510b4d8996aeb7ffc40d6fdb53faa8be3f708ebfefda748beda34677df5 test1/1464 0
-c90ea4c267313b1c45ad44f5e1f4d80c1d9f2caa0df9fd51579329389b8347d8 test1/1465 0
-a12679792d7874ba3343eb3594b6274d06f696412bc5db50519fd594a1ac1c4c test1/1466 0
-dc5f76273304fef749167910d5cc3f851996b248bb41ecc0a51144ab95f96ffc test1/1467 0
-18ee8397e85336fd8833d7b58e0057034f730d07a8f07121466763f8cb21e105 test1/1468 0
-0f4fad077fb289d91f6ca7cf40421c66d41052007f06936433ce789dd8febb6e test1/1469 0
-ede748b6bc71a179cb235399ecb28f0065bfb3d74b1747776046c1539e9b6896 test1/1470 0
-d4210cd247c548e1efe4f7c70a050788252b9a74c5df3ad1e1ae60f1762f85a6 test1/1471 0
-f501f293cee58ff8d8392051e073b5700b3b7483657aef23f0c75a128868adfb test1/1472 0
-512019960965a1d6b8781af21b30e2d08bcc62d7b12c778c1496f28d4ee3bbb4 test1/1473 0
-b41178ea0333f28c220e0ae7bd85656654369ca8891987efe964902cae0c56e2 test1/1474 0
-d0c93e682226e3ff62ceb52814ea747e27c69e046383883ef2236bf866757528 test1/1475 0
-b0c3eb2625cd4c33ae55f7cccba2d8818f630fe704b2ecdd1e6751920416f380 test1/1476 0
-4541406f43dcec32c94af4591811fecff12d14fb4d1f11f23b6f078c276c8184 test1/1477 0
-71d2bc3d006bb66988cb822ceb146ecd630864f2e4a104f813be64befb69ca2e test1/1478 0
-426fbe4a71894366c45e8a0d106dc0d23ec37a2fa8d1fbcbaa4ebf44651228be test1/1479 0
-8d715d7542bf8cdec807f62ce9010590bf1527d191b2e68f84d6720554e605dc test1/1480 0
-5685e4b3da19781e25383096cf227fddff35e2fec0ff21e5aa2a9491edfa5bac test1/1481 0
-e89274db339230a9e83a3b1464804b04adacf93da07cddc7d15cbab1319981b4 test1/1482 0
-fcc8645e4202824ccaa9c4452d841fe19bdd176922623c5942b9bb32119293bc test1/1483 0
-ca1add897ae84f5c1c9c96cae585abfb96ae2c2d6bd44deb0d6113e964d3d510 test1/1484 0
-998b324d99fa8baa8743b6147cb73aefa609c36d5fea2ba108c61cc368c67242 test1/1485 0
-068001d5b5abe1dd3095cc261a4bb142da32d0f89dca452613b6759738e06e53 test1/1486 0
-779ff849f0fa73f29b59ae3d4f7095fb20c444f0494f7c7b74d687f904239e71 test1/1487 0
-3254278df1a864b0172cb92ef796b9ec2504c620d3679b55ff7bb16222370357 test1/1488 0
-79d13fd8b1032089bb37a26feff44e90295236e3d5d9f71f17b0f01bdc23a286 test1/1489 0
-4aad8ffcfe4a78cb8932708918e2028bd24a97e2b11345283223aa2ca7d52252 test1/1490 0
-2dff6b536d64442fbd51c8edb6854e4f4489adb6349fa28a5c9ba8e84146d2c8 test1/1491 0
-f3bc4a63d7b26e38bb26e08330a34fc765318aece3aa66b8563dffa79d7012c8 test1/1492 0
-9297a2760d83bd155ec4498a91a5cfb40183af6da3573c0e90eae4c602798749 test1/1493 0
-ea7f9b94714989834afdd1e0285bdb288742f3fe77be41d4ec5b30fc7a2644ae test1/1494 0
-7408f2022dd786223ef678db65f601420ce3604ee85d1cd5d6e19d4b20cdb0b3 test1/1495 0
-3e72ee614c4e708b398b0978e579b0f004c5f9fa2cc0bbd1d4208309903051a4 test1/1496 0
-d9eddf3875132d44232b02dca8e28784ca5519ff905ae128c7ddced99c7149d4 test1/1497 0
-8987907ce2a65f0d0345eee296f85ba48323e22abf8cb058d3bf7d0f5dfb0c84 test1/1498 0
-38d8b6281b191c84ac063f158ef089d5e480f78bcde4c36813b69bf6c5a1400d test1/1499 0
-622d04dea46480235c6acdb092b36d7c6d9451e3f6c3f7d5499b0b96894e36f0 test1/1500 0
-b6916996619db88b6964e673b02678db3c81485eea01d8e22636beb748bf0e4c test1/1501 0
-99ce920a47d5d774f0d2f6dad6d6fe515f17e2defdb510096a6d69cefb3e893a test1/1502 0
-19128ef11fa071eeb9155cbc7a14a3833090c9f56400d3375311602c749e034c test1/1503 0
-6117e3c9f44bf163381f8b6ff9a13b08302c68356d0005bdc62cb9de7c677d84 test1/1504 0
-d6937a5a6955e2be139e3c91da6e5463e10d817dd0a6ec72572b832fed96f69c test1/1505 0
-8705f93bb4b18c544607db6adc4c1d877025d067c8684a7e69cec8454a3b429f test1/1506 0
-1f3f5f326c8750735be0404945105f8b2334504365c4ce6712b08ce401a7f552 test1/1507 0
-f0312b47b0bb570c92d1ac22065feb50d809c78c576a94277b2647bae204ea6b test1/1508 0
-4a843257b4b50c97b71b6441834dc74ddf682992e828e12ba7907277ba1ebb56 test1/1509 0
-f9eedf69ea3256fe997c849865b3859edf8e9ead555e1933592b7d1cec4ba157 test1/1510 0
-3a579e75e30369510e7a584f9ff3c3ccffd2f30572d51589da8b4a7656a35f39 test1/1511 0
-9dc71b6f25b5e9c0fdb50bf347e3b3a5568ea978e4640db5dbdac9e36e601ca0 test1/1512 0
-5d9b2b5187f69072156a6cd7d85ce98c08c8aa75c96a703bac9e9d8e6562bb38 test1/1513 0
-a5888fde3138669220989506478faef1cf6ea53c68168d3917c361e96025bc02 test1/1514 0
-0c0d0438a75bb8a2f5fbae588b8f40ad79ddf10c25022c781518d932990d73f2 test1/1515 0
-d955b60d4a7cf354f0f4b3be71ab99745a8fd860d974c107c5b64ab7126567c9 test1/1516 0
-7fb3e5a656e8f7c24dc0dc8a647733abf84fe4d05ec47af88c53c3b9881c7b72 test1/1517 0
-4db702d52f0bc8c9375d65fa4fb92967599a2d1802918e3734cdaeb39dee90c4 test1/1518 0
-487c9309054167ca555e86b4d99b3ecd957abcca1237c6b52f025af2e7b649fd test1/1519 0
-8f820d7239a2678f699ae80882d61a625592dd6e9a069630d10ebf1ad4ebe9bb test1/1520 0
-3742024fe987034e575ba6fd901e4593c47958adda4f890269c9be186e645039 test1/1521 0
-0ba75a5ecf53e5a76df39c262f6ff5cff1578e7f07b64d9ee17bce9fdced6fcd test1/1522 0
-a321514668a64e300a2f032b29419fb8828d1bbc1ae6d0a63fd60701db507210 test1/1523 0
-b3d5a724537b05863e6502e2a29276222d4e8427357797acbbf25abebfbcc2e7 test1/1524 0
-41af5d7071977cce39ce05982589fdcb3398d4ffee9d224ec4133525feed6d2d test1/1525 0
-83e809c5cada104d0d65ba99593c1fd901081a514705fb4a2699f7428854e2c8 test1/1526 0
-151da1f3c6df6064839628bcdc5c90b1d47c052acd053eb8e22b4dc4ff671da0 test1/1527 0
-3e754e752a9fdf09af4fd6bc4296a9ff5b0ff02db4eb70646f3098d851d072f9 test1/1528 0
-b81a7b3fc16f2498e55b071c54813b0988613b386fd2c5e0ed6d5120c5ca4282 test1/1529 0
-fa3217072903a1b676e14625323a9c1f9a1f25843e31eefda19712bd13b898a5 test1/1530 0
-df87a7bb0943efbb8d46608fb45df542e0e8eba5edd65890beae9a55868bec72 test1/1531 0
-a273a4762df8a5900ca0d8484fafe4413b74c93435fe0acb32a7fa00cc68ff69 test1/1532 0
-c9315a336b279b679381c7869e71790c381f9c0eb45f796e1556b2b3225390c5 test1/1533 0
-7ce72fec86f49add434fc4da99dc73b12155ce81fbfdebfd1f6c3ed106291476 test1/1534 0
-3960eec027b59c540c6a505a76b8862f8586b133adb3b5c433a28a68f1ba6fdd test1/1535 0
-2f1b5d4ff84879613d92987b3a6b121d580f6863dd7a6a61a66ac6bb5ad0720f test1/1536 0
-2330a91b486fc9ff0f4ce2e8d9aa2b470754770284a057c12aa26d1fe716bfa0 test1/1537 0
-13c0e2e5b2fb74249d1b38daf9bc378b712c3190cd282e0849090239ed064ea7 test1/1538 0
-aa75d9393b86d99fb220750a8be3db214cc82be5688a7f5e38bdf0ba5d7936c8 test1/1539 0
-f08d212266799a07ef75795c85c2aed8d924d9b2828f11de52c1893512be343e test1/1540 0
-d99031e73d061597e0cf27c124ec8770fd8a414b34a81e18148df55faf1e5d60 test1/1541 0
-d5dad494fdfd09a5f48d7bf4bcead28eb237c1495d092b7f52b6bbfeebe6bc46 test1/1542 0
-17b0f14ae1df38c6fc76bd126d87f069da406055d418a71ecfdb3ea8442cadc0 test1/1543 0
-d15a95df1a1e435a8c448cae1b860226acda569d6f1e175eb6dbc135d5ae5938 test1/1544 0
-c1c26aacf8171a1463ad8bee6baa83ba062348345975ee9d879ef972c6918b37 test1/1545 0
-e42ceee121a24e851781f725bbf79f76869e41fbd14802321f6ff5cb1412b85a test1/1546 0
-1d825ab0076f6fa7bc330b4b899fc68d2e73741ee9e2e77604e1cbdf6295a978 test1/1547 0
-0365f5177dc3a6490f68d54c5c539cb3c22fcdda877440d1873792e88fcb81af test1/1548 0
-3f6409c40511e85ee2935a11d1f71bccab1ca0fa0a8d5152a483a2c4f2107034 test1/1549 0
-f1c12ba82b06505d1120be9cdf155ff9ac70ecac1e01fd9d8e875da78217c6ed test1/1550 0
-bfac55b229abf7f8c3704d0f9cd1e6db8477759d11aec2640733085779c1cb0b test1/1551 0
-e38f48c77d3f127469d9c3ba12598d6b6035eb44d15e09bafb0087dc223581e3 test1/1552 0
-7fef6f591338f0863ff9aa144c111ecebc1aec14c62eafe565441500dfbe0f6c test1/1553 0
-2ccb661b4ca94e0d730666e1b3c665d1e30de540bc67a0acf1ffda2e5389b8ec test1/1554 0
-670b3d12eb3d64452ba03250203fe6d1c0ed47db71492927832ef51a10839fd9 test1/1555 0
-262ef2248abf34936584d28d59230481eced03b06a54529d87e73519644cb6f8 test1/1556 0
-f0d4610cfa5d7eeb2b97a76232f6f65c85eb2804fa7797a90b535938268db996 test1/1557 0
-37a04f525cce7f0e5b6cf3ca7bfde05c1754e7da04c7dad8e7a9e446ba608d70 test1/1558 0
-bcb0601c9d3fdcfb6e83817d4fb96caf39d56bb5fce3f8e4601a10460ecfca6b test1/1559 0
-2b82b2647ce221f245f04cba9d0fa81794b3cae833f2970807fe2a49516895e6 test1/1560 0
-3567d1f098dccfd99dfa0470caf6dadc87865681db963dbffc2d8a8b47857345 test1/1561 0
-67de9c534dbce8d922b47036a55e21e583d93ef8fdeac010d22ad7b92a3ee1f8 test1/1562 0
-98ce671d260f0a993b9f5a34ffcf9e9aa563c5e3236a3fcac541efcea725306a test1/1563 0
-e30734c45e19015bbc76eb05fbc784c28e70e5c763c114f86f732625de8ca90a test1/1564 0
-239c94bf80a5d7cb3c8b3badeb488448477eea1cc039e1045ba3ce7172198dde test1/1565 0
-3e88718913c11211a2b79b98f3c948654b9be50394d56a1e7cbace3d3f07d568 test1/1566 0
-d54de1201519096cf0ee87efdf5c37fb896ded693a26daf6106f8d6c33cfc6df test1/1567 0
-87eb0e8854b675e928fa2e65952178ab6c6304d5c5d2a896d04b1464b9c94f8e test1/1568 0
-b352d21e43432048bbf52418aa9b795126eacacfb69edbffa653e71388cbd2cf test1/1569 0
-57cf870cebe8b22cd55371df0b189b5acfcadcb9a7bee839fcb589f6e5e01a39 test1/1570 0
-33fc7ef6f6d0e39cfd682f0929e08d6d8d4f9d01979476e4f9cd64abdcbc9706 test1/1571 0
-d99e1ed759b87ba326cc70630fc6b8d81fbf3a11cc2c7dd972df70bb91523b96 test1/1572 0
-1cc408c278f36468c3bc4b73aac60ea59254a3f27ff0c610ca1a7926473b6542 test1/1573 0
-921b5e3781b14b07dde258622f59c879b8687612c5029597feb5d9a265a7c096 test1/1574 0
-089b33d82e7448eaa2218448cfa6e32c54c5727dfc3affd944db938e93de6535 test1/1575 0
-ce014f585fac0edbf2473476fea36f1259b9b9b7308d2de814bb8d868266c301 test1/1576 0
-4683555d152eaddfaa95a9917e9c3f29d93cca7cc87f128132e8d138df505363 test1/1577 0
-ac9cb65718a14f1806a9e89574da850717bf9354c22788fa8f9562e42590386d test1/1578 0
-4d88f597c18cc13212f8ff74ccfa9ed04888909a1bf8d44c3d2924d3b3e89450 test1/1579 0
-e4da7de075068266d4625545f4798399c7cbc1b0ea16be79123f55b48972f8a4 test1/1580 0
-abedb0e5d3f2425d06fe883bb3a6fcbba0a41badc8b3b73e08658f1456706ff1 test1/1581 0
-9e92011e6c6b89a06d8da766b41aa5fac4a1219dcc19f917927fad99087e3c25 test1/1582 0
-565cfa6b844ad1e16917b3c24b1ab255f7038b902339d51c1e7bfe4c31603d27 test1/1583 0
-01cc5d2637e09d20ec8abe3658d74464a6b8a98ca89c4ebc02ffb3d1c4e734e7 test1/1584 0
-e5f8c8586aed7f19457688cd3c1e857e32c804f756f3821efe24883aa4086f0c test1/1585 0
-1449524ba745cc0a358f5075f0ef786142014782da597ff369f75a837f8ec8c7 test1/1586 0
-65a72fb3b572d849610c377eaccba6b57669c11b0d48de1ca5201c8723b1eb64 test1/1587 0
-ddfadf4156834973d5d2f8825e8e7f210e4579d77e07bcd5c77c40bfaa91b30a test1/1588 0
-b97a5eb597a3a77070ebe68cc89929776e1c21e64b13271f0029230f9d402b4b test1/1589 0
-98e536d112c7a98e17df7d66add0c0caf7bd5786835d6cb8ab2a9c02426f0817 test1/1590 0
-2e12a3cf000ed60473fe5fc0ffadaeb25a8b0443a3e4f5056f7cba38985288b6 test1/1591 0
-b8361ba1758fe5c0141fe957e1ca58e8585a2072c481ac6b36135085bcc1d6cb test1/1592 0
-a7cd0d4e946049e31c4624769414355c56da8a17a06e3535c0e876fc8c6d4b0f test1/1593 0
-985c55c37d001814b2bb127517e7d6c1781e46949eaa400c9dd7dcdb8c9ba97c test1/1594 0
-0c32fbfbd275c4d53c2bf269cf384cd628d8f6b395ebcb7b5f21485f1c1256cc test1/1595 0
-60241efee7b1e161f77b92e4079918b717b9f3b861184f9b4db64fe8201cf2d1 test1/1596 0
-68c384541151eb2c5463024001e7c5a4150bbf8281463993d6b426bc4927b2ed test1/1597 0
-66ab3f7c7de7b3042a935a4012b2e30ba9b4f90a7f49d318a340d1c0e71f12cc test1/1598 0
-abfd29f98d43115d15cd16b97307a15bd3bdf91c14e7e20caa412f3502e1756f test1/1599 0
-cb6c334375353db5dc403920ce2cdc644e74f373f6611b6afe8ffda247ff512c test1/1600 0
-db6a09e441da8d0527cc7001ebbb6148c74a130b2c5b5067341628d5e8c3d19d test1/1601 0
-abe4809a942979de7c80665f2c27744a9ee5da289d4dcc83db5bf09fa9a72fb3 test1/1602 0
-139e43bca5adc6b10bd75da693e9d42a99ee7dda63ee62719a67b7d3a9b09619 test1/1603 0
-5ff14439693077d11f32fc71499f8d8d19385d4f528861fe0bf1451e0f081494 test1/1604 0
-23770185f1d9e78e5b093eca40b3310b179013405902c680566e09d3bbc0e120 test1/1605 0
-5208ce48ba4fc76076ec100924581c502a29e33fa4dc9888bcb650e98c32874c test1/1606 0
-4d95762c10dac5cd0bba04f60c29467c6537b8bdabe1f76fc5e4559e3d2ae871 test1/1607 0
-bacfaa625296d491c23d9c8a3fba049e66e37c9e4370d3dff92909febbd30b42 test1/1608 0
-7a1d92b0499e128702ae7ded8a3bfa1e46ce5560c76eb49b365c4ce0d9525469 test1/1609 0
-fe0d257d493f0145b8963c2388855bdad766f91c6713a3e0c823da1b4b6dcfc2 test1/1610 0
-e72915a10e19487b42100e6a4ae770d64f2e67d1f4686bd47a94d0a2e9e7343b test1/1611 0
-76baa965d5a74d0c40c17141b51afd611b4b52855c89cf16f2e6fba2185a6f0b test1/1612 0
-943170d550884c313f1b6ecbfda16cd8fc9c3d5f922008a570291bd20e9ffa99 test1/1613 0
-583b89a1443a52f305d848b6ee57516fd973e8008af9c12c6bcc83c1891cb254 test1/1614 0
-3c929a0dbcab401bf26fe5fc7a85e07fef2ea92766c871ebe7fe87ed6ac21014 test1/1615 0
-0d09c844dbfa9a924e73537857c55316cc895a7b56c802354e7f6fc6263e1047 test1/1616 0
-7427f013c6ecdcc21a99b3df6d05fd42cab31f58363f95a2c1d7019f33d9ae4b test1/1617 0
-daacf0ae0a11455d5b500a8dc323bed6077a41359f37ce9482635b7ff5fb74b1 test1/1618 0
-b46880a4e54e2ec226ba93d7939d4672d90f8e951d60c460531e9ec7b830fffc test1/1619 0
-9a241937f120aa0d86e3e57e0d13ed4843e5d71c654244dd9ab43d6401819e77 test1/1620 0
-4d484ef31ae81169f04f1ce3000a0bb41a466d2e1094161883b0197c9bfc451b test1/1621 0
-0caf7d71319169eb4512fbdb72aa4dda028ae993d5e15717c421d1670160c885 test1/1622 0
-bd059632f7c8a52421aafa5cc772d1016a9f15ab58b6e4dae74ee0ac823cdccb test1/1623 0
-aa085285d0175fdbd166ccca03cc521a461a8e7e874439807c6356c2a13d1c96 test1/1624 0
-60c1d4d107c394c0ed652e741006fdcc8c43f7a22a2270f07cb81530422490f1 test1/1625 0
-d3c8368bbbdc42ffc8c6b67af12a81742daac1f7fe0bb2aac1937abfe802c0e6 test1/1626 0
-1d091cb3e929a37c454c3c2fa30302494991a9742de246dffa28a88dc3d61872 test1/1627 0
-b9abe62b0fd7418062f33ab48474cf70e6d5ee3d6b802c667678e60afec40910 test1/1628 0
-f60a419d63609953817f04a1e341599a1fd0d57576d48c032666e94871813eb5 test1/1629 0
-4af7b57669a832258f95a3ce2630d9c3cbec6a81c2328f80a8a48706c5824aa7 test1/1630 0
-4ea6c5fa2fdd7f1137c08b58b7b09dabafeaf36fad3f94237f5701c98fe45afc test1/1631 0
-636340964e7628d98c0105be9d3c4f08ec91ffedd6b67cdbde37e7178631ab26 test1/1632 0
-55e0f2c76306e08e3b70ded4686a35b3106527048bf2b6a71caeb7c5cd1a290b test1/1633 0
-ee1b5554916c39a7c9b16eb3438cac900d5b262bb11684bc3d794a2bf3273f45 test1/1634 0
-1eb18e8c7b26def3b2233c855f47ba89af6c4c736e80d3a045bb5d12be637fcd test1/1635 0
-1bfdc94863922c2345d91bba937d9506c2127fa776334a2a28115663d8c275fd test1/1636 0
-4aa478fd19ecee0716b9578592f3bb02d99e3c272081822c0f7368abe89ad8d1 test1/1637 0
-09c80c85aeb1b342d6cbaf8645ede00980ff97f8d09680d9e661b6770abeedea test1/1638 0
-7a3c149b5c467301020167168487afd799754530ede3a850f838ea8bd00f984e test1/1639 0
-d2060bfcbb126518d3cf842b28ca10b920dec0cac8c70140cced2248882eff8e test1/1640 0
-220ba2786abcd5c9633dbbd6cea54507b026b5142ee05d4bcb41809651a253ef test1/1641 0
-a1b6f6eaa75470b6b0e93db86f3c1df05a427f8cd98875578bdf27981a01b9bb test1/1642 0
-9686fd7b39082053552437e75b04feea8481c8567eeb8cbff85fdd1260acb9e5 test1/1643 0
-e386ffad5dc8a3d2c1c54841bee4f37d968b70adc5877b74b6cfe4a288873558 test1/1644 0
-a00d0c647f8fbfaf2d919a04854e1e7c250012d813fb9aa99a69027db16b0402 test1/1645 0
-1f187111097c6ee6effce1a61c75a9d656005746a450205951e7086736f8cd33 test1/1646 0
-393511d7d8840b1336e07edf8d74d900d606de93dbb7c946900b0db163feb917 test1/1647 0
-21ad507d0e7f8614aaac9dba5d0ff5b650dd08da345521d31204a9702eefb60d test1/1648 0
-a681f85f9f6758f82670400c558044a156d75e2336d66a691930ef0204b9e6de test1/1649 0
-67fd0e554cd7b717203a5cfd6d942d1247572e5d36a47aed639da3fe00d457eb test1/1650 0
-7414e43d10091795b7f573bd64ebc31c268f1df25f5b5bdeccfccfef2f2064a4 test1/1651 0
-1c114ecb52f88e25c5b58e835740f9bcb18b9fa27c3afa26887060264ff700b7 test1/1652 0
-e5168f6f327d905af63d7968d8d66803a0029a01e6eab161fba79d1faeb0919a test1/1653 0
-b90a9e1cd677f7317f063bbb2136a3d2300b7aa5f7ac7cb7d50a019256b4eca6 test1/1654 0
-a7cd4622a6fc324304588c3f38de5628ddda0d6d8ff1b1bacb82a808b3235b5e test1/1655 0
-4df7027d186cec3b4469c972fad005cddb1cae8a48da9cc5816dd3787636f864 test1/1656 0
-f2119867cae8a680050ce2d3ea66be5bdc565509bcb69640d5f6dc1750fb3224 test1/1657 0
-e2009f34b8ba9f8e18a08d8ccb5c6ff82d8fa72132ef4b2e2ac74807664577a2 test1/1658 0
-eb9e052ddaa32b548225752604dd4ed28ed0dd1949a00502a75a048661f285c0 test1/1659 0
-e044dc8224c211965e4ccee35cdbcb4b098c52e935281787fc8a287417134d5f test1/1660 0
-716d23c1ef01f8dc121fd4ae213b17d832c58b2e5c7d014ec05a7d4bb6f5fb9c test1/1661 0
-dc3f0a3247a8f7f072f5f6c2da9ad3a23b85d8aa876dd5d39255c750420dcd53 test1/1662 0
-0788f094ba19974f14de020962763d3b4ddb00cac8d67d11efe65603771fdc81 test1/1663 0
-41318fddb38506e023e3aec80f3d1b8309109d567d6bef5f213f221c270c8cdf test1/1664 0
-fe9dc317eab105b49e3e35a462244f89be18b5df2b887380cc9faa2b6883f5a7 test1/1665 0
-59fff1d1d25c18bcfd86e3bf5d641d9e4cddce495fe64cc57ed34f6144bd75e7 test1/1666 0
-5fd188bbbc3e33285e3b70858fa83ba68bf40d7e5261609c3735edd1832aa181 test1/1667 0
-880e24b2efe1457b49b956181920429c8bc17e6005cf557bf7902e20610d1ba5 test1/1668 0
-85a4cc35a3403d10d7944b4d6b1a41b2c69cf9ba8372fca5f69529ad2332480b test1/1669 0
-5dcd7a2019d2f450ec384c5b4d8bf5e1bc1a1531c2c5d42703f616604895fbf3 test1/1670 0
-ba8992bf8eeb4ad718e1ed4012860e1a18b74cf0942765e6f5b195e27355ad71 test1/1671 0
-451404f62cdcca2b972fd0f8bc37a209630d87b59b2f396b6bc0f9ea5816d51a test1/1672 0
-03e8ac391b30829384f385ada51b419211d6af89ee447f60549268a67377d4c4 test1/1673 0
-9168f335093dbc43e1bef65660cd29ea2c8cea4504cd8bbbf655e83e0f0cfa67 test1/1674 0
-0aae4343b0470dcda72804c8c1a4cf03d088e9d208588e2e8bcf1521f287bfa8 test1/1675 0
-a35b00daedf7ef0921b2ac908b211952c6ed6d0336b2184bc852fffea9b9e9da test1/1676 0
-accba70f1ff5d5d8d822e1a067d500c4a6816522e521dabf7c75d40d157b22ff test1/1677 0
-37a2f8b6ee33ef6062e11dae1cf7173d7faabbde3c5a0904b3ef71eec0a1643f test1/1678 0
-61448e86a4874966daf148bb0424e1b0b591fa2f38c581ca59a66c00de1c37b0 test1/1679 0
-11cfac369d72a0861050feeb62971149e431bb0f5e026defc5d64c88780db9ab test1/1680 0
-ca4a5d44b14825f4a51249c582077ee9052388b4d6e22ab5039191428931d116 test1/1681 0
-a823ee57fedc8855076d689fd8fce81b76884077c178de696957cb17d0179545 test1/1682 0
-c186939576a5d7871e906f9bd3193e11dab9c8773f4b72a8c2fbbca541679906 test1/1683 0
-7bf0744216b397c41ac277bafd34f1675427b20620b2de41f58ffc6cb27acf91 test1/1684 0
-1731b4888e3f8b0eac7291fdf2a323c567a8a41b902716202cf2c68351bae9ab test1/1685 0
-04996bb33fc49434059f40148028562823c9b12a5ecb1d2870cf211c554d5c38 test1/1686 0
-018278082d5770fa8cb06d8d02e7d5c4592e2b0903847e48e608e108e093d4ce test1/1687 0
-f3ee30ed1cfd382d20c5838c8fcbe263a5a32cdc960a1df78935245c9462a18a test1/1688 0
-127e6f23f3bdda60663738cc837d0f139933df1aa064952047ab600ec0f6a590 test1/1689 0
-873aca8aef9008461a7e509c7e4e959a3aa4deca0b1c039c74e46923d8761f9a test1/1690 0
-a9a267d145154dd66169076ec00a0bd978282e1820d3762e9e21dae00a275266 test1/1691 0
-385c64f232508ac3d182f0cdce610a124882077110088b9a22cb57c8487b7e82 test1/1692 0
-1b8be89cec76a755499c6e6194e0e2a72743d6828aa9b83fce4b654c37bf8b34 test1/1693 0
-73cefaa54ed9b82ebb1af904188d8461192e77a6243f7de65bbdc8bf3d723143 test1/1694 0
-9b3bd592d8dc287386c7cead6ec5a44719e5ec2ac5a593f41ad0735180cdffd1 test1/1695 0
-a8b1911f0e6ade4f2fc8f72d1f58c8b1dfbd7cd394ccc2fc154305411da8e9f3 test1/1696 0
-c637110da897c99313d0aab5f594a971f1629ece787820ee5f844569700c0d78 test1/1697 0
-3deadf5794e1ce5feaabeb8786dd38dad97d8f310dacfc4a1707b4c6df0b5f4c test1/1698 0
-168be638f278e612b1641da1a60d003a0aa1e6b006788e7fb2637456ccc3ce7c test1/1699 0
-2a60398078d442f6f0c08693a0cae0cf67c5690eb00af7d2aa4f11bfe6b4fe08 test1/1700 0
-18ae59b8487a0f2e5afee021a3394c4774c26745dccad9d050b732e26c041321 test1/1701 0
-8da942053e5ad23998c5c2d3bbc7511463f95095389176364c45c270651d1294 test1/1702 0
-a7c81ead490352a452c8fd849d1da1b293a746917dac77be54dc59bd674d0239 test1/1703 0
-f7e3fdba21909dc6c56b31c0d841f2f8b9aa57f569aead804e6f423a836a25d8 test1/1704 0
-006dbd18f0e432b64a486ee967925921febb2684368977e88edb77a0dc661218 test1/1705 0
-caf8c56a986242d715c71acb7f94c619a20aa2775d615e4c047b41d2e6460225 test1/1706 0
-1978426deebb038a4fdf0b6f8610e8af83ba4dde1fc781d0414a82e3aead2c9e test1/1707 0
-5b0daac1505d152cdb619e6abc2eacc048fd360684f356bb3ce46957d977cd25 test1/1708 0
-baaff8a7c3413e4dacc1f77b03646d768db3a1862932a8fa42f8ea2c38c551f8 test1/1709 0
-7fdd9a859eed901d8da350dce65845d5c235f64f6319cfae5c6121e92d2d4712 test1/1710 0
-af6f4c51d508652ee3f4e08be00aa2eb7a9ebe8873ec19b0888ef4c2830a110f test1/1711 0
-63da1db07035436ff1b12ade6bc69ce46ac49b23d7baa3c43304738e0d3a2e50 test1/1712 0
-85481baf544dfd97ea46d5210461e4ee0d9f0f5127537414f805e261c694e114 test1/1713 0
-cd3d13c9978756f52df6a57572f6f8bcaac61d376e41e933106ae7131507c9a9 test1/1714 0
-5adb8b07609d86744744ce919e3cc921df60f927645bb80d3fa3f3510c8eaaf7 test1/1715 0
-c4030c3ad50c958673905dbc647dbc85b609baa3df1888932b2b5956cb952b9e test1/1716 0
-3b3c53afe6b48044e60c7cd3e3560d8a10e6ff226e35fb9689bf74324f8f351c test1/1717 0
-b2867ede2bbbdc6be1eb06383a2db4f3bdd1b98fce7ecf7f1bc3500d3da36b54 test1/1718 0
-dbb7b94a73350c7affcf92c18c5299702d66401f00d0f3d52f28fe2915020473 test1/1719 0
-c7b46cc14547cf6be18328ff6bb955002cc8db7643adec6c66be061f12d97d44 test1/1720 0
-ea680e66f1bba697c4c9476d6041d5b59c3620ff0164d633fa47041ff953e556 test1/1721 0
-dceb25c04188a219bd59972c014838e6af7415a07ce2b6bc133b8944d379a62a test1/1722 0
-b596d01e0f011211e1631b3a5de96207256a8c4931d925d9ecc791e5775b7e85 test1/1723 0
-6d14f3bec907dfd3886cf3c7fa851b27cb92631731de3fc8c7654aa506508871 test1/1724 0
-2b3627a9fc869194be5ebbea6db7261c629332dd8779b4008e4a406a1e16842e test1/1725 0
-312fc04b033591dfca786f3e1b62463526cf67c8e3efc2423ad296721e7ffc2e test1/1726 0
-959c63ceacba1404642012dcd0bb7cbabce62d7cabfcaa8a271dfe7e6e265989 test1/1727 0
-7d1bb6abc515e0eb38b83395096a1dac0af28837967972cbc6f6df254b2c0874 test1/1728 0
-d492340ced2347a4b12f3e4afdcd88d2e66d78a0c71e45671175520e9dfae8a0 test1/1729 0
-3e4cbfdd8bc1bc43c0dc5cef12a773269e444072d8679651ff9b64e0c3e85217 test1/1730 0
-b0ea0d9290b0c8b8466f9b4bf1210d33a49be45b445a460b95faff77113c23a7 test1/1731 0
-5faf5c834d3a6ca5596e25a6156a3fc926a2ee79737918eabdc977d3573b4746 test1/1732 0
-1bd7a630be88e3fa42783cd1344af2f40db71e842cbb91f4ffbe43469a0c171d test1/1733 0
-400ddf0d1fcd437adbd29085044eebd8847d99ac1b1cd695eef2cda27b547137 test1/1734 0
-c847194f99f72a110b0d633025f626c5a7d9f3a00b2816a4e8ff49a556dbed87 test1/1735 0
-53dd844dad16122cb7aaafb0299d5ff943cbfbe80aa06e8dcfcd428b360c0dc1 test1/1736 0
-798af40fa0c811cab170117ebd50a9fc1ad0e528e6b1e67a66532492ef55a672 test1/1737 0
-0ef37dad64d0e30fd25f93653facab686f239faa798dbe63cd475a509c866c38 test1/1738 0
-9295c9faf3ad34a72a7a88999bdce1d83f538cc9b811632d95b1292e3b6bb547 test1/1739 0
-0f7e9c3b90452b1e85980a99466e012cfb9b469b216ee14acbe70c8e5a6a0c57 test1/1740 0
-5a9f8b30848b383bedd34c78494ce596bcf5d8384eaff2cfa236561b767a8df7 test1/1741 0
-ee318ab99c5e3ff2b359e4bca6039c9de6a48a688f1deb7d03e2d111422e82eb test1/1742 0
-5e02b251e1b0a7ca16745403af3184827ee5bb94b84fa8e8e6e1eda86feae89d test1/1743 0
-f710c8ba2a0ba1df936739031d3bd56044650a38318d857466be6d8255689372 test1/1744 0
-e0b35dfafedc4b4b6154dc850a11f2d835c4ab0c6f219c40ea6d35e1646341cb test1/1745 0
-e31a0743f81f5e664eba9be6e4015835686d8d012255dcf0692da51216aed6cc test1/1746 0
-5b7e0a1aabe91c4ac04e0353cbdab97361fb781e00d214c3d33cec99cb115cca test1/1747 0
-2817345a1b76d018b70f4a50dfe04f81a5a9594b12d571103fba0dc7160fad21 test1/1748 0
-7c8f1954402c1c2566149d1437583fe6750419bd157e2d4d94474f8823f9b907 test1/1749 0
-7e15e6f1b9b5ec5e05718f164e3bc799de6c0fe7975455245f5990886b4c58d9 test1/1750 0
-6498ce26a2820f4a5a16f8671550e4c0ba24329e35491ebcb8249fad418bc142 test1/1751 0
-d3345aa3700a8f19bfdf2093ac7edf8a26e64e20e66c82c92e4773cb75bd93c4 test1/1752 0
-55c3bd2e34e377b82719f77d6590bab35f8dcab59258dc038063eef4a35f219e test1/1753 0
-0a2b691a9459037454c9a50994a7031228ad81ba1dd67c6faf173d653a4d8dcc test1/1754 0
-c92e343c7dfde6d07109ecc8d43a3a245373902857756374f4aecf47478a1ac0 test1/1755 0
-acf5a0c838139f59abfc4e1b8327fe157dc6b805bd8f28af78d851214d9e7c87 test1/1756 0
-9499e9426bf6f23b47f87068e551e849776e58e398fa124817483098b5662004 test1/1757 0
-a0744d4a796bca19122484198e72ca90254556d485245a1b13cf037c8aaec73f test1/1758 0
-e2cc38d737018c2fdadc9e5f1436021ae03333a299e97b8e708cd9eee7c890a5 test1/1759 0
-c148412b5e2129d6a98e3ea6ca21f971ae69aa794ac64f9ab7883137c72cdd7b test1/1760 0
-40688b17747c3ecaa1a6d67aad36d11f9e4f534688085a93a18fd71649523ddc test1/1761 0
-dc915254fdf38899ee0fb0cd98b5b3f3c04e028aa353d0361ebc37ff235bc11d test1/1762 0
-011cc313966aa3ee60d00150dd7702749ac3df68c43d26088be4ca7b7e4441c5 test1/1763 0
-e3351966454bf531c421cf211e5e626938573ab8a8b3a164ce9a6cdd667c7e91 test1/1764 0
-8df331abb372357fd9f5d4dc8bea40deb931011d03ee611d2227ff3835269160 test1/1765 0
-0a405ba13b814e4d8362c0469a5885c97d51ecdf7fad04164d359a588cdf21f4 test1/1766 0
-8e472a1b76de2cd3ef899686457adca273ff3a80baac18dade5f23e04463a83e test1/1767 0
-fdabdc853017e55cad4154eeec883f3bfe98cc288169a5be76aaaf96bd812126 test1/1768 0
-9fdd8dde2a1e22b0de6a75cade85dafab0392c93d7db28846c3ccb6e5c5c9e65 test1/1769 0
-46a9b70512333fd332bb8f694abe9ae8f5824d950dfcbc89e1e426092ec54757 test1/1770 0
-7c0ccf0f2e15c1b743350a22c9ddaf53efdcadd84ef1ab99cddf745330ad9acb test1/1771 0
-1fa704c2e6c41073d9cba33d3ade412f0c2319ef3a2e7ef1a9e6fa09108bbc3e test1/1772 0
-8490b5657c7c4ac962d56ba153eba1d55d289b2cf3443a556b7dad10a1f668f5 test1/1773 0
-eaa9ebd6c151f6960882e46b5022bb9644b066462a4c5217d369f24ed5ecd1d7 test1/1774 0
-db62dfc4d4148da854c892ee5294d88801551ecfa48eebe57ee72acdc696a69e test1/1775 0
-915bd981091d14f6af045a25550dfd4543f1e681dcc23dd4bbe82d48b1b2b541 test1/1776 0
-d386a99ee8866ef2088e463e4c39ccf8a798e8babff5456ff235bbd7fdc5df25 test1/1777 0
-6bdf32d512b5d905dfed4cd7fe90965c0bcd2bb1d582142a11c30ac2b040613d test1/1778 0
-f91a848a596d4e8d5c870c4c883c2c9ac8b8f44e202f16068ad42c864290e7e2 test1/1779 0
-107b537e2ddb997ee856fd848a6f40e85e7f8ade6ee185a22a5874d8021c288f test1/1780 0
-0ad8cf10347fe4e336a9a7d3615c61e274147623119e86e89bf35bc226247591 test1/1781 0
-c6b05fcdaf2a08d9a613c1945ad999961803941b0303f69dbdd194b28e3f48da test1/1782 0
-5ff5c64d2e7838975a6286b6661fca10c9e7be3e57ade2f4092a2aff06e9bbb4 test1/1783 0
-e7b092cc69ff886211be2f7c4e74b187d01fd4adec83f9badeee4b1316d7e5ca test1/1784 0
-3ae26e5a5274d913dcfaf4a501058e77040cbc1dbb91f3a88e3a4ea8ccc01f08 test1/1785 0
-0c805732d438defa2cd9450487e9c50281ac2f9d9e7b51606db6640e55f21586 test1/1786 0
-4fdac23245a70b3ffdfe5c3254e0a494915477b4a186b46eef8bac0c00d19f84 test1/1787 0
-7f971ce928efe54a13d8ae989eaeb089ee98d737049c03919788aa37abd11220 test1/1788 0
-3d49026cb395d3e212da704baa47f57c2d3ffd0e3dad681ea4e8d4170bf31b37 test1/1789 0
-848c1b89ffb894221ae27d2cc9d9ccab0a418ebf0ce19692b1ffd2b51d01f43c test1/1790 0
-ee9182d28ea4424939b52ede15bb15f189bd5ae9b5792423e9be917adfe9070b test1/1791 0
-770181dfd5e63fde6c2b1a4ee98a08825d13db36048972fb2741b16a5a2c9e45 test1/1792 0
-ca6cdcb34ed014a86d93d707470121a2dd89a348da166286f23533d838cf2a63 test1/1793 0
-406055ca35b41dc31bdd17129590fd7dd370b9cc106a43e5828da55d79dbac92 test1/1794 0
-e1e9be25543cbcd3ddaa5f16024feff1bf09c0a823ca60a9eefb76421088b511 test1/1795 0
-0b0de5dca7f0b0016e80a79206d2622a78b310b03f4e64bcf1376c2967a38776 test1/1796 0
-9c6fee8c8653dd42830075910b9d4289d488c00358e58de3c6f04ccd171d18a2 test1/1797 0
-5fb7ac3cc64385b9cd6fa602062fed79af7e3c2f5ba3e74b1b8712772e6e0e6c test1/1798 0
-e6f5e22747d409930d1818e31642ca6773d7452c82f6f47823101649fe30a712 test1/1799 0
-d922438b5adeab789caca2b5858a2a797a0deb3573075ec943f8938f3cd6c002 test1/1800 0
-11762fd5f2ee2558079b46914a8e873b9945189f231a56ad747962000dcdb225 test1/1801 0
-ea280696340f302c56ed9702d1595b8eda863c44a5c8ef46604e5daffb3d0ace test1/1802 0
-c7d85965d50fc7a1d013ad351e6a33a73bbeaec66ee2fcd69cd2d521162fe970 test1/1803 0
-6a50b51f186fcae16cc6a336bd8c9b95bdf2f8e1b05b1d65ea70f1316ae620ab test1/1804 0
-73249c56b803ac0976662ca8d7ab828239b561d4ecb2a5a941565f4b0177ab84 test1/1805 0
-b3bcc0f9244cb9ba882607494907f7e7fbb2f8820a0a25503af28ae1c2d4cfde test1/1806 0
-ffd626b4cc58acce777b3b128cda304c56beb90ab69aa85d60f0e03ff44f85a5 test1/1807 0
-b864668455a5fc33bf2e6e4743fa6b3e9867674e5a7486fb96ae2696f9538cd4 test1/1808 0
-860769a0f2fd42825f22f199d2a8617473e940bbb489b11623438e425e8fbf4e test1/1809 0
-90d6659643be3242b3e7a88d546e68ebf2630d23cbcaf43910e01c23a83e0946 test1/1810 0
-70ff59f4186660718adf4a471fdcab5d5fe5e3e0d618220d9b5a999b8018d4e8 test1/1811 0
-a3537162218c1b8efc217fd5edd570711e826216b74b9b458907c5d3bd33bfaa test1/1812 0
-316b6ae00b1dc0af2a92c35c518b1ec0d32f34dff0091c3c6aaafdc89339bdad test1/1813 0
-cf03248b382f0ac64aac5e2bb2e32a2c2cbee18460372ad36e19709e4fae4681 test1/1814 0
-98c589a919f685d8f4829d2af75bdf61fd2c8e6cb92dcd3e0ea852b56c2da2c2 test1/1815 0
-32e85fb867d4c641d97c28c84785a07f6216891225883eeec892885064add33e test1/1816 0
-e1aea112346004842a81bb282b82ed4609225a3492999282e137f4025d8d8a6c test1/1817 0
-0b029db449c09099929b361704e3ac53de0adaba2d20085f1fca97061b6f1f95 test1/1818 0
-c840d188705e90fdabe018c1fa4ca079ba8daea34e9853597180540811f76151 test1/1819 0
-ab82be415f13f9f388b0ec4307427ab70bb413e9e798e431203eadfaa6287220 test1/1820 0
-6710b4839844ba927cfee7f7ec896f5027e88bb605377d56aa941ced244ef67f test1/1821 0
-6a2a9a1f777bb194171a1de84d7fdb2573df85b1a3b58de03c8970b70042c660 test1/1822 0
-ba9f33e682ae2e7ac497151a473090b6f8a66eaa22e92efe6a627ed638ba6cc3 test1/1823 0
-95b01ff0affec4f4632c96677287e1bd86a20e7555c35ece1cdcc21df5664cbb test1/1824 0
-b0f76fbfc7bdd50cc7ffb3c477f13e24edaf5177b5549946d1bc048e3cccc213 test1/1825 0
-c0489af5afb94e1207a866e6c5592808711f384b70fbe6338b3a8edf53c19c74 test1/1826 0
-085f7b773659955705e7936f445ad5b123d6c0d07c96dee83184cd4027c641c1 test1/1827 0
-9e863a0f8617f99d6df1701bd96348bbf57d12b6d2f254c02b307ff149330dc1 test1/1828 0
-6963cc4657aa6b62de097e43fbc8f0f98c0af8a8ef4c2e01580e565bcedb97dc test1/1829 0
-a3339af0285ae0c1648479498a2e6785cc6aee69a912aa38ec48a2df3305d062 test1/1830 0
-ed6c90dac7eb6aac30014bf2d11aa7e1e2ea51f9bff3d8227a9c9a4d3855cd7b test1/1831 0
-2439628ff13fc41f0b21973baaba3c92f84cafa64868400420a98939d670aa13 test1/1832 0
-9a2e1c84c8a4b036367fca42b87c23ed9ac269c3cc69d231a1f66112836e5765 test1/1833 0
-67fa1576105cb6728c2fb66b07a7522392708ef662ac50ebb4d9e8ae3dd7ab85 test1/1834 0
-633fa5fec0b6c448a6f72d0b0f8017a5b5940b808067dd8acf4c2fd78205de03 test1/1835 0
-cf0a58d71bef9551e9841f1caa6d4ee8d7eda7acb76851fb7f9d6aedb771f6cb test1/1836 0
-5e5509cfdae6752bb6e7ebff75f51c4f90746e7b4256d831bd2c548dfa380ed1 test1/1837 0
-392fd1f84e3641b377a53c0db7c5f797c721614f9d297f26104f9a08570c67f0 test1/1838 0
-c80eed196a253b6ffcd4117c9c79b0d571081f4855a7d102b888ccb5335f2183 test1/1839 0
-a4fbddf46d24a23104593111ed47b0512332deb5e6b4f36a69f5af94d3bb14a2 test1/1840 0
-30104508b7e6464ff626e31394a8e5d56f99f600f3376ae7148b400ffcf70960 test1/1841 0
-f918e27b858d87811094672f7ccf365e72052d345326f3358c7dd4b956f59b38 test1/1842 0
-02fff5b78e6c0a178077741a7a111e8af49f582eb50c37e3915ac7978d60041d test1/1843 0
-60a070b92783c4f1091f14db86ce51da318a79a6fe30469983729b646d469487 test1/1844 0
-3f5e1c65b247ce172cba3c924ee878cd2f7b2831d25f05daab4a8e6eef9bef8d test1/1845 0
-a5d066e10fab2b9d6091750c9dccea2d86a0fc4f055ecff5dac6be143335c56c test1/1846 0
-e3e042421c99ac8fae1ae3c79f5d17565f143279f896aafe0800700741aa2b17 test1/1847 0
-df997cbf56be3d0c0d53a2e547b7e5b05fd71e01867695f987c38b17c3cb9927 test1/1848 0
-ff9613d278bcce680d6da0d9cd87c5f1f7f38c7f4666aa616e2bd4a65ff99c39 test1/1849 0
-10d9f19d1b67d52b2fe1a35ad05d195dd2d62c4343bf2d2c70f0b7acfe7f532b test1/1850 0
-e815c1fe8252767af9ac8e48e3ae4016908f16c4cbc669266e449450941f30aa test1/1851 0
-ca48f4388f5f300fdfd42b35453ad87b6347f2a85a881c33d07b106605516b8e test1/1852 0
-95ed75df3e2bc0405231d1b84371170a1c2b43dc8294ab1ace74c4a7bf4bf357 test1/1853 0
-0900b8acb7c8ce4662bf51bba4d03b49df8b97e42ebcb65cf46100e0bda4782a test1/1854 0
-4c6113aa2cb5a6a7adc5b9150411f880521fa304ed16c88f2c97faac7be2c72f test1/1855 0
-0df2d101648e585876d447dc81bfb6d02672eae18bbcb394308fa831e863120a test1/1856 0
-a7760b7181cfd85bd55b77906abbdeec53849230b23b528f5a982a892e59df07 test1/1857 0
-400e4a3cea49cc89b72a2ef3b470ee607d4b149f31cd368eef3bf1eab0813167 test1/1858 0
-566ed1d095dc23008849fa93fbd5cbaea69946b708f18d50981d6497d8737591 test1/1859 0
-e71329e2d418ab6551fec562bcfba2bdf4e8e22c4dbb701d7e9168a0d52e071d test1/1860 0
-be36ffce5f0670ac24319fa3add05e47e00c3dc9ef93373d89850241aafaab21 test1/1861 0
-3e6ba1cbf9ab12b33121ca72cbd1e07528550394793b44a3a2ced458f1c95f10 test1/1862 0
-39d192884aa159a9c0aa400d89c51b0ae1c2bb53f83a7685ff96665fdf91083f test1/1863 0
-c36e4485648860f8b31d8c861901777cbb3e36e255b4814a652e5cbf755403b0 test1/1864 0
-36292819d91aa93ea92bd1b957772fc53bbbb620249e2e1eba2e591d5245014f test1/1865 0
-5c47414c698e16ff2baef28fb115ab819438a47e5bfaca284bcdc1c54a8b2641 test1/1866 0
-4770fe870ff9893b78f0e4db0fe937cf3800152708371fc4dd7b7ab575645b63 test1/1867 0
-3d7399c06f611d3ff6fd49f8dbb9da600ffa249ebe6423389b331ab9438b275a test1/1868 0
-908d863a3650e2580f98a625f7281d8767cd3b24bee7e7b71ad372dc8cf42301 test1/1869 0
-ad5a12001662eda98c6eb02792a393fea12829b9851f67a5f3b630e06f33a52a test1/1870 0
-cdabe686334c5a332b69bf281494f75d7ea1ce3c21804edb0b30b2b6e86d378b test1/1871 0
-807b74519a0bfe60614a477b93516e8f7db723fbe6377481f2d10d746bac23c7 test1/1872 0
-8b38195087326c8aa3a259249683f0aabccf769e0971d8af4575c2599e2bd924 test1/1873 0
-7271d4b9c9e47337315fd46c24b14418b0ae615d01e13a7d0cbafac365045100 test1/1874 0
-6f73c55a0f601f9495cb09b3b9fdc23176aefbea07ebf41d47fb848cf7a293da test1/1875 0
-af24b6f2e09951d00b3f212e81352ee8035e40634dccf080c5fd9858a181b482 test1/1876 0
-8f7fe7d7154a0ee526636bb27c69d60fc18d79e5d0b27ba00c74ddd6868afb86 test1/1877 0
-88e9c1bfc6e9cb228a7cda4e4f44e9a240f743afabe5489bfe34061d4ce7690a test1/1878 0
-2153f7d554ded0028063992dc62c5f10b63916cba1b421a5938c1a0997bc15d1 test1/1879 0
-4d0615556a29086c77c36fc8271f1e7778f5a3fd65c35790ebc3245998dc4e8e test1/1880 0
-93c5d5fc7bda4d7b11edb52380df7c328b388ac208b29cf8a61c9282093b7ac8 test1/1881 0
-8dfbb4610825bd84309f83aeb81d8c159843c5d100a79ae336c370761c31eda5 test1/1882 0
-7efcc45344734b78c1060a8fddb55ed63601ec782798e134d64bb36b9606a2ef test1/1883 0
-6c66448384f1af5daca44d19d5d330f200ec907cf4a2cbe1eb1392351a264558 test1/1884 0
-91d22848dcc40f12b2fbb15f60ab61e243f9bc8f7d68d9a698d39c240d855f0d test1/1885 0
-82a9439ad7fb158041acabd81c90b005404863f4d9ffe41a6d73e47a74d413b2 test1/1886 0
-7745fa52555d2879848b239e5b3abbd5df4c231507e45ba6a5d23d971285e232 test1/1887 0
-5cb19c71e7b69a4c486485c845f81cbe023a5fc21d48e675db739490c4096c78 test1/1888 0
-b031ef79c9102012f6d9feae9ab9715bd09debd1b3a04e8a3daed96d9fe716e7 test1/1889 0
-b59df949fabd329d638a4168ce8595140202c012dfaf2e862f478eb955e57cb1 test1/1890 0
-c69a39fcef3eb421a4028bfae7e7ce11756faf03d8cb97e0382e1fec0d16b4ed test1/1891 0
-55b4aa58006a47f9e2069e29f75c6458b01cad651c066edb419bd884120fbf97 test1/1892 0
-2f655d0e8030dc7077e4f34e7b8f8a23257ddda919efaff1d3a176f1f7c5ba7a test1/1893 0
-c78b2317981511bb3ea1d3eeff48871c358d869ed13a916ab90ca0260e415891 test1/1894 0
-2c1906380980df071bd06e7330ecaec55389fa528bbe2487a0b601712f737545 test1/1895 0
-1de685bb5a12aebf9c9cf79198a6c534ef9ea26ed464828e5622215f83a7520e test1/1896 0
-a848d2806882a7dcec34a213b8d195090009006ab39af1d73c153eed8c6ada2c test1/1897 0
-115f3efb9913e9538e20d2b36d6aed0588787cd2d0dd678cc0ab4213d3834d5f test1/1898 0
-caa58407d52ae83ab52c72b50946f804aed504088d96b36bf8a33bae6d1d5cfb test1/1899 0
-b95b795c4cac492542e16f2da12abaf9f5ac3b99535037a71897ccc6c03a5d5c test1/1900 0
-c49b870d8d55096b08483be6cae1f22ab06a8ad93f8824bd110470d49546eb99 test1/1901 0
-13b80a7439d6c482f38350ffe541e31271ae1db7c71dba0592aebe102986ffe4 test1/1902 0
-819c4ed5083bdf390894d44e368da36d26b1f305b71a6798651c21cda80afb00 test1/1903 0
-a6f60c79053b14aaf6c24e7c3c1d4571a8b99e4f7a40f5d874889851ddf9de0b test1/1904 0
-6994f1eb45af8e1afabc1c627db9d42d8ad1e002559c4305b47cc08aa9c32679 test1/1905 0
-76f783f59b951e642287c02b52aaf005e28ab05a5fd1082d192195a3c94d35b9 test1/1906 0
-0297019dbfd5d7ad1ee286b0dc5fdea19bd61210962527e0ab5d4ac59667d3f0 test1/1907 0
-513dac8e5fb5fdeed7a4e43b72d67ce0e9b9445f25f61e0d32bd8e56b137784d test1/1908 0
-f5fa5219b3ae1df5c196e25d00145e5dffc789f59c615960f38045641b920c8c test1/1909 0
-2305bdefb0e7ff37df7086d34401952186ce0404bb294b28cf00981806a0045e test1/1910 0
-9dcf6129032d5485ec277a710edde4ae374bd2be871d46d13a80a4ca9a878630 test1/1911 0
-569f85e0a7be04b7fb6d6fb5fe88c3e1b90d90fc16c0c0afc6d70e62dcd1eca0 test1/1912 0
-4a77599d5933f7fcc54fc36e8caac7228672d369552600a7268f6f44e7aabe5c test1/1913 0
-f7df9c2a03ee2ea5e78278453bbd2fc8f8bb388d482733baf6f62267f38c2440 test1/1914 0
-05bc3c621a2188ae0f57996511d338f6919c8e6375f4950dd1e5300b64bcb773 test1/1915 0
-49bba5a373bb5ff17455067e6260cdd6820734e9d0dd7a81e4c5406445af6ad7 test1/1916 0
-3f0a485789e8e65ff537e80d36fd010d0b7f532d8fc3dc56536fc4bd249c609a test1/1917 0
-8b97d47d3067893f2209850d89a60efc1793aaf6b63091553ab79c41ca1fcea2 test1/1918 0
-d220251c702d159a46132fa41c86e4197dc929066d309aff3316eef432fcf8c3 test1/1919 0
-84f30b76b6cdabbf45227c07f939a75070dabda421f2baa886e791592f201777 test1/1920 0
-f97cfc1435760cb2611f880d87b271106f419da0fc0b47d0dfd5872bb4dd2d7c test1/1921 0
-13df1eb6a712131a4ddfc7af37283cd007dfa75238e4c6875e7a567d5853ca9e test1/1922 0
-71c30b8c88b83b47918ea56ab9130e82acde49975046a424df7e994fcfcc1845 test1/1923 0
-a1bd9d56eee1f8d0b95897887131d5f54f6e903fcce3c6364caeb5bfe9a43b38 test1/1924 0
-01cfc16b4a04351460899ead11f869735271a2d4a7b4c85a298874820da17e17 test1/1925 0
-0e086756472db45a9c106422aa04cd893c85119d0f01128122a68c349aceb395 test1/1926 0
-5e07a20ac2ec1ca5d50fa2cb6d9abd015099bf4d211c495c048262f6c6b19600 test1/1927 0
-3858d01d6cbe033b6c6de39852c86c5bccbe87153c089487b9fd999cd2c3230e test1/1928 0
-bbf3bf192445e84e8a6a5c1d91f8904bac08b538a90e6ec7b85f6bb1065378f2 test1/1929 0
-d72f0249c28363f15cbdb10beba4a4a377d91e930a94f44c322cc45f3c854c2c test1/1930 0
-d08c30ee6b2f02801bef86105827ece7f521a1d49418568cb30e81ae8970cfee test1/1931 0
-c7be71fb15d6711cf8e8f0f1dbdd32e5941376a9fbc06882da6b7ec40df33d4b test1/1932 0
-d933c3ac6ad8db8fef31ff7b90fb140fa8a950f3df9c7d9c7d2717f72cf029fa test1/1933 0
-ef91320d95a5644658a24303bd57d711139c9433a565cb6c5da8055dd8971fc4 test1/1934 0
-680175f24597a27d756db751172ae7daf69a4fb8d7f1f118fcfda0c393c669a3 test1/1935 0
-753835c6a59d416bbf3664d66217cd175e2fdb0901a92289993bb429b1b02e78 test1/1936 0
-c03b01b7bb189726a304901b0c9c86027dbcdc3aad5104934edc22868c3d5343 test1/1937 0
-803a419c881708dce55bc4bd31d9e6f480a94f5f9eebed08d9c793ba7837a03f test1/1938 0
-b166405c2d3d69820c7fcf1d34fb59b371dba78599552a7d9985e1a5705b35f1 test1/1939 0
-a161fbb87410ed647555b7ac47049165b89d41d1479751af8b8f8be0f583fb23 test1/1940 0
-87f7498c84b51aad72f237b95cb0e9bd49f0b983250e1121614d20ba531e8b5b test1/1941 0
-0d1b972a0c9a66d641e020f1551f57be91afa9c811a15244efeaaca268dde0be test1/1942 0
-a55ade630ee6c2c592a8f4c3f38b0b0abfc657b12e4d9a99af8a0e38990824dd test1/1943 0
-cd292ce487ef5829569e7f71aaded18e332dd7de06099a68e9b41ab9ef5caa2d test1/1944 0
-0b43e52771a6b84ee22aad948644d7f7838c4c6aa0521046058b59185d773f99 test1/1945 0
-bbd90b1028ec6c8c6cd1ceb0e3e75ed921a1bf84c971b7f889734cc9e5af210c test1/1946 0
-38d22451c228e223d25a700e94730d93854cd0d95395d040ab1028caf9c3ed2c test1/1947 0
-71f2ad1d07f111602f72284138fbc841da243b92975e6ece0cbe999a40e6d825 test1/1948 0
-7a3daee1064f8b8fc8a6126914be7975bcddbb09753d61cfe41649fea7bf2b47 test1/1949 0
-c5c21423cbb894f7e5f572ad4827fae968b541d4712c47d6ff84acb6458caf8b test1/1950 0
-0aa4b5b23d25d1b21afa3f185fa73f52ce79e71c916d9200b62be2433cf926a8 test1/1951 0
-1f053fcc43f4fe514a5db03c9a821a9fe4a6e004299f4b8f3ca605520a52df40 test1/1952 0
-84454f0ed2e6b49604aaeb145b4068d33183e27c2fb8463be9871b11f8060a30 test1/1953 0
-2071b54900c0098b88e1b20568e4b52208314da841f50fdf26b8eafcf501301b test1/1954 0
-86f65d76cb3a393f2d1f4361034d11a5cbd202a56688b73616458b9c9670747a test1/1955 0
-7c995e508648936db3acec21af13b4f716413f7aa8bfe21ecb7123e2f4132f58 test1/1956 0
-37dfd08c3f35816064408b05159fa9e8bd2aa5fb4030ae86eb5f7a068872a35e test1/1957 0
-98ee2d54a4f369d82ad1555eb029ce96ce4628243d18546346533d4a55e1ab06 test1/1958 0
-a6f484740fff25b1e7c1220e9240b72c0968db66af8b63a1fdd47dd36d92b94a test1/1959 0
-fa7434563798c59b5bddfe7f8375a030bcb30e447c25a7ba63000980af22f7cf test1/1960 0
-5fad70246ec35f9adc246a84c90ccc8fe468b3c490ca9ca847019e7a853cac7a test1/1961 0
-cd52e4492653813feaa68704c058513e433e8aa957d49e0f933822627ad36c81 test1/1962 0
-4f3fb8097dcbd5bc614dabe0aa1169b1943a6274a8daf8a9a62c657b64b5c003 test1/1963 0
-d627eb06b1fc4a8007081fb06fa329223b02ebf05270cb576c1b32616aa455af test1/1964 0
-c0fb48a0340b89315e8f52265d10a072fb5f8e5886e4346ffe31699e6f9f3d5e test1/1965 0
-4f47d5a31ae6c2da29d3d69cfe1ce061da7434e6e69d0a350b598093a05b6265 test1/1966 0
-2b1a6164deefc223b3c1cbef79245ddf81d9d73b19c871f45f8605cbba8fa707 test1/1967 0
-398f13325f1abaef5e2bea70583724316e0342d829b8028c51f9d925bbf814a7 test1/1968 0
-012f7a3338301a4c32ba16a56122a4a7d9473ea6214937dae39022892908d053 test1/1969 0
-124566776a2ee2484789f619fc17ecf630d19eec412f393307779092ce726f76 test1/1970 0
-0918825cc50466f4572dae1919a092492e99f1b846473ebce4df892d6da2031e test1/1971 0
-8e524a089dc087fdd5d0d28ff5115a203c53d7623d1c50075d766a815e51d1c1 test1/1972 0
-e859cf693cd7bc3229adf026f429ee1e170f3d73034f0ad6eae8d51ca678236f test1/1973 0
-32ac3db65f54bff58c481b27beabf7f74385013fd8c7081894ec67c71d7d626c test1/1974 0
-8b85d0cdddf593a32dd7d442bce7ddd1c2774b60b8d76da915f3ae4dd1d76653 test1/1975 0
-f40a6c8d3a77053a96497c48ab643bdbdcb53fd86da7e13ceb8d0826fd7fd2e5 test1/1976 0
-25e29e6c780033dc8953dd27700fe7bbfaf60bb688367452408dacb0ad6c477c test1/1977 0
-5cd3e31ab534200aeab66d599bc5cf71950495ff742047d8e3012d5df6f919dc test1/1978 0
-ab05427353806c3ab929b9572574bb73cd9ba774d8ee80e2c31992cb435c89b3 test1/1979 0
-037727960fde144246c9f40ab20aa9cf677d10bd04ce643b68e6ca01c10a998c test1/1980 0
-23b7b646e41d7aeb0b909ae5d438d28edcc0d05b21b143b6cb43f5bab19e4961 test1/1981 0
-a969dcd2139397ee8946f3ed00b8a5ba7e9aa3b60725e599a6b8938c4a9394af test1/1982 0
-f345f0417cb8b7bf2b120d4b3a8231d92b637f90e846170271af705a9593c4cb test1/1983 0
-1254a67e10fa8aa5eeb3b0f1e973e320edf9d30e63315c53326ed28cd6610e4f test1/1984 0
-0d48c13ec2a2070084408bc2fdfd1e2a920a11d273a08bda48d74c1d124c40ba test1/1985 0
-9366a05f5e05aa80dd2a78f4a3a1a7df1982a00580fbb8893d783251facac8c0 test1/1986 0
-fd5f0184e0792d74b72e079275c9cba4f4881ef7ae8b17ed08460888cedf8c1c test1/1987 0
-c5f161361d01553dbd23b4f49426b4d5ba4aee47ece4bfb4645760d5af07b86b test1/1988 0
-e4596e54bf858024186a5dd383f3e4eb4920f770157908b5a3a1627299bbc2a2 test1/1989 0
-6608587dd6bf3ad7d6bd9fece08ac4be72ab8a863f4d165c4bfe4c09f4f36e08 test1/1990 0
-9f0363de671184a46a1d9bdfcc04e447c67697f8f366eda50259524abe6888d5 test1/1991 0
-aeb1cb4d0d8c8b9a063f40d10a013833881df671a4d2d3839ec072efa7b75510 test1/1992 0
-b37257bedfb10384baa661a4f126f256de5e366c2bd84787b987b9cee2a23985 test1/1993 0
-3788f5a13703a76d52337ffd75022146ad294859ecc88352ad7695d06dae0027 test1/1994 0
-08c3a981d432519786101dda8f7df65591c456eb8f7fc8636b3039186635b4d0 test1/1995 0
-a4f84f443fb3e0336b4b7e96084acde330cfa4ecd33834bfbd7205d04bfbae33 test1/1996 0
-290b5d500c91f9f489f0662a4bdbd387e9cd3c338216726a8284017f706ebe36 test1/1997 0
-d02337d3b1b3cd36fdf63914fb427a7d91ea94b68e7aee42a156170afa45b8ed test1/1998 0
-aae69e8788220e992e1cdd13a72862472ead396cddbb18fee49b22517d4c163c test1/1999 0
-f2fc5089c757507d650546f117eedb612d2408e633d434825ff74a95a0cafbcc test1/2000 0
-a57ea3973b67d08670859ae529f590fd99513dacdf34ed86590ebd7ae7e8a4be test1/2001 0
-fc06ba818dbe3a5061983e6e66a418895ee4cd206c85735adf27fb01128fe5cd test1/2002 0
-e0684cce45e93b0e7e36bfe060bd01c054b8b5be12337363d3090a1a9565014d test1/2003 0
-724555b3893127728677d2e1753c426bc547ed774df9a68a69417477fdf9a291 test1/2004 0
-465956043c792faa0d21677d70f3a4e04862f591bc0afd1a0742b93a4c527ef3 test1/2005 0
-415d75d051741b6e032323903fd45539d4ee4321dc6c79d7b62fa434e3d5ffba test1/2006 0
-dbdfa1c846ebc8c3e5bd3aaffd963140f4b192d19d287032dc79c003ef91e591 test1/2007 0
-978e1cb47429e8a245c8204d3da98b3ee76200331d23b6b04caeabee37e916c8 test1/2008 0
-b02e7dd1d6f5d4c406f4f87c9a995cfd14779c31c9b197303b003cfbd7bdae77 test1/2009 0
-987af0c9e135933eefd5e10725ea630d3d4aab181b1b97499077a34723fe1e40 test1/2010 0
-99deba53e323a3e4643aeee95870e2da3aeca8b89837aab514f138f0fd4ff08a test1/2011 0
-5116ee74929926814f398120b493a8f69bc351e18bfae4871bad4ec3bca65d32 test1/2012 0
-9f8b98c468f1e957caebe2806fb35f24d0a01988045ad024600b0b77fd535a31 test1/2013 0
-da99fbbd6ff521089e44eb76f1b99b3808306aacbe07653ad44a88a894cf90f0 test1/2014 0
-02560213f5240778ec277aab22bac23752e2aa242060e3192da0ec7b141e63d8 test1/2015 0
-772949abfec305bbc3290549b98358d3c34ed529d993801512977dbf74e2a67d test1/2016 0
-8c3c21d95deb4afdad151804d5eb1d06455ad51aa633b8857c80fecd8a4bbae7 test1/2017 0
-25bda60c9ccbd06a89356d53557508012ae0d96ac19662e62efa55342a110371 test1/2018 0
-2149544454de08bcd62d9a12b1575d39eb1cee1599c0e6943acdb64f07edfee0 test1/2019 0
-9753e14b414ac1976cbbcadd7dbacd77c9da56695456e48471741a4f67b3c1f8 test1/2020 0
-27dc711615c46afee606b5861996703ad082d22882a22537a6db8f8073e9eec5 test1/2021 0
-3baf6e83bbbab8d125ecc79b3460ddf8cb33e8589d32ea37267e50a295e65106 test1/2022 0
-aee2f214346f89433c759fae8d1fdc67c861d931c1a708bb579800986dcb6970 test1/2023 0
-8e54a04f35a410dd214003330f74df5e95281c636f555c1463d4e22b28f11bec test1/2024 0
-9201b18ce1ee4b323687103736632d422e1254375711c3f0e0389d30c17a866d test1/2025 0
-51cf056d140571ed707f6514741ea4c5077cae4b6d046bbf8919b29c9845bdf8 test1/2026 0
-6ef6e1562657d3a7a6cecdcb553a1d5669a6d90623ac70eeebb4ad1b8a22fc6a test1/2027 0
-fc2d720380f0524ddacd1607d49627f443d6b234fb2d6175e476dbd327074b2d test1/2028 0
-556a47b24cf78cc8f41c1c03ba09f15b8eb825b44c38929d98f0e46f691b7f23 test1/2029 0
-f3f8b03880691bcb075a2d29dd748dcc5a384a70dcd311065e8b55184b05dcb6 test1/2030 0
-555b1eb99a6fe75f065c9ddc91994e04508dbda5411ca8fac8eb423aa20a9557 test1/2031 0
-de159829e1ac9acb048632bcf7546d0b50de43039cd34d06d3417d466002f4e4 test1/2032 0
-c4fb9f254dadfe86156f051ca5d80f07d9a9fefdaf4e88b88315b870fec40c63 test1/2033 0
-7aeea18670b28723e8c5cc9ba5880aceeb04952e6be1df1c44dc8d0f72393a1c test1/2034 0
-7b5f139b5dc3a86956d25b30223ae6516c839dcbdd3fad747a422318ec39141b test1/2035 0
-df76051a5286d177f0cf760d2f5d973e3381e36bbf9e7940c508d434a964a105 test1/2036 0
-f86cd0a901a8cb5468ae01809998d0fa7bd9e9991429778036ffa3b2553ea2f2 test1/2037 0
-1bec861e07303b91edc686696613a4c12da7340a468230a87f5f624f523ec6ab test1/2038 0
-12000566ee1337447c296be57a103dea87e92910b8e4b845b0d2db825c3d6d1f test1/2039 0
-3084abc6a27afa80ab818b562321b817651c8051783b2bb0fda9114aba335883 test1/2040 0
-0e3686f0aa5cc15215da0a7b174393099289ef9528a41b07c95224e78e25c909 test1/2041 0
-af50cca50f833f732b6ff737136c950934177c0f6f9e5dab69506e4740c7b67b test1/2042 0
-912342d10f814e3f7f6411682dffa3fb3000d9ebe7511b988235f8e5821f3617 test1/2043 0
-faf624f64253ab43dd8c6921d7773cf7432dabd487a07d36eadcd75dc9cd3133 test1/2044 0
-c9811c2627c57a2ae418ed603f06d741b5500c9da04893c1c3c6b2a3629edc9b test1/2045 0
-93dc877933fa6a0e93600d2b73598d3caf596a0e52aa32fecf195fc879ff58ac test1/2046 0
-396aad060b3f97256e25819384e40899b5b182130dc6da08e4466e8e8c974947 test1/2047 0
-caf27d9f8b2a5ecd5e6511485430273a3bbeb2cf9ab2c3c8f0488cb1868d60aa test1/2048 0
-574b6220c843c313f5fe432c3d98f9025ba5a142c332abe26386c1e474a3eb37 test1/2049 0
-4f635941b761683e89bbc1651e63941e55a42c52ee243fa8911638d07c091c54 test1/2050 0
-5c93f5d672434468b91ab8a3d391bfbaf67987212831913e7d1d46be73a9be83 test1/2051 0
-9769916e2ce3463c297d011b7e4e04b326993d22568b585276cba1f1fa0c637e test1/2052 0
-70f60d99cc3d96a2977f69c8ad3f39604c8bd9fc2c266ed9cbedbb0faf8592ca test1/2053 0
-78052633c014e593c30856f46ce4a6fea3aa286572424214128221e7163d732f test1/2054 0
-58ccd30f7f8a26414f1db7bceee8365ed93c357b5e059e7612313c20167b080d test1/2055 0
-6f49d7a1f9c77f5607cc9d7f6c8e8535c10c404a1dd656d091428cc3f7e84a7d test1/2056 0
-8812d6fc4e9b45ec991febfe6b1be990583ad283e2160dcd2a80ef2528b2f56e test1/2057 0
-c6645400d65b0858bcf35590c5d37cd5003268d4319dc36f74d6179352d845af test1/2058 0
-3cafcbb656c9f93c1e8b49a194773ce2041a9a829e9556e02ef16d6f2e6252d9 test1/2059 0
-46aced58f1fae864be1b78c85a9c4692e4b56e46234d4aab8664679453b5962d test1/2060 0
-ff544e916891c9a7ad615c07df789458994fd841565ab326461b4e49e18f8531 test1/2061 0
-e581c1ef07c47dc70919de4f9481a1997a011df9da90cd78d78c678db813de13 test1/2062 0
-294e2fca9806b7d981fcbea4ddf4f16f4f51fdd138920a590447f2221f8906a6 test1/2063 0
-d70e7df1624cd8c84e7503a73d8191061a11bc89d712212a6fff3ea963a6f9b2 test1/2064 0
-974013f5f2eddcf5507c410500a6cd30eea8348326853daca5b5ab49937974e6 test1/2065 0
-25da8a81c1038009114152814cf04857b02da3771e0f3a8d87aee11d5382e4b9 test1/2066 0
-75bed8ecbad90265a3343f41746d342e9d3c52be4ed3c3f7b8c19539a4004ba1 test1/2067 0
-8d0d89fa8482be67902a260e14136eff8b3ac0d2968b295b36d2aa6d313833a8 test1/2068 0
-9face09f7684988a539a6b88fbe3ca868c9f3591f016283d3000bfe88d8aaf64 test1/2069 0
-fa879cec350bd7f8d5ca31812f6536927509cd92ce725cbf5114b726756c90f5 test1/2070 0
-0080a2d31e5464ecbd8842b342257bc1f1c75563bc47687f76f3023ebf6d6f56 test1/2071 0
-ac7cdcd6345ee144ad43301e0a0d9f25e63d9aeff0f943086ae135c0476df159 test1/2072 0
-ed662d8d814b4e9af09cd76c55a5e47b1c793d3bc5f1067c0050658168b15ce0 test1/2073 0
-ceea8ba1b359cd06543860307410eb2e3801185ef3d5b735a9976193a04414fa test1/2074 0
-a35ac8c5c3913a7f701f1f69ac8ecd13db33f5ed2d36ad3473bbf4d6ab35e621 test1/2075 0
-4acc15fc63e6991ac4a117070d5d2945ad1273d277e8380452fd794b88e4ec8b test1/2076 0
-a805785b91ed490e04e4436e938d54e7dd176a93a8e1c7e77144956e4899bba2 test1/2077 0
-09753734262bab88fd2b807ff9db14df53109ca5c2ded7b63a8e371d311cb828 test1/2078 0
-d11103a0a012bb2208d4b33e12bdcdff6164f035226ea057404fd81580c580fa test1/2079 0
-68c04bbba402020a7d8df090bdb6fcab2819e0ed21d070156ae2ab875d8e4372 test1/2080 0
-7d8ec113fe6bdbb576c1ea54623738ae2282b3be871be5f53bc1ff1bd802fc71 test1/2081 0
-b9daca4a5c2fc1bc791fbc7578de29f11be72c1283649c004c8cc0a19637332f test1/2082 0
-73e59d2b0035972946dd0083efd1b454aeae61173ff3aef92c9b4bb75e33e70b test1/2083 0
-6ad2013612422e84ad329ff42f5e3717b3b36ae2354055eb6f4c09364d6389a1 test1/2084 0
-20c7816c7c852d404cb669744b4e989e65b74af4a0fddb1ad573fab6d5b01fda test1/2085 0
-c72a8d561b6f54aac1680789ecb4034cf8ee18cfbfea87cf105503a8290b363f test1/2086 0
-fab1bb3aac1c4429932a95848285168e287545f071cafc80152cfd0664b13c64 test1/2087 0
-bca32dfbcee94c5f8fc724f9638a75f875235aa483c9e1a37cb981537e2d9a0e test1/2088 0
-2d2d4cead21931a0f9ccd0894cbfeb3461176291c57a34b75ca6459a96bac7e1 test1/2089 0
-9ffeba58cd126e0c3792d643e55292806ce1a70ba349baa336909cd31c122252 test1/2090 0
-792e72453f844b6cddfc9f5b1d30b048422d8d54429250a055aa02d5edc14a76 test1/2091 0
-f4c47edd4f19d89a34e058db36ea04d118dcff90ccdaa7a14accbedc37c15cf1 test1/2092 0
-5c33b7f8bfca2eeee2f988ad647adf4968f1ffbf639bb1de45c40d82bb6011b2 test1/2093 0
-04e80541df8e06207792131cc984f3627a9e37b92147de6dac88a2591fe4395b test1/2094 0
-95f1f4aee65a072277dd41bfbc6c1c531c7ad0dbb037681b3c60fc240708b404 test1/2095 0
-85b83849126f4bdf71fcd3f32c7e3c63ff2e028f2201b028efb7a1adb0758e7d test1/2096 0
-3cfa8d39871b79ef29867e35175cf2468e9ffdcf9538bd15c6f8cbffc76d265d test1/2097 0
-7ca5e19f620eef087ed2bf7bd18ee5f7c2f3a477a5ace130768c1eee0eb777ae test1/2098 0
-8590d87a7bf2d503700f072c881a0df66d914cef6b4f1a528dcf45cd90721eea test1/2099 0
-324d92d3aac8ea302772332e1138d41b205ad8e9408837a7b9295074e0738c37 test1/2100 0
-081fd9e6d4d84665f6fff53656fe17605b99658abd9a985e9a607ee8decf2779 test1/2101 0
-73f60d8606108b0ea8c32fa08f008599d875928fc5d75c32d5d9b1c80ba79c56 test1/2102 0
-2a72013ff4ff6f8dee885c3ab9941f6d65b2cc06ca3f6e06311163d4284e7fc7 test1/2103 0
-6e52936a24c78badf112d1a9ca8eb271649353d42da0662742051d4b5ef7b82e test1/2104 0
-edffa69054c35eff12ea354ae22c08421991d2915a45a316fc99e3c7a2e57bdb test1/2105 0
-82c1d12949cf62d1d2a41263e78ca1cc5939f38d693030479abe7f4b68498650 test1/2106 0
-7b20bf608434df1dcb352c3cd227e8ea81129e50824ea9bba80c4c65b19b42b3 test1/2107 0
-faf187af2ea97c156d8c0a82ea50f368a6567442993452855854a3f0af79ab81 test1/2108 0
-0da217bbfbac2048d245a176fcbaef0be92cee302bbe30a7374b43f733a69e30 test1/2109 0
-7f8872e5527dbc802aa0b5f3634b01cf21aa51f6a8fe9dec9b992d707e19359a test1/2110 0
-59503c8328d67e5bf3e54a4bab001e469b9bebd5e904997d23b5466c066f863a test1/2111 0
-59ccc13132e01f8bf0f28ccfc9bc378d3045fc04e72a5a4354ccb4bf6f0c4ccb test1/2112 0
-c79bcc882c9c41f3c6eb1d46ae8581c7c5dd4a629c64a625351c82381c42ccf9 test1/2113 0
-e393cbef25857a01396140bde495a9f6e4475a29c2be0a75ffcda7ecc8126a67 test1/2114 0
-4243991930bf0e57a257fe26c1525f7d7b230eb473d461937f87c2c9d6b2e74c test1/2115 0
-d80ca696d8976e6bc1189ce940f3d6b08d2267b07f12c39dcf5e561557c761be test1/2116 0
-1b258395256e658af89ffc02b8e8dedfa254b371723638b8e0191b575b626187 test1/2117 0
-2b0077045f83707c57eca029a6e837c4ae8febe2905f2d1708756bb8347f2025 test1/2118 0
-669c9d3dcb6fc699025cad5fbb2e223be7b7cbaa47b5e48eea7fa684b77817fd test1/2119 0
-789c7aa0a0c65acf980c234a63495764035affbe9d95ccea4f4431ceb74f426a test1/2120 0
-0318a5eff2295cfbd961fcbf40efed14ec33db73e94389e44bbd14b98b33db5d test1/2121 0
-ddd79486248bb4b7877bba59b88231da2d6dd15cc3c0926712fbe2e3245b975e test1/2122 0
-0fd41f87b83585542c3fa40f9ad924929311e46ac79e2819e9e9a92538fb19c8 test1/2123 0
-08cdf08b96a508663c2a8884a2081546184ea04c6ae7aaec788fcba62e051e23 test1/2124 0
-0f5740d8206ee2c138eb953c480d92afae885c0b53c1d7910eefdfba851f133c test1/2125 0
-22487321e277e3cd88024260b2d66ea299ee912e581b24ce95ec37b3eb1415ec test1/2126 0
-bea4fa7c1ff5a9f9065fdf0ca5390741caf20e65f94b68a920626cde896979c1 test1/2127 0
-c0d8e47887cf3de55d432e2c69c052caf5fa5c43cee6e4f7805a3895a4ca3ba2 test1/2128 0
-f2f4db7b5ae658302d5660d7c79e3dbacfc66bff591064f5310e93f2b8a48490 test1/2129 0
-f4d04d4ca4467cf972fad0daac890d7b7bcc1d07d2622789c73ac4345daae4ad test1/2130 0
-c724458f80a7277123ca2a0503dee5cf83674888ae49bc9faad1deb9c6a9bf25 test1/2131 0
-f4f8589d0fc80e93611b9585b3b4c01b3068f91af704fffd0334d1ad80033c8d test1/2132 0
-f0da71301558e05567f6e34a5c4c958b71c97dd42774a3307c7f658290476bab test1/2133 0
-b06126a1af8d5069796d63c3b676f93aed00328090615d13cb85e2e778ae12d5 test1/2134 0
-394b9ebc191cb1aea0ec39aeb89cfe2d5fb9b4b95d8e5c95aef88556244816b3 test1/2135 0
-db033c9abfacb61f865a5dc1176dab01611a3ff25da67f559fa42f86e436ca5a test1/2136 0
-e24b35b6de35c1d637f4516d158a0ce71a80155da843befa0f57983646055f47 test1/2137 0
-d11a904c37eabb4a8dd137d427fb02413b45ea159cb43d46af20b68bbc835324 test1/2138 0
-b3234a01665a0fb74ef51c75b06961e02ba144cb4cda4f3e596023dac024c3af test1/2139 0
-360838526e1805b991c0eadc958725397c8eb14a00a30572241d4d33d6266c23 test1/2140 0
-7eb653f896e16d8f305faaf69a6931ca247e5e4f5d2d2c4ea2fc53e60ce6fd65 test1/2141 0
-6383f1ad0b124b2badd895f57e6fc8d9abec80569ebec2520fbdf4768cc0d831 test1/2142 0
-315c04e83cffd42367559e9df7afb6469f9766ec8b76c127f75465b7341160f3 test1/2143 0
-2aa2092e154502fa193bc31b1155dbc84baab5d96d8ad1754ccc62ecb02a36c9 test1/2144 0
-6ec1a9209cd9294aacab90ec3d3eab12182571ddd317d55237f5396484cc053e test1/2145 0
-d3c19b76b10c0a7da077a409ad6f77b097ca819d606ed4ad53e44e9ebcd26825 test1/2146 0
-e6942d180966f814a074a3ac54655c04c236ede67f7f89db1ee8dc6153cd0762 test1/2147 0
-85e7c06031973289383389759a0f5c0da36b49e95ea30d74de995ea67982a9a1 test1/2148 0
-82a766d7132ed98ee86dc851b0f613bbb31fbc121c5b97f17b5924cf904c9b87 test1/2149 0
-04ed017f3a83e0f8105dc8115a280e6cfdef67810e4c1bed9e876688c2dfbd6c test1/2150 0
-b5cc432d3160aefb23a87c7b188d07fdf47cc83a8cebe12807111924d542f831 test1/2151 0
-76549b98fe9cf87340aedac605397994d3f25b285df236c09810e17e9b233b22 test1/2152 0
-5b1bb1028bc7e35ba03b810c58e28d5edffcef165c6ad999e910e95edcf7806a test1/2153 0
-2de7956039012303cd0967a79456c5f1765eddaf9aa2aed88afe7a798958f91a test1/2154 0
-3bd48a943a8d2704ff20a3ca0ed51f1b141fb38284027b890b819440a9f5a04d test1/2155 0
-a8ab62dd72c8888ee50c733c09b4fb2fdbc1abbd028e751ffa506739aaa0d072 test1/2156 0
-d20666a320810a890dbeab10fd1074049209e1a749b08e7655eeadaab3028ec7 test1/2157 0
-ed7fd00850d41dfb22aa24fb5ac1b56a3f3ba231393a9f51b0be49c0f3a38500 test1/2158 0
-ec036eed64897a217aeb4f395e1927b6c9b3ce64a6cbc8f5e8bc45b01e7cac00 test1/2159 0
-c275c8d704364300b083f152cea8852532bd543a23be8149175cf347c2fb6fd2 test1/2160 0
-2c09070a35af89637bcd5c5fc9b5bc2189a89c9d91dbc63a0a457968df52083e test1/2161 0
-c861f68d23e660c1cbcb93ed82b8baf9ec9fad118c97c376309b37c0098268be test1/2162 0
-489e11496c865a395c72a880f7725ecb64b2dc9e9c03c1540d3f08aec0785400 test1/2163 0
-ea9ef3fa28ef27c1d027e6e44ad1d90cf6db99e157126b3f63c7ea83d0ba116c test1/2164 0
-58658b3251a4762f976bb7e0689dfeb877cfa8d09d6e806e0be726b788459abe test1/2165 0
-9fca02fa463fad70b41421150591134fba909e7bb1a3c231b49604461c629a19 test1/2166 0
-7caf125719b93e5d8da83187e1d708e7d899f48b41e293c3f0f0174e9b1f6960 test1/2167 0
-96becad6a1eb038404b77f35723611fbe6922c44d5613d0ed4cfde27c8c6b5de test1/2168 0
-1776bb421a59345bb64da6487606abb1d59bab511b89beeb420c8f88b9ec5a05 test1/2169 0
-3c05a706627e06d14bba52832d488ad32b57effa5ad0b671a11834af0569d480 test1/2170 0
-6088f546ce3cc22b9821cafae8a734ae82ac7b6850a59d8130b1538a133808eb test1/2171 0
-866da6798244c9cff3bc57102efac7d7d718eafb27ddfe1426b3eb19e9628c39 test1/2172 0
-3f7cd6ea845bf30f115b45612c2872b2b8b31ab88e7374a4a70effd7596a00ce test1/2173 0
-a35ea33ffd76dc5aa14a60617d57c1b9b790fa2310626e7e600006cd4a73a2fc test1/2174 0
-c0156417c12977af7851fcd620f6d254c0049b80996ce8aa6d0181f481e5a91c test1/2175 0
-8c12a0f360205d8b22c757c790fc94eca3cb591dcad5df8d652fc34d30f483d7 test1/2176 0
-d905c4a755cff0ae63de516c21dfd75425d34131c21bee984b97b14167da1fd6 test1/2177 0
-68ff55690bf216977f48867969e76f864b698a78ee7b3291d914db50a43fec0c test1/2178 0
-acf1ead7dfe1daa0f5dc378fd9ce826f87d9cf86ab37e62c9d7221f06b7946a5 test1/2179 0
-36ceadaac2a27e39d587d31772279256a1b151020b45832b9eb08ef0e6a1fee3 test1/2180 0
-3f3fd6ff065766b9d209df1ac2f7572cd18a7251b83eeb316f26659bc07ae668 test1/2181 0
-e7d480669048fbbfaf960aa04ee35729dbf991560ffcc982bb283656c6f8cc3e test1/2182 0
-a00130d8bb296089d2e149bfde846a16c04dcf5acc39f9b38ba33c62ecc1d7c7 test1/2183 0
-461e5474dd217c08207fcf2df16a7eb7713c2b0fcc22a75185e0607924ec81ce test1/2184 0
-de89b13084eb1ef620a48a467bb0337b0efe20d7dd6eecc629cff1dc4e5fc596 test1/2185 0
-e29ef8e4c5e18fd2453bda0e3635291e3e612febcdc57dbe138e31d6b44c7ea9 test1/2186 0
-62674c4f26be0f37825246a00f7e07b53657ad9403613ce445755f8928b9259e test1/2187 0
-b7bfee4a0aac049a3e06c2e608b8e5940c649da03f0f312563908953eac5333c test1/2188 0
-0a0e0b95504205e33879d3a873e63b5dc592af6cb8bbb558ec976769ec1d0636 test1/2189 0
-e200b81649e98cd63c78ca9f65dbc02206f4fcd7631fbbcba0b38bfb5b1f21e8 test1/2190 0
-fabe0e2a31fc38fa5cb7d980cae9605044fb5a2f98f9147f003785808e1a6d3c test1/2191 0
-9891e0ae0aaf3c4de7bce58d0510765eb210f8ded5963bb213bd7316756e80b3 test1/2192 0
-f20c72b5c859215fde4cf7e5843a32770a010d4b0030fba108867fce06be7ab0 test1/2193 0
-6d3422048f653bbda50f04dc2136d58a2c979bcf6712cfb7c6867390b400656a test1/2194 0
-4de489f5a822767a296ace3cc0fd130166bab3c9d01c247be3751b1ba787ecf6 test1/2195 0
-cb37148b56ed468ce464032b4989a7f9d66317d68871b74ca3b94c87ed3fd82b test1/2196 0
-9dee5dc891803545e6c3b062d64062421f410a8a1939beaca7997a228f561cb8 test1/2197 0
-b76345d2e877cd95c45aa02769b5fa41e9272355f4f1208882ffcd99bf6d4460 test1/2198 0
-fb88123fcf04f0c70fc765dcf88168ca222513ab1256c7c0d39ec13b35c15966 test1/2199 0
-dbe2e3bdf666f6193b38a2fd892aa2f23122f840e8eec20b65d2ccd75da43b95 test1/2200 0
-3ee28ae073112dd4f510c759e7427143d7a0b780a48767b1ec204890f397100d test1/2201 0
-e900536b4cbd4ee7be965976229a53f87046d447e1bb6502c6d76319d6b1bfbb test1/2202 0
-5f64f9ed8d3c960742049e7ae15dfaa7ec14b6f6c9b3bb1cde2a7ebcacb5ce36 test1/2203 0
-6bcd87e5f17bc2041abf0d1c757eaa1b5aa82c179cae580051f8e56a177c2327 test1/2204 0
-c4f52442f71576754fcf2479a5fc02d34a2588f9a07ed1d9ae35e34dfdf9ac8a test1/2205 0
-d93ab242a2e2b899e43bb37fb6b249fd2392b237e3926e1f04a5b6e186c297ee test1/2206 0
-414e1de8ae21765691a7206893222e718daa5c9eb066c00c03bb6bcf2dcbf768 test1/2207 0
-6390be28c5ab8cb3b72285f407cf25fccd573435d06c777eaf36a39b20cd99ea test1/2208 0
-1d2048f4bf8b800dd281bfc824731fc21d6e628b06fef22e178f908d40603526 test1/2209 0
-6c87236949d181076af920f3f2f4aef6fb1f41d30bed8dc9484676d244de1f86 test1/2210 0
-a018ac3b6e398c0ddfb532c809f538bdad61c06f6d15ab5955bea04a826dd1ca test1/2211 0
-6b2885193e15bb5bedbb331304b7b1ccb63bba76b624a9d31f4d7a2058eefbf6 test1/2212 0
-71be9c1a635be1de654393d78488942dc1f495a629075122933b3d52a6998b93 test1/2213 0
-e26fe0db4a9bc8fc2ca52d1165b1ac606bb4f2b65a8397b3efb2e7eccf0fb7f8 test1/2214 0
-82902e276c127f20d92e3a572ef60489f8d8b3613c5c6375d1c1bb71ec92de26 test1/2215 0
-81fb777852c4148a34e4c25036f5265a583175dc2f4671e93a8240e4f2cb2efc test1/2216 0
-f4e07cc26a1fc35f001cd6a60a5a29081e062f64da947b25bd8abf842ef2390a test1/2217 0
-0603f6eab57e3a9093308e967eac700507c99ef6d492fab55af0bccbe12e6912 test1/2218 0
-a6258fbc0a8a465359e5bada52181319a8d06aa6c139b8070fd4b506c3ddd0cc test1/2219 0
-1784cbf7e094e0220f502d7a1670ad5645fb25d62aaffa5425dabc3523955d79 test1/2220 0
-873e8dfbd4cd5b2a45866eeeadaf2b9507be9ba0f50cc66bf2b3b8fcaf61df26 test1/2221 0
-821f2903f7919d6c840d9aa476deb812703bfed9dc686122ca460caad652073d test1/2222 0
-301f58af68a48893985f5ee15b1fb66b805093ef19366f77ec4ae4c18f38f806 test1/2223 0
-1c4a437b2a87e762ba74ee03a4f7b3f7633fc41da1e0978c5bd91b9891d0496e test1/2224 0
-f7580007393af10557bc0a4224258f6f98df0ed7d4a93f3611e74f2ad7d20e0f test1/2225 0
-971ec0eccddec5192de7e11bf7a88f791d7c2518b9aeebfd7ea63a8414dcd314 test1/2226 0
-31397ca48ac1c5a49919899577e9a5da4d404e93b9b68a6b700820281fc4bfb8 test1/2227 0
-d4e0c5523825907a0b5b4b743baf3c1cab56e81618894913a34d8bef4d5c2b98 test1/2228 0
-38785d0f524364d5c72e91da9f09b6ee1972c967250c1e4d5bce8d8c0acb0fb9 test1/2229 0
-d3f727561c4f86e2e1f67daeeab7b8adf8786e7e785d6a569de77001971ee3a0 test1/2230 0
-df71d84a18460f3e90d400d864f201094a780dc52c863d7ba18a73fc13a30220 test1/2231 0
-4c28ebf7fc8e5444b63bb60f6ca78f15b011b52c2dd2bc5f5df0a6faaebb5c12 test1/2232 0
-5fb1e135aa50602716d43630ab36314c23fcbe77a2f8af65e6119b6d09f3db2a test1/2233 0
-ddfa0bbcc01c421645fc1bf729bfa57b8d1d1c78733358ef0526ef344fc752ac test1/2234 0
-c8ad0a4aeb9ebedd90f5144ce23675e4ee63cd0897ef6f26f7710be7a27b6034 test1/2235 0
-95a8d244e13f4b7f0a435340523c672aaafdeb9b7321a2ceabf1d0d0acbbe538 test1/2236 0
-7aa12528ce4dd175942ffbd68b2f4bc18ee3c171c8133dcfb38dcc155b4e19da test1/2237 0
-e8616dcdc384e828c15e212977cba3719c07e3ae5376c7c5d0f111c6e236a9a5 test1/2238 0
-208bc77523e3d31a346626bcae4abbacdfd909726532fdb80793b5776d869ea5 test1/2239 0
-87641d98b0987bbe98f7d0a41ab362c5a943554459e41415d99b87659ab7171e test1/2240 0
-c08ea31837ea79b6aae4772def1054c8e336fe26e81b8f0530442a4a9e5c975a test1/2241 0
-e584586c9171e1bc0fc3b4899f248c7616bd6aefd84ee9a81d7dafd441522113 test1/2242 0
-3db0e29f9645d2ce477290f1db861b6a1c1b5ad25a0da4b629be5ccfabe5ff59 test1/2243 0
-1de1cd7a9c2d30904e50f96ff02d6d688ffbbc50eed160dd3e9fb345ffca191b test1/2244 0
-66a82285ac90f46b66473fcf432c0a6014ae109610eb47de7265b7b41979abd9 test1/2245 0
-711f07d5aeb97a496fe0b33de80b830fad6ef1ade40949a2316bbb2b12f7bc98 test1/2246 0
-27c6aec840d86f4fe1b4b690e41934a1c348e107aaca89dfd4ba7d9c3cfb56b0 test1/2247 0
-7133d5470310cdb16f1559d50f32a1645963e1d2939e155d85598e742dd78555 test1/2248 0
-c4879a1a3cc11906be34b373fb58f68ca0308e90c091f29eff35e5213533fbf0 test1/2249 0
-62b527d8e73cce8693a8b554e38564f44070b53b11cb21bc249e0a607fd3df9b test1/2250 0
-e4d44312e6bb15594077e448fca316ff59c89a0f78b7fe94140f9f76962c2539 test1/2251 0
-52effbbe022ce24d08e70ec52f9ad6af681c714bac879800cf7461cd959da89c test1/2252 0
-d3aa23ccc3d32727a070c347dc2e182ca7402458eabe08c3625c38613fde5db7 test1/2253 0
-dfefbe8ffe639dada012c016c329d46968c3c9038b3f7e84281e853b1a511d33 test1/2254 0
-c1bddae075670a3d60babdbe21f47998a9dcceab38321bc184c444ccc66cdba4 test1/2255 0
-6920a1e0625c4bd268efbaef5df26b5924ff3db2832f90becfbc8690e2304567 test1/2256 0
-4a6e94937f75d0ea80bbae4c77b51a1cc67d21f9c9100df16cc9c21a7a4c9f7a test1/2257 0
-be0801bf012d6709b58e74f44f5e6e241464f2141ab581b0ebec9a67d58a0fb9 test1/2258 0
-7491d8895044f4f468a08736f05f8088bb037857cbc42a960be42f8dc585ed7d test1/2259 0
-d499227875a49306bd9db5b846f285fa28dbaff7e3ae867626dfedc15e44d56f test1/2260 0
-7edf5b1fc5af09ea0537129c7c9bd6547db4686d7a71bae98259eafa155b2bc6 test1/2261 0
-1ba4ac6dda4d088f3fcbe6b066fa9b26ad9986a4ce0e8e99ef7ab1f750befa49 test1/2262 0
-c2ed9cde01e7be231b4b2f9bfcfc2ce1295137d9abaeb408743400685457494a test1/2263 0
-25239e447b454ad0e1fcb12fde8f2c490c9c98074b7bca86a3ff9a8b14bfd81d test1/2264 0
-0b00ab860ec9d6f9b0d681edb78220a52d594c46cb5e96251881d4d5cefadcfa test1/2265 0
-45633ea33b9a6f0bf72a6820c52492724b46a94cb1c255084ee2300be88ba5c9 test1/2266 0
-cde670ea5cf9abe687ade7445142b6640c536c5f68f82f0d886738bb7e385778 test1/2267 0
-3828affcaef7022f02c3bbf36bbc5ee403ac6848b4d3312c145f62d1930c4c1f test1/2268 0
-4394a95253b2fb44ab62a28cb9b8fc80ebd98ea4353a55216f5ce1beb642f78c test1/2269 0
-9a12c7d3977bf8a4b84566f6dc895c196ccda531e508dc94226ead7e40fd6dd6 test1/2270 0
-74401f7c1d30d9ff9e83282ba8ea64ee72684cd60a69cf5c6bc65f5c9df1ed0e test1/2271 0
-1a1c8675d4241608b2a4e54fb0c68a91bd85bf3ce5f1d7c89bec0cf3f319b9ac test1/2272 0
-2d83a06503fd401bc2bc78843ce2961ddd3b9dd78255e9940158f871fb742c32 test1/2273 0
-43287efb7b4b4ce4a68d411bc49f816242a21d7131862a14c5df6ae2b2bed44c test1/2274 0
-724acbf2eb91890baad3b61f9791de4d4496d1ced5ccea1b6231a631a17453c0 test1/2275 0
-af880f9f410bb2f681e4ac80392f9078e1be1b95790c529bbc1147adf82d253c test1/2276 0
-bc259ed94a5a1b888cbf0c20d29b1741f5fe97713e0e7d73b6d635d7a03269ef test1/2277 0
-0b87b58fd36c28343d9db03e510c77151a4b1f441628d1b4b95295702f7e3a67 test1/2278 0
-6ac0c628d595363c05a41fa416f26600cdbd5ff09be98fab6af06c10991fb748 test1/2279 0
-906e612f065d8a186b2a6c7aa960c36434e68c35779930fb6f5ac944b5d2bc30 test1/2280 0
-0e12d9c21fc4e66eaef5cfb2addb56738a38fa29e0e3db42e81cc0a8bf76afb5 test1/2281 0
-a31d03d82072afad06fbbeab2e537f4b224e3d84d3f1daf527299c88d41a2b74 test1/2282 0
-1ca5186c11cde566b424286070dd5e3264fe18eb4813ef3786d2a1e7f034b674 test1/2283 0
-de168c0774e0889ff1bb883275b3bb184050b851ace959668b9dc38332c640d3 test1/2284 0
-86ba74295293b18ea8308b26f8527e68c971f01620b04ad01d8e874eff0d048b test1/2285 0
-2cd2cda97a3d33e23567ec2610ad5d4037d1342752078bd5c5be56fd640a987d test1/2286 0
-2f7d15c20e3e671ad915c13c0ead7529891ae855b57a1ff78ed3a99c0c850141 test1/2287 0
-ad3f1eb48828dcb89fec3090557e8168c6967ced3ed41ca2c11089d7a783f50b test1/2288 0
-1c56e94f0a52be7b4173495e8554dde3bce24ef21e36da704cc6f6a47adfa250 test1/2289 0
-86513501f54e4c87e6aa820f11c1653f943af0898c55e5146bb1ddf8a11fafa1 test1/2290 0
-5d776ab429901b67d57ff03876034b355fd5fc23cc7b44a57ce6b9dd2b67f0de test1/2291 0
-563fbc233df691e957161439a1fbd1bce8b9812a7166844cfa096da110c8eadd test1/2292 0
-8e28d033b2bafc2b16f804b6d7848c99439eed8f20f40e1f3df2abd4ca49c4fe test1/2293 0
-bed83a643ba5737509df8584963bb1aba2e60207c5b0e127b08069e9a809f291 test1/2294 0
-611b7a7922874e14213cb67af3e6533f70926d89423ef7f254f1f4bbae39edef test1/2295 0
-3d61cf474304d1fc298597932a3c10527ac9d28ec03ae6cf2311bd1c5b19984b test1/2296 0
-b8d9f7a34c1e84ba823bc53d98897a024bfefce5768623e6b8386d546527a0d5 test1/2297 0
-a21e7f715f2dbf5d92a533f49b0005e3df2871130dce1f35ecaf97bd0be0dfe3 test1/2298 0
-615704fd4dea0ff2d7353b38c2a818918f4cf1c37f808630ff61e7edff039faf test1/2299 0
-40a81358767a2fcb5676c8b9d61e28406fa8e0afff74b784d6836b4afec85ab7 test1/2300 0
-6e0b42879b572aeeafae91a23aa00273970e44a631407532195da146b1163fa4 test1/2301 0
-39fbbf6cc306c0e360807aa8ba164bd24965b606c09505151c8e3518155d963d test1/2302 0
-53260895507943a3a96c3e8e159b0cc6e3a195462e61f508b0c00d84e3d03658 test1/2303 0
-d7d8472b0a9ff330a28b9eb0080e9fd948f6f60b3d3e88509311d38faf11bccd test1/2304 0
-2c83b8f7f67e52b610504e9be07b74dd2ee192ae62c0e99048556d1674f9e388 test1/2305 0
-56c829f474b8d8a2fd7c88dffcc96d38c0c405afab0beefd7559e3c554f4dbb3 test1/2306 0
-515b3eeccd54459a6a52e5f7e86f4e1edd67e763f8beece26abb749ebdde1035 test1/2307 0
-29abb4597da4237a720c59094edf259344f410bbb2ee1325fe0b814f7ec932f0 test1/2308 0
-f7eeb4ea6c91513ee1d4135a34a59259812a13647cc2056d7e43da919b096f07 test1/2309 0
-36db0cb4db02b1eebd6e8f8b2b53237e943c976a7b1ea6d0c502bd602550417f test1/2310 0
-2d5095c498c29d4aba60dbe0c720ee77c53a47ee16e9272f55891795b86fa40e test1/2311 0
-bf7e521032d6d93e98d74710cd2e2892eb7db73120bf867721b449a0baa0f4ae test1/2312 0
-df39aa328871e3ac621a88949d3e574fe7b7b75b509f2108a7734a4831f07a82 test1/2313 0
-c14398370f6c5e0f7690c6e221ec6dd7d498fed32b2929491dfe8df9a12ba52f test1/2314 0
-96cd7b39f3b84d2e170c23f64e4cec99b02a9ebbcc23cda56fd23180b7a8af12 test1/2315 0
-b37b7d30772f10510e1f1a2650ab375e8b34d0c78e1de1c5d742520a899d798e test1/2316 0
-fedfcecc3c964c03f1a817a8a1aecb8edadc39ee2905ba3e68c95514ecc5bad7 test1/2317 0
-86f851835026e7806545371a027a482d479180e0b415788914084f77a3ef84bc test1/2318 0
-f4ec3e4499273e2129c60034038835dc00272ad54cc61598749df6fd872019cf test1/2319 0
-69886bf893b2a3257ddf333c8e49c09533b5de652a486a58cf79c1db04b8932e test1/2320 0
-374c3445ce9dea2b03fc0eff9ac1ca91970e40d644b974f34f1869b55d50b2ef test1/2321 0
-70e68888d71eb11a7d1abab32c474b79f7627bb92c14ddf6874bdb9fc6a5f57b test1/2322 0
-39daf1b5e30ab00dab233985a4af243195593c09bf5fefd7aab27fbb30836e38 test1/2323 0
-02eea346fc98d7bb71052c6514f990162b265b82240fa608950045dfd0498fbb test1/2324 0
-37a6a22ab12dcbc97e71a1133c382ea04b45959ce7a0ae9bc72a228c25a1df00 test1/2325 0
-0379b1e3af3c7e9caaf7be0d3fa2f5852b6b3f93f04d288c5273200a62fbfbbe test1/2326 0
-30e8c83dea3078cff5800e05f48bf18699f693bf3e94a2b58d4f85c09fe3cb86 test1/2327 0
-dc9e152ca7487828f3a7a2a3dbbfa3e6ec9178253e914aa52d05e19a9766afea test1/2328 0
-8a916424f2d248e4128eaeb133c7ce54f0366aa0d4051c047242ac83a01e4e14 test1/2329 0
-7a00aa0324c112bd053e18174697aa1cb3513b812e6a155b7fdf1d4d8b16e134 test1/2330 0
-881dea59d0001cdd72e2c7141b0aeab99db3ecc17ab3f0300c77ba3f84fea218 test1/2331 0
-257d71b0f8571141e5a10fb69f082697de8b80c65dea31dfc886de8e992e0c62 test1/2332 0
-9bc10152d613f420c499e68bfeca0f1e8262dabc26c76f25a9b991abb0d05992 test1/2333 0
-95be4121962826fd7282bf0a6d52a1c22b5f995e252d0d706cee3cb2af557b1e test1/2334 0
-2329a90712744157c169bb1e3b143195214808c4e0c1f43e2e4993cecb10c923 test1/2335 0
-3b86b7212b09521633c6f8822209d4e685b6066ccb40ba5100bd3abdfa140836 test1/2336 0
-a7d04532c14e7dd7e416f2f0cb05d3c07e19b76ba9effc752f1bcf9eac676d07 test1/2337 0
-7dbf9edaf283d9678580da8d057eb1f786886b24531783ad8dcb2cebb7c905ff test1/2338 0
-c6a8ceeef6a39d06d39c13e616f1507eedee5908843c73288652fd4e3a1eb9da test1/2339 0
-25e82a20c11b5a9ae6ca5ec0cb125690035904319fdf7e9f66025367b7f5da39 test1/2340 0
-fefa25082755287d04442aaf3915f4ef19bc17c79a2b6e3a8d6b79dccaba3363 test1/2341 0
-e05895af38e8e78eb95e4ff28c26e704ae4f0c5b51dba87322ba7e624abd9f90 test1/2342 0
-5deea7f282c1e994879963530eb2b4514fe5d9be01e476661e0629412d1e172e test1/2343 0
-745f5cb281b9f149404edcfeebd2a93f0a4f83e122bfc22cd618868810748134 test1/2344 0
-eb91fe2606c0528d64b37dfdb4a33c6ab3db14ee5fdadcbd2aabaf33ec4793a3 test1/2345 0
-7a9bc14eb4ff9ee0e351875afb0551d8275287391f6ee5248f2f7b63b37f2d6b test1/2346 0
-1643976f9f41a3894457a466c23f7a980975d1a67548c501860007e8fab0dd10 test1/2347 0
-00e69e93805401e337df6700458b3579a7be1d80537b59d050f222b14b19ec6e test1/2348 0
-c2fceab6e1711d234c537f6d558e811ad4f8f112aa28a6625939455806e258fc test1/2349 0
-4d201b8ac1136e6330e552c3ab99bfee21e203d277031f970a2a634d47a948ab test1/2350 0
-0b72599e0925347e780d21288bae40a0cf0a124c94b433efc067ec58f1dec35c test1/2351 0
-b7958836597552f72e9da6d32fb2cd60e61770880cd1145ebd67a47abd0af5e2 test1/2352 0
-0fda3ba7491dd59350ab61ae431403789ea99b677939ee8a14670a1aba3ca08f test1/2353 0
-25192b129e910219edde31d9ebc723e07ec3773fa343e3d4631809d73473f136 test1/2354 0
-af48eb8c8f9f17e12bc63e7f4971bf9c08b2da5f4dcf25c85772bfd91dd56e10 test1/2355 0
-48ee001ea8db780d0d00dc95b0cd2ad865150fd47016950ccbfa953518043f78 test1/2356 0
-a2e19e45c74b08a398e1c9bf17ab28de9708f81f3c80cba5040729d5dc7a87ee test1/2357 0
-866c3b25c705842e041ddf19d2c0d9c3ad8e796b57fedd6b9ca9f98a6f4fbca8 test1/2358 0
-bc11eda44621d1dcded27992410b64141e2f613d2b7e215dc7c5232b8f2eab59 test1/2359 0
-f75e62a0de545b2df3161989c4428b27518318c193cd56219055b4641d597aed test1/2360 0
-aced475d1cde49fec0c0defab7c70beedb78d3963da54a90a77e97e2addeb293 test1/2361 0
-8c389dd574494d0d1ba4219e2ca8a8aac4caf716ae50a0d651592214411d12a2 test1/2362 0
-aaaafe06daea89591cd44e8279182e8232e4c7041dc86869604001c40a977dea test1/2363 0
-c9dd4c6a16d5c24909c522b7cd6f074b251dffb980eb0bdef96c13403a0e4190 test1/2364 0
-532fef9288539f6238d103499e4e614bd90c97c133e7597aeeae2b98f05efab4 test1/2365 0
-ba51ccf692272081a6cee093a0dbb420bb65392b799cdd78703f2fa0cf4ed2ed test1/2366 0
-7b1ba277b61b3a508abc8ab6cbcfd020895eef7ffa15701a45150f6af334f260 test1/2367 0
-c12f970c06df1f843d154ccc4dca18a57b85fc905f04816e7f16cb4d164f3ca2 test1/2368 0
-a800b2c8df6e165b9b939b0980282a943d4ea383b452544c13253162004ff0df test1/2369 0
-3e15f1630ee4ee7d3e2e5432874d016e8e3680e7cec2ac9088daf8205b56eb4c test1/2370 0
-f7d18c4307ab897292a80ae491ba2b93697e141f5ed22dfff634b4cb5b42ed4a test1/2371 0
-14952e6ebb7a0c890cfefedc26dcd3dc5852f7992b25088b81b0b8070d0f3460 test1/2372 0
-2a0cca81ebcbb0c784d9894ac4cb601362707acfa3eae58d238d9cd004c75414 test1/2373 0
-eacc97edfe5aa1e58ecae2f1e40f32a22f1d110b1cf1eb260f3826730efd15c1 test1/2374 0
-0d40ef7968a0343207fd7c695f52d0ca835ec2007a84e5c99bb9a382e7e08638 test1/2375 0
-7aeeeebc30f2b2b282709fc370afa85cbcc835f5278c61b052d1032b496f2172 test1/2376 0
-af022f91d4553584b782a6d8ef97b5630aa225f57f33b97c08c070b63fc2e764 test1/2377 0
-03d9ad2f646da281d88a2a9886e1a5cd3d8220075def647c742d0a85a4244274 test1/2378 0
-d3999e1b668db4d2c713e7c73d2105a33215cc09735c9664abdce384a6b02446 test1/2379 0
-886c0b823688629c6d08a68f3356bed3d10b13e0a745c71ec991eb7d0016c827 test1/2380 0
-5ffe5fd73667f65e6b020cd91dff21d06bb0dab94edaa0c642a388b250e1118c test1/2381 0
-01756c42aae4ec96e79d59311852f1087d8654743fea6b3fd8e500834616499f test1/2382 0
-34cfe1bc46dcafccb99951bb462ebe63f8b9f360251ab19f72770bfa9cb41b48 test1/2383 0
-dce5c60cdfe45ec8bbf60409dbfccdf78843fbcd8375261d759187fb63a5b288 test1/2384 0
-673acba4e97f5908f348cdca1f191ed5d2a0bf5ca982bc79a979392bc2e2d860 test1/2385 0
-2e182c7625d1bcf780e8e322a1e61b64da2c9d39d33a10a9d49ac70dad4a5e07 test1/2386 0
-259d1a68746b600760dba18e34cb8a748db65a91f3966d05c25770fa93855135 test1/2387 0
-dfef7c7aa36dac5e609b29c1a59c8df3af830140bd27d708ccbfd1cee4c2ae0a test1/2388 0
-ff97050cf7e735e2ecb466a95fe2932c20d02ea12a1f6944880dbaa2ef26181a test1/2389 0
-01a4dc3d1cfaff8599cb5f8ac757a35e899a62a68741b6291a9fee6caf703d15 test1/2390 0
-38ed499b93cc7132d807e2c271df651657fc81757fd680b04cbe3a01ac99d844 test1/2391 0
-fc95a141fe5a83b3b8302821572bc921a7755fa7c3a68bd1d4156ae7507c3586 test1/2392 0
-5e15542fd02dd79044759a50bd93a334b74104afa89646f96349c05217f2f10d test1/2393 0
-d6a0bcf8a02c5ef24ad4c0fa18cba55a91a95e792d00863aeea86c09bb2d46e0 test1/2394 0
-5b91baea773e01b211f38f6370354beb3a7636dd9d97462cd1d89430fb5f4414 test1/2395 0
-f5a7545762b1d8c8d34a0508c7bea9408b508d477352b4bfb53ce6b001ee63af test1/2396 0
-cdc8f0c52ddce95af42588ba184074079dd5389c0f977e892a2d1d17b8754732 test1/2397 0
-81f8936ed4e92298f2db72aed8b084ed7c71f27c71427aa012e85f868b86f0e1 test1/2398 0
-0794dad518bfcae5f3b2024b60f277d235e0ef961455bc5794840c4974c072a8 test1/2399 0
-f2c4909af9f2a0f5279af60a1d63628dad083deb9908830625980380e4fbe742 test1/2400 0
-9ca5247b59bc1de975300efdc1d7c2ae3e01c2cb91a559f8a1d639b84ff26a3a test1/2401 0
-885f61bb41bfab7cecb5da7fe74e9a3ded57dbd294e275bc57e6ed0e051981e7 test1/2402 0
-9282a8ce43c327e28cabbfa15d1e6e27a0c0e37baf3e89dda1a8cc6fb8ac176b test1/2403 0
-7b10077add5c9ebdd4a06c3c9595d5ff5801f8ffae927d23c2b500b0938adbb3 test1/2404 0
-fc70b543147f497ffb7321016c0a9022d7e38e138bd05a03008984dea7185947 test1/2405 0
-7901d3859b5123727d36890f03ff6edfe78453821e8e001971e533e896238e10 test1/2406 0
-57735c81af204b204140aa8ea5aa31f81c83ceb3c29f38c204d16d39614f8f6e test1/2407 0
-29c42b02117b087afda9ef01c1a64eee5d6ef8d11e7924f734c5855e3c5e2eb4 test1/2408 0
-7d6c8711b5776c7f3cd77bcf346c9c7a06729261376e03674fa65bb8484a37c8 test1/2409 0
-dc11856906d69efbe4118596bb02fe809a3964e25ba3a47a34c639e19a350e1a test1/2410 0
-e029c69efae66a89da23d7836e52855c121b8f5ab1b8f5a40e748d05f6205d57 test1/2411 0
-01c2328044256a06294bd1364c4988bb2bf7faaa6109bde7fc81f6bfe373b166 test1/2412 0
-c078d7bbf2de32dd1022408bab248b7c9992f958ead5944882eed79fb8b39269 test1/2413 0
-b901aef7ed07fe9b9b7a2e30a2183c0d4049742570a6d437ea94768a94453e61 test1/2414 0
-08ec77a7eb86cbd92c9a23d2b8238b6a51753c0787050cfed0830a8ef4bbb10b test1/2415 0
-56946ad348b9531994dca4e7ecc65fc5a98d2ca2f84b8eab69e94fa10e1ac849 test1/2416 0
-a7c6e0b68fc6421dac98d6187e1f0b055b98b4579bc9b571e73dc8fb350fa8a5 test1/2417 0
-61aa6b7a58e1ec8b4f833a9642361bf3330f13aa33de8bef7ccd3759468d8fcd test1/2418 0
-06bb33d3ac0f221f6f4c9980e6163ce656bbda9d47dcc01f78ec36d4b1e81938 test1/2419 0
-987a7f17c6d289a5420daba24408ab46ce7656e72aba9f8cb1b5da1e6bc2a415 test1/2420 0
-2c5076156e9896cc4d2310ea7af87209cdec84923b08e52f375cc7f8a4b972f2 test1/2421 0
-8ad1d7f710e6bcb5f7ce316fba996bd43e408d5990afe9dac894e5c1bf900c0d test1/2422 0
-41653786e060828f1d765272efdd01606497f1990509f9b81cce24810b3fc865 test1/2423 0
-e0ff982e5b46eba2e1d6426ed330773a65d717d2df907bc844d31bd4214e6835 test1/2424 0
-fcdae10e0c6306236e6fa2b210b76ee679c7dbbbbd038acd26d6c1b17eb33583 test1/2425 0
-354053dd9d44bd976fd6a7b8c955ed67ecba60109078dcc8f359c486c9f1417e test1/2426 0
-789e7f73d78ab0fbcc2ffbd1ae66a0558306a2fc6e047685cc198d5f9e717e41 test1/2427 0
-e60371b90273609339d9efb96ea92a83ab70cc8d351f11cb0802e930a107165e test1/2428 0
-a67a92a05ffa45bcdb01f9b71e9491e1af640738abe2abaae3d99874f57a26be test1/2429 0
-9c4795a93a2bb4569db0d96e8e20caa1cfddc2f961fb3309297216200b1ae97f test1/2430 0
-e85164f75b79aeea2f97734267e74e072ec1c495b7438aad432da12b99656bb1 test1/2431 0
-2291a6578f678c08ed1e64c48f9b5c3572505b15cf0461536364dafd34818e0e test1/2432 0
-24ea3ff9593e7b67439e8dee49b4762f0e8a0e0a51f004848f81c3795446c487 test1/2433 0
-4b7491008158e6cfde832014f3e4ac3ac89ecf6710f6ecae87c7b0eea792e9e1 test1/2434 0
-2823a5ba65d6e7cdcce75ab9318cad4e5d7a8562dad7a28e46b2810d56b0eef7 test1/2435 0
-8d86968ebb9aabe3e14d5a8345eef6840d3802f0050448aa3ad30c0c799389a6 test1/2436 0
-c7ef4d45b44db1d766f31456e2b1a905d08d2bd812a8c3a19d1509d67173b9b7 test1/2437 0
-86574206ba6a1f5b66db5432d9650c35e2f23ef525a69b81f600d9ab3084ec2c test1/2438 0
-10392a19da01c008dcfa941a2a876701d07fe688191cc2ae0033dbad12fa361c test1/2439 0
-ac610589954442f47b88bb8879d180f0ecfaba439f9c4a3ac1aab3cbd9817327 test1/2440 0
-1aba8c772982428da0e4760f6cb10d8a20785e21c1685a6351251548ee872650 test1/2441 0
-a28372f7a0f9fa4dfc0b79e5ed80ce10bb973b7577fdf2100e7f06926656a328 test1/2442 0
-daa217eb792b981cc05710d3c839c4ca18fbdef2aa87506a9dfbd60d0079e705 test1/2443 0
-cec466254960eef9f980ab043fb05963864118a5864693fc33d5ab36487a1a69 test1/2444 0
-fc6953b423030f37366db0fb5cc1dd84b6763daf90db7939fdf67016527acf2c test1/2445 0
-4e85cee6d1d17efd3569451b888efc9e203d2d4ed7a624b110dac8fa70603098 test1/2446 0
-bde64c17be935cab89a9131ebc6a8b933212e2f20e4e27aebd3a398a8d8e31db test1/2447 0
-7bee64be95457ccec7429c4e83f94ad3f9e89c3ceca26126ff922990d357557c test1/2448 0
-55204ffa92be4909f8a8f927960cf82f48ee4ad5a06e9586b3feb36c56b1c317 test1/2449 0
-956bbf605d86f759e5070551168b54896244a8dbf5c82bf0377d319986ac1cfd test1/2450 0
-1622c8c7910398eeada0463f69b13dcc0bea6792055c7ef91e89cf1cb61aa515 test1/2451 0
-383dcef0e28a882856cd27d97d35110dbdc849076242af7f14e51cca136e8a0e test1/2452 0
-a1b4e27f87b1efe73f5241039d0c2733758cc52807485eea5ccd67a082b57d9b test1/2453 0
-a9a0926cdf9d0546ab8fee6b012f7218ce7058485231d752512e9e7482397de0 test1/2454 0
-550a43cf547914e290806a548f65d67ef53df70668a0f8dfb864cc30afc9cb23 test1/2455 0
-6f1b722ae0a0361456624d9189063d4484701ef740b95d08a8e5c4152aecd7a4 test1/2456 0
-5af60d49bbb62ca0e1e0c3f44a2cbb98a624e2aee209c2603dee96262b9fe55f test1/2457 0
-53cd751d4cb4409a1f57f0277a652c5fea57d3b441527c7ee7a17fa7d624de7f test1/2458 0
-830884c83cd15f4d97825bf6f14f851b367d59a79adb4fdeb3555f286dd2ebd5 test1/2459 0
-3449522e23e9ae243e1fb1b13dddca878af2943c04c967556120d9b3b6ec823e test1/2460 0
-4acdde00de529e1fbe511c7b9ad66720c170e35ff79b675d84bec8a30b97f59e test1/2461 0
-34db087583f4de9d2fb6320b5ffc38597cd238058bd980ef66ea280f97c8da1c test1/2462 0
-71dc3894081a77df259949019cfb384664bf432471f09a8ea014c426cd276c7d test1/2463 0
-0a8a40a00dc22bab81bb0f6527bab7c4080e8bd1d0568dce210a60efb15391cf test1/2464 0
-c74575ce2ebaf9411bd997bba2096018c2e02127dcbb8b24acf432c14400a450 test1/2465 0
-2f6cdfa0d66bb7a42518813e699b4010299ca576526e6b30fbd796216bc83ecd test1/2466 0
-16c39b20b8ca572d2215b03d4f656779ddc586d7699094007b36ca25fc919af4 test1/2467 0
-8bc2841405e6237320e733bc5d166a93739b2ca9a0e8a124ac409b16b919644f test1/2468 0
-1e0f34e595bd017964d69e706efca65b5c008f08589d248677f9893f643e96b7 test1/2469 0
-629f125eec7df2d6b255bbfa4823de1f70176cb430342aff2336b52062d96d2f test1/2470 0
-33a379e9bded2099fc8ce2a7a7d415595bb3ad8bc58938c6d798f31ae044219d test1/2471 0
-cfcc5209149d9407f6a972413fe8e3fda733886fb56c03159844a44dcd738a34 test1/2472 0
-499602a15dfe8d84bab88e20577787e07c2ac65c1e6f6977179d64d2641ccf0b test1/2473 0
-6b2b11647cb3622e52a808a3ab7308a5fd0bb07c131f226138acb01af756e254 test1/2474 0
-0be3dcb9acf6689afed90e76e6d0a7f75a43e6c951d6ecf4638c5f1c3cfd57cd test1/2475 0
-d0ecb15055116cb15724111ee692c096cf703f52559e1e62fa7ee6a5846c75cd test1/2476 0
-2660f2a3a4106f7fd0dcc3b1bde4fdd92d14a97cc3feadfa9c61c1d18833fe95 test1/2477 0
-9f066cd6162b862db492de49a325791845408aa060ed8a6082e77580237a193f test1/2478 0
-ecc9bf0080b360e9fe061f7170078a0c9e26809ef00423bb9db79d65dc297a7f test1/2479 0
-6f5ddaeea64f07d7d5743baac0d21773184d4f26fe11447c935a243d3c6b96d6 test1/2480 0
-11e8a2de12b6be16b15021cd4679360c51bda2f2749570184884d4f61b14528b test1/2481 0
-f574b944661a09d1c10bb8a09ea432cec5f3896402600b4865eaf2aa67c2e5cc test1/2482 0
-36cd79ae17832258f1baefe3f615ab18506a4d845ecd18524d22dfc85dce4ce1 test1/2483 0
-ae99ac24ab8a0456c9808833ecc4c01a85c3cbf1fa142dae571c8534297d1495 test1/2484 0
-4d60df57c37ae39559c3ea48a85aaf8558a14b0ce927b78f9cde776d56355c77 test1/2485 0
-97724a9e3969a7dea582ec0bbd0aca739bb32a3a3a69af297c5b7dc28ce22b5f test1/2486 0
-6ca74430cd9f484c74e661d61f599d7df71e01eb467d2303c44059c2183bc633 test1/2487 0
-d7f882a409f9bb45ed624d2aee4210d8b2c2bfefc8fc2f6899c79be30ef46891 test1/2488 0
-0e3ae7faae663df1b648d0c6ab0a9a7f131961939d66f8e26228a2696db31056 test1/2489 0
-a9f737884d54b249622aa61946ac85dfacf50f27417b6e97665c7f1c03476c2b test1/2490 0
-c3fc4e86dcd4187f004ed0021d3098ffa06e70238893d3fafd3fbe70dcdb8ec6 test1/2491 0
-926e9c29d87dd4ff02d62b2fd4c1587c39b90af056c70f57ce29c9480fd52598 test1/2492 0
-a24793797779fd3c5687515e0a603d60d7912ffb74a6744c1266eba510870f98 test1/2493 0
-f5f51843d0f616c9a63ef1efc266552d060c2e580691182d2c9a9d8f10e3afa2 test1/2494 0
-44982408578ceab99787d406aaa7f7d78157f542da310887fd5695e86f44e6c7 test1/2495 0
-fb4d74c6b24cb9335ce8ce0b94366a962344a61e510d0b469ce695815657417e test1/2496 0
-aba5723348e40bb3fe329936a283166d97f6f77cfc842b5bec36601866898db4 test1/2497 0
-d535fc493c19b1478321bde38cb19ddadd25d53132e4eba7771af3e64c97e66a test1/2498 0
-bff4d1733d1c44dcb5f2423f1f5188104e363075e0b238bcdcb2e5d5dbdabffa test1/2499 0
-2b778010b56c7ea2fc1a0b345a8f2dfde6aeb99c526741d9e45ce8b38f0f3be5 test1/2500 0
-ef58caab748f38f291e8a9cadff04d110deedf4fabf5bf548ac96fba4ad6c6bf test1/2501 0
-f58490c2283306c021904b2810749210b1bdc56c97cee69c3f99651903e84ef8 test1/2502 0
-343a3412df670f59a0ef699e1be121297136839a647720979ccfd75ef26b4e43 test1/2503 0
-6ac6bf47a552ba947364626d53c532667ff0656adac9a1f8d3e46b6e248d1992 test1/2504 0
-a7b1ff691d6d710876aef51dbc66bb4d8703ee9a853a4ec9eb9a5ade29158769 test1/2505 0
-906c4d987b843a8a9ca88e32bd4d0ba9d7195db3a6248d20612f04f63f568c22 test1/2506 0
-146a1666fbb6cb179bbb50a147ef0d4136e0d966dd6329762a3171c9fbb14f01 test1/2507 0
-6d95f192ecd57f367ec231394058bbfd6024ef7787f80fb24c68cd9f7b903293 test1/2508 0
-c7c0617248b0ea3e1bd698f2412173f54b1983c5b98d984d3678e154a94aa62f test1/2509 0
-f22120348aa4bafd6a00492bf8a9f81f386e64e2e2a325b32946faad9806c36e test1/2510 0
-067b3d9fea312d1ab860cbf38c9e284a6623b78e5b851948fb539c5a80c760cb test1/2511 0
-2a9fc6b9b392ff4bc337d740a6697e7a1e1095050bb4d08d9853bda390d4468a test1/2512 0
-935f08bcfe3e5577d5d0504c41d6785168d7379830bf66ab2b2dfcd5787e6278 test1/2513 0
-19adf9851795da605c22f7d9ede92511c28deeae2dac970e2172ba448d1c8fb1 test1/2514 0
-13e213efdad87ffeb109d63aa973a96982a716ef8e2e956ce42e389cbe0e489f test1/2515 0
-614dd583c154edc7a5094a8624375646bc486ee54287b58bf5b547a95e6eb197 test1/2516 0
-ad2510f28929af1db1d4452be21addf56fea068c3ca74547e673ca0bb7bb345c test1/2517 0
-59336ef15626b3b85f1c646b657e3f5b8c3b791d97c2f7c5cd7fda493adbdcce test1/2518 0
-dbc80f93bc08120836001ac73684e9b57ec213d9b09153c2209fbdae58972392 test1/2519 0
-9b7ee1e61becd4c351fd1f2b9be1c047d859cce93cdbea6db4910d84c768022a test1/2520 0
-71f5d6fce3b91e6cf35ebaababc8992a9cc7114c01dd40ebe44b70bd927d7627 test1/2521 0
-6a5371cb7bc779b451e0875ed8f8f668e2154c4223441d1c48992f50756ae836 test1/2522 0
-9a819e1d39bb77b7df6398099ab773be3d6a3a0e58ee8e827edad00f73525598 test1/2523 0
-de2cff9f685f26a877fa0d1fa9269ebc1e1df47bb68791b100a0eb6d35657b28 test1/2524 0
-e369a38333e2c168fc5fab29d2294db8696acc28f429a6c0b9121da00fe3810e test1/2525 0
-ae91dd65f06c430104f7349898377a96418f109004a21c0a5e92b0988157bc9f test1/2526 0
-b522ab831fb35012e4143868f05bbf9602d120f720b575d02374fe25292796d9 test1/2527 0
-4648f6a44ec1d5416ff7ea57eee677eae2619b891a249b09ca74be1beb62b76a test1/2528 0
-22fcf150197d77c48b18e96052c5a43982b1f641800b3d0867042d0a97979f88 test1/2529 0
-bdccc30094c6472bc61ba58d33bddcd22fe4f5b108adbff15e02ec9817880e7c test1/2530 0
-df7f02731d94f2aa8a17a505fbf531e8ec429451cca47445cfcde0e9ad1cbc22 test1/2531 0
-a0af5cd2aaa8c5b7db1b2c683be9d8fc71d666760c99c3d931ae758e05413d8c test1/2532 0
-be24a0240eb7f8d943ac68612f483181ca327241806f0420983f8c13ab9a7474 test1/2533 0
-10ff38b9832979f07aca8c4945cd5d42e2f459c8faacf9b608c61d05d1d506f4 test1/2534 0
-b86beb3dde81ff7dc7a863f216e4f37080c5d24a225c8d2e736751141002d848 test1/2535 0
-ecc4c710880598a26fc27fb7a3e7950bcc31d1721adce1009d45a43dc76aba2e test1/2536 0
-d67dded668cb3e6523f568ae191b7e21440c656c8f26d603633b91b839e12609 test1/2537 0
-fea7998d4da167ea69fd1c9c0e8074c2485c413276dfb2946359d31bebd61614 test1/2538 0
-868b37d6cdc8655d569036eb3d0189552fc1ecceed7c9cc1d37f11473a2db994 test1/2539 0
-2ae5ac2a14fda2c4ea0033152552b9edf6bdd3ebf74cc74202cc3d8a1e528cc1 test1/2540 0
-b26d8d0adcdfa1925c373f755126cb3d57b96ad7a471d293d63dfc93cb961e9a test1/2541 0
-dfe80c832024bf0d5ab6f623a5fd5e0ac92141be0f3c3baedc349aad5043f949 test1/2542 0
-d03034402971f082093ac1b743f72d2be8a11d167c4e9b7a12e7ce362000f842 test1/2543 0
-be894beac213ec9c6d6168108d6ec4a7d4b951c7ff8075e255700318356f4e11 test1/2544 0
-0f9e892347c18b2941862be767031215ca64078f2155b9c1501d341ae499874e test1/2545 0
-4178802f6332bf7fa2688205c096aca827fa426fca6267b6823c6a9e787b9cf9 test1/2546 0
-a2161a0fae79efb2949194c4dc3e9528b934c327144a24b6e2e3961ab5f77040 test1/2547 0
-bdd74e742064b1a9f22eccc8060c8637c42363107600e750e6f55e7c4395c7be test1/2548 0
-9fa51522d80fc5ada925412ab32a65fb82cc3e9423e4de6558434abbe9d95436 test1/2549 0
-66dc0a420a07f97f42c08304a9cf4bc9fed59a790add2a240525e756bbed8ae5 test1/2550 0
-1901afaab8e3f45f868dcad25199d04b11d25a44efe428169e9574e655f5c560 test1/2551 0
-6ee5a3e06480870a483acafa187bceca71729b890c38a8ca6dd28bffa85b9c84 test1/2552 0
-7152c497f369b11e5322e3dbdd3c405fcc18cb6c71500c7839de2c2e613891e7 test1/2553 0
-236106818a02ed844b19b613a5a1b93cb92c0b62a74eda45ffa19ad30dc59bad test1/2554 0
-6e78749a97818d9bc613d7e689810c148be44cd923a0987af63cffc3cde50acf test1/2555 0
-3f9ac134f7bd388fde9f86e4e4ace2c0bfcafc88d7ed8d7b17ca2935a029da6b test1/2556 0
-1858463c98b80c5c08185448e6def51dc1227f95314d359d56e1d2d9b9c82a1f test1/2557 0
-469cb17c67c0c5375fa288f43baa2852408ac13645c3cfb01abaa1d6f653b1c7 test1/2558 0
-4a3c5c28352a52d4f90702fa0bb1c9a1f30744b1b34fdcd605bcc0aa72aad417 test1/2559 0
-2b9c54157f993d661c6b963b1f77d48b684f72412077f1285b420f4c85dc3071 test1/2560 0
-c5d69f05478c744a3616d41de0c5267bfbc5abc9ebc3de9b236d29a0b95ce3d4 test1/2561 0
-7f5e920cfbc045f42ebf5f787a15ad278ccfaef28fcedde7a184e0c1f4cb5131 test1/2562 0
-1befc9112e4038d382286f1888aa9a1c9d28d8cede82d69bdf5241915dbacc91 test1/2563 0
-3fe88c0b7fc3f57e263a3af82fc7481b574650accd8672894d2aceb97440c1e4 test1/2564 0
-d460cf7a796abd59226f9a32ca29454f43e62f835a7a48ec2be8d641c47273ac test1/2565 0
-68357cbbf1de3534d2d2c7a2f9e7a7b26cc787310036d63e6ce97a21a8ff102e test1/2566 0
-f9e4c1b42a1664a72c77cd00cddddec2a61887bd7f0d9ba4f289bd187dee952f test1/2567 0
-20331aa62aeba796140355453648ce2579c41df3be33aa931866bc72f0682ba0 test1/2568 0
-44aa0c549b0678d524a909aad280f8235f474a424858f04fa4eb3beb63bf170e test1/2569 0
-0da71175bdea2a1e158a5308babd42620b2efb799af6b8b60935040d6d360c7e test1/2570 0
-d25791a63a29c369225b5a180efef7507ba6772a3ff55b93a5042471072d8dd9 test1/2571 0
-85093c866c15b181899242b2863cfad7198c462220377e5024ef409ad846ccb4 test1/2572 0
-8afa021e26b88ddc1640938428aab28d5223e041ad723b9250440134370faf42 test1/2573 0
-e0aeba8eb8626af97c8888491060094e89f856bac54020466094803c135f9984 test1/2574 0
-5e059090b044e38b0ee9f7f2a038e77f64989d237514f557e9ae9bca1a092d51 test1/2575 0
-86529154ed58a15fa6b9a1541d61f6288fad342264ae61f930a2399a4d2b14bb test1/2576 0
-f5b37c7604c03d532d16fe9eb0a11c6775c4e917fb4a063d2d83c9dcc4d6d4f6 test1/2577 0
-e821d60cba07a4c5fd2ee58bc58f421671fd99582e84021b5e9b6b51ceb35977 test1/2578 0
-db9bdaa6222dacc63916d91b76ab7a8ebe11325099174c339870c4f89f89d8ba test1/2579 0
-1705735da6753c91803e003af4fbd47d1e04f00c7c028d79356d5f148ad1e0d8 test1/2580 0
-a81f6f86054dc5038da00d6a19b45695e3e162c62759c696dedc334a0764849a test1/2581 0
-dc1349b0dbbb06f109a7d0552b36b42e9d02b98f16a05e6365e57fe7586c50ef test1/2582 0
-7480942e415e89e2f9e7cb39b47fe098871d21e67b4d8ef5011cb49770a382cf test1/2583 0
-1f90792140613aeb30216351fd39c81d019d785fe0b86406e95f47ed5d7cef30 test1/2584 0
-d4be82cbb9bf3872fc3361bff5b176144f11bc4331a94eda455169b8bce279e3 test1/2585 0
-4f41d215cd2bd2283d8bca7f4918863c500be9334bddef5ee7734fdfe2da23be test1/2586 0
-b800e393a322693b5de86fe05486f4e57fba68726d94cc04d090b184db493e9f test1/2587 0
-58ff503b9c148a5d4c97f58d48911e3f7d56dfa5b7e5dda52d3100f7cd455d3c test1/2588 0
-440a847c7ccdaa4c9fd53e806ad424a36b5dc09f86f649c3d4509afb9d2a6c52 test1/2589 0
-9dd9fc8f387932a03f42b04e363bbcb744675716ca93fd4ee6a3ea187e14f004 test1/2590 0
-5a6c333f77534afc1033c26ecda96ba9fc6ede4161e85193ffdc6918ab0e5a5a test1/2591 0
-da5b5ff8b1e42aa0243989243803027b2bef832fff5d4abd7f90ee58967b450f test1/2592 0
-2d4c63c06f24ec40564fec83adedbc9f97adfc42deb40b0dfe3140a5d8aaaf05 test1/2593 0
-adf7e8a09037a6f214d46b744ac00a809fdafb897750a8517a282b35858270df test1/2594 0
-c7000e796aae80195c7e6925385cb1f90e4b361e626bef95ce73c8f65844cc6c test1/2595 0
-80ef6af296fc3573a3967cda657d94b2d2cc40c6943ffc9f88706da571a1cc9b test1/2596 0
-6b8b28c92cef6d8567235008a40277e5d6978eb09accee06e8cab75c1e43e680 test1/2597 0
-1a084399f4a47e965a7353248854793b5469388de7971a695a08fb28f9a7e417 test1/2598 0
-d3be5898b453a959ad0965401556d484cf96897b82d0c601e35b6f6ef7f22e6c test1/2599 0
-aeb51840f21ff92f628f09caa450587f6696b84b772505eccd1588e72baa0534 test1/2600 0
-75df14f569ab79fea8e876239f8a4665a42b2925d939c89eca47bd1b38f6fa03 test1/2601 0
-ede645f1afcd72b9281136918e07ef92149f63a87455fc221e248eaccd615b92 test1/2602 0
-1f2ad6e876606d908092fe87f5fe7e1a422583e1d7320a6fc2ec47f65c3483a0 test1/2603 0
-dec530acbeeb1a9093b7d293a72c07b20c905a00e17bb0b2cabf9f7dbeeddb5e test1/2604 0
-f9c4c3f43430e84cc3968a393e74131e9e0c617a10c12906cffe8ae73c380f95 test1/2605 0
-3e90299c7d0b50990218b0e5a929e6617b3025988386364a93d32a545c44e960 test1/2606 0
-c4a18d255aaa53d32b6e5b4f72c42a0fb08d5f130011acd0428807d1d2b90038 test1/2607 0
-a604283de549ce9fff597f8019d04cafb083882a64a329ad79905ca207030f7e test1/2608 0
-59faab148feceef49fd4c419ca691e08a14beda15eac58f09a8bc1a9c2530b83 test1/2609 0
-959c713c6257d485349181315569ca25ec9f68325ccf9add79c2273e26fe5cc3 test1/2610 0
-e137dff00155318da845cbf0e1923d53877605f317f625f86e358735ac525c01 test1/2611 0
-978f975e2b8bf0373a45b08fbeceea38ba4195b919bb7902d4d3d94f36949742 test1/2612 0
-f8e3f8d2989beca09efbfa4b0ede4475438afcc077fce6ebf218f873f09f7235 test1/2613 0
-7ae1418f30048b47aa06ac9ad4bd44eb14a846fab3b277e12a7af406c924e7ec test1/2614 0
-4551aad2002bfbc5c048449bbe090115968847e9ae8a64fca1a0d750b35c67ad test1/2615 0
-5deeda89c99ea75da963ebe78ba068153728b924414e4767994281c699aa1696 test1/2616 0
-ee516a35bdb7dda3cb36fb88e3e22bb71c9da44558029a0625b87cd0806a7c40 test1/2617 0
-70c3a782784d4a8e1d19b6e45907894ccbc671cb42f95a8f589e172b738fe8a1 test1/2618 0
-b6784b35d030716817d2e9d132d89ec49a5d40aa683b1c0f4e142357bb19d9f9 test1/2619 0
-f11e996b113c67315948e98716e347e4cec95a7fcc5013d06ca65a5c3fbbed50 test1/2620 0
-d83c370d132615030815745e7296d4f36475ffe4b3688c6e480c7b6fd0dbf452 test1/2621 0
-3d14750a7431566ac92eab9db743457dc3fae3f90d2d2a5d98015cb2366b89eb test1/2622 0
-53a1edf54af3ab247a316f20e4c410a50ae72d0867a4bc398cf34feb1ff258a0 test1/2623 0
-ce2f6cd957a51cb357db5115a636e2fdc0ae28e4977eaf35d84d25520e714727 test1/2624 0
-689ff51db54aa787098fd6fe108a93e2e047940d87133a83f38c45c619151c4a test1/2625 0
-e04b6704ebe46f85fc97148bda1320afb49dfdf6b12e2742e2182d04350597c8 test1/2626 0
-b709ede581f63362a297a00d87ee7a75afc287a0a3bf2cd2c953a9536fbc9d2f test1/2627 0
-a5e6de32fe6c9647d89cfc0ddf9ef9d996073829b98c6e8908cb13bda539fcda test1/2628 0
-769f4a92d4a8e52e72a7d8e0ae0883848c693a23f020b608d1918206ec191931 test1/2629 0
-ac2fde4cf2ec3169066dcf33b05e8c2fb1fc7f30ae6c4cbe60f889caee3e294b test1/2630 0
-50d473ee6e0faf16685988bb6f97007ee41c99b887b2e86e8567106ea3b848c1 test1/2631 0
-d3b1cdb74ea1d30ead937bf0dbed8a0e7c77e25c2cabecbbd8c446a190c1c5e5 test1/2632 0
-c80f793dd229e605979ed526ebd05a639d6175fbd352ce65234289a8b722bfa7 test1/2633 0
-edd42aa56c61ab42e93cceb8d3244d808da21c9fdc778ea8c4e49e395c685ada test1/2634 0
-9131982d3c7963d4ec03f3efb9c0c48da71a31581a1da7e64abac3e4debf935a test1/2635 0
-7b1fb748375a63297859ab876e9ffb0403ffb0d1051054cc63d97449cc005d13 test1/2636 0
-2067154697286dcc5ed79315e9b5e006b4cdf0a36e9add2147e4c15ed9526965 test1/2637 0
-7d4f7db629b86efc08c862f92e5f907c463e47aa62dd48da092b90fd1a9056e4 test1/2638 0
-56be074866fcd9015f59f70366fd03126bfb9025f5e044b7f3e21d4c98bd084b test1/2639 0
-fd636f79ec0c89c222775b258c2d9d53ea9c5f0e73978a9df00e3396381573e0 test1/2640 0
-e52698d8433e2d064f2cb3d4c25200e89db170bd79386efe188a8e8b67f865d9 test1/2641 0
-45875db8a1cd318ea04f7a311faf96c23b97eefb0a8ea13245a9f570f09d1651 test1/2642 0
-57fded8a8ff9e96e37cea9a96d97f03d6b42fb44b631658afabe066cced41c1d test1/2643 0
-de5a55cd978e90f40565125b41cacc480a941747ac14b8cc322b8497b6beb893 test1/2644 0
-1e1d47fbbc89cd06ed4f36b1620bfc695f04681a383248d312c1e89a4e632b7f test1/2645 0
-62c84612f92dd7c6dca8beb05d419e7871dc287d62ec93205ec2bed8fb279b3b test1/2646 0
-ee83a40340ccef3debff281f872265de1654f6fc8ce16c26b798e08125efc236 test1/2647 0
-979de8e83429153f2894f24f7b5f0587a5062adbd6c7c51f9db86f9f2745c086 test1/2648 0
-3eaa83a4deb540c2c0f24d07749e5baf629bff655b8499dae8fd3a8f5f1c8573 test1/2649 0
-d033a76f7df198b3c414f94c7c594df3da83823335dfc468226c50367edc82bf test1/2650 0
-c224af2bf464045316df3b4588a4fccbd733bacb8cc71e53a0c5ca95c1ce3c59 test1/2651 0
-12d83ac788b102d1a4eadd3f163cb4e29397d59db2c0263ad03eb9d731015826 test1/2652 0
-a762bb6a860d9d58574f3d354f44e13b75ebc0945c4d645421cca50ef6487f07 test1/2653 0
-6999d04374f1a0d9b9b05966d7962288744929959e9825dfcc45a4dabd97057d test1/2654 0
-56b1c9e8489a2ffe532b6c1462a3a8c22c1391f4bb2389fc04f6dbadc429ab10 test1/2655 0
-92f33ca0c58e866b5df4ed6e65a4959001ff0c1edf7ddc94e28f3a765b3d25bc test1/2656 0
-f5cde198374e97e888730b0a32e3501e5a1bac8c816829c24c6444f7ee5aea9d test1/2657 0
-b4c9afeb855bb9f630fe8bdcf939d781694d02aedf7cbd1a1824ed0be678b167 test1/2658 0
-6bec70eb9222f4b6de05ed28fd670a8d9ee20d41298a7c7ae41fb279551a2842 test1/2659 0
-ff1b5b16130c81a0735ed96e90f32079fe10511a5b7966fd6619ec5a5b0bc21b test1/2660 0
-a21872fda210e1c11ef51928ba8ed0f13dc539fb2136a0238dcc3c0cf9600406 test1/2661 0
-222b1ac105525d8b3e8ca260590d9408abf414de10da6b06e437efdbb6797db2 test1/2662 0
-d597f9b638f8394d8716731e0aef376cfbf148d334dcb27a4b0aaf97f2c16ae2 test1/2663 0
-5788d35217e0a281f0d5d788765d2ae393dde3243601abf69e9d9178f9d3d8b4 test1/2664 0
-9523240de24932826d1637521ec2dafcecbfece93a37836fbb432753520c88d1 test1/2665 0
-03cba944c72766f53d5096919897b6c5cd389b1b13d06c50cc8e7dfa37232554 test1/2666 0
-7efb8d8590e846d6bffdfec91d7d310b99fee8d9a145dfc6ebf3e690ddd7ffe5 test1/2667 0
-4c7900fcd1763191b15071947a9591dbdd489bd7f6e9b93388be35bff0177c9e test1/2668 0
-058453bd6f0ab66fcc6d414f01d6d6de6a65cec591413d2fb71b2c9355894630 test1/2669 0
-b65046d1300481c0c87cb00d9a777efeaf1165b939650850752fd56cd049370d test1/2670 0
-72e8efc1d8d3dc9079f4f72339bdb86d19cb06e8705c2eae54c92b78b199518d test1/2671 0
-6bef39534de0075b1e6f0602b6c6581eff6029155846a48ecc9b2bd0e3d9be64 test1/2672 0
-724d1ac3f19231841a87b6472fa192c0904b394821fa4bfe6f49dc302289277a test1/2673 0
-2c8f131f7f87be27eff1fed447c0be36aa8fad210c1a4f5184ea726e6c90197e test1/2674 0
-233afdc8e6c58d513cf1bdcf7c074f460c6cb2f5a03d6a48ae26398199fa1983 test1/2675 0
-1ec9e28acf9a4d407cd47e3933026efe4541818013309dad184a7d1b40c40274 test1/2676 0
-fcde01a335625de61a3507b315eeda9ebfd8bc5f4b91131364e97aa9301d721b test1/2677 0
-2511e253eee15ce87cc868f7cab762b77831123a65ae2626f7f95604a333e14a test1/2678 0
-958712ed8e0368faa673b547ffca68955a35fdfbf7c32556f8199eec84c50276 test1/2679 0
-48f468667444cb3ad8da3f2544d0aa49237546c41a3872c779b56e75f4eace59 test1/2680 0
-1ebe6030cc1ede1cb846b1c789e9ea302d307ed1fabd60158335dee2fa3984f9 test1/2681 0
-7534112fedd80b9f9e330cbfc0089b8ed03cc481c724f14a9eb5db38e10e98c6 test1/2682 0
-0868308d650afb3998070b187fb42f3c87a510e95c868f686efd67650abf33aa test1/2683 0
-99048c6dcc7c4ea0542a57e5377aac27167a56ff54ee28a20ea284d1cc5bbe09 test1/2684 0
-a403200272e2bb97a73c0b43fef53df5240521792cb4d424713b1c2d8c818464 test1/2685 0
-d2ff826a1f7cbd24c40fb50a819b37490ca31af8dfdc94174c16055e64febc55 test1/2686 0
-6a9af39108789ab73870afa2645a01f147ef85d45680030d3d065a54779a0bfb test1/2687 0
-0566619e5c095768f1ab36fd2b8fb4f974a841b9234271311f951837741e4f05 test1/2688 0
-ad2134cb7b5fe2a73ab3168cf43d0b497655e58076f2ca34687685b248deaf7e test1/2689 0
-60f0a8e61e3b6585b87ac7daf614eab7ab0d6ba3554ac51d10298164f9660d16 test1/2690 0
-2735b8132215bfbb9f5e5ba78ab02d46fa9a08f6878a433df45219f338515412 test1/2691 0
-916d702a7bf5835073d0f15101a9445c536f4a65b664cfcb71b6bb9abe3d4931 test1/2692 0
-dbfa603a22fce058932a89f15c0325115c9475d354da59d5115b0fed9973b63d test1/2693 0
-53e57f96e5591f71ccf92bd3af3bf0290cbfded399f18bce3b1cde77aaeaa74b test1/2694 0
-56995926e7e6f3ddaad6b60da5bfa464ada75eadbe69b556714ec421933a1d68 test1/2695 0
-2b4b77402caa67e6da32f3578d513b3c7f2df09fbcadb1ad0385dc73fe198da8 test1/2696 0
-c80b4e4dff2659bb4e4530a2d2febc944bd2022626c25ee43d539235991dd289 test1/2697 0
-89b2aadf363ef26d79ead65461f4c16f9e7343a7a14d40d338b76f9c439dc342 test1/2698 0
-fd9bf6e76a7b97ad2e2d588662746e92a9957fb8184e9dde67cb840b73cffefa test1/2699 0
-1b307c670076a7fe8e643900b1391e50efef80ac228559e91aefa9f6ef868890 test1/2700 0
-0fcc0ad6bcad924ca70d42bfe2b31c1ba0ff57ee70ebcf09a080edec0e28630c test1/2701 0
-b3f469ebaf2db6d71ea9ef92656e8f2b6cef1f245746a17d5b0468b16e2d7050 test1/2702 0
-cb4321050b3d8de90d7860d80e25dc75ea5404082ec4d3e07a9c5d0668121877 test1/2703 0
-7a5252a5df3218d5e3781e9df6eefc3330273587a6357d3c9327df7a2228de5b test1/2704 0
-ffa3f379c8f4e8902068218fa859c666b2882cac57739b0e788ef26195f49267 test1/2705 0
-8d96a594ad8c72b5164af7f8935234aa0014ed7d5c7e0433ba23727faa52be69 test1/2706 0
-e93bc9daf5d932389f2a8d24db2121ea5421c3ac983b0429b8596b6b1170319b test1/2707 0
-d2b1f9e1b7c2f82c7cc26ebae36a15600742ceaac35c2da8246fbfca0c18c250 test1/2708 0
-f583bcfd2fcd62fabea7b1f9d40f28993dde568e9e25a3a2f7c0ace1a0a76d19 test1/2709 0
-ecbc43ef9300e1589a0d095c6e3d0dd9abb7892c38a0a33f4721251ec9cb10c2 test1/2710 0
-1d88a23e7ac64cef925a57f042f59d7e93e3c7d7c7c4c1bd206e1fc2c4b3fa31 test1/2711 0
-b979e880281bbddaab2e6a1bd684ea37146e4bb35369b3a9502a5da3279a6619 test1/2712 0
-c0e4eb4568904ad4270a080d8b7e9b1cba08f0ad7ec75bc25b1b45e714c0aa0c test1/2713 0
-f03dc6fa2732c5946f70b45c80d0912d8ca8520ad9256cda029f976b6604ea70 test1/2714 0
-97a9f36c9dc9a10b889643348cdf9c851b9eeda92e91dfb36796146ad19ec860 test1/2715 0
-d7fe35a4b544245098ce0356531524ebe15d3ea99a2ece46aadd7938ffbd538e test1/2716 0
-2367cc37222c46fabdd517953cd8c90fe3de2dd13a20289f4557af6988134dbf test1/2717 0
-df57bb54b0fe7ee254bf9463d8c304e6f63388f954702e9f4d909dfb9b08e8d8 test1/2718 0
-dde9410c5b8de527e80ab3cbd470599f581370b9114c742846f194706055bf6f test1/2719 0
-4c65df0c35b0506736c70bba74be4668376acffb58bf00a66a09b1d7251f762d test1/2720 0
-068d2ed00a64507a115ba03c4c06ccd3e6bc76cb77c1e3d4f278c09d92cf9358 test1/2721 0
-29487197526916b219f8261f29e37ea5caaa3a910f318d9c197297ecd71ba571 test1/2722 0
-5937542e90f1fcfa0b9d443f46c0245d24c4328ee32abe42a8ec8ffdb5a338a9 test1/2723 0
-84335a191914666d79044d9f99034b128572d16dd1b3b049531f34e5fb0ec8da test1/2724 0
-6a96ddb7b8f8dc66f3dc56f5ddbac111c0b19b58de73c83239885cb316e91f9b test1/2725 0
-adbec1a38804f6de1c75c5f6bbe783d0b1d44caf17d29ff0892db3b86cc73133 test1/2726 0
-721f2364d865b73032768397b13aa610f67970216212b5e27d03f3afd0df2083 test1/2727 0
-8261447bbf8d1111b88abef54d79bf3eb186ef1afbc397b687d69edd078ebd0f test1/2728 0
-bd08e9bbb24b148d51dcfac4d17f4c555d902c89d30eaeb0798c414c32085578 test1/2729 0
-247080865d74134e1e8621b356c50dcac01e245cef4912d6f6cc13fd53ca2dfd test1/2730 0
-e66db873457c7077bda396081dc462bbb4f8c5fa37ec9abe9b0b8364ad0167ea test1/2731 0
-837bf596c36cad8a5ccd7f37d88105479dbff59222220c915b232f838b19ae22 test1/2732 0
-2da8733bfb643b45e63e02d159115097cc11a13550d8b00ece734981daa773da test1/2733 0
-c8ecb6e1b53b5b15e689edf18f10b76056504fc7405606fb647fd52f8c67128a test1/2734 0
-9b9b5b36b026de625b9a4ffa6f5a77cf8c99f63cf9921b75b170d0f734bcdee0 test1/2735 0
-7151f4da57d4c108da4de89b264fbadcf9700c5b9f72ddec8270abde186b7e7e test1/2736 0
-b8c017aac0f91a7eb3815271f0ce56fcfa992cd2bee71d37355ccef4f4a4c4e6 test1/2737 0
-e63fd20be5465bf3b30e0585a6fd2af215906d130ef02be099020a5a904aed77 test1/2738 0
-b0173d1cdc7578b8755f831d5bc89a0826acafd0a5e1c7e7963f201cc0721c79 test1/2739 0
-f55191a518e7717fd294497a619ce742eab8f926bf86b5c45c46ca780e739533 test1/2740 0
-bdd209dfe960ca0cb37c104494ff09b11d3091235529ae371efdc3e9e006fb89 test1/2741 0
-dc87c01d17c9eb17f848255253e0467a9823c688118a5b70afde7c00c317bd59 test1/2742 0
-3ee0a88d08b1980ff7252904566842045561dea1471c85ef25b3e9b7ed5f9201 test1/2743 0
-b0a691e475d31e93bc5b7734a750e979f06d9b937470b573fb409d1d76366711 test1/2744 0
-06671f3d57f55e69c3ff808e80d8cb782bb1a85b351da71b622ce3d5c39c9c47 test1/2745 0
-254d5aa681c73090dfb40def5c43fb403a947dec3f401c723e0d8a66e5d53892 test1/2746 0
-a491d1e60f56a22e549024c2b1c5087b34c8d8d180dc2deabec5db9e37afcbf8 test1/2747 0
-2819f2773cc3138249a33169777d76ddfd0f8b10b1b98a00e5421d5a0d67d107 test1/2748 0
-249f4e9ed9d77df4e5db010c56e45232d024ca640dc99c4347998614f7714bd1 test1/2749 0
-53bc66337856e257894be40f306dacb478d02e9bdd570ef1f74fed854b02b1a6 test1/2750 0
-4346d0ddb12f4bf1acff1357366f6b06c52721cbf935040bf198369c3568e8ad test1/2751 0
-762a09192187f117a8f7450c0baa9bf3c5006eacba0f16e9eabd0146711bf15a test1/2752 0
-0d92124b4d72a3e13b86f6c5c4342fb0945e8777cc30c355bb75b311697b6930 test1/2753 0
-6f75088fb5d391fc98e2f0032183a2d7092873dd8a016af45c83440aa851b1a6 test1/2754 0
-166e51319c115c02320faf4beebdaf8ded62659c414f1faaf30a732ecc1271e6 test1/2755 0
-563f91ee9a9d42b59171d989fb1eda46599d3033c14a3af8c4e7d3d84784204c test1/2756 0
-626d16eb8c89355316f7fa68e207e3bd8be6471d750569ae081486330a30c1d9 test1/2757 0
-6c76b83a5aadeb87b71ec6150d8272707963eace6ac80ecb740dd4a0f9f4e317 test1/2758 0
-1902ca38727744c5ca4308511ac35cb62a966076d435f0a2ae89ea89ac9b7bcb test1/2759 0
-8ae330b5651ee1387a59eead34c3d14f1341d5f8d4c6565d0348edd269e86d32 test1/2760 0
-f4dad3e97d12b358e2178c92eca1c84b1e1a2000ce7b35375f6d5dcd4fae58f8 test1/2761 0
-d27f3c0ad17fddbb1f374ada0167fddc76db17a80991c3ac4528fca93c91383a test1/2762 0
-bfa2f7e0ba4d50b4729d38b02c867655b5597d4ef771115341dd946c5460e5f9 test1/2763 0
-bfe3e2270f28817b82d1560e1073915537078582ca5ede64d87e8deffc37dfb1 test1/2764 0
-ce5f28c43449082f0fd4970f4b22bc050d822f82f0c06464b64f98bcf5ae05a7 test1/2765 0
-3d7feb160c2264519ca2090d51dcfa7cf87334de713acb95cce4ed93095b4203 test1/2766 0
-8e614681a8e308a61c661c5b1b7a40e26bcf3d07fa9cdeb1cd0fd19ecfab35e2 test1/2767 0
-e098e11351ddec9064424724ae0e7f1304c5d1935692ee2d627fbbd301fcec45 test1/2768 0
-3b0b856e1738e22c3aa08522476bdb88f30259d02738d780b069ab293c018f2e test1/2769 0
-43d6419bd978f32508c6d9beb49b6acff0a7bbb81430863ca83c37176f2239af test1/2770 0
-2b707794ff138d9995b33e1871e58fbd94c5cba44bdf5d0768e9d627ed259e8b test1/2771 0
-28c6b28f7d59f9485c1ed9739ba4cd9f3e78f99c9216d529e5a44f2c9a98482c test1/2772 0
-6c6da015baf87d34c377a14a3692b95591b38e29e18a07aa626ad1be71a6ae05 test1/2773 0
-a173536e20bea77df4e52885c33519c807cb61ebed44ffad188de74e9a4e0333 test1/2774 0
-856907c7e81380e79669b2b585485d759a0b5180d7f662028b1315f750ce49e4 test1/2775 0
-3b2f6d3fe6eedeebb545de74aa5359c8c1bb52ec4672e25b18ca95c98c333c57 test1/2776 0
-54e143dc7235cc659d9d73478763d0412397259cfa76208dc2e685c4745d36b9 test1/2777 0
-e3b8acf4d29daa138f00b2d6522f90be9d2d6a7d5edcab47bd5d07e6925ad569 test1/2778 0
-0a368be2eb9343f5815b2abacab9402ba2bdcc280f50791d558bb3b02d279126 test1/2779 0
-1b5e1b0405c2e60ff7a546c629f92bfea7af2e260788106cfff75615803c350f test1/2780 0
-7be67cddd5a04a030275d83a82557b3d4b1406d8666699d092e15aa9392c9b6f test1/2781 0
-23fa1831330d7c1bc1113b7a5cb8b6bdad3adc29afb3c00af0b54fb362358d8c test1/2782 0
-04ab385b924b44e2089f008ce7d9d51fb4922fd487c9f31a30b4beac28a6ba20 test1/2783 0
-2541d0efaa04cc67510404b142f0445fd9020c5cd740b561f5e7b17b6c748312 test1/2784 0
-774739f36525e002a20ba9771479cc0d99173ce7ecdf5d6b5def20042d9bdf6f test1/2785 0
-d1ae6b1d27dbebd56150da15e9a079ee6f0c0472fc05a8c68d7b7390f837d29c test1/2786 0
-54d06f58c6d694910b3a792b8505651b1927e156d02dfe1c8d284936bbcb5e37 test1/2787 0
-020c88ca8000285074b8943e878940fcdb2bb1efeab59c2a27686d5f48bd5329 test1/2788 0
-44a1f3bbfac5d534e46b2abd8b080375d85e8e9dee35952b633014171e1ecf6b test1/2789 0
-f0e1042a16471aae14f7f5e155a80d25beccf86e99b3ffddd095b61fc26acc6b test1/2790 0
-1bac752e66ab182bccbac1148af675928fcab37fe3a1227fb0af2ca6dae8ad97 test1/2791 0
-e1ea734db508a6c87d0b743d4343588d063e2b25d11520ca54cae8283370de6e test1/2792 0
-60166301d140495d61f1c6942578fee8b0f09943199d1da80da311bdf0f7ecee test1/2793 0
-b9ab514e951977831bb8fc0629edcfb6dff7543cbb2280e8ab32d306616c50e6 test1/2794 0
-e907538330f62cffe737dc9b889d507a5cb3441ca21ef98a021de9c8208a0c2c test1/2795 0
-408134e380e511d9344238f1ed457e6631170f558d222662416a8770d3a2d942 test1/2796 0
-de52ef403fd781f1de82be3b219a07de4343cf8c4d29a5af95a74da6082caca6 test1/2797 0
-fa99431bd1847b4a5ce4f88ff77747e57c1a16af46e223c613e9472d2624b898 test1/2798 0
-d97d1b798ddf2842a7c5ac7d78a12537dab27d15acb0b3dafcfba5f89ce49c97 test1/2799 0
-c933acf9fb14347b5aac3241a0ba345d244f203a21e21b684afc47d210f36710 test1/2800 0
-0e6785a5da77e6acfa84b5aff90ef6a2066583d56b6a75e65fde0d4f0b3959f6 test1/2801 0
-78495d6af176c87e9403d1e227abecc1b48975cdcaccf6bea0c956447296ba88 test1/2802 0
-f01360eb90567167ecd3fce3889253c793ffb3a3809da91288efb3fc262460cf test1/2803 0
-0925b51ebf24b0593d5407f26e4c898dcfaacd7f612c02426bad9811189c1cc7 test1/2804 0
-c3bad171e54ccd54e29ca095abc5ff1e23afe571ed37134d29fa544beeca33f5 test1/2805 0
-839bb33da65182cea98e7dfb371b0b70ab78b92c9e932d9081840d443af5e2da test1/2806 0
-992c5709d26a731cc4f361d28e30fe9a91e1e7c2f2001d07ceaa5f6c652f5eb3 test1/2807 0
-53948bfb8c160b3e8ca1aa4e88f5b378d1c4b7953f9d41fcf5edc8b4e8ca4f88 test1/2808 0
-5053cd6b087f3dbf15eff0b772c66961280352c6b903da4c459d70b44c5050cd test1/2809 0
-083b8beb46c944836fe67fade2a652aa478acbf27d982074687afef531fcad26 test1/2810 0
-e2efef66749b799c0c48229dcac2e6559d00cb092525571817d3dbf12a14f55e test1/2811 0
-d6d2b6c9964f435e34c728d29510109cd8956b2ad0425be9e1475dc1a2de73e3 test1/2812 0
-77b3cdb3d6b6a18899b4f2967f5544d684b19779554b634d3bc010361c641c2e test1/2813 0
-65e361bc6f4f6e163faa4fbe1307af1511b3c229a891bd33034f005cf7ec3d4f test1/2814 0
-9c05a66ef663f73d0eeec2e150dac656da117c6a344e1121aae502e83be2aad9 test1/2815 0
-d374144dd06d0a0902c44152e90788836ac470e5c1ed889e79acc286c42d18bc test1/2816 0
-405fa95b7a2ef8a5804ffeac06f74a053230f600bde58e2567e89c3b7e25f006 test1/2817 0
-e73595adab5ab8a8fd7f6397560942844565a23682b23696569d346e134651f9 test1/2818 0
-b848bd518dc93690a45a1edf2ac0146863ecf23ecec09062dc6a59c614b98683 test1/2819 0
-10bbbbf0f9bc8d82878cff3fb8968eb800a43a39f27291e8d1d63d1dcd53f197 test1/2820 0
-a90df09df42883dc08bad2de757d7c76aafedc1ff958e04bd799055d2680e586 test1/2821 0
-2517b444dd840e26c5d3e73406a27a17ce82befa1ca45109de63633ea27a07f7 test1/2822 0
-3565124ad54da806395bf170fdb5a1760449eb71e4fda0702a75d5734a3818cb test1/2823 0
-545f4bc96398572f9bafd8733224e0916e8c2391a68c5a3319dca82cee786b9b test1/2824 0
-69fbba40b4c151022207eb85297833834924e6df73fbba056528b857ff1a29cb test1/2825 0
-82fb44afff495b00ee99650bd414785bd030e59b2502db475f96c8294bab28a6 test1/2826 0
-380c2673b7c495c9e21d3b2891df197d32a82c03ccddf5b410f560d62df8a043 test1/2827 0
-2d631979aec8ca003dc609dcc8b9c5a4e94a5c8e6ae11be1c10810cb707e4fb0 test1/2828 0
-01adca85e263997fb00a79da16916cd1386511e1479fa49ece67a5cc93804d18 test1/2829 0
-292918ea9572aea300bc8e99f29f201e62d2e770b5294636b15d639fa90eafc0 test1/2830 0
-384eb796c091a7db47ed5512413edd4822b018e0e3f4ae9160149ae274df0b8d test1/2831 0
-072b56a55a44268d8f9a281fca21b2058f2316aeb0ac5f1c5f0d11464f3f9005 test1/2832 0
-f1088639cf58d6448442f9c66cff895f21c676e3df51129d98dc75bdaa83c950 test1/2833 0
-d67e9483962293944f61c64eeef45c85a88c6a6a001fdaa20ba288fb7ed3b81b test1/2834 0
-4121d1448514bf26f59ded75d4dbd49e4e07a91c262f4cbb3960123ab59e880e test1/2835 0
-c2f8d62b9fd4198a1754397b8323cd463cc08c266b97d450626aad9ec39268fa test1/2836 0
-85899bb54bc996c3a1cc87073d70afd5292c96bbb17052b7adb3edb174e532f5 test1/2837 0
-2ac782b7fef6b7a375069acc3f398b70014a01c33fb733faf66fc4885864930b test1/2838 0
-f7e18b2b565d5169bde4fd8b7ade9412a3c098379eb754758833f824eb171682 test1/2839 0
-019c32c27a9c2d46b8738e4e39beb66a40f491538046a532c734e037092794b0 test1/2840 0
-af5a5e7edf8080551bfaf5482cc1102e3fa0e587621c8fb17f82160b20132b9f test1/2841 0
-a7f8bf12a956b01e1c94bed5c7ae556597c3fc387ea92160042d039583355f32 test1/2842 0
-48b4cc523441bd6e03b0c52053365463f76a49beeebc6faf6ebdfeed26db7236 test1/2843 0
-5bc6dfcab6356c8c3505a6ee4d5154580b99b0ee56331aa11618ab9101df45f3 test1/2844 0
-fcffdcaa6fac8219a083d16f751357b50ef45bd8e451095ea7e15fac70ad4b66 test1/2845 0
-dbec24bcf178b405ad8a234613eb3d522158205b14d550abb53edd5bacb0d6e1 test1/2846 0
-260b360df02c65885f6b655c63fc029b00650239d1f05017d5eb0955faf25fcb test1/2847 0
-ec295d4c4674f0e1592fa54c692728a8354eaac80b6825db165780f15325e72e test1/2848 0
-36612898d09267b076cea4c9ae8b3b8de9ecb808c81d4d75a46ddce310122d10 test1/2849 0
-4f8c0f2242625c4720ab49603e655633e21485aff5b1fd481fbfc865901c60dc test1/2850 0
-4847c377188e1209cb8b95c899459d8542f165985cc2847a63d0d28ccb3c48ce test1/2851 0
-92e70d0d27d373cd4b3d92ca1762af9d17e03f580c25215c8157db228c66c0e0 test1/2852 0
-cdeaf99d365d46e148105ed3a6a6f67063271e5e602c6c8df69fd305e75efc18 test1/2853 0
-a7694916a18aca2d06aa7da3d674e22e9cd255cb2bc3a95152594bdf83da4c1e test1/2854 0
-d84d4ba36dd1a0cc786a6ab62329be975f8ac7a328f5771d0f4112f0324d56a2 test1/2855 0
-59341229662ea779d8d63cba45d5c3715fa4c33c89d54e1daf5b97da54fba98d test1/2856 0
-798bc95ad41f69192d2eae69c0ec2fcca50c1e9d97103473bdde3942aea124ed test1/2857 0
-cb2403e10ee67f42365b04dfbff267611a762bad418c76911323a8a628933880 test1/2858 0
-46de72422906d92199355d8d09224de13fe37fec01eb16a5032942fb7136df73 test1/2859 0
-66b3daeca3efb9498d21139cfaed05f625646ca62617d29cbf221fb8265b95d1 test1/2860 0
-d52da1d6b89d8659dbf1a7859ecafdf507aba21e017d1d1297c82280b4433838 test1/2861 0
-9b730b0d51f81fafe1674d248d37e58f6221ffea87b52735ad5fd670a706eb13 test1/2862 0
-4cd71e83488c8110c91a8b777e77766c70f4e8f6b75481798ecdb5c87a441804 test1/2863 0
-b49f40aa3fc9559c4f8c0c6a5e3afef74cc2e021e98d4bbc56b056a22bd33da7 test1/2864 0
-7de6145c104777db6292857431c5af53b1ecca0c1669ea974b97a313016f2fa9 test1/2865 0
-27f3592790b591c2738ae6a5f7b4d39f80e5a61c3c20614600a0f33e58371f7e test1/2866 0
-99ed7c6ac36358c24f06cf03e4d7073206716cf72e3185629e19aef34f4570bb test1/2867 0
-22d412ebbad4b38a1843a46c3563d67a5a7c0218cceca4c33423e299dd40415b test1/2868 0
-fed498be36cb2c0bb64ae9ea368de78003a46078968cc720a2acec1a2f76b0fa test1/2869 0
-c05776cf90e1ae00f43066b11980fe2923e6933179b91b3de7eb496fdc78c515 test1/2870 0
-cc4b2b25aece6e645a0fbff58b71363602990536c901ebeee7a8bb20289d6fe3 test1/2871 0
-968e86bf9630aab3627aff546a5c38f5912aee8342324f4a346ed95b9d0d3d73 test1/2872 0
-8abc40591be782331284e8608ef1f82973963e152df25ec8f9891c49727be8e6 test1/2873 0
-2f3f6d9c47290fe061272cfb6106c12cafe156dc01ccaac004473d6b6beab2b2 test1/2874 0
-5143d99bafa6ba8e1ca73001eb4a41d0158dc8a0136a4c7bc685aa8bf87eec6e test1/2875 0
-4aa778e59f16f854e70cfbe3e787ea27dcb359d2ec0eaecb9901767296998ae5 test1/2876 0
-2b0b7aaa2ab0e32cdd155aab38dded95fec63e5dde52d48b39517c652e595ab6 test1/2877 0
-34a579c64648f78afa1444b1a82d3668b7b7cc80f0df136947fc2829c9c3cce4 test1/2878 0
-927773c703435160888a181409eac7ca4d18bcc91b3a9d9b576c2ccd0d275349 test1/2879 0
-7ae66d21e54997af35a0d329760a545609df5291e6deb9cd436a9472b78428af test1/2880 0
-6fee1832ac36361284f8bad53466d1408c2ce7e8bcfada1d45598611fc2dd85a test1/2881 0
-a7be3ebeccbe23eb6225a139471ec4dd7a74e24deca9daefd118ce987f0f8a7d test1/2882 0
-aae84cbf60a312439e0f1c4214bc93695706e1c4f818a067fcb2e32176766dff test1/2883 0
-4a47c600ed541c8c62b4c13032e927518575ece8f72daf4864f89ddd93afd872 test1/2884 0
-f88b2a2a37f23aee86aae3f733e5085f3bb8c827e29cc613804a771555ac1c56 test1/2885 0
-2d4a3becde98241def3019463c772fdbfd0fccf0f3fa725caecb783f70571da4 test1/2886 0
-4bdd367c3efec38e3baffa123140ec08a06b5928020778119b20dcb62c33f0a2 test1/2887 0
-6dff9f86e4665ec2800db2521e78b3acd43eb621078c306946f478b02f03f8aa test1/2888 0
-09c79b0f3d4ab407f60d6b21c4162696c3836f43ea17aa28690bfcf47f6c83c8 test1/2889 0
-b18d8c06bc9394a07c30968f38835069c947ee5583ae411c9eadd11d7da232e9 test1/2890 0
-7da561130beb7426c5f5ea68652b5f2f24812f16d795e59c133e37be7da362b2 test1/2891 0
-d3386d3f4cd0f6af673254c940e6f27f5a9f6453076c62753ac0dcc90011455c test1/2892 0
-a95f3a258819649a546ccaff18d08407315f587e83664d72d91608b33dd316d3 test1/2893 0
-393ca4dff751f3c8912dd6893e4b0a6a092bba3f5a62e2aa91a59b2122333a5e test1/2894 0
-ca2db108f8be49c3093b2b43053ae67e84b2dc7a7618e7ecbcae975ee43c1bba test1/2895 0
-96eb5e51d71b65a3e51f93973dfd09bc1a064b68a57bd8b392347de8bed43b65 test1/2896 0
-9afedae5118c62fcf3ba4c3a54aa3df5e59499d106fece050dc89298b56e8557 test1/2897 0
-fe0fadd6dbb4a3993d0a6946bc78c049ae7f83b8f0195b82694c6c4527790d14 test1/2898 0
-1beb312f8872f3cafa905b287f22ec68d861ed3fab5917f270c9d48fdf3baece test1/2899 0
-1b864a6d99d2ee3098c16062040163233cdf41d901ffcc60b839da3e26ae6570 test1/2900 0
-d4011b56de71f5e25afd4675b149023b730070f04e3cf62b8329c6b48019aa1c test1/2901 0
-09de244282999f0bf5f1ffb7ecb0c206bc72227a16dd10523bd0ec666e396c79 test1/2902 0
-54192bdbe158c797183fc248c85da09f27c44388a4edfad8b5d6b7ccd45f69de test1/2903 0
-c92a8027b0c3bdde82cc63488fa1b2b344564d5571e670af99cbb170f6eaab05 test1/2904 0
-89b094a37d64705e2c066a8856b4c9dfaf8225f7a14362004d6912a995b64d89 test1/2905 0
-505af18ba330ef3100b8e2f0c31d1d4b222d36e7d9dc3f09d8fd3ed614fcfbb0 test1/2906 0
-61178a21e17cca205adc35bfee2f7b9f3906089c38abcae39afc64c2e029864a test1/2907 0
-048a91abd2933278cc51c2e74d7c59d33c65c1443ab44944db11830ee9e7e6f6 test1/2908 0
-031415bf2dd4344a0139938a40c63a9cae953066ded086d9d25771057f1251a8 test1/2909 0
-65e266de4ff5dcee912db08f03170501d918da696089008c602db48fa1867980 test1/2910 0
-edb2b4b1ddb4c853affcbe5cb82c53582551abf42a2b4377124eed55d43e0e9d test1/2911 0
-c64ba762feb1f4568f66db59dfaf566d3ebc7c7bdca9fa03cb1a3ccc407bb2fe test1/2912 0
-94809d49af3a4705c675f17e5a70c0b7bb4b985bfa103cfc6107444bb05cac1e test1/2913 0
-16733fb82a05f876008deea7b9fc71377271177a2e41dee7457f8bd94339c01f test1/2914 0
-e47526cdd9296f6aa2cfcb5e0cd184918d4dd96d43395a7b40cc1d33ff32399e test1/2915 0
-7c746895b356845875a5319f10daec0e5bccd8964305a4ffc4b757112d1fb69f test1/2916 0
-c7e275e7e00ea5a25a0afce1cc8004845fdd8930f7651a39dd69654eadc111fe test1/2917 0
-aaf71d5580dc9c54221ebb896b256ce1a0b8aafeb5f602913f06e48e8681f464 test1/2918 0
-5b12203350172fea0fd072c45049cffa4db7da0b96b9ea2fc8dd641008f126fb test1/2919 0
-7d838f764aa9d3200bb2d2e9db2d9fd030d7f5659b24bd32f36073c4e326f0d8 test1/2920 0
-62a63042ce91113d5e6fd585692bf299041d80b59e869ac9244f397fd4d00872 test1/2921 0
-f1bc07d0fb9c5c12b41800a3ec4719a511a88d2977ce984935cb7103bcbbf671 test1/2922 0
-b8f3c3ed6335f15751b1991f999a889d884c6d0dc11da86772408594f91c3fbd test1/2923 0
-c27902b2424d33a74d6b6040d71b78026734311a0c1ccfe7d8c0b21d9cde4c56 test1/2924 0
-e0cce9853a9df4c71673743abfdaea3acddd2da91aa7172cebb0cf49be2140a8 test1/2925 0
-7cc5c4b66a7bd725ab79ef0840f8eb7d0011dcadea165a33f669f985a6ad06be test1/2926 0
-006d50c6956221642e9b4ad9cf86d4bc8bb0301e4ae71d82f2630aff4a1ac8ee test1/2927 0
-89a1577e5fb1ef0a7731b6b2d4f58476270c810396e2b22b8db13e7d75d4131c test1/2928 0
-a5453397eec6dfd1d44d59b5ab1c2368fd15bc38411c02770da66c2978c92e05 test1/2929 0
-21fa11d4da39ed740f6af427089bd1e34faab79fa456cf29f63146b27368b923 test1/2930 0
-86b882f7d19cc77981f36ae94272556032096130eff6e69cbf09b47e4302d625 test1/2931 0
-1b3363302630f77bc9ae0c2ba9d26a6cb90eb5858c01872a3681c9430e444b7e test1/2932 0
-25be3bf05a88652b4900370425a2d930a9691745bc5e111ec3dbc8c4f80cb6ff test1/2933 0
-64d05a806ae64f2ad104d188697a0f6d6e9e8ccbb4d62d25b5108e0d71fef929 test1/2934 0
-ad3553888cc380180b670eac3f168637feaf6717b59ca24bde365f02e622e5ad test1/2935 0
-dc855e3d7cd9d345637fb32638954e3c80b9da5d8acd06b4f085cc6d0bf891a8 test1/2936 0
-65044f168cd3ab38be227de1d8b7337eeb79d32c157b68c0abeb685410035742 test1/2937 0
-d2a2076ed4f19908ec2022d1e7b24a8ffadd33b935ea1aebce08d0baab13ac38 test1/2938 0
-57f3715a0f4e4d08afe25d3f21f52c14e91472a6b79d89daf123e6d9ba20d815 test1/2939 0
-cbe78f95ab31a3d8eb8070c27ec6f077b0b9b6a7d9acab619a589bdef271ade9 test1/2940 0
-0b9ad5ba4bea62b691fb3f4435041bb58108ed19bad520e5894627a0ccdbe276 test1/2941 0
-e584746c7db40c58c2fc4e188a5738cc37bd2792a0481edd8c7272ee0f22eed0 test1/2942 0
-e0f8468e3fb932e809ae8189f2e695133f3b8219864b2e9b956319351b0d6cb5 test1/2943 0
-368096572deda36211a28413a1afbee5d19ea19ea3de6f359bbf46b3bb9d98eb test1/2944 0
-8b2abf73fac61167a7545b83979d50ea3f511ab864c38de81a4dfe940d773583 test1/2945 0
-c48135d77474a97778147aa840cbb0409d5fac00bb9167c5270c209391e04b9b test1/2946 0
-2abcc0f29f41835d37b3b5d7fec41f55e73c17833503d0cb0d76bb8697b5eae2 test1/2947 0
-d9d86a738fa5002b0cb5b268c3152719e1809cde1b032849a0b34e9b0c7a066b test1/2948 0
-11652727b8431476aeb90cd8dd2cc05fcbf8d16162ebbb9d5d983802c5c81a2f test1/2949 0
-5867da820fde5940d7c0a34ed8ef397ff0c81c9dbedbc103e3cc2511d28b9aa7 test1/2950 0
-4da53e83a59212b67ee075f7bf6fa4d1b8ab898f5cb17b916551a420e4950ef3 test1/2951 0
-9e6a2d8c86e9500e5a4b7a65ad13e6757d9e7bfcff4cc88a4cc28d91765bc659 test1/2952 0
-a0b2715dc2951179de3e2d2e33131b7ce9ac9680572dd90734897dba5f98e993 test1/2953 0
-9f984e2110bc8312b987585f9254fbe5363a076ceafd45d0834789d0130fff05 test1/2954 0
-ac9593dd50e2aaf31dc843c8ccf8aaa158236cf832c306335a2b3cc6dea748af test1/2955 0
-bb610dc36b46acc9011d6de5994cc3e004a3de0d645885633b2dbbeb690fd6f7 test1/2956 0
-b37a1a5961aa6a6421e7af307d299bc8d09cdc2d3b01b4889eefc03bd49fd155 test1/2957 0
-7cf0e1faef63f78fe2993d865c39e8a425c82ed6885744994f0bce5b4dcf22fa test1/2958 0
-110c2c5a06e8b5a7e7ec2acbeb0d503ac24a5a8d799204ae0ee575b28a9035d8 test1/2959 0
-3c99c7cd555005383293c6cb1dcc7b2822dd0132d5985802dadc892a031ffff6 test1/2960 0
-26835dfed3505322dd68e556eda429873624afa628fdcb23bd02170c544cb4ef test1/2961 0
-2685cc4df39198d502e34a841b81a7a916ea891f15b77a98ff8a153c34e7225a test1/2962 0
-074a1f06c8a5deefda34e60ae30e5af271811eadedbd02e9eab11104f7fe230d test1/2963 0
-fe83d60c7099e231fd0c57edad15472272ab63a0c958df874b00e13ed0eb956f test1/2964 0
-54e48e84bcc0f774f11934f553c1687101c1e639e32ffd4cd9a9fb55eecd285e test1/2965 0
-ddd6fae9979dda839bc7dbc370530e5b3adc8445ee0caceb49519883cee83739 test1/2966 0
-a281835dbed1e4fc9deb7943a5efca05b7ac92f2839027b007e505d4bc7c3d48 test1/2967 0
-a6c9c29efefbe720a6414fc12c2fe4679ff819b5b2c771bd99474573824e73ad test1/2968 0
-7847709e0677cfd0d114158a22cbb4900714c3c276a6a313c0f5f2c1f71df5a8 test1/2969 0
-a7139a1587e08b85776a4b4dfed553b6b7d558c1221a1cefc28c1e46393562e4 test1/2970 0
-5bf5611712faf02cf71cba2ba9efcd925951d45aa4e133b97450f84289e2a5fc test1/2971 0
-172089a3515735aaf4bc246e67f83c5266a5a8ab0efe57a223f93281b4faee2a test1/2972 0
-fa0e4b2f2ee1832ebd68676f22966f65e822b85f680e0397df3d44181732844a test1/2973 0
-3486589dc8ffb845c7fd2818f47c714f9a18e0c089e862d2c9ac203d7e6f3396 test1/2974 0
-2a7357cae0796dd83fe086bc7511f34b0bb61fe6bbda091629e667d6c775f272 test1/2975 0
-c58629fa79ea48da49daee30cafb9d276b3f0467a5f7d0eb522ceb5b9ef83d50 test1/2976 0
-0938caeaffd5a4d4b2557ddf27d85a00e4b135697c70158053942eb289004f64 test1/2977 0
-468e712434715c9808554b76020a660c1df296d448eb4ebd7fcdb53830666ee5 test1/2978 0
-5dcbe597bb4be06b61622efd4ab59715fcda1f85f5b0fb3ffead038a4a7e7975 test1/2979 0
-11e8ebc6da602391abc7b3ed14709e637848a49f794987ff5336adba512cbd29 test1/2980 0
-d66bc7295eba90722a7594c2a9143e7f35a194714921cd3c7f3522122aed4ae9 test1/2981 0
-047ebf0cebf36b6a754faad01a5e3d6e5e0a77766b87f807b1ecaf59174f09da test1/2982 0
-e5351b4749017e65e064b1f152086184e46b8640c329e89db62778a3c1aa817d test1/2983 0
-3db33214f2016e78a7aa6d3f0d2827b8d5d40d3da12a3757f132de597d15c79f test1/2984 0
-08c7cc09e71ed76c82d00e325bdcc84e3a5d2cc386d2f4e03968496a96792f81 test1/2985 0
-cb88fe541000fb33b44e5b70d8c26ac8311c102a124980694d668810dca64cb1 test1/2986 0
-542472a6f3566e0d716b3758d70c2bcfc9b9d09156985867b0fb2e1a13824845 test1/2987 0
-c359e996a630ce709109376d70201bbbb22b2226280717774cbcc19f9f022c21 test1/2988 0
-7bf83c1d95e09ce3c65094da2227b786fee9cd9673c017ac38b5b783106ba27a test1/2989 0
-62e779585c02500ec2e085b07f99797a543c55b53a1bc2048e690f73ef68dcda test1/2990 0
-0f3b82a490c2d3d4caa86d8e290ee2b245c2d97b95af465246935a2f8bdb6fdf test1/2991 0
-85354ff3fee9c06ddaa34fbedb2f7b8b0890436d085de05ce1a0f7fa7f790324 test1/2992 0
-dbf4ab486ca53b2710914bb0ee8f2074c61c024e044fe41501fcd718cd2f1375 test1/2993 0
-b3083cc70ea831123e1f7756527655cbe148898d4e7810caefdfc64a436c5311 test1/2994 0
-e98d3684f784c4dd2faa96ba68a8454e65589cbbd295138604543eda293a67d6 test1/2995 0
-5e850d63c3d528db495ab68e87862655dba38526987667afe1898f6c6b3e4e2e test1/2996 0
-5b18cb632ccd3cc63f9d1a056553d419d56d398a2918b18de31a56bf9f526fa7 test1/2997 0
-16f432cdc47bd1890ee87064f3bd472b457be46ada2763d60441a20cf4dd8079 test1/2998 0
-5ea0b38d9049b021a7c39d798e2aa312659eb1db52569b0c4ccee60f5d356e57 test1/2999 0
commit 8c20ec307817a096741af905f66a99e85a783a3f
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Jul 21 21:06:54 2011 +0200
Test configuration writing for nested AS7-resources
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationWriteDelegate.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationWriteDelegate.java
index a89db4d..c7a4e2a 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationWriteDelegate.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationWriteDelegate.java
@@ -182,6 +182,9 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet {
private void updateHandlePropertyMapSpecial(CompositeOperation cop, PropertyMap prop, PropertyDefinitionMap propDef) {
Map<String,Object> results = updateHandleMap(prop,propDef);
+ if (prop.get(namePropLocator)==null) {
+ throw new IllegalArgumentException("There is no element in the map with the name " + namePropLocator);
+ }
String addrVal= ((PropertySimple)prop.get(namePropLocator)).getStringValue();
Address addr = new Address(address);
addr.add(type,addrVal);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
index 3ed04d1..ad91dac 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
@@ -41,7 +41,8 @@ public class Address {
public Address(Address other) {
this();
- path.addAll(other.path);
+ if (other!=null && other.path!=null)
+ path.addAll(other.path);
}
public Address(List<PROPERTY_VALUE> other) {
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
index 3afc242..4fedcd5 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
@@ -134,5 +134,13 @@ public class Operation {
return address;
}
+ @Override
+ public String toString() {
+ return "Operation{" +
+ "operation='" + operation + '\'' +
+ ", address=" + address +
+ ", additionalProperties=" + additionalProperties +
+ '}';
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java
index 3bddfd4..3510b71 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java
@@ -222,4 +222,48 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest
String result = mapper.writeValueAsString(cop);
}
+
+ public void test7() throws Exception {
+ ConfigurationDefinition definition = loadDescriptor("SocketBindingGroupStandalone");
+
+ FakeConnection connection = new FakeConnection();
+
+ ConfigurationWriteDelegate delegate = new ConfigurationWriteDelegate(definition,connection,null);
+
+ Configuration conf = new Configuration();
+ PropertyMap propertyMap = new PropertyMap("http");
+ propertyMap.put(new PropertySimple("name","http"));
+ propertyMap.put(new PropertySimple("port",18080));
+ propertyMap.put(new PropertySimple("fixed-port",false));
+ PropertyList propertyList = new PropertyList("*");
+ propertyList.add(propertyMap);
+ conf.put(propertyList);
+ conf.put(new PropertySimple("port-offset",0));
+
+ CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf);
+
+ assert cop.numberOfSteps() == 3 : "#Steps should be 3 but were " + cop.numberOfSteps();
+ Operation step1 = cop.step(0);
+ Operation step2 = cop.step(1);
+ Operation step3 = cop.step(2);
+
+ // As we do not specify a base address when creating the delegate 0 or 1 address element is ok.
+ assert step1.getAddress().isEmpty();
+ assert step2.getAddress().size()==1;
+ assert step3.getAddress().size()==1;
+
+ assert step1.getAdditionalProperties().get("name").equals("port-offset");
+ assert step1.getAdditionalProperties().get("value").equals("0");
+
+ assert step2.getAdditionalProperties().get("name").equals("port");
+ assert step2.getAdditionalProperties().get("value").equals("18080");
+
+ assert step3.getAdditionalProperties().get("name").equals("fixed-port");
+ assert step3.getAdditionalProperties().get("value").equals("false");
+
+ assert step2.getAddress().get(0).getKey().equals("socket-binding");
+ assert step2.getAddress().get(0).getValue().equals("http");
+ assert step3.getAddress().get(0).getKey().equals("socket-binding");
+ assert step3.getAddress().get(0).getValue().equals("http");
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml b/modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml
index 1de7d7a..42ff024 100644
--- a/modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml
@@ -137,4 +137,41 @@
</resource-configuration>
</server>
+
+ <server name="SocketBindingGroupStandalone"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ >
+
+ <resource-configuration>
+ <c:simple-property name="default-interface" readOnly="true" displayName="Default Interface"
+ description="Default Interface for these bindings. See NetworkInterfaces for its definition"
+ required="true">
+ <c:option-source target="resource" expression="type=NetworkInterface plugin=jboss-as-7"/>
+ </c:simple-property>
+ <!-- note: at domain level there is no port-offset -->
+ <c:simple-property name="port-offset" readOnly="false" displayName="Port Offset"
+ description="Offset from standard ports for this group."
+ required="false"/>
+ <c:group name="children:socket-binding:name" displayName="Individual socket bindings">
+ <c:list-property name="*" displayName="Bindings">
+ <c:map-property name="binding">
+ <c:simple-property name="name" readOnly="true"/>
+ <c:simple-property name="interface"
+ required="false">
+ <c:option-source target="resource" expression="type=NetworkInterface plugin=jboss-as-7"/>
+ </c:simple-property>
+ <c:simple-property name="port" type="integer"/>
+ <c:simple-property name="fixed-port"
+ type="boolean" defaultValue="false"/>
+ <c:simple-property name="multicast-address" required="false"/>
+ <c:simple-property name="multicast-port" type="integer" required="false"/>
+ </c:map-property>
+ </c:list-property>
+ </c:group>
+ </resource-configuration>
+
+ </server>
+
+
</plugin>
\ No newline at end of file
commit f418da3ebe60d1107370ee7436c0bef7d1895b65
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 27 22:52:30 2011 -0400
Refactoring logic for accessing list of drift plugins in system config
Storing the drift config plugin names as was done initially was not
going to work. It would break in an HA environment. Instead of
persisting the names of enabled drift plugins, it is now a calculated
value obtained via a call from the service/SLSB layer.
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml b/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml
index 6d0e80a..8dbc06e 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml
@@ -126,10 +126,8 @@
DEFAULT_PROPERTY_VALUE="false" FREAD_ONLY="FALSE"/>
<!-- default drift server plugin settings -->
- <data ID="57" PROPERTY_KEY="ACTIVE_DRIFT_PLUGIN" PROPERTY_VALUE="[drift-rhq$$Drift:RHQ]"
- DEFAULT_PROPERTY_VALUE="[drift-rhq$$Drift:RHQ]" FREAD_ONLY="FALSE"/>
- <data ID="58" PROPERTY_KEY="DRIFT_PLUGINS" PROPERTY_VALUE="" DEFAULT_PROPERTY_VALUE="[drift-rhq$$Drift:RHQ]"
- FREAD_ONLY="FALSE"/>
+ <data ID="57" PROPERTY_KEY="ACTIVE_DRIFT_PLUGIN" PROPERTY_VALUE="drift-rhq"
+ DEFAULT_PROPERTY_VALUE="drift-rhq" FREAD_ONLY="FALSE"/>
</table>
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 2b1097d..fe5f1f6 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3590,14 +3590,7 @@
<schema-directSQL>
<statement desc="Adding drift server plugin active plugin system configuration property">
INSERT INTO rhq_system_config (id, property_key, property_value, default_property_value)
- VALUES (57, 'ACTIVE_DRIFT_PLUGIN', '[drift-rhq$$Drift:RHQ]', '[drift-rhq$$Drift:RHQ]')
- </statement>
- </schema-directSQL>
-
- <schema-directSQL>
- <statement desc="Adding drift server plugin plugins system configuration property">
- INSERT INTO rhq_system_config (id, property_key, property_value, default_property_value)
- VALUES (58, 'DRIFT_PLUGINS', '', '[drift-rhq$$Drift:RHQ]')
+ VALUES (57, 'ACTIVE_DRIFT_PLUGIN', 'drift-rhq', 'drift-rhq')
</statement>
</schema-directSQL>
</schemaSpec>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/common/composite/SystemSettings.java b/modules/core/domain/src/main/java/org/rhq/core/domain/common/composite/SystemSettings.java
new file mode 100644
index 0000000..ae1264d
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/common/composite/SystemSettings.java
@@ -0,0 +1,39 @@
+package org.rhq.core.domain.common.composite;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+// TODO javadocs...
+public class SystemSettings implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private Map<String, String> systemConfiguration;
+
+ private Map<String, String> driftPlugins = new HashMap<String, String>();
+
+ public SystemSettings() {
+ }
+
+ public SystemSettings(Map<String, String> sysConfig, Map<String, String> driftPlugins) {
+ systemConfiguration = sysConfig;
+ this.driftPlugins = driftPlugins;
+ }
+
+ public Map<String, String> getSystemConfiguration() {
+ return systemConfiguration;
+ }
+
+ public void setSystemConfiguration(Map<String, String> systemConfiguration) {
+ this.systemConfiguration = systemConfiguration;
+ }
+
+ public Map<String, String> getDriftPlugins() {
+ return driftPlugins;
+ }
+
+ public void setDriftPlugins(Map<String, String> driftPlugins) {
+ this.driftPlugins = driftPlugins;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/lib/morphia-gwt-0.99-SNAPSHOT.jar b/modules/enterprise/gui/coregui/lib/morphia-gwt-0.99-SNAPSHOT.jar
new file mode 100644
index 0000000..e8a10a6
Binary files /dev/null and b/modules/enterprise/gui/coregui/lib/morphia-gwt-0.99-SNAPSHOT.jar differ
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java
index ac861b0..d404581 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java
@@ -36,6 +36,7 @@ import com.smartgwt.client.widgets.toolbar.ToolStrip;
import org.rhq.core.domain.common.ProductInfo;
import org.rhq.core.domain.common.ServerDetails;
import org.rhq.core.domain.common.ServerDetails.Detail;
+import org.rhq.core.domain.common.composite.SystemSettings;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
@@ -127,15 +128,14 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
protected void onDraw() {
super.onDraw();
- GWTServiceLookup.getSystemService().getSystemConfiguration(new AsyncCallback<HashMap<String, String>>() {
+ GWTServiceLookup.getSystemService().getSystemSettings(new AsyncCallback<SystemSettings>() {
@Override
- public void onSuccess(HashMap<String, String> result) {
+ public void onSuccess(SystemSettings result) {
canvas.addMember(getServerDetails());
Configuration config = new Configuration();
- String[] driftPlugins = null;
- for (Map.Entry<String, String> entry : result.entrySet()) {
+ for (Map.Entry<String, String> entry : result.getSystemConfiguration().entrySet()) {
String name = entry.getKey();
String value = (entry.getValue() == null) ? "" : entry.getValue();
@@ -173,9 +173,6 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
if (value.trim().length() == 0) {
value = "true";
}
- } else if (Constant.DRIFT_PLUGINS.equals(name)) {
- driftPlugins = value.split(",");
- continue;
}
PropertySimple prop = new PropertySimple(name, value);
@@ -184,7 +181,7 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
// build our config definition and populate our config editor
editor = new ConfigurationEditor(extendLocatorId("configEditor"), getSystemSettingsDefinition(config,
- driftPlugins), config);
+ result.getDriftPlugins()), config);
editor.addPropertyValueChangeListener(SystemSettingsView.this);
canvas.addMember(editor);
@@ -315,7 +312,8 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
*
* @return system settings config def
*/
- private ConfigurationDefinition getSystemSettingsDefinition(Configuration config, String[] driftPlugins) {
+ private ConfigurationDefinition getSystemSettingsDefinition(Configuration config,
+ Map<String, String> driftPlugins) {
ConfigurationDefinition def = new ConfigurationDefinition("sysset", MSG.view_adminConfig_systemSettings());
///////////////////////////////////
@@ -544,12 +542,10 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
activeDriftServer.setPropertyGroupDefinition(driftGroup);
List<PropertyDefinitionEnumeration> options = new ArrayList<PropertyDefinitionEnumeration>();
- for (String plugin : driftPlugins) {
- // plugin is of the form, [plugin_name$$plugin_display_name]]
- String pluginName = plugin.substring(1, plugin.indexOf("$$"));
- String pluginDisplayName = plugin.substring(pluginName.length() + 3, plugin.indexOf("]"));
- options.add(new PropertyDefinitionEnumeration(pluginDisplayName, plugin));
+ for (Map.Entry<String, String> entry : driftPlugins.entrySet()) {
+ options.add(new PropertyDefinitionEnumeration(entry.getValue(), entry.getKey())) ;
}
+
activeDriftServer.setEnumeratedValues(options, false);
def.put(activeDriftServer);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/SystemGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/SystemGWTService.java
index e530b67..a4fda65 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/SystemGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/SystemGWTService.java
@@ -24,6 +24,7 @@ import com.google.gwt.user.client.rpc.RemoteService;
import org.rhq.core.domain.common.ProductInfo;
import org.rhq.core.domain.common.ServerDetails;
+import org.rhq.core.domain.common.composite.SystemSettings;
/**
* Provides information about the server as well as a way to reconfigure parts of the server.
@@ -37,6 +38,8 @@ public interface SystemGWTService extends RemoteService {
ServerDetails getServerDetails() throws RuntimeException;
+ SystemSettings getSystemSettings();
+
HashMap<String, String> getSystemConfiguration() throws RuntimeException;
void setSystemConfiguration(HashMap<String, String> properties, boolean skipValidation) throws RuntimeException;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java
index 052bf11..7aa4117 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SystemGWTServiceImpl.java
@@ -28,6 +28,7 @@ import java.util.Properties;
import org.rhq.core.domain.common.ProductInfo;
import org.rhq.core.domain.common.ServerDetails;
+import org.rhq.core.domain.common.composite.SystemSettings;
import org.rhq.enterprise.gui.coregui.client.gwt.SystemGWTService;
import org.rhq.enterprise.server.core.AgentManagerLocal;
import org.rhq.enterprise.server.system.SystemManagerLocal;
@@ -66,6 +67,15 @@ public class SystemGWTServiceImpl extends AbstractGWTServiceImpl implements Syst
}
@Override
+ public SystemSettings getSystemSettings() {
+ try {
+ return systemManager.getSystemSettings(getSessionSubject());
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
+ }
+ }
+
+ @Override
public HashMap<String, String> getSystemConfiguration() throws RuntimeException {
try {
Properties props = systemManager.getSystemConfiguration(getSessionSubject());
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java
index 9e405ec..f080f1a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java
@@ -18,7 +18,6 @@
*/
package org.rhq.enterprise.server.plugin.pc.drift;
-import java.util.List;
import java.util.Properties;
import org.apache.commons.logging.Log;
@@ -29,12 +28,8 @@ import org.rhq.enterprise.server.plugin.pc.ServerPluginEnvironment;
import org.rhq.enterprise.server.plugin.pc.ServerPluginManager;
import org.rhq.enterprise.server.system.SystemManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
-import org.rhq.enterprise.server.xmlschema.generated.serverplugin.ServerPluginDescriptorType;
-import static org.rhq.core.domain.util.StringUtils.getListAsString;
-import static org.rhq.core.domain.util.StringUtils.getStringAsList;
import static org.rhq.enterprise.server.RHQConstants.ACTIVE_DRIFT_PLUGIN;
-import static org.rhq.enterprise.server.RHQConstants.DRIFT_PLUGINS;
/**
* This loads in all drift server plugins that can be found. You can obtain a loaded plugin's
@@ -53,55 +48,13 @@ public class DriftServerPluginManager extends ServerPluginManager {
public DriftServerPluginFacet getDriftServerPluginComponent() {
Properties sysConfig = getSysConfig();
- String value = sysConfig.getProperty(ACTIVE_DRIFT_PLUGIN);
+ String pluginName = sysConfig.getProperty(ACTIVE_DRIFT_PLUGIN);
- if (value == null) {
+ if (pluginName == null) {
throw new RuntimeException(ACTIVE_DRIFT_PLUGIN + " system configuration property is not set.");
}
- return (DriftServerPluginFacet) getServerPluginComponent(value.substring(1, value.indexOf("$$")));
- }
-
- @Override
- protected void loadPlugin(ServerPluginEnvironment env, boolean enabled) throws Exception {
- super.loadPlugin(env, enabled);
-
- String pluginName = env.getPluginKey().getPluginName();
- List<String> plugins = getDriftPlugins();
-
- int index = findPluginIndex(plugins, pluginName);
- if (index == -1) {
- plugins.add("[" + pluginName + "$$" + env.getPluginDescriptor().getDisplayName() + "]");
- saveDriftPlugins(plugins);
- }
-
- }
-
- @Override
- protected void unloadPlugin(String pluginName) throws Exception {
- super.unloadPlugin(pluginName);
-
- List<String> plugins = getDriftPlugins();
- int index = findPluginIndex(plugins, pluginName);
-
- if (index != -1) {
- plugins.remove(index);
- saveDriftPlugins(plugins);
- }
- }
-
- private List<String> getDriftPlugins() {
- Properties sysConfig = getSysConfig();
- return getStringAsList(sysConfig.getProperty(DRIFT_PLUGINS, ""), ",", true);
- }
-
- private void saveDriftPlugins(List<String> plugins) throws Exception {
- SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
- SystemManagerLocal systemMgr = LookupUtil.getSystemManager();
-
- Properties sysConfig = systemMgr.getSystemConfiguration(subjectMgr.getOverlord());
- sysConfig.put(DRIFT_PLUGINS, getListAsString(plugins, ","));
- systemMgr.setSystemConfiguration(subjectMgr.getOverlord(), sysConfig, false);
+ return (DriftServerPluginFacet) getServerPluginComponent(pluginName);
}
private Properties getSysConfig() {
@@ -111,17 +64,4 @@ public class DriftServerPluginManager extends ServerPluginManager {
return systemMgr.getSystemConfiguration(subjectMgr.getOverlord());
}
- private int findPluginIndex(List<String> plugins, String name) {
- int i = 0;
- for (String value : plugins) {
- // value is of the form, [plugin_name$$plugin_display_name]
- if (name.equals(value.substring(1, value.indexOf("$$")))) {
- return i;
- }
- ++i;
- }
- return -1;
- }
-
-
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java
index 19a454a..229183d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java
@@ -60,8 +60,9 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.common.ProductInfo;
import org.rhq.core.domain.common.ServerDetails;
-import org.rhq.core.domain.common.SystemConfiguration;
import org.rhq.core.domain.common.ServerDetails.Detail;
+import org.rhq.core.domain.common.SystemConfiguration;
+import org.rhq.core.domain.common.composite.SystemSettings;
import org.rhq.core.server.PersistenceUtility;
import org.rhq.core.util.ObjectNameFactory;
import org.rhq.core.util.StopWatch;
@@ -70,6 +71,10 @@ import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.RequiredPermission;
import org.rhq.enterprise.server.core.CoreServerMBean;
import org.rhq.enterprise.server.core.CustomJaasDeploymentServiceMBean;
+import org.rhq.enterprise.server.plugin.pc.MasterServerPluginContainer;
+import org.rhq.enterprise.server.plugin.pc.ServerPluginEnvironment;
+import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginContainer;
+import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginManager;
import org.rhq.enterprise.server.util.LookupUtil;
import org.rhq.enterprise.server.util.SystemDatabaseInformation;
@@ -182,6 +187,46 @@ public class SystemManagerBean implements SystemManagerLocal, SystemManagerRemot
return copy;
}
+ @RequiredPermission(Permission.MANAGE_SETTINGS)
+ public SystemSettings getSystemSettings(Subject subject) {
+ return new SystemSettings(toMap(getSystemConfiguration(subject)), getDriftServerPlugins());
+ }
+
+ private Map<String, String> toMap(Properties props) {
+ HashMap<String, String> map = new HashMap<String, String>(props.size());
+ for (Map.Entry<Object, Object> entry : props.entrySet()) {
+ map.put(String.valueOf(entry.getKey()), String.valueOf(entry.getValue()));
+ }
+ return map;
+ }
+
+ private Map<String, String> getDriftServerPlugins() {
+ DriftServerPluginManager pluginMgr = getDriftSererPluginManager();
+ Map<String, String> plugins = new HashMap<String, String>();
+
+ for (ServerPluginEnvironment env : pluginMgr.getPluginEnvironments()) {
+ plugins.put(env.getPluginKey().getPluginName(), env.getPluginDescriptor().getDisplayName());
+ }
+
+ return plugins;
+ }
+
+ private DriftServerPluginManager getDriftSererPluginManager() {
+ MasterServerPluginContainer masterPC = LookupUtil.getServerPluginService().getMasterPluginContainer();
+ if (masterPC == null) {
+ log.warn(MasterServerPluginContainer.class.getSimpleName() + " is not started yet");
+ return null;
+ }
+
+ DriftServerPluginContainer pc = masterPC.getPluginContainerByClass(DriftServerPluginContainer.class);
+ if (pc == null) {
+ log.warn(DriftServerPluginContainer.class + " has not been loaded by the " + masterPC.getClass() + " yet");
+ return null;
+ }
+
+ return (DriftServerPluginManager) pc.getPluginManager();
+ }
+
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void loadSystemConfigurationCacheInNewTx() {
// this is used by our timer, so any exceptions coming out here doesn't throw away our timer
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerLocal.java
index e023f48..0d82732 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerLocal.java
@@ -26,6 +26,7 @@ import org.rhq.core.db.DatabaseType;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.ProductInfo;
import org.rhq.core.domain.common.ServerDetails;
+import org.rhq.core.domain.common.composite.SystemSettings;
/**
* Provides access to the server cloud's system configuration as well as some methods
@@ -146,6 +147,8 @@ public interface SystemManagerLocal {
ServerDetails getServerDetails(Subject subject);
+ SystemSettings getSystemSettings(Subject subject);
+
Properties getSystemConfiguration(Subject subject);
void setSystemConfiguration(Subject subject, Properties properties, boolean skipValidation) throws Exception;
diff --git a/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
index b385473..46611ed 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
@@ -143,7 +143,7 @@ public class JPAUtils {
em.createNativeQuery("delete from rhq_measurement_sched");
em.createNativeQuery("delete from rhq_measurement_def");
em.createNativeQuery("delete from rhq_plugin");
- em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56, 57, 58)");
+ em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56, 57)");
em.createNativeQuery("delete from rhq_alert_notification");
em.createNativeQuery("delete from rhq_alert_condition_log");
em.createNativeQuery("delete from rhq_alert");
commit a8b8c0db8667875f84b14e502d5c225ad2ceec57
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Jul 27 16:10:09 2011 -0400
[BZ-726202 - alerts not firing despite valid baseline values and alert conditions templates for some agents]
The issue here was that user created baseline did not properly trigger a
measurement condition cache reload for the affected agent. This was due
to the new Baseline not committed/visible to the trans executing the
agent status update.
- also, removed unused findBaselineForResourceAndMeasurementDefinition as
opposed to changing it for this fix.
- made a local public method private and removed some dead commented code
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerBean.java
index 282ae1a..286a75e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerBean.java
@@ -355,9 +355,25 @@ public class MeasurementBaselineManagerBean implements MeasurementBaselineManage
return baseline;
}
+ @TransactionAttribute(TransactionAttributeType.NEVER)
public MeasurementBaseline calculateAutoBaseline(Subject subject, Integer measurementScheduleId, long startDate,
long endDate, boolean save) throws BaselineCreationException, MeasurementNotFoundException {
+ MeasurementBaseline result = measurementBaselineManager.calculateAutoBaselineInNewTransaction(subject,
+ measurementScheduleId, startDate, endDate, save);
+
+ if (save) {
+ // note, this executes in a new transaction so the baseline must already be committed to the database
+ agentStatusManager.updateByMeasurementBaseline(result.getId());
+ }
+
+ return result;
+ }
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public MeasurementBaseline calculateAutoBaselineInNewTransaction(Subject subject, Integer measurementScheduleId,
+ long startDate, long endDate, boolean save) throws BaselineCreationException, MeasurementNotFoundException {
+
MeasurementBaseline baseline;
MeasurementSchedule sched = entityManager.find(MeasurementSchedule.class, measurementScheduleId);
@@ -391,13 +407,26 @@ public class MeasurementBaselineManagerBean implements MeasurementBaselineManage
return baseline;
}
- //calculateAutoBaseline(LookupUtil.getSubjectManager().getOverlord(),
- //chartForm.getGroupId(), chartForm.getM()[0], chartForm.getStartDate().getTime(), chartForm
- //.getEndDate().getTime(), false);
-
+ @TransactionAttribute(TransactionAttributeType.NEVER)
public MeasurementBaseline calculateAutoBaseline(Subject subject, int groupId, int definitionId, long startDate,
long endDate, boolean save) throws BaselineCreationException, MeasurementNotFoundException {
+ MeasurementBaseline result = measurementBaselineManager.calculateAutoBaselineForGroupInNewTransaction(subject,
+ groupId, definitionId, startDate, endDate, save);
+
+ if (save) {
+ // note, this executes in a new transaction so the baseline must already be committed to the database
+ agentStatusManager.updateByMeasurementBaseline(result.getId());
+ }
+
+ return result;
+ }
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public MeasurementBaseline calculateAutoBaselineForGroupInNewTransaction(Subject subject, int groupId,
+ int definitionId, long startDate, long endDate, boolean save) throws BaselineCreationException,
+ MeasurementNotFoundException {
+
if (save && !authorizationManager.hasGroupPermission(subject, Permission.MANAGE_MEASUREMENTS, groupId)) {
throw new PermissionException("User[" + subject.getName()
+ "] does not have permission to calculate and set baselines for group[id=" + groupId + "]");
@@ -405,7 +434,7 @@ public class MeasurementBaselineManagerBean implements MeasurementBaselineManage
MeasurementBaseline baseline;
try {
- baseline = calculateBaseline(groupId, definitionId, true, startDate, endDate, save);
+ baseline = calculateBaselineForGroup(groupId, definitionId, true, startDate, endDate, save);
if (save) {
// We have changed the baseline information for the schedule, so remove the now outdated OOB info.
oobManager.removeOOBsForGroupAndDefinition(subject, groupId, definitionId);
@@ -435,43 +464,6 @@ public class MeasurementBaselineManagerBean implements MeasurementBaselineManage
}
}
- public MeasurementBaseline findBaselineForResourceAndMeasurementDefinition(Subject subject, Integer resourceId,
- Integer measurementDefinitionId) {
- if (!authorizationManager.canViewResource(subject, resourceId)) {
- throw new PermissionException("Cannot view the baseline for resourceId=" + resourceId
- + "] - you do not have permission");
- }
-
- List<MeasurementBaseline> baselines = getBaselinesForResourcesAndDefinitionIds(new Integer[] { resourceId },
- new Integer[] { measurementDefinitionId });
- if ((baselines != null) && (baselines.size() > 0)) {
- return baselines.get(0);
- }
-
- Subject overlord = subjectManager.getOverlord();
- try {
- MeasurementSchedule schedule = measurementScheduleManager.getSchedule(overlord, resourceId,
- measurementDefinitionId, true);
-
- /*
- * Use all available data from the epoch until now to calculate the baseline (we don't need to start from
- * the epoch, because the baseline should have been auto-calculated after a few days, but it's a catch-all)
- */
- MeasurementBaseline baseline = calculateAutoBaseline(overlord, schedule.getId(), 0, System
- .currentTimeMillis(), true);
-
- return baseline;
- } catch (MeasurementNotFoundException mnfe) {
- log.error("Could not find measurement schedule for " + "resourceId=" + resourceId + ", "
- + "measurementDefinitionId=" + measurementDefinitionId, mnfe);
- } catch (BaselineCreationException bce) {
- log.error("Could not calculate baseline for " + "resourceId=" + resourceId + ", "
- + "measurementDefinitionId=" + measurementDefinitionId, bce);
- }
-
- return null;
- }
-
@SuppressWarnings("unchecked")
private List<MeasurementBaseline> getBaselinesForResourcesAndDefinitionIds(Integer[] resourceIds,
Integer[] definitionIds) {
@@ -531,15 +523,13 @@ public class MeasurementBaselineManagerBean implements MeasurementBaselineManage
if (save) {
entityManager.persist(baseline);
entityManager.merge(schedule);
-
- notifyAlertConditionCacheManager("calculateBaseline", baseline);
}
return baseline;
}
- public MeasurementBaseline calculateBaseline(int groupId, int definitionId, boolean userEntered, long startDate,
- long endDate, boolean save) throws DataNotAvailableException, BaselineCreationException {
+ private MeasurementBaseline calculateBaselineForGroup(int groupId, int definitionId, boolean userEntered,
+ long startDate, long endDate, boolean save) throws DataNotAvailableException, BaselineCreationException {
MeasurementAggregate agg = dataManager.getAggregate(subjectManager.getOverlord(), groupId, definitionId,
startDate, endDate);
@@ -583,8 +573,6 @@ public class MeasurementBaselineManagerBean implements MeasurementBaselineManage
if (save) {
entityManager.persist(baseline);
entityManager.merge(schedule);
-
- notifyAlertConditionCacheManager("calculateBaseline", baseline);
}
}
@@ -592,12 +580,6 @@ public class MeasurementBaselineManagerBean implements MeasurementBaselineManage
return baseline;
}
- private void notifyAlertConditionCacheManager(String callingMethod, MeasurementBaseline baseline) {
- agentStatusManager.updateByMeasurementBaseline(baseline.getId());
-
- log.debug("Invoking... " + callingMethod);
- }
-
@SuppressWarnings("unchecked")
public List<MeasurementBaseline> findBaselinesForResource(Subject subject, int resourceId) {
if (authorizationManager.canViewResource(subject, resourceId) == false) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerLocal.java
index 88d8e94..7f7655a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementBaselineManagerLocal.java
@@ -92,9 +92,17 @@ public interface MeasurementBaselineManagerLocal {
MeasurementBaseline calculateAutoBaseline(Subject subject, Integer measurementScheduleId, long startDate,
long endDate, boolean save) throws BaselineCreationException, MeasurementNotFoundException;
+ // internal use only for transactioning reasons
+ MeasurementBaseline calculateAutoBaselineInNewTransaction(Subject subject, Integer measurementScheduleId,
+ long startDate, long endDate, boolean save) throws BaselineCreationException, MeasurementNotFoundException;
+
MeasurementBaseline calculateAutoBaseline(Subject subject, int groupId, int definitionId, long startDate,
long endDate, boolean save) throws BaselineCreationException, MeasurementNotFoundException;
+ // internal use only for transactioning reasons
+ MeasurementBaseline calculateAutoBaselineForGroupInNewTransaction(Subject subject, int groupId, int definitionId,
+ long startDate, long endDate, boolean save) throws BaselineCreationException, MeasurementNotFoundException;
+
/**
* Unset the {@link MeasurementBaseline#setUserEntered(boolean) user-entered} property in baselines so that we can
* do autobaselines on it again.
@@ -105,19 +113,6 @@ public interface MeasurementBaselineManagerLocal {
*/
void enableAutoBaselineCalculation(Subject subject, Integer[] resourceIds, Integer[] definitionIds);
- /**
- * Returns the baseline for a measurement identified by its measurement definition and the resource whose
- * measurement it is.
- *
- * @param subject
- * @param resource
- * @param measurementDefinitionId
- *
- * @return baseline of the resource's measurement with the given definition
- */
- MeasurementBaseline findBaselineForResourceAndMeasurementDefinition(Subject subject, Integer resource,
- Integer measurementDefinitionId);
-
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// The following are shared with the Remote Interface
commit 7a464d4a04553a27de92b426604f81ce6f710567
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jul 27 15:17:52 2011 -0400
context menu on change set node
multiple select tree nodes
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
index 6085af1..8203361 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -47,7 +47,6 @@ import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
/**
@@ -67,7 +66,7 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
// fetch the top nodes at the inital onDraw()
setAutoFetchData(true);
setAnimateFolders(false);
- setSelectionType(SelectionStyle.SINGLE);
+ setSelectionType(SelectionStyle.MULTIPLE);
setShowRollOver(false);
setShowHeader(false);
setSortField(AbstractDriftChangeSetsTreeDataSource.ATTR_NAME);
@@ -96,9 +95,10 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
TreeNode eventNode = event.getNode();
if (eventNode instanceof ChangeSetTreeNode) {
- CoreGUI.getMessageCenter().notify(new Message("TODO [this will popup the changeset menu]"));
+ Menu menu = buildChangeSetTreeNodeContextMenu((ChangeSetTreeNode) eventNode);
+ menu.showContextMenu();
} else if (eventNode instanceof DriftTreeNode) {
- Menu menu = buildContextMenu((DriftTreeNode) eventNode);
+ Menu menu = buildDriftTreeNodeContextMenu((DriftTreeNode) eventNode);
menu.showContextMenu();
}
}
@@ -171,12 +171,12 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
* @param node the drift node whose menu is to be displayed
* @return the context menu to display
*/
- protected Menu buildContextMenu(final DriftTreeNode node) {
+ protected Menu buildDriftTreeNodeContextMenu(final DriftTreeNode node) {
Menu contextMenu = new Menu();
// title
- String titleName = node.getName();
+ String titleName = node.getTitle();
if (titleName.length() > 50) {
// make sure the title isn't really long so the menu is not abnormally wide
titleName = "..." + titleName.substring(titleName.length() - 50);
@@ -204,6 +204,36 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
}
/**
+ * Builds the right-mouse-click context menu for the given change set node
+ * @param node the change set node whose menu is to be displayed
+ * @return the context menu to display
+ */
+ protected Menu buildChangeSetTreeNodeContextMenu(final ChangeSetTreeNode node) {
+
+ Menu contextMenu = new Menu();
+
+ // title
+ String titleName = node.getTitle();
+ MenuItem titleItem = new MenuItem(titleName);
+ titleItem.setEnabled(false);
+ contextMenu.setItems(titleItem);
+
+ // separator
+ contextMenu.addItem(new MenuItemSeparator());
+
+ // item that links to the history details
+ MenuItem deleteItem = new MenuItem(MSG.common_button_delete());
+ deleteItem.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ // TODO: delete the change set
+ }
+ });
+ contextMenu.addItem(deleteItem);
+
+ return contextMenu;
+ }
+
+ /**
* We override this because we know all of our nodes will have titles. Without this,
* I could not get the title of change set nodes to show - it always fell back to using
* the name. This way is at least faster, since we don't do any conditional checking,
commit 9aecf5f44f150b18a2454182d12827a52e16f49f
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 27 14:50:44 2011 -0400
Making the active drift server plugin configurable via system settings
When a drift serer plugin is loaded or unloaded, it is added to or
removed from the systems settings. When the DriftServerBean (SLSB
layers) asks for the drift plugin, the DriftServerPlugin queries the
system settings to find the active drift server plugin. The drift-rhq
plugin is active by default.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 39f0798..e2a599d 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.111</db.schema.version>
+ <db.schema.version>2.112</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml b/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml
index 121e971..6d0e80a 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml
@@ -125,6 +125,12 @@
<data ID="56" PROPERTY_KEY="RESOURCE_GENERIC_PROPERTIES_UPGRADE" PROPERTY_VALUE="false"
DEFAULT_PROPERTY_VALUE="false" FREAD_ONLY="FALSE"/>
+ <!-- default drift server plugin settings -->
+ <data ID="57" PROPERTY_KEY="ACTIVE_DRIFT_PLUGIN" PROPERTY_VALUE="[drift-rhq$$Drift:RHQ]"
+ DEFAULT_PROPERTY_VALUE="[drift-rhq$$Drift:RHQ]" FREAD_ONLY="FALSE"/>
+ <data ID="58" PROPERTY_KEY="DRIFT_PLUGINS" PROPERTY_VALUE="" DEFAULT_PROPERTY_VALUE="[drift-rhq$$Drift:RHQ]"
+ FREAD_ONLY="FALSE"/>
+
</table>
</dbsetup>
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 7e38d96..2b1097d 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3586,6 +3586,22 @@
</schema-directSQL>
</schemaSpec>
+ <schemaSpec version="2.112">
+ <schema-directSQL>
+ <statement desc="Adding drift server plugin active plugin system configuration property">
+ INSERT INTO rhq_system_config (id, property_key, property_value, default_property_value)
+ VALUES (57, 'ACTIVE_DRIFT_PLUGIN', '[drift-rhq$$Drift:RHQ]', '[drift-rhq$$Drift:RHQ]')
+ </statement>
+ </schema-directSQL>
+
+ <schema-directSQL>
+ <statement desc="Adding drift server plugin plugins system configuration property">
+ INSERT INTO rhq_system_config (id, property_key, property_value, default_property_value)
+ VALUES (58, 'DRIFT_PLUGINS', '', '[drift-rhq$$Drift:RHQ]')
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
+
</dbupgrade>
</target>
</project>
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java
index 5e83850..ac861b0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java
@@ -19,8 +19,10 @@
package org.rhq.enterprise.gui.coregui.client.admin;
+import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -38,6 +40,7 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionEnumeration;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertyGroupDefinition;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
@@ -99,6 +102,9 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
String LDAPBaseDN = "CAM_LDAP_BASE_DN";
String LDAPBindDN = "CAM_LDAP_BIND_DN";
String LDAPBindPW = "CAM_LDAP_BIND_PW";
+
+ String ACTIVE_DRIFT_PLUGIN = "ACTIVE_DRIFT_PLUGIN";
+ String DRIFT_PLUGINS = "DRIFT_PLUGINS";
}
public SystemSettingsView(String locatorId) {
@@ -128,6 +134,7 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
canvas.addMember(getServerDetails());
Configuration config = new Configuration();
+ String[] driftPlugins = null;
for (Map.Entry<String, String> entry : result.entrySet()) {
String name = entry.getKey();
String value = (entry.getValue() == null) ? "" : entry.getValue();
@@ -166,6 +173,9 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
if (value.trim().length() == 0) {
value = "true";
}
+ } else if (Constant.DRIFT_PLUGINS.equals(name)) {
+ driftPlugins = value.split(",");
+ continue;
}
PropertySimple prop = new PropertySimple(name, value);
@@ -173,8 +183,8 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
}
// build our config definition and populate our config editor
- editor = new ConfigurationEditor(extendLocatorId("configEditor"), getSystemSettingsDefinition(config),
- config);
+ editor = new ConfigurationEditor(extendLocatorId("configEditor"), getSystemSettingsDefinition(config,
+ driftPlugins), config);
editor.addPropertyValueChangeListener(SystemSettingsView.this);
canvas.addMember(editor);
@@ -305,7 +315,7 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
*
* @return system settings config def
*/
- private ConfigurationDefinition getSystemSettingsDefinition(Configuration config) {
+ private ConfigurationDefinition getSystemSettingsDefinition(Configuration config, String[] driftPlugins) {
ConfigurationDefinition def = new ConfigurationDefinition("sysset", MSG.view_adminConfig_systemSettings());
///////////////////////////////////
@@ -519,6 +529,31 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
ldapBindPW.setDefaultValue("");
def.put(ldapBindPW);
+ ///////////////////////////////////////////
+ // Drift Server Configuration Properties //
+ ///////////////////////////////////////////
+ PropertyGroupDefinition driftGroup = new PropertyGroupDefinition("drift server");
+ driftGroup.setDisplayName("Drift Server Configuration Settings");
+ driftGroup.setOrder(4);
+ driftGroup.setDefaultHidden(false);
+
+ PropertyDefinitionSimple activeDriftServer = new PropertyDefinitionSimple("ACTIVE_DRIFT_PLUGIN",
+ "The drift server plugin that manages the persistence of drift-related entities and content", true,
+ PropertySimpleType.STRING);
+ activeDriftServer.setDisplayName("Active Drift Server Plugin");
+ activeDriftServer.setPropertyGroupDefinition(driftGroup);
+
+ List<PropertyDefinitionEnumeration> options = new ArrayList<PropertyDefinitionEnumeration>();
+ for (String plugin : driftPlugins) {
+ // plugin is of the form, [plugin_name$$plugin_display_name]]
+ String pluginName = plugin.substring(1, plugin.indexOf("$$"));
+ String pluginDisplayName = plugin.substring(pluginName.length() + 3, plugin.indexOf("]"));
+ options.add(new PropertyDefinitionEnumeration(pluginDisplayName, plugin));
+ }
+ activeDriftServer.setEnumeratedValues(options, false);
+
+ def.put(activeDriftServer);
+
//
// if the config is missing any properties for which we have defaults, set them to their defaults
//
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java
index e992271..63037c1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java
@@ -49,6 +49,10 @@ public class RHQConstants {
public static final String LDAPBindDN = "CAM_LDAP_BIND_DN";
public static final String LDAPBindPW = "CAM_LDAP_BIND_PW";
+ // DRIFT Server properties
+ public static final String ACTIVE_DRIFT_PLUGIN = "ACTIVE_DRIFT_PLUGIN";
+ public static final String DRIFT_PLUGINS = "DRIFT_PLUGINS";
+
// Base URL for the application - (i think this is only used for alert emails)
public static final String BaseURL = "CAM_BASE_URL";
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java
index 8e00b0c..9e405ec 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java
@@ -18,11 +18,23 @@
*/
package org.rhq.enterprise.server.plugin.pc.drift;
+import java.util.List;
+import java.util.Properties;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.plugin.pc.ServerPluginEnvironment;
import org.rhq.enterprise.server.plugin.pc.ServerPluginManager;
+import org.rhq.enterprise.server.system.SystemManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+import org.rhq.enterprise.server.xmlschema.generated.serverplugin.ServerPluginDescriptorType;
+
+import static org.rhq.core.domain.util.StringUtils.getListAsString;
+import static org.rhq.core.domain.util.StringUtils.getStringAsList;
+import static org.rhq.enterprise.server.RHQConstants.ACTIVE_DRIFT_PLUGIN;
+import static org.rhq.enterprise.server.RHQConstants.DRIFT_PLUGINS;
/**
* This loads in all drift server plugins that can be found. You can obtain a loaded plugin's
@@ -32,6 +44,7 @@ import org.rhq.enterprise.server.plugin.pc.ServerPluginManager;
* @author John Sanda
*/
public class DriftServerPluginManager extends ServerPluginManager {
+
private final Log log = LogFactory.getLog(this.getClass());
public DriftServerPluginManager(DriftServerPluginContainer pc) {
@@ -39,7 +52,76 @@ public class DriftServerPluginManager extends ServerPluginManager {
}
public DriftServerPluginFacet getDriftServerPluginComponent() {
- // TODO The name of the drift server plugin probably will need to be obtained from the system config
- return (DriftServerPluginFacet) getServerPluginComponent("drift-rhq");
+ Properties sysConfig = getSysConfig();
+ String value = sysConfig.getProperty(ACTIVE_DRIFT_PLUGIN);
+
+ if (value == null) {
+ throw new RuntimeException(ACTIVE_DRIFT_PLUGIN + " system configuration property is not set.");
+ }
+
+ return (DriftServerPluginFacet) getServerPluginComponent(value.substring(1, value.indexOf("$$")));
+ }
+
+ @Override
+ protected void loadPlugin(ServerPluginEnvironment env, boolean enabled) throws Exception {
+ super.loadPlugin(env, enabled);
+
+ String pluginName = env.getPluginKey().getPluginName();
+ List<String> plugins = getDriftPlugins();
+
+ int index = findPluginIndex(plugins, pluginName);
+ if (index == -1) {
+ plugins.add("[" + pluginName + "$$" + env.getPluginDescriptor().getDisplayName() + "]");
+ saveDriftPlugins(plugins);
+ }
+
+ }
+
+ @Override
+ protected void unloadPlugin(String pluginName) throws Exception {
+ super.unloadPlugin(pluginName);
+
+ List<String> plugins = getDriftPlugins();
+ int index = findPluginIndex(plugins, pluginName);
+
+ if (index != -1) {
+ plugins.remove(index);
+ saveDriftPlugins(plugins);
+ }
+ }
+
+ private List<String> getDriftPlugins() {
+ Properties sysConfig = getSysConfig();
+ return getStringAsList(sysConfig.getProperty(DRIFT_PLUGINS, ""), ",", true);
}
+
+ private void saveDriftPlugins(List<String> plugins) throws Exception {
+ SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
+ SystemManagerLocal systemMgr = LookupUtil.getSystemManager();
+
+ Properties sysConfig = systemMgr.getSystemConfiguration(subjectMgr.getOverlord());
+ sysConfig.put(DRIFT_PLUGINS, getListAsString(plugins, ","));
+ systemMgr.setSystemConfiguration(subjectMgr.getOverlord(), sysConfig, false);
+ }
+
+ private Properties getSysConfig() {
+ SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
+ SystemManagerLocal systemMgr = LookupUtil.getSystemManager();
+
+ return systemMgr.getSystemConfiguration(subjectMgr.getOverlord());
+ }
+
+ private int findPluginIndex(List<String> plugins, String name) {
+ int i = 0;
+ for (String value : plugins) {
+ // value is of the form, [plugin_name$$plugin_display_name]
+ if (name.equals(value.substring(1, value.indexOf("$$")))) {
+ return i;
+ }
+ ++i;
+ }
+ return -1;
+ }
+
+
}
\ No newline at end of file
diff --git a/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
index 349b84c..b385473 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
@@ -143,7 +143,7 @@ public class JPAUtils {
em.createNativeQuery("delete from rhq_measurement_sched");
em.createNativeQuery("delete from rhq_measurement_def");
em.createNativeQuery("delete from rhq_plugin");
- em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56)");
+ em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56, 57, 58)");
em.createNativeQuery("delete from rhq_alert_notification");
em.createNativeQuery("delete from rhq_alert_condition_log");
em.createNativeQuery("delete from rhq_alert");
commit fea0df9ea83a2abea14e4f80d3e5143458e7edd3
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 27 10:03:47 2011 -0400
Deleting scratch file that should not be in git
diff --git a/modules/core/domain/mvn.out b/modules/core/domain/mvn.out
deleted file mode 100644
index 7e78162..0000000
--- a/modules/core/domain/mvn.out
+++ /dev/null
@@ -1,194 +0,0 @@
-[INFO]
-NOTE: Maven is executing in offline mode. Any artifacts not already in your local
-repository will be inaccessible.
-
-[INFO] Scanning for projects...
-[INFO] ------------------------------------------------------------------------
-[INFO] Building RHQ Domain Model
-[INFO] task-segment: [clean, test]
-[INFO] ------------------------------------------------------------------------
-[INFO] [clean:clean {execution: default-clean}]
-[INFO] Deleting /home/jsanda/Development/redhat/rhq/modules/core/domain/target
-[INFO] [enforcer:enforce {execution: enforce-versions}]
-[INFO] [build-helper:maven-version {execution: default}]
-[WARNING] DEPRECATED [tasks]: Use target instead
-[INFO] [antrun:run {execution: write-build-properties-file}]
-[WARNING] Parameter tasks is deprecated, use target instead
-[INFO] Executing tasks
-
-main:
-[INFO] Executed tasks
-[INFO] [properties:read-project-properties {execution: read-build-properties-file}]
-[INFO] [resources:resources {execution: default-resources}]
-[INFO] Using 'ISO-8859-1' encoding to copy filtered resources.
-[INFO] Copying 393 resources
-[INFO] Copying 2 resources
-[INFO] [compiler:compile {execution: default-compile}]
-[INFO] Compiling 391 source files to /home/jsanda/Development/redhat/rhq/modules/core/domain/target/classes
-[WARNING] DEPRECATED [tasks]: Use target instead
-[INFO] [antrun:run {execution: echo-build-properties}]
-[WARNING] Parameter tasks is deprecated, use target instead
-[INFO] Executing tasks
-
-main:
-[INFO] Executed tasks
-[INFO] [resources:testResources {execution: default-testResources}]
-[INFO] Using 'ISO-8859-1' encoding to copy filtered resources.
-[INFO] Copying 13 resources
-[INFO] [compiler:testCompile {execution: default-testCompile}]
-[INFO] Compiling 54 source files to /home/jsanda/Development/redhat/rhq/modules/core/domain/target/test-classes
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java:[116,70] [deprecation] connection() in org.hibernate.Session has been deprecated
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/content/test/PackageVersionContentSourceTest.java:[118,71] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.content.PackageVersionContentSource>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/content/test/PackageVersionContentSourceTest.java:[157,80] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.content.composite.PackageVersionMetadataComposite>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/TestUtil.java:[42,37] [unchecked] unchecked cast
-found : java.lang.Object
-required: T
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/test/ConfigurationTest.java:[198,26] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.configuration.Configuration>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/AgentTest.java:[67,37] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.resource.composite.AgentLastAvailabilityReportComposite>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/AgentTest.java:[90,37] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.resource.composite.AgentLastAvailabilityReportComposite>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/AgentTest.java:[112,37] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.resource.composite.AgentLastAvailabilityReportComposite>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/AgentTest.java:[117,37] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.resource.composite.AgentLastAvailabilityReportComposite>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/test/SerializableTest.java:[177,19] [unchecked] unchecked cast
-found : java.lang.Object
-required: T
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/test/ConfigurationDefinitionTest.java:[98,105] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.configuration.definition.ConfigurationDefinition>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/test/ConfigurationDefinitionTest.java:[135,30] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.configuration.definition.ConfigurationDefinition>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/test/ConfigurationDefinitionTest.java:[184,26] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.configuration.definition.ConfigurationDefinition>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/resource/ResourceTypeTest.java:[41,26] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.resource.ResourceType>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java:[332,50] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.plugin.Plugin>
-[WARNING] DEPRECATED [systemProperties]: Use systemPropertyVariables instead.
-[INFO] [surefire:test {execution: default-test}]
-[INFO] Surefire report directory: /home/jsanda/Development/redhat/rhq/modules/core/domain/target/surefire-reports
-
--------------------------------------------------------
- T E S T S
--------------------------------------------------------
-Running TestSuite
-Starting ejb3...
-Loading EJB3 classes from directory: target/classes
-log4j: Threshold ="null".
-log4j: Class name: [org.apache.log4j.ConsoleAppender]
-log4j: Setting property [target] to [System.out].
-log4j: Setting property [threshold] to [WARN].
-log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
-log4j: Setting property [conversionPattern] to [%-5p %d{dd-MM HH:mm:ss,SSS} (%F:%M:%L) -%m%n].
-log4j: Adding appender named [CONSOLE] to category [root].
-WARN 13-07 15:00:21,151 (Ejb3Configuration.java:addXMLEntities:422) -Persistence provider caller does not implements the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.
-lookup
- UserTransaction: org.jboss.ejb3.embedded.UserTransactionImpl
-...... embedded-jboss-beans deployed....
-...... deploying MM ejb3.....
-...... ejb3 deployed....
-...... deployer created....
-WARN 13-07 15:00:29,804 (Ejb3Configuration.java:addXMLEntities:422) -Persistence provider caller does not implements the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.
-lookup
- UserTransaction: org.jboss.ejb3.embedded.UserTransactionImpl
-...... deployer started....
-Configuration definition: CONFIG_ENUM_VAL_TEST (test data)
- SimpleProperty[EnumeratedProperty] (Type: STRING)
-Before: [PropertyDefinitionEnumeration{id=10871, name='A', value='a', orderIndex=0}, PropertyDefinitionEnumeration{id=10872, name='B', value='b', orderIndex=1}]
-After: [PropertyDefinitionEnumeration{id=10872, name='B', value='b', orderIndex=1}, PropertyDefinitionEnumeration{id=10871, name='A', value='a', orderIndex=0}]
-Configuration definition: CONFIG_CONSTRAINT_TEST (test data)
- SimpleProperty[ConstrainedProperty] (Type: FLOAT)
-Constraint: FloatRangeConstraint[details=1.0#3.0]
-Configuration definition: TEST_CONFIG (Config definition for the thing)
- SimpleProperty[SimpleProp] (Type: STRING)
- Map Property [MapProp]
- SimpleProperty[IntInMap] (Type: INTEGER)
- SimpleProperty[ConnectionType] (Type: STRING)(Group: Basic Group)
- SimpleProperty[SimpleBool] (Type: BOOLEAN)(Group: Basic Group)
-Serialized version of config was 1367 bytes
-WARN 13-07 15:01:20,904 (JDBCExceptionReporter.java:logExceptions:77) -SQL Error: 0, SQLState: 23505
-ERROR 13-07 15:01:20,905 (JDBCExceptionReporter.java:logExceptions:78) -Batch entry 0 insert into RHQ_DRIFT_FILE (CTIME, DATA_SIZE, STATUS, DATA, HASH_ID) values ('1310583680392', '10485760', 'EMPTY', '1489397', '6486d7a1e0f8a97387e1f1f8780ea7dd1ab212a4b862bcefdfb0f1d1480f9996') was aborted. Call getNextException to see the cause.
-WARN 13-07 15:01:20,906 (JDBCExceptionReporter.java:logExceptions:77) -SQL Error: 0, SQLState: 23505
-ERROR 13-07 15:01:20,906 (JDBCExceptionReporter.java:logExceptions:78) -ERROR: duplicate key value violates unique constraint "rhq_drift_file_pkey"
-ERROR 13-07 15:01:20,907 (AbstractFlushingEventListener.java:performExecutions:301) -Could not synchronize database state with session
-org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
- at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
- at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
- at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:254)
- at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
- at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
- at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
- at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
- at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
- at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
- at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515)
- at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:3074)
- at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:2632)
- at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:1194)
- at org.jboss.tm.TxManager.commit(TxManager.java:588)
- at org.rhq.core.domain.drift.DriftFileTest.executeInTransaction(DriftFileTest.java:187)
- at org.rhq.core.domain.drift.DriftFileTest.loadSameFile(DriftFileTest.java:152)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
- at java.lang.reflect.Method.invoke(Method.java:597)
- at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:640)
- at org.testng.internal.Invoker.invokeMethod(Invoker.java:627)
- at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:798)
- at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1102)
- at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:137)
- at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:121)
- at org.testng.TestRunner.runWorkers(TestRunner.java:1009)
- at org.testng.TestRunner.privateRun(TestRunner.java:683)
- at org.testng.TestRunner.run(TestRunner.java:553)
- at org.testng.SuiteRunner.runTest(SuiteRunner.java:311)
- at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:306)
- at org.testng.SuiteRunner.privateRun(SuiteRunner.java:268)
- at org.testng.SuiteRunner.run(SuiteRunner.java:217)
- at org.testng.TestNG.runSuite(TestNG.java:1062)
- at org.testng.TestNG.runSuitesLocally(TestNG.java:956)
- at org.testng.TestNG.run(TestNG.java:874)
- at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:61)
- at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:144)
- at org.apache.maven.surefire.Surefire.run(Surefire.java:169)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
- at java.lang.reflect.Method.invoke(Method.java:597)
- at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
- at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)
-Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into RHQ_DRIFT_FILE (CTIME, DATA_SIZE, STATUS, DATA, HASH_ID) values ('1310583680392', '10485760', 'EMPTY', '1489397', '6486d7a1e0f8a97387e1f1f8780ea7dd1ab212a4b862bcefdfb0f1d1480f9996') was aborted. Call getNextException to see the cause.
- at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2598)
- at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
- at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
- at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2737)
- at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:518)
- at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
- at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:247)
- ... 42 more
-testTraitQuery ...
-testTraitQuery: found 1 item(s)
- and it is MeasurementDataTrait[value=[Hello World], MeasurementData [MeasurementDataPK: timestamp=[Wed Jul 13 15:01:21 EDT 2011], scheduleId=[12011]]] and name Fake display name
-Created resource with id 13617
-Created resource with id 13618
-Took [5092]ms to create [2000] resources
-Took [853]ms to remove [2000] resources
-Destroying 1 processes
-Destroying process..
-Destroyed 1 processes
commit e753a90cb8d2ab73c2943d9c9491962798ff771d
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 26 22:32:38 2011 -0400
Initial commit for drift DTOs
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftComposite.java
index 068907a..3313755 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftComposite.java
@@ -24,7 +24,15 @@ public class DriftComposite implements Serializable {
return drift;
}
+ public void setDrift(Drift drift) {
+ this.drift = drift;
+ }
+
public Resource getResource() {
return resource;
}
+
+ public void setResource(Resource resource) {
+ this.resource = resource;
+ }
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftChangeSetDTO.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftChangeSetDTO.java
new file mode 100644
index 0000000..68a5ff7
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftChangeSetDTO.java
@@ -0,0 +1,84 @@
+package org.rhq.core.domain.drift.dto;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
+
+public class DriftChangeSetDTO implements DriftChangeSet<DriftDTO> {
+
+ private String id;
+
+ private Long ctime;
+
+ private int version;
+
+ private DriftChangeSetCategory category;
+
+ private int configId;
+
+ private int resourceId;
+
+ private Set<DriftDTO> drifts = new HashSet<DriftDTO>();
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public Long getCtime() {
+ return ctime;
+ }
+
+ @Override
+ public int getVersion() {
+ return version;
+ }
+
+ @Override
+ public void setVersion(int version) {
+ this.version = version;
+ }
+
+ @Override
+ public DriftChangeSetCategory getCategory() {
+ return category;
+ }
+
+ @Override
+ public void setCategory(DriftChangeSetCategory category) {
+ this.category = category;
+ }
+
+ @Override
+ public int getDriftConfigurationId() {
+ return configId;
+ }
+
+ @Override
+ public void setDriftConfigurationId(int id) {
+ configId = id;
+ }
+
+ @Override
+ public int getResourceId() {
+ return resourceId;
+ }
+
+ @Override
+ public Set<DriftDTO> getDrifts() {
+ return drifts;
+ }
+
+ @Override
+ public void setDrifts(Set<DriftDTO> drifts) {
+ this.drifts = drifts;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftDTO.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftDTO.java
new file mode 100644
index 0000000..adc5c52
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftDTO.java
@@ -0,0 +1,86 @@
+package org.rhq.core.domain.drift.dto;
+
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftCategory;
+
+public class DriftDTO implements Drift<DriftChangeSetDTO, DriftFileDTO> {
+
+ private String id;
+
+ private Long ctime;
+
+ private DriftChangeSetDTO changeSet;
+
+ private DriftCategory category;
+
+ private String path;
+
+ private DriftFileDTO oldDriftFile;
+
+ private DriftFileDTO newDriftFile;
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public Long getCtime() {
+ return ctime;
+ }
+
+ @Override
+ public DriftChangeSetDTO getChangeSet() {
+ return changeSet;
+ }
+
+ @Override
+ public void setChangeSet(DriftChangeSetDTO changeSet) {
+ this.changeSet = changeSet;
+ }
+
+ @Override
+ public DriftCategory getCategory() {
+ return category;
+ }
+
+ @Override
+ public void setCategory(DriftCategory category) {
+ this.category = category;
+ }
+
+ @Override
+ public String getPath() {
+ return path;
+ }
+
+ @Override
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ @Override
+ public DriftFileDTO getOldDriftFile() {
+ return oldDriftFile;
+ }
+
+ @Override
+ public void setOldDriftFile(DriftFileDTO oldDriftFile) {
+ this.oldDriftFile = oldDriftFile;
+ }
+
+ @Override
+ public DriftFileDTO getNewDriftFile() {
+ return newDriftFile;
+ }
+
+ @Override
+ public void setNewDriftFile(DriftFileDTO newDriftFile) {
+ this.newDriftFile = newDriftFile;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftFileDTO.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftFileDTO.java
new file mode 100644
index 0000000..97fa7ef
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/dto/DriftFileDTO.java
@@ -0,0 +1,50 @@
+package org.rhq.core.domain.drift.dto;
+
+import org.rhq.core.domain.drift.DriftFile;
+import org.rhq.core.domain.drift.DriftFileStatus;
+
+public class DriftFileDTO implements DriftFile {
+
+ private String hash;
+
+ private Long ctime;
+
+ private Long size;
+
+ private DriftFileStatus status;
+
+ @Override
+ public String getHashId() {
+ return hash;
+ }
+
+ @Override
+ public void setHashId(String hashId) {
+ hash = hashId;
+ }
+
+ @Override
+ public Long getCtime() {
+ return ctime;
+ }
+
+ @Override
+ public Long getDataSize() {
+ return size;
+ }
+
+ @Override
+ public void setDataSize(Long size) {
+ this.size = size;
+ }
+
+ @Override
+ public DriftFileStatus getStatus() {
+ return status;
+ }
+
+ @Override
+ public void setStatus(DriftFileStatus status) {
+ this.status = status;
+ }
+}
commit d9fdb0434e2828b47b77138f8fd1856f3728c4a1
Merge: 5840be4 e14fb8a
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 26 22:33:24 2011 -0400
Merge branch 'drift' into drift-mongodb
commit e14fb8a490ab8b2838612fcb6a5795427dfb93ad
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 26 21:22:19 2011 -0400
Persist drift detection schedule across agent restarts
This commit add functionality for persisting drift detection schedules
across restarts. When the agent is shutting down and the inventory is
persisted to disk, the schedules are now written out to disk along with
the rest of the inventory.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java
index fe42744..ab5bac3 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java
@@ -1,8 +1,12 @@
package org.rhq.core.pc.drift;
+import java.io.Serializable;
+
import org.rhq.core.domain.drift.DriftConfiguration;
-public class DriftDetectionSchedule implements Comparable<DriftDetectionSchedule> {
+public class DriftDetectionSchedule implements Comparable<DriftDetectionSchedule>, Serializable {
+
+ private static final long serialVersionUID = 1L;
private int resourceId;
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
index f499697..879ceca 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
@@ -67,11 +67,36 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
driftDetector.setChangeSetManager(changeSetMgr);
driftDetector.setDriftClient(this);
+ InventoryManager inventoryMgr = PluginContainer.getInstance().getInventoryManager();
+ initSchedules(inventoryMgr.getPlatform(), inventoryMgr);
+
driftThreadPool = new ScheduledThreadPoolExecutor(5);
// TODO Make the drift detection rate configurable
driftThreadPool.scheduleAtFixedRate(driftDetector, 30, 60, TimeUnit.SECONDS);
}
+ private void initSchedules(Resource r, InventoryManager inventoryMgr) {
+ if (r.getId() == 0) {
+ log.debug("Will not reschedule drift detection schedules for " + r + ". It is not sync'ed yet.");
+ return;
+ }
+
+ ResourceContainer container = inventoryMgr.getResourceContainer(r.getId());
+ if (container == null) {
+ log.debug("No resource container found for " + r + ". Unable to reschedule drift detection schedules.");
+ return;
+ }
+
+ log.debug("Rescheduling drift detection schedules for " + r);
+ for (DriftDetectionSchedule schedule : container.getDriftSchedules()) {
+ schedulesQueue.addSchedule(schedule);
+ }
+
+ for (Resource child : r.getChildResources()) {
+ initSchedules(child, inventoryMgr);
+ }
+ }
+
@Override
public void shutdown() {
driftThreadPool.shutdown();
@@ -164,8 +189,8 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
}
@Override
- public boolean update(int resourceId, DriftConfiguration config) {
- return false;
+ public DriftDetectionSchedule update(int resourceId, DriftConfiguration config) {
+ return schedule;
}
@Override
@@ -208,9 +233,16 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
@Override
public void updateDriftDetection(int resourceId, DriftConfiguration driftConfiguration) {
- boolean updated = schedulesQueue.update(resourceId, driftConfiguration);
- if (!updated) {
- schedulesQueue.addSchedule(new DriftDetectionSchedule(resourceId, driftConfiguration));
+ DriftDetectionSchedule updatedSchedule = schedulesQueue.update(resourceId, driftConfiguration);
+ if (updatedSchedule == null) {
+ updatedSchedule = new DriftDetectionSchedule(resourceId, driftConfiguration);
+ schedulesQueue.addSchedule(updatedSchedule);
+ }
+
+ InventoryManager inventoryMgr = PluginContainer.getInstance().getInventoryManager();
+ ResourceContainer container = inventoryMgr.getResourceContainer(resourceId);
+ if (container != null) {
+ container.getDriftSchedules().add(updatedSchedule);
}
}
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 ca7edc5..374e27e 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
@@ -38,7 +38,7 @@ public interface ScheduleQueue {
* Adds a schedule to the queue for processing by the drift detector
*
* @param schedule A {@link DriftDetectionSchedule} object
- * @return true if the schedule is added, falsed otherwise
+ * @return true if the schedule is added, false otherwise
*/
boolean addSchedule(DriftDetectionSchedule schedule);
@@ -52,9 +52,9 @@ public interface ScheduleQueue {
*
* @param resourceId The resource id
* @param config A {@link DriftConfiguration} belonging the resource with the specified id
- * @return true if the schedule is updated, false otherwise.
+ * @return A copy of the updated schedule or null if no update was performed
*/
- boolean update(int resourceId, DriftConfiguration config);
+ DriftDetectionSchedule update(int resourceId, DriftConfiguration config);
/**
* Removes the schedule identified by the resource id and the drift configuration. More
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 499ad91..b4a2f00 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
@@ -112,20 +112,26 @@ public class ScheduleQueueImpl implements ScheduleQueue {
}
@Override
- public boolean update(int resourceId, DriftConfiguration config) {
+ public DriftDetectionSchedule update(int resourceId, DriftConfiguration config) {
try {
lock.writeLock().lock();
if (isActiveSchedule(resourceId, config)) {
update(activeSchedule, config);
- } else {
- DriftDetectionSchedule schedule = remove(resourceId, config);
- if (schedule == null) {
- return false;
- }
- update(schedule, config);
- queue.offer(schedule);
+ return activeSchedule.copy();
+ }
+
+ DriftDetectionSchedule schedule = remove(resourceId, config);
+ if (schedule == null) {
+ return null;
}
- return true;
+
+ update(schedule, config);
+
+ if (queue.offer(schedule)) {
+ return schedule.copy();
+ }
+
+ return null;
} finally {
lock.writeLock().unlock();
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
index ab8d30e..fcf1aea 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
@@ -52,6 +52,7 @@ import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.pc.drift.DriftDetectionSchedule;
import org.rhq.core.pc.util.FacetLockType;
import org.rhq.core.pc.util.LoggingThreadFactory;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
@@ -88,6 +89,7 @@ public class ResourceContainer implements Serializable {
private SynchronizationState synchronizationState = SynchronizationState.NEW;
private Set<MeasurementScheduleRequest> measurementSchedule = new HashSet<MeasurementScheduleRequest>();
private Set<ResourcePackageDetails> installedPackages = new HashSet<ResourcePackageDetails>();
+ private Set<DriftDetectionSchedule> driftSchedules = new HashSet<DriftDetectionSchedule>();
// transient fields
private transient ResourceComponent resourceComponent;
@@ -242,6 +244,16 @@ public class ResourceContainer implements Serializable {
}
}
+ public Set<DriftDetectionSchedule> getDriftSchedules() {
+ synchronized (this) {
+ return driftSchedules;
+ }
+ }
+
+ public void setDriftSchedules(Set<DriftDetectionSchedule> schedules) {
+ driftSchedules = schedules;
+ }
+
public ResourceComponentState getResourceComponentState() {
synchronized (this) {
return this.resourceComponentState;
commit 1359b2b4bb7743395916b0a8fab21cff1bc214cf
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jul 26 18:31:39 2011 -0400
tweek folder icons for drift
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png
index fdda214..e728bc8 100644
Binary files a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png
index 358cf61..1ca204f 100644
Binary files a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png differ
commit 302705e7ebf3731bb5eb27d67c8a4f8b38a93248
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 26 16:14:26 2011 -0400
Adding support for updating drift configs
When the server sends a request to the agent to update a drift
configuration, that config is attached to a schedule which is in one of
two places. It is either on the schedule queue or it is "active"
schedule currently being processed by the drift detector. The config
update will be applied such that the next time the drift detector
processes the schedule the update will take effect.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java
index a767b99..fe42744 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java
@@ -32,6 +32,13 @@ public class DriftDetectionSchedule implements Comparable<DriftDetectionSchedule
nextScan = System.currentTimeMillis() + (driftConfig.getInterval() * 1000);
}
+ public DriftDetectionSchedule copy() {
+ DriftDetectionSchedule copy = new DriftDetectionSchedule(resourceId,
+ new DriftConfiguration(driftConfig.getConfiguration().deepCopyWithoutProxies()));
+ copy.nextScan = nextScan;
+ return copy;
+ }
+
@Override
public int compareTo(DriftDetectionSchedule other) {
if (this.nextScan < other.nextScan) {
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 b92dd7c..153e5a9 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
@@ -47,52 +47,44 @@ public class DriftDetector implements Runnable {
@Override
public void run() {
- DriftDetectionSchedule schedule = scheduleQueue.dequeue();
+ DriftDetectionSchedule schedule = scheduleQueue.getNextSchedule();
if (schedule == null) {
return;
}
- if (schedule.getNextScan() > (System.currentTimeMillis() + 100L)) {
- scheduleQueue.enqueue(schedule);
- // TODO should we grab the schedule from the queue?
- // Maybe we should continue pulling schedules off the queue until
- // we find one that is ready to be processed.
- return;
- }
-
- if (!schedule.getDriftConfiguration().getEnabled()) {
- schedule.updateShedule();
- scheduleQueue.enqueue(schedule);
- // TODO should we grab the schedule from the queue?
- // Maybe we should continue pulling schedules off the queue until
- // we find one that is ready to be processed.
- return;
- }
-
- DriftConfiguration driftConfig = schedule.getDriftConfiguration();
- int resourceId = schedule.getResourceId();
- DriftChangeSetCategory changeSetType = null;
- int changes = 0;
-
try {
- if (changeSetMgr.changeSetExists(schedule.getResourceId(), new Headers(driftConfig.getName(),
- basedir(resourceId, driftConfig), COVERAGE))) {
- changeSetType = DRIFT;
- changes = generateDriftChangeSet(schedule);
- } else {
- changeSetType = COVERAGE;
- generateCoverageChangeSet(schedule);
+ if (schedule.getNextScan() > (System.currentTimeMillis() + 100L)) {
+ return;
}
- } catch (IOException e) {
- // TODO Call ChangeSetManager here to rollback any thing that was written to disk.
- log.error("An error occurred while scanning for drift", e);
- }
- schedule.updateShedule();
- scheduleQueue.enqueue(schedule);
+ if (!schedule.getDriftConfiguration().getEnabled()) {
+ return;
+ }
- if (changeSetType == COVERAGE || changes > 0) {
- driftClient.sendChangeSetToServer(schedule.getResourceId(), driftConfig, changeSetType);
+ DriftConfiguration driftConfig = schedule.getDriftConfiguration();
+ int resourceId = schedule.getResourceId();
+ DriftChangeSetCategory changeSetType = null;
+ int changes = 0;
+
+ try {
+ if (changeSetMgr.changeSetExists(schedule.getResourceId(), new Headers(driftConfig.getName(),
+ basedir(resourceId, driftConfig), COVERAGE))) {
+ changeSetType = DRIFT;
+ changes = generateDriftChangeSet(schedule);
+ } else {
+ changeSetType = COVERAGE;
+ generateCoverageChangeSet(schedule);
+ }
+ } catch (IOException e) {
+ // TODO Call ChangeSetManager here to rollback any thing that was written to disk.
+ log.error("An error occurred while scanning for drift", e);
+ }
+
+ if (changeSetType == COVERAGE || changes > 0) {
+ driftClient.sendChangeSetToServer(schedule.getResourceId(), driftConfig, changeSetType);
+ }
+ } finally {
+ scheduleQueue.deactivateSchedule();
}
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
index b688154..f499697 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
@@ -141,14 +141,14 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
DriftDetectionSchedule schedule;
@Override
- public DriftDetectionSchedule dequeue() {
+ public DriftDetectionSchedule getNextSchedule() {
DriftDetectionSchedule removedSchedule = schedule;
schedule = null;
return removedSchedule;
}
@Override
- public boolean enqueue(DriftDetectionSchedule schedule) {
+ public boolean addSchedule(DriftDetectionSchedule schedule) {
this.schedule = schedule;
return true;
}
@@ -157,8 +157,23 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
public void clear() {
schedule = null;
}
+
+ @Override
+ public void deactivateSchedule() {
+ schedule = null;
+ }
+
+ @Override
+ public boolean update(int resourceId, DriftConfiguration config) {
+ return false;
+ }
+
+ @Override
+ public DriftDetectionSchedule remove(int resourceId, DriftConfiguration config) {
+ return null;
+ }
};
- queue.enqueue(new DriftDetectionSchedule(resourceId, driftConfiguration));
+ queue.addSchedule(new DriftDetectionSchedule(resourceId, driftConfiguration));
DriftDetector driftDetector = new DriftDetector();
driftDetector.setChangeSetManager(changeSetMgr);
@@ -170,7 +185,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
@Override
public void scheduleDriftDetection(int resourceId, DriftConfiguration driftConfiguration) {
- schedulesQueue.enqueue(new DriftDetectionSchedule(resourceId, driftConfiguration));
+ schedulesQueue.addSchedule(new DriftDetectionSchedule(resourceId, driftConfiguration));
}
@Override
@@ -193,6 +208,10 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
@Override
public void updateDriftDetection(int resourceId, DriftConfiguration driftConfiguration) {
+ boolean updated = schedulesQueue.update(resourceId, driftConfiguration);
+ if (!updated) {
+ schedulesQueue.addSchedule(new DriftDetectionSchedule(resourceId, driftConfiguration));
+ }
}
/**
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 09b0aa5..ca7edc5 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
@@ -1,11 +1,79 @@
package org.rhq.core.pc.drift;
+import org.rhq.core.domain.drift.DriftConfiguration;
+
+/**
+ * Manages the drift detection schedules that are processed by the drift detector. The
+ * queue has a concept of the currently "active" schedule. This is identified simply as
+ * the schedule returned from {@link #getNextSchedule()} which is the previous head of the
+ * queue. A reference to the active schedule needs to be maintained because at any point in
+ * time the server can send a request to update the drift configuration that is attached to
+ * a schedule. That schedule will either be on the queue waiting to be processed or in the
+ * "active" state meaning it is currently being processed by the drift detector.
+ */
public interface ScheduleQueue {
- DriftDetectionSchedule dequeue();
+ /**
+ * Removes the head of the queue and returns a copy of the schedule that was removed.
+ * That schedule is also marked as the active schedule.
+ *
+ * @return A copy of the schedule that is removed from the head of the queue.
+ *
+ * @see DriftDetectionSchedule
+ *
+ * @throws IllegalStateException if there is already an active schedule. The active
+ * schedule must be deactivated before getting the next schedule.
+ */
+ DriftDetectionSchedule getNextSchedule();
+
+ /**
+ * This method does two things. First it updates the active schedule's nextScan
+ * property. Then it adds the schedule back onto the queue, allowing the next schedule
+ * at the head of the queue to become active. If there is no active schedule this
+ * method simply does nothing and returns.
+ */
+ void deactivateSchedule();
+
+ /**
+ * Adds a schedule to the queue for processing by the drift detector
+ *
+ * @param schedule A {@link DriftDetectionSchedule} object
+ * @return true if the schedule is added, falsed otherwise
+ */
+ boolean addSchedule(DriftDetectionSchedule schedule);
+
+ /**
+ * This method attempts to update the schedule identified by the resource id the and
+ * the drift configuration. More specifically, the schedule is identified by a
+ * combination of resource id and drift configuraiton name. If the schedule to be
+ * updated is the active schedule, it is immediately updated and then placed back on
+ * the queue the next time {@link #deactivateSchedule()} is called. If the schedule
+ * is on the queue, it is removed, updated, and then added back onto the queue.
+ *
+ * @param resourceId The resource id
+ * @param config A {@link DriftConfiguration} belonging the resource with the specified id
+ * @return true if the schedule is updated, false otherwise.
+ */
+ boolean update(int resourceId, DriftConfiguration config);
- boolean enqueue(DriftDetectionSchedule schedule);
+ /**
+ * Removes the schedule identified by the resource id and the drift configuration. More
+ * specifically, the schedule is identified by a combination of resource id drift
+ * configuration name. This method can remove either the active schedule or a schedule
+ * on the queue.
+ *
+ * @param resourceId The resource id
+ *
+ * @param config A {@link DriftConfiguration} belonging the resource with the specified id
+ *
+ * @return The {@link DriftDetectionSchedule} that is removed or null if no matching
+ * schedule is found.
+ */
+ DriftDetectionSchedule remove(int resourceId, DriftConfiguration config);
+ /**
+ * Removes all elements from the queue and deactivates the active schedule.
+ */
void clear();
}
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 7934c2d..499ad91 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
@@ -3,24 +3,54 @@ package org.rhq.core.pc.drift;
import java.util.PriorityQueue;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import org.rhq.core.domain.drift.DriftConfiguration;
+
public class ScheduleQueueImpl implements ScheduleQueue {
private PriorityQueue<DriftDetectionSchedule> queue = new PriorityQueue<DriftDetectionSchedule>();
private ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+ private DriftDetectionSchedule activeSchedule;
+
@Override
- public DriftDetectionSchedule dequeue() {
+ public DriftDetectionSchedule getNextSchedule() {
try {
lock.writeLock().lock();
- return queue.poll();
+ if (activeSchedule != null) {
+ throw new IllegalStateException("There is already an active schedule that must be deactivated " +
+ "before getting the next schedule.");
+ }
+ activeSchedule = queue.poll();
+ return activeSchedule == null ? null : activeSchedule.copy();
} finally {
lock.writeLock().unlock();
}
}
+ private boolean isActiveSchedule(int resourceId, DriftConfiguration config) {
+ return activeSchedule != null && activeSchedule.getResourceId() == resourceId &&
+ activeSchedule.getDriftConfiguration().getName().equals(config.getName());
+
+ }
+
@Override
- public boolean enqueue(DriftDetectionSchedule schedule) {
+ public void deactivateSchedule() {
+ try {
+ lock.writeLock().lock();
+ if (activeSchedule == null) {
+ return;
+ }
+ activeSchedule.updateShedule();
+ queue.offer(activeSchedule);
+ activeSchedule = null;
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
+ @Override
+ public boolean addSchedule(DriftDetectionSchedule schedule) {
boolean inserted = false;
try {
lock.writeLock().lock();
@@ -32,9 +62,85 @@ public class ScheduleQueueImpl implements ScheduleQueue {
}
@Override
+ public DriftDetectionSchedule remove(int resourceId, DriftConfiguration config) {
+ DriftDetectionSchedule scheduleToRemove = null;
+ try {
+ lock.readLock().lock();
+ if (isActiveSchedule(resourceId, config)) {
+ // The schedule to be removed is the currently active schedule so "upgrade"
+ // to the write lock and return the schedule while removing it from the queue
+ // at the same time.
+ try {
+ lock.writeLock().lock();
+ DriftDetectionSchedule removedSchedule = activeSchedule;
+ activeSchedule = null;
+ return removedSchedule;
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
+ for (DriftDetectionSchedule s : queue) {
+ if (s.getResourceId() == resourceId &&
+ s.getDriftConfiguration().getName().equals(config.getName())) {
+ scheduleToRemove = s;
+ break;
+ }
+ }
+
+ // The schedule was not found in the queue so we can simply return null without
+ // any additional processing.
+ if (scheduleToRemove == null) {
+ return null;
+ }
+
+ boolean removed = false;
+ // At this point, we found the target schedule in the queue. We "upgrade" to
+ // the write lock and remove it from the queue. If the schedule was successfully
+ // removed we return it; otherwise, return null.
+ try {
+ lock.writeLock().lock();
+ removed = queue.remove(scheduleToRemove);
+ } finally {
+ lock.writeLock().unlock();
+ }
+
+ return removed ? scheduleToRemove : null;
+ } finally {
+ lock.readLock().unlock();
+ }
+ }
+
+ @Override
+ public boolean update(int resourceId, DriftConfiguration config) {
+ try {
+ lock.writeLock().lock();
+ if (isActiveSchedule(resourceId, config)) {
+ update(activeSchedule, config);
+ } else {
+ DriftDetectionSchedule schedule = remove(resourceId, config);
+ if (schedule == null) {
+ return false;
+ }
+ update(schedule, config);
+ queue.offer(schedule);
+ }
+ return true;
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
+ private void update(DriftDetectionSchedule schedule, DriftConfiguration config) {
+ schedule.getDriftConfiguration().setEnabled(config.getEnabled());
+ schedule.getDriftConfiguration().setInterval(config.getInterval());
+ }
+
+ @Override
public void clear() {
try {
lock.writeLock().lock();
+ activeSchedule = null;
queue.clear();
} finally {
lock.writeLock().unlock();
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 9b62422..49dab54 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
@@ -58,7 +58,7 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration driftConfig = driftConfiguration("coverage-test", resourceDir.getAbsolutePath());
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), driftConfig));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), driftConfig));
detector.run();
File changeSet = changeSet(driftConfig.getName(), COVERAGE);
@@ -77,12 +77,12 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration driftConfig = driftConfiguration("basedir-entry-test", resourceDir.getAbsolutePath());
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), driftConfig));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), driftConfig));
detector.run();
DriftDetectionSchedule schedule = new DriftDetectionSchedule(resourceId(), driftConfig);
- scheduleQueue.enqueue(schedule);
+ scheduleQueue.addSchedule(schedule);
detector.run();
assertChangeSetContainsDirEntry(changeSet(driftConfig.getName(), COVERAGE),
@@ -102,7 +102,7 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration config = driftConfiguration("multiple-files-test", resourceDir.getAbsolutePath());
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File changeSet = changeSet(config.getName(), COVERAGE);
@@ -127,7 +127,7 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration config = driftConfiguration("sibling-dirs-test", resourceDir.getAbsolutePath());
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File changeSet = changeSet(config.getName(), COVERAGE);
@@ -153,7 +153,7 @@ public class DriftDetectorTest extends DriftTest {
DriftConfiguration config = driftConfiguration("nested-dirs-test", resourceDir.getAbsolutePath());
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File changeSet = changeSet(config.getName(), COVERAGE);
@@ -188,7 +188,7 @@ public class DriftDetectorTest extends DriftTest {
File server1Conf = new File(confDir, "server-1.conf");
touch(server1Conf);
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
detector.run();
}
@@ -217,7 +217,7 @@ public class DriftDetectorTest extends DriftTest {
File server2Conf = new File(confDir, "server-2.conf");
touch(server2Conf);
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File driftChangeSet = changeSet(config.getName(), DRIFT);
@@ -266,7 +266,7 @@ public class DriftDetectorTest extends DriftTest {
// create some drift
server2Conf.delete();
- scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ scheduleQueue.addSchedule(new DriftDetectionSchedule(resourceId(), config));
detector.run();
File driftChangeSet = changeSet(config.getName(), DRIFT);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
index 276c8b9..9de0966 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
@@ -145,7 +145,7 @@ public class DriftServerBean implements DriftServerLocal {
AgentClient agentClient = agentMgr.getAgentClient(subjectMgr.getOverlord(), resourceId);
DriftAgentService service = agentClient.getDriftAgentService();
try {
- service.scheduleDriftDetection(resourceId, driftConfig);
+ service.updateDriftDetection(resourceId, driftConfig);
} catch (Exception e) {
log.warn(" Unable to inform agent of unscheduled drift detection [" + driftConfig + "]", e);
}
commit 934d364a217e74c33f22f19f472ee33a7ad68e5f
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jul 26 16:05:42 2011 -0400
add sort direction
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
index 2d7205d..6085af1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -26,6 +26,7 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
@@ -70,6 +71,7 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
setShowRollOver(false);
setShowHeader(false);
setSortField(AbstractDriftChangeSetsTreeDataSource.ATTR_NAME);
+ setSortDirection(SortDirection.DESCENDING);
}
@Override
commit 9299aefd7d32cbca6e5e85a1cc52e113564d8ded
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jul 26 15:58:32 2011 -0400
sort the tree and provide a refresh button
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
index 7778084..2d7205d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -24,7 +24,9 @@ package org.rhq.enterprise.gui.coregui.client.drift;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
+import com.smartgwt.client.data.Record;
import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
import com.smartgwt.client.widgets.menu.Menu;
@@ -67,6 +69,7 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
setSelectionType(SelectionStyle.SINGLE);
setShowRollOver(false);
setShowHeader(false);
+ setSortField(AbstractDriftChangeSetsTreeDataSource.ATTR_NAME);
}
@Override
@@ -198,6 +201,17 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
return contextMenu;
}
+ /**
+ * We override this because we know all of our nodes will have titles. Without this,
+ * I could not get the title of change set nodes to show - it always fell back to using
+ * the name. This way is at least faster, since we don't do any conditional checking,
+ * we always immediately use the getTitle results.
+ */
+ @Override
+ protected String getNodeTitle(Record node, int recordNum, ListGridField field) {
+ return ((TreeNode) node).getTitle();
+ }
+
@SuppressWarnings("unchecked")
static class ChangeSetTreeNode extends TreeNode {
public ChangeSetTreeNode(DriftChangeSet changeset) {
@@ -205,7 +219,8 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
setIcon("subsystems/drift/ChangeSet_16.png");
setShowOpenIcon(true);
setID(changeset.getId());
- setName(buildDriftChangeSetNodeName(changeset));
+ setName(padWithZeroes(changeset.getVersion())); // we sort on this column, hence we make sure the version # is padded
+ setTitle(buildDriftChangeSetNodeName(changeset));
}
private String buildDriftChangeSetNodeName(DriftChangeSet changeset) {
@@ -219,6 +234,14 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
str.append(')');
return str.toString();
}
+
+ private String padWithZeroes(int numberToPad) {
+ String stringToPad = String.valueOf(numberToPad);
+ char[] zeroes = new char[10 - stringToPad.length()];
+ for (int i = 0; i < zeroes.length; i++)
+ zeroes[i] = '0';
+ return new String(zeroes) + stringToPad;
+ }
}
@SuppressWarnings("unchecked")
@@ -229,7 +252,12 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
String parentID = drift.getChangeSet().getId();
setParentID(parentID);
setID(parentID + '_' + drift.getId());
- setName(drift.getPath());
+ setName(drift.getPath()); // we sort on this column
+ }
+
+ @Override
+ public String getTitle() {
+ return super.getName();
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
index 48f5bc8..56b4aa2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
@@ -19,7 +19,14 @@
*/
package org.rhq.enterprise.gui.coregui.client.drift;
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.toolbar.ToolStrip;
+
import org.rhq.core.domain.common.EntityContext;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableToolStrip;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
@@ -42,7 +49,23 @@ public class DriftChangeSetsView extends LocatableVLayout {
protected void onDraw() {
super.onDraw();
- addMember(new ResourceDriftChangeSetsTreeView(extendLocatorId("Tree"), this.hasWriteAccess, this.context));
+ final ResourceDriftChangeSetsTreeView tree = new ResourceDriftChangeSetsTreeView(extendLocatorId("Tree"),
+ this.hasWriteAccess, this.context);
+ addMember(tree);
+
+ ToolStrip toolStrip = new LocatableToolStrip(extendLocatorId("toolstrip"));
+ toolStrip.setBackgroundImage(null);
+ toolStrip.setWidth100();
+ toolStrip.setMembersMargin(3);
+ toolStrip.setPadding(3);
+ IButton refreshButton = new LocatableIButton(extendLocatorId("refreshButton"), MSG.common_button_refresh());
+ refreshButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ tree.refresh();
+ }
+ });
+ toolStrip.addMember(refreshButton);
+ addMember(toolStrip);
}
public EntityContext getContext() {
commit e5b9ac7711eed5dddca75efb27796b80b4f42270
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jul 26 13:34:42 2011 -0400
refactor so we can later put in group classes but still support indiv resources
fix query so we filter on resource ID for resource view
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java
new file mode 100644
index 0000000..50b4634
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeDataSource.java
@@ -0,0 +1,266 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.tree.TreeNode;
+
+import org.rhq.core.domain.criteria.BaseCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
+import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.criteria.DriftJPACriteria;
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.DriftGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * @author John Mazzitelli
+ */
+@SuppressWarnings("unchecked")
+public abstract class AbstractDriftChangeSetsTreeDataSource extends RPCDataSource<Object, BaseCriteria> {
+
+ public static final String ATTR_PARENT_ID = "parentId";
+ public static final String ATTR_ID = "id";
+ public static final String ATTR_NAME = "name";
+
+ private DriftGWTServiceAsync driftService = GWTServiceLookup.getDriftService();
+ private final boolean canManageDrift;
+
+ public AbstractDriftChangeSetsTreeDataSource(boolean canManageDrift) {
+ super();
+ this.canManageDrift = canManageDrift;
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ DataSourceField idDataField = new DataSourceTextField(ATTR_ID, MSG.common_title_id());
+ idDataField.setPrimaryKey(true);
+ fields.add(idDataField);
+
+ DataSourceTextField nameDataField = new DataSourceTextField(ATTR_NAME, MSG.common_title_name());
+ nameDataField.setCanEdit(false);
+ fields.add(nameDataField);
+
+ DataSourceTextField parentIdField = new DataSourceTextField(ATTR_PARENT_ID, MSG.common_title_id_parent());
+ parentIdField.setForeignKey(ATTR_ID);
+ fields.add(parentIdField);
+
+ return fields;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, final BaseCriteria unused) {
+
+ String parentId = request.getCriteria().getAttribute(ATTR_PARENT_ID);
+
+ if (parentId == null) {
+
+ // There is no parent - we are at the root of the tree.
+ // Get the top nodes (the change sets) but to be as fast as possible don't load their drifts.
+ // We will lazily load drifts when the these changeset tree nodes are opened
+ DriftChangeSetCriteria criteria = getDriftChangeSetCriteria(request);
+
+ driftService.findDriftChangeSetsByCriteria(criteria, new AsyncCallback<PageList<DriftChangeSet>>() {
+ public void onSuccess(PageList<DriftChangeSet> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ } else {
+ String changesetId = parentId;
+ DriftCriteria criteria = new DriftJPACriteria();
+ criteria.addFilterChangeSetId(changesetId);
+
+ driftService.findDriftsByCriteria(criteria, new AsyncCallback<PageList<Drift>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onSuccess(PageList<Drift> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
+
+ /*
+ * I am leaving this code commented for future reference. Because today the drit change set tree only
+ * shows simple changeset->drift tree, we don't need this. But if we need to have
+ * multiple types of child nodes, we'll need something like below to query
+ * for the different child node data. For example, we'd need this if we have a tree like:
+ * ChangeSet
+ * |____Resources
+ * | |____ My resource 1
+ * | |____ ...
+ * |_____Drifts
+ * |___ Drift #1
+ * |___ Drift #2
+ * |___ ...
+ * Today we only have Drifts child nodes, so we don't need to have that intermediate
+ * "Drifts" node. If we later want to introduce different node types (like Resources)
+ * we need additional code like below.
+ *
+
+ // we are at an inner node, being asked to get the children of it
+ if (p.endsWith("_drifts")) {
+ // ...load drift items like above in the real code...
+ } else if (p.endsWith("_resources")) {
+ // ...load resource items and put those nodes in the tree...
+ } else {
+ // This is an unknown type of node, so just log an error.
+ // Note that if, in the future, we have other types of nodes (like maybe resource nodes for group change sets?)
+ // we'll add more if-else statements above to process those different nodes.
+ CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure());
+ }
+
+ *
+ */
+ }
+
+ return;
+ }
+
+ /**
+ * Returns a criteria that will be used to obtain the root nodes for the tree - that is,
+ * the top level change set entries.
+ *
+ * Subclasses can override this method, or modify the returned criteria to further
+ * filter the change sets that are to be returned.
+ *
+ * @param request the request being made of the tree
+ *
+ * @return the criteria to use when querying for change setss
+ */
+ protected DriftChangeSetCriteria getDriftChangeSetCriteria(final DSRequest request) {
+ DriftChangeSetCriteria criteria = new DriftChangeSetJPACriteria();
+ criteria.addSortVersion(PageOrdering.DESC);
+ criteria.setPageControl(getPageControl(request));
+ return criteria;
+ }
+
+ @Override
+ protected BaseCriteria getFetchCriteria(DSRequest request) {
+ // our executeFetch will determine on its own what criteria to use based on what is to be fetched
+ // thus we don't return anything here and let the executeFetch do everything
+ return null;
+ }
+
+ @Override
+ public Object copyValues(Record from) {
+ return null; // don't need this method.
+ }
+
+ @Override
+ public ListGridRecord[] buildRecords(Collection dataObjects) {
+ return buildRecordsForKnownChangeSets(dataObjects, null);
+ }
+
+ public ListGridRecord[] buildRecordsForKnownChangeSets(Collection dataObjects, Integer changeSetId) {
+ if (dataObjects == null) {
+ return null;
+ }
+
+ final List<ListGridRecord> records = new ArrayList<ListGridRecord>();
+
+ for (Object item : dataObjects) {
+
+ // the resultant item is a direct node to build
+ records.add(copyValues(item));
+
+ // now build the children of the node
+ /*
+ * We do not have the need for building any intermeidate nodes today.
+ * There is nothing to do, but if in the future we have differnet node types,
+ * we'll probably want intermediate nodes that we create here. See BundleTreeDataSource
+ * for an example of where this is already done. Commenting this out just as an
+ * example of how this can be done.
+
+ if (item instanceof DriftChangeSet) {
+ DriftChangeSet changeset = (DriftChangeSet) item;
+
+ // each bundle has two direct children - the versions and destinations folders
+ TreeNode versionNode = new TreeNode(MSG.view_drift());
+ versionNode.setID(changeset.getId() + "_drifts");
+ versionNode.setParentID(changeset.getId());
+ versionNode.setName(MSG.view_drift());
+ versionNode.setAttribute("name", MSG.view_drift());
+ records.add(versionNode);
+ } else if (item instanceof Drift) {
+ if (canManageDrift) {
+ records.add(copyValuesForKnownDriftChangeSet(driftItem, changeSetId));
+ }
+ }
+
+ *
+ */
+ }
+
+ return records.toArray(new ListGridRecord[records.size()]);
+ }
+
+ @Override
+ public ListGridRecord copyValues(Object from) {
+ return copyValuesForKnownDriftChangeSet(from, null);
+ }
+
+ public ListGridRecord copyValuesForKnownDriftChangeSet(Object from, Integer changeSetId) {
+ TreeNode node;
+ if (from instanceof DriftChangeSet) {
+ DriftChangeSet changeset = (DriftChangeSet) from;
+ node = new AbstractDriftChangeSetsTreeView.ChangeSetTreeNode(changeset);
+ } else if (from instanceof Drift) {
+ Drift drift = (Drift) from;
+ node = new AbstractDriftChangeSetsTreeView.DriftTreeNode(drift);
+ } else {
+ throw new IllegalArgumentException("please report this bug - bad value: " + from);
+ }
+ // if, in the future, we add more node types, we'll add more else-if statements here
+
+ return node;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
index 50d787d..7778084 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -67,8 +67,6 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
setSelectionType(SelectionStyle.SINGLE);
setShowRollOver(false);
setShowHeader(false);
-
- setDataSource(new DriftChangeSetsTreeDataSource(canManageDrift));
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
deleted file mode 100644
index c6e9e65..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.drift;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.data.fields.DataSourceTextField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.tree.TreeNode;
-
-import org.rhq.core.domain.criteria.BaseCriteria;
-import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
-import org.rhq.core.domain.criteria.DriftCriteria;
-import org.rhq.core.domain.criteria.DriftJPACriteria;
-import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.DriftChangeSet;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.gwt.DriftGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-
-/**
- * @author John Mazzitelli
- */
-@SuppressWarnings("unchecked")
-public class DriftChangeSetsTreeDataSource extends RPCDataSource<Object, BaseCriteria> {
-
- private static final String ATTR_PARENT_ID = "parentId";
- public static final String ATTR_ID = "id";
- public static final String ATTR_NAME = "name";
-
- private DriftGWTServiceAsync driftService = GWTServiceLookup.getDriftService();
- private final boolean canManageDrift;
-
- public DriftChangeSetsTreeDataSource(boolean canManageDrift) {
- super();
- this.canManageDrift = canManageDrift;
- List<DataSourceField> fields = addDataSourceFields();
- addFields(fields);
- }
-
- @Override
- protected List<DataSourceField> addDataSourceFields() {
- List<DataSourceField> fields = super.addDataSourceFields();
-
- DataSourceField idDataField = new DataSourceTextField(ATTR_ID, MSG.common_title_id());
- idDataField.setPrimaryKey(true);
- fields.add(idDataField);
-
- DataSourceTextField nameDataField = new DataSourceTextField(ATTR_NAME, MSG.common_title_name());
- nameDataField.setCanEdit(false);
- fields.add(nameDataField);
-
- DataSourceTextField parentIdField = new DataSourceTextField(ATTR_PARENT_ID, MSG.common_title_id_parent());
- parentIdField.setForeignKey(ATTR_ID);
- fields.add(parentIdField);
-
- return fields;
- }
-
- @Override
- protected void executeFetch(final DSRequest request, final DSResponse response, final BaseCriteria unused) {
-
- String parentId = request.getCriteria().getAttribute(ATTR_PARENT_ID);
-
- if (parentId == null) {
-
- // There is no parent - we are at the root of the tree.
- // Get the top nodes (the change sets) but to be as fast as possible don't load their drifts.
- // We will lazily load drifts when the these changeset tree nodes are opened
- DriftChangeSetCriteria criteria = new DriftChangeSetJPACriteria();
- criteria.addSortVersion(PageOrdering.DESC);
- criteria.setPageControl(getPageControl(request));
-
- driftService.findDriftChangeSetsByCriteria(criteria, new AsyncCallback<PageList<DriftChangeSet>>() {
- public void onSuccess(PageList<DriftChangeSet> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
-
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure(), caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
- });
- } else {
- String changesetId = parentId;
- DriftCriteria criteria = new DriftJPACriteria();
- criteria.addFilterChangeSetId(changesetId);
-
- driftService.findDriftsByCriteria(criteria, new AsyncCallback<PageList<Drift>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure(), caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
-
- public void onSuccess(PageList<Drift> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
- });
-
- /*
- * I am leaving this code commented for future reference. Because today the drit change set tree only
- * shows simple changeset->drift tree, we don't need this. But if we need to have
- * multiple types of child nodes, we'll need something like below to query
- * for the different child node data. For example, we'd need this if we have a tree like:
- * ChangeSet
- * |____Resources
- * | |____ My resource 1
- * | |____ ...
- * |_____Drifts
- * |___ Drift #1
- * |___ Drift #2
- * |___ ...
- * Today we only have Drifts child nodes, so we don't need to have that intermediate
- * "Drifts" node. If we later want to introduce different node types (like Resources)
- * we need additional code like below.
- *
-
- // we are at an inner node, being asked to get the children of it
- if (p.endsWith("_drifts")) {
- // ...load drift items like above in the real code...
- } else if (p.endsWith("_resources")) {
- // ...load resource items and put those nodes in the tree...
- } else {
- // This is an unknown type of node, so just log an error.
- // Note that if, in the future, we have other types of nodes (like maybe resource nodes for group change sets?)
- // we'll add more if-else statements above to process those different nodes.
- CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure());
- }
-
- *
- */
- }
-
- return;
- }
-
- @Override
- protected BaseCriteria getFetchCriteria(DSRequest request) {
- // our executeFetch will determine on its own what criteria to use based on what is to be fetched
- // thus we don't return anything here and let the executeFetch do everything
- return null;
- }
-
- @Override
- public Object copyValues(Record from) {
- return null; // don't need this method.
- }
-
- @Override
- public ListGridRecord[] buildRecords(Collection dataObjects) {
- return buildRecordsForKnownChangeSets(dataObjects, null);
- }
-
- public ListGridRecord[] buildRecordsForKnownChangeSets(Collection dataObjects, Integer changeSetId) {
- if (dataObjects == null) {
- return null;
- }
-
- final List<ListGridRecord> records = new ArrayList<ListGridRecord>();
-
- for (Object item : dataObjects) {
-
- // the resultant item is a direct node to build
- records.add(copyValues(item));
-
- // now build the children of the node
- /*
- * We do not have the need for building any intermeidate nodes today.
- * There is nothing to do, but if in the future we have differnet node types,
- * we'll probably want intermediate nodes that we create here. See BundleTreeDataSource
- * for an example of where this is already done. Commenting this out just as an
- * example of how this can be done.
-
- if (item instanceof DriftChangeSet) {
- DriftChangeSet changeset = (DriftChangeSet) item;
-
- // each bundle has two direct children - the versions and destinations folders
- TreeNode versionNode = new TreeNode(MSG.view_drift());
- versionNode.setID(changeset.getId() + "_drifts");
- versionNode.setParentID(changeset.getId());
- versionNode.setName(MSG.view_drift());
- versionNode.setAttribute("name", MSG.view_drift());
- records.add(versionNode);
- } else if (item instanceof Drift) {
- if (canManageDrift) {
- records.add(copyValuesForKnownDriftChangeSet(driftItem, changeSetId));
- }
- }
-
- *
- */
- }
-
- return records.toArray(new ListGridRecord[records.size()]);
- }
-
- @Override
- public ListGridRecord copyValues(Object from) {
- return copyValuesForKnownDriftChangeSet(from, null);
- }
-
- public ListGridRecord copyValuesForKnownDriftChangeSet(Object from, Integer changeSetId) {
- TreeNode node;
- if (from instanceof DriftChangeSet) {
- DriftChangeSet changeset = (DriftChangeSet) from;
- node = new AbstractDriftChangeSetsTreeView.ChangeSetTreeNode(changeset);
- } else if (from instanceof Drift) {
- Drift drift = (Drift) from;
- node = new AbstractDriftChangeSetsTreeView.DriftTreeNode(drift);
- } else {
- throw new IllegalArgumentException("please report this bug - bad value: " + from);
- }
- // if, in the future, we add more node types, we'll add more else-if statements here
-
- return node;
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeDataSource.java
new file mode 100644
index 0000000..f5341e2
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeDataSource.java
@@ -0,0 +1,51 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import com.smartgwt.client.data.DSRequest;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+
+/**
+ * @author John Mazzitelli
+ */
+public class ResourceDriftChangeSetsTreeDataSource extends AbstractDriftChangeSetsTreeDataSource {
+
+ private final EntityContext context;
+
+ public ResourceDriftChangeSetsTreeDataSource(boolean canManageDrift, EntityContext context) {
+ super(canManageDrift);
+
+ if (context.type != EntityContext.Type.Resource) {
+ throw new IllegalArgumentException("wrong context: " + context);
+ }
+
+ this.context = context;
+ }
+
+ @Override
+ protected DriftChangeSetCriteria getDriftChangeSetCriteria(final DSRequest request) {
+ DriftChangeSetCriteria criteria = super.getDriftChangeSetCriteria(request);
+ criteria.addFilterResourceId(this.context.resourceId);
+ return criteria;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
index 3e368d5..3ee0b5f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
@@ -40,11 +40,13 @@ public class ResourceDriftChangeSetsTreeView extends AbstractDriftChangeSetsTree
}
this.context = context;
+
+ setDataSource(new ResourceDriftChangeSetsTreeDataSource(canManageDrift, context));
}
protected String getNodeTargetLink(TreeNode node) {
if (node instanceof DriftTreeNode) {
- String driftIdStr = node.getAttribute(DriftChangeSetsTreeDataSource.ATTR_ID).split("_")[1];
+ String driftIdStr = node.getAttribute(AbstractDriftChangeSetsTreeDataSource.ATTR_ID).split("_")[1];
String path = LinkManager.getDriftHistoryLink(this.context.resourceId, Integer.valueOf(driftIdStr));
return path;
}
commit d00c5e84c87a2e906e9a5127c836965acaf6e56f
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 26 09:22:15 2011 -0400
Adding logic to check the enabled flag during drift detection
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 f2883b9..b92dd7c 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
@@ -54,6 +54,18 @@ public class DriftDetector implements Runnable {
if (schedule.getNextScan() > (System.currentTimeMillis() + 100L)) {
scheduleQueue.enqueue(schedule);
+ // TODO should we grab the schedule from the queue?
+ // Maybe we should continue pulling schedules off the queue until
+ // we find one that is ready to be processed.
+ return;
+ }
+
+ if (!schedule.getDriftConfiguration().getEnabled()) {
+ schedule.updateShedule();
+ scheduleQueue.enqueue(schedule);
+ // TODO should we grab the schedule from the queue?
+ // Maybe we should continue pulling schedules off the queue until
+ // we find one that is ready to be processed.
return;
}
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 fe15677..7934c2d 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,7 +1,6 @@
package org.rhq.core.pc.drift;
import java.util.PriorityQueue;
-import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
public class ScheduleQueueImpl implements ScheduleQueue {
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 4f27974..9b62422 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
@@ -16,6 +16,7 @@ import org.rhq.common.drift.ChangeSetReaderImpl;
import org.rhq.common.drift.DirectoryEntry;
import org.rhq.common.drift.FileEntry;
import org.rhq.common.drift.Headers;
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftConfiguration;
import static org.apache.commons.io.FileUtils.touch;
@@ -167,6 +168,32 @@ public class DriftDetectorTest extends DriftTest {
@SuppressWarnings("unchecked")
@Test
+ public void skipScheduledThatHasConfigDisabled() throws Exception {
+ detector.setDriftClient(new DriftClientTestStub() {
+ {
+ setBaseDir(resourceDir);
+ }
+
+ @Override
+ public void sendChangeSetToServer(int resourceId, DriftConfiguration driftConfiguration,
+ DriftChangeSetCategory type) {
+ throw new RuntimeException("Should not invoke drift client when drift configuration is disabled");
+ }
+ });
+
+ DriftConfiguration config = driftConfiguration("disabled-config-test", resourceDir.getAbsolutePath());
+ config.setEnabled(false);
+
+ File confDir = mkdir(resourceDir, "conf");
+ File server1Conf = new File(confDir, "server-1.conf");
+ touch(server1Conf);
+
+ scheduleQueue.enqueue(new DriftDetectionSchedule(resourceId(), config));
+ detector.run();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
public void includeAddedFileInDriftChangeSet() throws Exception {
DriftConfiguration config = driftConfiguration("file-added-drift-test", resourceDir.getAbsolutePath());
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftTest.java
index 97bfa45..98c421e 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftTest.java
@@ -81,6 +81,12 @@ public class DriftTest {
*/
protected File resourceDir;
+ /**
+ * The default interval assigned to drift configurations created using
+ * {@link #driftConfiguration(String, String)}
+ */
+ protected long defaultInterval = 1800L; // 30 minutes;
+
private MessageDigestGenerator digestGenerator;
/**
@@ -180,6 +186,7 @@ public class DriftTest {
/**
* Creates a {@link DriftConfiguration} with the specified basedir. The file system is
* used as the context for the basedir which means the path specified is used as is.
+ * The interval property is set to {@link #defaultInterval}.
*
* @param name The configuration name
* @param basedir An absolute path of the base directory
@@ -189,6 +196,8 @@ public class DriftTest {
DriftConfiguration config = new DriftConfiguration(new Configuration());
config.setName(name);
config.setBasedir(new DriftConfiguration.BaseDirectory(fileSystem, basedir));
+ config.setEnabled(true);
+ config.setInterval(defaultInterval);
return config;
}
commit d0ccf2a4181f6f301bc29e229fe9425885d706d9
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jul 25 17:53:45 2011 -0400
sort the query in desc order, though the tree currently ignores this and has its own sorting.
need to fix that later
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
index fe8586a..c6e9e65 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
@@ -95,7 +95,7 @@ public class DriftChangeSetsTreeDataSource extends RPCDataSource<Object, BaseCri
// Get the top nodes (the change sets) but to be as fast as possible don't load their drifts.
// We will lazily load drifts when the these changeset tree nodes are opened
DriftChangeSetCriteria criteria = new DriftChangeSetJPACriteria();
- criteria.addSortVersion(PageOrdering.ASC);
+ criteria.addSortVersion(PageOrdering.DESC);
criteria.setPageControl(getPageControl(request));
driftService.findDriftChangeSetsByCriteria(criteria, new AsyncCallback<PageList<DriftChangeSet>>() {
commit d1cc955cb7b2ea22dd60e847f5fdca4c52f7a8af
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jul 25 17:53:03 2011 -0400
default subtab view for drift is the change set tree
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 4efc189..0e63d8e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -243,13 +243,13 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
driftTab = new TwoLevelTab(getTabSet().extendLocatorId(Tab.DRIFT), new ViewName(Tab.DRIFT, MSG
.view_tabs_common_drift()), "subsystems/drift/Drift_16.png");
- this.driftHistory = new SubTab(driftTab.extendLocatorId(DriftSubTab.HISTORY), new ViewName(DriftSubTab.HISTORY,
- MSG.view_tabs_common_history()), null);
this.driftChangeSets = new SubTab(driftTab.extendLocatorId(DriftSubTab.CHANGE_SETS), new ViewName(
DriftSubTab.CHANGE_SETS, MSG.view_drift_changeSets()), null);
+ this.driftHistory = new SubTab(driftTab.extendLocatorId(DriftSubTab.HISTORY), new ViewName(DriftSubTab.HISTORY,
+ MSG.view_tabs_common_history()), null);
this.driftConfig = new SubTab(driftTab.extendLocatorId(DriftSubTab.CONFIGURATION), new ViewName(
DriftSubTab.CONFIGURATION, MSG.view_tabs_common_configuration()), null);
- driftTab.registerSubTabs(driftHistory, driftChangeSets, driftConfig);
+ driftTab.registerSubTabs(driftChangeSets, driftHistory, driftConfig);
tabs.add(driftTab);
contentTab = new TwoLevelTab(getTabSet().extendLocatorId("Content"), new ViewName("Content", MSG
@@ -519,17 +519,17 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
ResourcePermission resourcePermissions, Set<ResourceTypeFacet> facets) {
if (updateTab(this.driftTab, facets.contains(ResourceTypeFacet.DRIFT), resourcePermissions.isDrift())) {
- updateSubTab(this.driftTab, this.driftHistory, true, true, new ViewFactory() {
+ updateSubTab(this.driftTab, this.driftChangeSets, true, true, new ViewFactory() {
@Override
public Canvas createView() {
- return ResourceDriftHistoryView.get(driftHistory.extendLocatorId("View"), resourceComposite);
+ return ResourceDriftChangeSetsView.get(driftChangeSets.extendLocatorId("View"), resourceComposite);
}
});
- updateSubTab(this.driftTab, this.driftChangeSets, true, true, new ViewFactory() {
+ updateSubTab(this.driftTab, this.driftHistory, true, true, new ViewFactory() {
@Override
public Canvas createView() {
- return ResourceDriftChangeSetsView.get(driftChangeSets.extendLocatorId("View"), resourceComposite);
+ return ResourceDriftHistoryView.get(driftHistory.extendLocatorId("View"), resourceComposite);
}
});
commit 63afe8975ac731bf9b2422ed2f72b941523359b0
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jul 25 17:49:19 2011 -0400
initial start of the context menu for the change set tree
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
index 521d7b2..50d787d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -27,14 +27,24 @@ import com.google.gwt.core.client.RunAsyncCallback;
import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
+import com.smartgwt.client.widgets.menu.Menu;
+import com.smartgwt.client.widgets.menu.MenuItem;
+import com.smartgwt.client.widgets.menu.MenuItemSeparator;
+import com.smartgwt.client.widgets.menu.events.ClickHandler;
+import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
import com.smartgwt.client.widgets.tree.Tree;
import com.smartgwt.client.widgets.tree.TreeNode;
-import com.smartgwt.client.widgets.tree.events.NodeClickEvent;
-import com.smartgwt.client.widgets.tree.events.NodeClickHandler;
+import com.smartgwt.client.widgets.tree.events.NodeContextClickEvent;
+import com.smartgwt.client.widgets.tree.events.NodeContextClickHandler;
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
/**
@@ -56,18 +66,9 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
setAnimateFolders(false);
setSelectionType(SelectionStyle.SINGLE);
setShowRollOver(false);
- setSortField(DriftChangeSetsTreeDataSource.ATTR_NAME);
setShowHeader(false);
setDataSource(new DriftChangeSetsTreeDataSource(canManageDrift));
-
- addNodeClickHandler(new NodeClickHandler() {
- public void onNodeClick(NodeClickEvent event) {
- TreeNode node = event.getNode();
- String link = getNodeTargetLink(node);
- CoreGUI.goToView(link);
- }
- });
}
@Override
@@ -76,13 +77,30 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
// We may need to wait for tree data to be fetched before we can complete processing the selected path.
// When the datasource pulls data keep processing the selectedPath if necessary.
- this.addDataArrivedHandler(new DataArrivedHandler() {
+ addDataArrivedHandler(new DataArrivedHandler() {
public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
if (null != pendingPath) {
selectPath(pendingPath);
}
}
});
+
+ addNodeContextClickHandler(new NodeContextClickHandler() {
+ public void onNodeContextClick(final NodeContextClickEvent event) {
+ // stop the browser right-click menu
+ event.cancel();
+
+ TreeNode eventNode = event.getNode();
+
+ if (eventNode instanceof ChangeSetTreeNode) {
+ CoreGUI.getMessageCenter().notify(new Message("TODO [this will popup the changeset menu]"));
+ } else if (eventNode instanceof DriftTreeNode) {
+ Menu menu = buildContextMenu((DriftTreeNode) eventNode);
+ menu.showContextMenu();
+ }
+ }
+ });
+
}
public void selectPath(ViewPath viewPath) {
@@ -144,4 +162,76 @@ public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid
* @return the node's link
*/
protected abstract String getNodeTargetLink(TreeNode node);
+
+ /**
+ * Builds the right-mouse-click context menu for the given drift node
+ * @param node the drift node whose menu is to be displayed
+ * @return the context menu to display
+ */
+ protected Menu buildContextMenu(final DriftTreeNode node) {
+
+ Menu contextMenu = new Menu();
+
+ // title
+ String titleName = node.getName();
+ if (titleName.length() > 50) {
+ // make sure the title isn't really long so the menu is not abnormally wide
+ titleName = "..." + titleName.substring(titleName.length() - 50);
+ }
+ MenuItem titleItem = new MenuItem(titleName);
+ titleItem.setEnabled(false);
+ contextMenu.setItems(titleItem);
+
+ // separator
+ contextMenu.addItem(new MenuItemSeparator());
+
+ // item that links to the history details
+ MenuItem detailsItem = new MenuItem(MSG.common_title_details());
+ detailsItem.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ String link = getNodeTargetLink(node);
+ if (link != null) {
+ CoreGUI.goToView(link);
+ }
+ }
+ });
+ contextMenu.addItem(detailsItem);
+
+ return contextMenu;
+ }
+
+ @SuppressWarnings("unchecked")
+ static class ChangeSetTreeNode extends TreeNode {
+ public ChangeSetTreeNode(DriftChangeSet changeset) {
+ setIsFolder(true);
+ setIcon("subsystems/drift/ChangeSet_16.png");
+ setShowOpenIcon(true);
+ setID(changeset.getId());
+ setName(buildDriftChangeSetNodeName(changeset));
+ }
+
+ private String buildDriftChangeSetNodeName(DriftChangeSet changeset) {
+ StringBuilder str = new StringBuilder();
+ str.append(MSG.common_title_version());
+ str.append(' ');
+ str.append(changeset.getVersion());
+ str.append(" (");
+ str.append(TimestampCellFormatter.format(changeset.getCtime(),
+ TimestampCellFormatter.DATE_TIME_FORMAT_SHORT));
+ str.append(')');
+ return str.toString();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ static class DriftTreeNode extends TreeNode {
+ public DriftTreeNode(Drift drift) {
+ setIsFolder(false);
+ setIcon(ImageManager.getDriftCategoryIcon(drift.getCategory()));
+ String parentID = drift.getChangeSet().getId();
+ setParentID(parentID);
+ setID(parentID + '_' + drift.getId());
+ setName(drift.getPath());
+ }
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
index c609a1e..fe8586a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
@@ -39,9 +39,8 @@ import org.rhq.core.domain.criteria.DriftJPACriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.DriftGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
@@ -96,6 +95,7 @@ public class DriftChangeSetsTreeDataSource extends RPCDataSource<Object, BaseCri
// Get the top nodes (the change sets) but to be as fast as possible don't load their drifts.
// We will lazily load drifts when the these changeset tree nodes are opened
DriftChangeSetCriteria criteria = new DriftChangeSetJPACriteria();
+ criteria.addSortVersion(PageOrdering.ASC);
criteria.setPageControl(getPageControl(request));
driftService.findDriftChangeSetsByCriteria(criteria, new AsyncCallback<PageList<DriftChangeSet>>() {
@@ -233,38 +233,18 @@ public class DriftChangeSetsTreeDataSource extends RPCDataSource<Object, BaseCri
}
public ListGridRecord copyValuesForKnownDriftChangeSet(Object from, Integer changeSetId) {
- String parentID;
- TreeNode node = new TreeNode();
+ TreeNode node;
if (from instanceof DriftChangeSet) {
DriftChangeSet changeset = (DriftChangeSet) from;
- node.setIsFolder(true);
- node.setIcon("subsystems/drift/ChangeSet_16.png");
- node.setShowOpenIcon(true);
- node.setID(changeset.getId());
- node.setName(buildDriftChangeSetNodeName(changeset));
-
+ node = new AbstractDriftChangeSetsTreeView.ChangeSetTreeNode(changeset);
} else if (from instanceof Drift) {
Drift drift = (Drift) from;
- node.setIsFolder(false);
- node.setIcon(ImageManager.getDriftCategoryIcon(drift.getCategory()));
- parentID = drift.getChangeSet().getId();
- node.setParentID(parentID);
- node.setID(parentID + '_' + drift.getId());
- node.setName(drift.getPath());
+ node = new AbstractDriftChangeSetsTreeView.DriftTreeNode(drift);
+ } else {
+ throw new IllegalArgumentException("please report this bug - bad value: " + from);
}
// if, in the future, we add more node types, we'll add more else-if statements here
return node;
}
-
- private String buildDriftChangeSetNodeName(DriftChangeSet changeset) {
- StringBuilder str = new StringBuilder();
- str.append(MSG.common_title_version());
- str.append(' ');
- str.append(changeset.getVersion());
- str.append(" (");
- str.append(TimestampCellFormatter.format(changeset.getCtime(), TimestampCellFormatter.DATE_TIME_FORMAT_SHORT));
- str.append(')');
- return str.toString();
- }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
index dc2a22d..3e368d5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
@@ -43,9 +43,12 @@ public class ResourceDriftChangeSetsTreeView extends AbstractDriftChangeSetsTree
}
protected String getNodeTargetLink(TreeNode node) {
- String driftIdStr = node.getAttribute(DriftChangeSetsTreeDataSource.ATTR_ID).split("_")[1];
- String path = LinkManager.getDriftHistoryLink(this.context.resourceId, Integer.valueOf(driftIdStr));
- return path;
+ if (node instanceof DriftTreeNode) {
+ String driftIdStr = node.getAttribute(DriftChangeSetsTreeDataSource.ATTR_ID).split("_")[1];
+ String path = LinkManager.getDriftHistoryLink(this.context.resourceId, Integer.valueOf(driftIdStr));
+ return path;
+ }
+ return null;
}
}
commit 5840be4d821c70b293c8be154e6beb174b929960
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 25 17:11:41 2011 -0400
Adding mapping fields to drift mongodb entities
Also adding initial implementation for
DriftServerPluginFacet.findDriftCompositesByCriteria. The method does
return results but it is not yet usable from the GWT UI since the entity
classes returned are known only to the rhq-mongodb plugin.
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
index 722dd22..2b3aca0 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
@@ -3,11 +3,15 @@ package org.rhq.enterprise.server.plugins.drift.mongodb;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import com.google.code.morphia.Datastore;
import com.google.code.morphia.Morphia;
+import com.google.code.morphia.query.Query;
import com.mongodb.Mongo;
import org.apache.commons.logging.Log;
@@ -22,10 +26,12 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.Snapshot;
+import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.ZipUtil;
import org.rhq.enterprise.server.plugin.pc.ServerPluginContext;
@@ -33,6 +39,9 @@ import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginFacet;
import org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSet;
import org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSetEntry;
import org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBFile;
+import org.rhq.enterprise.server.resource.ResourceManagerLocal;
+
+import static org.rhq.enterprise.server.util.LookupUtil.getResourceManager;
public class MongoDBDriftServer implements DriftServerPluginFacet {
@@ -118,11 +127,40 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
@Override
public PageList<DriftComposite> findDriftCompositesByCriteria(Subject subject, DriftCriteria criteria) {
- return new PageList<DriftComposite>();
+ Query<MongoDBChangeSet> query = ds.createQuery(MongoDBChangeSet.class)
+ .filter("files.category in ", criteria.getFilterCategories())
+ .filter("resourceId in", criteria.getFilterResourceIds());
+
+ PageList<DriftComposite> results = new PageList<DriftComposite>();
+ Map<Integer, Resource> resources = loadResourceMap(subject, criteria.getFilterResourceIds());
+
+ for (MongoDBChangeSet changeSet : query) {
+ for (MongoDBChangeSetEntry entry : changeSet.getDrifts()) {
+ entry.setChangeSet(changeSet);
+ results.add(new DriftComposite(entry, resources.get(changeSet.getResourceId())));
+ }
+ }
+
+ return results;
}
@Override
public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
return null;
}
+
+ Map<Integer, Resource> loadResourceMap(Subject subject, List<Integer> resourceIds) {
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.addFilterIds(resourceIds.toArray(new Integer[resourceIds.size()]));
+
+ ResourceManagerLocal resourceMgr = getResourceManager();
+ PageList<Resource> resources = resourceMgr.findResourcesByCriteria(subject, criteria);
+
+ Map<Integer, Resource> map = new HashMap<Integer, Resource>();
+ for (Resource r : resources) {
+ map.put(r.getId(), r);
+ }
+
+ return map;
+ }
}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java
index 2640eff..2818b2c 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java
@@ -1,5 +1,6 @@
package org.rhq.enterprise.server.plugins.drift.mongodb.entities;
+import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
@@ -13,7 +14,9 @@ import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftChangeSetCategory;
@Entity("changesets")
-public class MongoDBChangeSet implements DriftChangeSet<MongoDBChangeSetEntry> {
+public class MongoDBChangeSet implements DriftChangeSet<MongoDBChangeSetEntry>, Serializable {
+
+ private static final long serialVersionUID = 1L;
@Id
private ObjectId id;
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java
index 80cdc0c..ced7bff 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java
@@ -1,12 +1,16 @@
package org.rhq.enterprise.server.plugins.drift.mongodb.entities;
+import java.io.Serializable;
+
import com.google.code.morphia.annotations.Embedded;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
@Embedded
-public class MongoDBChangeSetEntry implements Drift<MongoDBChangeSet, MongoDBFile> {
+public class MongoDBChangeSetEntry implements Drift<MongoDBChangeSet, MongoDBFile>, Serializable {
+
+ private static final long serialVersionUID = 1L;
private Long ctime = System.currentTimeMillis();
@@ -14,6 +18,14 @@ public class MongoDBChangeSetEntry implements Drift<MongoDBChangeSet, MongoDBFil
private String path;
+ public MongoDBChangeSetEntry() {
+ }
+
+ public MongoDBChangeSetEntry(String path, DriftCategory category) {
+ this.path = path;
+ this.category = category;
+ }
+
@Override
public String getId() {
return null;
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
index e6aec82..b5b8306 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
@@ -9,6 +9,7 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import static org.rhq.core.domain.drift.DriftCategory.FILE_ADDED;
import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
import static org.rhq.test.AssertUtils.assertCollectionMatchesNoOrder;
import static org.rhq.test.AssertUtils.assertPropertiesMatch;
@@ -57,7 +58,8 @@ public class MongoDBChangeSetTest {
@Test
public void saveAndLoadChangeSetWithOneEntry() throws Exception {
MongoDBChangeSet expected = new MongoDBChangeSet();
- expected.getDrifts().add(new MongoDBChangeSetEntry());
+ expected.setResourceId(10001);
+ expected.getDrifts().add(new MongoDBChangeSetEntry("foo", FILE_ADDED));
ds.save(expected);
commit cfc31a74808e6a68ea2b334364b377fad5c93c81
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jul 25 16:37:56 2011 -0400
the initial start of the drift change set tree view
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
index 30523b3..10c15e4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
@@ -458,4 +458,8 @@ public class LinkManager {
public static String getBundleDeploymentLink(int bundleId, int bundleDeploymentId) {
return "#Bundles/Bundle/" + bundleId + "/deployments/" + bundleDeploymentId;
}
+
+ public static String getDriftHistoryLink(int resourceId, int driftId) {
+ return "#Resource/" + resourceId + "/Drift/History/" + driftId;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
new file mode 100644
index 0000000..521d7b2
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/AbstractDriftChangeSetsTreeView.java
@@ -0,0 +1,147 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.RunAsyncCallback;
+import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
+import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
+import com.smartgwt.client.widgets.tree.Tree;
+import com.smartgwt.client.widgets.tree.TreeNode;
+import com.smartgwt.client.widgets.tree.events.NodeClickEvent;
+import com.smartgwt.client.widgets.tree.events.NodeClickHandler;
+
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ViewId;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
+
+/**
+ * @author John Mazzitelli
+ */
+public abstract class AbstractDriftChangeSetsTreeView extends LocatableTreeGrid {
+
+ // We may need to wait for tree data to be fetched before we can complete processing the selected path.
+ // If so, hold it here and retry after the datasource pulls the data.
+ private ViewPath pendingPath = null;
+
+ public AbstractDriftChangeSetsTreeView(String locatorId, boolean canManageDrift) {
+ super(locatorId);
+ setWidth100();
+ setHeight100();
+ setLeaveScrollbarGap(false);
+ // fetch the top nodes at the inital onDraw()
+ setAutoFetchData(true);
+ setAnimateFolders(false);
+ setSelectionType(SelectionStyle.SINGLE);
+ setShowRollOver(false);
+ setSortField(DriftChangeSetsTreeDataSource.ATTR_NAME);
+ setShowHeader(false);
+
+ setDataSource(new DriftChangeSetsTreeDataSource(canManageDrift));
+
+ addNodeClickHandler(new NodeClickHandler() {
+ public void onNodeClick(NodeClickEvent event) {
+ TreeNode node = event.getNode();
+ String link = getNodeTargetLink(node);
+ CoreGUI.goToView(link);
+ }
+ });
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ // We may need to wait for tree data to be fetched before we can complete processing the selected path.
+ // When the datasource pulls data keep processing the selectedPath if necessary.
+ this.addDataArrivedHandler(new DataArrivedHandler() {
+ public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
+ if (null != pendingPath) {
+ selectPath(pendingPath);
+ }
+ }
+ });
+ }
+
+ public void selectPath(ViewPath viewPath) {
+ Tree theTree = getTree();
+
+ if (viewPath.viewsLeft() > 0) {
+ String key = "";
+ for (ViewId view : viewPath.getViewPath().subList(2, viewPath.getViewPath().size())) {
+ if (key.length() > 0) {
+ key += "_";
+ }
+
+ key += view.getPath();
+
+ TreeNode node = theTree.findById(key);
+
+ if (node != null) {
+ // open the node, this will force a fetch of child data if necessary
+ theTree.openFolder(node);
+ } else {
+ // wait for data to get loaded...
+ pendingPath = new ViewPath(viewPath.toString());
+ return;
+ }
+ }
+
+ // we found the node, so keep going
+ pendingPath = null;
+
+ final String finalKey = key;
+ GWT.runAsync(new RunAsyncCallback() {
+ public void onFailure(Throwable reason) {
+ }
+
+ public void onSuccess() {
+ TreeNode node = getTree().findById(finalKey);
+ if (node != null) {
+ deselectAllRecords();
+ selectRecord(node);
+ }
+ }
+ });
+ } else {
+ deselectAllRecords();
+ if (getTotalRows() > 0)
+ selectRecord(0);
+ }
+ }
+
+ public void refresh() {
+ invalidateCache();
+ }
+
+ /**
+ * Returns the link (as a string) that the client should be redirected to
+ * if the given node is clicked.
+ *
+ * @param node the node whose target link is to be returned
+ * @return the node's link
+ */
+ protected abstract String getNodeTargetLink(TreeNode node);
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
new file mode 100644
index 0000000..c609a1e
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsTreeDataSource.java
@@ -0,0 +1,270 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.tree.TreeNode;
+
+import org.rhq.core.domain.criteria.BaseCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
+import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.criteria.DriftJPACriteria;
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
+import org.rhq.enterprise.gui.coregui.client.gwt.DriftGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * @author John Mazzitelli
+ */
+@SuppressWarnings("unchecked")
+public class DriftChangeSetsTreeDataSource extends RPCDataSource<Object, BaseCriteria> {
+
+ private static final String ATTR_PARENT_ID = "parentId";
+ public static final String ATTR_ID = "id";
+ public static final String ATTR_NAME = "name";
+
+ private DriftGWTServiceAsync driftService = GWTServiceLookup.getDriftService();
+ private final boolean canManageDrift;
+
+ public DriftChangeSetsTreeDataSource(boolean canManageDrift) {
+ super();
+ this.canManageDrift = canManageDrift;
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ DataSourceField idDataField = new DataSourceTextField(ATTR_ID, MSG.common_title_id());
+ idDataField.setPrimaryKey(true);
+ fields.add(idDataField);
+
+ DataSourceTextField nameDataField = new DataSourceTextField(ATTR_NAME, MSG.common_title_name());
+ nameDataField.setCanEdit(false);
+ fields.add(nameDataField);
+
+ DataSourceTextField parentIdField = new DataSourceTextField(ATTR_PARENT_ID, MSG.common_title_id_parent());
+ parentIdField.setForeignKey(ATTR_ID);
+ fields.add(parentIdField);
+
+ return fields;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, final BaseCriteria unused) {
+
+ String parentId = request.getCriteria().getAttribute(ATTR_PARENT_ID);
+
+ if (parentId == null) {
+
+ // There is no parent - we are at the root of the tree.
+ // Get the top nodes (the change sets) but to be as fast as possible don't load their drifts.
+ // We will lazily load drifts when the these changeset tree nodes are opened
+ DriftChangeSetCriteria criteria = new DriftChangeSetJPACriteria();
+ criteria.setPageControl(getPageControl(request));
+
+ driftService.findDriftChangeSetsByCriteria(criteria, new AsyncCallback<PageList<DriftChangeSet>>() {
+ public void onSuccess(PageList<DriftChangeSet> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ } else {
+ String changesetId = parentId;
+ DriftCriteria criteria = new DriftJPACriteria();
+ criteria.addFilterChangeSetId(changesetId);
+
+ driftService.findDriftsByCriteria(criteria, new AsyncCallback<PageList<Drift>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure(), caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onSuccess(PageList<Drift> result) {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
+
+ /*
+ * I am leaving this code commented for future reference. Because today the drit change set tree only
+ * shows simple changeset->drift tree, we don't need this. But if we need to have
+ * multiple types of child nodes, we'll need something like below to query
+ * for the different child node data. For example, we'd need this if we have a tree like:
+ * ChangeSet
+ * |____Resources
+ * | |____ My resource 1
+ * | |____ ...
+ * |_____Drifts
+ * |___ Drift #1
+ * |___ Drift #2
+ * |___ ...
+ * Today we only have Drifts child nodes, so we don't need to have that intermediate
+ * "Drifts" node. If we later want to introduce different node types (like Resources)
+ * we need additional code like below.
+ *
+
+ // we are at an inner node, being asked to get the children of it
+ if (p.endsWith("_drifts")) {
+ // ...load drift items like above in the real code...
+ } else if (p.endsWith("_resources")) {
+ // ...load resource items and put those nodes in the tree...
+ } else {
+ // This is an unknown type of node, so just log an error.
+ // Note that if, in the future, we have other types of nodes (like maybe resource nodes for group change sets?)
+ // we'll add more if-else statements above to process those different nodes.
+ CoreGUI.getErrorHandler().handleError(MSG.view_drift_changeset_tree_loadFailure());
+ }
+
+ *
+ */
+ }
+
+ return;
+ }
+
+ @Override
+ protected BaseCriteria getFetchCriteria(DSRequest request) {
+ // our executeFetch will determine on its own what criteria to use based on what is to be fetched
+ // thus we don't return anything here and let the executeFetch do everything
+ return null;
+ }
+
+ @Override
+ public Object copyValues(Record from) {
+ return null; // don't need this method.
+ }
+
+ @Override
+ public ListGridRecord[] buildRecords(Collection dataObjects) {
+ return buildRecordsForKnownChangeSets(dataObjects, null);
+ }
+
+ public ListGridRecord[] buildRecordsForKnownChangeSets(Collection dataObjects, Integer changeSetId) {
+ if (dataObjects == null) {
+ return null;
+ }
+
+ final List<ListGridRecord> records = new ArrayList<ListGridRecord>();
+
+ for (Object item : dataObjects) {
+
+ // the resultant item is a direct node to build
+ records.add(copyValues(item));
+
+ // now build the children of the node
+ /*
+ * We do not have the need for building any intermeidate nodes today.
+ * There is nothing to do, but if in the future we have differnet node types,
+ * we'll probably want intermediate nodes that we create here. See BundleTreeDataSource
+ * for an example of where this is already done. Commenting this out just as an
+ * example of how this can be done.
+
+ if (item instanceof DriftChangeSet) {
+ DriftChangeSet changeset = (DriftChangeSet) item;
+
+ // each bundle has two direct children - the versions and destinations folders
+ TreeNode versionNode = new TreeNode(MSG.view_drift());
+ versionNode.setID(changeset.getId() + "_drifts");
+ versionNode.setParentID(changeset.getId());
+ versionNode.setName(MSG.view_drift());
+ versionNode.setAttribute("name", MSG.view_drift());
+ records.add(versionNode);
+ } else if (item instanceof Drift) {
+ if (canManageDrift) {
+ records.add(copyValuesForKnownDriftChangeSet(driftItem, changeSetId));
+ }
+ }
+
+ *
+ */
+ }
+
+ return records.toArray(new ListGridRecord[records.size()]);
+ }
+
+ @Override
+ public ListGridRecord copyValues(Object from) {
+ return copyValuesForKnownDriftChangeSet(from, null);
+ }
+
+ public ListGridRecord copyValuesForKnownDriftChangeSet(Object from, Integer changeSetId) {
+ String parentID;
+ TreeNode node = new TreeNode();
+ if (from instanceof DriftChangeSet) {
+ DriftChangeSet changeset = (DriftChangeSet) from;
+ node.setIsFolder(true);
+ node.setIcon("subsystems/drift/ChangeSet_16.png");
+ node.setShowOpenIcon(true);
+ node.setID(changeset.getId());
+ node.setName(buildDriftChangeSetNodeName(changeset));
+
+ } else if (from instanceof Drift) {
+ Drift drift = (Drift) from;
+ node.setIsFolder(false);
+ node.setIcon(ImageManager.getDriftCategoryIcon(drift.getCategory()));
+ parentID = drift.getChangeSet().getId();
+ node.setParentID(parentID);
+ node.setID(parentID + '_' + drift.getId());
+ node.setName(drift.getPath());
+ }
+ // if, in the future, we add more node types, we'll add more else-if statements here
+
+ return node;
+ }
+
+ private String buildDriftChangeSetNodeName(DriftChangeSet changeset) {
+ StringBuilder str = new StringBuilder();
+ str.append(MSG.common_title_version());
+ str.append(' ');
+ str.append(changeset.getVersion());
+ str.append(" (");
+ str.append(TimestampCellFormatter.format(changeset.getCtime(), TimestampCellFormatter.DATE_TIME_FORMAT_SHORT));
+ str.append(')');
+ return str.toString();
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
index f610b8b..48f5bc8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
@@ -38,6 +38,13 @@ public class DriftChangeSetsView extends LocatableVLayout {
this.hasWriteAccess = hasWriteAccess;
}
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ addMember(new ResourceDriftChangeSetsTreeView(extendLocatorId("Tree"), this.hasWriteAccess, this.context));
+ }
+
public EntityContext getContext() {
return context;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
new file mode 100644
index 0000000..dc2a22d
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsTreeView.java
@@ -0,0 +1,51 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import com.smartgwt.client.widgets.tree.TreeNode;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
+
+/**
+ * @author John Mazzitelli
+ */
+public class ResourceDriftChangeSetsTreeView extends AbstractDriftChangeSetsTreeView {
+
+ private final EntityContext context;
+
+ public ResourceDriftChangeSetsTreeView(String locatorId, boolean canManageDrift, EntityContext context) {
+
+ super(locatorId, canManageDrift);
+
+ if (context.type != EntityContext.Type.Resource) {
+ throw new IllegalArgumentException("wrong context: " + context);
+ }
+
+ this.context = context;
+ }
+
+ protected String getNodeTargetLink(TreeNode node) {
+ String driftIdStr = node.getAttribute(DriftChangeSetsTreeDataSource.ATTR_ID).split("_")[1];
+ String path = LinkManager.getDriftHistoryLink(this.context.resourceId, Integer.valueOf(driftIdStr));
+ return path;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index c7d6f91..ea8c956 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -1123,6 +1123,7 @@ view_drift_category_fileChanged = File Changed
view_drift_category_fileRemoved = File Removed
view_drift_changeSets = Change Sets
view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
view_drift_delete_confirm = Delete the selected drift(s)?
view_drift_delete_confirmAll = Delete all drifts from this source?
view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index 5fe14aa..a07568a 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -941,6 +941,7 @@ view_dashboards_title = Dashboard
##view_drift_category_fileRemoved = File Removed
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index 6bce847..6e68cff 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -1106,6 +1106,7 @@ view_dashboards_title = ダッシュボード
##view_drift = Drift
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
##view_drift_table_baseDir = Base Directory
##view_drift_table_changeSet = Change Set
##view_drift_table_newFile = New File
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index bd2b6fb..fa86006 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -1141,6 +1141,7 @@ view_dashboards_title = Dashboard~
##view_drift_category_fileRemoved = File Removed
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index 9fa9115..79816c5 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -1115,6 +1115,7 @@ view_dashboards_title = \u7edf\u8ba1\u8868\u76d8
##view_drift = Drift
##view_drift_changeSets = Change Sets
##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
+##view_drift_changeset_tree_loadFailure = Failed to load drift change set tree.
##view_drift_table_baseDir = Base Directory
##view_drift_table_changeSet = Change Set
##view_drift_table_newFile = New File
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png
new file mode 100644
index 0000000..fdda214
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png
new file mode 100644
index 0000000..358cf61
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png differ
commit fe7f34b7c81f58995cba007e0105478d3c53b97c
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 25 13:54:24 2011 -0400
Initial commit for entity classes and some initial unit tests
This commit provides the first cut at drift entities for mongodb. I also
provided an initial implementation for
DriftServerPluginFacet.saveChangeSet.
diff --git a/modules/enterprise/server/plugins/drift-mongodb/pom.xml b/modules/enterprise/server/plugins/drift-mongodb/pom.xml
index 8721db7..958d3e0 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/pom.xml
+++ b/modules/enterprise/server/plugins/drift-mongodb/pom.xml
@@ -33,6 +33,19 @@
</dependency>
<dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>test-utils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-common-drift</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.6.3</version>
@@ -72,16 +85,44 @@
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.0</version>
+ <executions>
+ <execution>
+ <id>copy-libs</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.mongodb</groupId>
+ <artifactId>mongo-java-driver</artifactId>
+ </artifactItem>
+ <artifactItem>
+ <groupId>com.google.code.morphia</groupId>
+ <artifactId>morphia</artifactId>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
<repositories>
- <id>morphia-repo</id>
- <name>Morphia Repo</name>
- <url>http://morphia.googlecode.com/svn/mavenrepo/</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
+ <repository>
+ <id>morphia-repo</id>
+ <name>Morphia Repo</name>
+ <url>http://morphia.googlecode.com/svn/mavenrepo/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
</repositories>
<profiles>
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
index d7c7202..722dd22 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
@@ -1,12 +1,61 @@
package org.rhq.enterprise.server.plugins.drift.mongodb;
+import java.io.BufferedReader;
import java.io.File;
-
+import java.io.InputStreamReader;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import com.google.code.morphia.Datastore;
+import com.google.code.morphia.Morphia;
+import com.mongodb.Mongo;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.common.drift.ChangeSetReader;
+import org.rhq.common.drift.ChangeSetReaderImpl;
+import org.rhq.common.drift.DirectoryEntry;
+import org.rhq.common.drift.FileEntry;
+import org.rhq.common.drift.Headers;
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
+import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.DriftComposite;
+import org.rhq.core.domain.drift.Snapshot;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.util.ZipUtil;
import org.rhq.enterprise.server.plugin.pc.ServerPluginContext;
import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginFacet;
+import org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSet;
+import org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBChangeSetEntry;
+import org.rhq.enterprise.server.plugins.drift.mongodb.entities.MongoDBFile;
public class MongoDBDriftServer implements DriftServerPluginFacet {
+ private final Log log = LogFactory.getLog(MongoDBDriftServer.class);
+
+ private Mongo connection;
+
+ private Morphia morphia;
+
+ private Datastore ds;
+
+ static int changeSetVersions = 0;
+
+ @Override
+ public void initialize(ServerPluginContext context) throws Exception {
+ connection = new Mongo("localhost");
+ morphia = new Morphia()
+ .map(MongoDBChangeSet.class)
+ .map(MongoDBChangeSetEntry.class)
+ .map(MongoDBFile.class);
+ ds = morphia.createDatastore(connection, "rhq");
+ }
+
@Override
public void start() {
@@ -23,8 +72,33 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
}
@Override
- public void saveChangeSet(int resourceId, File changeSetZip) throws Exception {
-
+ public void saveChangeSet(final int resourceId, final File changeSetZip) throws Exception {
+ ZipUtil.walkZipFile(changeSetZip, new ZipUtil.ZipEntryVisitor() {
+ @Override
+ public boolean visit(ZipEntry zipEntry, ZipInputStream stream) throws Exception {
+ ChangeSetReader reader = new ChangeSetReaderImpl(new BufferedReader(new InputStreamReader(stream)));
+
+ Headers headers = reader.getHeaders();
+ MongoDBChangeSet changeSet = new MongoDBChangeSet();
+ changeSet.setCategory(headers.getType());
+ changeSet.setResourceId(resourceId);
+ // TODO Figure out how best to handle drift config reference
+ changeSet.setDriftConfigurationId(1);
+ changeSet.setVersion(changeSetVersions++);
+
+ for (DirectoryEntry dirEntry : reader) {
+ for (FileEntry fileEntry : dirEntry) {
+ MongoDBChangeSetEntry entry = new MongoDBChangeSetEntry();
+ entry.setCategory(fileEntry.getType());
+ entry.setPath(fileEntry.getFile());
+ changeSet.add(entry);
+ }
+ }
+
+ ds.save(changeSet);
+ return true;
+ }
+ });
}
@Override
@@ -33,8 +107,22 @@ public class MongoDBDriftServer implements DriftServerPluginFacet {
}
@Override
- public void initialize(ServerPluginContext context) throws Exception {
+ public PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria) {
+ return new PageList<DriftChangeSet>();
+ }
+ @Override
+ public PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria) {
+ return new PageList<Drift>();
}
+ @Override
+ public PageList<DriftComposite> findDriftCompositesByCriteria(Subject subject, DriftCriteria criteria) {
+ return new PageList<DriftComposite>();
+ }
+
+ @Override
+ public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
+ return null;
+ }
}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java
new file mode 100644
index 0000000..2640eff
--- /dev/null
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSet.java
@@ -0,0 +1,110 @@
+package org.rhq.enterprise.server.plugins.drift.mongodb.entities;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import com.google.code.morphia.annotations.Embedded;
+import com.google.code.morphia.annotations.Entity;
+import com.google.code.morphia.annotations.Id;
+
+import org.bson.types.ObjectId;
+
+import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
+
+@Entity("changesets")
+public class MongoDBChangeSet implements DriftChangeSet<MongoDBChangeSetEntry> {
+
+ @Id
+ private ObjectId id;
+
+ private Long ctime = System.currentTimeMillis();
+
+ private int version;
+
+ private DriftChangeSetCategory category;
+
+ private int configId;
+
+ private int resourceId;
+
+ @Embedded("files")
+ private Set<MongoDBChangeSetEntry> entries = new HashSet<MongoDBChangeSetEntry>();
+
+ public ObjectId getObjectId() {
+ return id;
+ }
+
+ @Override
+ public String getId() {
+ return id.toString();
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = new ObjectId(id);
+ }
+
+ public void setId(ObjectId id) {
+ this.id = id;
+ }
+
+ @Override
+ public Long getCtime() {
+ return ctime;
+ }
+
+ @Override
+ public int getVersion() {
+ return version;
+ }
+
+ @Override
+ public void setVersion(int version) {
+ this.version = version;
+ }
+
+ @Override
+ public DriftChangeSetCategory getCategory() {
+ return category;
+ }
+
+ @Override
+ public void setCategory(DriftChangeSetCategory category) {
+ this.category = category;
+ }
+
+ @Override
+ public int getDriftConfigurationId() {
+ return configId;
+ }
+
+ @Override
+ public void setDriftConfigurationId(int id) {
+ configId = id;
+ }
+
+ @Override
+ public int getResourceId() {
+ return resourceId;
+ }
+
+ public void setResourceId(int id) {
+ resourceId = id;
+ }
+
+ @Override
+ public Set<MongoDBChangeSetEntry> getDrifts() {
+ return entries;
+ }
+
+ public MongoDBChangeSet add(MongoDBChangeSetEntry entry) {
+ entries.add(entry);
+ return this;
+ }
+
+ @Override
+ public void setDrifts(Set<MongoDBChangeSetEntry> drifts) {
+ entries = drifts;
+ }
+}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java
new file mode 100644
index 0000000..80cdc0c
--- /dev/null
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetEntry.java
@@ -0,0 +1,77 @@
+package org.rhq.enterprise.server.plugins.drift.mongodb.entities;
+
+import com.google.code.morphia.annotations.Embedded;
+
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftCategory;
+
+@Embedded
+public class MongoDBChangeSetEntry implements Drift<MongoDBChangeSet, MongoDBFile> {
+
+ private Long ctime = System.currentTimeMillis();
+
+ private DriftCategory category;
+
+ private String path;
+
+ @Override
+ public String getId() {
+ return null;
+ }
+
+ @Override
+ public void setId(String id) {
+ }
+
+ @Override
+ public Long getCtime() {
+ return null;
+ }
+
+ @Override
+ public MongoDBChangeSet getChangeSet() {
+ return null;
+ }
+
+ @Override
+ public void setChangeSet(MongoDBChangeSet changeSet) {
+ }
+
+ @Override
+ public DriftCategory getCategory() {
+ return category;
+ }
+
+ @Override
+ public void setCategory(DriftCategory category) {
+ this.category = category;
+ }
+
+ @Override
+ public String getPath() {
+ return path;
+ }
+
+ @Override
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ @Override
+ public MongoDBFile getOldDriftFile() {
+ return null;
+ }
+
+ @Override
+ public void setOldDriftFile(MongoDBFile oldDriftFile) {
+ }
+
+ @Override
+ public MongoDBFile getNewDriftFile() {
+ return null;
+ }
+
+ @Override
+ public void setNewDriftFile(MongoDBFile newDriftFile) {
+ }
+}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBFile.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBFile.java
new file mode 100644
index 0000000..ea0c509
--- /dev/null
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBFile.java
@@ -0,0 +1,49 @@
+package org.rhq.enterprise.server.plugins.drift.mongodb.entities;
+
+import com.google.code.morphia.annotations.Entity;
+import com.google.code.morphia.annotations.Id;
+
+import org.rhq.core.domain.drift.DriftFile;
+import org.rhq.core.domain.drift.DriftFileStatus;
+
+@Entity
+public class MongoDBFile implements DriftFile {
+
+ @Id
+ private String hash;
+
+ @Override
+ public String getHashId() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void setHashId(String hashId) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public Long getCtime() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public Long getDataSize() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void setDataSize(Long size) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public DriftFileStatus getStatus() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void setStatus(DriftFileStatus status) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/drift-mongodb/src/main/resources/META-INF/rhq-serverplugin.xml
index e1894d0..eb32c51 100644
--- a/modules/enterprise/server/plugins/drift-mongodb/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -4,9 +4,9 @@
version="1.0"
apiVersion="1.0"
description="The Drift Management MongoDB Persistence Store"
- displayName="Drift:RHQ"
+ displayName="Drift:MongoDB"
name="drift-mongodb"
- package="org.rhq.enterprise.server.plugins.drift.MorphiaTest"
+ package="org.rhq.enterprise.server.plugins.drift.mongodb"
xmlns="urn:xmlns:rhq-serverplugin.drift"
xmlns:serverplugin="urn:xmlns:rhq-serverplugin"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/MorphiaTest.java b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/MorphiaTest.java
deleted file mode 100644
index c88432e..0000000
--- a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/MorphiaTest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.rhq.enterprise.server.plugins.drift;
-
-import com.google.code.morphia.Datastore;
-import com.google.code.morphia.Morphia;
-import com.mongodb.DB;
-import com.mongodb.Mongo;
-
-import org.testng.annotations.Test;
-
-import org.rhq.core.domain.drift.DriftChangeSet;
-
-public class MorphiaTest {
-
- @Test
- public void connectToMongoDB() throws Exception {
- Mongo connection = new Mongo("localhost");
- DB db = connection.getDB("test");
-
- Morphia morphia = new Morphia();
- morphia.map(DriftChangeSet.class);
-
- Datastore ds = morphia.createDatastore(connection, "test");
-
-// DriftChangeSet changeSet = new DriftChangeSet(null, 1, COVERAGE);
-// ds.save(changeSet);
- }
-
-}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
new file mode 100644
index 0000000..e6aec82
--- /dev/null
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/mongodb/entities/MongoDBChangeSetTest.java
@@ -0,0 +1,71 @@
+package org.rhq.enterprise.server.plugins.drift.mongodb.entities;
+
+import com.google.code.morphia.Datastore;
+import com.google.code.morphia.Morphia;
+import com.google.code.morphia.query.Query;
+import com.mongodb.Mongo;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
+import static org.rhq.test.AssertUtils.assertCollectionMatchesNoOrder;
+import static org.rhq.test.AssertUtils.assertPropertiesMatch;
+import static org.testng.Assert.assertNotNull;
+
+public class MongoDBChangeSetTest {
+
+ Mongo connection;
+
+ Morphia morphia;
+
+ Datastore ds;
+
+ @BeforeClass
+ public void initDB() throws Exception {
+ connection = new Mongo("localhost");
+
+ morphia = new Morphia()
+ .map(MongoDBChangeSet.class)
+ .map(MongoDBChangeSetEntry.class)
+ .map(MongoDBFile.class);
+
+ ds = morphia.createDatastore(connection, "rhq");
+ }
+
+ @BeforeMethod
+ public void clearCollections() throws Exception {
+ Query deleteAll = ds.createQuery(MongoDBChangeSet.class);
+ ds.delete(deleteAll);
+ }
+
+ @Test
+ public void saveAndLoadEmptyChangeSet() throws Exception {
+ MongoDBChangeSet expected = new MongoDBChangeSet();
+ expected.setCategory(COVERAGE);
+ expected.setVersion(1);
+ expected.setDriftConfigurationId(1);
+
+ ds.save(expected);
+ MongoDBChangeSet actual = ds.get(MongoDBChangeSet.class, expected.getObjectId());
+
+ assertNotNull(actual, "Failed to load change set");
+ assertPropertiesMatch("Failed to save change set", expected, actual);
+ }
+
+ @Test
+ public void saveAndLoadChangeSetWithOneEntry() throws Exception {
+ MongoDBChangeSet expected = new MongoDBChangeSet();
+ expected.getDrifts().add(new MongoDBChangeSetEntry());
+
+ ds.save(expected);
+
+ MongoDBChangeSet actual = ds.get(MongoDBChangeSet.class, expected.getObjectId());
+
+ assertNotNull(expected, "Failed to load change set");
+ assertPropertiesMatch("Failed to save change set", expected, actual, "drifts");
+ assertCollectionMatchesNoOrder(expected.getDrifts(), actual.getDrifts(), "Failed to save change set entries");
+ }
+
+}
commit 33d629c91cab66d62ea80fc57f131638b698b263
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jul 25 12:12:31 2011 -0400
drift change set criteria needs to support paging like everyone else.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BaseCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BaseCriteria.java
index edc436b..f377ade 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BaseCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BaseCriteria.java
@@ -3,8 +3,11 @@ package org.rhq.core.domain.criteria;
import org.rhq.core.domain.util.PageControl;
/**
- * Created by IntelliJ IDEA. User: jsanda Date: 7/19/11 Time: 5:30 PM To change this template use File | Settings | File
- * Templates.
+ * All criteria, regardless of the backend storage that will be queried with this criteria, needs
+ * to support certain base functionality (like paging).
+ * This base interface provides that common API.
+ *
+ * @author John Sanda
*/
public interface BaseCriteria {
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
index 1b3effc..b5f71b2 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
@@ -5,7 +5,7 @@ import java.io.Serializable;
import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.util.PageOrdering;
-public interface DriftChangeSetCriteria extends Serializable {
+public interface DriftChangeSetCriteria extends BaseCriteria, Serializable {
void addFilterId(String filterId);
commit dd2b33298b58db71552a7435bd9dbdb1bcaa125b
Merge: d2b6c62 3b0c734
Author: John Sanda <jsanda(a)redhat.com>
Date: Sun Jul 24 22:01:49 2011 -0400
Merge branch 'drift' into drift-mongodb
Conflicts:
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
modules/core/domain/src/main/java/org/rhq/core/domain/drift/Drift.java
modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSet.java
modules/core/domain/src/main/java/org/rhq/core/domain/drift/RhqDrift.java
modules/core/domain/src/main/java/org/rhq/core/domain/drift/RhqDriftChangeSet.java
modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
diff --cc modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
index 26520a1,bc8d26a..0000000
deleted file mode 100644,100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
+++ /dev/null
commit 3b0c7347778c73588535665e2afc410e1478da9a
Author: John Sanda <jsanda(a)redhat.com>
Date: Sun Jul 24 21:13:24 2011 -0400
Adding createSnapshot method to drift server api
Also moving Snapshot and DiffReport classes to core/domain to make them
accessible to coregui.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DiffReport.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DiffReport.java
new file mode 100644
index 0000000..e0659d9
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DiffReport.java
@@ -0,0 +1,38 @@
+package org.rhq.core.domain.drift;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DiffReport<T> {
+
+ private List<T> notInLeft = new ArrayList<T>();
+
+ private List<T> notInRight = new ArrayList<T>();
+
+ private List<T> conflicts = new ArrayList<T>();
+
+ public List<T> getElementsNotInLeft() {
+ return notInLeft;
+ }
+
+ public void elementNotInLeft(T element) {
+ notInLeft.add(element);
+ }
+
+ public List<T> getElementsNotInRight() {
+ return notInRight;
+ }
+
+ public void elementNotInRight(T element) {
+ notInRight.add(element);
+ }
+
+ public List<T> getElementsInConflict() {
+ return conflicts;
+ }
+
+ public void elementInConflict(T element) {
+ conflicts.add(element);
+ }
+
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/Snapshot.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/Snapshot.java
new file mode 100644
index 0000000..91e5f50
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/Snapshot.java
@@ -0,0 +1,68 @@
+package org.rhq.core.domain.drift;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Map;
+import java.util.TreeMap;
+
+import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
+
+public class Snapshot implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private int version;
+
+ private Map<String, Drift> entries = new TreeMap<String, Drift>();
+
+ public int getVersion() {
+ return version;
+ }
+
+ public Collection<Drift> getEntries() {
+ return entries.values();
+ }
+
+ public <D extends Drift> Snapshot add(DriftChangeSet<D> changeSet) {
+ for (Drift entry : changeSet.getDrifts()) {
+ entries.remove(entry.getPath());
+ if (entry.getCategory() != FILE_REMOVED) {
+ entries.put(entry.getPath(), entry);
+ }
+ }
+ version = changeSet.getVersion();
+ return this;
+ }
+
+ public DiffReport diff(Snapshot right) {
+ Snapshot left = this;
+ DiffReport<Drift> diff = new DiffReport<Drift>();
+
+ for (Map.Entry<String, Drift> entry : left.entries.entrySet()) {
+ if (!right.entries.containsKey(entry.getKey())) {
+ diff.elementNotInRight(entry.getValue());
+ }
+ }
+
+ for (Map.Entry<String, Drift> entry : right.entries.entrySet()) {
+ if (!left.entries.containsKey(entry.getKey())) {
+ diff.elementNotInLeft(entry.getValue());
+ }
+ }
+
+ for (Map.Entry<String, Drift> entry : left.entries.entrySet()) {
+ Drift rightDrift = right.entries.get(entry.getKey());
+ if (rightDrift != null) {
+ DriftFile leftFile = entry.getValue().getNewDriftFile();
+ DriftFile rightFile = rightDrift.getNewDriftFile();
+
+ if (!leftFile.getHashId().equals(rightFile.getHashId())) {
+ diff.elementInConflict(entry.getValue());
+ }
+ }
+ }
+
+ return diff;
+ }
+
+}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java
new file mode 100644
index 0000000..93653b3
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/SnapshotTest.java
@@ -0,0 +1,383 @@
+package org.rhq.core.domain.drift;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.testng.annotations.Test;
+
+import static java.util.Arrays.asList;
+import static org.rhq.core.domain.drift.DriftCategory.FILE_ADDED;
+import static org.rhq.core.domain.drift.DriftCategory.FILE_CHANGED;
+import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.DRIFT;
+import static org.rhq.core.domain.drift.DriftFileStatus.LOADED;
+import static org.rhq.test.AssertUtils.assertCollectionMatchesNoOrder;
+import static org.testng.Assert.assertEquals;
+
+public class SnapshotTest {
+
+ @Test
+ public void addChangeSetWithAddedFile() {
+ int configId = 1;
+
+ FakeDriftChangeSet changeSet = new FakeDriftChangeSet(0, COVERAGE, configId)
+ .add(new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt"));
+
+ Snapshot snapshot = new Snapshot().add(changeSet);
+
+ assertCollectionMatchesNoOrder(changeSet.getDrifts(), snapshot.getEntries(), "Failed to build " +
+ "a snapshot that contains a single change set");
+ assertEquals(snapshot.getVersion(), changeSet.getVersion(), "Snapshot version is wrong");
+ }
+
+ @Test
+ public void addChangeSetsWithAddedFiles() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
+
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("4a5b6c", 1024, LOADED), "/drift/2.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2);
+
+ Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
+
+ assertCollectionMatchesNoOrder(asSet(entry1, entry2), snapshot.getEntries(), "Failed to build snapshot " +
+ "with two change sets and file added in second change set");
+ assertEquals(snapshot.getVersion(), changeSet2.getVersion(), "Snapshot version is wrong");
+ }
+
+ @Test
+ public void replaceFileWithChangedVersion() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
+
+ Drift entry2 = new FakeDrift(FILE_CHANGED, new FakeDriftFile("a1b2c3", 1024, LOADED),
+ new FakeDriftFile("4d5e6f", 1024, LOADED), "/drift/1.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2);
+
+ Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
+
+ assertCollectionMatchesNoOrder(asSet(entry2), snapshot.getEntries(),
+ "Failed to build snapshot with file changed");
+ }
+
+ @Test
+ public void deleteFileThatHasBeenRemoved() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("d1f2a3", 1024, LOADED), "/drift/2.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1).add(entry2);
+
+ Drift entry3 = new FakeDrift(FILE_REMOVED, new FakeDriftFile("a1b2c3", 1024, LOADED), null, "/drift/1.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry3);
+
+ Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
+
+ assertCollectionMatchesNoOrder(asSet(entry2), snapshot.getEntries(),
+ "Failed to build snapshot with a file " +
+ "removed.");
+ }
+
+ @Test
+ public void diffShowsEntriesInLeftAndNotInRight() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
+ Snapshot right = new Snapshot().add(changeSet1);
+
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1).add(entry2);
+ Snapshot left = new Snapshot().add(changeSet1).add(changeSet2);
+
+ DiffReport diff = left.diff(right);
+
+ assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsNotInRight(),
+ "Diff report does not contain " +
+ "elements that are in the left but not in the right.");
+ }
+
+ @Test
+ public void diffShowsEntriesInRightAndNotInLeft() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
+ Snapshot right = new Snapshot().add(changeSet1);
+
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry2);
+ Snapshot left = new Snapshot().add(changeSet2);
+
+ DiffReport diff = left.diff(right);
+
+ assertCollectionMatchesNoOrder(asList(entry1), diff.getElementsNotInLeft(),
+ "Diff report does not contain " +
+ "elements that are in the left but not in the right");
+ }
+
+ @Test
+ public void diffShowsEntriesInLeftAndRightThatAreInConflict() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drfit/1.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
+ Snapshot right = new Snapshot().add(changeSet1);
+
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("c3b2a1", 1024, LOADED), "/drfit/1.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2);
+ Snapshot left = new Snapshot().add(changeSet2);
+
+ DiffReport diff = left.diff(right);
+
+ assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsInConflict(),
+ "Diff report does not contain " +
+ "element that are in both left and right and are in conflict");
+ }
+
+ <E> Set<E> asSet(E... elements) {
+ HashSet<E> set = new HashSet<E>();
+ for (E element : elements) {
+ set.add(element);
+ }
+ return set;
+ }
+
+ static class FakeDriftChangeSet implements DriftChangeSet {
+
+ private String id;
+ private int version;
+ private DriftChangeSetCategory category;
+ private int configId;
+ private Set<Drift> drifts = new HashSet<Drift>();
+ private long ctime = System.currentTimeMillis();
+
+ public FakeDriftChangeSet() {
+ }
+
+ public FakeDriftChangeSet(int version, DriftChangeSetCategory category, int configId) {
+ this.version = version;
+ this.category = category;
+ this.configId = configId;
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public Long getCtime() {
+ return ctime;
+ }
+
+ @Override
+ public int getVersion() {
+ return version;
+ }
+
+ @Override
+ public void setVersion(int version) {
+ this.version = version;
+ }
+
+ @Override
+ public DriftChangeSetCategory getCategory() {
+ return category;
+ }
+
+ @Override
+ public void setCategory(DriftChangeSetCategory category) {
+ this.category = category;
+ }
+
+ @Override
+ public int getDriftConfigurationId() {
+ return configId;
+ }
+
+ @Override
+ public void setDriftConfigurationId(int id) {
+ configId = id;
+ }
+
+ @Override
+ public int getResourceId() {
+ return 0;
+ }
+
+ @Override
+ public Set getDrifts() {
+ return drifts;
+ }
+
+ @Override
+ public void setDrifts(Set drifts) {
+ this.drifts = drifts;
+ }
+
+ public FakeDriftChangeSet add(Drift drift) {
+ drifts.add(drift);
+ return this;
+ }
+ }
+
+ static class FakeDrift implements Drift {
+
+ private String id;
+ private DriftCategory category;
+ private String path;
+ private DriftFile oldFile;
+ private DriftFile newFile;
+ private long ctime = System.currentTimeMillis();
+
+ public FakeDrift() {
+ }
+
+ public FakeDrift(DriftCategory category, DriftFile oldFile, DriftFile newFile, String path) {
+ this.category = category;
+ this.oldFile = oldFile;
+ this.newFile = newFile;
+ this.path = path;
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public Long getCtime() {
+ return ctime;
+ }
+
+ @Override
+ public DriftChangeSet getChangeSet() {
+ return null;
+ }
+
+ @Override
+ public void setChangeSet(DriftChangeSet changeSet) {
+
+ }
+
+ @Override
+ public DriftCategory getCategory() {
+ return category;
+ }
+
+ @Override
+ public void setCategory(DriftCategory category) {
+ this.category = category;
+ }
+
+ @Override
+ public String getPath() {
+ return path;
+ }
+
+ @Override
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ @Override
+ public DriftFile getOldDriftFile() {
+ return oldFile;
+ }
+
+ @Override
+ public void setOldDriftFile(DriftFile oldDriftFile) {
+ this.oldFile = oldDriftFile;
+ }
+
+ @Override
+ public DriftFile getNewDriftFile() {
+ return newFile;
+ }
+
+ @Override
+ public void setNewDriftFile(DriftFile newDriftFile) {
+ newFile = newDriftFile;
+ }
+
+ @Override
+ public String toString() {
+ return "Drift[category: " + category.code() + ", oldFile: " + oldFile + ", newFile: " + newFile +
+ ", path: " + path + "]";
+ }
+ }
+
+ static class FakeDriftFile implements DriftFile {
+
+ private String hash;
+ private long size;
+ private DriftFileStatus status;
+ private long ctime = System.currentTimeMillis();
+
+ public FakeDriftFile() {
+ }
+
+ public FakeDriftFile(String hash, long size, DriftFileStatus status) {
+ this.hash = hash;
+ this.size = size;
+ this.status = status;
+ }
+
+ @Override
+ public String getHashId() {
+ return hash;
+ }
+
+ @Override
+ public void setHashId(String hashId) {
+ hash = hashId;
+ }
+
+ @Override
+ public Long getCtime() {
+ return ctime;
+ }
+
+ @Override
+ public Long getDataSize() {
+ return size;
+ }
+
+ @Override
+ public void setDataSize(Long size) {
+ this.size = size;
+ }
+
+ @Override
+ public DriftFileStatus getStatus() {
+ return status;
+ }
+
+ @Override
+ public void setStatus(DriftFileStatus status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ return "DriftFile[hashId: " + hash + ", dataSize: " + size + ", status: " + status.ordinal() + "]";
+ }
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
index f69195d..10f72f5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
@@ -20,13 +20,16 @@ package org.rhq.enterprise.gui.coregui.client.gwt;
import com.google.gwt.user.client.rpc.RemoteService;
+import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.DriftConfiguration;
+import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.util.PageList;
/**
@@ -115,6 +118,8 @@ public interface DriftGWTService extends RemoteService {
PageList<DriftComposite> findDriftCompositesByCriteria(DriftCriteria criteria);
+ Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria);
+
/**
* Get the specified drift configuration for the specified context.
*
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
index 8d5beb9..b440ffd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
@@ -18,13 +18,16 @@
*/
package org.rhq.enterprise.gui.coregui.server.gwt;
+import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.DriftConfiguration;
+import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.gwt.DriftGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
@@ -122,6 +125,15 @@ public class DriftGWTServiceImpl extends AbstractGWTServiceImpl implements Drift
}
@Override
+ public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
+ try {
+ return driftServer.createSnapshot(subject, criteria);
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
+ }
+ }
+
+ @Override
public DriftConfiguration getDriftConfiguration(EntityContext entityContext, int driftConfigId)
throws RuntimeException {
try {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DiffReport.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DiffReport.java
deleted file mode 100644
index 89f3286..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DiffReport.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.rhq.enterprise.server.drift;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class DiffReport<T> {
-
- private List<T> notInLeft = new ArrayList<T>();
-
- private List<T> notInRight = new ArrayList<T>();
-
- private List<T> conflicts = new ArrayList<T>();
-
- public List<T> getElementsNotInLeft() {
- return notInLeft;
- }
-
- public void elementNotInLeft(T element) {
- notInLeft.add(element);
- }
-
- public List<T> getElementsNotInRight() {
- return notInRight;
- }
-
- public void elementNotInRight(T element) {
- notInRight.add(element);
- }
-
- public List<T> getElementsInConflict() {
- return conflicts;
- }
-
- public void elementInConflict(T element) {
- conflicts.add(element);
- }
-
-}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index 4c669e7..54eda95 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@ -71,6 +71,7 @@ import org.rhq.core.domain.drift.DriftFileBits;
import org.rhq.core.domain.drift.DriftFileStatus;
import org.rhq.core.domain.drift.RhqDrift;
import org.rhq.core.domain.drift.RhqDriftChangeSet;
+import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.ZipUtil;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
index 0fb077d..6939c7c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
@@ -33,6 +33,7 @@ import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.drift.RhqDrift;
import org.rhq.core.domain.drift.RhqDriftChangeSet;
import org.rhq.core.domain.drift.RhqDriftFile;
+import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.util.PageList;
@Local
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
index 0dd2aa8..276c8b9 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
@@ -19,11 +19,13 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.DriftConfiguration;
+import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.RHQConstants;
@@ -41,6 +43,13 @@ import static javax.ejb.TransactionAttributeType.NOT_SUPPORTED;
@Stateless
public class DriftServerBean implements DriftServerLocal {
+ // TODO Should security checks be handled here instead of delegating to the drift plugin?
+ // Currently any security checks that need to be performed are delegated to the plugin.
+ // This is fine *so far* since the only plugin is the default which is our existing SLSB
+ // layer backed by the RHQ database. If the plugins are only supposed to be responsible
+ // for persistence management of drift entities and content, then they should not be
+ // responsible for other concerns like security.
+
private Log log = LogFactory.getLog(DriftServerBean.class);
@PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
@@ -87,6 +96,13 @@ public class DriftServerBean implements DriftServerLocal {
driftServerPlugin.saveChangeSetFiles(changeSetFilesZip);
}
+ @Override
+ @TransactionAttribute(NOT_SUPPORTED)
+ public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
+ DriftServerPluginFacet driftServerPlugin = getServerPlugin();
+ return driftServerPlugin.createSnapshot(subject, criteria);
+ }
+
DriftServerPluginFacet getServerPlugin() {
MasterServerPluginContainer masterPC = LookupUtil.getServerPluginService().getMasterPluginContainer();
if (masterPC == null) {
@@ -201,4 +217,5 @@ public class DriftServerBean implements DriftServerLocal {
throw new IllegalArgumentException("Entity Context Type not supported [" + context + "]");
}
}
+
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
index 756f135..5046e83 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
@@ -7,11 +7,13 @@ import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftComposite;
import org.rhq.core.domain.drift.DriftConfiguration;
+import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.util.PageList;
@Local
@@ -33,4 +35,6 @@ public interface DriftServerLocal {
PageList<DriftComposite> findDriftCompositesByCriteria(Subject subject, DriftCriteria criteria);
+ Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria);
+
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
deleted file mode 100644
index 5dc18fa..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.rhq.enterprise.server.drift;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.DriftChangeSet;
-import org.rhq.core.domain.drift.DriftFile;
-
-import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
-
-public class Snapshot implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private int version;
-
- private Map<String, Drift> entries = new TreeMap<String, Drift>();
-
- public int getVersion() {
- return version;
- }
-
- public Collection<Drift> getEntries() {
- return entries.values();
- }
-
- public <D extends Drift> Snapshot add(DriftChangeSet<D> changeSet) {
- for (Drift entry : changeSet.getDrifts()) {
- entries.remove(entry.getPath());
- if (entry.getCategory() != FILE_REMOVED) {
- entries.put(entry.getPath(), entry);
- }
- }
- version = changeSet.getVersion();
- return this;
- }
-
- public DiffReport diff(Snapshot right) {
- Snapshot left = this;
- DiffReport<Drift> diff = new DiffReport<Drift>();
-
- for (Map.Entry<String, Drift> entry : left.entries.entrySet()) {
- if (!right.entries.containsKey(entry.getKey())) {
- diff.elementNotInRight(entry.getValue());
- }
- }
-
- for (Map.Entry<String, Drift> entry : right.entries.entrySet()) {
- if (!left.entries.containsKey(entry.getKey())) {
- diff.elementNotInLeft(entry.getValue());
- }
- }
-
- for (Map.Entry<String, Drift> entry : left.entries.entrySet()) {
- Drift rightDrift = right.entries.get(entry.getKey());
- if (rightDrift != null) {
- DriftFile leftFile = entry.getValue().getNewDriftFile();
- DriftFile rightFile = rightDrift.getNewDriftFile();
-
- if (!leftFile.getHashId().equals(rightFile.getHashId())) {
- diff.elementInConflict(entry.getValue());
- }
- }
- }
-
- return diff;
- }
-
-}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
index 890d2d8..867464d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
@@ -23,10 +23,12 @@ import java.io.File;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftComposite;
+import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
@@ -47,4 +49,6 @@ public interface DriftServerPluginFacet extends ServerPluginComponent {
void saveChangeSet(int resourceId, File changeSetZip) throws Exception;
void saveChangeSetFiles(File changeSetFilesZip) throws Exception;
+
+ Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria);
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java
deleted file mode 100644
index 47dbb73..0000000
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java
+++ /dev/null
@@ -1,385 +0,0 @@
-package org.rhq.enterprise.server.drift;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.testng.annotations.Test;
-
-import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.DriftCategory;
-import org.rhq.core.domain.drift.DriftChangeSet;
-import org.rhq.core.domain.drift.DriftChangeSetCategory;
-import org.rhq.core.domain.drift.DriftFile;
-import org.rhq.core.domain.drift.DriftFileStatus;
-
-import static java.util.Arrays.asList;
-import static org.rhq.core.domain.drift.DriftCategory.FILE_ADDED;
-import static org.rhq.core.domain.drift.DriftCategory.FILE_CHANGED;
-import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
-import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
-import static org.rhq.core.domain.drift.DriftChangeSetCategory.DRIFT;
-import static org.rhq.core.domain.drift.DriftFileStatus.LOADED;
-import static org.rhq.test.AssertUtils.assertCollectionMatchesNoOrder;
-import static org.testng.Assert.assertEquals;
-
-public class SnapshotTest {
-
- @Test
- public void addChangeSetWithAddedFile() {
- int configId = 1;
-
- FakeDriftChangeSet changeSet = new FakeDriftChangeSet(0, COVERAGE, configId)
- .add(new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt"));
-
- Snapshot snapshot = new Snapshot().add(changeSet);
-
- assertCollectionMatchesNoOrder(changeSet.getDrifts(), snapshot.getEntries(), "Failed to build " +
- "a snapshot that contains a single change set");
- assertEquals(snapshot.getVersion(), changeSet.getVersion(), "Snapshot version is wrong");
- }
-
- @Test
- public void addChangeSetsWithAddedFiles() {
- int configId = 1;
-
- Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
- FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
-
- Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("4a5b6c", 1024, LOADED), "/drift/2.txt");
- FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2);
-
- Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
-
- assertCollectionMatchesNoOrder(asSet(entry1, entry2), snapshot.getEntries(), "Failed to build snapshot " +
- "with two change sets and file added in second change set");
- assertEquals(snapshot.getVersion(), changeSet2.getVersion(), "Snapshot version is wrong");
- }
-
- @Test
- public void replaceFileWithChangedVersion() {
- int configId = 1;
-
- Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
- FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
-
- Drift entry2 = new FakeDrift(FILE_CHANGED, new FakeDriftFile("a1b2c3", 1024, LOADED),
- new FakeDriftFile("4d5e6f", 1024, LOADED), "/drift/1.txt");
- FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2);
-
- Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
-
- assertCollectionMatchesNoOrder(asSet(entry2), snapshot.getEntries(), "Failed to build snapshot with file changed");
- }
-
- @Test
- public void deleteFileThatHasBeenRemoved() {
- int configId = 1;
-
- Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
- Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("d1f2a3", 1024, LOADED), "/drift/2.txt");
- FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1).add(entry2);
-
- Drift entry3 = new FakeDrift(FILE_REMOVED, new FakeDriftFile("a1b2c3", 1024, LOADED), null, "/drift/1.txt");
- FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry3);
-
- Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
-
- assertCollectionMatchesNoOrder(asSet(entry2), snapshot.getEntries(), "Failed to build snapshot with a file " +
- "removed.");
- }
-
- @Test
- public void diffShowsEntriesInLeftAndNotInRight() {
- int configId = 1;
-
- Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
- FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
- Snapshot right = new Snapshot().add(changeSet1);
-
- Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt");
- FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1).add(entry2);
- Snapshot left = new Snapshot().add(changeSet1).add(changeSet2);
-
- DiffReport diff = left.diff(right);
-
- assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsNotInRight(), "Diff report does not contain " +
- "elements that are in the left but not in the right.");
- }
-
- @Test
- public void diffShowsEntriesInRightAndNotInLeft() {
- int configId = 1;
-
- Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
- FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
- Snapshot right = new Snapshot().add(changeSet1);
-
- Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt");
- FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry2);
- Snapshot left = new Snapshot().add(changeSet2);
-
- DiffReport diff = left.diff(right);
-
- assertCollectionMatchesNoOrder(asList(entry1), diff.getElementsNotInLeft(), "Diff report does not contain " +
- "elements that are in the left but not in the right");
- }
-
- @Test
- public void diffShowsEntriesInLeftAndRightThatAreInConflict() {
- int configId = 1;
-
- Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drfit/1.txt");
- FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
- Snapshot right = new Snapshot().add(changeSet1);
-
- Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("c3b2a1", 1024, LOADED), "/drfit/1.txt");
- FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2);
- Snapshot left = new Snapshot().add(changeSet2);
-
- DiffReport diff = left.diff(right);
-
- assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsInConflict(), "Diff report does not contain " +
- "element that are in both left and right and are in conflict");
- }
-
- <E> Set<E> asSet(E... elements) {
- HashSet<E> set = new HashSet<E>();
- for (E element : elements) {
- set.add(element);
- }
- return set;
- }
-
- static class FakeDriftChangeSet implements DriftChangeSet {
-
- private String id;
- private int version;
- private DriftChangeSetCategory category;
- private int configId;
- private Set<Drift> drifts = new HashSet<Drift>();
- private long ctime = System.currentTimeMillis();
-
- public FakeDriftChangeSet() {
- }
-
- public FakeDriftChangeSet(int version, DriftChangeSetCategory category, int configId) {
- this.version = version;
- this.category = category;
- this.configId = configId;
- }
-
- @Override
- public String getId() {
- return id;
- }
-
- @Override
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public Long getCtime() {
- return ctime;
- }
-
- @Override
- public int getVersion() {
- return version;
- }
-
- @Override
- public void setVersion(int version) {
- this.version = version;
- }
-
- @Override
- public DriftChangeSetCategory getCategory() {
- return category;
- }
-
- @Override
- public void setCategory(DriftChangeSetCategory category) {
- this.category = category;
- }
-
- @Override
- public int getDriftConfigurationId() {
- return configId;
- }
-
- @Override
- public void setDriftConfigurationId(int id) {
- configId = id;
- }
-
- @Override
- public int getResourceId() {
- return 0;
- }
-
- @Override
- public Set getDrifts() {
- return drifts;
- }
-
- @Override
- public void setDrifts(Set drifts) {
- this.drifts = drifts;
- }
-
- public FakeDriftChangeSet add(Drift drift) {
- drifts.add(drift);
- return this;
- }
- }
-
- static class FakeDrift implements Drift {
-
- private String id;
- private DriftCategory category;
- private String path;
- private DriftFile oldFile;
- private DriftFile newFile;
- private long ctime = System.currentTimeMillis();
-
- public FakeDrift() {
- }
-
- public FakeDrift(DriftCategory category, DriftFile oldFile, DriftFile newFile, String path) {
- this.category = category;
- this.oldFile = oldFile;
- this.newFile = newFile;
- this.path = path;
- }
-
- @Override
- public String getId() {
- return id;
- }
-
- @Override
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public Long getCtime() {
- return ctime;
- }
-
- @Override
- public DriftChangeSet getChangeSet() {
- return null;
- }
-
- @Override
- public void setChangeSet(DriftChangeSet changeSet) {
-
- }
-
- @Override
- public DriftCategory getCategory() {
- return category;
- }
-
- @Override
- public void setCategory(DriftCategory category) {
- this.category = category;
- }
-
- @Override
- public String getPath() {
- return path;
- }
-
- @Override
- public void setPath(String path) {
- this.path = path;
- }
-
- @Override
- public DriftFile getOldDriftFile() {
- return oldFile;
- }
-
- @Override
- public void setOldDriftFile(DriftFile oldDriftFile) {
- this.oldFile = oldDriftFile;
- }
-
- @Override
- public DriftFile getNewDriftFile() {
- return newFile;
- }
-
- @Override
- public void setNewDriftFile(DriftFile newDriftFile) {
- newFile = newDriftFile;
- }
-
- @Override
- public String toString() {
- return "Drift[category: " + category.code() + ", oldFile: " + oldFile + ", newFile: " + newFile +
- ", path: " + path + "]";
- }
- }
-
- static class FakeDriftFile implements DriftFile {
-
- private String hash;
- private long size;
- private DriftFileStatus status;
- private long ctime = System.currentTimeMillis();
-
- public FakeDriftFile() {
- }
-
- public FakeDriftFile(String hash, long size, DriftFileStatus status) {
- this.hash = hash;
- this.size = size;
- this.status = status;
- }
-
- @Override
- public String getHashId() {
- return hash;
- }
-
- @Override
- public void setHashId(String hashId) {
- hash = hashId;
- }
-
- @Override
- public Long getCtime() {
- return ctime;
- }
-
- @Override
- public Long getDataSize() {
- return size;
- }
-
- @Override
- public void setDataSize(Long size) {
- this.size = size;
- }
-
- @Override
- public DriftFileStatus getStatus() {
- return status;
- }
-
- @Override
- public void setStatus(DriftFileStatus status) {
- this.status = status;
- }
-
- @Override
- public String toString() {
- return "DriftFile[hashId: " + hash + ", dataSize: " + size + ", status: " + status.ordinal() + "]";
- }
- }
-
-}
diff --git a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
index 456c4a5..8d4cae4 100644
--- a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
@@ -33,6 +33,7 @@ import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftComposite;
+import org.rhq.core.domain.drift.Snapshot;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.drift.DriftManagerLocal;
import org.rhq.enterprise.server.plugin.pc.ServerPluginContext;
@@ -107,6 +108,12 @@ public class DriftServerPluginComponent implements DriftServerPluginFacet {
driftMgr.storeFiles(changeSetFilesZip);
}
+ @Override
+ public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
+ DriftManagerLocal driftMgr = getDriftManager();
+ return driftMgr.createSnapshot(subject, criteria);
+ }
+
private DriftJPACriteria toJPACriteria(DriftCriteria criteria) {
DriftJPACriteria jpaCriteria = new DriftJPACriteria();
jpaCriteria.addFilterId(criteria.getFilterId());
commit b468967cf8d1436096ad63164fee480234d37f93
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat Jul 23 22:57:09 2011 -0400
First cut at createSnapshot method in DriftManagerBean
Also refactoring tests in server/jar to use the JPAUtils class for
resetting the db.
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
index c03e3e6..bc8d26a 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
@@ -38,24 +38,6 @@ public class RhqDriftChangeSetTest extends AbstractEJB3Test {
resource.setDriftConfigurations(driftConfigs);
-// executeInTransaction(new TransactionCallback() {
-// @Override
-// public void execute() throws Exception {
-// getEntityManager().createQuery("delete from RhqDriftChangeSet").executeUpdate();
-//
-// // Cascading deletes for Resource.driftConfigurations does not work, nor does it
-// // appear the orphan deletes work either. I came across https://hibernate.onjira.com/browse/HHH-1917
-// // and https://hibernate.onjira.com/browse/HHH-1917 which led me to using
-// // native SQL to perform the delete on the join table rhq_drift_config_map.
-// //
-// // jsanda
-// getEntityManager().createNativeQuery("delete from rhq_drift_config_map").executeUpdate();
-//
-// getEntityManager().createQuery("delete from Resource").executeUpdate();
-// getEntityManager().createQuery("delete from ResourceType").executeUpdate();
-// }
-// });
-
executeInTransaction(new TransactionCallback() {
@Override
public void execute() throws Exception {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index 65a6a55..4c669e7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@ -581,4 +581,17 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
throw new IllegalArgumentException("Entity Context Type not supported [" + context + "]");
}
}
+
+ @Override
+ public Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria) {
+ // TODO security checks
+ Snapshot snapshot = new Snapshot();
+ PageList<RhqDriftChangeSet> changeSets = findDriftChangeSetsByCriteria(subject, criteria);
+
+ for (RhqDriftChangeSet changeSet : changeSets) {
+ snapshot.add(changeSet);
+ }
+
+ return snapshot;
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
index 4a30952..0fb077d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
@@ -177,7 +177,7 @@ public interface DriftManagerLocal extends DriftManagerRemote {
* @return
* @throws Exception
*/
- public RhqDriftFile persistDriftFile(RhqDriftFile driftFile) throws Exception;
+ RhqDriftFile persistDriftFile(RhqDriftFile driftFile) throws Exception;
/**
* SUPPORTS DRIFT RHQ SERVER PLUGIN
@@ -185,6 +185,8 @@ public interface DriftManagerLocal extends DriftManagerRemote {
* @param data
* @throws Exception
*/
- public void persistDriftFileData(RhqDriftFile driftFile, InputStream data) throws Exception;
+ void persistDriftFileData(RhqDriftFile driftFile, InputStream data) throws Exception;
+
+ Snapshot createSnapshot(Subject subject, DriftChangeSetJPACriteria criteria);
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java
index f1934d7..7ffacbf 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java
@@ -1,7 +1,5 @@
package org.rhq.enterprise.server.resource.metadata;
-import static org.rhq.core.clientapi.shared.PluginDescriptorUtil.loadPluginDescriptor;
-
import java.io.File;
import java.net.URL;
import java.sql.Connection;
@@ -39,10 +37,17 @@ import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
+import static org.rhq.core.clientapi.shared.PluginDescriptorUtil.loadPluginDescriptor;
+
public class MetadataBeanTest extends AbstractEJB3Test {
private static List<String> plugins = new ArrayList<String>();
+ @Override
+ protected boolean isDBResetNeeded() {
+ return false;
+ }
+
@BeforeGroups(groups = { "plugin.metadata" }, dependsOnGroups = { "integration.ejb3" })
public void startMBeanServer() throws Exception {
setupDB();
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
index ee2a45f..5ed329f 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
@@ -28,7 +28,6 @@ import javax.management.MBeanServerFactory;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
import javax.transaction.TransactionManager;
import org.hibernate.SessionFactory;
@@ -36,6 +35,7 @@ import org.hibernate.stat.Statistics;
import org.testng.AssertJUnit;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
@@ -57,12 +57,28 @@ import org.rhq.enterprise.server.scheduler.SchedulerService;
import org.rhq.enterprise.server.scheduler.SchedulerServiceMBean;
import org.rhq.enterprise.server.util.LookupUtil;
+import static org.rhq.test.JPAUtils.clearDB;
+import static org.rhq.test.JPAUtils.lookupEntityManager;
+import static org.rhq.test.JPAUtils.lookupTransactionManager;
+
/**
* This is the abstract test base for server jar tests.
*
* @author Greg Hinkle
*/
public abstract class AbstractEJB3Test extends AssertJUnit {
+
+ @BeforeClass
+ public void resetDB() throws Exception {
+ if (isDBResetNeeded()) {
+ clearDB();
+ }
+ }
+
+ protected boolean isDBResetNeeded() {
+ return true;
+ }
+
//@BeforeSuite(groups = {"integration.ejb3","PERF"}) // TODO investigate again
@BeforeSuite(alwaysRun = true)
public static void startupEmbeddedJboss() throws Exception {
@@ -165,23 +181,11 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
private static Statistics stats;
public TransactionManager getTransactionManager() {
- try {
- tm = (TransactionManager) getInitialContext().lookup("java:/TransactionManager");
- return tm;
- } catch (NamingException e) {
- e.printStackTrace();
- throw new RuntimeException("Failed to load transaction manager", e);
- }
+ return lookupTransactionManager();
}
public static EntityManager getEntityManager() {
- try {
- return ((EntityManagerFactory) getInitialContext().lookup(RHQConstants.ENTITY_MANAGER_JNDI_NAME))
- .createEntityManager();
- } catch (NamingException e) {
- e.printStackTrace();
- throw new RuntimeException("Failed to load entity manager", e);
- }
+ return lookupEntityManager();
}
public static InitialContext getInitialContext() {
commit bc096cd1e17cbb3d2b3cbc1ce9733fd6243f97a5
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat Jul 23 21:38:07 2011 -0400
Initial commit for JPAUtils
Refactoring some methods in AbstractEJB3Test to delegate to JPAUtils
with the intent to eliminate duplicate code in core/domain and
server/jar tests. Most importantly though, the method clearDB is now
part of JPAUtils making it accessible to any test. This provides a much
more robust way of resetting the entire database to a known, consistent
state.
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
index c9e61ef..c03e3e6 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
@@ -3,10 +3,6 @@ package org.rhq.core.domain.drift;
import java.util.HashSet;
import java.util.Set;
-import javax.persistence.EntityManager;
-import javax.transaction.SystemException;
-
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -16,6 +12,7 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.shared.ResourceBuilder;
import org.rhq.core.domain.test.AbstractEJB3Test;
+import org.rhq.test.TransactionCallback;
import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java b/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
index aa6e0e0..dc5319a 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
@@ -30,8 +30,6 @@ import java.util.Hashtable;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
import org.testng.AssertJUnit;
@@ -42,6 +40,13 @@ import org.testng.annotations.BeforeSuite;
import org.jboss.ejb3.embedded.EJB3StandaloneBootstrap;
import org.jboss.ejb3.embedded.EJB3StandaloneDeployer;
+import org.rhq.test.JPAUtils;
+import org.rhq.test.TransactionCallback;
+
+import static org.rhq.test.JPAUtils.clearDB;
+import static org.rhq.test.JPAUtils.lookupEntityManager;
+import static org.rhq.test.JPAUtils.lookupTransactionManager;
+
public abstract class AbstractEJB3Test extends AssertJUnit {
@BeforeClass
@@ -96,26 +101,12 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
EJB3StandaloneBootstrap.shutdown();
}
- private TransactionManager tm;
-
public TransactionManager getTransactionManager() {
- try {
- tm = (TransactionManager) getInitialContext().lookup("java:/TransactionManager");
- return tm;
- } catch (NamingException e) {
- e.printStackTrace();
- throw new RuntimeException("Failed to load transaction manager", e);
- }
+ return lookupTransactionManager();
}
public EntityManager getEntityManager() {
- try {
- return ((EntityManagerFactory) getInitialContext().lookup("java:/RHQEntityManagerFactory"))
- .createEntityManager();
- } catch (NamingException e) {
- e.printStackTrace();
- throw new RuntimeException("Failed to load entity manager", e);
- }
+ return lookupEntityManager();
}
public boolean isPostgres(EntityManager em) throws Exception {
@@ -148,171 +139,7 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
}
protected void executeInTransaction(TransactionCallback callback) {
- try {
- getTransactionManager().begin();
- callback.execute();
- getTransactionManager().commit();
- } catch (Throwable t) {
- try {
- getTransactionManager().rollback();
- } catch (SystemException e) {
- throw new RuntimeException("Failed to rollback transaction", e);
- }
- throw new RuntimeException(t.getCause());
- }
+ JPAUtils.executeInTransaction(callback);
}
- void clearDB() throws Exception {
- executeInTransaction(new TransactionCallback() {
- @Override
- public void execute() throws Exception {
- EntityManager em = getEntityManager();
-
- em.createNativeQuery("delete from jms_subscriptions");
- em.createNativeQuery("delete from jms_roles");
- em.createNativeQuery("delete from jms_users");
- em.createNativeQuery("delete from jms_transactions");
- em.createNativeQuery("delete from jms_messages");
- em.createNativeQuery("delete from rhq_drift_config_map");
- em.createNativeQuery("delete from rhq_drift_template_map");
- em.createNativeQuery("delete from rhq_delete_res_hist");
- em.createNativeQuery("delete from rhq_create_res_hist");
- em.createNativeQuery("delete from rhq_tagging_bundle_dest_map");
- em.createNativeQuery("delete from rhq_tagging_bundle_deploy_map");
- em.createNativeQuery("delete from rhq_tagging_bundle_version_map");
- em.createNativeQuery("delete from rhq_tagging_bundle_map");
- em.createNativeQuery("delete from rhq_bundle_res_dep_hist");
- em.createNativeQuery("delete from rhq_bundle_res_deploy");
- em.createNativeQuery("delete from rhq_bundle_deployment");
- em.createNativeQuery("delete from rhq_bundle_destination");
- em.createNativeQuery("delete from rhq_bundle_file");
- em.createNativeQuery("delete from rhq_bundle_version_repo");
- em.createNativeQuery("delete from rhq_bundle_version");
- em.createNativeQuery("delete from rhq_bundle");
- em.createNativeQuery("delete from rhq_bundle_type");
- em.createNativeQuery("delete from rhq_repo_advisory");
- em.createNativeQuery("delete from rhq_advisory_buglist");
- em.createNativeQuery("delete from rhq_advisory_cve");
- em.createNativeQuery("delete from rhq_cve");
- em.createNativeQuery("delete from rhq_advisory_package");
- em.createNativeQuery("delete from rhq_advisory");
- em.createNativeQuery("delete from rhq_distribution_file");
- em.createNativeQuery("delete from rhq_repo_distribution");
- em.createNativeQuery("delete from rhq_distribution where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_pkg_prd_map");
- em.createNativeQuery("delete from rhq_pkg_ver_content_src_map");
- em.createNativeQuery("delete from rhq_repo_pkg_version_map");
- em.createNativeQuery("delete from rhq_repo_repo_relation_map");
- em.createNativeQuery("delete from rhq_repo_repo_group_map");
- em.createNativeQuery("delete from rhq_repo_content_src_map");
- em.createNativeQuery("delete from rhq_repo_resource_map");
- em.createNativeQuery("delete from rhq_package_inst_step");
- em.createNativeQuery("delete from rhq_repo_sync");
- em.createNativeQuery("delete from rhq_content_src_sync");
- em.createNativeQuery("delete from rhq_installed_pkg_hist");
- em.createNativeQuery("delete from rhq_installed_package");
- em.createNativeQuery("delete from rhq_content_req");
- em.createNativeQuery("delete from rhq_package_version");
- em.createNativeQuery("delete from rhq_package_bits");
- em.createNativeQuery("delete from rhq_package");
- em.createNativeQuery("delete from rhq_package_type");
- em.createNativeQuery("delete from rhq_repo_relation");
- em.createNativeQuery("delete from rhq_repo_relation_type where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_repo");
- em.createNativeQuery("delete from rhq_repo_group");
- em.createNativeQuery("delete from rhq_repo_group_type where id <> 1");
- em.createNativeQuery("delete from rhq_archirtecture where id < 1 and id > 38");
- em.createNativeQuery("delete from rhq_meas_data_num_r14");
- em.createNativeQuery("delete from rhq_meas_data_num_r13");
- em.createNativeQuery("delete from rhq_meas_data_num_r12");
- em.createNativeQuery("delete from rhq_meas_data_num_r11");
- em.createNativeQuery("delete from rhq_meas_data_num_r10");
- em.createNativeQuery("delete from rhq_meas_data_num_r09");
- em.createNativeQuery("delete from rhq_meas_data_num_r08");
- em.createNativeQuery("delete from rhq_meas_data_num_r07");
- em.createNativeQuery("delete from rhq_meas_data_num_r06");
- em.createNativeQuery("delete from rhq_meas_data_num_r05");
- em.createNativeQuery("delete from rhq_meas_data_num_r04");
- em.createNativeQuery("delete from rhq_meas_data_num_r03");
- em.createNativeQuery("delete from rhq_meas_data_num_r02");
- em.createNativeQuery("delete from rhq_meas_data_num_r01");
- em.createNativeQuery("delete from rhq_meas_data_num_r00");
- em.createNativeQuery("delete from rhq_measurement_oob_tmp");
- em.createNativeQuery("delete rhq_measurement_oob");
- em.createNativeQuery("delete rhq_resource_avail");
- em.createNativeQuery("delete from rhq_availability");
- em.createNativeQuery("delete from rhq_calltime_data_value");
- em.createNativeQuery("delete from rhq_calltime_data_key");
- em.createNativeQuery("delete from rhq_measurement_data_trait");
- em.createNativeQuery("delete from rhq_measurement_data_num_1d");
- em.createNativeQuery("delete from rhq_measurement_data_num_6h");
- em.createNativeQuery("delete from rhq_measurement_data_num_1h");
- em.createNativeQuery("delete from rhq_measurement_bline");
- em.createNativeQuery("delete from rhq_measurement_sched");
- em.createNativeQuery("delete from rhq_measurement_def");
- em.createNativeQuery("delete from rhq_plugin");
- em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56)");
- em.createNativeQuery("delete from rhq_alert_notification");
- em.createNativeQuery("delete from rhq_alert_condition_log");
- em.createNativeQuery("delete from rhq_alert");
- em.createNativeQuery("delete from rhq_alert_condition");
- em.createNativeQuery("delete from rhq_alert_dampen_event");
- em.createNativeQuery("delete from rhq_alert_definition");
- em.createNativeQuery("delete from rhq_event");
- em.createNativeQuery("delete from rhq_event_source");
- em.createNativeQuery("delete from rhq_event_def");
- em.createNativeQuery("delete from rhq_operation_schedule");
- em.createNativeQuery("delete from rhq_operation_history");
- em.createNativeQuery("delete from rhq_operation_def");
- em.createNativeQuery("delete from rhq_dashboard_portlet");
- em.createNativeQuery("delete from rhq_dashboard");
- em.createNativeQuery("delete from rhq_saved_search");
- em.createNativeQuery("delete from rhq_subject_role_ldap_map");
- em.createNativeQuery("delete from rhq_subject_role_map where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_permission where role_id not in (1, 2)");
- em.createNativeQuery("delete from rhq_role_ldap_group");
- em.createNativeQuery("delete from rhq_role_resource_group_map");
- em.createNativeQuery("delete from rhq_role where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_tagging_res_group_map");
- em.createNativeQuery("delete from rhq_tagging_resource_map");
- em.createNativeQuery("delete from rhq_tagging");
- em.createNativeQuery("delete from rhq_config_update");
- em.createNativeQuery("delete from rhq_config_group_update");
- em.createNativeQuery("delete from rhq_resource_group_res_exp_map");
- em.createNativeQuery("delete from rhq_resource_group_res_imp_map");
- em.createNativeQuery("delete from rhq_resource_group");
- em.createNativeQuery("delete from rhq_group_def");
- em.createNativeQuery("delete from rhq_resource_error");
- em.createNativeQuery("delete from rhq_resource");
- em.createNativeQuery("delete from rhq_prd_ver");
- em.createNativeQuery("delete from rhq_process_scan");
- em.createNativeQuery("delete from rhq_resource_type_parents");
- em.createNativeQuery("delete from rhq_resource_subcat");
- em.createNativeQuery("delete from rhq_resource_type");
- em.createNativeQuery("delete from rhq_subject where id not in (1, 2)");
- em.createNativeQuery("delete from rhq_principal where id <> 2");
- em.createNativeQuery("delete from rhq_failover_details");
- em.createNativeQuery("delete from rhq_failover_list");
- em.createNativeQuery("delete from rhq_partition_details");
- em.createNativeQuery("delete from rhq_partition_event");
- em.createNativeQuery("delete from rhq_agent");
- em.createNativeQuery("delete from rhq_server");
- em.createNativeQuery("delete from rhq_affinity_group");
- em.createNativeQuery("delete from rhq_raw_config");
- em.createNativeQuery("delete from rhq_config_template");
- em.createNativeQuery("delete from rhq_config_property");
- em.createNativeQuery("delete from rhq_config");
- em.createNativeQuery("delete from rhq_config_prop_constr");
- em.createNativeQuery("delete from rhq_conf_prop_def_enum");
- em.createNativeQuery("delete from rhq_config_pd_osrc");
- em.createNativeQuery("delete from rhq_config_prop_def");
- em.createNativeQuery("delete from rhq_config_prop_grp_def");
- em.createNativeQuery("delete from rhq_config_def");
- }
- });
- }
-
- public static interface TransactionCallback {
- void execute() throws Exception;
- }
}
\ No newline at end of file
diff --git a/modules/test-utils/pom.xml b/modules/test-utils/pom.xml
index 3ed6856..5c6e85c 100644
--- a/modules/test-utils/pom.xml
+++ b/modules/test-utils/pom.xml
@@ -15,6 +15,16 @@
<dependencies>
<dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
diff --git a/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
new file mode 100644
index 0000000..349b84c
--- /dev/null
+++ b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
@@ -0,0 +1,207 @@
+package org.rhq.test;
+
+import java.util.Hashtable;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
+
+public class JPAUtils {
+
+ public static InitialContext getInitialContext() {
+ Hashtable<String, String> env = new Hashtable<String, String>();
+ env.put("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
+ env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
+ try {
+ return new InitialContext(env);
+ } catch (NamingException e) {
+ throw new RuntimeException("Failed to load initial context", e);
+ }
+ }
+
+ public static EntityManager lookupEntityManager() {
+ try {
+ return ((EntityManagerFactory) getInitialContext().lookup("java:/RHQEntityManagerFactory"))
+ .createEntityManager();
+ } catch (NamingException e) {
+ throw new RuntimeException("Failed to load entity manager", e);
+ }
+ }
+
+ public static TransactionManager lookupTransactionManager() {
+ try {
+ return (TransactionManager) getInitialContext().lookup("java:/TransactionManager");
+ } catch (NamingException e) {
+ throw new RuntimeException("Failed to load transaction manager", e);
+ }
+ }
+
+ public static void executeInTransaction(TransactionCallback callback) {
+ try {
+ lookupTransactionManager().begin();
+ callback.execute();
+ lookupTransactionManager().commit();
+ } catch (Throwable t) {
+ try {
+ lookupTransactionManager().rollback();
+ } catch (SystemException e) {
+ throw new RuntimeException("Failed to rollback transaction", e);
+ }
+ throw new RuntimeException(t.getCause());
+ }
+ }
+
+ public static void clearDB() {
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ EntityManager em = lookupEntityManager();
+
+ em.createNativeQuery("delete from jms_subscriptions");
+ em.createNativeQuery("delete from jms_roles");
+ em.createNativeQuery("delete from jms_users");
+ em.createNativeQuery("delete from jms_transactions");
+ em.createNativeQuery("delete from jms_messages");
+ em.createNativeQuery("delete from rhq_drift_config_map");
+ em.createNativeQuery("delete from rhq_drift_template_map");
+ em.createNativeQuery("delete from rhq_delete_res_hist");
+ em.createNativeQuery("delete from rhq_create_res_hist");
+ em.createNativeQuery("delete from rhq_tagging_bundle_dest_map");
+ em.createNativeQuery("delete from rhq_tagging_bundle_deploy_map");
+ em.createNativeQuery("delete from rhq_tagging_bundle_version_map");
+ em.createNativeQuery("delete from rhq_tagging_bundle_map");
+ em.createNativeQuery("delete from rhq_bundle_res_dep_hist");
+ em.createNativeQuery("delete from rhq_bundle_res_deploy");
+ em.createNativeQuery("delete from rhq_bundle_deployment");
+ em.createNativeQuery("delete from rhq_bundle_destination");
+ em.createNativeQuery("delete from rhq_bundle_file");
+ em.createNativeQuery("delete from rhq_bundle_version_repo");
+ em.createNativeQuery("delete from rhq_bundle_version");
+ em.createNativeQuery("delete from rhq_bundle");
+ em.createNativeQuery("delete from rhq_bundle_type");
+ em.createNativeQuery("delete from rhq_repo_advisory");
+ em.createNativeQuery("delete from rhq_advisory_buglist");
+ em.createNativeQuery("delete from rhq_advisory_cve");
+ em.createNativeQuery("delete from rhq_cve");
+ em.createNativeQuery("delete from rhq_advisory_package");
+ em.createNativeQuery("delete from rhq_advisory");
+ em.createNativeQuery("delete from rhq_distribution_file");
+ em.createNativeQuery("delete from rhq_repo_distribution");
+ em.createNativeQuery("delete from rhq_distribution where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_pkg_prd_map");
+ em.createNativeQuery("delete from rhq_pkg_ver_content_src_map");
+ em.createNativeQuery("delete from rhq_repo_pkg_version_map");
+ em.createNativeQuery("delete from rhq_repo_repo_relation_map");
+ em.createNativeQuery("delete from rhq_repo_repo_group_map");
+ em.createNativeQuery("delete from rhq_repo_content_src_map");
+ em.createNativeQuery("delete from rhq_repo_resource_map");
+ em.createNativeQuery("delete from rhq_package_inst_step");
+ em.createNativeQuery("delete from rhq_repo_sync");
+ em.createNativeQuery("delete from rhq_content_src_sync");
+ em.createNativeQuery("delete from rhq_installed_pkg_hist");
+ em.createNativeQuery("delete from rhq_installed_package");
+ em.createNativeQuery("delete from rhq_content_req");
+ em.createNativeQuery("delete from rhq_package_version");
+ em.createNativeQuery("delete from rhq_package_bits");
+ em.createNativeQuery("delete from rhq_package");
+ em.createNativeQuery("delete from rhq_package_type");
+ em.createNativeQuery("delete from rhq_repo_relation");
+ em.createNativeQuery("delete from rhq_repo_relation_type where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_repo");
+ em.createNativeQuery("delete from rhq_repo_group");
+ em.createNativeQuery("delete from rhq_repo_group_type where id <> 1");
+ em.createNativeQuery("delete from rhq_archirtecture where id < 1 and id > 38");
+ em.createNativeQuery("delete from rhq_meas_data_num_r14");
+ em.createNativeQuery("delete from rhq_meas_data_num_r13");
+ em.createNativeQuery("delete from rhq_meas_data_num_r12");
+ em.createNativeQuery("delete from rhq_meas_data_num_r11");
+ em.createNativeQuery("delete from rhq_meas_data_num_r10");
+ em.createNativeQuery("delete from rhq_meas_data_num_r09");
+ em.createNativeQuery("delete from rhq_meas_data_num_r08");
+ em.createNativeQuery("delete from rhq_meas_data_num_r07");
+ em.createNativeQuery("delete from rhq_meas_data_num_r06");
+ em.createNativeQuery("delete from rhq_meas_data_num_r05");
+ em.createNativeQuery("delete from rhq_meas_data_num_r04");
+ em.createNativeQuery("delete from rhq_meas_data_num_r03");
+ em.createNativeQuery("delete from rhq_meas_data_num_r02");
+ em.createNativeQuery("delete from rhq_meas_data_num_r01");
+ em.createNativeQuery("delete from rhq_meas_data_num_r00");
+ em.createNativeQuery("delete from rhq_measurement_oob_tmp");
+ em.createNativeQuery("delete rhq_measurement_oob");
+ em.createNativeQuery("delete rhq_resource_avail");
+ em.createNativeQuery("delete from rhq_availability");
+ em.createNativeQuery("delete from rhq_calltime_data_value");
+ em.createNativeQuery("delete from rhq_calltime_data_key");
+ em.createNativeQuery("delete from rhq_measurement_data_trait");
+ em.createNativeQuery("delete from rhq_measurement_data_num_1d");
+ em.createNativeQuery("delete from rhq_measurement_data_num_6h");
+ em.createNativeQuery("delete from rhq_measurement_data_num_1h");
+ em.createNativeQuery("delete from rhq_measurement_bline");
+ em.createNativeQuery("delete from rhq_measurement_sched");
+ em.createNativeQuery("delete from rhq_measurement_def");
+ em.createNativeQuery("delete from rhq_plugin");
+ em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56)");
+ em.createNativeQuery("delete from rhq_alert_notification");
+ em.createNativeQuery("delete from rhq_alert_condition_log");
+ em.createNativeQuery("delete from rhq_alert");
+ em.createNativeQuery("delete from rhq_alert_condition");
+ em.createNativeQuery("delete from rhq_alert_dampen_event");
+ em.createNativeQuery("delete from rhq_alert_definition");
+ em.createNativeQuery("delete from rhq_event");
+ em.createNativeQuery("delete from rhq_event_source");
+ em.createNativeQuery("delete from rhq_event_def");
+ em.createNativeQuery("delete from rhq_operation_schedule");
+ em.createNativeQuery("delete from rhq_operation_history");
+ em.createNativeQuery("delete from rhq_operation_def");
+ em.createNativeQuery("delete from rhq_dashboard_portlet");
+ em.createNativeQuery("delete from rhq_dashboard");
+ em.createNativeQuery("delete from rhq_saved_search");
+ em.createNativeQuery("delete from rhq_subject_role_ldap_map");
+ em.createNativeQuery("delete from rhq_subject_role_map where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_permission where role_id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_role_ldap_group");
+ em.createNativeQuery("delete from rhq_role_resource_group_map");
+ em.createNativeQuery("delete from rhq_role where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_tagging_res_group_map");
+ em.createNativeQuery("delete from rhq_tagging_resource_map");
+ em.createNativeQuery("delete from rhq_tagging");
+ em.createNativeQuery("delete from rhq_config_update");
+ em.createNativeQuery("delete from rhq_config_group_update");
+ em.createNativeQuery("delete from rhq_resource_group_res_exp_map");
+ em.createNativeQuery("delete from rhq_resource_group_res_imp_map");
+ em.createNativeQuery("delete from rhq_resource_group");
+ em.createNativeQuery("delete from rhq_group_def");
+ em.createNativeQuery("delete from rhq_resource_error");
+ em.createNativeQuery("delete from rhq_resource");
+ em.createNativeQuery("delete from rhq_prd_ver");
+ em.createNativeQuery("delete from rhq_process_scan");
+ em.createNativeQuery("delete from rhq_resource_type_parents");
+ em.createNativeQuery("delete from rhq_resource_subcat");
+ em.createNativeQuery("delete from rhq_resource_type");
+ em.createNativeQuery("delete from rhq_subject where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_principal where id <> 2");
+ em.createNativeQuery("delete from rhq_failover_details");
+ em.createNativeQuery("delete from rhq_failover_list");
+ em.createNativeQuery("delete from rhq_partition_details");
+ em.createNativeQuery("delete from rhq_partition_event");
+ em.createNativeQuery("delete from rhq_agent");
+ em.createNativeQuery("delete from rhq_server");
+ em.createNativeQuery("delete from rhq_affinity_group");
+ em.createNativeQuery("delete from rhq_raw_config");
+ em.createNativeQuery("delete from rhq_config_template");
+ em.createNativeQuery("delete from rhq_config_property");
+ em.createNativeQuery("delete from rhq_config");
+ em.createNativeQuery("delete from rhq_config_prop_constr");
+ em.createNativeQuery("delete from rhq_conf_prop_def_enum");
+ em.createNativeQuery("delete from rhq_config_pd_osrc");
+ em.createNativeQuery("delete from rhq_config_prop_def");
+ em.createNativeQuery("delete from rhq_config_prop_grp_def");
+ em.createNativeQuery("delete from rhq_config_def");
+ }
+ });
+ }
+
+}
diff --git a/modules/test-utils/src/main/java/org/rhq/test/TransactionCallback.java b/modules/test-utils/src/main/java/org/rhq/test/TransactionCallback.java
new file mode 100644
index 0000000..711df43
--- /dev/null
+++ b/modules/test-utils/src/main/java/org/rhq/test/TransactionCallback.java
@@ -0,0 +1,7 @@
+package org.rhq.test;
+
+public interface TransactionCallback {
+
+ void execute() throws Exception;
+
+}
commit ccf7dad401703bf3ea4fcbc2800053988a73ef62
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat Jul 23 07:09:35 2011 -0400
Adding support for version and date ranges in DriftChangeSetCriteria
Version and/or date ranges are needed in order to fetch multiple change
sets to build a snapshot. This commit also includes new set up code in
the base test class AbstractEJB3Test. It clears all database tables
which should be more robust than the approach taken with dbunit.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
index 6ba63df..1b3effc 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
@@ -15,6 +15,22 @@ public interface DriftChangeSetCriteria extends Serializable {
String getFilterVersion();
+ void addFilterStartVersion(String filterStartVersion);
+
+ String getFilterStartVersion();
+
+ void addFilterEndVersion(String filterEndVersion);
+
+ String getFilterEndVersion();
+
+ void addFilterCreatedAfter(Long filterCreatedAfter);
+
+ Long getFilterCreatedAfter();
+
+ void addFilterCreatedBefore(Long filterCreatedBefore);
+
+ Long getFilterCreatedBefore();
+
void addFilterResourceId(Integer filterResourceId);
Integer getFilterResourceId();
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
index 9b39cc3..6c17877 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
@@ -40,6 +40,10 @@ public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSe
private Integer filterInitial; // needs override
private Integer filterResourceId; // needs override
private String filterVersion;
+ private String filterStartVersion;
+ private String filterEndVersion;
+ private Long filterCreatedAfter;
+ private Long filterCreatedBefore;
private DriftChangeSetCategory filterCategory;
private boolean fetchDrifts;
@@ -48,6 +52,10 @@ public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSe
public DriftChangeSetJPACriteria() {
filterOverrides.put("initial", "version = 0");
filterOverrides.put("resourceId", "resource.id = ?");
+ filterOverrides.put("filterStartVersion", "version >= ?");
+ filterOverrides.put("filterEndVersion", "version <= ?");
+ filterOverrides.put("filterCreatedAfter", "ctime >= ?");
+ filterOverrides.put("filterCreatedBefore", "ctime <= ?");
}
@Override
@@ -75,6 +83,46 @@ public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSe
return filterVersion;
}
+ @Override
+ public void addFilterStartVersion(String filterStartVersion) {
+ this.filterStartVersion = filterStartVersion;
+ }
+
+ @Override
+ public String getFilterStartVersion() {
+ return filterStartVersion;
+ }
+
+ @Override
+ public void addFilterEndVersion(String filterEndVersion) {
+ this.filterEndVersion = filterEndVersion;
+ }
+
+ @Override
+ public String getFilterEndVersion() {
+ return filterEndVersion;
+ }
+
+ @Override
+ public void addFilterCreatedAfter(Long filterCreatedAfter) {
+ this.filterCreatedAfter = filterCreatedAfter;
+ }
+
+ @Override
+ public Long getFilterCreatedAfter() {
+ return filterCreatedAfter;
+ }
+
+ @Override
+ public void addFilterCreatedBefore(Long filterCreatedBefore) {
+ this.filterCreatedBefore = filterCreatedBefore;
+ }
+
+ @Override
+ public Long getFilterCreatedBefore() {
+ return filterCreatedBefore;
+ }
+
public void addFilterResourceId(Integer filterResourceId) {
this.filterResourceId = filterResourceId;
}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
index abc300d..c9e61ef 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
@@ -1,11 +1,12 @@
package org.rhq.core.domain.drift;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
+import javax.persistence.EntityManager;
import javax.transaction.SystemException;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -20,10 +21,6 @@ import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
public class RhqDriftChangeSetTest extends AbstractEJB3Test {
- static interface TransactionCallback {
- void execute() throws Exception;
- }
-
Resource resource;
DriftConfiguration driftConfig;
@@ -44,23 +41,23 @@ public class RhqDriftChangeSetTest extends AbstractEJB3Test {
resource.setDriftConfigurations(driftConfigs);
- executeInTransaction(new TransactionCallback() {
- @Override
- public void execute() throws Exception {
- getEntityManager().createQuery("delete from RhqDriftChangeSet").executeUpdate();
-
- // Cascading deletes for Resource.driftConfigurations does not work, nor does it
- // appear the orphan deletes work either. I came across https://hibernate.onjira.com/browse/HHH-1917
- // and https://hibernate.onjira.com/browse/HHH-1917 which led me to using
- // native SQL to perform the delete on the join table rhq_drift_config_map.
- //
- // jsanda
- getEntityManager().createNativeQuery("delete from rhq_drift_config_map").executeUpdate();
-
- getEntityManager().createQuery("delete from Resource").executeUpdate();
- getEntityManager().createQuery("delete from ResourceType").executeUpdate();
- }
- });
+// executeInTransaction(new TransactionCallback() {
+// @Override
+// public void execute() throws Exception {
+// getEntityManager().createQuery("delete from RhqDriftChangeSet").executeUpdate();
+//
+// // Cascading deletes for Resource.driftConfigurations does not work, nor does it
+// // appear the orphan deletes work either. I came across https://hibernate.onjira.com/browse/HHH-1917
+// // and https://hibernate.onjira.com/browse/HHH-1917 which led me to using
+// // native SQL to perform the delete on the join table rhq_drift_config_map.
+// //
+// // jsanda
+// getEntityManager().createNativeQuery("delete from rhq_drift_config_map").executeUpdate();
+//
+// getEntityManager().createQuery("delete from Resource").executeUpdate();
+// getEntityManager().createQuery("delete from ResourceType").executeUpdate();
+// }
+// });
executeInTransaction(new TransactionCallback() {
@Override
@@ -115,19 +112,4 @@ public class RhqDriftChangeSetTest extends AbstractEJB3Test {
});
}
- void executeInTransaction(TransactionCallback callback) {
- try {
- getTransactionManager().begin();
- callback.execute();
- getTransactionManager().commit();
- } catch (Throwable t) {
- try {
- getTransactionManager().rollback();
- } catch (SystemException e) {
- throw new RuntimeException("Failed to rollback transaction", e);
- }
- throw new RuntimeException(t.getCause());
- }
- }
-
}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java b/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
index 57ec318..aa6e0e0 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java
@@ -31,20 +31,26 @@ import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
+import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
import org.testng.AssertJUnit;
import org.testng.annotations.AfterGroups;
-import org.testng.annotations.AfterSuite;
-import org.testng.annotations.BeforeGroups;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeSuite;
import org.jboss.ejb3.embedded.EJB3StandaloneBootstrap;
import org.jboss.ejb3.embedded.EJB3StandaloneDeployer;
public abstract class AbstractEJB3Test extends AssertJUnit {
-// @BeforeSuite(groups = "integration.ejb3")
- @BeforeGroups(groups = "integration.ejb3")
+
+ @BeforeClass
+ public void resetDB() throws Exception {
+ clearDB();
+ }
+
+ @BeforeSuite(groups = "integration.ejb3")
+ //@BeforeGroups(groups = "integration.ejb3")
public static void startupEmbeddedJboss() {
System.out.println("Starting ejb3...");
String classesDir = System.getProperty("ejbjarDirectory", "target/classes");
@@ -140,4 +146,173 @@ public abstract class AbstractEJB3Test extends AssertJUnit {
referenceTime += offset;
return new Date(referenceTime);
}
+
+ protected void executeInTransaction(TransactionCallback callback) {
+ try {
+ getTransactionManager().begin();
+ callback.execute();
+ getTransactionManager().commit();
+ } catch (Throwable t) {
+ try {
+ getTransactionManager().rollback();
+ } catch (SystemException e) {
+ throw new RuntimeException("Failed to rollback transaction", e);
+ }
+ throw new RuntimeException(t.getCause());
+ }
+ }
+
+ void clearDB() throws Exception {
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ EntityManager em = getEntityManager();
+
+ em.createNativeQuery("delete from jms_subscriptions");
+ em.createNativeQuery("delete from jms_roles");
+ em.createNativeQuery("delete from jms_users");
+ em.createNativeQuery("delete from jms_transactions");
+ em.createNativeQuery("delete from jms_messages");
+ em.createNativeQuery("delete from rhq_drift_config_map");
+ em.createNativeQuery("delete from rhq_drift_template_map");
+ em.createNativeQuery("delete from rhq_delete_res_hist");
+ em.createNativeQuery("delete from rhq_create_res_hist");
+ em.createNativeQuery("delete from rhq_tagging_bundle_dest_map");
+ em.createNativeQuery("delete from rhq_tagging_bundle_deploy_map");
+ em.createNativeQuery("delete from rhq_tagging_bundle_version_map");
+ em.createNativeQuery("delete from rhq_tagging_bundle_map");
+ em.createNativeQuery("delete from rhq_bundle_res_dep_hist");
+ em.createNativeQuery("delete from rhq_bundle_res_deploy");
+ em.createNativeQuery("delete from rhq_bundle_deployment");
+ em.createNativeQuery("delete from rhq_bundle_destination");
+ em.createNativeQuery("delete from rhq_bundle_file");
+ em.createNativeQuery("delete from rhq_bundle_version_repo");
+ em.createNativeQuery("delete from rhq_bundle_version");
+ em.createNativeQuery("delete from rhq_bundle");
+ em.createNativeQuery("delete from rhq_bundle_type");
+ em.createNativeQuery("delete from rhq_repo_advisory");
+ em.createNativeQuery("delete from rhq_advisory_buglist");
+ em.createNativeQuery("delete from rhq_advisory_cve");
+ em.createNativeQuery("delete from rhq_cve");
+ em.createNativeQuery("delete from rhq_advisory_package");
+ em.createNativeQuery("delete from rhq_advisory");
+ em.createNativeQuery("delete from rhq_distribution_file");
+ em.createNativeQuery("delete from rhq_repo_distribution");
+ em.createNativeQuery("delete from rhq_distribution where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_pkg_prd_map");
+ em.createNativeQuery("delete from rhq_pkg_ver_content_src_map");
+ em.createNativeQuery("delete from rhq_repo_pkg_version_map");
+ em.createNativeQuery("delete from rhq_repo_repo_relation_map");
+ em.createNativeQuery("delete from rhq_repo_repo_group_map");
+ em.createNativeQuery("delete from rhq_repo_content_src_map");
+ em.createNativeQuery("delete from rhq_repo_resource_map");
+ em.createNativeQuery("delete from rhq_package_inst_step");
+ em.createNativeQuery("delete from rhq_repo_sync");
+ em.createNativeQuery("delete from rhq_content_src_sync");
+ em.createNativeQuery("delete from rhq_installed_pkg_hist");
+ em.createNativeQuery("delete from rhq_installed_package");
+ em.createNativeQuery("delete from rhq_content_req");
+ em.createNativeQuery("delete from rhq_package_version");
+ em.createNativeQuery("delete from rhq_package_bits");
+ em.createNativeQuery("delete from rhq_package");
+ em.createNativeQuery("delete from rhq_package_type");
+ em.createNativeQuery("delete from rhq_repo_relation");
+ em.createNativeQuery("delete from rhq_repo_relation_type where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_repo");
+ em.createNativeQuery("delete from rhq_repo_group");
+ em.createNativeQuery("delete from rhq_repo_group_type where id <> 1");
+ em.createNativeQuery("delete from rhq_archirtecture where id < 1 and id > 38");
+ em.createNativeQuery("delete from rhq_meas_data_num_r14");
+ em.createNativeQuery("delete from rhq_meas_data_num_r13");
+ em.createNativeQuery("delete from rhq_meas_data_num_r12");
+ em.createNativeQuery("delete from rhq_meas_data_num_r11");
+ em.createNativeQuery("delete from rhq_meas_data_num_r10");
+ em.createNativeQuery("delete from rhq_meas_data_num_r09");
+ em.createNativeQuery("delete from rhq_meas_data_num_r08");
+ em.createNativeQuery("delete from rhq_meas_data_num_r07");
+ em.createNativeQuery("delete from rhq_meas_data_num_r06");
+ em.createNativeQuery("delete from rhq_meas_data_num_r05");
+ em.createNativeQuery("delete from rhq_meas_data_num_r04");
+ em.createNativeQuery("delete from rhq_meas_data_num_r03");
+ em.createNativeQuery("delete from rhq_meas_data_num_r02");
+ em.createNativeQuery("delete from rhq_meas_data_num_r01");
+ em.createNativeQuery("delete from rhq_meas_data_num_r00");
+ em.createNativeQuery("delete from rhq_measurement_oob_tmp");
+ em.createNativeQuery("delete rhq_measurement_oob");
+ em.createNativeQuery("delete rhq_resource_avail");
+ em.createNativeQuery("delete from rhq_availability");
+ em.createNativeQuery("delete from rhq_calltime_data_value");
+ em.createNativeQuery("delete from rhq_calltime_data_key");
+ em.createNativeQuery("delete from rhq_measurement_data_trait");
+ em.createNativeQuery("delete from rhq_measurement_data_num_1d");
+ em.createNativeQuery("delete from rhq_measurement_data_num_6h");
+ em.createNativeQuery("delete from rhq_measurement_data_num_1h");
+ em.createNativeQuery("delete from rhq_measurement_bline");
+ em.createNativeQuery("delete from rhq_measurement_sched");
+ em.createNativeQuery("delete from rhq_measurement_def");
+ em.createNativeQuery("delete from rhq_plugin");
+ em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56)");
+ em.createNativeQuery("delete from rhq_alert_notification");
+ em.createNativeQuery("delete from rhq_alert_condition_log");
+ em.createNativeQuery("delete from rhq_alert");
+ em.createNativeQuery("delete from rhq_alert_condition");
+ em.createNativeQuery("delete from rhq_alert_dampen_event");
+ em.createNativeQuery("delete from rhq_alert_definition");
+ em.createNativeQuery("delete from rhq_event");
+ em.createNativeQuery("delete from rhq_event_source");
+ em.createNativeQuery("delete from rhq_event_def");
+ em.createNativeQuery("delete from rhq_operation_schedule");
+ em.createNativeQuery("delete from rhq_operation_history");
+ em.createNativeQuery("delete from rhq_operation_def");
+ em.createNativeQuery("delete from rhq_dashboard_portlet");
+ em.createNativeQuery("delete from rhq_dashboard");
+ em.createNativeQuery("delete from rhq_saved_search");
+ em.createNativeQuery("delete from rhq_subject_role_ldap_map");
+ em.createNativeQuery("delete from rhq_subject_role_map where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_permission where role_id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_role_ldap_group");
+ em.createNativeQuery("delete from rhq_role_resource_group_map");
+ em.createNativeQuery("delete from rhq_role where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_tagging_res_group_map");
+ em.createNativeQuery("delete from rhq_tagging_resource_map");
+ em.createNativeQuery("delete from rhq_tagging");
+ em.createNativeQuery("delete from rhq_config_update");
+ em.createNativeQuery("delete from rhq_config_group_update");
+ em.createNativeQuery("delete from rhq_resource_group_res_exp_map");
+ em.createNativeQuery("delete from rhq_resource_group_res_imp_map");
+ em.createNativeQuery("delete from rhq_resource_group");
+ em.createNativeQuery("delete from rhq_group_def");
+ em.createNativeQuery("delete from rhq_resource_error");
+ em.createNativeQuery("delete from rhq_resource");
+ em.createNativeQuery("delete from rhq_prd_ver");
+ em.createNativeQuery("delete from rhq_process_scan");
+ em.createNativeQuery("delete from rhq_resource_type_parents");
+ em.createNativeQuery("delete from rhq_resource_subcat");
+ em.createNativeQuery("delete from rhq_resource_type");
+ em.createNativeQuery("delete from rhq_subject where id not in (1, 2)");
+ em.createNativeQuery("delete from rhq_principal where id <> 2");
+ em.createNativeQuery("delete from rhq_failover_details");
+ em.createNativeQuery("delete from rhq_failover_list");
+ em.createNativeQuery("delete from rhq_partition_details");
+ em.createNativeQuery("delete from rhq_partition_event");
+ em.createNativeQuery("delete from rhq_agent");
+ em.createNativeQuery("delete from rhq_server");
+ em.createNativeQuery("delete from rhq_affinity_group");
+ em.createNativeQuery("delete from rhq_raw_config");
+ em.createNativeQuery("delete from rhq_config_template");
+ em.createNativeQuery("delete from rhq_config_property");
+ em.createNativeQuery("delete from rhq_config");
+ em.createNativeQuery("delete from rhq_config_prop_constr");
+ em.createNativeQuery("delete from rhq_conf_prop_def_enum");
+ em.createNativeQuery("delete from rhq_config_pd_osrc");
+ em.createNativeQuery("delete from rhq_config_prop_def");
+ em.createNativeQuery("delete from rhq_config_prop_grp_def");
+ em.createNativeQuery("delete from rhq_config_def");
+ }
+ });
+ }
+
+ public static interface TransactionCallback {
+ void execute() throws Exception;
+ }
}
\ No newline at end of file
commit 64fc9eabcd406ed63230444d2e85d70c00244fb6
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 22 16:09:08 2011 -0400
stub out the new drift change sets subtab
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
new file mode 100644
index 0000000..f610b8b
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftChangeSetsView.java
@@ -0,0 +1,48 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * A view that displays a tree of all change sets and their related drift trails.
+ *
+ * @author John Mazzitelli
+ */
+public class DriftChangeSetsView extends LocatableVLayout {
+
+ private EntityContext context;
+ private boolean hasWriteAccess;
+
+ protected DriftChangeSetsView(String locatorId, String tableTitle, EntityContext context, boolean hasWriteAccess) {
+ super(locatorId);
+ this.context = context;
+ this.hasWriteAccess = hasWriteAccess;
+ }
+
+ public EntityContext getContext() {
+ return context;
+ }
+
+ protected boolean hasWriteAccess() {
+ return this.hasWriteAccess;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsView.java
new file mode 100644
index 0000000..ab54e88
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/ResourceDriftChangeSetsView.java
@@ -0,0 +1,40 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.drift;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+
+/**
+ * @author John Mazzitelli
+ */
+public class ResourceDriftChangeSetsView extends DriftChangeSetsView {
+ public static ResourceDriftChangeSetsView get(String locatorId, ResourceComposite composite) {
+ String tableTitle = MSG.view_drift_changeSets_resourceViewTitle();
+ EntityContext context = EntityContext.forResource(composite.getResource().getId());
+ boolean hasWriteAccess = composite.getResourcePermission().isDrift();
+ return new ResourceDriftChangeSetsView(locatorId, tableTitle, context, hasWriteAccess);
+ }
+
+ private ResourceDriftChangeSetsView(String locatorId, String tableTitle, EntityContext context,
+ boolean hasWriteAccess) {
+ super(locatorId, tableTitle, context, hasWriteAccess);
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index b8031ea..4efc189 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -50,6 +50,7 @@ import org.rhq.enterprise.gui.coregui.client.components.tab.SubTab;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewFactory;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
+import org.rhq.enterprise.gui.coregui.client.drift.ResourceDriftChangeSetsView;
import org.rhq.enterprise.gui.coregui.client.drift.ResourceDriftConfigurationView;
import org.rhq.enterprise.gui.coregui.client.drift.ResourceDriftHistoryView;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -98,6 +99,7 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
public static class DriftSubTab {
public static final String CONFIGURATION = "Configuration";
public static final String HISTORY = "History";
+ public static final String CHANGE_SETS = "ChangeSets";
}
public static class OperationsSubTab {
@@ -143,6 +145,7 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
private SubTab configHistory;
private SubTab eventHistory;
private SubTab driftHistory;
+ private SubTab driftChangeSets;
private SubTab driftConfig;
private SubTab contentDeployed;
private SubTab contentNew;
@@ -242,9 +245,11 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
.view_tabs_common_drift()), "subsystems/drift/Drift_16.png");
this.driftHistory = new SubTab(driftTab.extendLocatorId(DriftSubTab.HISTORY), new ViewName(DriftSubTab.HISTORY,
MSG.view_tabs_common_history()), null);
+ this.driftChangeSets = new SubTab(driftTab.extendLocatorId(DriftSubTab.CHANGE_SETS), new ViewName(
+ DriftSubTab.CHANGE_SETS, MSG.view_drift_changeSets()), null);
this.driftConfig = new SubTab(driftTab.extendLocatorId(DriftSubTab.CONFIGURATION), new ViewName(
DriftSubTab.CONFIGURATION, MSG.view_tabs_common_configuration()), null);
- driftTab.registerSubTabs(driftHistory, driftConfig);
+ driftTab.registerSubTabs(driftHistory, driftChangeSets, driftConfig);
tabs.add(driftTab);
contentTab = new TwoLevelTab(getTabSet().extendLocatorId("Content"), new ViewName("Content", MSG
@@ -521,6 +526,13 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
}
});
+ updateSubTab(this.driftTab, this.driftChangeSets, true, true, new ViewFactory() {
+ @Override
+ public Canvas createView() {
+ return ResourceDriftChangeSetsView.get(driftChangeSets.extendLocatorId("View"), resourceComposite);
+ }
+ });
+
updateSubTab(this.driftTab, this.driftConfig, true, true, new ViewFactory() {
@Override
public Canvas createView() {
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 354e504..c7d6f91 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -1121,6 +1121,8 @@ view_drift_button_detectNow = Detect Now
view_drift_category_fileAdded = File Added
view_drift_category_fileChanged = File Changed
view_drift_category_fileRemoved = File Removed
+view_drift_changeSets = Change Sets
+view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
view_drift_delete_confirm = Delete the selected drift(s)?
view_drift_delete_confirmAll = Delete all drifts from this source?
view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index f117bdf..5fe14aa 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -939,6 +939,8 @@ view_dashboards_title = Dashboard
##view_drift_category_fileAdded = File Added
##view_drift_category_fileChanged = File Changed
##view_drift_category_fileRemoved = File Removed
+##view_drift_changeSets = Change Sets
+##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index f343153..6bce847 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -1104,6 +1104,8 @@ view_dashboards_portlets_refresh_success1 = ポートレットの自動リフレ
view_dashboards_portlets_refresh_success2 = 自動リフレッシュするポートレットのリロードを停止しています
view_dashboards_title = ダッシュボード
##view_drift = Drift
+##view_drift_changeSets = Change Sets
+##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
##view_drift_table_baseDir = Base Directory
##view_drift_table_changeSet = Change Set
##view_drift_table_newFile = New File
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index 516f235..bd2b6fb 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -1139,6 +1139,8 @@ view_dashboards_title = Dashboard~
##view_drift_category_fileAdded = File Added
##view_drift_category_fileChanged = File Changed
##view_drift_category_fileRemoved = File Removed
+##view_drift_changeSets = Change Sets
+##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
##view_drift_delete_confirm = Delete the selected drift(s)?
##view_drift_delete_confirmAll = Delete all drifts from this source?
##view_drift_failure_delete = Failed to delete drift targets with id''s: {0}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index bcac425..9fa9115 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -1113,6 +1113,8 @@ view_dashboards_portlets_refresh_success1 = \u6210\u529f\u4fee\u6539portlets\u81
view_dashboards_portlets_refresh_success2 = \u6210\u529f\u505c\u7528portlets\u81ea\u52a8\u5237\u65b0\u7684\u91cd\u8f7d
view_dashboards_title = \u7edf\u8ba1\u8868\u76d8
##view_drift = Drift
+##view_drift_changeSets = Change Sets
+##view_drift_changeSets_resourceViewTitle = Resource Drift Change Sets
##view_drift_table_baseDir = Base Directory
##view_drift_table_changeSet = Change Set
##view_drift_table_newFile = New File
commit 1ea599c35ea9377818a0424c6eae32ab00f56a22
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 22 14:17:26 2011 -0400
tell eclipse that some source is now in the filtered sources location
diff --git a/.classpath b/.classpath
index c263ab4..d5bec34 100644
--- a/.classpath
+++ b/.classpath
@@ -154,6 +154,7 @@
<classpathentry kind="src" path="modules/enterprise/server/xml-schemas/target/generated-sources/xjc"/>
<classpathentry kind="src" path="modules/enterprise/server/jar/src/main/java"/>
<classpathentry kind="src" path="modules/enterprise/server/jar/src/test/java"/>
+ <classpathentry kind="src" path="modules/enterprise/server/jar/src/main/filtered-sources/java"/>
<classpathentry kind="src" path="modules/enterprise/server/jar/target/generated-sources/antlr3"/>
<classpathentry kind="src" path="modules/enterprise/binding/src/main/java"/>
<classpathentry kind="src" path="modules/enterprise/gui/coregui/src/main/java"/>
commit a9f16e8f23c3f52d8529217f533d2b07b02a117f
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 22 13:24:06 2011 -0400
Do not upload large amounts of data to the db for unit tests
We will however want to test uploading large and very large files in a
separate test suite.
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/DriftFileTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/DriftFileTest.java
index b22ac84..05757a7 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/DriftFileTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/DriftFileTest.java
@@ -96,11 +96,11 @@ public class DriftFileTest extends AbstractEJB3Test {
// running and should be moved to an integration test suite.
@Test(groups = { "integration.ejb3", "driftFile" })
public void loadMultipleDriftFilesWithoutLoadingData() throws Exception {
- int numDriftFiles = 10;
+ int numDriftFiles = 3;
final List<String> driftFileHashIds = new ArrayList<String>();
for (int i = 0; i < numDriftFiles; ++i) {
- File dataFile = createDataFile("test_data.txt", 10, (char) ('a' + i));
+ File dataFile = createDataFile("test_data.txt", 1, (char) ('a' + i));
final DriftFileBits driftFile = new DriftFileBits();
driftFile.setDataSize(dataFile.length());
driftFile.setHashId(digestGen.calcDigestString(dataFile));
commit b5cbc3b24e932325ba55dafac974d3a7b4dab5b9
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 22 13:22:56 2011 -0400
Adding support for generating snapshot diffs
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DiffReport.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DiffReport.java
new file mode 100644
index 0000000..89f3286
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DiffReport.java
@@ -0,0 +1,38 @@
+package org.rhq.enterprise.server.drift;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DiffReport<T> {
+
+ private List<T> notInLeft = new ArrayList<T>();
+
+ private List<T> notInRight = new ArrayList<T>();
+
+ private List<T> conflicts = new ArrayList<T>();
+
+ public List<T> getElementsNotInLeft() {
+ return notInLeft;
+ }
+
+ public void elementNotInLeft(T element) {
+ notInLeft.add(element);
+ }
+
+ public List<T> getElementsNotInRight() {
+ return notInRight;
+ }
+
+ public void elementNotInRight(T element) {
+ notInRight.add(element);
+ }
+
+ public List<T> getElementsInConflict() {
+ return conflicts;
+ }
+
+ public void elementInConflict(T element) {
+ conflicts.add(element);
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
index 2efc8d8..5dc18fa 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
@@ -1,12 +1,13 @@
package org.rhq.enterprise.server.drift;
import java.io.Serializable;
-import java.util.Comparator;
-import java.util.Set;
-import java.util.TreeSet;
+import java.util.Collection;
+import java.util.Map;
+import java.util.TreeMap;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.DriftFile;
import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
@@ -16,30 +17,56 @@ public class Snapshot implements Serializable {
private int version;
- private Set<Drift> entries = new TreeSet<Drift>(new Comparator<Drift>() {
- @Override
- public int compare(Drift d1, Drift d2) {
- return d1.getPath().compareTo(d2.getPath());
- }
- });
+ private Map<String, Drift> entries = new TreeMap<String, Drift>();
public int getVersion() {
return version;
}
- public Set<Drift> getEntries() {
- return entries;
+ public Collection<Drift> getEntries() {
+ return entries.values();
}
public <D extends Drift> Snapshot add(DriftChangeSet<D> changeSet) {
for (Drift entry : changeSet.getDrifts()) {
- entries.remove(entry);
+ entries.remove(entry.getPath());
if (entry.getCategory() != FILE_REMOVED) {
- entries.add(entry);
+ entries.put(entry.getPath(), entry);
}
}
version = changeSet.getVersion();
return this;
}
+ public DiffReport diff(Snapshot right) {
+ Snapshot left = this;
+ DiffReport<Drift> diff = new DiffReport<Drift>();
+
+ for (Map.Entry<String, Drift> entry : left.entries.entrySet()) {
+ if (!right.entries.containsKey(entry.getKey())) {
+ diff.elementNotInRight(entry.getValue());
+ }
+ }
+
+ for (Map.Entry<String, Drift> entry : right.entries.entrySet()) {
+ if (!left.entries.containsKey(entry.getKey())) {
+ diff.elementNotInLeft(entry.getValue());
+ }
+ }
+
+ for (Map.Entry<String, Drift> entry : left.entries.entrySet()) {
+ Drift rightDrift = right.entries.get(entry.getKey());
+ if (rightDrift != null) {
+ DriftFile leftFile = entry.getValue().getNewDriftFile();
+ DriftFile rightFile = rightDrift.getNewDriftFile();
+
+ if (!leftFile.getHashId().equals(rightFile.getHashId())) {
+ diff.elementInConflict(entry.getValue());
+ }
+ }
+ }
+
+ return diff;
+ }
+
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java
index b646b19..47dbb73 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java
@@ -12,6 +12,7 @@ import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftFile;
import org.rhq.core.domain.drift.DriftFileStatus;
+import static java.util.Arrays.asList;
import static org.rhq.core.domain.drift.DriftCategory.FILE_ADDED;
import static org.rhq.core.domain.drift.DriftCategory.FILE_CHANGED;
import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
@@ -87,6 +88,60 @@ public class SnapshotTest {
"removed.");
}
+ @Test
+ public void diffShowsEntriesInLeftAndNotInRight() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
+ Snapshot right = new Snapshot().add(changeSet1);
+
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1).add(entry2);
+ Snapshot left = new Snapshot().add(changeSet1).add(changeSet2);
+
+ DiffReport diff = left.diff(right);
+
+ assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsNotInRight(), "Diff report does not contain " +
+ "elements that are in the left but not in the right.");
+ }
+
+ @Test
+ public void diffShowsEntriesInRightAndNotInLeft() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
+ Snapshot right = new Snapshot().add(changeSet1);
+
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a3b6c9", 1024, LOADED), "/drift/2.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry2);
+ Snapshot left = new Snapshot().add(changeSet2);
+
+ DiffReport diff = left.diff(right);
+
+ assertCollectionMatchesNoOrder(asList(entry1), diff.getElementsNotInLeft(), "Diff report does not contain " +
+ "elements that are in the left but not in the right");
+ }
+
+ @Test
+ public void diffShowsEntriesInLeftAndRightThatAreInConflict() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drfit/1.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1);
+ Snapshot right = new Snapshot().add(changeSet1);
+
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("c3b2a1", 1024, LOADED), "/drfit/1.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry2);
+ Snapshot left = new Snapshot().add(changeSet2);
+
+ DiffReport diff = left.diff(right);
+
+ assertCollectionMatchesNoOrder(asList(entry2), diff.getElementsInConflict(), "Diff report does not contain " +
+ "element that are in both left and right and are in conflict");
+ }
+
<E> Set<E> asSet(E... elements) {
HashSet<E> set = new HashSet<E>();
for (E element : elements) {
commit 2f88f1db6226746b6c6c543db39802b884c43b1c
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 21 22:03:41 2011 -0400
Adding logic for removing files from a snapshot
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
index 35a4669..2efc8d8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/Snapshot.java
@@ -1,5 +1,6 @@
package org.rhq.enterprise.server.drift;
+import java.io.Serializable;
import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;
@@ -7,7 +8,11 @@ import java.util.TreeSet;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
-public class Snapshot {
+import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
+
+public class Snapshot implements Serializable {
+
+ private static final long serialVersionUID = 1L;
private int version;
@@ -29,7 +34,9 @@ public class Snapshot {
public <D extends Drift> Snapshot add(DriftChangeSet<D> changeSet) {
for (Drift entry : changeSet.getDrifts()) {
entries.remove(entry);
- entries.add(entry);
+ if (entry.getCategory() != FILE_REMOVED) {
+ entries.add(entry);
+ }
}
version = changeSet.getVersion();
return this;
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java
index 627bc2c..b646b19 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/SnapshotTest.java
@@ -14,6 +14,7 @@ import org.rhq.core.domain.drift.DriftFileStatus;
import static org.rhq.core.domain.drift.DriftCategory.FILE_ADDED;
import static org.rhq.core.domain.drift.DriftCategory.FILE_CHANGED;
+import static org.rhq.core.domain.drift.DriftCategory.FILE_REMOVED;
import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
import static org.rhq.core.domain.drift.DriftChangeSetCategory.DRIFT;
import static org.rhq.core.domain.drift.DriftFileStatus.LOADED;
@@ -23,7 +24,7 @@ import static org.testng.Assert.assertEquals;
public class SnapshotTest {
@Test
- public void generateSnapshotForOneChangeSet() throws Exception {
+ public void addChangeSetWithAddedFile() {
int configId = 1;
FakeDriftChangeSet changeSet = new FakeDriftChangeSet(0, COVERAGE, configId)
@@ -37,7 +38,7 @@ public class SnapshotTest {
}
@Test
- public void generateSnapshotWithTwoChangeSetsAndFileAdded() {
+ public void addChangeSetsWithAddedFiles() {
int configId = 1;
Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
@@ -54,7 +55,7 @@ public class SnapshotTest {
}
@Test
- public void generateSnapshotWithFileChanged() {
+ public void replaceFileWithChangedVersion() {
int configId = 1;
Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
@@ -66,7 +67,24 @@ public class SnapshotTest {
Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
- assertCollectionMatchesNoOrder(asSet(entry2), snapshot.getEntries(), "Failed build snapshot with file changed");
+ assertCollectionMatchesNoOrder(asSet(entry2), snapshot.getEntries(), "Failed to build snapshot with file changed");
+ }
+
+ @Test
+ public void deleteFileThatHasBeenRemoved() {
+ int configId = 1;
+
+ Drift entry1 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("a1b2c3", 1024, LOADED), "/drift/1.txt");
+ Drift entry2 = new FakeDrift(FILE_ADDED, null, new FakeDriftFile("d1f2a3", 1024, LOADED), "/drift/2.txt");
+ FakeDriftChangeSet changeSet1 = new FakeDriftChangeSet(0, COVERAGE, configId).add(entry1).add(entry2);
+
+ Drift entry3 = new FakeDrift(FILE_REMOVED, new FakeDriftFile("a1b2c3", 1024, LOADED), null, "/drift/1.txt");
+ FakeDriftChangeSet changeSet2 = new FakeDriftChangeSet(1, DRIFT, configId).add(entry3);
+
+ Snapshot snapshot = new Snapshot().add(changeSet1).add(changeSet2);
+
+ assertCollectionMatchesNoOrder(asSet(entry2), snapshot.getEntries(), "Failed to build snapshot with a file " +
+ "removed.");
}
<E> Set<E> asSet(E... elements) {
commit 7c6c2071cae2cae41db7888e37f5d4284c851c9e
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 21 16:45:15 2011 -0400
Disable verbose logging by default
diff --git a/modules/enterprise/server/jar/src/test/resources/default.persistence.properties b/modules/enterprise/server/jar/src/test/resources/default.persistence.properties
index 366ecb3..8e4f317 100644
--- a/modules/enterprise/server/jar/src/test/resources/default.persistence.properties
+++ b/modules/enterprise/server/jar/src/test/resources/default.persistence.properties
@@ -16,7 +16,7 @@ hibernate.bytecode.use_reflection_optimizer=false
# I don't think this is honored, but EJB3Deployer uses it
hibernate.bytecode.provider=javassist
hibernate.jdbc.use_streams_for_binary=true
-hibernate.show_sql=true
+hibernate.show_sql=false
hibernate.format_sql=true
hibernate.default_batch_fetch_size=16
hibernate.jdbc.batch_size=20
diff --git a/modules/enterprise/server/jar/src/test/resources/log4j.xml b/modules/enterprise/server/jar/src/test/resources/log4j.xml
index 83c5a23..681f2af 100644
--- a/modules/enterprise/server/jar/src/test/resources/log4j.xml
+++ b/modules/enterprise/server/jar/src/test/resources/log4j.xml
@@ -19,7 +19,7 @@
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="Target" value="System.out"/>
- <param name="Threshold" value="DEBUG"/>
+ <param name="Threshold" value="WARN"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Messagen -->
commit d2b6c62d7894fc85f8bf0613d36d957f70b81581
Merge: fc8d638 bc3c8ab
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 19 21:08:01 2011 -0400
Merge branch 'drift' into drift-mongodb
commit bc3c8abff3baaade68753f45e0eb47a049815e5f
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 19 20:58:25 2011 -0400
More refactoring to better support criteria queries for non-JPA back ends
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BaseCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BaseCriteria.java
new file mode 100644
index 0000000..edc436b
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BaseCriteria.java
@@ -0,0 +1,15 @@
+package org.rhq.core.domain.criteria;
+
+import org.rhq.core.domain.util.PageControl;
+
+/**
+ * Created by IntelliJ IDEA. User: jsanda Date: 7/19/11 Time: 5:30 PM To change this template use File | Settings | File
+ * Templates.
+ */
+public interface BaseCriteria {
+
+ PageControl getPageControlOverrides();
+
+ void setPageControl(PageControl pageControl);
+
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java
index b3c4dc2..55201d8 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java
@@ -40,7 +40,7 @@ import org.rhq.core.domain.util.PageList;
* @author Joseph Marques
*/
@XmlAccessorType(XmlAccessType.FIELD)
-public abstract class Criteria implements Serializable {
+public abstract class Criteria implements Serializable, BaseCriteria {
public enum Type {
FILTER, FETCH, SORT;
}
@@ -150,6 +150,7 @@ public abstract class Criteria implements Serializable {
* which is useful from a server-side calling context where the PageControl object
* will already have been created for you by the extensions at the JSF layer.
*/
+ @Override
public void setPageControl(PageControl pageControl) {
this.pageControlOverrides = pageControl;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
new file mode 100644
index 0000000..9b39cc3
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetJPACriteria.java
@@ -0,0 +1,114 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.core.domain.criteria;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
+import org.rhq.core.domain.drift.RhqDriftChangeSet;
+import org.rhq.core.domain.util.PageOrdering;
+
+/**
+ * @author Jay Shaughnessy
+ */
+@XmlRootElement
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@SuppressWarnings("unused")
+public class DriftChangeSetJPACriteria extends Criteria implements DriftChangeSetCriteria {
+ private static final long serialVersionUID = 1L;
+
+ private Integer filterId;
+ private Integer filterInitial; // needs override
+ private Integer filterResourceId; // needs override
+ private String filterVersion;
+ private DriftChangeSetCategory filterCategory;
+ private boolean fetchDrifts;
+
+ private PageOrdering sortVersion;
+
+ public DriftChangeSetJPACriteria() {
+ filterOverrides.put("initial", "version = 0");
+ filterOverrides.put("resourceId", "resource.id = ?");
+ }
+
+ @Override
+ public Class<RhqDriftChangeSet> getPersistentClass() {
+ return RhqDriftChangeSet.class;
+ }
+
+ public void addFilterId(String filterId) {
+ if (filterId != null) {
+ this.filterId = Integer.parseInt(filterId);
+ }
+ }
+
+ @Override
+ public String getFilterId() {
+ return filterId == null ? null : filterId.toString();
+ }
+
+ public void addFilterVersion(String filterVersion) {
+ this.filterVersion = filterVersion;
+ }
+
+ @Override
+ public String getFilterVersion() {
+ return filterVersion;
+ }
+
+ public void addFilterResourceId(Integer filterResourceId) {
+ this.filterResourceId = filterResourceId;
+ }
+
+ @Override
+ public Integer getFilterResourceId() {
+ return filterResourceId;
+ }
+
+ public void addFilterCategory(DriftChangeSetCategory filterCategory) {
+ this.filterCategory = filterCategory;
+ }
+
+ @Override
+ public DriftChangeSetCategory getFilterCategory() {
+ return filterCategory;
+ }
+
+ public void fetchDrifts(boolean fetchDrifts) {
+ this.fetchDrifts = fetchDrifts;
+ }
+
+ @Override
+ public boolean isFetchDrifts() {
+ return fetchDrifts;
+ }
+
+ public void addSortVersion(PageOrdering sortVersion) {
+ addSortField("version");
+ this.sortVersion = sortVersion;
+ }
+
+ @Override
+ public PageOrdering getSortVersion() {
+ return sortVersion;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java
index dc9764c..cdd061e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java
@@ -6,7 +6,7 @@ import java.util.List;
import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.core.domain.util.PageOrdering;
-public interface DriftCriteria extends Serializable {
+public interface DriftCriteria extends BaseCriteria, Serializable {
void addFilterId(String filterId);
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftJPACriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftJPACriteria.java
new file mode 100644
index 0000000..506cb06
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftJPACriteria.java
@@ -0,0 +1,153 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.core.domain.criteria;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.rhq.core.domain.drift.DriftCategory;
+import org.rhq.core.domain.drift.RhqDrift;
+import org.rhq.core.domain.util.CriteriaUtils;
+import org.rhq.core.domain.util.PageOrdering;
+
+/**
+ * @author Jay Shaughnessy
+ */
+@XmlRootElement
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@SuppressWarnings("unused")
+public class DriftJPACriteria extends Criteria implements DriftCriteria {
+ private static final long serialVersionUID = 1L;
+
+ private Integer filterId;
+ private List<DriftCategory> filterCategories = new ArrayList<DriftCategory>();
+ private Integer filterChangeSetId; // needs override
+ private String filterPath;
+ private List<Integer> filterResourceIds = new ArrayList<Integer>();
+ private Long filterStartTime; // requires overrides
+ private Long filterEndTime; // requires overrides
+
+ private boolean fetchChangeSet;
+
+ private PageOrdering sortCtime;
+
+ public DriftJPACriteria() {
+ filterOverrides.put("changeSetId", "changeSet.id = ?");
+ filterOverrides.put("categories", "category IN ( ? )");
+ filterOverrides.put("resourceIds", "changeSet.resource.id IN ( ? )");
+ filterOverrides.put("startTime", "ctime >= ?");
+ filterOverrides.put("endTime", "ctime <= ?");
+ }
+
+ @Override
+ public Class<RhqDrift> getPersistentClass() {
+ return RhqDrift.class;
+ }
+
+ public void addFilterId(String filterId) {
+ if (filterId != null) {
+ this.filterId = Integer.parseInt(filterId);
+ }
+ }
+
+ @Override
+ public String getFilterId() {
+ return filterId == null ? null : filterId.toString();
+ }
+
+ public void addFilterCategories(DriftCategory... filterCategories) {
+ this.filterCategories = CriteriaUtils.getListIgnoringNulls(filterCategories);
+ }
+
+ @Override
+ public List<DriftCategory> getFilterCategories() {
+ return filterCategories;
+ }
+
+ public void addFilterChangeSetId(String filterChangeSetId) {
+ if (filterChangeSetId != null) {
+ this.filterChangeSetId = Integer.parseInt(filterChangeSetId);
+ }
+ }
+
+ @Override
+ public String getFilterChangeSetId() {
+ return filterChangeSetId == null ? null : filterChangeSetId.toString();
+ }
+
+ public void addFilterPath(String filterPath) {
+ this.filterPath = filterPath;
+ }
+
+ @Override
+ public String getFilterPath() {
+ return filterPath;
+ }
+
+ public void addFilterResourceIds(Integer... filterResourceIds) {
+ this.filterResourceIds = CriteriaUtils.getListIgnoringNulls(filterResourceIds);
+ }
+
+ @Override
+ public List<Integer> getFilterResourceIds() {
+ return filterResourceIds;
+ }
+
+ public void addFilterStartTime(Long filterStartTime) {
+ this.filterStartTime = filterStartTime;
+ }
+
+ @Override
+ public Long getFilterStartTime() {
+ return filterStartTime;
+ }
+
+ public void addFilterEndTime(Long filterEndTime) {
+ this.filterEndTime = filterEndTime;
+ }
+
+ @Override
+ public Long getFilterEndTime() {
+ return filterEndTime;
+ }
+
+ public void fetchChangeSet(boolean fetchChangeSet) {
+ this.fetchChangeSet = fetchChangeSet;
+ }
+
+ @Override
+ public boolean isFetchChangeSet() {
+ return fetchChangeSet;
+ }
+
+ public void addSortCtime(PageOrdering sortCtime) {
+ addSortField("ctime");
+ this.sortCtime = sortCtime;
+ }
+
+ @Override
+ public PageOrdering getSortCtime() {
+ return sortCtime;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftChangeSetCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftChangeSetCriteria.java
deleted file mode 100644
index 7c09542..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftChangeSetCriteria.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package org.rhq.core.domain.criteria;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.rhq.core.domain.drift.DriftChangeSetCategory;
-import org.rhq.core.domain.drift.RhqDriftChangeSet;
-import org.rhq.core.domain.util.PageOrdering;
-
-/**
- * @author Jay Shaughnessy
- */
-@XmlRootElement
-(a)XmlAccessorType(XmlAccessType.FIELD)
-@SuppressWarnings("unused")
-public class RhqDriftChangeSetCriteria extends Criteria implements DriftChangeSetCriteria {
- private static final long serialVersionUID = 1L;
-
- private Integer filterId;
- private Integer filterInitial; // needs override
- private Integer filterResourceId; // needs override
- private String filterVersion;
- private DriftChangeSetCategory filterCategory;
- private boolean fetchDrifts;
-
- private PageOrdering sortVersion;
-
- public RhqDriftChangeSetCriteria() {
- filterOverrides.put("initial", "version = 0");
- filterOverrides.put("resourceId", "resource.id = ?");
- }
-
- @Override
- public Class<RhqDriftChangeSet> getPersistentClass() {
- return RhqDriftChangeSet.class;
- }
-
- public void addFilterId(String filterId) {
- if (filterId != null) {
- this.filterId = Integer.parseInt(filterId);
- }
- }
-
- @Override
- public String getFilterId() {
- return filterId == null ? null : filterId.toString();
- }
-
- public void addFilterVersion(String filterVersion) {
- this.filterVersion = filterVersion;
- }
-
- @Override
- public String getFilterVersion() {
- return filterVersion;
- }
-
- public void addFilterResourceId(Integer filterResourceId) {
- this.filterResourceId = filterResourceId;
- }
-
- @Override
- public Integer getFilterResourceId() {
- return filterResourceId;
- }
-
- public void addFilterCategory(DriftChangeSetCategory filterCategory) {
- this.filterCategory = filterCategory;
- }
-
- @Override
- public DriftChangeSetCategory getFilterCategory() {
- return filterCategory;
- }
-
- public void fetchDrifts(boolean fetchDrifts) {
- this.fetchDrifts = fetchDrifts;
- }
-
- @Override
- public boolean isFetchDrifts() {
- return fetchDrifts;
- }
-
- public void addSortVersion(PageOrdering sortVersion) {
- addSortField("version");
- this.sortVersion = sortVersion;
- }
-
- @Override
- public PageOrdering getSortVersion() {
- return sortVersion;
- }
-}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
deleted file mode 100644
index ca37104..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package org.rhq.core.domain.criteria;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.rhq.core.domain.drift.DriftCategory;
-import org.rhq.core.domain.drift.RhqDrift;
-import org.rhq.core.domain.util.CriteriaUtils;
-import org.rhq.core.domain.util.PageOrdering;
-
-/**
- * @author Jay Shaughnessy
- */
-@XmlRootElement
-(a)XmlAccessorType(XmlAccessType.FIELD)
-@SuppressWarnings("unused")
-public class RhqDriftCriteria extends Criteria implements DriftCriteria {
- private static final long serialVersionUID = 1L;
-
- private Integer filterId;
- private List<DriftCategory> filterCategories = new ArrayList<DriftCategory>();
- private Integer filterChangeSetId; // needs override
- private String filterPath;
- private List<Integer> filterResourceIds = new ArrayList<Integer>();
- private Long filterStartTime; // requires overrides
- private Long filterEndTime; // requires overrides
-
- private boolean fetchChangeSet;
-
- private PageOrdering sortCtime;
-
- public RhqDriftCriteria() {
- filterOverrides.put("changeSetId", "changeSet.id = ?");
- filterOverrides.put("categories", "category IN ( ? )");
- filterOverrides.put("resourceIds", "changeSet.resource.id IN ( ? )");
- filterOverrides.put("startTime", "ctime >= ?");
- filterOverrides.put("endTime", "ctime <= ?");
- }
-
- @Override
- public Class<RhqDrift> getPersistentClass() {
- return RhqDrift.class;
- }
-
- public void addFilterId(String filterId) {
- if (filterId != null) {
- this.filterId = Integer.parseInt(filterId);
- }
- }
-
- @Override
- public String getFilterId() {
- return filterId == null ? null : filterId.toString();
- }
-
- public void addFilterCategories(DriftCategory... filterCategories) {
- this.filterCategories = CriteriaUtils.getListIgnoringNulls(filterCategories);
- }
-
- @Override
- public List<DriftCategory> getFilterCategories() {
- return filterCategories;
- }
-
- public void addFilterChangeSetId(String filterChangeSetId) {
- if (filterChangeSetId != null) {
- this.filterChangeSetId = Integer.parseInt(filterChangeSetId);
- }
- }
-
- @Override
- public String getFilterChangeSetId() {
- return filterChangeSetId == null ? null : filterChangeSetId.toString();
- }
-
- public void addFilterPath(String filterPath) {
- this.filterPath = filterPath;
- }
-
- @Override
- public String getFilterPath() {
- return filterPath;
- }
-
- public void addFilterResourceIds(Integer... filterResourceIds) {
- this.filterResourceIds = CriteriaUtils.getListIgnoringNulls(filterResourceIds);
- }
-
- @Override
- public List<Integer> getFilterResourceIds() {
- return filterResourceIds;
- }
-
- public void addFilterStartTime(Long filterStartTime) {
- this.filterStartTime = filterStartTime;
- }
-
- @Override
- public Long getFilterStartTime() {
- return filterStartTime;
- }
-
- public void addFilterEndTime(Long filterEndTime) {
- this.filterEndTime = filterEndTime;
- }
-
- @Override
- public Long getFilterEndTime() {
- return filterEndTime;
- }
-
- public void fetchChangeSet(boolean fetchChangeSet) {
- this.fetchChangeSet = fetchChangeSet;
- }
-
- @Override
- public boolean isFetchChangeSet() {
- return fetchChangeSet;
- }
-
- public void addSortCtime(PageOrdering sortCtime) {
- addSortField("ctime");
- this.sortCtime = sortCtime;
- }
-
- @Override
- public PageOrdering getSortCtime() {
- return sortCtime;
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/drift/AbstractRecentDriftsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/drift/AbstractRecentDriftsPortlet.java
index 59f9eb3..75967aa 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/drift/AbstractRecentDriftsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/drift/AbstractRecentDriftsPortlet.java
@@ -23,8 +23,7 @@ import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.criteria.DriftCriteria;
-import org.rhq.core.domain.criteria.RhqDriftCriteria;
+import org.rhq.core.domain.criteria.DriftJPACriteria;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
@@ -356,8 +355,8 @@ public abstract class AbstractRecentDriftsPortlet extends DriftHistoryView imple
}
@Override
- protected RhqDriftCriteria getFetchCriteria(DSRequest request) {
- RhqDriftCriteria criteria = new RhqDriftCriteria();
+ protected DriftJPACriteria getFetchCriteria(DSRequest request) {
+ DriftJPACriteria criteria = new DriftJPACriteria();
// result count
String currentSetting = this.configuration.getSimpleValue(Constant.RESULT_COUNT,
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
index 5c80eca..a9faf69 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
@@ -38,7 +38,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.DriftCriteria;
-import org.rhq.core.domain.criteria.RhqDriftCriteria;
+import org.rhq.core.domain.criteria.DriftJPACriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftCategory;
@@ -61,7 +61,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Jay Shaughnessy
* @author John Mazzitelli
*/
-public class DriftDataSource extends RPCDataSource<Drift, RhqDriftCriteria> {
+public class DriftDataSource extends RPCDataSource<Drift, DriftCriteria> {
public static final String CATEGORY_ICON_ADD = ImageManager.getDriftCategoryIcon(DriftCategory.FILE_ADDED);
public static final String CATEGORY_ICON_CHANGE = ImageManager.getDriftCategoryIcon(DriftCategory.FILE_CHANGED);
@@ -162,7 +162,7 @@ public class DriftDataSource extends RPCDataSource<Drift, RhqDriftCriteria> {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response, final RhqDriftCriteria criteria) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final DriftCriteria criteria) {
if (criteria == null) {
// the user selected no categories in the filter - it makes sense from the UI perspective to show 0 rows
response.setTotalRows(0);
@@ -248,14 +248,14 @@ public class DriftDataSource extends RPCDataSource<Drift, RhqDriftCriteria> {
}
@Override
- protected RhqDriftCriteria getFetchCriteria(DSRequest request) {
+ protected DriftCriteria getFetchCriteria(DSRequest request) {
DriftCategory[] categoriesFilter = getArrayFilter(request, FILTER_CATEGORIES, DriftCategory.class);
if (categoriesFilter == null || categoriesFilter.length == 0) {
return null; // user didn't select any priorities - return null to indicate no data should be displayed
}
- RhqDriftCriteria criteria = new RhqDriftCriteria();
+ DriftJPACriteria criteria = new DriftJPACriteria();
criteria.fetchChangeSet(true);
criteria.addFilterCategories(categoriesFilter);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
index f5ffc9c..9a5c52b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
@@ -28,7 +28,7 @@ import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import org.rhq.core.domain.criteria.DriftCriteria;
-import org.rhq.core.domain.criteria.RhqDriftCriteria;
+import org.rhq.core.domain.criteria.DriftJPACriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
@@ -58,7 +58,7 @@ public class DriftDetailsView extends LocatableVLayout implements BookmarkableVi
}
private void show(String driftId) {
- DriftCriteria criteria = new RhqDriftCriteria();
+ DriftCriteria criteria = new DriftJPACriteria();
criteria.addFilterId(driftId);
criteria.fetchChangeSet(true);
GWTServiceLookup.getDriftService().findDriftsByCriteria(criteria, new AsyncCallback<PageList<Drift>>() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index d916075..014466b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@ -49,6 +49,7 @@ import com.smartgwt.client.widgets.form.validator.LengthRangeValidator;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertPriority;
+import org.rhq.core.domain.criteria.BaseCriteria;
import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.operation.OperationRequestStatus;
@@ -72,7 +73,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Greg Hinkle
* @author Ian Springer
*/
-public abstract class RPCDataSource<T, C extends org.rhq.core.domain.criteria.Criteria> extends DataSource {
+public abstract class RPCDataSource<T, C extends BaseCriteria> extends DataSource {
protected static final Messages MSG = CoreGUI.getMessages();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index f10c3fb..a1a7e6e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@ -58,8 +58,8 @@ import org.rhq.core.clientapi.agent.drift.DriftAgentService;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.criteria.RhqDriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.RhqDriftCriteria;
+import org.rhq.core.domain.criteria.DriftJPACriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftConfiguration;
@@ -143,7 +143,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
try {
- RhqDriftChangeSetCriteria c = new RhqDriftChangeSetCriteria();
+ DriftChangeSetJPACriteria c = new DriftChangeSetJPACriteria();
c.addFilterResourceId(resourceId);
List<RhqDriftChangeSet> changeSets = findDriftChangeSetsByCriteria(subjectManager.getOverlord(), c);
final int version = changeSets.size();
@@ -355,7 +355,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
@Override
public int deleteDriftsByContext(Subject subject, EntityContext entityContext) throws RuntimeException {
int result = 0;
- RhqDriftCriteria criteria = new RhqDriftCriteria();
+ DriftJPACriteria criteria = new DriftJPACriteria();
switch (entityContext.getType()) {
case Resource:
@@ -457,7 +457,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
@Override
- public PageList<RhqDriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, RhqDriftChangeSetCriteria criteria) {
+ public PageList<RhqDriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetJPACriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
CriteriaQueryRunner<RhqDriftChangeSet> queryRunner = new CriteriaQueryRunner<RhqDriftChangeSet>(criteria, generator,
@@ -467,7 +467,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
@Override
- public PageList<RhqDrift> findDriftsByCriteria(Subject subject, RhqDriftCriteria criteria) {
+ public PageList<RhqDrift> findDriftsByCriteria(Subject subject, DriftJPACriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
CriteriaQueryRunner<RhqDrift> queryRunner = new CriteriaQueryRunner<RhqDrift>(criteria, generator, entityManager);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
index c052b46..de1453f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
@@ -26,8 +26,8 @@ import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
-import org.rhq.core.domain.criteria.RhqDriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.RhqDriftCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
+import org.rhq.core.domain.criteria.DriftJPACriteria;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.drift.DriftFile;
import org.rhq.core.domain.drift.RhqDrift;
@@ -116,7 +116,7 @@ public interface DriftManagerLocal extends DriftManagerRemote {
* @param criteria
* @return The DriftChangeSets matching the criteria
*/
- PageList<RhqDriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, RhqDriftChangeSetCriteria criteria);
+ PageList<RhqDriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetJPACriteria criteria);
/**
* Standard criteria based fetch method
@@ -124,7 +124,7 @@ public interface DriftManagerLocal extends DriftManagerRemote {
* @param criteria
* @return The Drifts matching the criteria
*/
- PageList<RhqDrift> findDriftsByCriteria(Subject subject, RhqDriftCriteria criteria);
+ PageList<RhqDrift> findDriftsByCriteria(Subject subject, DriftJPACriteria criteria);
/**
* Get the specified drift configuration for the specified context.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
index ce3c4b0..0252284 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
@@ -40,7 +40,7 @@ import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.criteria.RhqDriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.core.domain.drift.DriftConfiguration;
@@ -118,7 +118,7 @@ public class DriftManagerBeanTest extends AbstractEJB3Test {
assertTrue(changeset1.exists());
driftManager.storeChangeSet(newResource.getId(), changeset1);
- RhqDriftChangeSetCriteria c = new RhqDriftChangeSetCriteria();
+ DriftChangeSetJPACriteria c = new DriftChangeSetJPACriteria();
c.addFilterResourceId(newResource.getId());
c.fetchDrifts(true);
List<RhqDriftChangeSet> changeSets = driftManager.findDriftChangeSetsByCriteria(overlord, c);
diff --git a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
index 67658f5..b727deb 100644
--- a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
@@ -27,8 +27,8 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
import org.rhq.core.domain.criteria.DriftCriteria;
-import org.rhq.core.domain.criteria.RhqDriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.RhqDriftCriteria;
+import org.rhq.core.domain.criteria.DriftJPACriteria;
+import org.rhq.core.domain.criteria.DriftChangeSetJPACriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.core.domain.drift.DriftChangeSet;
@@ -71,7 +71,7 @@ public class DriftServerPluginComponent implements DriftServerPluginFacet {
@Override
public PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria) {
- RhqDriftChangeSetCriteria rhqCriteria = new RhqDriftChangeSetCriteria();
+ DriftChangeSetJPACriteria rhqCriteria = new DriftChangeSetJPACriteria();
rhqCriteria.addFilterId(criteria.getFilterId());
rhqCriteria.addFilterResourceId(criteria.getFilterResourceId());
rhqCriteria.addFilterVersion(criteria.getFilterVersion());
@@ -85,7 +85,7 @@ public class DriftServerPluginComponent implements DriftServerPluginFacet {
@Override
public PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria) {
- RhqDriftCriteria rhqCriteria = new RhqDriftCriteria();
+ DriftJPACriteria rhqCriteria = new DriftJPACriteria();
rhqCriteria.addFilterId(criteria.getFilterId());
rhqCriteria.addFilterCategories(criteria.getFilterCategories().toArray(new DriftCategory[] {}));
rhqCriteria.addFilterChangeSetId(criteria.getFilterChangeSetId());
commit 00dd47d5962a0b5a4129e4600594893b8e8ae9bf
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 19 15:08:25 2011 -0400
Cannot use java.util.Collections in criteria classes
Collections is not Serializable which was causing client-side errors in
the GWT code.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
index b5cb14e..ca37104 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
@@ -19,16 +19,15 @@
package org.rhq.core.domain.criteria;
-import java.util.Collections;
+import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
-import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.RhqDrift;
import org.rhq.core.domain.drift.DriftCategory;
+import org.rhq.core.domain.drift.RhqDrift;
import org.rhq.core.domain.util.CriteriaUtils;
import org.rhq.core.domain.util.PageOrdering;
@@ -42,10 +41,10 @@ public class RhqDriftCriteria extends Criteria implements DriftCriteria {
private static final long serialVersionUID = 1L;
private Integer filterId;
- private List<DriftCategory> filterCategories = Collections.emptyList();
+ private List<DriftCategory> filterCategories = new ArrayList<DriftCategory>();
private Integer filterChangeSetId; // needs override
private String filterPath;
- private List<Integer> filterResourceIds = Collections.emptyList(); // requires overrides
+ private List<Integer> filterResourceIds = new ArrayList<Integer>();
private Long filterStartTime; // requires overrides
private Long filterEndTime; // requires overrides
commit 18c8e52eecc6bb71e2f6472de108215ba47eb96a
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 19 14:03:46 2011 -0400
Removing hibernate custom type and making criteria interfaces Serializable
IntegerString is not used so it can safely be removed.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
index 023115d..6ba63df 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
@@ -1,9 +1,11 @@
package org.rhq.core.domain.criteria;
+import java.io.Serializable;
+
import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.util.PageOrdering;
-public interface DriftChangeSetCriteria {
+public interface DriftChangeSetCriteria extends Serializable {
void addFilterId(String filterId);
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java
index d693cb3..dc9764c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java
@@ -1,11 +1,12 @@
package org.rhq.core.domain.criteria;
+import java.io.Serializable;
import java.util.List;
import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.core.domain.util.PageOrdering;
-public interface DriftCriteria {
+public interface DriftCriteria extends Serializable {
void addFilterId(String filterId);
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
index 5d027dc..b5cb14e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
@@ -62,7 +62,7 @@ public class RhqDriftCriteria extends Criteria implements DriftCriteria {
}
@Override
- public Class<? extends Drift> getPersistentClass() {
+ public Class<RhqDrift> getPersistentClass() {
return RhqDrift.class;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/hibernate/types/IntegerString.java b/modules/core/domain/src/main/java/org/rhq/core/domain/hibernate/types/IntegerString.java
deleted file mode 100644
index 6fa6658..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/hibernate/types/IntegerString.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.rhq.core.domain.hibernate.types;
-
-import java.io.Serializable;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import org.hibernate.Hibernate;
-import org.hibernate.HibernateException;
-import org.hibernate.usertype.UserType;
-
-public class IntegerString implements UserType {
-
- @Override
- public int[] sqlTypes() {
- return new int[] {Hibernate.INTEGER.sqlType()};
- }
-
- @Override
- public Class returnedClass() {
- return String.class;
- }
-
- @Override
- public boolean equals(Object x, Object y) throws HibernateException {
- if (x == y) {
- return true;
- }
- if (x == null || y == null) {
- return false;
- }
- return x.equals(y);
- }
-
- @Override
- public int hashCode(Object o) throws HibernateException {
- return o.hashCode();
- }
-
- @Override
- public Object nullSafeGet(ResultSet resultSet, String[] names, Object o) throws HibernateException, SQLException {
- int value = resultSet.getInt(names[0]);
-
- if (resultSet.wasNull()) {
- return null;
- }
- return Integer.toString(value);
- }
-
- @Override
- public void nullSafeSet(PreparedStatement stmt, Object value, int index) throws HibernateException,
- SQLException {
- if (value == null) {
- stmt.setNull(index, Hibernate.INTEGER.sqlType());
- } else {
- stmt.setInt(index, Integer.parseInt((String) value));
- }
- }
-
- @Override
- public Object deepCopy(Object value) throws HibernateException {
- return value;
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
-
- @Override
- public Serializable disassemble(Object value) throws HibernateException {
- return (Serializable) value;
- }
-
- @Override
- public Object assemble(Serializable cached, Object owner) throws HibernateException {
- return cached;
- }
-
- @Override
- public Object replace(Object original, Object target, Object owner) throws HibernateException {
- return original;
- }
-}
commit dc69b44ceb8d0eebc3d4aae3f9bab663bc7dc8a9
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 19 13:35:24 2011 -0400
Refactoring drift domain and criteria classes to make them pluggable
diff --git a/modules/core/client-api/src/main/resources/rhq-drift.xsd b/modules/core/client-api/src/main/resources/rhq-drift.xsd
index 2330c64..afc8142 100644
--- a/modules/core/client-api/src/main/resources/rhq-drift.xsd
+++ b/modules/core/client-api/src/main/resources/rhq-drift.xsd
@@ -37,7 +37,7 @@
</xs:appinfo>
</xs:annotation>
- <xs:complexType name="Drift">
+ <xs:complexType name="RhqDrift">
<xs:annotation>
<xs:appinfo>
<jaxb:class name="DriftDescriptor" />
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
index 355a354..023115d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftChangeSetCriteria.java
@@ -1,84 +1,32 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
package org.rhq.core.domain.criteria;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.util.PageOrdering;
-/**
- * @author Jay Shaughnessy
- */
-@XmlRootElement
-(a)XmlAccessorType(XmlAccessType.FIELD)
-@SuppressWarnings("unused")
-public class DriftChangeSetCriteria extends Criteria {
- private static final long serialVersionUID = 1L;
+public interface DriftChangeSetCriteria {
+
+ void addFilterId(String filterId);
- private String filterId;
- private Integer filterInitial; // needs override
- private Integer filterResourceId; // needs override
- private String filterVersion;
- private DriftChangeSetCategory filterCategory;
+ String getFilterId();
- private boolean fetchDrifts;
+ void addFilterVersion(String filterVersion);
- private PageOrdering sortVersion;
+ String getFilterVersion();
- public DriftChangeSetCriteria() {
- filterOverrides.put("initial", "version = 0");
- filterOverrides.put("resourceId", "resource.id = ?");
- }
+ void addFilterResourceId(Integer filterResourceId);
- @Override
- public Class<DriftChangeSet> getPersistentClass() {
- return DriftChangeSet.class;
- }
+ Integer getFilterResourceId();
- public void addFilterId(String filterId) {
- this.filterId = filterId;
- }
+ void addFilterCategory(DriftChangeSetCategory filterCategory);
- public void addFilterVersion(String filterVersion) {
- this.filterVersion = filterVersion;
- }
+ DriftChangeSetCategory getFilterCategory();
- public void addFilterResourceId(Integer filterResourceId) {
- this.filterResourceId = filterResourceId;
- }
+ void fetchDrifts(boolean fetchDrifts);
- public void addFilterCategory(DriftChangeSetCategory filterCategory) {
- this.filterCategory = filterCategory;
- }
+ boolean isFetchDrifts();
- public void fetchDrifts(boolean fetchDrifts) {
- this.fetchDrifts = fetchDrifts;
- }
+ void addSortVersion(PageOrdering sortVersion);
- public void addSortVersion(PageOrdering sortVersion) {
- addSortField("version");
- this.sortVersion = sortVersion;
- }
+ PageOrdering getSortVersion();
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java
index 1988410..d693cb3 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/DriftCriteria.java
@@ -1,104 +1,48 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
package org.rhq.core.domain.criteria;
import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
-import org.rhq.core.domain.util.CriteriaUtils;
import org.rhq.core.domain.util.PageOrdering;
-/**
- * @author Jay Shaughnessy
- */
-@XmlRootElement
-(a)XmlAccessorType(XmlAccessType.FIELD)
-@SuppressWarnings("unused")
-public class DriftCriteria extends Criteria {
- private static final long serialVersionUID = 1L;
-
- private String filterId;
- private List<DriftCategory> filterCategories;
- private String filterChangeSetId; // needs override
- private String filterPath;
- private List<Integer> filterResourceIds; // requires overrides
- private Long filterStartTime; // requires overrides
- private Long filterEndTime; // requires overrides
-
- private boolean fetchChangeSet;
-
- private PageOrdering sortCtime;
-
- public DriftCriteria() {
- filterOverrides.put("changeSetId", "changeSet.id = ?");
- filterOverrides.put("categories", "category IN ( ? )");
- filterOverrides.put("resourceIds", "changeSet.resource.id IN ( ? )");
- filterOverrides.put("startTime", "ctime >= ?");
- filterOverrides.put("endTime", "ctime <= ?");
- }
-
- @Override
- public Class<Drift> getPersistentClass() {
- return Drift.class;
- }
-
- public void addFilterId(String filterId) {
- this.filterId = filterId;
- }
-
- public void addFilterCategories(DriftCategory... filterCategories) {
- this.filterCategories = CriteriaUtils.getListIgnoringNulls(filterCategories);
- }
-
- public void addFilterChangeSetId(String filterChangeSetId) {
- this.filterChangeSetId = filterChangeSetId;
- }
-
- public void addFilterPath(String filterPath) {
- this.filterPath = filterPath;
- }
-
- public void addFilterResourceIds(Integer... filterResourceIds) {
- this.filterResourceIds = CriteriaUtils.getListIgnoringNulls(filterResourceIds);
- }
-
- public void addFilterStartTime(Long filterStartTime) {
- this.filterStartTime = filterStartTime;
- }
-
- public void addFilterEndTime(Long filterEndTime) {
- this.filterEndTime = filterEndTime;
- }
-
- public void fetchChangeSet(boolean fetchChangeSet) {
- this.fetchChangeSet = fetchChangeSet;
- }
-
- public void addSortCtime(PageOrdering sortCtime) {
- addSortField("ctime");
- this.sortCtime = sortCtime;
- }
+public interface DriftCriteria {
+
+ void addFilterId(String filterId);
+
+ String getFilterId();
+
+ void addFilterCategories(DriftCategory... filterCategories);
+
+ List<DriftCategory> getFilterCategories();
+
+ void addFilterChangeSetId(String filterChangeSetId);
+
+ String getFilterChangeSetId();
+
+ void addFilterPath(String filterPath);
+
+ String getFilterPath();
+
+ void addFilterResourceIds(Integer... filterResourceIds);
+
+ List<Integer> getFilterResourceIds();
+
+ void addFilterStartTime(Long filterStartTime);
+
+ Long getFilterStartTime();
+
+ void addFilterEndTime(Long filterEndTime);
+
+ Long getFilterEndTime();
+
+ void fetchChangeSet(boolean fetchChangeSet);
+
+ boolean isFetchChangeSet();
+
+ void addSortCtime(PageOrdering sortCtime);
+
+ PageOrdering getSortCtime();
+
+
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftChangeSetCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftChangeSetCriteria.java
new file mode 100644
index 0000000..7c09542
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftChangeSetCriteria.java
@@ -0,0 +1,114 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.core.domain.criteria;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
+import org.rhq.core.domain.drift.RhqDriftChangeSet;
+import org.rhq.core.domain.util.PageOrdering;
+
+/**
+ * @author Jay Shaughnessy
+ */
+@XmlRootElement
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@SuppressWarnings("unused")
+public class RhqDriftChangeSetCriteria extends Criteria implements DriftChangeSetCriteria {
+ private static final long serialVersionUID = 1L;
+
+ private Integer filterId;
+ private Integer filterInitial; // needs override
+ private Integer filterResourceId; // needs override
+ private String filterVersion;
+ private DriftChangeSetCategory filterCategory;
+ private boolean fetchDrifts;
+
+ private PageOrdering sortVersion;
+
+ public RhqDriftChangeSetCriteria() {
+ filterOverrides.put("initial", "version = 0");
+ filterOverrides.put("resourceId", "resource.id = ?");
+ }
+
+ @Override
+ public Class<RhqDriftChangeSet> getPersistentClass() {
+ return RhqDriftChangeSet.class;
+ }
+
+ public void addFilterId(String filterId) {
+ if (filterId != null) {
+ this.filterId = Integer.parseInt(filterId);
+ }
+ }
+
+ @Override
+ public String getFilterId() {
+ return filterId == null ? null : filterId.toString();
+ }
+
+ public void addFilterVersion(String filterVersion) {
+ this.filterVersion = filterVersion;
+ }
+
+ @Override
+ public String getFilterVersion() {
+ return filterVersion;
+ }
+
+ public void addFilterResourceId(Integer filterResourceId) {
+ this.filterResourceId = filterResourceId;
+ }
+
+ @Override
+ public Integer getFilterResourceId() {
+ return filterResourceId;
+ }
+
+ public void addFilterCategory(DriftChangeSetCategory filterCategory) {
+ this.filterCategory = filterCategory;
+ }
+
+ @Override
+ public DriftChangeSetCategory getFilterCategory() {
+ return filterCategory;
+ }
+
+ public void fetchDrifts(boolean fetchDrifts) {
+ this.fetchDrifts = fetchDrifts;
+ }
+
+ @Override
+ public boolean isFetchDrifts() {
+ return fetchDrifts;
+ }
+
+ public void addSortVersion(PageOrdering sortVersion) {
+ addSortField("version");
+ this.sortVersion = sortVersion;
+ }
+
+ @Override
+ public PageOrdering getSortVersion() {
+ return sortVersion;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
new file mode 100644
index 0000000..5d027dc
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RhqDriftCriteria.java
@@ -0,0 +1,154 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.core.domain.criteria;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.RhqDrift;
+import org.rhq.core.domain.drift.DriftCategory;
+import org.rhq.core.domain.util.CriteriaUtils;
+import org.rhq.core.domain.util.PageOrdering;
+
+/**
+ * @author Jay Shaughnessy
+ */
+@XmlRootElement
+(a)XmlAccessorType(XmlAccessType.FIELD)
+@SuppressWarnings("unused")
+public class RhqDriftCriteria extends Criteria implements DriftCriteria {
+ private static final long serialVersionUID = 1L;
+
+ private Integer filterId;
+ private List<DriftCategory> filterCategories = Collections.emptyList();
+ private Integer filterChangeSetId; // needs override
+ private String filterPath;
+ private List<Integer> filterResourceIds = Collections.emptyList(); // requires overrides
+ private Long filterStartTime; // requires overrides
+ private Long filterEndTime; // requires overrides
+
+ private boolean fetchChangeSet;
+
+ private PageOrdering sortCtime;
+
+ public RhqDriftCriteria() {
+ filterOverrides.put("changeSetId", "changeSet.id = ?");
+ filterOverrides.put("categories", "category IN ( ? )");
+ filterOverrides.put("resourceIds", "changeSet.resource.id IN ( ? )");
+ filterOverrides.put("startTime", "ctime >= ?");
+ filterOverrides.put("endTime", "ctime <= ?");
+ }
+
+ @Override
+ public Class<? extends Drift> getPersistentClass() {
+ return RhqDrift.class;
+ }
+
+ public void addFilterId(String filterId) {
+ if (filterId != null) {
+ this.filterId = Integer.parseInt(filterId);
+ }
+ }
+
+ @Override
+ public String getFilterId() {
+ return filterId == null ? null : filterId.toString();
+ }
+
+ public void addFilterCategories(DriftCategory... filterCategories) {
+ this.filterCategories = CriteriaUtils.getListIgnoringNulls(filterCategories);
+ }
+
+ @Override
+ public List<DriftCategory> getFilterCategories() {
+ return filterCategories;
+ }
+
+ public void addFilterChangeSetId(String filterChangeSetId) {
+ if (filterChangeSetId != null) {
+ this.filterChangeSetId = Integer.parseInt(filterChangeSetId);
+ }
+ }
+
+ @Override
+ public String getFilterChangeSetId() {
+ return filterChangeSetId == null ? null : filterChangeSetId.toString();
+ }
+
+ public void addFilterPath(String filterPath) {
+ this.filterPath = filterPath;
+ }
+
+ @Override
+ public String getFilterPath() {
+ return filterPath;
+ }
+
+ public void addFilterResourceIds(Integer... filterResourceIds) {
+ this.filterResourceIds = CriteriaUtils.getListIgnoringNulls(filterResourceIds);
+ }
+
+ @Override
+ public List<Integer> getFilterResourceIds() {
+ return filterResourceIds;
+ }
+
+ public void addFilterStartTime(Long filterStartTime) {
+ this.filterStartTime = filterStartTime;
+ }
+
+ @Override
+ public Long getFilterStartTime() {
+ return filterStartTime;
+ }
+
+ public void addFilterEndTime(Long filterEndTime) {
+ this.filterEndTime = filterEndTime;
+ }
+
+ @Override
+ public Long getFilterEndTime() {
+ return filterEndTime;
+ }
+
+ public void fetchChangeSet(boolean fetchChangeSet) {
+ this.fetchChangeSet = fetchChangeSet;
+ }
+
+ @Override
+ public boolean isFetchChangeSet() {
+ return fetchChangeSet;
+ }
+
+ public void addSortCtime(PageOrdering sortCtime) {
+ addSortField("ctime");
+ this.sortCtime = sortCtime;
+ }
+
+ @Override
+ public PageOrdering getSortCtime() {
+ return sortCtime;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/Drift.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/Drift.java
index a9e95e0..ef6a1ed 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/Drift.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/Drift.java
@@ -1,171 +1,29 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
package org.rhq.core.domain.drift;
-import java.io.Serializable;
+public interface Drift {
+ String getId();
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.PrePersist;
-import javax.persistence.SequenceGenerator;
-import javax.persistence.Table;
+ void setId(String id);
-import org.hibernate.annotations.Type;
+ Long getCtime();
-/**
- * An occurrence of drifty to be reported and managed by the user.
-
- * @author Jay Shaughnessy
- * @author John Sanda
- */
-@Entity
-@NamedQueries( { @NamedQuery(name = Drift.QUERY_DELETE_BY_RESOURCES, query = "" //
- + "DELETE FROM Drift d " //
- + " WHERE d.changeSet IN ( SELECT dcs FROM DriftChangeSet dcs WHERE dcs.resource.id IN ( :resourceIds ) ) )") })
-@Table(name = "RHQ_DRIFT")
-@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_DRIFT_ID_SEQ")
-public class Drift implements Serializable {
- private static final long serialVersionUID = 1L;
+ DriftChangeSet getChangeSet();
- public static final String QUERY_DELETE_BY_RESOURCES = "Drift.deleteByResources";
+ void setChangeSet(RhqDriftChangeSet changeSet);
- @Type(type = "org.rhq.core.domain.hibernate.types.IntegerString")
- @Column(name = "ID", nullable = false)
- @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
- @Id
- private String id;
+ DriftCategory getCategory();
- @Column(name = "CTIME", nullable = false)
- private Long ctime = -1L;
+ void setCategory(DriftCategory category);
- @Column(name = "CATEGORY", nullable = false)
- @Enumerated(EnumType.STRING)
- private DriftCategory category;
+ String getPath();
- @Column(name = "PATH", nullable = false)
- @Enumerated(EnumType.STRING)
- private String path;
+ void setPath(String path);
- @JoinColumn(name = "DRIFT_CHANGE_SET_ID", referencedColumnName = "ID", nullable = false)
- @ManyToOne(fetch = FetchType.LAZY, optional = false)
- private DriftChangeSet changeSet;
+ DriftFile getOldDriftFile();
- @JoinColumn(name = "OLD_DRIFT_FILE", referencedColumnName = "HASH_ID", nullable = true)
- @ManyToOne(fetch = FetchType.EAGER, optional = true)
- private DriftFile oldDriftFile;
+ void setOldDriftFile(DriftFile oldDriftFile);
- @JoinColumn(name = "NEW_DRIFT_FILE", referencedColumnName = "HASH_ID", nullable = true)
- @ManyToOne(fetch = FetchType.EAGER, optional = true)
- private DriftFile newDriftFile;
-
- protected Drift() {
- }
-
- /**
- * @param resource
- * @param category
- * @param oldDriftFile required for FILE_CHANGED and FILE_REMOVED, null for FILE_ADDED
- * @param newDriftFile required for FILE_CHANGED and FILE_ADDED, null for FILE_REMOVED
- */
- public Drift(DriftChangeSet changeSet, String path, DriftCategory category, DriftFile oldDriftFile,
- DriftFile newDriftFile) {
- this.changeSet = changeSet;
- this.path = path;
- this.category = category;
- this.oldDriftFile = oldDriftFile;
- this.newDriftFile = newDriftFile;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public Long getCtime() {
- return ctime;
- }
-
- @PrePersist
- void onPersist() {
- this.ctime = System.currentTimeMillis();
- }
-
- public DriftChangeSet getChangeSet() {
- return changeSet;
- }
-
- public void setChangeSet(DriftChangeSet changeSet) {
- this.changeSet = changeSet;
- }
-
- public DriftCategory getCategory() {
- return category;
- }
-
- public void setCategory(DriftCategory category) {
- this.category = category;
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public DriftFile getOldDriftFile() {
- return oldDriftFile;
- }
-
- public void setOldDriftFile(DriftFile oldDriftFile) {
- this.oldDriftFile = oldDriftFile;
- }
-
- public DriftFile getNewDriftFile() {
- return newDriftFile;
- }
-
- public void setNewDriftFile(DriftFile newDriftFile) {
- this.newDriftFile = newDriftFile;
- }
-
- @Override
- public String toString() {
- return "Drift [ id=" + id + ", category=" + category + ", path=" + path + ", changeSet=" + changeSet + "]";
- }
+ DriftFile getNewDriftFile();
+ void setNewDriftFile(DriftFile newDriftFile);
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSet.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSet.java
index 97a76ee..a07a95a 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSet.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSet.java
@@ -1,152 +1,29 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
package org.rhq.core.domain.drift;
-import java.io.Serializable;
-import java.util.LinkedHashSet;
import java.util.Set;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToMany;
-import javax.persistence.PrePersist;
-import javax.persistence.SequenceGenerator;
-import javax.persistence.Table;
-
-import org.hibernate.annotations.Type;
-
import org.rhq.core.domain.resource.Resource;
-/**
- * @author Jay Shaughnessy
- * @author John Sanda
- */
-@Entity
-@NamedQueries( { @NamedQuery(name = DriftChangeSet.QUERY_DELETE_BY_RESOURCES, query = "" //
- + "DELETE FROM DriftChangeSet dcs " //
- + " WHERE dcs.resource.id IN ( :resourceIds )") })
-@Table(name = "RHQ_DRIFT_CHANGE_SET")
-@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_DRIFT_CHANGE_SET_ID_SEQ")
-public class DriftChangeSet implements Serializable {
- private static final long serialVersionUID = 1L;
-
- public static final String QUERY_DELETE_BY_RESOURCES = "DriftChangeSet.deleteByResources";
-
- @Type(type = "org.rhq.core.domain.hibernate.types.IntegerString")
- @Column(name = "ID", nullable = false)
- @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
- @Id
- private String id;
-
- @Column(name = "CTIME", nullable = false)
- private Long ctime = -1L;
-
- // 0..N
- @Column(name = "VERSION", nullable = false)
- private int version;
-
- @Column(name = "CATEGORY", nullable = false)
- @Enumerated(EnumType.STRING)
- private DriftChangeSetCategory category;
-
- @JoinColumn(name = "RESOURCE_ID", referencedColumnName = "ID", nullable = false)
- @ManyToOne(optional = false)
- private Resource resource;
-
- @OneToMany(mappedBy = "changeSet", cascade = { CascadeType.ALL })
- private Set<Drift> drifts = new LinkedHashSet<Drift>();
-
- protected DriftChangeSet() {
- }
-
- public DriftChangeSet(Resource resource, int version, DriftChangeSetCategory category) {
- this.resource = resource;
- this.version = version;
- this.category = category;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public Long getCtime() {
- return ctime;
- }
-
- @PrePersist
- void onPersist() {
- this.ctime = System.currentTimeMillis();
- }
+public interface DriftChangeSet<D extends Drift> {
+ String getId();
- public int getVersion() {
- return version;
- }
+ void setId(String id);
- public void setVersion(int version) {
- this.version = version;
- }
+ Long getCtime();
- public DriftChangeSetCategory getCategory() {
- return category;
- }
+ int getVersion();
- public void setCategory(DriftChangeSetCategory category) {
- this.category = category;
- }
+ void setVersion(int version);
- public Resource getResource() {
- return resource;
- }
+ DriftChangeSetCategory getCategory();
- public void setResource(Resource resource) {
- this.resource = resource;
- }
+ void setCategory(DriftChangeSetCategory category);
- public Set<Drift> getDrifts() {
- return drifts;
- }
+ Resource getResource();
- public void setDrifts(Set<Drift> drifts) {
- this.drifts = drifts;
- }
+ void setResource(Resource resource);
- @Override
- public String toString() {
- return "DriftChangeSet [id=" + id + ", resource=" + resource + ", version=" + version + "]";
- }
+ Set<D> getDrifts();
+ void setDrifts(Set<D> drifts);
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/RhqDrift.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/RhqDrift.java
new file mode 100644
index 0000000..d82520e
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/RhqDrift.java
@@ -0,0 +1,183 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.drift;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.PrePersist;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.Type;
+
+/**
+ * An occurrence of drifty to be reported and managed by the user.
+
+ * @author Jay Shaughnessy
+ * @author John Sanda
+ */
+@Entity
+@NamedQueries( { @NamedQuery(name = RhqDrift.QUERY_DELETE_BY_RESOURCES, query = "" //
+ + "DELETE FROM RhqDrift d " //
+ + " WHERE d.changeSet IN ( SELECT dcs FROM RhqDriftChangeSet dcs WHERE dcs.resource.id IN ( :resourceIds ) ) )") })
+@Table(name = "RHQ_DRIFT")
+@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_DRIFT_ID_SEQ")
+public class RhqDrift implements Serializable, Drift {
+ private static final long serialVersionUID = 1L;
+
+ public static final String QUERY_DELETE_BY_RESOURCES = "RhqDrift.deleteByResources";
+
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
+ @Id
+ private int id;
+
+ @Column(name = "CTIME", nullable = false)
+ private Long ctime = -1L;
+
+ @Column(name = "CATEGORY", nullable = false)
+ @Enumerated(EnumType.STRING)
+ private DriftCategory category;
+
+ @Column(name = "PATH", nullable = false)
+ @Enumerated(EnumType.STRING)
+ private String path;
+
+ @JoinColumn(name = "DRIFT_CHANGE_SET_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne(fetch = FetchType.LAZY, optional = false)
+ private RhqDriftChangeSet changeSet;
+
+ @JoinColumn(name = "OLD_DRIFT_FILE", referencedColumnName = "HASH_ID", nullable = true)
+ @ManyToOne(fetch = FetchType.EAGER, optional = true)
+ private DriftFile oldDriftFile;
+
+ @JoinColumn(name = "NEW_DRIFT_FILE", referencedColumnName = "HASH_ID", nullable = true)
+ @ManyToOne(fetch = FetchType.EAGER, optional = true)
+ private DriftFile newDriftFile;
+
+ protected RhqDrift() {
+ }
+
+ /**
+ * @param resource
+ * @param category
+ * @param oldDriftFile required for FILE_CHANGED and FILE_REMOVED, null for FILE_ADDED
+ * @param newDriftFile required for FILE_CHANGED and FILE_ADDED, null for FILE_REMOVED
+ */
+ public RhqDrift(RhqDriftChangeSet changeSet, String path, DriftCategory category, DriftFile oldDriftFile,
+ DriftFile newDriftFile) {
+ this.changeSet = changeSet;
+ this.path = path;
+ this.category = category;
+ this.oldDriftFile = oldDriftFile;
+ this.newDriftFile = newDriftFile;
+ }
+
+ @Override
+ public String getId() {
+ return Integer.toString(id);
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = Integer.parseInt(id);
+ }
+
+ @Override
+ public Long getCtime() {
+ return ctime;
+ }
+
+ @PrePersist
+ void onPersist() {
+ this.ctime = System.currentTimeMillis();
+ }
+
+ @Override
+ public DriftChangeSet getChangeSet() {
+ return changeSet;
+ }
+
+ @Override
+ public void setChangeSet(RhqDriftChangeSet changeSet) {
+ this.changeSet = changeSet;
+ }
+
+ @Override
+ public DriftCategory getCategory() {
+ return category;
+ }
+
+ @Override
+ public void setCategory(DriftCategory category) {
+ this.category = category;
+ }
+
+ @Override
+ public String getPath() {
+ return path;
+ }
+
+ @Override
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ @Override
+ public DriftFile getOldDriftFile() {
+ return oldDriftFile;
+ }
+
+ @Override
+ public void setOldDriftFile(DriftFile oldDriftFile) {
+ this.oldDriftFile = oldDriftFile;
+ }
+
+ @Override
+ public DriftFile getNewDriftFile() {
+ return newDriftFile;
+ }
+
+ @Override
+ public void setNewDriftFile(DriftFile newDriftFile) {
+ this.newDriftFile = newDriftFile;
+ }
+
+ @Override
+ public String toString() {
+ return "RhqDrift [ id=" + id + ", category=" + category + ", path=" + path + ", changeSet=" + changeSet + "]";
+ }
+
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/RhqDriftChangeSet.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/RhqDriftChangeSet.java
new file mode 100644
index 0000000..28ebfbb
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/RhqDriftChangeSet.java
@@ -0,0 +1,162 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.drift;
+
+import java.io.Serializable;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.PrePersist;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.Type;
+
+import org.rhq.core.domain.resource.Resource;
+
+/**
+ * @author Jay Shaughnessy
+ * @author John Sanda
+ */
+@Entity
+@NamedQueries( { @NamedQuery(name = RhqDriftChangeSet.QUERY_DELETE_BY_RESOURCES, query = "" //
+ + "DELETE FROM RhqDriftChangeSet dcs " //
+ + " WHERE dcs.resource.id IN ( :resourceIds )") })
+@Table(name = "RHQ_DRIFT_CHANGE_SET")
+@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_DRIFT_CHANGE_SET_ID_SEQ")
+public class RhqDriftChangeSet implements Serializable, DriftChangeSet<RhqDrift> {
+ private static final long serialVersionUID = 1L;
+
+ public static final String QUERY_DELETE_BY_RESOURCES = "RhqDriftChangeSet.deleteByResources";
+
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
+ @Id
+ private int id;
+
+ @Column(name = "CTIME", nullable = false)
+ private Long ctime = -1L;
+
+ // 0..N
+ @Column(name = "VERSION", nullable = false)
+ private int version;
+
+ @Column(name = "CATEGORY", nullable = false)
+ @Enumerated(EnumType.STRING)
+ private DriftChangeSetCategory category;
+
+ @JoinColumn(name = "RESOURCE_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne(optional = false)
+ private Resource resource;
+
+ @OneToMany(mappedBy = "changeSet", cascade = { CascadeType.ALL })
+ private Set<RhqDrift> drifts = new LinkedHashSet<RhqDrift>();
+
+ protected RhqDriftChangeSet() {
+ }
+
+ public RhqDriftChangeSet(Resource resource, int version, DriftChangeSetCategory category) {
+ this.resource = resource;
+ this.version = version;
+ this.category = category;
+ }
+
+ @Override
+ public String getId() {
+ return Integer.toString(id);
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = Integer.parseInt(id);
+ }
+
+ @Override
+ public Long getCtime() {
+ return ctime;
+ }
+
+ @PrePersist
+ void onPersist() {
+ this.ctime = System.currentTimeMillis();
+ }
+
+ @Override
+ public int getVersion() {
+ return version;
+ }
+
+ @Override
+ public void setVersion(int version) {
+ this.version = version;
+ }
+
+ @Override
+ public DriftChangeSetCategory getCategory() {
+ return category;
+ }
+
+ @Override
+ public void setCategory(DriftChangeSetCategory category) {
+ this.category = category;
+ }
+
+ @Override
+ public Resource getResource() {
+ return resource;
+ }
+
+ @Override
+ public void setResource(Resource resource) {
+ this.resource = resource;
+ }
+
+ @Override
+ public Set<RhqDrift> getDrifts() {
+ return drifts;
+ }
+
+ @Override
+ public void setDrifts(Set<RhqDrift> drifts) {
+ this.drifts = drifts;
+ }
+
+ @Override
+ public String toString() {
+ return "RhqDriftChangeSet [id=" + id + ", resource=" + resource + ", version=" + version + "]";
+ }
+
+}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/DriftChangeSetTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/DriftChangeSetTest.java
deleted file mode 100644
index b06d8a4..0000000
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/DriftChangeSetTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package org.rhq.core.domain.drift;
-
-import javax.transaction.SystemException;
-
-import org.testng.annotations.BeforeGroups;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import org.rhq.core.domain.alert.Alert;
-import org.rhq.core.domain.alert.AlertCondition;
-import org.rhq.core.domain.alert.AlertConditionLog;
-import org.rhq.core.domain.alert.AlertDampeningEvent;
-import org.rhq.core.domain.alert.AlertDefinition;
-import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.alert.notification.AlertNotificationLog;
-import org.rhq.core.domain.bundle.BundleResourceDeployment;
-import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory;
-import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
-import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
-import org.rhq.core.domain.content.ContentServiceRequest;
-import org.rhq.core.domain.content.InstalledPackage;
-import org.rhq.core.domain.content.InstalledPackageHistory;
-import org.rhq.core.domain.content.PackageInstallationStep;
-import org.rhq.core.domain.content.ResourceRepo;
-import org.rhq.core.domain.event.Event;
-import org.rhq.core.domain.event.EventSource;
-import org.rhq.core.domain.measurement.Availability;
-import org.rhq.core.domain.measurement.MeasurementBaseline;
-import org.rhq.core.domain.measurement.MeasurementDataTrait;
-import org.rhq.core.domain.measurement.MeasurementOOB;
-import org.rhq.core.domain.measurement.MeasurementSchedule;
-import org.rhq.core.domain.measurement.calltime.CallTimeDataKey;
-import org.rhq.core.domain.measurement.calltime.CallTimeDataValue;
-import org.rhq.core.domain.operation.ResourceOperationHistory;
-import org.rhq.core.domain.operation.ResourceOperationScheduleEntity;
-import org.rhq.core.domain.resource.CreateResourceHistory;
-import org.rhq.core.domain.resource.DeleteResourceHistory;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceError;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.shared.ResourceBuilder;
-import org.rhq.core.domain.test.AbstractEJB3Test;
-
-import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
-
-public class DriftChangeSetTest extends AbstractEJB3Test {
-
- static interface TransactionCallback {
- void execute() throws Exception;
- }
-
- Resource resource;
-
- @BeforeGroups(groups = {"drift.changeset"})
- public void initResource() throws Exception {
- resource = new ResourceBuilder().createRandomServer().build();
- resource.setId(0);
-
- final ResourceType type = resource.getResourceType();
- type.setId(0);
-
- executeInTransaction(new TransactionCallback() {
- @Override
- public void execute() throws Exception {
- getEntityManager().createQuery("delete from DriftChangeSet").executeUpdate();
- getEntityManager().createQuery("delete from Resource").executeUpdate();
- getEntityManager().createQuery("delete from ResourceType").executeUpdate();
- }
- });
-
- executeInTransaction(new TransactionCallback() {
- @Override
- public void execute() throws Exception {
- getEntityManager().persist(type);
- getEntityManager().persist(resource);
- }
- });
- }
-
- @BeforeMethod(groups = {"drift.changeset"})
- public void setup() throws Exception {
- executeInTransaction(new TransactionCallback() {
- @Override
- public void execute() throws Exception {
- getEntityManager().createQuery("delete from DriftChangeSet").executeUpdate();
- }
- });
- }
-
- @Test(groups = {"integration.ejb3", "drift.changeset"}, enabled = false)
- public void insertAndLoad() throws Exception {
- final DriftChangeSet changeSet = new DriftChangeSet();
-
- executeInTransaction(new TransactionCallback() {
- @Override
- public void execute() throws Exception {
- changeSet.setCategory(COVERAGE);
- changeSet.setVersion(0);
- changeSet.setResource(resource);
-
- getEntityManager().persist(changeSet);
- }
- });
-
- executeInTransaction(new TransactionCallback() {
- @Override
- public void execute() throws Exception {
- // Verify that we can both load by id and by JPQL to ensure that using a
- // custom type for the id works.
-
- DriftChangeSet actual = getEntityManager().find(DriftChangeSet.class, changeSet.getId());
- assertNotNull("Failed to load change set by id", actual);
-
- actual = (DriftChangeSet) getEntityManager().createQuery("from DriftChangeSet where id = :id")
- .setParameter("id", actual.getId())
- .getSingleResult();
- assertNotNull("Failed to load change set with JPQL query", actual);
- }
- });
- }
-
- void executeInTransaction(TransactionCallback callback) {
- try {
- getTransactionManager().begin();
- callback.execute();
- getTransactionManager().commit();
- } catch (Throwable t) {
- try {
- getTransactionManager().rollback();
- } catch (SystemException e) {
- throw new RuntimeException("Failed to rollback transaction", e);
- }
- throw new RuntimeException(t.getCause());
- }
- }
-
-}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
new file mode 100644
index 0000000..26520a1
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/RhqDriftChangeSetTest.java
@@ -0,0 +1,107 @@
+package org.rhq.core.domain.drift;
+
+import javax.transaction.SystemException;
+
+import org.testng.annotations.BeforeGroups;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.shared.ResourceBuilder;
+import org.rhq.core.domain.test.AbstractEJB3Test;
+
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
+
+public class RhqDriftChangeSetTest extends AbstractEJB3Test {
+
+ static interface TransactionCallback {
+ void execute() throws Exception;
+ }
+
+ Resource resource;
+
+ @BeforeGroups(groups = {"drift.changeset"})
+ public void initResource() throws Exception {
+ resource = new ResourceBuilder().createRandomServer().build();
+ resource.setId(0);
+
+ final ResourceType type = resource.getResourceType();
+ type.setId(0);
+
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ getEntityManager().createQuery("delete from RhqDriftChangeSet").executeUpdate();
+ getEntityManager().createQuery("delete from Resource").executeUpdate();
+ getEntityManager().createQuery("delete from ResourceType").executeUpdate();
+ }
+ });
+
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ getEntityManager().persist(type);
+ getEntityManager().persist(resource);
+ }
+ });
+ }
+
+ @BeforeMethod(groups = {"drift.changeset"})
+ public void setup() throws Exception {
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ getEntityManager().createQuery("delete from RhqDriftChangeSet").executeUpdate();
+ }
+ });
+ }
+
+ @Test(groups = {"integration.ejb3", "drift.changeset"}, enabled = false)
+ public void insertAndLoad() throws Exception {
+ final RhqDriftChangeSet changeSet = new RhqDriftChangeSet();
+
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ changeSet.setCategory(COVERAGE);
+ changeSet.setVersion(0);
+ changeSet.setResource(resource);
+
+ getEntityManager().persist(changeSet);
+ }
+ });
+
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ // Verify that we can both load by id and by JPQL to ensure that using a
+ // custom type for the id works.
+
+ RhqDriftChangeSet actual = getEntityManager().find(RhqDriftChangeSet.class, changeSet.getId());
+ assertNotNull("Failed to load change set by id", actual);
+
+ actual = (RhqDriftChangeSet) getEntityManager().createQuery("from RhqDriftChangeSet where id = :id")
+ .setParameter("id", actual.getId())
+ .getSingleResult();
+ assertNotNull("Failed to load change set with JPQL query", actual);
+ }
+ });
+ }
+
+ void executeInTransaction(TransactionCallback callback) {
+ try {
+ getTransactionManager().begin();
+ callback.execute();
+ getTransactionManager().commit();
+ } catch (Throwable t) {
+ try {
+ getTransactionManager().rollback();
+ } catch (SystemException e) {
+ throw new RuntimeException("Failed to rollback transaction", e);
+ }
+ throw new RuntimeException(t.getCause());
+ }
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/drift/AbstractRecentDriftsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/drift/AbstractRecentDriftsPortlet.java
index 8e858de..59f9eb3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/drift/AbstractRecentDriftsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/drift/AbstractRecentDriftsPortlet.java
@@ -24,6 +24,7 @@ import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.criteria.RhqDriftCriteria;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
@@ -355,8 +356,8 @@ public abstract class AbstractRecentDriftsPortlet extends DriftHistoryView imple
}
@Override
- protected DriftCriteria getFetchCriteria(DSRequest request) {
- DriftCriteria criteria = new DriftCriteria();
+ protected RhqDriftCriteria getFetchCriteria(DSRequest request) {
+ RhqDriftCriteria criteria = new RhqDriftCriteria();
// result count
String currentSetting = this.configuration.getSimpleValue(Constant.RESULT_COUNT,
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
index eaefcfb..5c80eca 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDataSource.java
@@ -38,9 +38,10 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.criteria.RhqDriftCriteria;
import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
@@ -60,7 +61,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
* @author Jay Shaughnessy
* @author John Mazzitelli
*/
-public class DriftDataSource extends RPCDataSource<Drift, DriftCriteria> {
+public class DriftDataSource extends RPCDataSource<Drift, RhqDriftCriteria> {
public static final String CATEGORY_ICON_ADD = ImageManager.getDriftCategoryIcon(DriftCategory.FILE_ADDED);
public static final String CATEGORY_ICON_CHANGE = ImageManager.getDriftCategoryIcon(DriftCategory.FILE_CHANGED);
@@ -161,7 +162,7 @@ public class DriftDataSource extends RPCDataSource<Drift, DriftCriteria> {
}
@Override
- protected void executeFetch(final DSRequest request, final DSResponse response, final DriftCriteria criteria) {
+ protected void executeFetch(final DSRequest request, final DSResponse response, final RhqDriftCriteria criteria) {
if (criteria == null) {
// the user selected no categories in the filter - it makes sense from the UI perspective to show 0 rows
response.setTotalRows(0);
@@ -200,7 +201,7 @@ public class DriftDataSource extends RPCDataSource<Drift, DriftCriteria> {
default:
Set<Integer> typesSet = new HashSet<Integer>();
Set<String> ancestries = new HashSet<String>();
- for (Drift drift : result) {
+ for (Drift drift : result) {
Resource resource = drift.getChangeSet().getResource();
typesSet.add(resource.getResourceType().getId());
ancestries.add(resource.getAncestry());
@@ -247,14 +248,14 @@ public class DriftDataSource extends RPCDataSource<Drift, DriftCriteria> {
}
@Override
- protected DriftCriteria getFetchCriteria(DSRequest request) {
+ protected RhqDriftCriteria getFetchCriteria(DSRequest request) {
DriftCategory[] categoriesFilter = getArrayFilter(request, FILTER_CATEGORIES, DriftCategory.class);
if (categoriesFilter == null || categoriesFilter.length == 0) {
return null; // user didn't select any priorities - return null to indicate no data should be displayed
}
- DriftCriteria criteria = new DriftCriteria();
+ RhqDriftCriteria criteria = new RhqDriftCriteria();
criteria.fetchChangeSet(true);
criteria.addFilterCategories(categoriesFilter);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
index ffa7185..f5ffc9c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
@@ -28,6 +28,7 @@ import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.criteria.RhqDriftCriteria;
import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
@@ -57,7 +58,7 @@ public class DriftDetailsView extends LocatableVLayout implements BookmarkableVi
}
private void show(String driftId) {
- DriftCriteria criteria = new DriftCriteria();
+ DriftCriteria criteria = new RhqDriftCriteria();
criteria.addFilterId(driftId);
criteria.fetchChangeSet(true);
GWTServiceLookup.getDriftService().findDriftsByCriteria(criteria, new AsyncCallback<PageList<Drift>>() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
index 74531cc..a608f8f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftHistoryView.java
@@ -53,7 +53,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
- * A view that displays a paginated table of {@link org.rhq.core.domain.drift.Drift}s, along with the
+ * A view that displays a paginated table of {@link org.rhq.core.domain.drift.RhqDrift}s, along with the
* ability to filter those drifts, sort those drifts, double-click a row to view full details a drift, and perform
* various actions on the the drifts: delete selected, delete all from source, etc.
* This view full respects the user's authorization, and will not allow acttions on the drifts unless the user is
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
index a5c0209..7767a8f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
@@ -91,12 +91,10 @@ public class DriftGWTServiceImpl extends AbstractGWTServiceImpl implements Drift
}
@Override
- public PageList<DriftChangeSet> findDriftChangeSetsByCriteria(DriftChangeSetCriteria criteria)
- throws RuntimeException {
+ public PageList<DriftChangeSet> findDriftChangeSetsByCriteria(DriftChangeSetCriteria criteria) {
try {
- PageList<DriftChangeSet> result = driftManager.findDriftChangeSetsByCriteria(getSessionSubject(),
- criteria);
- return SerialUtility.prepare(result, "DriftService.findDriftChangeSetsByCriteria");
+ PageList<DriftChangeSet> results = driftServer.findDriftChangeSetsByCriteria(getSessionSubject(), criteria);
+ return SerialUtility.prepare(results, "DriftService.findDriftChangeSetsByCriteria");
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
}
@@ -105,8 +103,8 @@ public class DriftGWTServiceImpl extends AbstractGWTServiceImpl implements Drift
@Override
public PageList<Drift> findDriftsByCriteria(DriftCriteria criteria) throws RuntimeException {
try {
- PageList<Drift> result = driftManager.findDriftsByCriteria(getSessionSubject(), criteria);
- return SerialUtility.prepare(result, "DriftService.findDriftsByCriteria");
+ PageList<Drift> results = driftServer.findDriftsByCriteria(getSessionSubject(), criteria);
+ return SerialUtility.prepare(results, "DriftService.findDriftsByCriteria");
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index 817bb13..f10c3fb 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@ -19,8 +19,6 @@
*/
package org.rhq.enterprise.server.drift;
-import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
-
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
@@ -60,15 +58,16 @@ import org.rhq.core.clientapi.agent.drift.DriftAgentService;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.criteria.RhqDriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.RhqDriftCriteria;
import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.drift.DriftFile;
import org.rhq.core.domain.drift.DriftFileBits;
import org.rhq.core.domain.drift.DriftFileStatus;
+import org.rhq.core.domain.drift.RhqDrift;
+import org.rhq.core.domain.drift.RhqDriftChangeSet;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.ZipUtil;
@@ -80,6 +79,8 @@ import org.rhq.enterprise.server.core.AgentManagerLocal;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
+import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
+
@Stateless
public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
private final Log log = LogFactory.getLog(this.getClass());
@@ -142,9 +143,9 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
try {
- DriftChangeSetCriteria c = new DriftChangeSetCriteria();
+ RhqDriftChangeSetCriteria c = new RhqDriftChangeSetCriteria();
c.addFilterResourceId(resourceId);
- List<DriftChangeSet> changeSets = findDriftChangeSetsByCriteria(subjectManager.getOverlord(), c);
+ List<RhqDriftChangeSet> changeSets = findDriftChangeSetsByCriteria(subjectManager.getOverlord(), c);
final int version = changeSets.size();
ZipUtil.walkZipFile(changeSetZip, new ChangeSetFileVisitor() {
@@ -152,7 +153,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
@Override
public boolean visit(ZipEntry zipEntry, ZipInputStream stream) throws Exception {
List<DriftFile> emptyDriftFiles = new ArrayList<DriftFile>();
- DriftChangeSet driftChangeSet = null;
+ RhqDriftChangeSet driftChangeSet = null;
try {
ChangeSetReader reader = new ChangeSetReaderImpl(new BufferedReader(new InputStreamReader(
@@ -160,7 +161,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
// store the new change set info (not the actual blob)
DriftChangeSetCategory category = reader.getHeaders().getType();
- driftChangeSet = new DriftChangeSet(resource, version, category);
+ driftChangeSet = new RhqDriftChangeSet(resource, version, category);
entityManager.persist(driftChangeSet);
for (DirectoryEntry dir = reader.readDirectoryEntry(); null != dir; dir = reader
@@ -177,7 +178,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
// use a path with only forward slashing to ensure consistent paths across reports
String path = new File(dir.getDirectory(), entry.getFile()).getPath();
path = FileUtil.useForwardSlash(path);
- Drift drift = new Drift(driftChangeSet, path, entry.getType(), oldDriftFile,
+ Drift drift = new RhqDrift(driftChangeSet, path, entry.getType(), oldDriftFile,
newDriftFile);
entityManager.persist(drift);
}
@@ -329,7 +330,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
int result = 0;
for (String driftId : driftIds) {
- Drift doomed = entityManager.find(Drift.class, driftId);
+ Drift doomed = entityManager.find(RhqDrift.class, driftId);
if (null != doomed) {
entityManager.remove(doomed);
++result;
@@ -354,7 +355,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
@Override
public int deleteDriftsByContext(Subject subject, EntityContext entityContext) throws RuntimeException {
int result = 0;
- DriftCriteria criteria = new DriftCriteria();
+ RhqDriftCriteria criteria = new RhqDriftCriteria();
switch (entityContext.getType()) {
case Resource:
@@ -369,7 +370,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
throw new IllegalArgumentException("Entity Context Type not supported [" + entityContext + "]");
}
- List<Drift> drifts = driftManager.findDriftsByCriteria(subject, criteria);
+ List<RhqDrift> drifts = driftManager.findDriftsByCriteria(subject, criteria);
if (!drifts.isEmpty()) {
String[] driftIds = new String[drifts.size()];
int i = 0;
@@ -456,21 +457,21 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
@Override
- public PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria) {
+ public PageList<RhqDriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, RhqDriftChangeSetCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- CriteriaQueryRunner<DriftChangeSet> queryRunner = new CriteriaQueryRunner<DriftChangeSet>(criteria, generator,
+ CriteriaQueryRunner<RhqDriftChangeSet> queryRunner = new CriteriaQueryRunner<RhqDriftChangeSet>(criteria, generator,
entityManager);
- PageList<DriftChangeSet> result = queryRunner.execute();
+ PageList<RhqDriftChangeSet> result = queryRunner.execute();
return result;
}
@Override
- public PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria) {
+ public PageList<RhqDrift> findDriftsByCriteria(Subject subject, RhqDriftCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- CriteriaQueryRunner<Drift> queryRunner = new CriteriaQueryRunner<Drift>(criteria, generator, entityManager);
- PageList<Drift> result = queryRunner.execute();
+ CriteriaQueryRunner<RhqDrift> queryRunner = new CriteriaQueryRunner<RhqDrift>(criteria, generator, entityManager);
+ PageList<RhqDrift> result = queryRunner.execute();
return result;
}
@@ -501,7 +502,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
if (null == result) {
- throw new IllegalArgumentException("Drift Configuration Id [" + driftConfigId
+ throw new IllegalArgumentException("RhqDrift Configuration Id [" + driftConfigId
+ "] not found for entityContext [" + entityContext + "]");
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
index b1bfa34..c052b46 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
@@ -26,12 +26,12 @@ import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
-import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
-import org.rhq.core.domain.criteria.DriftCriteria;
-import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.criteria.RhqDriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.RhqDriftCriteria;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.drift.DriftFile;
+import org.rhq.core.domain.drift.RhqDrift;
+import org.rhq.core.domain.drift.RhqDriftChangeSet;
import org.rhq.core.domain.util.PageList;
@Local
@@ -91,7 +91,7 @@ public interface DriftManagerLocal extends DriftManagerRemote {
*
* @return the number of Drift records deleted
*/
- int deleteDriftsByContext(Subject subject, EntityContext entityContext) throws RuntimeException;
+ int deleteDriftsByContext(Subject subject, EntityContext entityContext);
/**
* Remove the provided driftConfig (identified by name) on the specified entityContext.
@@ -116,7 +116,7 @@ public interface DriftManagerLocal extends DriftManagerRemote {
* @param criteria
* @return The DriftChangeSets matching the criteria
*/
- PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria);
+ PageList<RhqDriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, RhqDriftChangeSetCriteria criteria);
/**
* Standard criteria based fetch method
@@ -124,7 +124,7 @@ public interface DriftManagerLocal extends DriftManagerRemote {
* @param criteria
* @return The Drifts matching the criteria
*/
- PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria);
+ PageList<RhqDrift> findDriftsByCriteria(Subject subject, RhqDriftCriteria criteria);
/**
* Get the specified drift configuration for the specified context.
@@ -134,8 +134,7 @@ public interface DriftManagerLocal extends DriftManagerRemote {
* @return The drift configuration
* @throws RuntimeException, IllegalArgumentException if entity or driftConfig not found.
*/
- DriftConfiguration getDriftConfiguration(Subject subject, EntityContext entityContext, int driftConfigId)
- throws RuntimeException;
+ DriftConfiguration getDriftConfiguration(Subject subject, EntityContext entityContext, int driftConfigId);
/**
* This method stores the provided change-set file for the resource. The version will be incremented based
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
index 3814288..8cef2a7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerBean.java
@@ -18,8 +18,13 @@ import org.rhq.core.clientapi.agent.drift.DriftAgentService;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.agentclient.AgentClient;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
@@ -47,6 +52,18 @@ public class DriftServerBean implements DriftServerLocal {
private AgentManagerLocal agentMgr;
@Override
+ public PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria) {
+ DriftServerPluginFacet driftServerPlugin = getServerPlugin();
+ return driftServerPlugin.findDriftChangeSetsByCriteria(subject, criteria);
+ }
+
+ @Override
+ public PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria) {
+ DriftServerPluginFacet driftServerPlugin = getServerPlugin();
+ return driftServerPlugin.findDriftsByCriteria(subject, criteria);
+ }
+
+ @Override
@TransactionAttribute(NOT_SUPPORTED)
public void saveChangeSet(int resourceId, File changeSetZip) throws Exception {
DriftServerPluginFacet driftServerPlugin = getServerPlugin();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
index 014a5a8..e24ef5e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftServerLocal.java
@@ -6,7 +6,12 @@ import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftConfiguration;
+import org.rhq.core.domain.util.PageList;
@Local
public interface DriftServerLocal {
@@ -21,4 +26,8 @@ public interface DriftServerLocal {
void detectDrift(Subject subject, EntityContext context, DriftConfiguration driftConfig);
+ PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria);
+
+ PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria);
+
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
index c5423c6..02375b7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginFacet.java
@@ -21,7 +21,12 @@ package org.rhq.enterprise.server.plugin.pc.drift;
import java.io.File;
-import org.rhq.core.domain.drift.DriftFile;
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
/**
@@ -32,6 +37,10 @@ import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
*/
public interface DriftServerPluginFacet extends ServerPluginComponent {
+ PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria);
+
+ PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria);
+
void saveChangeSet(int resourceId, File changeSetZip) throws Exception;
void saveChangeSetFiles(File changeSetFilesZip) throws Exception;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index 9792fad..53ec93e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -69,8 +69,8 @@ import org.rhq.core.domain.content.PackageInstallationStep;
import org.rhq.core.domain.content.ResourceRepo;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.criteria.ResourceTypeCriteria;
-import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.RhqDrift;
+import org.rhq.core.domain.drift.RhqDriftChangeSet;
import org.rhq.core.domain.event.Event;
import org.rhq.core.domain.event.EventSource;
import org.rhq.core.domain.measurement.Availability;
@@ -503,8 +503,8 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
AlertDampeningEvent.QUERY_DELETE_BY_RESOURCES, // alert-
AlertNotification.QUERY_DELETE_BY_RESOURCES, // related
AlertDefinition.QUERY_DELETE_BY_RESOURCES, // deletes
- Drift.QUERY_DELETE_BY_RESOURCES, // drift before changeset
- DriftChangeSet.QUERY_DELETE_BY_RESOURCES };
+ RhqDrift.QUERY_DELETE_BY_RESOURCES, // drift before changeset
+ RhqDriftChangeSet.QUERY_DELETE_BY_RESOURCES };
List<Integer> resourceIds = new ArrayList<Integer>();
resourceIds.add(resourceId);
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
index eef7aba..ce3c4b0 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
@@ -40,15 +40,15 @@ import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.RhqDriftChangeSetCriteria;
import org.rhq.core.domain.criteria.ResourceCriteria;
-import org.rhq.core.domain.drift.Drift;
import org.rhq.core.domain.drift.DriftCategory;
-import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.drift.DriftFile;
import org.rhq.core.domain.drift.DriftFileStatus;
import org.rhq.core.domain.drift.DriftConfigurationDefinition.BaseDirValueContext;
+import org.rhq.core.domain.drift.RhqDrift;
+import org.rhq.core.domain.drift.RhqDriftChangeSet;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
@@ -118,12 +118,12 @@ public class DriftManagerBeanTest extends AbstractEJB3Test {
assertTrue(changeset1.exists());
driftManager.storeChangeSet(newResource.getId(), changeset1);
- DriftChangeSetCriteria c = new DriftChangeSetCriteria();
+ RhqDriftChangeSetCriteria c = new RhqDriftChangeSetCriteria();
c.addFilterResourceId(newResource.getId());
c.fetchDrifts(true);
- List<DriftChangeSet> changeSets = driftManager.findDriftChangeSetsByCriteria(overlord, c);
+ List<RhqDriftChangeSet> changeSets = driftManager.findDriftChangeSetsByCriteria(overlord, c);
assertEquals(1, changeSets.size());
- DriftChangeSet changeSet = changeSets.get(0);
+ RhqDriftChangeSet changeSet = changeSets.get(0);
assertEquals(0, changeSet.getVersion());
assertEquals(0, changeSet.getDrifts().size());
@@ -144,7 +144,7 @@ public class DriftManagerBeanTest extends AbstractEJB3Test {
changeSet = changeSets.get(1);
assertEquals(1, changeSet.getVersion());
assertEquals(1, changeSet.getDrifts().size());
- Drift drift = changeSet.getDrifts().iterator().next();
+ RhqDrift drift = changeSet.getDrifts().iterator().next();
assertEquals("dir/filename.ext", drift.getPath());
assertEquals("aaaaa", drift.getOldDriftFile().getHashId());
assertEquals("bbbbb", drift.getNewDriftFile().getHashId());
diff --git a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
index f6e657a..67658f5 100644
--- a/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/drift-rhq/src/main/java/org/rhq/enterprise/server/plugins/drift/DriftServerPluginComponent.java
@@ -24,15 +24,18 @@ import java.io.File;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.drift.DriftFile;
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.DriftCriteria;
+import org.rhq.core.domain.criteria.RhqDriftChangeSetCriteria;
+import org.rhq.core.domain.criteria.RhqDriftCriteria;
+import org.rhq.core.domain.drift.Drift;
+import org.rhq.core.domain.drift.DriftCategory;
+import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.drift.DriftManagerLocal;
-import org.rhq.enterprise.server.plugin.pc.ControlFacet;
-import org.rhq.enterprise.server.plugin.pc.ControlResults;
-import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
import org.rhq.enterprise.server.plugin.pc.ServerPluginContext;
import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginFacet;
-import org.rhq.enterprise.server.util.LookupUtil;
import static org.rhq.enterprise.server.util.LookupUtil.getDriftManager;
@@ -67,6 +70,37 @@ public class DriftServerPluginComponent implements DriftServerPluginFacet {
}
@Override
+ public PageList<DriftChangeSet> findDriftChangeSetsByCriteria(Subject subject, DriftChangeSetCriteria criteria) {
+ RhqDriftChangeSetCriteria rhqCriteria = new RhqDriftChangeSetCriteria();
+ rhqCriteria.addFilterId(criteria.getFilterId());
+ rhqCriteria.addFilterResourceId(criteria.getFilterResourceId());
+ rhqCriteria.addFilterVersion(criteria.getFilterVersion());
+ rhqCriteria.addFilterCategory(criteria.getFilterCategory());
+ rhqCriteria.fetchDrifts(criteria.isFetchDrifts());
+
+ PageList<? extends DriftChangeSet> results = getDriftManager().findDriftChangeSetsByCriteria(subject,
+ rhqCriteria);
+ return (PageList<DriftChangeSet>) results;
+ }
+
+ @Override
+ public PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria) {
+ RhqDriftCriteria rhqCriteria = new RhqDriftCriteria();
+ rhqCriteria.addFilterId(criteria.getFilterId());
+ rhqCriteria.addFilterCategories(criteria.getFilterCategories().toArray(new DriftCategory[] {}));
+ rhqCriteria.addFilterChangeSetId(criteria.getFilterChangeSetId());
+ rhqCriteria.addFilterEndTime(criteria.getFilterEndTime());
+ rhqCriteria.addFilterPath(criteria.getFilterPath());
+ rhqCriteria.addFilterResourceIds(criteria.getFilterResourceIds().toArray(new Integer[] {}));
+ rhqCriteria.addFilterStartTime(criteria.getFilterStartTime());
+ rhqCriteria.fetchChangeSet(criteria.isFetchChangeSet());
+ rhqCriteria.addSortCtime(criteria.getSortCtime());
+
+ PageList<? extends Drift> results = getDriftManager().findDriftsByCriteria(subject, rhqCriteria);
+ return (PageList<Drift>) results;
+ }
+
+ @Override
public void saveChangeSet(int resourceId, File changeSetZip) throws Exception {
DriftManagerLocal driftMgr = getDriftManager();
driftMgr.storeChangeSet(resourceId, changeSetZip);
commit fc8d638828caaf235ddeff2bbe3dfd19dcbbf0a5
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 18 13:25:26 2011 -0400
Initial commit for drift mongodb server plugin
diff --git a/modules/enterprise/server/plugins/drift-mongodb/pom.xml b/modules/enterprise/server/plugins/drift-mongodb/pom.xml
new file mode 100644
index 0000000..8721db7
--- /dev/null
+++ b/modules/enterprise/server/plugins/drift-mongodb/pom.xml
@@ -0,0 +1,249 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-enterprise-server-plugins-parent</artifactId>
+ <version>4.1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.rhq</groupId>
+ <artifactId>drift-mongodb-serverplugin</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Drift Server MongoDB Plugin</name>
+ <description>Server side plugin providing MongoDB Backend for drift management</description>
+
+ <scm>
+ <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/server/...</connection>
+ <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/server/...</developerConnection>
+ </scm>
+
+ <properties>
+ <scm.module.path>modules/enterprise/server/plugins/drift-mongodb/</scm.module.path>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mongodb</groupId>
+ <artifactId>mongo-java-driver</artifactId>
+ <version>2.6.3</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.code.morphia</groupId>
+ <artifactId>morphia</artifactId>
+ <version>1.00-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib-nodep</artifactId>
+ <version>2.1_3</version>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>com.thoughtworks.proxytoys</groupId>
+ <artifactId>proxytoys</artifactId>
+ <version>1.0</version>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
+ <!--
+ <argLine>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine>
+ -->
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <repositories>
+ <id>morphia-repo</id>
+ <name>Morphia Repo</name>
+ <url>http://morphia.googlecode.com/svn/mavenrepo/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repositories>
+
+ <profiles>
+
+ <profile>
+ <id>dev</id>
+
+ <properties>
+ <rhq.rootDir>../../../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-serverplugins</rhq.deploymentDir>
+ </properties>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${rhq.deploymentDir}" />
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>deploy-jar-meta-inf</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating META-INF dir in ${deployment.file}...</echo>
+ <unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.outputDirectory}">
+ <patternset>
+ <include name="META-INF/**" />
+ </patternset>
+ </unjar>
+ <jar destfile="${deployment.file}" manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF" update="true">
+ </jar>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>cobertura-plugins</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>net.sourceforge.cobertura</groupId>
+ <artifactId>cobertura</artifactId>
+ <version>${cobertura.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>cobertura-instrument</id>
+ <phase>pre-integration-test</phase>
+ <configuration>
+ <tasks>
+ <!-- prepare directory structure for cobertura-->
+ <mkdir dir="target/cobertura" />
+ <mkdir dir="target/cobertura/backup" />
+ <!-- backup all classes so that we can instrument the original classes-->
+ <copy toDir="target/cobertura/backup" verbose="true" overwrite="true">
+ <fileset dir="target/classes">
+ <include name="**/*.class" />
+ </fileset>
+ </copy>
+ <!-- create a properties file and save there location of cobertura data file-->
+ <touch file="target/classes/cobertura.properties" />
+ <echo file="target/classes/cobertura.properties">net.sourceforge.cobertura.datafile=${project.build.directory}/cobertura/cobertura.ser</echo>
+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
+ <!-- instrument all classes in target/classes directory -->
+ <cobertura-instrument datafile="${project.build.directory}/cobertura/cobertura.ser" todir="${project.build.directory}/classes">
+ <fileset dir="${project.build.directory}/classes">
+ <include name="**/*.class" />
+ </fileset>
+ </cobertura-instrument>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>cobertura-report</id>
+ <phase>post-integration-test</phase>
+ <configuration>
+ <tasks>
+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
+ <!-- prepare directory structure for cobertura-->
+ <mkdir dir="target/cobertura" />
+ <mkdir dir="target/site/cobertura" />
+ <!-- restore classes from backup folder to classes folder -->
+ <copy toDir="target/classes" verbose="true" overwrite="true">
+ <fileset dir="target/cobertura/backup">
+ <include name="**/*.class" />
+ </fileset>
+ </copy>
+ <!-- delete backup folder-->
+ <delete dir="target/cobertura/backup" />
+ <!-- create a code coverage report -->
+ <cobertura-report format="html" datafile="${project.build.directory}/cobertura/cobertura.ser" destdir="${project.build.directory}/site/cobertura">
+ <fileset dir="${basedir}/src/main/java">
+ <include name="**/*.java" />
+ </fileset>
+ </cobertura-report>
+ <!-- delete cobertura.properties file -->
+ <delete file="target/classes/cobertura.properties" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
new file mode 100644
index 0000000..d7c7202
--- /dev/null
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/java/org/rhq/enterprise/server/plugins/drift/mongodb/MongoDBDriftServer.java
@@ -0,0 +1,40 @@
+package org.rhq.enterprise.server.plugins.drift.mongodb;
+
+import java.io.File;
+
+import org.rhq.enterprise.server.plugin.pc.ServerPluginContext;
+import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginFacet;
+
+public class MongoDBDriftServer implements DriftServerPluginFacet {
+
+ @Override
+ public void start() {
+
+ }
+
+ @Override
+ public void stop() {
+
+ }
+
+ @Override
+ public void shutdown() {
+
+ }
+
+ @Override
+ public void saveChangeSet(int resourceId, File changeSetZip) throws Exception {
+
+ }
+
+ @Override
+ public void saveChangeSetFiles(File changeSetFilesZip) throws Exception {
+
+ }
+
+ @Override
+ public void initialize(ServerPluginContext context) throws Exception {
+
+ }
+
+}
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/drift-mongodb/src/main/resources/META-INF/rhq-serverplugin.xml
new file mode 100644
index 0000000..e1894d0
--- /dev/null
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<drift-plugin
+ version="1.0"
+ apiVersion="1.0"
+ description="The Drift Management MongoDB Persistence Store"
+ displayName="Drift:RHQ"
+ name="drift-mongodb"
+ package="org.rhq.enterprise.server.plugins.drift.MorphiaTest"
+ xmlns="urn:xmlns:rhq-serverplugin.drift"
+ xmlns:serverplugin="urn:xmlns:rhq-serverplugin"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <serverplugin:help><![CDATA[
+ Provides back-end store and retrieve for drift files.
+ ]]></serverplugin:help>
+
+ <serverplugin:plugin-component class="MongoDBDriftServer"/>
+
+ <drift diff-support="false" />
+
+</drift-plugin>
diff --git a/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/MorphiaTest.java b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/MorphiaTest.java
new file mode 100644
index 0000000..c88432e
--- /dev/null
+++ b/modules/enterprise/server/plugins/drift-mongodb/src/test/java/org/rhq/enterprise/server/plugins/drift/MorphiaTest.java
@@ -0,0 +1,28 @@
+package org.rhq.enterprise.server.plugins.drift;
+
+import com.google.code.morphia.Datastore;
+import com.google.code.morphia.Morphia;
+import com.mongodb.DB;
+import com.mongodb.Mongo;
+
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.drift.DriftChangeSet;
+
+public class MorphiaTest {
+
+ @Test
+ public void connectToMongoDB() throws Exception {
+ Mongo connection = new Mongo("localhost");
+ DB db = connection.getDB("test");
+
+ Morphia morphia = new Morphia();
+ morphia.map(DriftChangeSet.class);
+
+ Datastore ds = morphia.createDatastore(connection, "test");
+
+// DriftChangeSet changeSet = new DriftChangeSet(null, 1, COVERAGE);
+// ds.save(changeSet);
+ }
+
+}
diff --git a/modules/enterprise/server/plugins/pom.xml b/modules/enterprise/server/plugins/pom.xml
index f3362ef..abf3f43 100644
--- a/modules/enterprise/server/plugins/pom.xml
+++ b/modules/enterprise/server/plugins/pom.xml
@@ -84,6 +84,7 @@
<module>alert-log4j</module>
<module>cobbler</module>
<module>drift-rhq</module>
+ <module>drift-mongodb</module>
<module>filetemplate-bundle</module>
<module>ant-bundle</module>
<module>validate-all-serverplugins</module>
12 years, 10 months
[rhq] Branch 'stefan/dbreset' - modules/core
by snegrea
modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java | 3 +++
1 file changed, 3 insertions(+)
New commits:
commit 19437cae8ca6ceb053fa191e08dff6368b8574b9
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 4 07:44:43 2011 -0500
Throw an exception if trying to use dbreset with anything else other than Oracle and Postgres.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 4736988..ce12786 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -132,5 +132,8 @@ public class DBReset {
}
}
}
+ else {
+ throw new Exception("dbreset not supported for "+ dbTypeMapping +"!");
+ }
}
}
12 years, 10 months
[rhq] Branch 'release-3.0.1' - modules/plugins
by lkrejci
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java | 122 +-
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java | 79 +
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java | 135 +--
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java | 65 -
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java | 60 -
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java | 61 -
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java | 409 +++++-----
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java | 224 +++--
modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasComponent.java | 52 +
modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java | 44 -
modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java | 189 ++--
modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java | 22
modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java | 78 +
modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java | 4
modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java | 21
modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java | 54 -
16 files changed, 904 insertions(+), 715 deletions(-)
New commits:
commit 399a6ce35b92d632ba42b7579ba645e8a76f0705
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Aug 1 13:44:18 2011 +0200
BZ 721151 - fixing the augeas memory leak - cherrypicked over from release-3.0.0
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java
index 0c3f447..e828818 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java
@@ -23,17 +23,14 @@
package org.rhq.plugins.apache;
-import java.util.ArrayList;
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
-import org.rhq.core.domain.configuration.Property;
-import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
@@ -46,23 +43,24 @@ import org.rhq.plugins.apache.mapping.ApacheAugeasMapping;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
/**
- * Component for configuring the <Directory> and underlying directives inside
- * Apache configuration.
+ * Component for configuring the <Directory> and underlying directives
+ * inside Apache configuration.
*
* @author Lukas Krejci
*/
-public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtualHostServiceComponent>, ConfigurationFacet, DeleteResourceFacet {
-
- private final Log log = LogFactory.getLog(this.getClass());
+public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtualHostServiceComponent>,
+ ConfigurationFacet, DeleteResourceFacet {
+
+ private final Log log = LogFactory.getLog(this.getClass());
public static final String REGEXP_PROP = "regexp";
public static final String DIRECTORY_DIRECTIVE = "<Directory";
-
+
private ResourceContext<ApacheVirtualHostServiceComponent> resourceContext;
-
- public void start(ResourceContext<ApacheVirtualHostServiceComponent> context) throws InvalidPluginConfigurationException, Exception {
- resourceContext = context;
- }
-
+
+ public void start(ResourceContext<ApacheVirtualHostServiceComponent> context)
+ throws InvalidPluginConfigurationException, Exception {
+ resourceContext = context;
+ }
public void stop() {
}
@@ -73,20 +71,27 @@ public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtual
public Configuration loadResourceConfiguration() throws Exception {
ApacheVirtualHostServiceComponent parentVirtualHost = resourceContext.getParentResourceComponent();
- AugeasTree tree = parentVirtualHost.getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType().getResourceConfigurationDefinition();
-
- AugeasNode virtualHostNode = parentVirtualHost.getNode(tree);
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- return mapping.updateConfiguration(getNode(virtualHostNode), resourceConfigDef);
+
+ AugeasComponent comp = getAugeas();
+ try {
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
+
+ AugeasNode virtualHostNode = parentVirtualHost.getNode(tree);
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ return mapping.updateConfiguration(getNode(virtualHostNode), resourceConfigDef);
+ } finally {
+ comp.close();
+ }
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
- ApacheVirtualHostServiceComponent parentVirtualHost = resourceContext.getParentResourceComponent();
+ AugeasComponent comp = getAugeas();
AugeasTree tree = null;
try {
- tree = parentVirtualHost.getServerConfigurationTree();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
.getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
@@ -96,7 +101,7 @@ public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtual
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
log.info("Apache configuration was updated");
-
+
resourceContext.getParentResourceComponent().finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null)
@@ -104,27 +109,35 @@ public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtual
else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ } finally {
+ comp.close();
}
- }
-
+ }
public void deleteResource() throws Exception {
ApacheVirtualHostServiceComponent parentVirtualHost = resourceContext.getParentResourceComponent();
- AugeasTree tree = parentVirtualHost.getServerConfigurationTree();
- AugeasNode virtualHostNode = parentVirtualHost.getNode(tree);
-
- AugeasNode myNode = getNode(virtualHostNode);
-
- if (myNode != null) {
- tree.removeNode(myNode, true);
- tree.save();
-
- ApacheVirtualHostServiceComponent parentVhost = resourceContext.getParentResourceComponent();
-
- parentVhost.deleteEmptyFile(tree, myNode);
- parentVhost.conditionalRestart();
- } else {
- log.info("Could find the configuration corresponding to the directory " + resourceContext.getResourceKey() + ". Ignoring.");
+ AugeasComponent comp = getAugeas();
+
+ try {
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ AugeasNode virtualHostNode = parentVirtualHost.getNode(tree);
+
+ AugeasNode myNode = getNode(virtualHostNode);
+
+ if (myNode != null) {
+ tree.removeNode(myNode, true);
+ tree.save();
+
+ ApacheVirtualHostServiceComponent parentVhost = resourceContext.getParentResourceComponent();
+
+ parentVhost.deleteEmptyFile(tree, myNode);
+ parentVhost.conditionalRestart();
+ } else {
+ log.info("Could find the configuration corresponding to the directory "
+ + resourceContext.getResourceKey() + ". Ignoring.");
+ }
+ } finally {
+ comp.close();
}
}
@@ -132,35 +145,36 @@ public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtual
* Gets the node from under given node corresponding to the Directory this
* component is managing.
*
- * @param virtualHost the node of the parent virtualHost (or root node of the augeas tree)
+ * @param virtualHost
+ * the node of the parent virtualHost (or root node of the augeas
+ * tree)
* @return
*/
public AugeasNode getNode(AugeasNode virtualHost) {
AugeasNode directory = AugeasNodeSearch.findNodeById(virtualHost, resourceContext.getResourceKey());
-
+
return directory;
}
-
- public AugeasNode getNode(){
+
+ public AugeasNode getNode(AugeasTree tree) {
ApacheVirtualHostServiceComponent virtHost = resourceContext.getParentResourceComponent();
- AugeasTree tree = virtHost.getServerConfigurationTree();
AugeasNode virtHostNode = resourceContext.getParentResourceComponent().getNode(tree);
return getNode(virtHostNode);
}
-
- public AugeasTree getServerConfigurationTree(){
- return resourceContext.getParentResourceComponent().getServerConfigurationTree();
+
+ public AugeasComponent getAugeas() {
+ return resourceContext.getParentResourceComponent().getAugeas();
}
-
+
/**
* @see ApacheServerComponent#finishConfigurationUpdate(ConfigurationUpdateReport)
*/
public void finishConfigurationUpdate(ConfigurationUpdateReport report) {
resourceContext.getParentResourceComponent().finishConfigurationUpdate(report);
}
-
- public boolean isAugeasEnabled(){
+
+ public boolean isAugeasEnabled() {
ApacheVirtualHostServiceComponent parent = resourceContext.getParentResourceComponent();
- return parent.isAugeasEnabled();
+ return parent.isAugeasEnabled();
}
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java
index c407f34..97d14d5 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java
@@ -29,6 +29,7 @@ import java.util.Set;
import net.augeas.AugeasException;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
@@ -52,8 +53,8 @@ public class ApacheDirectoryDiscoveryComponent implements ResourceDiscoveryCompo
* @see org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext)
*/
public static final String DIRECTORY_DIRECTIVE = "<Directory";
- public static final String [] PARENT_DIRECTIVES = {"<IfModule"};
-
+ public static final String[] PARENT_DIRECTIVES = { "<IfModule" };
+
public Set<DiscoveredResourceDetails> discoverResources(
ResourceDiscoveryContext<ApacheVirtualHostServiceComponent> context)
throws InvalidPluginConfigurationException, Exception {
@@ -63,47 +64,55 @@ public class ApacheDirectoryDiscoveryComponent implements ResourceDiscoveryCompo
if (!context.getParentResourceComponent().isAugeasEnabled())
return discoveredResources;
-
+ AugeasComponent comp = context.getParentResourceComponent().getAugeas();
AugeasTree tree = null;
-
+
try {
- tree = context.getParentResourceComponent().getServerConfigurationTree();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
} catch (AugeasException e) {
//we depend on Augeas to do anything useful with directories.
- //give up, if Augeas isn't there.
+ //give up, if Augeas isn't there.
+ comp.close();
return discoveredResources;
}
- AugeasNode parentNode = context.getParentResourceComponent().getNode(tree);
- List<AugeasNode> directories = AugeasNodeSearch.searchNode(PARENT_DIRECTIVES, DIRECTORY_DIRECTIVE, parentNode);
-
- ResourceType resourceType = context.getResourceType();
-
- for (AugeasNode node : directories) {
- Configuration pluginConfiguration = new Configuration();
-
- String ifmoduleParams = AugeasNodeSearch.getNodeKey(node, parentNode);
- List<AugeasNode> params = node.getChildByLabel("param");
-
- String directoryParam;
- boolean isRegexp;
-
- if (params.size() > 1) {
- directoryParam = params.get(1).getValue();
- isRegexp = true;
- } else {
- directoryParam = params.get(0).getValue();
- isRegexp = false;
+ try {
+ AugeasNode parentNode = context.getParentResourceComponent().getNode(tree);
+ List<AugeasNode> directories = AugeasNodeSearch.searchNode(PARENT_DIRECTIVES, DIRECTORY_DIRECTIVE,
+ parentNode);
+
+ ResourceType resourceType = context.getResourceType();
+
+ for (AugeasNode node : directories) {
+ Configuration pluginConfiguration = new Configuration();
+
+ String ifmoduleParams = AugeasNodeSearch.getNodeKey(node, parentNode);
+ List<AugeasNode> params = node.getChildByLabel("param");
+
+ String directoryParam;
+ boolean isRegexp;
+
+ if (params.size() > 1) {
+ directoryParam = params.get(1).getValue();
+ isRegexp = true;
+ } else {
+ directoryParam = params.get(0).getValue();
+ isRegexp = false;
+ }
+
+ pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.REGEXP_PROP, isRegexp));
+
+ String resourceKey = ifmoduleParams;
+ String resourceName = AugeasNodeValueUtil.unescape(directoryParam);
+
+ discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null,
+ null, pluginConfiguration, null));
}
-
- pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.REGEXP_PROP, isRegexp));
-
- String resourceKey = ifmoduleParams;
- String resourceName = AugeasNodeValueUtil.unescape(directoryParam);
-
- discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null, null,
- pluginConfiguration, null));
+ return discoveredResources;
+
+ } finally {
+ if (comp != null)
+ comp.close();
}
- return discoveredResources;
}
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java
index b046f17..bd6b4ee 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java
@@ -22,19 +22,14 @@
*/
package org.rhq.plugins.apache;
-import java.util.ArrayList;
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
-import org.rhq.core.domain.configuration.Property;
-import org.rhq.core.domain.configuration.PropertyList;
-import org.rhq.core.domain.configuration.PropertyMap;
-import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
@@ -43,57 +38,64 @@ import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.plugins.apache.augeas.mappingImpl.MappingPositionToConfiguration;
import org.rhq.plugins.apache.mapping.ApacheAugeasMapping;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
-
-public class ApacheIfModuleComponent implements ResourceComponent<ApacheVirtualHostServiceComponent>, ConfigurationFacet, DeleteResourceFacet {
+public class ApacheIfModuleComponent implements ResourceComponent<ApacheVirtualHostServiceComponent>,
+ ConfigurationFacet, DeleteResourceFacet {
private AugeasTree tree;
private ResourceContext<ApacheVirtualHostServiceComponent> context;
- private ApacheVirtualHostServiceComponent parentComponent;
+ private ApacheVirtualHostServiceComponent parentComponent;
private final Log log = LogFactory.getLog(this.getClass());
- private static final String IFMODULE_DIRECTIVE_NAME="<IfModule";
-
+ private static final String IFMODULE_DIRECTIVE_NAME = "<IfModule";
+
public void start(ResourceContext<ApacheVirtualHostServiceComponent> context)
throws InvalidPluginConfigurationException, Exception {
-
- this.context = context;
- parentComponent = context.getParentResourceComponent();
+
+ this.context = context;
+ parentComponent = context.getParentResourceComponent();
}
- public void stop(){
+ public void stop() {
}
public AvailabilityType getAvailability() {
- return parentComponent.getAvailability();
+ return parentComponent.getAvailability();
}
- public Configuration loadResourceConfiguration() throws Exception {
- AugeasTree tree = parentComponent.getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
-
- AugeasNode virtualHostNode = parentComponent.getNode(tree);
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- return mapping.updateConfiguration(getNode(virtualHostNode), resourceConfigDef);
+ public Configuration loadResourceConfiguration() throws Exception {
+ AugeasComponent comp = null;
+ try {
+ comp = parentComponent.getAugeas();
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
+
+ AugeasNode virtualHostNode = parentComponent.getNode(tree);
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ return mapping.updateConfiguration(getNode(virtualHostNode), resourceConfigDef);
+ } finally {
+ if (comp != null)
+ comp.close();
+ }
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ AugeasComponent comp = null;
AugeasTree tree = null;
try {
- tree = parentComponent.getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = context.getResourceType()
- .getResourceConfigurationDefinition();
+ comp = parentComponent.getAugeas();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
-
+
AugeasNode directoryNode = getNode(parentComponent.getNode(tree));
mapping.updateAugeas(directoryNode, report.getConfiguration(), resourceConfigDef);
tree.save();
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
log.info("Apache configuration was updated");
-
+
context.getParentResourceComponent().finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null)
@@ -101,73 +103,30 @@ public class ApacheIfModuleComponent implements ResourceComponent<ApacheVirtualH
else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ } finally {
+ if (comp != null)
+ comp.close();
}
- }
+ }
+
public void deleteResource() throws Exception {
-
+
}
-
+
private AugeasNode getNode(AugeasNode virtualHost) {
AugeasNode directory = AugeasNodeSearch.findNodeById(virtualHost, context.getResourceKey());
return directory;
- }
-
- private void prepareNode(AugeasNode node,AugeasNode parentNode,AugeasTree tree,Configuration configuration){
- List<String> params = AugeasNodeSearch.getParams(node, parentNode);
-
- PropertyList list = (PropertyList)configuration.get(MappingPositionToConfiguration.LIST_PROPERTY_NAME);
- List<String> newParams = new ArrayList<String>();
- //get new list of params
- for (Property prop : list.getList()){
- if (prop instanceof PropertyMap)
- {
- PropertyMap propMap = (PropertyMap) prop;
- PropertySimple value = (PropertySimple) propMap.get(MappingPositionToConfiguration.SIMPLE_PROPERTY_NAME);
- newParams.add(value.getStringValue());
- }
- }
-
- int i = 0;
- int position = 0;
- AugeasNode tempNode = parentNode;
- boolean updated = true;
-
- while (updated){
- updated = false;
- List<AugeasNode> nodes = tempNode.getChildByLabel(IFMODULE_DIRECTIVE_NAME);
- for (AugeasNode nd : nodes){
- List<AugeasNode> paramNodes = nd.getChildByLabel("param");
- if (paramNodes.size()>0)
- {
- String value = paramNodes.get(0).getValue();
- if (value.equals(newParams.get(position)))
- {
- position = position + 1;
- tempNode = nd;
- updated = true;
- break;
- }
- }
- }
- }
-
- for(i=position;i<newParams.size();i++){
- int size = tempNode.getChildByLabel(IFMODULE_DIRECTIVE_NAME).size()+1;
- tempNode = tree.createNode(tempNode, IFMODULE_DIRECTIVE_NAME, null, size);
- tree.createNode(tempNode, "param", newParams.get(i), 1);
- }
}
-
- public void copy(AugeasNode a, AugeasNode b){
- for (AugeasNode nd : a.getChildNodes()){
+
+ public void copy(AugeasNode a, AugeasNode b) {
+ for (AugeasNode nd : a.getChildNodes()) {
AugeasNode tempNode = tree.createNode(b, nd.getLabel(), nd.getValue(), nd.getSeq());
- copy(nd,tempNode);
+ copy(nd, tempNode);
}
}
-
-
- public boolean isAugeasEnabled(){
- return parentComponent.isAugeasEnabled();
+
+ public boolean isAugeasEnabled() {
+ return parentComponent.isAugeasEnabled();
}
-
+
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java
index acb2572..dedcb3c 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java
@@ -24,6 +24,8 @@ package org.rhq.plugins.apache;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
@@ -38,51 +40,57 @@ import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.plugins.apache.mapping.ApacheAugeasMapping;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
-public class ApacheIfModuleDirectoryComponent implements ResourceComponent<ApacheDirectoryComponent>, ConfigurationFacet {
+public class ApacheIfModuleDirectoryComponent implements ResourceComponent<ApacheDirectoryComponent>,
+ ConfigurationFacet {
private ResourceContext<ApacheDirectoryComponent> context;
- private ApacheDirectoryComponent parentComponent;
+ private ApacheDirectoryComponent parentComponent;
private final Log log = LogFactory.getLog(this.getClass());
- private static final String IFMODULE_DIRECTIVE_NAME="<IfModule";
-
- public void start(ResourceContext<ApacheDirectoryComponent> context)
- throws InvalidPluginConfigurationException, Exception {
-
- this.context = context;
- parentComponent = context.getParentResourceComponent();
+ private static final String IFMODULE_DIRECTIVE_NAME = "<IfModule";
+
+ public void start(ResourceContext<ApacheDirectoryComponent> context) throws InvalidPluginConfigurationException,
+ Exception {
+ this.context = context;
+ parentComponent = context.getParentResourceComponent();
}
public void stop() {
}
public AvailabilityType getAvailability() {
- return parentComponent.getAvailability();
+ return parentComponent.getAvailability();
}
- public Configuration loadResourceConfiguration() throws Exception {
+ public Configuration loadResourceConfiguration() throws Exception {
ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
-
- AugeasNode directoryNode = parentComponent.getNode();
- AugeasTree tree = parentComponent.getServerConfigurationTree();
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- return mapping.updateConfiguration(getNode(directoryNode), resourceConfigDef);
+ AugeasComponent comp = parentComponent.getAugeas();
+ AugeasTree tree = null;
+ try {
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ AugeasNode directoryNode = parentComponent.getNode(tree);
+
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ return mapping.updateConfiguration(getNode(directoryNode), resourceConfigDef);
+ } finally {
+ comp.close();
+ }
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ AugeasComponent comp = parentComponent.getAugeas();
AugeasTree tree = null;
try {
- tree = parentComponent.getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = context.getResourceType()
- .getResourceConfigurationDefinition();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- AugeasNode directoryNode = getNode(parentComponent.getNode());
+ AugeasNode directoryNode = getNode(parentComponent.getNode(tree));
mapping.updateAugeas(directoryNode, report.getConfiguration(), resourceConfigDef);
tree.save();
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
log.info("Apache configuration was updated");
-
+
context.getParentResourceComponent().finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null)
@@ -90,16 +98,17 @@ public class ApacheIfModuleDirectoryComponent implements ResourceComponent<Apach
else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ } finally {
+ comp.close();
}
- }
-
+ }
+
private AugeasNode getNode(AugeasNode virtualHost) {
AugeasNode directory = AugeasNodeSearch.findNodeById(virtualHost, context.getResourceKey());
return directory;
- }
-
- public boolean isAugeasEnabled(){
- return parentComponent.isAugeasEnabled();
}
-}
+ public boolean isAugeasEnabled() {
+ return parentComponent.isAugeasEnabled();
+ }
+}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java
index 3d17f71..d3bbe15 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java
@@ -26,6 +26,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.resource.ResourceType;
@@ -36,39 +37,44 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
public class ApacheIfModuleDirectoryDiscoveryComponent implements ResourceDiscoveryComponent<ApacheDirectoryComponent> {
-
- private static final String [] parentRes = {"<IfModule"};
+
+ private static final String[] parentRes = { "<IfModule" };
private static final String IFMODULE_NODE_NAME = "<IfModule";
private AugeasTree tree;
private AugeasNode parentNode;
-
- public Set<DiscoveredResourceDetails> discoverResources(
- ResourceDiscoveryContext<ApacheDirectoryComponent> context)
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ApacheDirectoryComponent> context)
throws InvalidPluginConfigurationException, Exception {
-
- ApacheDirectoryComponent directory = context.getParentResourceComponent();
- Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
-
- if (!directory.isAugeasEnabled())
- return discoveredResources;
-
- parentNode = directory.getNode();
-
- List<AugeasNode> ifModuleNodes = AugeasNodeSearch.searchNode(parentRes, IFMODULE_NODE_NAME, parentNode);
-
- ResourceType resourceType = context.getResourceType();
+ ApacheDirectoryComponent directory = context.getParentResourceComponent();
+ Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
+
+ if (!directory.isAugeasEnabled())
+ return discoveredResources;
+
+ AugeasComponent comp = directory.getAugeas();
+ AugeasTree tree = null;
+ try {
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+
+ parentNode = directory.getNode(tree);
+
+ List<AugeasNode> ifModuleNodes = AugeasNodeSearch.searchNode(parentRes, IFMODULE_NODE_NAME, parentNode);
+
+ ResourceType resourceType = context.getResourceType();
+
+ for (AugeasNode node : ifModuleNodes) {
- for (AugeasNode node : ifModuleNodes) {
-
-
- String resourceKey = AugeasNodeSearch.getNodeKey(node,parentNode);
- String [] paramArray = resourceKey.split("\\|");
- String resourceName = paramArray[1];
+ String resourceKey = AugeasNodeSearch.getNodeKey(node, parentNode);
+ String[] paramArray = resourceKey.split("\\|");
+ String resourceName = paramArray[1];
- discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null, null,
- null, null));
+ discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null,
+ null, null, null));
+ }
+ return discoveredResources;
+ } finally {
+ comp.close();
}
- return discoveredResources;
- }
+ }
}
\ No newline at end of file
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java
index 708c198..e7165fd 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java
@@ -26,6 +26,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.resource.ResourceType;
@@ -35,41 +36,47 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
-public class ApacheIfModuleDiscoveryComponent implements ResourceDiscoveryComponent<ApacheVirtualHostServiceComponent> {
+public class ApacheIfModuleDiscoveryComponent implements ResourceDiscoveryComponent<ApacheVirtualHostServiceComponent> {
- private static final String [] parentRes = {"<IfModule"};
+ private static final String[] parentRes = { "<IfModule" };
private static final String IFMODULE_NODE_NAME = "<IfModule";
private AugeasTree tree;
private AugeasNode parentNode;
-
+
public Set<DiscoveredResourceDetails> discoverResources(
ResourceDiscoveryContext<ApacheVirtualHostServiceComponent> context)
throws InvalidPluginConfigurationException, Exception {
-
- Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
- ApacheVirtualHostServiceComponent virtualHost = context.getParentResourceComponent();
-
- if (!virtualHost.isAugeasEnabled()){
- return discoveredResources;
- }
-
- tree = virtualHost.getServerConfigurationTree();
- parentNode = virtualHost.getNode(tree);
-
- List<AugeasNode> ifModuleNodes = AugeasNodeSearch.searchNode(parentRes, IFMODULE_NODE_NAME, parentNode);
-
-
- ResourceType resourceType = context.getResourceType();
- for (AugeasNode node : ifModuleNodes) {
-
- String resourceKey = AugeasNodeSearch.getNodeKey(node,parentNode);
- String [] paramArray = resourceKey.split("\\|");
- String resourceName = paramArray[1];
+ Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
+ ApacheVirtualHostServiceComponent virtualHost = context.getParentResourceComponent();
- discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null, null,
- null, null));
+ if (!virtualHost.isAugeasEnabled()) {
+ return discoveredResources;
}
- return discoveredResources;
- }
+ AugeasComponent comp = virtualHost.getAugeas();
+ AugeasTree tree = null;
+ try {
+
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+
+ parentNode = virtualHost.getNode(tree);
+
+ List<AugeasNode> ifModuleNodes = AugeasNodeSearch.searchNode(parentRes, IFMODULE_NODE_NAME, parentNode);
+
+ ResourceType resourceType = context.getResourceType();
+
+ for (AugeasNode node : ifModuleNodes) {
+
+ String resourceKey = AugeasNodeSearch.getNodeKey(node, parentNode);
+ String[] paramArray = resourceKey.split("\\|");
+ String resourceName = paramArray[1];
+
+ discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null,
+ null, null, null));
+ }
+ return discoveredResources;
+ } finally {
+ comp.close();
+ }
+ }
}
\ No newline at end of file
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
index 80b934b..c1f7260 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
@@ -38,10 +38,14 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.rhq.augeas.AugeasProxy;
+
+import org.rhq.augeas.AugeasComponent;
+import org.rhq.augeas.config.AugeasConfiguration;
import org.rhq.augeas.config.AugeasModuleConfig;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
+import org.rhq.augeas.tree.AugeasTreeBuilder;
+import org.rhq.augeas.tree.AugeasTreeException;
import org.rhq.augeas.util.Glob;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
@@ -66,6 +70,7 @@ import org.rhq.core.pluginapi.event.log.LogFileEventPoller;
import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.pluginapi.operation.OperationFacet;
@@ -99,8 +104,8 @@ import org.rhq.rhqtransform.AugeasRHQComponent;
* @author Ian Springer
* @author Lukas Krejci
*/
-public class ApacheServerComponent implements AugeasRHQComponent<PlatformComponent>, MeasurementFacet, OperationFacet,
- ConfigurationFacet, CreateChildResourceFacet {
+public class ApacheServerComponent implements AugeasRHQComponent, ResourceComponent<PlatformComponent>,
+ MeasurementFacet, OperationFacet, ConfigurationFacet, CreateChildResourceFacet {
public static final String CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE = "Configuration is supported only for Apache version 2 and up using Augeas. You either have an old version of Apache or Augeas is not installed.";
@@ -111,6 +116,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
public static final String PLUGIN_CONFIG_PROP_CONTROL_SCRIPT_PATH = "controlScriptPath";
public static final String PLUGIN_CONFIG_PROP_URL = "url";
public static final String PLUGIN_CONFIG_PROP_HTTPD_CONF = "configFile";
+ public static final String AUGEAS_HTTP_MODULE_NAME = "Httpd";
public static final String PLUGIN_CONFIG_PROP_SNMP_AGENT_HOST = "snmpAgentHost";
public static final String PLUGIN_CONFIG_PROP_SNMP_AGENT_PORT = "snmpAgentPort";
@@ -122,9 +128,9 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
public static final String PLUGIN_CONFIG_PROP_ERROR_LOG_INCLUDES_PATTERN = "errorLogIncludesPattern";
public static final String PLUGIN_CONFIG_PROP_VHOST_FILES_MASK = "vhostFilesMask";
public static final String PLUGIN_CONFIG_PROP_VHOST_CREATION_POLICY = "vhostCreationPolicy";
-
+
public static final String PLUGIN_CONFIG_PROP_RESTART_AFTER_CONFIG_UPDATE = "restartAfterConfigurationUpdate";
-
+
public static final String PLUGIN_CONFIG_VHOST_IN_SINGLE_FILE_PROP_VALUE = "single-file";
public static final String PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE = "vhost-per-file";
@@ -148,7 +154,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
private static final String[] CONTROL_SCRIPT_PATHS = { "bin/apachectl", "sbin/apachectl", "bin/apachectl2",
"sbin/apachectl2" };
-
+
private ResourceContext<PlatformComponent> resourceContext;
private EventContext eventContext;
private SNMPClient snmpClient;
@@ -173,14 +179,13 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
SNMPSession snmpSession = getSNMPSession();
if (!snmpSession.ping()) {
- log
- .warn("Failed to connect to SNMP agent at "
- + snmpSession
- + "\n"
- + ". Make sure\n1) the managed Apache server has been instrumented with the JON SNMP module,\n"
- + "2) the Apache server is running, and\n"
- + "3) the SNMP agent host, port, and community are set correctly in this resource's connection properties.\n"
- + "The agent will not be able to record metrics from apache httpd without SNMP");
+ log.warn("Failed to connect to SNMP agent at "
+ + snmpSession
+ + "\n"
+ + ". Make sure\n1) the managed Apache server has been instrumented with the JON SNMP module,\n"
+ + "2) the Apache server is running, and\n"
+ + "3) the SNMP agent host, port, and community are set correctly in this resource's connection properties.\n"
+ + "The agent will not be able to record metrics from apache httpd without SNMP");
} else {
configured = true;
}
@@ -191,11 +196,10 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
try {
this.url = new URL(url);
if (this.url.getPort() == 0) {
- log
- .error("The 'url' connection property is invalid - 0 is not a valid port; please change the value to the "
- + "port the \"main\" Apache server is listening on. NOTE: If the 'url' property was set this way "
- + "after autodiscovery, you most likely did not include the port in the ServerName directive for "
- + "the \"main\" Apache server in httpd.conf.");
+ log.error("The 'url' connection property is invalid - 0 is not a valid port; please change the value to the "
+ + "port the \"main\" Apache server is listening on. NOTE: If the 'url' property was set this way "
+ + "after autodiscovery, you most likely did not include the port in the ServerName directive for "
+ + "the \"main\" Apache server in httpd.conf.");
} else {
configured = true;
}
@@ -212,15 +216,15 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
File executablePath = getExecutablePath();
try {
- this.binaryInfo = ApacheBinaryInfo.getInfo(executablePath.getPath(), this.resourceContext
- .getSystemInformation());
+ this.binaryInfo = ApacheBinaryInfo.getInfo(executablePath.getPath(),
+ this.resourceContext.getSystemInformation());
} catch (Exception e) {
throw new InvalidPluginConfigurationException("'" + executablePath
+ "' is not a valid Apache executable (" + e + ").");
}
- this.operationsDelegate = new ApacheServerOperationsDelegate(this, pluginConfig, this.resourceContext
- .getSystemInformation());
+ this.operationsDelegate = new ApacheServerOperationsDelegate(this, pluginConfig,
+ this.resourceContext.getSystemInformation());
//init the module names with the defaults
moduleNames = new HashMap<String, String>(ApacheServerDiscoveryComponent.getDefaultModuleNames(binaryInfo.getVersion()));
@@ -335,31 +339,38 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
}
public Configuration loadResourceConfiguration() throws Exception {
+
if (!isAugeasEnabled())
throw new RuntimeException(CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
+ AugeasComponent comp = getAugeas();
try {
ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
.getResourceConfigurationDefinition();
- AugeasTree tree = getAugeasTree();
+ AugeasTree tree = comp.getAugeasTree(AUGEAS_HTTP_MODULE_NAME);
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
return mapping.updateConfiguration(tree.getRootNode(), resourceConfigDef);
} catch (Exception e) {
log.error("Failed to load Apache configuration.", e);
throw e;
+ } finally {
+ comp.close();
}
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
- if (!isAugeasEnabled()){
+ if (!isAugeasEnabled()) {
report.setStatus(ConfigurationUpdateStatus.FAILURE);
return;
}
+
+ AugeasComponent comp = getAugeas();
+
Configuration originalConfig = report.getConfiguration().deepCopy(true);
AugeasTree tree = null;
try {
- tree = getAugeasTree();
+ tree = comp.getAugeasTree(AUGEAS_HTTP_MODULE_NAME);
ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
.getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
@@ -369,183 +380,198 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
log.info("Apache configuration was updated");
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
-
+
finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null) {
log.error("Augeas failed to save configuration " + tree.summarizeAugeasError());
e = new AugeasException("Failed to save configuration: " + tree.summarizeAugeasError() + " ", e);
- }
- else
+ } else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
report.setErrorMessageFromThrowable(e);
if (!originalConfig.equals(report.getConfiguration())) {
log.error("Configuration has changed");
- }
- else {
+ } else {
log.error("Configuratio has not changed");
}
+ } finally {
+ comp.close();
}
- }
-
- public AugeasProxy getAugeasProxy() throws AugeasException {
- File tempDir = resourceContext.getDataDirectory();
- if (!tempDir.exists())
- throw new RuntimeException("Loading of lens failed");
- AugeasConfigurationApache config = new AugeasConfigurationApache(tempDir.getAbsolutePath(),resourceContext.getPluginConfiguration());
- AugeasTreeBuilderApache builder = new AugeasTreeBuilderApache();
- AugeasProxy augeasProxy = new AugeasProxy(config, builder);
- augeasProxy.load();
- return augeasProxy;
- }
-
- public AugeasTree getAugeasTree() throws AugeasException {
- AugeasProxy proxy = getAugeasProxy();
- String module = ((AugeasConfigurationApache)proxy.getConfiguration()).getAugeasModuleName();
-
- return proxy.getAugeasTree(module, true);
}
-
+
+ public AugeasComponent getAugeas() throws AugeasTreeException {
+ return new AugeasComponent() {
+
+ public AugeasConfiguration initConfiguration() {
+ File tempDir = resourceContext.getDataDirectory();
+ if (!tempDir.exists())
+ throw new RuntimeException("Loading of lens failed");
+ AugeasConfigurationApache config = new AugeasConfigurationApache(tempDir.getAbsolutePath(),
+ resourceContext.getPluginConfiguration());
+ return config;
+ }
+
+ public AugeasTreeBuilder initTreeBuilder() {
+ AugeasTreeBuilderApache builder = new AugeasTreeBuilderApache();
+ return builder;
+ }
+
+ };
+ }
+
public CreateResourceReport createResource(CreateResourceReport report) {
- if (!isAugeasEnabled()){
+ if (!isAugeasEnabled()) {
report.setStatus(CreateResourceStatus.FAILURE);
report.setErrorMessage("Resources can be created only when augeas is enabled.");
return report;
}
if (ApacheVirtualHostServiceComponent.RESOURCE_TYPE_NAME.equals(report.getResourceType().getName())) {
Configuration vhostResourceConfig = report.getResourceConfiguration();
- ConfigurationDefinition vhostResourceConfigDef = report.getResourceType().getResourceConfigurationDefinition();
+ ConfigurationDefinition vhostResourceConfigDef = report.getResourceType()
+ .getResourceConfigurationDefinition();
Configuration vhostPluginConfig = report.getPluginConfiguration();
-
+
String vhostDef = report.getUserSpecifiedResourceName();
- String serverName = vhostResourceConfig.getSimpleValue(ApacheVirtualHostServiceComponent.SERVER_NAME_CONFIG_PROP, null);
-
+ String serverName = vhostResourceConfig.getSimpleValue(
+ ApacheVirtualHostServiceComponent.SERVER_NAME_CONFIG_PROP, null);
+
//determine the resource key
String resourceKey = vhostDef;
if (serverName != null) {
resourceKey = serverName + "|" + resourceKey;
}
-
- //determine the resource name
- AugeasProxy proxy = getAugeasProxy();
- AugeasTree tree = getAugeasTree();
+
String[] vhostDefs = vhostDef.split(" ");
- HttpdAddressUtility.Address addr;
- try{
+ HttpdAddressUtility.Address addr;
+ try {
ApacheDirectiveTree parserTree = new ApacheDirectiveTree();
- ApacheParser parser = new ApacheParserImpl(parserTree,getServerRoot().getAbsolutePath());
-
+ ApacheParser parser = new ApacheParserImpl(parserTree, getServerRoot().getAbsolutePath());
+
ApacheConfigReader.buildTree(getHttpdConfFile().getAbsolutePath(), parser);
-
+
Pattern virtualHostPattern = Pattern.compile(".+:([\\d]+|\\*)");
Matcher matcher = virtualHostPattern.matcher(vhostDefs[0]);
if (!matcher.matches())
- throw new Exception("Wrong format of virtual host resource name. The right format is Address:Port.");
-
+ throw new Exception("Wrong format of virtual host resource name. The right format is Address:Port.");
+
addr = getAddressUtility().getVirtualHostSampleAddress(parserTree, vhostDefs[0], serverName, false);
} catch (Exception e) {
- report.setStatus(CreateResourceStatus.FAILURE);
- report.setErrorMessage("Wrong format of virtual host resource name.");
- report.setException(e);
- return report;
- }
-
+ report.setStatus(CreateResourceStatus.FAILURE);
+ report.setErrorMessage("Wrong format of virtual host resource name.");
+ report.setException(e);
+ return report;
+ }
+
String resourceName;
if (serverName != null) {
resourceName = addr.host + ":" + addr.port;
} else {
resourceName = resourceKey;
}
-
+
report.setResourceKey(resourceKey);
report.setResourceName(resourceName);
- //fill in the plugin config
- String url = "http://" + addr.host + ":" + addr.port + "/";
- vhostPluginConfig.put(new PropertySimple(ApacheVirtualHostServiceComponent.URL_CONFIG_PROP, url));
-
- //determine the sequence number of the new vhost
- List<AugeasNode> existingVhosts = tree.matchRelative(tree.getRootNode(), "<VirtualHost");
- int seq = existingVhosts.size() + 1;
-
- Configuration pluginConfig = resourceContext.getPluginConfiguration();
- String creationType = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_VHOST_CREATION_POLICY,
- PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE);
+ AugeasComponent comp = getAugeas();
+ //determine the resource name
- AugeasNode vhost = null;
- String vhostFile = proxy.getConfiguration().getModules().get(0).getConfigFiles().get(0);
-
- if (PLUGIN_CONFIG_VHOST_IN_SINGLE_FILE_PROP_VALUE.equals(creationType)) {
- vhost = tree.createNode(tree.getRootNode(), "<VirtualHost", null, seq);
- } else if (PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE.equals(creationType)) {
- String mask = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_VHOST_FILES_MASK, null);
- if (mask == null) {
- report.setErrorMessage("No virtual host file mask configured.");
- } else {
- vhostFile = getNewVhostFileName(addr, mask);
- File vhostFileFile = new File(vhostFile);
-
- //we're creating a new file here, so we must ensure that Augeas does have this file
- //on its load path, otherwise it will refuse to create it.
- AugeasConfigurationApache config = (AugeasConfigurationApache) proxy.getConfiguration();
- AugeasModuleConfig moduleConfig = config.getModuleByName(config.getAugeasModuleName());
- boolean willPersist = false;
- for(String glob : moduleConfig.getIncludedGlobs()) {
- if (Glob.matches(getServerRoot(), glob, vhostFileFile)) {
- willPersist = true;
- break;
+ AugeasTree tree;
+ try {
+
+ tree = comp.getAugeasTree(AUGEAS_HTTP_MODULE_NAME);
+ //fill in the plugin config
+ String url = "http://" + addr.host + ":" + addr.port + "/";
+ vhostPluginConfig.put(new PropertySimple(ApacheVirtualHostServiceComponent.URL_CONFIG_PROP, url));
+
+ //determine the sequence number of the new vhost
+ List<AugeasNode> existingVhosts = tree.matchRelative(tree.getRootNode(), "<VirtualHost");
+ int seq = existingVhosts.size() + 1;
+
+ Configuration pluginConfig = resourceContext.getPluginConfiguration();
+ String creationType = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_VHOST_CREATION_POLICY,
+ PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE);
+
+ AugeasNode vhost = null;
+
+ String vhostFile = comp.getConfiguration().getModules().get(0).getConfigFiles().get(0);
+
+ if (PLUGIN_CONFIG_VHOST_IN_SINGLE_FILE_PROP_VALUE.equals(creationType)) {
+ vhost = tree.createNode(tree.getRootNode(), "<VirtualHost", null, seq);
+ } else if (PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE.equals(creationType)) {
+ String mask = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_VHOST_FILES_MASK, null);
+ if (mask == null) {
+ report.setErrorMessage("No virtual host file mask configured.");
+ } else {
+ vhostFile = getNewVhostFileName(addr, mask);
+ File vhostFileFile = new File(vhostFile);
+
+ //we're creating a new file here, so we must ensure that Augeas does have this file
+ //on its load path, otherwise it will refuse to create it.
+ AugeasConfigurationApache config = (AugeasConfigurationApache) comp.getConfiguration();
+ AugeasModuleConfig moduleConfig = config.getModuleByName(config.getAugeasModuleName());
+ boolean willPersist = false;
+ for (String glob : moduleConfig.getIncludedGlobs()) {
+ if (Glob.matches(getServerRoot(), glob, vhostFileFile)) {
+ willPersist = true;
+ break;
+ }
}
- }
-
- if (!willPersist) {
- //the file wouldn't be loaded by augeas
- moduleConfig.addIncludedGlob(vhostFile);
- }
-
- try {
- vhostFileFile.createNewFile();
- } catch (IOException e) {
- log.error("Failed to create a new vhost file: " + vhostFile, e);
- }
-
- proxy.load();
- tree = proxy.getAugeasTree(moduleConfig.getModuletName(), true);
-
- vhost = tree.createNode(AugeasTree.AUGEAS_DATA_PATH + vhostFile + "/<VirtualHost");
- ((ApacheAugeasNode)vhost).setParentNode(tree.getRootNode());
-
- if (!willPersist) {
- //this also means that there was no include
- //that would load the file, so we have to
- //add the include directive to the main conf.
- List<AugeasNode> includes = tree.matchRelative(tree.getRootNode(), "Include");
- AugeasNode include = tree.createNode(tree.getRootNode(), "Include", null, includes.size() + 1);
- tree.createNode(include, "param", vhostFile, 0);
+
+ if (!willPersist) {
+ //the file wouldn't be loaded by augeas
+ moduleConfig.addIncludedGlob(vhostFile);
+ //this also means that there was no include
+ //that would load the file, so we have to
+ //add the include directive to the main conf.
+ List<AugeasNode> includes = tree.matchRelative(tree.getRootNode(), "Include");
+ AugeasNode include = tree.createNode(tree.getRootNode(), "Include", null,
+ includes.size() + 1);
+ tree.createNode(include, "param", vhostFile, 0);
+ tree.save();
+ }
+
+ try {
+ vhostFileFile.createNewFile();
+ } catch (IOException e) {
+ log.error("Failed to create a new vhost file: " + vhostFile, e);
+ }
+
+ comp.close();
+ comp = getAugeas();
+ tree = comp.getAugeasTree(moduleConfig.getModuletName());
+
+ vhost = tree.createNode(AugeasTree.AUGEAS_DATA_PATH + vhostFile + "/<VirtualHost");
+ ((ApacheAugeasNode) vhost).setParentNode(tree.getRootNode());
+
}
}
- }
-
- if (vhost == null) {
- report.setStatus(CreateResourceStatus.FAILURE);
- } else {
- try {
- for(int i = 0; i < vhostDefs.length; ++i) {
- tree.createNode(vhost, "param", vhostDefs[i], i + 1);
- }
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- mapping.updateAugeas(vhost, vhostResourceConfig, vhostResourceConfigDef);
-
- tree.save();
- report.setStatus(CreateResourceStatus.SUCCESS);
-
- finishChildResourceCreate(report);
- } catch (Exception e) {
+
+ if (vhost == null) {
report.setStatus(CreateResourceStatus.FAILURE);
- report.setException(e);
+ } else {
+ try {
+ for (int i = 0; i < vhostDefs.length; ++i) {
+ tree.createNode(vhost, "param", vhostDefs[i], i + 1);
+ }
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ mapping.updateAugeas(vhost, vhostResourceConfig, vhostResourceConfigDef);
+
+ tree.save();
+ report.setStatus(CreateResourceStatus.SUCCESS);
+
+ finishChildResourceCreate(report);
+ } catch (Exception e) {
+ report.setStatus(CreateResourceStatus.FAILURE);
+ report.setException(e);
+ }
}
+ } finally {
+ if (comp != null)
+ comp.close();
}
}
+
return report;
}
@@ -604,14 +630,14 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
if (executablePath != null) {
executableFile = resolvePathRelativeToServerRoot(executablePath);
} else {
- String serverRoot=null;
-
- ApacheDirectiveTree tree = loadParser();
- List<ApacheDirective> directives = tree.search("/ServerRoot");
- if (!directives.isEmpty())
- if (!directives.get(0).getValues().isEmpty())
- serverRoot = directives.get(0).getValues().get(0);
-
+ String serverRoot = null;
+
+ ApacheDirectiveTree tree = loadParser();
+ List<ApacheDirective> directives = tree.search("/ServerRoot");
+ if (!directives.isEmpty())
+ if (!directives.get(0).getValues().isEmpty())
+ serverRoot = directives.get(0).getValues().get(0);
+
SystemInfo systemInfo = this.resourceContext.getSystemInformation();
if (systemInfo.getOperatingSystemType() != OperatingSystemType.WINDOWS) // UNIX
{
@@ -635,10 +661,11 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
/**
* @return The url the server is pinged for availability or null if the url is not set.
*/
- public @Nullable String getServerUrl() {
+ public @Nullable
+ String getServerUrl() {
return resourceContext.getPluginConfiguration().getSimpleValue(PLUGIN_CONFIG_PROP_URL, null);
}
-
+
/**
* Returns the httpd.conf file
* @return A File object that represents the httpd.conf file or null in case of error
@@ -691,19 +718,20 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
}
}
}
-
+
//only try harder on the control script path on OSes with UNIX file system layout
- if (!found && resourceContext.getSystemInformation().getOperatingSystemType() != OperatingSystemType.WINDOWS) {
+ if (!found
+ && resourceContext.getSystemInformation().getOperatingSystemType() != OperatingSystemType.WINDOWS) {
String executablePath = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_EXECUTABLE_PATH, null);
if (executablePath != null) {
// this is now something like /usr/sbin/httpd .. trim off the last 2 parts
int i = executablePath.lastIndexOf(File.separatorChar);
-
+
if (i >= 0) {
executablePath = executablePath.substring(0, i);
i = executablePath.lastIndexOf(File.separatorChar);
}
-
+
if (i >= 0) {
executablePath = executablePath.substring(0, i);
for (String path : CONTROL_SCRIPT_PATHS) {
@@ -713,10 +741,10 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
break;
}
}
- }
+ }
}
}
-
+
if (!found) {
controlScriptFile = getExecutablePath(); // fall back to the httpd binary
}
@@ -727,11 +755,11 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
@NotNull
public ConfigurationTimestamp getConfigurationTimestamp() {
- AugeasConfigurationApache config = new AugeasConfigurationApache(resourceContext.getTemporaryDirectory().getAbsolutePath(),
- resourceContext.getPluginConfiguration());
+ AugeasConfigurationApache config = new AugeasConfigurationApache(resourceContext.getTemporaryDirectory()
+ .getAbsolutePath(), resourceContext.getPluginConfiguration());
return new ConfigurationTimestamp(config.getAllConfigurationFiles());
}
-
+
/**
* This method is supposed to be called from {@link #updateResourceConfiguration(ConfigurationUpdateReport)}
* of this resource and any child resources.
@@ -748,7 +776,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
report.setErrorMessageFromThrowable(e);
}
}
-
+
/**
* This method is akin to {@link #finishConfigurationUpdate(ConfigurationUpdateReport)} but should
* be used in the {@link #createResource(CreateResourceReport)} method.
@@ -763,7 +791,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
report.setException(e);
}
}
-
+
/**
* Conditionally restarts the server based on the settings in the plugin configuration of the server.
*
@@ -776,7 +804,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
operationsDelegate.invokeOperation("graceful_restart", new Configuration());
}
}
-
+
/**
* This method checks whether the supplied node that has been deleted from the tree didn't leave
* the file it was contained in empty.
@@ -787,7 +815,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
public void deleteEmptyFile(AugeasTree tree, AugeasNode deletedNode) {
File file = tree.getFile(deletedNode);
List<AugeasNode> fileContents = tree.match(file.getAbsolutePath() + AugeasTree.PATH_SEPARATOR + "*");
-
+
if (fileContents.size() == 0) {
file.delete();
}
@@ -913,13 +941,13 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
String version = getVersion();
return HttpdAddressUtility.get(version);
}
-
+
private String getNewVhostFileName(HttpdAddressUtility.Address address, String mask) {
String filename = address.host + "_" + address.port;
String fullPath = mask.replace("*", filename);
-
+
File file = getFileRelativeToServerRoot(fullPath);
-
+
int i = 1;
while (file.exists()) {
filename = address.host + "_" + address.port + "-" + (i++);
@@ -928,32 +956,31 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
}
return file.getAbsolutePath();
}
-
+
private File getFileRelativeToServerRoot(String path) {
File f = new File(path);
if (f.isAbsolute()) {
return f;
} else {
return new File(getServerRoot(), path);
- }
+ }
}
-
- public ApacheDirectiveTree loadParser(){
+
+ public ApacheDirectiveTree loadParser() {
ApacheDirectiveTree tree = new ApacheDirectiveTree();
- ApacheParser parser = new ApacheParserImpl(tree,getServerRoot().getAbsolutePath());
+ ApacheParser parser = new ApacheParserImpl(tree, getServerRoot().getAbsolutePath());
ApacheConfigReader.buildTree(getHttpdConfFile().getAbsolutePath(), parser);
- return tree;
+ return tree;
}
-
+
public boolean isAugeasEnabled() {
-
+
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
PropertySimple prop = pluginConfig.getSimple(AUGEAS_ENABLED);
- if (prop == null || prop.getStringValue() == null)
- {
+ if (prop == null || prop.getStringValue() == null) {
return false;
- }
-
+ }
+
String val = prop.getStringValue();
if (val.equals("yes")) {
@@ -961,7 +988,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
try {
ag = new Augeas();
} catch (Exception e) {
- log.error("Augeas is enabled in configuration but was not found on the system.");
+ log.error("Augeas is enabled in configuration but was not found on the system.", e);
throw new RuntimeException(CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
} finally {
if (ag != null) {
@@ -979,8 +1006,8 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
throw new RuntimeException(CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
}
return true;
- }else{
- return false;
+ } else {
+ return false;
}
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
index 9a56626..63b0637 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
@@ -34,6 +34,8 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
@@ -100,7 +102,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
private ConfigurationTimestamp lastConfigurationTimeStamp = new ConfigurationTimestamp();
public static final String RESOURCE_TYPE_NAME = "Apache Virtual Host";
-
+
public void start(ResourceContext<ApacheServerComponent> resourceContext) throws Exception {
this.resourceContext = resourceContext;
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
@@ -120,7 +122,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
+ "') is not a valid URL.");
}
}
-
+
ResponseTimeConfiguration responseTimeConfig = new ResponseTimeConfiguration(pluginConfig);
File logFile = responseTimeConfig.getLogFile();
if (logFile != null) {
@@ -142,20 +144,26 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
public Configuration loadResourceConfiguration() throws Exception {
ApacheServerComponent parent = resourceContext.getParentResourceComponent();
if (!parent.isAugeasEnabled())
- throw new Exception(ApacheServerComponent.CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
-
- AugeasTree tree = getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
- .getResourceConfigurationDefinition();
+ throw new Exception(ApacheServerComponent.CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- return mapping.updateConfiguration(getNode(tree), resourceConfigDef);
+ AugeasComponent comp = getAugeas();
+ try {
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
+
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ return mapping.updateConfiguration(getNode(tree), resourceConfigDef);
+ } finally {
+ comp.close();
+ }
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ AugeasComponent comp = getAugeas();
AugeasTree tree = null;
try {
- tree = getServerConfigurationTree();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
.getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
@@ -165,7 +173,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
log.info("Apache configuration was updated");
-
+
finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null)
@@ -173,31 +181,37 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ } finally {
+ comp.close();
}
}
public void deleteResource() throws Exception {
ApacheServerComponent parent = resourceContext.getParentResourceComponent();
if (!parent.isAugeasEnabled())
- throw new Exception(ApacheServerComponent.CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
-
+ throw new Exception(ApacheServerComponent.CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
+
if (MAIN_SERVER_RESOURCE_KEY.equals(resourceContext.getResourceKey())) {
- throw new IllegalArgumentException("Cannot delete the virtual host representing the main server configuration.");
+ throw new IllegalArgumentException(
+ "Cannot delete the virtual host representing the main server configuration.");
}
-
- AugeasTree tree = getServerConfigurationTree();
-
+
+ AugeasComponent comp = getAugeas();
+
try {
- AugeasNode myNode = getNode(getServerConfigurationTree());
-
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ AugeasNode myNode = getNode(tree);
+
tree.removeNode(myNode, true);
tree.save();
-
+
deleteEmptyFile(tree, myNode);
conditionalRestart();
} catch (IllegalStateException e) {
//this means we couldn't find the augeas node for this vhost.
//that error can be safely ignored in this situation.
+ } finally {
+ comp.close();
}
}
@@ -248,82 +262,106 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
}
public CreateResourceReport createResource(CreateResourceReport report) {
- if (!isAugeasEnabled()){
+ if (!isAugeasEnabled()) {
report.setStatus(CreateResourceStatus.FAILURE);
report.setErrorMessage("Resources can be created only when augeas is enabled.");
return report;
}
ResourceType resourceType = report.getResourceType();
-
- if (resourceType.equals(getDirectoryResourceType())) {
- Configuration resourceConfiguration = report.getResourceConfiguration();
- Configuration pluginConfiguration = report.getPluginConfiguration();
-
- String directoryName = report.getUserSpecifiedResourceName();
-
- //fill in the plugin configuration
-
- //get the directive index
- AugeasTree tree = getServerConfigurationTree();
- AugeasNode myNode = getNode(tree);
- List<AugeasNode> directories = myNode.getChildByLabel("<Directory");
- int seq = 1;
- /*
- * myNode will be parent node of the new Directory node.
- * We need to create a new node for directory node which will contain child nodes.
- * To create a node we can call method from AugeasTree which will create a node. In this method is
- * parameter sequence, if we will leave this parameter empty and there will be more nodes with
- * the same label, new node will be created but the method createNode will return node with index 0 resp 1.
- * If that will happen we can not update the node anymore because we are updating wrong node.
- * To avoid this situation we need to know what is the last sequence nr. of virtual host's child (directory) nodes.
- * We can not just count child nodes with the same label because some of the child nodes
- * could be stored in another file. So that in httpd configurationstructure they are child nodes of virtual host,
- * but in augeas configuration structure they can be child nodes of node Include[];.
- */
-
- for (AugeasNode n : directories) {
- String param = n.getFullPath();
- int end = param.lastIndexOf(File.separatorChar);
- if (end != -1)
- if (myNode.getFullPath().equals(param.substring(0,end)))
- seq++;
+ AugeasComponent comp = null;
+ try {
+ comp = getAugeas();
+ if (resourceType.equals(getDirectoryResourceType())) {
+ Configuration resourceConfiguration = report.getResourceConfiguration();
+ Configuration pluginConfiguration = report.getPluginConfiguration();
+
+ String directoryName = report.getUserSpecifiedResourceName();
+
+ //fill in the plugin configuration
+
+ //get the directive index
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ AugeasNode myNode = getNode(tree);
+ List<AugeasNode> directories = myNode.getChildByLabel("<Directory");
+ int seq = 1;
+ /*
+ * myNode will be parent node of the new Directory node.
+ * We need to create a new node for directory node which will contain child nodes.
+ * To create a node we can call method from AugeasTree which will create a node. In this method is
+ * parameter sequence, if we will leave this parameter empty and there will be more nodes with
+ * the same label, new node will be created but the method createNode will return node with index 0 resp 1.
+ * If that will happen we can not update the node anymore because we are updating wrong node.
+ * To avoid this situation we need to know what is the last sequence nr. of virtual host's child (directory) nodes.
+ * We can not just count child nodes with the same label because some of the child nodes
+ * could be stored in another file. So that in httpd configurationstructure they are child nodes of virtual host,
+ * but in augeas configuration structure they can be child nodes of node Include[];.
+ */
+
+ for (AugeasNode n : directories) {
+ String param = n.getFullPath();
+ int end = param.lastIndexOf(File.separatorChar);
+ if (end != -1)
+ if (myNode.getFullPath().equals(param.substring(0, end)))
+ seq++;
}
-
- //pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.DIRECTIVE_INDEX_PROP, seq));
- //we don't support this yet... need to figure out how...
- pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.REGEXP_PROP, false));
- String dirNameToSet = AugeasNodeValueUtil.escape(directoryName);
-
- //now actually create the data in augeas
- try {
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- AugeasNode directoryNode = tree.createNode(myNode, "<Directory", null, seq);
- tree.createNode(directoryNode, "param", dirNameToSet, 0);
- mapping.updateAugeas(directoryNode, resourceConfiguration, resourceType.getResourceConfigurationDefinition());
- tree.save();
-
-
- tree = getServerConfigurationTree();
- String key = AugeasNodeSearch.getNodeKey(myNode, directoryNode);
- report.setResourceKey(key);
- report.setResourceName(directoryName);
-
- report.setStatus(CreateResourceStatus.SUCCESS);
-
- resourceContext.getParentResourceComponent().finishChildResourceCreate(report);
- } catch (Exception e) {
- report.setException(e);
+
+ //pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.DIRECTIVE_INDEX_PROP, seq));
+ //we don't support this yet... need to figure out how...
+ pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.REGEXP_PROP, false));
+ String dirNameToSet = AugeasNodeValueUtil.escape(directoryName);
+
+ //now actually create the data in augeas
+ try {
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ AugeasNode directoryNode = tree.createNode(myNode, "<Directory", null, seq);
+ String myNodeKey = AugeasNodeSearch.getNodeKey(myNode, tree.getRootNode());
+ tree.createNode(directoryNode, "param", dirNameToSet, 0);
+ mapping.updateAugeas(directoryNode, resourceConfiguration,
+ resourceType.getResourceConfigurationDefinition());
+
+ tree.save();
+ comp.close();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+
+ AugeasNode parentNode;
+ if (myNodeKey.equals("")) {
+ parentNode = tree.getRootNode();
+ } else
+ parentNode = AugeasNodeSearch.findNodeById(tree.getRootNode(), myNodeKey);
+
+ List<AugeasNode> nodes = parentNode.getChildByLabel("<Directory");
+ if (nodes.size() < seq) {
+ report.setStatus(CreateResourceStatus.FAILURE);
+ report.setErrorMessage("Could not create directory node.");
+ }
+
+ AugeasNode nd = nodes.get(seq - 1);
+ String key = AugeasNodeSearch.getNodeKey(nd, parentNode);
+
+ report.setResourceKey(key);
+ report.setResourceName(directoryName);
+
+ report.setStatus(CreateResourceStatus.SUCCESS);
+
+ resourceContext.getParentResourceComponent().finishChildResourceCreate(report);
+ } catch (Exception e) {
+ log.error("Could not create httpd virtual host child resource.", e);
+ report.setException(e);
+ report.setStatus(CreateResourceStatus.FAILURE);
+ }
+ } else {
+ report.setErrorMessage("Unable to create resources of type " + resourceType.getName());
report.setStatus(CreateResourceStatus.FAILURE);
}
- } else {
- report.setErrorMessage("Unable to create resources of type " + resourceType.getName());
- report.setStatus(CreateResourceStatus.FAILURE);
+ } finally {
+ if (comp != null)
+ comp.close();
}
return report;
}
-
- public AugeasTree getServerConfigurationTree() {
- return resourceContext.getParentResourceComponent().getAugeasTree();
+
+ public AugeasComponent getAugeas() {
+ return resourceContext.getParentResourceComponent().getAugeas();
}
/**
@@ -388,7 +426,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
public void finishConfigurationUpdate(ConfigurationUpdateReport report) {
resourceContext.getParentResourceComponent().finishConfigurationUpdate(report);
}
-
+
/**
* @see ApacheServerComponent#conditionalRestart()
*
@@ -397,11 +435,11 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
public void conditionalRestart() throws Exception {
resourceContext.getParentResourceComponent().conditionalRestart();
}
-
+
public void deleteEmptyFile(AugeasTree tree, AugeasNode deletedNode) {
resourceContext.getParentResourceComponent().deleteEmptyFile(tree, deletedNode);
}
-
+
private void collectSnmpMetric(MeasurementReport report, int primaryIndex, SNMPSession snmpSession,
MeasurementScheduleRequest schedule) throws SNMPException {
SNMPValue snmpValue = null;
@@ -474,13 +512,13 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
private ResourceType getDirectoryResourceType() {
return resourceContext.getResourceType().getChildResourceTypes().iterator().next();
}
-
- public ApacheDirectiveTree loadParser() throws Exception{
+
+ public ApacheDirectiveTree loadParser() throws Exception {
return resourceContext.getParentResourceComponent().loadParser();
}
-
- public boolean isAugeasEnabled(){
+
+ public boolean isAugeasEnabled() {
ApacheServerComponent parent = resourceContext.getParentResourceComponent();
- return parent.isAugeasEnabled();
+ return parent.isAugeasEnabled();
}
}
\ No newline at end of file
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasComponent.java
new file mode 100644
index 0000000..d41490f
--- /dev/null
+++ b/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasComponent.java
@@ -0,0 +1,52 @@
+package org.rhq.augeas;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.augeas.config.AugeasConfiguration;
+import org.rhq.augeas.tree.AugeasTree;
+import org.rhq.augeas.tree.AugeasTreeBuilder;
+
+public abstract class AugeasComponent {
+
+ AugeasProxy augeasProxy;
+ boolean isClosed = true;
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public abstract AugeasConfiguration initConfiguration();
+
+ public abstract AugeasTreeBuilder initTreeBuilder();
+
+ protected void reloadAugeas() {
+ if (!isClosed)
+ close();
+
+ augeasProxy = new AugeasProxy(initConfiguration(), initTreeBuilder());
+ augeasProxy.load();
+ isClosed = false;
+ }
+
+ public AugeasTree getAugeasTree(String moduleName) {
+ reloadAugeas();
+ return augeasProxy.getAugeasTree(moduleName, true);
+ }
+
+ public void close() {
+ isClosed = true;
+ if (augeasProxy != null) {
+ try {
+ augeasProxy.close();
+ } catch (Exception e) {
+ log.error("Could not close augeas instance", e);
+ }
+ }
+ }
+
+ public AugeasConfiguration getConfiguration() {
+ if (augeasProxy == null)
+ throw new RuntimeException("Could not provide augeas configuration because augeas was not initialized yet.");
+
+ return augeasProxy.getConfiguration();
+ }
+
+}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java b/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java
index 5d96389..81c7c2e 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java
@@ -23,7 +23,6 @@
package org.rhq.augeas;
import java.io.File;
-import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@@ -32,13 +31,13 @@ import net.augeas.AugeasException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.rhq.augeas.config.AugeasConfiguration;
import org.rhq.augeas.config.AugeasModuleConfig;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.augeas.tree.AugeasTreeBuilder;
import org.rhq.augeas.tree.AugeasTreeException;
import org.rhq.augeas.tree.impl.DefaultAugeasTreeBuilder;
-import org.rhq.plugins.augeas.AugeasPluginLifecycleListener;
/**
* This is the main entry point for interfacing with Augeas.
@@ -53,13 +52,13 @@ import org.rhq.plugins.augeas.AugeasPluginLifecycleListener;
*
*/
public class AugeasProxy {
-
- private final Log log = LogFactory.getLog(this.getClass());
+
+ private final Log log = LogFactory.getLog(this.getClass());
private AugeasConfiguration config;
private Augeas augeas;
private List<String> modules;
private AugeasTreeBuilder augeasTreeBuilder;
-
+
/**
* Instantiates new proxy with supplied configuration and
* {@link DefaultAugeasTreeBuilder} as the tree builder.
@@ -99,13 +98,20 @@ public class AugeasProxy {
public void load() throws AugeasTreeException {
try {
config.loadFiles();
+ if (augeas != null) {
+ try {
+ augeas.close();
+ } catch (Exception e) {
+ log.error("Could not close augeas instance", e);
+ }
+ }
augeas = new Augeas(config.getRootPath(), config.getLoadPath(), config.getMode());
-
+
for (AugeasModuleConfig module : config.getModules()) {
-
+
modules.add(module.getModuletName());
augeas.set("/augeas/load/" + module.getModuletName() + "/lens", module.getLensPath());
-
+
int idx = 1;
for (String incl : module.getConfigFiles()) {
augeas.set("/augeas/load/" + module.getModuletName() + "/incl[" + (idx++) + "]", incl);
@@ -132,8 +138,6 @@ public class AugeasProxy {
throw new AugeasException(e);
}
}
-
-
/**
* Produces the Augeas tree by loading it from augeas (if {@link #load()} wasn't called already)
@@ -192,4 +196,24 @@ public class AugeasProxy {
public Augeas getAugeas() {
return augeas;
}
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#finalize()
+ */
+ @Override
+ protected void finalize() throws Throwable {
+ close();
+ super.finalize();
+ }
+
+ public void close() {
+ if (augeas != null) {
+ try {
+ augeas.close();
+ } catch (Exception e) {
+ log.error("Could not close augeas instance", e);
+ }
+ augeas = null;
+ }
+ }
}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
index 6770503..54044b1 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
@@ -130,41 +130,45 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
public Configuration loadResourceConfiguration() throws Exception {
abortIfAugeasNotAvailable();
- // Load the config file from disk and build a tree representation of it.
- loadConfigurationFiles(this.augeas);
+ //augeas was initialized in abortIfAugeasNotAvailable();
+ try {
+ ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
+ Configuration resourceConfig = new Configuration();
+ resourceConfig.setNotes("Loaded from Augeas at " + new Date());
- ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
- .getResourceConfigurationDefinition();
- Configuration resourceConfig = new Configuration();
- resourceConfig.setNotes("Loaded from Augeas at " + new Date());
+ Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
- Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
+ for (PropertyDefinition propDef : propDefs) {
+ loadProperty(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
+ }
- for (PropertyDefinition propDef : propDefs) {
- loadProperty(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
+ // This will add error messages to any PropertySimples with invalid values, so they can be displayed by the GUI.
+ validateResourceConfiguration(new ConfigurationUpdateReport(resourceConfig));
+ return resourceConfig;
+ } finally {
+ close();
}
-
- // This will add error messages to any PropertySimples with invalid values, so they can be displayed by the GUI.
- validateResourceConfiguration(new ConfigurationUpdateReport(resourceConfig));
- return resourceConfig;
}
protected void updateStructuredConfiguration(Configuration config) throws Exception {
abortIfAugeasNotAvailable();
- // Load the config files from disk and build a tree representation of them in memory.
- loadConfigurationFiles(this.augeas);
+ //augeas was initialized in abortIfAugeasNotAvailable
+ try {
+ ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
- ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
- .getResourceConfigurationDefinition();
+ Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
+ for (PropertyDefinition propDef : propDefs) {
+ setNode(propDef, config, this.augeas, this.resourceConfigRootNode);
+ }
- Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
- for (PropertyDefinition propDef : propDefs) {
- setNode(propDef, config, this.augeas, this.resourceConfigRootNode);
+ // Write the updated tree out to the config file.
+ saveConfigurationFiles();
+ } finally {
+ close();
}
-
- // Write the updated tree out to the config file.
- saveConfigurationFiles();
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
@@ -179,26 +183,29 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
log.debug("Validation of updated Resource configuration for " + this.resourceDescription
+ " failed with the following errors: " + report.getErrorMessage());
report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ close();
return;
}
- // Load the config files from disk and build a tree representation of them in memory.
- loadConfigurationFiles(this.augeas);
-
- ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
- .getResourceConfigurationDefinition();
- Configuration resourceConfig = report.getConfiguration();
+ //augeas was initialized in abortIfAugeasNotAvailable();
+ try {
+ ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
+ Configuration resourceConfig = report.getConfiguration();
- Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
- for (PropertyDefinition propDef : propDefs) {
- setNode(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
- }
+ Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
+ for (PropertyDefinition propDef : propDefs) {
+ setNode(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
+ }
- // Write the updated tree out to the config file.
- saveConfigurationFiles();
+ // Write the updated tree out to the config file.
+ saveConfigurationFiles();
- // If we got this far, we've succeeded in our mission.
- report.setStatus(ConfigurationUpdateStatus.SUCCESS);
+ // If we got this far, we've succeeded in our mission.
+ report.setStatus(ConfigurationUpdateStatus.SUCCESS);
+ } finally {
+ close();
+ }
}
public CreateResourceReport createResource(CreateResourceReport report) {
@@ -206,37 +213,47 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
ConfigurationDefinition resourceConfigDef = report.getResourceType().getResourceConfigurationDefinition();
// First insert the root node corresponding to the new child Resource.
- String rootPath = getChildResourceConfigurationRootPath(report.getResourceType(), report
- .getResourceConfiguration());
- AugeasNode rootNode = new AugeasNode(rootPath);
- if (this.augeas.exists(rootNode.getPath())) {
- report.setStatus(CreateResourceStatus.FAILURE);
- report.setErrorMessage("An Augeas node already exists with path " + rootPath);
- return report;
- }
- String rootLabel = getChildResourceConfigurationRootLabel(report.getResourceType(), report
- .getResourceConfiguration());
- this.augeas.set(rootNode.getPath(), rootLabel);
-
- // Then set all its child nodes.
- Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
- for (PropertyDefinition propDef : propDefs) {
- setNode(propDef, resourceConfig, this.augeas, rootNode);
- }
+ String rootPath = getChildResourceConfigurationRootPath(report.getResourceType(),
+ report.getResourceConfiguration());
+ initAugeas();
+ try {
+ AugeasNode rootNode = new AugeasNode(rootPath);
+ if (this.augeas.exists(rootNode.getPath())) {
+ report.setStatus(CreateResourceStatus.FAILURE);
+ report.setErrorMessage("An Augeas node already exists with path " + rootPath);
+ return report;
+ }
+ String rootLabel = getChildResourceConfigurationRootLabel(report.getResourceType(),
+ report.getResourceConfiguration());
+ this.augeas.set(rootNode.getPath(), rootLabel);
+
+ // Then set all its child nodes.
+ Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
+ for (PropertyDefinition propDef : propDefs) {
+ setNode(propDef, resourceConfig, this.augeas, rootNode);
+ }
- // Write the updated tree out to the config file.
- saveConfigurationFiles();
+ // Write the updated tree out to the config file.
+ saveConfigurationFiles();
- // If we got this far, we've succeeded in our mission.
- report.setStatus(CreateResourceStatus.SUCCESS);
- return report;
+ // If we got this far, we've succeeded in our mission.
+ report.setStatus(CreateResourceStatus.SUCCESS);
+ return report;
+ } finally {
+ close();
+ }
}
public void deleteResource() throws Exception {
String rootPath = getResourceConfigurationRootPath();
- Augeas augeas = getAugeas();
- augeas.remove(rootPath);
- augeas.save();
+ initAugeas();
+ try {
+ Augeas augeas = getAugeas();
+ augeas.remove(rootPath);
+ augeas.save();
+ } finally {
+ close();
+ }
}
/**
@@ -317,7 +334,14 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
return files;
}
+ /**
+ * Returns initialized augeas instance. Augeas instance must be closed by calling method close on the Augeas instance
+ * or by calling method close on AugeasConfigurationComponent instance after use of augeas.
+ * @return
+ */
public Augeas getAugeas() {
+ if (this.augeas == null)
+ initAugeas();
return this.augeas;
}
@@ -343,7 +367,6 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
try {
augeas = new Augeas(this.augeasRootPath, AUGEAS_LOAD_PATH, Augeas.NO_MODL_AUTOLOAD);
setupAugeasModules(augeas);
- loadConfigurationFiles(augeas);
} catch (RuntimeException e) {
if (augeas != null) {
try {
@@ -625,14 +648,6 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
return mapKeyNames.getSimpleValue(listName, null);
}
- private void loadConfigurationFiles(Augeas augeas) {
- try {
- augeas.load();
- } catch (AugeasException e) {
- throw new RuntimeException(summarizeAugeasError(augeas), e);
- }
- }
-
private void saveConfigurationFiles() {
// TODO: Backup original file.
try {
@@ -682,8 +697,8 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
List<String> nodePaths = augeas.match(errorNode.getPath() + "/*");
for (String path : nodePaths) {
String error = augeas.get(path);
- summary.append("File \"").append(path.substring(metadataNodePrefix.length(), path.length())).append(
- "\":\n").append(error).append("\n");
+ summary.append("File \"").append(path.substring(metadataNodePrefix.length(), path.length()))
+ .append("\":\n").append(error).append("\n");
}
}
@@ -691,7 +706,15 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
}
protected void initAugeas() {
+ if (this.augeas != null) {
+ try {
+ this.augeas.close();
+ } catch (Exception e) {
+ }
+ this.augeas = null;
+ }
this.augeas = createAugeas();
+ this.augeas.load();
String resourceConfigRootPath = getResourceConfigurationRootPath();
if (resourceConfigRootPath.indexOf(AugeasNode.SEPARATOR_CHAR) != 0) {
// root path is relative - make it absolute
@@ -701,6 +724,7 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
this.resourceConfigRootNode = new AugeasNode(resourceConfigRootPath);
}
log.debug("Resource Config Root Node = \"" + this.resourceConfigRootNode + "\"");
+
}
private void abortIfAugeasNotAvailable() throws Exception {
@@ -724,4 +748,23 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
}
}
}
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#finalize()
+ */
+ @Override
+ protected void finalize() throws Throwable {
+ close();
+ super.finalize();
+ }
+
+ public void close() {
+ if (this.augeas != null) {
+ try {
+ this.augeas.close();
+ } catch (Exception e) {
+ }
+ this.augeas = null;
+ }
+ }
}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java
index 7660de2..05e7bc4 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java
@@ -23,11 +23,8 @@
package org.rhq.rhqtransform;
-import org.rhq.augeas.AugeasProxy;
-import org.rhq.augeas.tree.AugeasTree;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.tree.AugeasTreeException;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-
/**
* An interface the RHQ resource components can implement to provide access
@@ -36,20 +33,7 @@ import org.rhq.core.pluginapi.inventory.ResourceComponent;
* @author Filip Drabek
*
*/
-public interface AugeasRHQComponent<T extends ResourceComponent> extends ResourceComponent<T> {
-
- /**
- * @return the augeas tree for the component
- * @throws AugeasTreeException
- */
- public AugeasTree getAugeasTree() throws AugeasTreeException;
+public interface AugeasRHQComponent {
- /**
- * Provides access to the Augeas proxy configured in the way this component needs
- * so that users are able to perform non-trivial operations on it.
- *
- * @return
- * @throws AugeasTreeException
- */
- public AugeasProxy getAugeasProxy() throws AugeasTreeException;
+ public AugeasComponent getAugeas() throws AugeasTreeException;
}
diff --git a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
index ae22c2f..cfc1799 100644
--- a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
+++ b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
@@ -25,6 +25,7 @@ import java.util.List;
import net.augeas.Augeas;
import net.augeas.AugeasException;
+import org.rhq.augeas.util.GlobFilter;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.Property;
@@ -41,7 +42,6 @@ import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.plugins.augeas.AugeasConfigurationComponent;
import org.rhq.plugins.augeas.AugeasConfigurationDiscoveryComponent;
import org.rhq.plugins.augeas.helper.AugeasNode;
-import org.rhq.augeas.util.GlobFilter;
import org.rhq.plugins.platform.PlatformComponent;
/**
@@ -53,7 +53,7 @@ import org.rhq.plugins.platform.PlatformComponent;
public class CronComponent extends AugeasConfigurationComponent<PlatformComponent> implements CreateChildResourceFacet {
private static final String HOURLY_JOBS_PROP = "hourlyJobs";
- private static final String HOURLY_JOBS_NODE = "entry[time/minute != \"*\" and time/hour = \"*\" and time/dayofmonth = \"*\" and time/month = \"*\" and time/dayofweek = \"*\"]";
+ private static final String HOURLY_JOBS_NODE = "entry[time/minute != \"*\" and time/hour = \"*\" and time/dayofmonth = \"*\" and time/month = \"*\" and time/dayofweek = \"*\"]";
private static final String DAILY_JOBS_PROP = "dailyJobs";
private static final String DAILY_JOBS_NODE = "entry[time/minute != \"*\" and time/hour != \"*\" and time/dayofmonth = \"*\" and time/month = \"*\" and time/dayofweek = \"*\"]";
private static final String WEEKLY_JOBS_PROP = "weeklyJobs";
@@ -67,7 +67,7 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
private static final String AUGEAS_FILES_PREFIX = "/files";
private static final int AUGEAS_FILES_PREFIX_LENGTH = AUGEAS_FILES_PREFIX.length();
private static final String CRONTAB_RESOURCE_TYPE_NAME = "Cron Tab";
-
+
@Override
protected String getResourceConfigurationRootPath() {
return "/files/"; //the trailing slash is intentional so that we can get the
@@ -77,7 +77,8 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
public CreateResourceReport createResource(CreateResourceReport report) {
if (CRONTAB_RESOURCE_TYPE_NAME.equals(report.getResourceType().getName())) {
try {
- String resourceKey = createCrontab(report.getUserSpecifiedResourceName(), report.getResourceType().getResourceConfigurationDefinition(), report.getResourceConfiguration());
+ String resourceKey = createCrontab(report.getUserSpecifiedResourceName(), report.getResourceType()
+ .getResourceConfigurationDefinition(), report.getResourceConfiguration());
report.setResourceName(resourceKey);
report.setResourceKey(resourceKey);
report.setStatus(CreateResourceStatus.SUCCESS);
@@ -130,7 +131,7 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
private String getEntryCrontabPath(AugeasNode crontabNode) {
//the node's path is /files/blah/blah/entry/..
//we want the /blah/blah part
- return crontabNode.getParent().getParent().getPath().substring(AUGEAS_FILES_PREFIX_LENGTH);
+ return crontabNode.getParent().getParent().getPath().substring(AUGEAS_FILES_PREFIX_LENGTH);
}
/**
@@ -139,65 +140,71 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
* @param resourceConfiguration
* @return the resource key of the crontab
*/
- private String createCrontab(String resourceName, ConfigurationDefinition configurationDefinition, Configuration resourceConfiguration) {
+ private String createCrontab(String resourceName, ConfigurationDefinition configurationDefinition,
+ Configuration resourceConfiguration) {
File crontabFile = new File(resourceName);
-
+
try {
if (!crontabFile.createNewFile()) {
- throw new RuntimeException("File " + resourceName + " already exists. Creating the crontab would overwrite it.");
+ throw new RuntimeException("File " + resourceName
+ + " already exists. Creating the crontab would overwrite it.");
}
} catch (IOException e) {
throw new RuntimeException("Failed to create the crontab file named: " + resourceName);
}
-
+
//check that the crontab's name passes the glob filters
Configuration pluginConfiguration = getResourceContext().getPluginConfiguration();
-
- List<String> includeGlobs = AugeasConfigurationDiscoveryComponent.getGlobList(pluginConfiguration.getSimple(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP));
- List<String> excludeGlobs = AugeasConfigurationDiscoveryComponent.getGlobList(pluginConfiguration.getSimple(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP));
+
+ List<String> includeGlobs = AugeasConfigurationDiscoveryComponent.getGlobList(pluginConfiguration
+ .getSimple(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP));
+ List<String> excludeGlobs = AugeasConfigurationDiscoveryComponent.getGlobList(pluginConfiguration
+ .getSimple(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP));
boolean isIncluded = false;
-
- for(String include : includeGlobs) {
+
+ for (String include : includeGlobs) {
if (new GlobFilter(include).accept(crontabFile)) {
isIncluded = true;
break;
}
}
-
- String errorText = "Given Cron tab file name would be created outside of mapped filters. See the Cron resource connection properties for the inclusion and exclusion filters set up.";
+
+ String errorText = "Given Cron tab file name would be created outside of mapped filters. See the Cron resource connection properties for the inclusion and exclusion filters set up.";
if (!isIncluded) {
throw new IllegalArgumentException(errorText);
}
-
- for(String exclude : excludeGlobs) {
+
+ for (String exclude : excludeGlobs) {
if (new GlobFilter(exclude).accept(crontabFile)) {
throw new IllegalArgumentException(errorText);
}
}
-
+
updateCrontab(resourceName, configurationDefinition, resourceConfiguration);
-
+
return resourceName;
}
-
- protected void updateCrontab(String crontabPath, ConfigurationDefinition crontabConfigurationDefinition, Configuration crontabConfiguration) {
- Augeas augeas = getAugeas();
+
+ protected void updateCrontab(String crontabPath, ConfigurationDefinition crontabConfigurationDefinition,
+ Configuration crontabConfiguration) {
+ Augeas augeas = null;
try {
- augeas.load();
-
+ augeas = getAugeas();
+
File crontabFile = new File(crontabPath);
String basePath = AUGEAS_FILES_PREFIX + crontabFile.getAbsolutePath();
AugeasNode baseNode = new AugeasNode(basePath);
-
+
PropertyList entries = crontabConfiguration.getList(CronTabComponent.ENTRIES_PROP);
- PropertyDefinitionList entriesDef = crontabConfigurationDefinition.getPropertyDefinitionList(CronTabComponent.ENTRIES_PROP);
+ PropertyDefinitionList entriesDef = crontabConfigurationDefinition
+ .getPropertyDefinitionList(CronTabComponent.ENTRIES_PROP);
setNodeFromPropertyList(entriesDef, entries, augeas, baseNode);
-
+
PropertyList settings = crontabConfiguration.getList(CronTabComponent.ENVIRONMENT_SETTINGS_PROP);
if (settings != null) {
- for(Property p : settings.getList()) {
- PropertyMap setting = (PropertyMap)p;
+ for (Property p : settings.getList()) {
+ PropertyMap setting = (PropertyMap) p;
String name = setting.getSimpleValue(CronTabComponent.NAME_PROP, null);
String value = setting.getSimpleValue(CronTabComponent.VALUE_PROP, "");
if (name != null) {
@@ -206,10 +213,15 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
}
}
}
-
+
augeas.save();
} catch (AugeasException e) {
- throw new RuntimeException(summarizeAugeasError(augeas), e);
+ if (augeas != null)
+ throw new RuntimeException(summarizeAugeasError(augeas), e);
+ else
+ throw new RuntimeException(e);
+ } finally {
+ close();
}
- }
+ }
}
diff --git a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
index dd29e6e..3f59718 100644
--- a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
+++ b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
@@ -78,7 +78,7 @@ public class HostsComponent extends AugeasConfigurationComponent {
@Override
public Configuration loadResourceConfiguration() throws Exception {
Configuration resourceConfig;
- if (getAugeas() != null) {
+ if (isAugeasAvailable()) {
resourceConfig = super.loadResourceConfiguration();
} else {
resourceConfig = new NonAugeasHostsConfigurationDelegate(this).loadResourceConfiguration();
@@ -90,7 +90,7 @@ public class HostsComponent extends AugeasConfigurationComponent {
@Override
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
- if (getAugeas() != null) {
+ if (isAugeasAvailable()) {
super.updateResourceConfiguration(report);
} else {
if (!validateResourceConfiguration(report)) {
diff --git a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java
index c123e86..7524a93 100644
--- a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java
+++ b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java
@@ -18,19 +18,18 @@ GNU General Public License for more details.
*/
package org.rhq.plugins.samba;
+import java.util.List;
+
import net.augeas.Augeas;
+
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.resource.CreateResourceHistory;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.plugins.augeas.AugeasConfigurationComponent;
import org.rhq.plugins.augeas.helper.AugeasNode;
-import java.util.List;
-
/**
* TODO
*/
@@ -52,7 +51,7 @@ public class SambaShareComponent extends AugeasConfigurationComponent<SambaServe
String targetPath = "/files/etc/samba/smb.conf/target[.='" + targetName + "']";
AugeasNode targetNode = new AugeasNode(targetPath);
Augeas augeas = getAugeas();
- augeas.load();
+
List<String> matches = augeas.match(targetNode.getPath());
return matches.get(0);
}
@@ -62,7 +61,7 @@ public class SambaShareComponent extends AugeasConfigurationComponent<SambaServe
}
public AvailabilityType getAvailability() {
- return super.getAvailability();
+ return super.getAvailability();
}
public Configuration loadResourceConfiguration() throws Exception {
@@ -78,7 +77,15 @@ public class SambaShareComponent extends AugeasConfigurationComponent<SambaServe
}
public void deleteResource() throws Exception {
- super.deleteResource();
+ initAugeas();
+ String rootPath = getResourceConfigurationRootPath();
+ try {
+ Augeas augeas = getAugeas();
+ augeas.remove(rootPath);
+ augeas.save();
+ } finally {
+ close();
+ }
}
}
diff --git a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java
index 5fc3b4f..34809b7 100644
--- a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java
+++ b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java
@@ -18,49 +18,47 @@
*/
package org.rhq.plugins.samba;
-import java.util.Set;
-import java.util.List;
import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import net.augeas.Augeas;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
public class SambaShareDiscoveryComponent implements ResourceDiscoveryComponent<SambaServerComponent> {
-
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<SambaServerComponent> discoveryContext)
- throws InvalidPluginConfigurationException, Exception {
+ public Set<DiscoveredResourceDetails> discoverResources(
+ ResourceDiscoveryContext<SambaServerComponent> discoveryContext) throws InvalidPluginConfigurationException,
+ Exception {
Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>();
SambaServerComponent serverComponent = discoveryContext.getParentResourceComponent();
- Augeas augeas = serverComponent.getAugeas();
- augeas.load();
+ Augeas augeas = null;
+ try {
+ augeas = serverComponent.getAugeas();
+
+ List<String> matches = augeas.match("/files/etc/samba/smb.conf/target[. != 'global']");
+ for (String match : matches) {
+ String name = augeas.get(match);
+ Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration();
+ pluginConfig.put(new PropertySimple("targetName", name));
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(discoveryContext.getResourceType(),
+ name, name + " share", null, "Samba Share [" + name + "]", pluginConfig, null);
+ details.add(detail);
+ }
- List<String> matches = augeas.match("/files/etc/samba/smb.conf/target[. != 'global']");
- for (String match : matches) {
- String name = augeas.get(match);
- Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration();
- pluginConfig.put(new PropertySimple("targetName", name));
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- discoveryContext.getResourceType(),
- name,
- name + " share",
- null,
- "Samba Share [" + name + "]",
- pluginConfig,
- null
- );
- details.add(detail);
+ return details;
+ } finally {
+ if (serverComponent != null)
+ serverComponent.close();
}
-
- return details;
}
}
12 years, 10 months
[rhq] modules/core
by Heiko W. Rupp
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java | 15 ++++++----
1 file changed, 9 insertions(+), 6 deletions(-)
New commits:
commit cfd92234978464c9c724ade77627aa5fea6dcf5e
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Aug 4 13:50:09 2011 +0200
Prevent possible NPE that makes agent startup fail.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
index 879ceca..3f10089 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
@@ -7,6 +7,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
+import java.util.Set;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.zip.ZipEntry;
@@ -88,9 +89,11 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
}
log.debug("Rescheduling drift detection schedules for " + r);
- for (DriftDetectionSchedule schedule : container.getDriftSchedules()) {
- schedulesQueue.addSchedule(schedule);
- }
+ Set<DriftDetectionSchedule> driftSchedules = container.getDriftSchedules();
+ if (driftSchedules!=null)
+ for (DriftDetectionSchedule schedule : driftSchedules) {
+ schedulesQueue.addSchedule(schedule);
+ }
for (Resource child : r.getChildResources()) {
initSchedules(child, inventoryMgr);
@@ -252,7 +255,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
*
* @param resourceId The id of the resource to which the config belongs
* @param driftConfiguration describes what is to be monitored for drift
- *
+ *
* @return absolute directory location where the drift configuration base directory is referring
*/
@Override
@@ -323,7 +326,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
/**
* Returns the manager that can provide data on the inventory. This is a separate protected method
* so we can extend our manger class to have a mock manager for testing.
- *
+ *
* @return the inventory manager
*/
protected InventoryManager getInventoryManager() {
@@ -333,7 +336,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
/**
* Returns the manager that can provide data on the measurements/metrics. This is a separate protected method
* so we can extend our manger class to have a mock manager for testing.
- *
+ *
* @return the inventory manager
*/
protected MeasurementManager getMeasurementManager() {
12 years, 10 months
[rhq] 3 commits - modules/integration-tests modules/plugins modules/test-utils
by lkrejci
modules/integration-tests/apache-plugin-test/pom.xml | 37
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/PluginLocation.java | 33
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/AugeasReferenceLeakingTest.java | 241 +++++
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/CreateAndCloseTracker.java | 173 ++++
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestConfiguration.java | 77 +
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java | 372 ++++++++
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java | 420 ---------
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeNestedConfigurationFromRHQ1_3Test.java | 27
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java | 22
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeNestedConfigurationFromRHQ3_0_0Test.java | 73 -
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java | 53 -
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeNestedConfigurationFromRHQ3_0_1Test.java | 93 +-
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java | 81 -
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeNestedConfigurationFromRHQ3_0_2Test.java | 34
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java | 22
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/util/ResourceTypes.java | 66 +
modules/integration-tests/apache-plugin-test/src/test/resources/augeas-leak-test-config/httpd.conf | 64 +
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java | 122 +-
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java | 79 +
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java | 135 +--
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java | 65 -
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java | 60 -
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java | 61 -
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java | 428 +++++-----
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java | 223 +++--
modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasComponent.java | 52 +
modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java | 44 -
modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java | 190 ++--
modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java | 22
modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java | 78 +
modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java | 4
modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java | 21
modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java | 57 -
modules/test-utils/src/main/java/org/rhq/test/JMockTest.java | 63 -
34 files changed, 2248 insertions(+), 1344 deletions(-)
New commits:
commit 0ca1154d6f3f5e959d48f3c85ebd188c513c7f4c
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Aug 4 11:45:53 2011 +0200
New byteman-based tests for correct closing of the augeas native resources.
The original apache integration tests were refactored a bit so that the setup classes
can be reused outside of the UpgradeTestBase class hierarchy.
diff --git a/modules/integration-tests/apache-plugin-test/pom.xml b/modules/integration-tests/apache-plugin-test/pom.xml
index 7eea30d..0e67a19 100644
--- a/modules/integration-tests/apache-plugin-test/pom.xml
+++ b/modules/integration-tests/apache-plugin-test/pom.xml
@@ -23,6 +23,7 @@
<scm.module.path>modules/integration-tests/apache-plugin-test</scm.module.path>
<httpd.version>2.2.17</httpd.version>
<httpd.install.dir>${basedir}/target/itest/httpd</httpd.install.dir>
+ <byteman.version>1.5.2</byteman.version>
</properties>
<repositories>
@@ -94,6 +95,34 @@
<scope>test</scope>
<type>zip</type>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman</artifactId>
+ <version>${byteman.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman-install</artifactId>
+ <version>${byteman.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman-submit</artifactId>
+ <version>${byteman.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman-bmunit</artifactId>
+ <version>${byteman.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -253,13 +282,19 @@
<configuration>
<skip>${maven.test.skip}</skip>
<excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
- <useSystemClassLoader>false</useSystemClassLoader>
+ <useSystemClassLoader>true</useSystemClassLoader>
+
+ <additionalClasspathElements>
+ <additionalClasspathElement>${env.JAVA_HOME}/lib/tools.jar</additionalClasspathElement>
+ </additionalClasspathElements>
<!--<argLine>-Dorg.hyperic.sigar.path=${basedir}/target/itest/lib
-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine> -->
<environmentVariables>
<LD_LIBRARY_PATH>${basedir}/target/itest/lib:${env.LD_LIBRARY_PATH}</LD_LIBRARY_PATH>
</environmentVariables>
<systemPropertyVariables>
+ <!-- <org.jboss.byteman.verbose>true</org.jboss.byteman.verbose> -->
+ <AugeasReferenceLeakingTest.configurationReadingInvocationCount>10</AugeasReferenceLeakingTest.configurationReadingInvocationCount>
<org.hyperic.sigar.path>${basedir}/target/itest/lib</org.hyperic.sigar.path>
<project.artifactId>${project.artifactId}</project.artifactId>
<project.version>${project.version}</project.version>
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/PluginLocation.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/PluginLocation.java
new file mode 100644
index 0000000..16bbc8d
--- /dev/null
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/PluginLocation.java
@@ -0,0 +1,33 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.apache;
+
+/**
+ *
+ *
+ * @author Lukas Krejci
+ */
+public interface PluginLocation {
+
+ public static final String PLATFORM_PLUGIN = "file:target/itest/plugins/rhq-platform-plugin-for-apache-test.jar";
+ public static final String AUGEAS_PLUGIN = "file:target/itest/plugins/rhq-augeas-plugin-for-apache-test.jar";
+ public static final String APACHE_PLUGIN = "file:target/itest/plugins/rhq-apache-plugin-for-apache-test.jar";
+
+}
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/AugeasReferenceLeakingTest.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/AugeasReferenceLeakingTest.java
new file mode 100644
index 0000000..b297a18
--- /dev/null
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/AugeasReferenceLeakingTest.java
@@ -0,0 +1,241 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.apache.augeas;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jmock.Expectations;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Listeners;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+import org.jboss.byteman.contrib.bmunit.BMNGRunner;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+
+import org.rhq.core.clientapi.agent.PluginContainerException;
+import org.rhq.core.clientapi.server.discovery.InventoryReport;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.discovery.AvailabilityReport;
+import org.rhq.core.domain.resource.InventoryStatus;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pc.PluginContainer;
+import org.rhq.core.pc.ServerServices;
+import org.rhq.core.pc.configuration.ConfigurationManager;
+import org.rhq.core.pc.inventory.InventoryManager;
+import org.rhq.core.pc.inventory.ResourceContainer;
+import org.rhq.core.pc.upgrade.FakeServerInventory;
+import org.rhq.plugins.apache.PluginLocation;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
+import org.rhq.plugins.apache.setup.ApacheTestSetup;
+import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
+import org.rhq.plugins.apache.util.ResourceTypes;
+import org.rhq.plugins.apache.util.ApacheExecutionUtil.ExpectedApacheState;
+import org.rhq.test.pc.PluginContainerSetup;
+import org.rhq.test.pc.PluginContainerTest;
+
+/**
+ *
+ *
+ * @author Lukas Krejci
+ */
+(a)Listeners(PluginContainerTest.class)
+@Test
+public class AugeasReferenceLeakingTest extends BMNGRunner {
+
+ private ApacheTestSetup setup;
+
+ @BeforeMethod
+ public void clearCreateAndCloseTracker() {
+ CreateAndCloseTracker.clear();
+ }
+
+ @SuppressWarnings("unchecked")
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN,
+ PluginLocation.APACHE_PLUGIN })
+ @BMRules(
+ rules = {
+ @BMRule(name = "increment reference count on Augeas init", targetClass = "net.augeas.Augeas",
+ targetMethod = "<init>(String, String, int)",
+ helper = "org.rhq.plugins.apache.augeas.CreateAndCloseTracker",
+ action = "recordCreate($0, formatStack())"),
+ @BMRule(name = "decrement reference count on Augeas close", targetClass = "net.augeas.Augeas",
+ targetMethod = "close()", helper = "org.rhq.plugins.apache.augeas.CreateAndCloseTracker",
+ action = "recordClose($0, formatStack())") })
+ @Parameters({ "apache2.install.dir", "apache2.exe.path",
+ "AugeasReferenceLeakingTest.configurationReadingInvocationCount" })
+ public void testReadingConfigurationsDoesNotLeakAugeasReferences(final String installDir, final String exePath,
+ int configurationReadingInvocationCount) throws Exception {
+ final FakeServerInventory fakeInventory = new FakeServerInventory();
+ PluginContainerTest.getCurrentMockContext().checking(new Expectations() {
+ {
+ ServerServices ss = PluginContainerTest.getCurrentPluginContainerConfiguration().getServerServices();
+
+ allowing(ss.getDiscoveryServerService()).mergeInventoryReport(with(any(InventoryReport.class)));
+ will(fakeInventory.mergeInventoryReport(InventoryStatus.COMMITTED));
+
+ allowing(ss.getDiscoveryServerService()).getResources(with(any(Set.class)), with(any(boolean.class)));
+ will(fakeInventory.getResources());
+
+ allowing(ss.getDiscoveryServerService()).mergeAvailabilityReport(with(any(AvailabilityReport.class)));
+ allowing(ss.getDiscoveryServerService()).postProcessNewlyCommittedResources(with(any(Set.class)));
+
+ ignoring(ss.getBundleServerService());
+ ignoring(ss.getConfigurationServerService());
+ ignoring(ss.getContentServerService());
+ ignoring(ss.getCoreServerService());
+ ignoring(ss.getEventServerService());
+ ignoring(ss.getMeasurementServerService());
+ ignoring(ss.getOperationServerService());
+ ignoring(ss.getResourceFactoryServerService());
+ }
+ });
+
+ boolean apacheStarted = false;
+ try {
+ apacheStarted = startApache(installDir, exePath);
+
+ PluginContainerTest.startConfiguredPluginContainer();
+
+ configureApacheServerToUseAugeas();
+
+ PluginContainer pc = PluginContainer.getInstance();
+ Resource platform = pc.getInventoryManager().getPlatform();
+
+ for (int i = 0; i < configurationReadingInvocationCount; ++i) {
+ checkConfigurationRecursively(platform, pc.getConfigurationManager());
+ Thread.sleep(10000);
+ }
+
+ //wait a couple of seconds for the loadConfig calls to finish
+ Thread.sleep(60000);
+ } finally {
+ if (apacheStarted) {
+ stopApache();
+ }
+ }
+ }
+
+ @AfterMethod
+ public void checkForLeaksAndMultiCloses() {
+ List<String> leaks = CreateAndCloseTracker.getCreateLocationsWithoutClose();
+ Map<String, List<String>> multiCloses = CreateAndCloseTracker.getMultiplyClosingLocations();
+
+ assertEquals(leaks.size(), 0,
+ "There were Augeas instances without a close() call on them created at the following locations: " + leaks);
+
+ assertEquals(
+ multiCloses.size(),
+ 0,
+ "Each key in the map is a location where Augeas was created and the values are the lists of locations where that instance was closed: "
+ + multiCloses);
+ }
+
+ private boolean startApache(final String installDir, final String exePath) throws Exception {
+ ApacheTestConfiguration apacheConfig = new ApacheTestConfiguration() {
+ {
+ serverRoot = installDir;
+ binPath = exePath;
+ configurationName = "augeas-leak-test-config";
+ apacheConfigurationFiles = new String[] { "/augeas-leak-test-config/httpd.conf", "/snmpd.conf" };
+ inventoryFile = null;
+ }
+ };
+
+ setup = new ApacheTestSetup(apacheConfig.configurationName, PluginContainerTest.getCurrentMockContext(),
+ new ResourceTypes(PluginLocation.APACHE_PLUGIN));
+
+ Resource platform = UpgradeTestBase.discoverPlatform();
+
+ setup.withInventoryFrom(apacheConfig.inventoryFile).withPlatformResource(platform)
+ .withDefaultOverrides(apacheConfig.defaultOverrides).withApacheSetup()
+ .withConfigurationFiles(apacheConfig.apacheConfigurationFiles).withServerRoot(apacheConfig.serverRoot)
+ .withExePath(apacheConfig.binPath);
+
+ setup.setup();
+
+ return true;
+ }
+
+ private void stopApache() throws Exception {
+ if (setup != null) {
+ setup.withApacheSetup().getExecutionUtil().invokeOperation(ExpectedApacheState.STOPPED, "stop");
+ setup = null;
+ }
+ }
+
+ private void checkConfigurationRecursively(Resource resource, ConfigurationManager cm)
+ throws PluginContainerException {
+ if (resource.getResourceType().getResourceConfigurationDefinition() != null) {
+ cm.loadResourceConfiguration(resource.getId());
+ }
+
+ for (Resource child : resource.getChildResources()) {
+ checkConfigurationRecursively(child, cm);
+ }
+ }
+
+ private void configureApacheServerToUseAugeas() throws Exception {
+ ResourceTypes resourceTypes = new ResourceTypes(PluginLocation.APACHE_PLUGIN);
+
+ InventoryManager im = PluginContainer.getInstance().getInventoryManager();
+
+ ResourceContainer apacheServer = findResource(resourceTypes.findByName("Apache HTTP Server"));
+
+ Configuration config = apacheServer.getResourceContext().getPluginConfiguration();
+
+ config.getSimple("augeasEnabled").setValue("yes");
+
+ im.updatePluginConfiguration(apacheServer.getResource().getId(), config);
+
+ //and run discovery so that the new resources can go into inventory
+
+ im.executeServiceScanImmediately();
+ }
+
+ private ResourceContainer findResource(ResourceType resourceType) {
+ InventoryManager im = PluginContainer.getInstance().getInventoryManager();
+
+ return findResource(im, resourceType, im.getPlatform());
+ }
+
+ private ResourceContainer findResource(InventoryManager im, ResourceType rt, Resource root) {
+ if (root.getResourceType().equals(rt)) {
+ return im.getResourceContainer(root);
+ }
+
+ for (Resource child : root.getChildResources()) {
+ ResourceContainer rc = findResource(im, rt, child);
+ if (rc != null) {
+ return rc;
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/CreateAndCloseTracker.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/CreateAndCloseTracker.java
new file mode 100644
index 0000000..7ccc7b5
--- /dev/null
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/CreateAndCloseTracker.java
@@ -0,0 +1,173 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.apache.augeas;
+
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.byteman.rule.Rule;
+import org.jboss.byteman.rule.helper.Helper;
+
+/**
+ * This is a helper class to help us make sense of the augeas leaks.
+ *
+ * The byteman rules in the {@link AugeasReferenceLeakingTest} make use
+ * of this class to record the locations that create instances of augeas
+ * and match them with locations that close the instance.
+ * <p>
+ * We can then report on any locations that created an augeas instance
+ * that was never closed.
+ *
+ * @author Lukas Krejci
+ */
+public class CreateAndCloseTracker extends Helper {
+ private static class EqualableWeakReference<T> extends WeakReference<T> {
+
+ private final int hash;
+
+ public EqualableWeakReference(T referent, ReferenceQueue<? super T> q) {
+ super(referent, q);
+ hash = referent.hashCode();
+ }
+
+ public EqualableWeakReference(T referent) {
+ super(referent);
+ hash = referent.hashCode();
+ }
+
+ @Override
+ public int hashCode() {
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (!(other instanceof EqualableWeakReference)) {
+ return false;
+ }
+
+ Object ref = get();
+
+ if (ref == null) {
+ //the reference has been cleared. There is no telling
+ //on what this reference pointed to, so it is not
+ //possible to determine equality.
+ return false;
+ }
+
+ EqualableWeakReference<?> o = (EqualableWeakReference<?>) other;
+
+ Object oref = o.get();
+
+ //reference equality is what we're after here...
+ return ref == oref;
+ }
+ }
+
+ private static class CreateAndCloseLocations {
+ public String createLocation;
+ public List<String> closeLocations = new ArrayList<String>();
+ }
+
+ private static final HashMap<EqualableWeakReference<Object>, CreateAndCloseLocations> REFERENCES = new HashMap<CreateAndCloseTracker.EqualableWeakReference<Object>, CreateAndCloseLocations>();
+
+ /**
+ * @param rule
+ */
+ public CreateAndCloseTracker(Rule rule) {
+ super(rule);
+ }
+
+
+ private static synchronized void _recordCreate(Object object, String stackTrace) {
+ EqualableWeakReference<Object> ref = new EqualableWeakReference<Object>(object);
+
+ CreateAndCloseLocations locations = REFERENCES.get(ref);
+
+ if (locations == null) {
+ locations = new CreateAndCloseLocations();
+ REFERENCES.put(ref, locations);
+
+ locations.createLocation = stackTrace;
+ } else {
+ throw new IllegalStateException("Cannot record a create request on a single object twice. Object: " + object + ", Stacktrace: " + stackTrace);
+ }
+ }
+
+ public void recordCreate(Object object, String stackTrace) {
+ _recordCreate(object, stackTrace);
+ }
+
+ private static synchronized void _recordClose(Object object, String stackTrace) {
+ EqualableWeakReference<Object> ref = new EqualableWeakReference<Object>(object);
+
+ CreateAndCloseLocations locations = REFERENCES.get(ref);
+
+ if (locations == null) {
+ //weird, but actually track this so that we
+ //can report about an object not being
+ //recorded for create.
+ locations = new CreateAndCloseLocations();
+ REFERENCES.put(ref, locations);
+ }
+
+ locations.closeLocations.add(stackTrace);
+ }
+
+ public void recordClose(Object object, String stackTrace) {
+ _recordClose(object, stackTrace);
+ }
+
+ public static synchronized void clear() {
+ REFERENCES.clear();
+ }
+
+ public static synchronized List<String> getCreateLocationsWithoutClose() {
+ ArrayList<String> ret = new ArrayList<String>();
+
+ for(CreateAndCloseLocations l : REFERENCES.values()) {
+ if (l.closeLocations.isEmpty()) {
+ ret.add(l.createLocation);
+ }
+ }
+
+ return ret;
+ }
+
+ public static synchronized Map<String, List<String>> getMultiplyClosingLocations() {
+ HashMap<String, List<String>> ret = new HashMap<String, List<String>>();
+
+ for(CreateAndCloseLocations l : REFERENCES.values()) {
+ if (l.closeLocations.size() > 1) {
+ ret.put(l.createLocation, l.closeLocations);
+ }
+ }
+
+ return ret;
+ }
+}
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestConfiguration.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestConfiguration.java
new file mode 100644
index 0000000..fedffe6
--- /dev/null
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestConfiguration.java
@@ -0,0 +1,77 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.apache.setup;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.rhq.plugins.apache.ApacheVirtualHostServiceComponent;
+import org.rhq.plugins.apache.ApacheVirtualHostServiceDiscoveryComponent;
+import org.rhq.plugins.apache.util.VHostSpec;
+import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig;
+
+public class ApacheTestConfiguration {
+ public String[] apacheConfigurationFiles;
+ public String inventoryFile;
+ public String configurationName;
+ public String serverRoot;
+ public String binPath;
+ public Map<String, String> defaultOverrides = new HashMap<String, String>();
+
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
+
+ }
+
+ public void beforePluginContainerStart(ApacheTestSetup setup) throws Throwable {
+
+ }
+
+ public void beforeTests(ApacheTestSetup setup) throws Throwable {
+
+ }
+
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
+ return getFullSuccessfulUpgradeResourceKeys(setup);
+ }
+
+ public String[] getExpectedResourceKeysWithFailures(ApacheTestSetup setup) {
+ return null;
+ }
+
+ protected String[] getFullSuccessfulUpgradeResourceKeys(ApacheTestSetup setup) {
+ DeploymentConfig dc = setup.getDeploymentConfig();
+ Map<String, String> replacements = dc.getTokenReplacements();
+
+ VHostSpec vh1 = dc.vhost1.getVHostSpec(replacements);
+ VHostSpec vh2 = dc.vhost2.getVHostSpec(replacements);
+ VHostSpec vh3 = dc.vhost3.getVHostSpec(replacements);
+ VHostSpec vh4 = dc.vhost4.getVHostSpec(replacements);
+
+ String[] ret = new String[5];
+
+ ret[0] = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
+ ret[1] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh1.serverName, vh1.hosts);
+ ret[2] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh2.serverName, vh2.hosts);
+ ret[3] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh3.serverName, vh3.hosts);
+ ret[4] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh4.serverName, vh4.hosts);
+
+ return ret;
+ }
+}
\ No newline at end of file
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java
new file mode 100644
index 0000000..cb10807
--- /dev/null
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java
@@ -0,0 +1,372 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.apache.setup;
+
+import static org.testng.Assert.assertTrue;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+
+import org.rhq.core.clientapi.server.discovery.InventoryReport;
+import org.rhq.core.domain.discovery.AvailabilityReport;
+import org.rhq.core.domain.resource.InventoryStatus;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceError;
+import org.rhq.core.pc.ServerServices;
+import org.rhq.core.pc.upgrade.FakeServerInventory;
+import org.rhq.plugins.apache.ApacheVirtualHostServiceComponent;
+import org.rhq.plugins.apache.ApacheVirtualHostServiceDiscoveryComponent;
+import org.rhq.plugins.apache.parser.ApacheConfigReader;
+import org.rhq.plugins.apache.parser.ApacheDirectiveTree;
+import org.rhq.plugins.apache.parser.ApacheParser;
+import org.rhq.plugins.apache.parser.ApacheParserImpl;
+import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
+import org.rhq.plugins.apache.util.ApacheDeploymentUtil;
+import org.rhq.plugins.apache.util.ApacheExecutionUtil;
+import org.rhq.plugins.apache.util.HttpdAddressUtility;
+import org.rhq.plugins.apache.util.ResourceTypes;
+import org.rhq.plugins.apache.util.VHostSpec;
+import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig;
+import org.rhq.plugins.apache.util.ApacheExecutionUtil.ExpectedApacheState;
+import org.rhq.test.ObjectCollectionSerializer;
+import org.rhq.test.TokenReplacingReader;
+import org.rhq.test.pc.PluginContainerTest;
+
+public class ApacheTestSetup {
+ private String configurationName;
+ private FakeServerInventory fakeInventory = new FakeServerInventory();
+ private String inventoryFile;
+ private Resource platform;
+ private ApacheSetup apacheSetup = new ApacheSetup();
+ private DeploymentConfig deploymentConfig;
+ private Map<String, String> defaultOverrides = new HashMap<String, String>();
+ private Map<String, String> inventoryFileReplacements;
+ private Mockery context;
+ private ResourceTypes apacheResourceTypes;
+
+ public class ApacheSetup {
+ private String serverRoot;
+ private String exePath;
+ private Collection<String> configurationFiles;
+ private ApacheExecutionUtil execution;
+ private boolean deploy = true;
+
+ private ApacheSetup() {
+
+ }
+
+ public ApacheSetup withServerRoot(String serverRoot) {
+ this.serverRoot = serverRoot;
+ //auto-define the server root property as if it was passed on the commandline
+ System.getProperties().put(configurationName + ".server.root", serverRoot);
+ deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, defaultOverrides);
+ return this;
+ }
+
+ public ApacheSetup withExePath(String exePath) {
+ this.exePath = exePath;
+ return this;
+ }
+
+ public ApacheSetup withConfigurationFiles(String... classPathUris) {
+ return withConfigurationFiles(Arrays.asList(classPathUris));
+ }
+
+ public ApacheSetup withConfigurationFiles(Collection<String> classPathUris) {
+ this.configurationFiles = classPathUris;
+ return this;
+ }
+
+ public ApacheSetup withDeploymentOnSetup() {
+ this.deploy = true;
+ return this;
+ }
+
+ public ApacheSetup withNoDeploymentOnSetup() {
+ this.deploy = false;
+ return this;
+ }
+
+ public ApacheExecutionUtil getExecutionUtil() {
+ return execution;
+ }
+
+ public void init() throws Exception {
+ File serverRootDir = new File(serverRoot);
+
+ assertTrue(serverRootDir.exists(), "The configured server root denotes a non-existant directory: '"
+ + serverRootDir + "'.");
+
+ File confDir = new File(serverRootDir, "conf");
+
+ assertTrue(confDir.exists(),
+ "The configured server root denotes a directory that doesn't have a 'conf' subdirectory. This is unexpected.");
+
+ String confFilePath = confDir.getAbsolutePath() + File.separatorChar + "httpd.conf";
+
+ String snmpHost = null;
+ int snmpPort = 0;
+ String pingUrl = null;
+
+ if (configurationName != null) {
+ if (deploy) {
+ File binDir = new File(serverRootDir, "bin");
+ List<File> additionalFilesToProcess = Arrays.asList(
+ new File(binDir, "apachectl"),
+ new File(binDir, "envvars"),
+ new File(binDir, "envvars-std"));
+ ApacheDeploymentUtil.deployConfiguration(confDir, configurationFiles, additionalFilesToProcess, deploymentConfig);
+ }
+
+ //ok, now try to find the ping URL. The best thing is to actually invoke
+ //the same code the apache server discovery does.
+ ApacheDirectiveTree tree = new ApacheDirectiveTree();
+ ApacheParser parser = new ApacheParserImpl(tree, serverRootDir.getAbsolutePath());
+ ApacheConfigReader.buildTree(confFilePath, parser);
+
+ //XXX this hardcodes apache2 as the only option we have...
+ HttpdAddressUtility.Address addrToUse = HttpdAddressUtility.APACHE_2_x.getMainServerSampleAddress(tree, null, -1);
+ pingUrl = addrToUse.toString();
+
+ snmpHost = deploymentConfig.snmpHost;
+ snmpPort = deploymentConfig.snmpPort;
+ }
+
+ execution = new ApacheExecutionUtil(apacheResourceTypes.findByName("Apache HTTP Server"),
+ serverRoot, exePath, confFilePath, pingUrl,
+ snmpHost, snmpPort);
+ execution.init();
+ }
+
+ private void doSetup() throws Exception {
+ init();
+ execution.invokeOperation(ExpectedApacheState.RUNNING, "start");
+ }
+
+ public ApacheTestSetup setup() throws Exception {
+ return ApacheTestSetup.this.setup();
+ }
+ }
+
+ public ApacheTestSetup(String configurationName, Mockery context, ResourceTypes apacheResourceTypes) {
+ this.configurationName = configurationName;
+ this.context = context;
+ this.apacheResourceTypes = apacheResourceTypes;
+ deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, defaultOverrides);
+ }
+
+ public ApacheTestSetup withInventoryFrom(String classPathUri) {
+ inventoryFile = classPathUri;
+ return this;
+ }
+
+ public ApacheTestSetup withDefaultOverrides(Map<String, String> defaultOverrides) {
+ this.defaultOverrides = defaultOverrides == null ? new HashMap<String, String>() : defaultOverrides;
+ deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, this.defaultOverrides);
+ return this;
+ }
+
+ public ApacheTestSetup withPlatformResource(Resource platform) {
+ this.platform = platform;
+ return this;
+ }
+
+ public ApacheSetup withApacheSetup() {
+ return apacheSetup;
+ }
+
+ public ApacheTestSetup withDefaultExpectations() throws Exception {
+ context.checking(new Expectations() {
+ {
+ addDefaultExceptations(this);
+ }
+ });
+
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void addDefaultExceptations(Expectations expectations) throws Exception {
+ ServerServices ss = PluginContainerTest.getCurrentPluginContainerConfiguration().getServerServices();
+
+ expectations.allowing(ss.getDiscoveryServerService()).mergeInventoryReport(
+ expectations.with(Expectations.any(InventoryReport.class)));
+ expectations.will(fakeInventory.mergeInventoryReport(InventoryStatus.COMMITTED));
+
+ expectations.allowing(ss.getDiscoveryServerService()).upgradeResources(
+ expectations.with(Expectations.any(Set.class)));
+ expectations.will(fakeInventory.upgradeResources());
+
+ expectations.allowing(ss.getDiscoveryServerService()).getResources(
+ expectations.with(Expectations.any(Set.class)), expectations.with(Expectations.any(boolean.class)));
+ expectations.will(fakeInventory.getResources());
+
+ expectations.allowing(ss.getDiscoveryServerService()).setResourceError(expectations.with(Expectations.any(ResourceError.class)));
+ expectations.will(fakeInventory.setResourceError());
+
+ expectations.allowing(ss.getDiscoveryServerService()).mergeAvailabilityReport(
+ expectations.with(Expectations.any(AvailabilityReport.class)));
+
+ expectations.allowing(ss.getDiscoveryServerService()).postProcessNewlyCommittedResources(
+ expectations.with(Expectations.any(Set.class)));
+
+ expectations.allowing(ss.getDiscoveryServerService()).clearResourceConfigError(
+ expectations.with(Expectations.any(int.class)));
+
+ expectations.ignoring(ss.getBundleServerService());
+ expectations.ignoring(ss.getConfigurationServerService());
+ expectations.ignoring(ss.getContentServerService());
+ expectations.ignoring(ss.getCoreServerService());
+ expectations.ignoring(ss.getEventServerService());
+ expectations.ignoring(ss.getMeasurementServerService());
+ expectations.ignoring(ss.getOperationServerService());
+ expectations.ignoring(ss.getResourceFactoryServerService());
+ }
+
+ public FakeServerInventory getFakeInventory() {
+ return fakeInventory;
+ }
+
+ public DeploymentConfig getDeploymentConfig() {
+ return deploymentConfig;
+ }
+
+ public ApacheTestSetup setup() throws Exception {
+ apacheSetup.doSetup();
+
+ Map<String, String> replacements = deploymentConfig.getTokenReplacements();
+ replacements.put("server.root", apacheSetup.serverRoot);
+ replacements.put("exe.path", apacheSetup.exePath);
+
+ ApacheDeploymentUtil.addDefaultVariables(replacements, null);
+
+ HttpdAddressUtility addressUtility = apacheSetup.getExecutionUtil().getServerComponent()
+ .getAddressUtility();
+ ApacheDirectiveTree runtimeConfig = apacheSetup.getExecutionUtil().getRuntimeConfiguration();
+
+ replacements.put("snmp.identifier",
+ addressUtility.getHttpdInternalMainServerAddressRepresentation(runtimeConfig).toString(false, false));
+
+ replacements.put("main.rhq4.resource.key", ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY);
+
+ VHostSpec vhost1 = deploymentConfig.vhost1 == null ? null : deploymentConfig.vhost1.getVHostSpec(replacements);
+ VHostSpec vhost2 = deploymentConfig.vhost2 == null ? null : deploymentConfig.vhost2.getVHostSpec(replacements);
+ VHostSpec vhost3 = deploymentConfig.vhost3 == null ? null : deploymentConfig.vhost3.getVHostSpec(replacements);
+ VHostSpec vhost4 = deploymentConfig.vhost4 == null ? null : deploymentConfig.vhost4.getVHostSpec(replacements);
+
+ if (vhost1 != null) {
+ replacements.put(
+ "vhost1.snmp.identifier",
+ addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost1.hosts.get(0),
+ vhost1.serverName).toString(false, false));
+
+ replacements.put(
+ "vhost1.rhq4.resource.key",
+ ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
+ vhost1.serverName, vhost1.hosts));
+ }
+
+ if (vhost2 != null) {
+ replacements.put(
+ "vhost2.snmp.identifier",
+ addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost2.hosts.get(0),
+ vhost2.serverName).toString(false, false));
+
+ replacements.put(
+ "vhost2.rhq4.resource.key",
+ ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
+ vhost2.serverName, vhost2.hosts));
+ }
+
+ if (vhost3 != null) {
+ replacements.put(
+ "vhost3.snmp.identifier",
+ addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost3.hosts.get(0),
+ vhost3.serverName).toString(false, false));
+
+ replacements.put(
+ "vhost3.rhq4.resource.key",
+ ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
+ vhost3.serverName, vhost3.hosts));
+ }
+
+ if (vhost4 != null) {
+ replacements.put(
+ "vhost4.snmp.identifier",
+ addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost4.hosts.get(0),
+ vhost4.serverName).toString(false, false));
+
+ replacements.put(
+ "vhost4.rhq4.resource.key",
+ ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
+ vhost4.serverName, vhost4.hosts));
+ }
+
+ //let the user override everything we just did
+ replacements.putAll(defaultOverrides);
+
+ inventoryFileReplacements = replacements;
+
+ if (inventoryFile != null) {
+ InputStream dataStream = getClass().getResourceAsStream(inventoryFile);
+
+ Reader rdr = new TokenReplacingReader(new InputStreamReader(dataStream), replacements);
+
+ @SuppressWarnings("unchecked")
+ List<Resource> inventory = (List<Resource>) new ObjectCollectionSerializer().deserialize(rdr);
+
+ //fix up the parent relationships, because they might not be reconstructed correctly by
+ //JAXB - we're missing XmlID and XmlIDRef annotations in our model
+ fixupParent(null, inventory);
+
+ fakeInventory.prepopulateInventory(platform, inventory);
+ }
+ return this;
+ }
+
+ /**
+ * After the setup, this returns all the variables used to update the tokens in the inventory file.
+ *
+ * @return
+ */
+ public Map<String, String> getInventoryFileReplacements() {
+ return inventoryFileReplacements;
+ }
+
+ private void fixupParent(Resource parent, Collection<Resource> children) {
+ for (Resource child : children) {
+ child.setParentResource(parent);
+ if (child.getChildResources() != null) {
+ fixupParent(child, child.getChildResources());
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java
index ccbe42d..f86b095 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java
@@ -23,19 +23,13 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
-import java.io.File;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
import java.io.StringReader;
import java.net.InetAddress;
import java.net.URI;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -44,21 +38,15 @@ import java.util.UUID;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jmock.Expectations;
import org.testng.annotations.BeforeClass;
import org.rhq.core.clientapi.agent.metadata.PluginMetadataParser;
import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil;
import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
-import org.rhq.core.clientapi.server.discovery.InventoryReport;
-import org.rhq.core.domain.discovery.AvailabilityReport;
-import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceError;
import org.rhq.core.domain.resource.ResourceErrorType;
import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.pc.ServerServices;
-import org.rhq.core.pc.upgrade.FakeServerInventory;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.PluginContainerDeployment;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
@@ -70,20 +58,17 @@ import org.rhq.plugins.apache.ApacheServerComponent;
import org.rhq.plugins.apache.ApacheServerDiscoveryComponent;
import org.rhq.plugins.apache.ApacheVirtualHostServiceComponent;
import org.rhq.plugins.apache.ApacheVirtualHostServiceDiscoveryComponent;
-import org.rhq.plugins.apache.parser.ApacheConfigReader;
+import org.rhq.plugins.apache.PluginLocation;
import org.rhq.plugins.apache.parser.ApacheDirectiveTree;
-import org.rhq.plugins.apache.parser.ApacheParser;
-import org.rhq.plugins.apache.parser.ApacheParserImpl;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
+import org.rhq.plugins.apache.setup.ApacheTestSetup;
import org.rhq.plugins.apache.upgrade.UpgradeTestBase.ResourceKeyFormat;
-import org.rhq.plugins.apache.util.ApacheDeploymentUtil;
import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig;
import org.rhq.plugins.apache.util.ApacheExecutionUtil.ExpectedApacheState;
-import org.rhq.plugins.apache.util.ApacheExecutionUtil;
-import org.rhq.plugins.apache.util.HttpdAddressUtility;
+import org.rhq.plugins.apache.util.ResourceTypes;
import org.rhq.plugins.apache.util.RuntimeApacheConfiguration;
import org.rhq.plugins.apache.util.VHostSpec;
import org.rhq.plugins.apache.util.VirtualHostLegacyResourceKeyUtil;
-import org.rhq.test.ObjectCollectionSerializer;
import org.rhq.test.TokenReplacingReader;
import org.rhq.test.pc.PluginContainerTest;
@@ -101,390 +86,21 @@ public class UpgradeTestBase extends PluginContainerTest {
SNMP, RHQ3, RHQ4
};
- public class TestSetup {
- private String configurationName;
- private FakeServerInventory fakeInventory = new FakeServerInventory();
- private String inventoryFile;
- private Resource platform;
- private ApacheSetup apacheSetup = new ApacheSetup();
- private DeploymentConfig deploymentConfig;
- private Map<String, String> defaultOverrides = new HashMap<String, String>();
- private Map<String, String> inventoryFileReplacements;
-
- public class ApacheSetup {
- private String serverRoot;
- private String exePath;
- private Collection<String> configurationFiles;
- private ApacheExecutionUtil execution;
- private boolean deploy = true;
-
- private ApacheSetup() {
-
- }
-
- public ApacheSetup withServerRoot(String serverRoot) {
- this.serverRoot = serverRoot;
- //auto-define the server root property as if it was passed on the commandline
- System.getProperties().put(configurationName + ".server.root", serverRoot);
- deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, defaultOverrides);
- return this;
- }
-
- public ApacheSetup withExePath(String exePath) {
- this.exePath = exePath;
- return this;
- }
-
- public ApacheSetup withConfigurationFiles(String... classPathUris) {
- return withConfigurationFiles(Arrays.asList(classPathUris));
- }
-
- public ApacheSetup withConfigurationFiles(Collection<String> classPathUris) {
- this.configurationFiles = classPathUris;
- return this;
- }
-
- public ApacheSetup withDeploymentOnSetup() {
- this.deploy = true;
- return this;
- }
-
- public ApacheSetup withNoDeploymentOnSetup() {
- this.deploy = false;
- return this;
- }
-
- public ApacheExecutionUtil getExecutionUtil() {
- return execution;
- }
-
- public void init() throws Exception {
- File serverRootDir = new File(serverRoot);
-
- assertTrue(serverRootDir.exists(), "The configured server root denotes a non-existant directory: '"
- + serverRootDir + "'.");
-
- File confDir = new File(serverRootDir, "conf");
-
- assertTrue(confDir.exists(),
- "The configured server root denotes a directory that doesn't have a 'conf' subdirectory. This is unexpected.");
-
- String confFilePath = confDir.getAbsolutePath() + File.separatorChar + "httpd.conf";
-
- String snmpHost = null;
- int snmpPort = 0;
- String pingUrl = null;
-
- if (configurationName != null) {
- if (deploy) {
- File binDir = new File(serverRootDir, "bin");
- List<File> additionalFilesToProcess = Arrays.asList(
- new File(binDir, "apachectl"),
- new File(binDir, "envvars"),
- new File(binDir, "envvars-std"));
- ApacheDeploymentUtil.deployConfiguration(confDir, configurationFiles, additionalFilesToProcess, deploymentConfig);
- }
-
- //ok, now try to find the ping URL. The best thing is to actually invoke
- //the same code the apache server discovery does.
- ApacheDirectiveTree tree = new ApacheDirectiveTree();
- ApacheParser parser = new ApacheParserImpl(tree, serverRootDir.getAbsolutePath());
- ApacheConfigReader.buildTree(confFilePath, parser);
-
- //XXX this hardcodes apache2 as the only option we have...
- HttpdAddressUtility.Address addrToUse = HttpdAddressUtility.APACHE_2_x.getMainServerSampleAddress(tree, null, -1);
- pingUrl = addrToUse.toString();
-
- snmpHost = deploymentConfig.snmpHost;
- snmpPort = deploymentConfig.snmpPort;
- }
-
- execution = new ApacheExecutionUtil(findApachePluginResourceTypeByName("Apache HTTP Server"),
- serverRoot, exePath, confFilePath, pingUrl,
- snmpHost, snmpPort);
- execution.init();
- }
-
- private void doSetup() throws Exception {
- init();
- execution.invokeOperation(ExpectedApacheState.RUNNING, "start");
- }
-
- public TestSetup setup() throws Exception {
- return TestSetup.this.setup();
- }
- }
-
- public TestSetup(String configurationName) {
- this.configurationName = configurationName;
- deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, defaultOverrides);
- }
-
- public TestSetup withInventoryFrom(String classPathUri) {
- inventoryFile = classPathUri;
- return this;
- }
-
- public TestSetup withDefaultOverrides(Map<String, String> defaultOverrides) {
- this.defaultOverrides = defaultOverrides == null ? new HashMap<String, String>() : defaultOverrides;
- deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, this.defaultOverrides);
- return this;
- }
-
- public TestSetup withPlatformResource(Resource platform) {
- this.platform = platform;
- return this;
- }
-
- public ApacheSetup withApacheSetup() {
- return apacheSetup;
- }
-
- public TestSetup withDefaultExpectations() throws Exception {
- context.checking(new Expectations() {
- {
- addDefaultExceptations(this);
- }
- });
-
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public void addDefaultExceptations(Expectations expectations) throws Exception {
- ServerServices ss = getCurrentPluginContainerConfiguration().getServerServices();
-
- expectations.allowing(ss.getDiscoveryServerService()).mergeInventoryReport(
- expectations.with(Expectations.any(InventoryReport.class)));
- expectations.will(fakeInventory.mergeInventoryReport(InventoryStatus.COMMITTED));
-
- expectations.allowing(ss.getDiscoveryServerService()).upgradeResources(
- expectations.with(Expectations.any(Set.class)));
- expectations.will(fakeInventory.upgradeResources());
-
- expectations.allowing(ss.getDiscoveryServerService()).getResources(
- expectations.with(Expectations.any(Set.class)), expectations.with(Expectations.any(boolean.class)));
- expectations.will(fakeInventory.getResources());
-
- expectations.allowing(ss.getDiscoveryServerService()).setResourceError(expectations.with(Expectations.any(ResourceError.class)));
- expectations.will(fakeInventory.setResourceError());
-
- expectations.allowing(ss.getDiscoveryServerService()).mergeAvailabilityReport(
- expectations.with(Expectations.any(AvailabilityReport.class)));
-
- expectations.allowing(ss.getDiscoveryServerService()).postProcessNewlyCommittedResources(
- expectations.with(Expectations.any(Set.class)));
-
- expectations.allowing(ss.getDiscoveryServerService()).clearResourceConfigError(
- expectations.with(Expectations.any(int.class)));
-
- expectations.ignoring(ss.getBundleServerService());
- expectations.ignoring(ss.getConfigurationServerService());
- expectations.ignoring(ss.getContentServerService());
- expectations.ignoring(ss.getCoreServerService());
- expectations.ignoring(ss.getEventServerService());
- expectations.ignoring(ss.getMeasurementServerService());
- expectations.ignoring(ss.getOperationServerService());
- expectations.ignoring(ss.getResourceFactoryServerService());
- }
-
- public FakeServerInventory getFakeInventory() {
- return fakeInventory;
- }
-
- public DeploymentConfig getDeploymentConfig() {
- return deploymentConfig;
- }
-
- public TestSetup setup() throws Exception {
- apacheSetup.doSetup();
-
- Map<String, String> replacements = deploymentConfig.getTokenReplacements();
- replacements.put("server.root", apacheSetup.serverRoot);
- replacements.put("exe.path", apacheSetup.exePath);
-
- ApacheDeploymentUtil.addDefaultVariables(replacements, null);
-
- HttpdAddressUtility addressUtility = apacheSetup.getExecutionUtil().getServerComponent()
- .getAddressUtility();
- ApacheDirectiveTree runtimeConfig = apacheSetup.getExecutionUtil().getRuntimeConfiguration();
-
- replacements.put("snmp.identifier",
- addressUtility.getHttpdInternalMainServerAddressRepresentation(runtimeConfig).toString(false, false));
-
- replacements.put("main.rhq4.resource.key", ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY);
-
- VHostSpec vhost1 = deploymentConfig.vhost1 == null ? null : deploymentConfig.vhost1.getVHostSpec(replacements);
- VHostSpec vhost2 = deploymentConfig.vhost2 == null ? null : deploymentConfig.vhost2.getVHostSpec(replacements);
- VHostSpec vhost3 = deploymentConfig.vhost3 == null ? null : deploymentConfig.vhost3.getVHostSpec(replacements);
- VHostSpec vhost4 = deploymentConfig.vhost4 == null ? null : deploymentConfig.vhost4.getVHostSpec(replacements);
-
- if (vhost1 != null) {
- replacements.put(
- "vhost1.snmp.identifier",
- addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost1.hosts.get(0),
- vhost1.serverName).toString(false, false));
-
- replacements.put(
- "vhost1.rhq4.resource.key",
- ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
- vhost1.serverName, vhost1.hosts));
- }
-
- if (vhost2 != null) {
- replacements.put(
- "vhost2.snmp.identifier",
- addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost2.hosts.get(0),
- vhost2.serverName).toString(false, false));
-
- replacements.put(
- "vhost2.rhq4.resource.key",
- ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
- vhost2.serverName, vhost2.hosts));
- }
-
- if (vhost3 != null) {
- replacements.put(
- "vhost3.snmp.identifier",
- addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost3.hosts.get(0),
- vhost3.serverName).toString(false, false));
-
- replacements.put(
- "vhost3.rhq4.resource.key",
- ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
- vhost3.serverName, vhost3.hosts));
- }
-
- if (vhost4 != null) {
- replacements.put(
- "vhost4.snmp.identifier",
- addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost4.hosts.get(0),
- vhost4.serverName).toString(false, false));
-
- replacements.put(
- "vhost4.rhq4.resource.key",
- ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
- vhost4.serverName, vhost4.hosts));
- }
-
- //let the user override everything we just did
- replacements.putAll(defaultOverrides);
-
- inventoryFileReplacements = replacements;
-
- InputStream dataStream = getClass().getResourceAsStream(inventoryFile);
-
- Reader rdr = new TokenReplacingReader(new InputStreamReader(dataStream), replacements);
-
- @SuppressWarnings("unchecked")
- List<Resource> inventory = (List<Resource>) new ObjectCollectionSerializer().deserialize(rdr);
-
- //fix up the parent relationships, because they might not be reconstructed correctly by
- //JAXB - we're missing XmlID and XmlIDRef annotations in our model
- fixupParent(null, inventory);
-
- fakeInventory.prepopulateInventory(platform, inventory);
-
- return this;
- }
-
- /**
- * After the setup, this returns all the variables used to update the tokens in the inventory file.
- *
- * @return
- */
- public Map<String, String> getInventoryFileReplacements() {
- return inventoryFileReplacements;
- }
-
- private void fixupParent(Resource parent, Collection<Resource> children) {
- for (Resource child : children) {
- child.setParentResource(parent);
- if (child.getChildResources() != null) {
- fixupParent(child, child.getChildResources());
- }
- }
- }
- }
-
- public static class TestConfiguration {
- public String[] apacheConfigurationFiles;
- public String inventoryFile;
- public String configurationName;
- public String serverRoot;
- public String binPath;
- public Map<String, String> defaultOverrides = new HashMap<String, String>();
-
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
-
- }
-
- public void beforePluginContainerStart(TestSetup setup) throws Throwable {
-
- }
-
- public void beforeTests(TestSetup setup) throws Throwable {
-
- }
-
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
- return getFullSuccessfulUpgradeResourceKeys(setup);
- }
-
- public String[] getExpectedResourceKeysWithFailures(TestSetup setup) {
- return null;
- }
-
- protected String[] getFullSuccessfulUpgradeResourceKeys(TestSetup setup) {
- DeploymentConfig dc = setup.getDeploymentConfig();
- Map<String, String> replacements = dc.getTokenReplacements();
-
- VHostSpec vh1 = dc.vhost1.getVHostSpec(replacements);
- VHostSpec vh2 = dc.vhost2.getVHostSpec(replacements);
- VHostSpec vh3 = dc.vhost3.getVHostSpec(replacements);
- VHostSpec vh4 = dc.vhost4.getVHostSpec(replacements);
-
- String[] ret = new String[5];
-
- ret[0] = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
- ret[1] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh1.serverName, vh1.hosts);
- ret[2] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh2.serverName, vh2.hosts);
- ret[3] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh3.serverName, vh3.hosts);
- ret[4] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh4.serverName, vh4.hosts);
-
- return ret;
- }
- }
-
- protected static final String PLATFORM_PLUGIN = "file:target/itest/plugins/rhq-platform-plugin-for-apache-test.jar";
- protected static final String AUGEAS_PLUGIN = "file:target/itest/plugins/rhq-augeas-plugin-for-apache-test.jar";
- protected static final String APACHE_PLUGIN = "file:target/itest/plugins/rhq-apache-plugin-for-apache-test.jar";
-
protected static final String DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES = "simpleWithResolvableServerNames";
protected static final String DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES = "simpleWithUnresolvableServerNames";
protected static final String DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS = "simpleWithWildcardListens";
- private List<ResourceType> resourceTypesInApachePlugin;
+ private ResourceTypes apacheResourceTypes;
protected Resource platform;
@BeforeClass
public void parseResourceTypesFromApachePlugin() throws Exception {
- resourceTypesInApachePlugin = getResourceTypesInPlugin(APACHE_PLUGIN);
+ apacheResourceTypes = new ResourceTypes(PluginLocation.APACHE_PLUGIN);
platform = discoverPlatform();
}
- protected ResourceType findApachePluginResourceTypeByName(String resourceTypeName) {
- for (ResourceType rt : resourceTypesInApachePlugin) {
- if (resourceTypeName.equals(rt.getName())) {
- return rt;
- }
- }
-
- return null;
- }
-
- protected void testUpgrade(TestConfiguration testConfiguration) throws Throwable {
- final TestSetup setup = new TestSetup(testConfiguration.configurationName);
+ protected void testUpgrade(ApacheTestConfiguration testConfiguration) throws Throwable {
+ final ApacheTestSetup setup = new ApacheTestSetup(testConfiguration.configurationName, context, apacheResourceTypes);
boolean testFailed = false;
try {
@@ -507,8 +123,8 @@ public class UpgradeTestBase extends PluginContainerTest {
testConfiguration.beforeTests(setup);
//ok, now we should see the resources upgraded in the fake server inventory.
- ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server");
- ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host");
+ ResourceType serverResourceType = apacheResourceTypes.findByName("Apache HTTP Server");
+ ResourceType vhostResourceType = apacheResourceTypes.findByName("Apache Virtual Host");
Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType);
@@ -588,7 +204,7 @@ public class UpgradeTestBase extends PluginContainerTest {
}
}
- protected void defineRHQ3ResourceKeys(TestConfiguration testConfig, TestSetup setup) throws Exception {
+ protected void defineRHQ3ResourceKeys(ApacheTestConfiguration testConfig, ApacheTestSetup setup) throws Exception {
setup.withApacheSetup().init();
ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent();
ApacheDirectiveTree config = component.loadParser();
@@ -625,7 +241,7 @@ public class UpgradeTestBase extends PluginContainerTest {
return StreamUtil.slurp(new TokenReplacingReader(new StringReader(string), variables));
}
- protected static String[] getVHostRKs(TestSetup setup, int[] successfulUpgrades, int[] failedUpgrades, ResourceKeyFormat rkFormat) {
+ protected static String[] getVHostRKs(ApacheTestSetup setup, int[] successfulUpgrades, int[] failedUpgrades, ResourceKeyFormat rkFormat) {
int sucLen = successfulUpgrades == null ? 0 : successfulUpgrades.length;
int failLen = failedUpgrades == null ? 0 : failedUpgrades.length;
@@ -679,17 +295,9 @@ public class UpgradeTestBase extends PluginContainerTest {
return ret;
}
- private static List<ResourceType> getResourceTypesInPlugin(String pluginUri) throws Exception {
- PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(pluginUri).toURL());
- PluginMetadataParser parser = new PluginMetadataParser(descriptor,
- Collections.<String, PluginMetadataParser> emptyMap());
-
- return parser.getAllTypes();
- }
-
@SuppressWarnings({ "rawtypes", "unchecked" })
- private static Resource discoverPlatform() throws Exception {
- PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(PLATFORM_PLUGIN)
+ public static Resource discoverPlatform() throws Exception {
+ PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(PluginLocation.PLATFORM_PLUGIN)
.toURL());
PluginMetadataParser parser = new PluginMetadataParser(descriptor,
Collections.<String, PluginMetadataParser> emptyMap());
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeNestedConfigurationFromRHQ1_3Test.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeNestedConfigurationFromRHQ1_3Test.java
index 69d7e78..80efc67 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeNestedConfigurationFromRHQ1_3Test.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeNestedConfigurationFromRHQ1_3Test.java
@@ -24,6 +24,9 @@ import java.util.HashMap;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
+import org.rhq.plugins.apache.PluginLocation;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
+import org.rhq.plugins.apache.setup.ApacheTestSetup;
import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
import org.rhq.test.pc.PluginContainerSetup;
@@ -50,12 +53,12 @@ public class UpgradeNestedConfigurationFromRHQ1_3Test extends UpgradeTestBase {
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithResolvableServerNames(final String installPath, final String exePath)
throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
serverRoot = installPath;
binPath = exePath;
@@ -65,7 +68,7 @@ public class UpgradeNestedConfigurationFromRHQ1_3Test extends UpgradeTestBase {
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.SNMP);
}
});
@@ -88,10 +91,10 @@ public class UpgradeNestedConfigurationFromRHQ1_3Test extends UpgradeTestBase {
// }
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }, numberOfInitialDiscoveries = 2)
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN }, numberOfInitialDiscoveries = 2)
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithNonUniqueServerNames(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES;
apacheConfigurationFiles = configuredApacheConfigurationFiles;
@@ -107,17 +110,17 @@ public class UpgradeNestedConfigurationFromRHQ1_3Test extends UpgradeTestBase {
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.SNMP);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2)
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN}, numberOfInitialDiscoveries = 2)
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddress(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -135,17 +138,17 @@ public class UpgradeNestedConfigurationFromRHQ1_3Test extends UpgradeTestBase {
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.SNMP);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddress(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -163,7 +166,7 @@ public class UpgradeNestedConfigurationFromRHQ1_3Test extends UpgradeTestBase {
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.SNMP);
}
});
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java
index 167ba8d..fff3bab 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java
@@ -24,6 +24,8 @@ import java.util.HashMap;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
+import org.rhq.plugins.apache.PluginLocation;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
import org.rhq.test.pc.PluginContainerSetup;
@@ -52,12 +54,12 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase {
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithResolvableServerNames_Apache2(final String installPath, final String exePath)
throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
serverRoot = installPath;
binPath = exePath;
@@ -70,12 +72,12 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase {
@Test(enabled = false)
//ApacheServerOperationsDelegate doesn't work with apache 1.3
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache1.install.dir", "apache1.exe.path" })
public void testWithResolvableServerNames_Apache1(final String installPath, final String exePath)
throws Throwable {
- testUpgrade(new TestConfiguration() {{
+ testUpgrade(new ApacheTestConfiguration() {{
serverRoot = installPath;
binPath = exePath;
configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES;
@@ -85,10 +87,10 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase {
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithNonUniqueServerNames_Apache2(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES;
apacheConfigurationFiles = configuredApacheConfigurationFiles;
@@ -108,10 +110,10 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase {
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddress(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -130,10 +132,10 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase {
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddress(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeNestedConfigurationFromRHQ3_0_0Test.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeNestedConfigurationFromRHQ3_0_0Test.java
index 4e16208..67bedf4 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeNestedConfigurationFromRHQ3_0_0Test.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeNestedConfigurationFromRHQ3_0_0Test.java
@@ -22,6 +22,9 @@ package org.rhq.plugins.apache.upgrade.rhq3_0_0;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
+import org.rhq.plugins.apache.PluginLocation;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
+import org.rhq.plugins.apache.setup.ApacheTestSetup;
import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
import org.rhq.test.pc.PluginContainerSetup;
@@ -60,10 +63,10 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
* and therefore the vhost discovery wouldn't even take place.
*/
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }, numberOfInitialDiscoveries = 2)
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN }, numberOfInitialDiscoveries = 2)
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -78,17 +81,17 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }, numberOfInitialDiscoveries = 2)
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN }, numberOfInitialDiscoveries = 2)
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithUnresolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -107,17 +110,17 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }, numberOfInitialDiscoveries = 2)
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN }, numberOfInitialDiscoveries = 2)
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithNonUniqueNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -136,7 +139,7 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
@@ -154,10 +157,10 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
* @throws Throwable
*/
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -167,22 +170,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithUnresolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -203,22 +206,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithNonUniqueNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -239,22 +242,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -275,17 +278,17 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddressWithSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -302,22 +305,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -338,17 +341,17 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddressWithSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -365,12 +368,12 @@ public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3);
}
});
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java
index ececb12..9fceb54 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java
@@ -23,6 +23,9 @@ package org.rhq.plugins.apache.upgrade.rhq3_0_0;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
+import org.rhq.plugins.apache.PluginLocation;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
+import org.rhq.plugins.apache.setup.ApacheTestSetup;
import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
import org.rhq.test.pc.PluginContainerSetup;
@@ -67,10 +70,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
* and therefore the vhost discovery wouldn't even take place.
*/
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2)
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN}, numberOfInitialDiscoveries = 2)
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -87,10 +90,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2)
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN}, numberOfInitialDiscoveries = 2)
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithUnresolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -108,10 +111,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2)
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN}, numberOfInitialDiscoveries = 2)
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithNonUniqueNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -140,10 +143,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
* @throws Throwable
*/
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -153,17 +156,17 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithUnresolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -179,17 +182,17 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithNonUniqueNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -205,17 +208,17 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -251,10 +254,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
* @throws Throwable
*/
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddressWithSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -271,17 +274,17 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -304,10 +307,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddressWithSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -324,7 +327,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeNestedConfigurationFromRHQ3_0_1Test.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeNestedConfigurationFromRHQ3_0_1Test.java
index f8231a9..97c1c35 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeNestedConfigurationFromRHQ3_0_1Test.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeNestedConfigurationFromRHQ3_0_1Test.java
@@ -24,6 +24,9 @@ import java.util.Arrays;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
+import org.rhq.plugins.apache.PluginLocation;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
+import org.rhq.plugins.apache.setup.ApacheTestSetup;
import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
import org.rhq.test.pc.PluginContainerSetup;
@@ -68,10 +71,10 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -81,22 +84,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -111,22 +114,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithUnresolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -142,22 +145,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithUnresolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -181,22 +184,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithNonUniqueNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -212,22 +215,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithNonUniqueNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -250,12 +253,12 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
@@ -281,10 +284,10 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
* @throws Throwable
*/
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testDuplicateMainVhostsMarkedAsFailedUpgrade(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithDuplicateMain;
@@ -294,12 +297,12 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
//the inventory has main1, main2 and vhost4
//main2 and main1 would be upgraded to the same resource key (MainServer)
//the upgrade therefore fails and no discoveries are being made
@@ -317,7 +320,7 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysWithFailures(TestSetup setup) {
+ public String[] getExpectedResourceKeysWithFailures(ApacheTestSetup setup) {
String mainVhost1RK = setup.getInventoryFileReplacements().get("main.rhq3.resource.key");
String mainVhost2RK = setup.getInventoryFileReplacements().get("snmp.identifier");
return new String[] { mainVhost1RK, mainVhost2RK };
@@ -326,10 +329,10 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -352,12 +355,12 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
@@ -377,10 +380,10 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
* @throws Throwable
*/
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddressWithSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -397,22 +400,22 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -433,23 +436,23 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddressWithSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -466,12 +469,12 @@ public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java
index 4af1879..ffdc62d 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java
@@ -24,6 +24,9 @@ import java.util.Arrays;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
+import org.rhq.plugins.apache.PluginLocation;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
+import org.rhq.plugins.apache.setup.ApacheTestSetup;
import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
import org.rhq.test.pc.PluginContainerSetup;
@@ -68,10 +71,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -81,17 +84,17 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -106,12 +109,12 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
//the inventory has main, vhost1, vhost2, vhost3 and vhost4
//the main vhost uses the URL of the server resource as its RK which is
//setup to be the IP address, whereas vhost1 uses the 'normal'
@@ -125,7 +128,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysWithFailures(TestSetup setup) {
+ public String[] getExpectedResourceKeysWithFailures(ApacheTestSetup setup) {
String failedRK = setup.getInventoryFileReplacements().get("vhost1.rhq3.resource.key");
return new String[] { failedRK };
}
@@ -133,10 +136,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithUnresolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -152,17 +155,17 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithUnresolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -181,17 +184,17 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithNonUniqueNamesWithSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSNMP;
@@ -207,17 +210,17 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testWithNonUniqueNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithoutSNMP;
@@ -240,7 +243,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
@@ -266,10 +269,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
* @throws Throwable
*/
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path"})
public void testDuplicateMainVhostsMarkedAsFailedUpgrade(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithDuplicateMain;
@@ -279,12 +282,12 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
//the inventory has main1, main2, vhost2, vhost3 and vhost4
//vhost1 has the same resource key as the main vhost in RHQ 3.0.0
//because the upgrade failed for main (because of the ambiguity),
@@ -302,7 +305,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysWithFailures(TestSetup setup) {
+ public String[] getExpectedResourceKeysWithFailures(ApacheTestSetup setup) {
String mainVhost1RK = setup.getInventoryFileReplacements().get("main.rhq3.resource.key");
String mainVhost2RK = interpret("${localhost}:${port1}", setup.getInventoryFileReplacements());
return new String[] { mainVhost1RK, mainVhost2RK };
@@ -311,10 +314,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -337,7 +340,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
@@ -357,10 +360,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
* @throws Throwable
*/
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddressWithSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -377,7 +380,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
@@ -388,10 +391,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
* vhosts - it could be either a main vhost or vhost1.
*/
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -412,12 +415,12 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
//the inventory has main, vhost1, vhost2, vhost3 and vhost4
//the main vhost uses the URL of the server resource as its RK which is
//setup to be the IP address, whereas vhost1 uses the 'normal'
@@ -431,7 +434,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysWithFailures(TestSetup setup) {
+ public String[] getExpectedResourceKeysWithFailures(ApacheTestSetup setup) {
String failedRK = setup.getInventoryFileReplacements().get("vhost1.rhq3.resource.key");
return new String[] { failedRK };
}
@@ -439,10 +442,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN})
+ @PluginContainerSetup(plugins = {PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN})
@Parameters({"apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddressWithSNMP(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -459,7 +462,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
}
@Override
- public void beforeTestSetup(TestSetup testSetup) throws Throwable {
+ public void beforeTestSetup(ApacheTestSetup testSetup) throws Throwable {
defineRHQ3ResourceKeys(this, testSetup);
}
});
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeNestedConfigurationFromRHQ3_0_2Test.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeNestedConfigurationFromRHQ3_0_2Test.java
index 2e31664..e911667 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeNestedConfigurationFromRHQ3_0_2Test.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeNestedConfigurationFromRHQ3_0_2Test.java
@@ -22,8 +22,10 @@ package org.rhq.plugins.apache.upgrade.rhq3_0_2;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
+import org.rhq.plugins.apache.PluginLocation;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
+import org.rhq.plugins.apache.setup.ApacheTestSetup;
import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
-import org.rhq.plugins.apache.upgrade.UpgradeTestBase.TestSetup;
import org.rhq.test.pc.PluginContainerSetup;
/**
@@ -57,10 +59,10 @@ public class UpgradeNestedConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithResolvableNames(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFile;
@@ -70,17 +72,17 @@ public class UpgradeNestedConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithUnresolvableNames(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFile;
@@ -101,17 +103,17 @@ public class UpgradeNestedConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithNonUniqueNames(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSingleVHost;
@@ -132,17 +134,17 @@ public class UpgradeNestedConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddress(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -163,7 +165,7 @@ public class UpgradeNestedConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
@@ -174,10 +176,10 @@ public class UpgradeNestedConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
* vhosts - it could be either a main vhost or vhost1.
*/
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddress(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -198,7 +200,7 @@ public class UpgradeNestedConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Override
- public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) {
+ public String[] getExpectedResourceKeysAfterUpgrade(ApacheTestSetup setup) {
return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null);
}
});
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java
index 38b7368..3882f8f 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java
@@ -22,6 +22,8 @@ package org.rhq.plugins.apache.upgrade.rhq3_0_2;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
+import org.rhq.plugins.apache.PluginLocation;
+import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
import org.rhq.plugins.apache.upgrade.UpgradeTestBase;
import org.rhq.test.pc.PluginContainerSetup;
@@ -56,10 +58,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithResolvableNames(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFile;
@@ -71,10 +73,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithUnresolvableNames(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFile;
@@ -97,10 +99,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithNonUniqueNames(final String installDir, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
apacheConfigurationFiles = configuredApacheConfigurationFiles;
inventoryFile = configuredInventoryFileWithSingleVhost;
@@ -123,10 +125,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
}
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithAnyAddress(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
@@ -153,10 +155,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
* vhosts - it could be either a main vhost or vhost1.
*/
@Test
- @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN })
+ @PluginContainerSetup(plugins = { PluginLocation.PLATFORM_PLUGIN, PluginLocation.AUGEAS_PLUGIN, PluginLocation.APACHE_PLUGIN })
@Parameters({ "apache2.install.dir", "apache2.exe.path" })
public void testWithWildcardAddress(final String installPath, final String exePath) throws Throwable {
- testUpgrade(new TestConfiguration() {
+ testUpgrade(new ApacheTestConfiguration() {
{
configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/util/ResourceTypes.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/util/ResourceTypes.java
new file mode 100644
index 0000000..fa8e8be
--- /dev/null
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/util/ResourceTypes.java
@@ -0,0 +1,66 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.apache.util;
+
+import java.net.URI;
+import java.util.Collections;
+import java.util.List;
+
+import org.rhq.core.clientapi.agent.metadata.PluginMetadataParser;
+import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil;
+import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
+import org.rhq.core.domain.resource.ResourceType;
+
+/**
+ *
+ *
+ * @author Lukas Krejci
+ */
+public class ResourceTypes {
+
+ private List<ResourceType> resourceTypes;
+
+ public ResourceTypes(String pluginUri) throws Exception {
+ this.resourceTypes = getResourceTypesInPlugin(pluginUri);
+ }
+
+ public List<ResourceType> getResourceTypes() {
+ return resourceTypes;
+ }
+
+ public ResourceType findByName(String resourceTypeName) {
+ for (ResourceType rt : resourceTypes) {
+ if (resourceTypeName.equals(rt.getName())) {
+ return rt;
+ }
+ }
+
+ return null;
+ }
+
+ private static List<ResourceType> getResourceTypesInPlugin(String pluginUri) throws Exception {
+ PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(pluginUri).toURL());
+ PluginMetadataParser parser = new PluginMetadataParser(descriptor,
+ Collections.<String, PluginMetadataParser> emptyMap());
+
+ return parser.getAllTypes();
+ }
+
+}
diff --git a/modules/integration-tests/apache-plugin-test/src/test/resources/augeas-leak-test-config/httpd.conf b/modules/integration-tests/apache-plugin-test/src/test/resources/augeas-leak-test-config/httpd.conf
new file mode 100644
index 0000000..c740459
--- /dev/null
+++ b/modules/integration-tests/apache-plugin-test/src/test/resources/augeas-leak-test-config/httpd.conf
@@ -0,0 +1,64 @@
+ServerRoot ${server.root}
+
+Listen ${listen1}
+Listen ${listen2}
+Listen ${listen3}
+Listen ${listen4}
+
+ServerAdmin root@localhost
+
+${servername.directive}
+
+DocumentRoot ${document.root}
+
+DefaultType text/plain
+
+ErrorLog logs/error_log
+
+LogLevel debug
+
+# Apache SNMP
+LoadModule snmpcommon_module modules/libsnmpcommon.so
+LoadModule snmpagt_module modules/libsnmpmonagt.so
+SNMPConf conf
+SNMPVar var
+# End of apache SNMP
+
+${additional.directives}
+
+<Directory "/var/www/html">
+</Directory>
+
+<IfModule not_loaded_module>
+ <VirtualHost ${vhost1.urls}>
+ ${vhost1.servername.directive}
+ ${vhost1.additional.directives}
+ </VirtualHost>
+</IfModule>
+
+LoadModule alias_module modules/mod_alias.so
+
+<IfModule snmpcommon_module>
+<IfModule mod_alias.c>
+ <Directory "/var/www/html2">
+ </Directory>
+ <VirtualHost ${vhost2.urls}>
+ ${vhost2.servername.directive}
+ ${vhost2.additional.directives}
+ </VirtualHost>
+</IfModule>
+
+<IfModule mod_unknown.c>
+ <VirtualHost ${vhost3.urls}>
+ ${vhost3.servername.directive}
+ ${vhost3.additional.directives}
+ </VirtualHost>
+</IfModule>
+</IfModule>
+
+<VirtualHost ${vhost4.urls}>
+ ${vhost4.servername.directive}
+ ${vhost4.additional.directives}
+ <Directory "/var/www/html3">
+ </Directory>
+</VirtualHost>
commit fd9d48ccc5b0eac0bd8e1cab216480d894969e05
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Aug 4 11:44:13 2011 +0200
JMockTest now behaves as originally intended when used as a Listener on a class.
By default any class specified in the @Listeners annotation is used as a listener on
ALL tests in ALL test classes in the current test suite.
The JMockTest to be of any use needs only to be applied on a class it is specified on, because
we certainly don't want all the test methods to use jmock.
diff --git a/modules/test-utils/src/main/java/org/rhq/test/JMockTest.java b/modules/test-utils/src/main/java/org/rhq/test/JMockTest.java
index 2088460..0cb5e22 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/JMockTest.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/JMockTest.java
@@ -30,6 +30,7 @@ import org.testng.IHookCallBack;
import org.testng.IHookable;
import org.testng.IInvokedMethod;
import org.testng.IInvokedMethodListener;
+import org.testng.ITestNGListener;
import org.testng.ITestResult;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -44,6 +45,13 @@ import org.testng.annotations.Listeners;
* field, while in the latter case (when JMockTest is specified as a {@link Listeners listener}
* of a test class), the JMock context is accessible using the {@link #getCurrentMockContext()}
* static method.
+ * <p>
+ * Unlike the default behavior of the Listeners annotation which makes the supplied classes
+ * the listeners on <b>ALL</b> test methods in <b>ALL</b> classes, this implementation behaves differntly.
+ * It checks whether the Listeners annotation is specified on the class that the current test
+ * method is being executed on (or its superclasses) and only if it does, the test method is
+ * "augmented". This means that the classes can specify if they want to be augmented by JMockTest
+ * by specifying it as their listener.
*
* @author John Sanda
* @author Lukas Krejci
@@ -54,9 +62,6 @@ public class JMockTest implements IHookable, IInvokedMethodListener {
private static final ThreadLocal<Mockery> STATICALLY_ACCESSIBLE_CONTEXT = new ThreadLocal<Mockery>();
- private boolean initRan;
- private boolean tearDownRan;
-
/**
* @return the JMock context of the current test or null if the calling test class doesn't have
* this class set as a listener or doesn't inherit from this class.
@@ -66,21 +71,13 @@ public class JMockTest implements IHookable, IInvokedMethodListener {
}
@BeforeMethod
- public void initMockContext(Method testMethod) {
- if (!initRan) {
- initBeforeTest(this, testMethod);
- }
- tearDownRan = false;
- initRan = true;
+ public final void initMockContext(Method testMethod) {
+ initBeforeTest(this, testMethod);
}
@AfterMethod
- public void tearDownMockContext(ITestResult testResult) {
- if (!tearDownRan) {
- tearDownAfterTest(testResult);
- }
- tearDownRan = true;
- initRan = false;
+ public final void tearDownMockContext(ITestResult testResult) {
+ tearDownAfterTest(testResult);
}
/**
@@ -101,12 +98,10 @@ public class JMockTest implements IHookable, IInvokedMethodListener {
*
* @see IInvokedMethodListener#beforeInvocation(IInvokedMethod, ITestResult)
*/
- public final void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
- if (!initRan) {
+ public final void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
+ if (!isUsedAsSubClass(method) && isListenerDefinedOnTestClass(method)) {
initBeforeTest(testResult.getInstance(), testResult.getMethod().getMethod());
}
- initRan = true;
- tearDownRan = false;
}
/**
@@ -115,11 +110,9 @@ public class JMockTest implements IHookable, IInvokedMethodListener {
* @see IInvokedMethodListener#afterInvocation(IInvokedMethod, ITestResult)
*/
public final void afterInvocation(IInvokedMethod method, ITestResult testResult) {
- if (!tearDownRan) {
+ if (!isUsedAsSubClass(method) && isListenerDefinedOnTestClass(method)) {
tearDownAfterTest(testResult);
}
- initRan = false;
- tearDownRan = true;
}
/**
@@ -164,4 +157,30 @@ public class JMockTest implements IHookable, IInvokedMethodListener {
//collect the no-longer used context.
STATICALLY_ACCESSIBLE_CONTEXT.set(null);
}
+
+ private boolean isUsedAsSubClass(IInvokedMethod method) {
+ Class<?> testMethodClass = method.getTestMethod().getTestClass().getRealClass();
+
+ return this.getClass().isAssignableFrom(testMethodClass);
+ }
+
+ private boolean isListenerDefinedOnTestClass(IInvokedMethod method) {
+ Class<?> cls = method.getTestMethod().getTestClass().getRealClass();
+
+ while (cls != null) {
+ Listeners annotation = cls.getAnnotation(Listeners.class);
+
+ if (annotation != null) {
+ for(Class<?> listener : annotation.value()) {
+ if (this.getClass().equals(listener)) {
+ return true;
+ }
+ }
+ }
+
+ cls = cls.getSuperclass();
+ }
+
+ return false;
+ }
}
commit ba3fcbe5cdea5c384743c0a90e71e73a48707b9f
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Aug 1 14:11:28 2011 +0200
BZ 721152 - fixing the augeas memory leak - cherrypicked over from release-3.0.0
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java
index 0c3f447..e828818 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java
@@ -23,17 +23,14 @@
package org.rhq.plugins.apache;
-import java.util.ArrayList;
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
-import org.rhq.core.domain.configuration.Property;
-import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
@@ -46,23 +43,24 @@ import org.rhq.plugins.apache.mapping.ApacheAugeasMapping;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
/**
- * Component for configuring the <Directory> and underlying directives inside
- * Apache configuration.
+ * Component for configuring the <Directory> and underlying directives
+ * inside Apache configuration.
*
* @author Lukas Krejci
*/
-public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtualHostServiceComponent>, ConfigurationFacet, DeleteResourceFacet {
-
- private final Log log = LogFactory.getLog(this.getClass());
+public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtualHostServiceComponent>,
+ ConfigurationFacet, DeleteResourceFacet {
+
+ private final Log log = LogFactory.getLog(this.getClass());
public static final String REGEXP_PROP = "regexp";
public static final String DIRECTORY_DIRECTIVE = "<Directory";
-
+
private ResourceContext<ApacheVirtualHostServiceComponent> resourceContext;
-
- public void start(ResourceContext<ApacheVirtualHostServiceComponent> context) throws InvalidPluginConfigurationException, Exception {
- resourceContext = context;
- }
-
+
+ public void start(ResourceContext<ApacheVirtualHostServiceComponent> context)
+ throws InvalidPluginConfigurationException, Exception {
+ resourceContext = context;
+ }
public void stop() {
}
@@ -73,20 +71,27 @@ public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtual
public Configuration loadResourceConfiguration() throws Exception {
ApacheVirtualHostServiceComponent parentVirtualHost = resourceContext.getParentResourceComponent();
- AugeasTree tree = parentVirtualHost.getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType().getResourceConfigurationDefinition();
-
- AugeasNode virtualHostNode = parentVirtualHost.getNode(tree);
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- return mapping.updateConfiguration(getNode(virtualHostNode), resourceConfigDef);
+
+ AugeasComponent comp = getAugeas();
+ try {
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
+
+ AugeasNode virtualHostNode = parentVirtualHost.getNode(tree);
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ return mapping.updateConfiguration(getNode(virtualHostNode), resourceConfigDef);
+ } finally {
+ comp.close();
+ }
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
- ApacheVirtualHostServiceComponent parentVirtualHost = resourceContext.getParentResourceComponent();
+ AugeasComponent comp = getAugeas();
AugeasTree tree = null;
try {
- tree = parentVirtualHost.getServerConfigurationTree();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
.getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
@@ -96,7 +101,7 @@ public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtual
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
log.info("Apache configuration was updated");
-
+
resourceContext.getParentResourceComponent().finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null)
@@ -104,27 +109,35 @@ public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtual
else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ } finally {
+ comp.close();
}
- }
-
+ }
public void deleteResource() throws Exception {
ApacheVirtualHostServiceComponent parentVirtualHost = resourceContext.getParentResourceComponent();
- AugeasTree tree = parentVirtualHost.getServerConfigurationTree();
- AugeasNode virtualHostNode = parentVirtualHost.getNode(tree);
-
- AugeasNode myNode = getNode(virtualHostNode);
-
- if (myNode != null) {
- tree.removeNode(myNode, true);
- tree.save();
-
- ApacheVirtualHostServiceComponent parentVhost = resourceContext.getParentResourceComponent();
-
- parentVhost.deleteEmptyFile(tree, myNode);
- parentVhost.conditionalRestart();
- } else {
- log.info("Could find the configuration corresponding to the directory " + resourceContext.getResourceKey() + ". Ignoring.");
+ AugeasComponent comp = getAugeas();
+
+ try {
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ AugeasNode virtualHostNode = parentVirtualHost.getNode(tree);
+
+ AugeasNode myNode = getNode(virtualHostNode);
+
+ if (myNode != null) {
+ tree.removeNode(myNode, true);
+ tree.save();
+
+ ApacheVirtualHostServiceComponent parentVhost = resourceContext.getParentResourceComponent();
+
+ parentVhost.deleteEmptyFile(tree, myNode);
+ parentVhost.conditionalRestart();
+ } else {
+ log.info("Could find the configuration corresponding to the directory "
+ + resourceContext.getResourceKey() + ". Ignoring.");
+ }
+ } finally {
+ comp.close();
}
}
@@ -132,35 +145,36 @@ public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtual
* Gets the node from under given node corresponding to the Directory this
* component is managing.
*
- * @param virtualHost the node of the parent virtualHost (or root node of the augeas tree)
+ * @param virtualHost
+ * the node of the parent virtualHost (or root node of the augeas
+ * tree)
* @return
*/
public AugeasNode getNode(AugeasNode virtualHost) {
AugeasNode directory = AugeasNodeSearch.findNodeById(virtualHost, resourceContext.getResourceKey());
-
+
return directory;
}
-
- public AugeasNode getNode(){
+
+ public AugeasNode getNode(AugeasTree tree) {
ApacheVirtualHostServiceComponent virtHost = resourceContext.getParentResourceComponent();
- AugeasTree tree = virtHost.getServerConfigurationTree();
AugeasNode virtHostNode = resourceContext.getParentResourceComponent().getNode(tree);
return getNode(virtHostNode);
}
-
- public AugeasTree getServerConfigurationTree(){
- return resourceContext.getParentResourceComponent().getServerConfigurationTree();
+
+ public AugeasComponent getAugeas() {
+ return resourceContext.getParentResourceComponent().getAugeas();
}
-
+
/**
* @see ApacheServerComponent#finishConfigurationUpdate(ConfigurationUpdateReport)
*/
public void finishConfigurationUpdate(ConfigurationUpdateReport report) {
resourceContext.getParentResourceComponent().finishConfigurationUpdate(report);
}
-
- public boolean isAugeasEnabled(){
+
+ public boolean isAugeasEnabled() {
ApacheVirtualHostServiceComponent parent = resourceContext.getParentResourceComponent();
- return parent.isAugeasEnabled();
+ return parent.isAugeasEnabled();
}
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java
index c407f34..97d14d5 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java
@@ -29,6 +29,7 @@ import java.util.Set;
import net.augeas.AugeasException;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
@@ -52,8 +53,8 @@ public class ApacheDirectoryDiscoveryComponent implements ResourceDiscoveryCompo
* @see org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext)
*/
public static final String DIRECTORY_DIRECTIVE = "<Directory";
- public static final String [] PARENT_DIRECTIVES = {"<IfModule"};
-
+ public static final String[] PARENT_DIRECTIVES = { "<IfModule" };
+
public Set<DiscoveredResourceDetails> discoverResources(
ResourceDiscoveryContext<ApacheVirtualHostServiceComponent> context)
throws InvalidPluginConfigurationException, Exception {
@@ -63,47 +64,55 @@ public class ApacheDirectoryDiscoveryComponent implements ResourceDiscoveryCompo
if (!context.getParentResourceComponent().isAugeasEnabled())
return discoveredResources;
-
+ AugeasComponent comp = context.getParentResourceComponent().getAugeas();
AugeasTree tree = null;
-
+
try {
- tree = context.getParentResourceComponent().getServerConfigurationTree();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
} catch (AugeasException e) {
//we depend on Augeas to do anything useful with directories.
- //give up, if Augeas isn't there.
+ //give up, if Augeas isn't there.
+ comp.close();
return discoveredResources;
}
- AugeasNode parentNode = context.getParentResourceComponent().getNode(tree);
- List<AugeasNode> directories = AugeasNodeSearch.searchNode(PARENT_DIRECTIVES, DIRECTORY_DIRECTIVE, parentNode);
-
- ResourceType resourceType = context.getResourceType();
-
- for (AugeasNode node : directories) {
- Configuration pluginConfiguration = new Configuration();
-
- String ifmoduleParams = AugeasNodeSearch.getNodeKey(node, parentNode);
- List<AugeasNode> params = node.getChildByLabel("param");
-
- String directoryParam;
- boolean isRegexp;
-
- if (params.size() > 1) {
- directoryParam = params.get(1).getValue();
- isRegexp = true;
- } else {
- directoryParam = params.get(0).getValue();
- isRegexp = false;
+ try {
+ AugeasNode parentNode = context.getParentResourceComponent().getNode(tree);
+ List<AugeasNode> directories = AugeasNodeSearch.searchNode(PARENT_DIRECTIVES, DIRECTORY_DIRECTIVE,
+ parentNode);
+
+ ResourceType resourceType = context.getResourceType();
+
+ for (AugeasNode node : directories) {
+ Configuration pluginConfiguration = new Configuration();
+
+ String ifmoduleParams = AugeasNodeSearch.getNodeKey(node, parentNode);
+ List<AugeasNode> params = node.getChildByLabel("param");
+
+ String directoryParam;
+ boolean isRegexp;
+
+ if (params.size() > 1) {
+ directoryParam = params.get(1).getValue();
+ isRegexp = true;
+ } else {
+ directoryParam = params.get(0).getValue();
+ isRegexp = false;
+ }
+
+ pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.REGEXP_PROP, isRegexp));
+
+ String resourceKey = ifmoduleParams;
+ String resourceName = AugeasNodeValueUtil.unescape(directoryParam);
+
+ discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null,
+ null, pluginConfiguration, null));
}
-
- pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.REGEXP_PROP, isRegexp));
-
- String resourceKey = ifmoduleParams;
- String resourceName = AugeasNodeValueUtil.unescape(directoryParam);
-
- discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null, null,
- pluginConfiguration, null));
+ return discoveredResources;
+
+ } finally {
+ if (comp != null)
+ comp.close();
}
- return discoveredResources;
}
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java
index b046f17..bd6b4ee 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java
@@ -22,19 +22,14 @@
*/
package org.rhq.plugins.apache;
-import java.util.ArrayList;
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
-import org.rhq.core.domain.configuration.Property;
-import org.rhq.core.domain.configuration.PropertyList;
-import org.rhq.core.domain.configuration.PropertyMap;
-import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
@@ -43,57 +38,64 @@ import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.plugins.apache.augeas.mappingImpl.MappingPositionToConfiguration;
import org.rhq.plugins.apache.mapping.ApacheAugeasMapping;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
-
-public class ApacheIfModuleComponent implements ResourceComponent<ApacheVirtualHostServiceComponent>, ConfigurationFacet, DeleteResourceFacet {
+public class ApacheIfModuleComponent implements ResourceComponent<ApacheVirtualHostServiceComponent>,
+ ConfigurationFacet, DeleteResourceFacet {
private AugeasTree tree;
private ResourceContext<ApacheVirtualHostServiceComponent> context;
- private ApacheVirtualHostServiceComponent parentComponent;
+ private ApacheVirtualHostServiceComponent parentComponent;
private final Log log = LogFactory.getLog(this.getClass());
- private static final String IFMODULE_DIRECTIVE_NAME="<IfModule";
-
+ private static final String IFMODULE_DIRECTIVE_NAME = "<IfModule";
+
public void start(ResourceContext<ApacheVirtualHostServiceComponent> context)
throws InvalidPluginConfigurationException, Exception {
-
- this.context = context;
- parentComponent = context.getParentResourceComponent();
+
+ this.context = context;
+ parentComponent = context.getParentResourceComponent();
}
- public void stop(){
+ public void stop() {
}
public AvailabilityType getAvailability() {
- return parentComponent.getAvailability();
+ return parentComponent.getAvailability();
}
- public Configuration loadResourceConfiguration() throws Exception {
- AugeasTree tree = parentComponent.getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
-
- AugeasNode virtualHostNode = parentComponent.getNode(tree);
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- return mapping.updateConfiguration(getNode(virtualHostNode), resourceConfigDef);
+ public Configuration loadResourceConfiguration() throws Exception {
+ AugeasComponent comp = null;
+ try {
+ comp = parentComponent.getAugeas();
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
+
+ AugeasNode virtualHostNode = parentComponent.getNode(tree);
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ return mapping.updateConfiguration(getNode(virtualHostNode), resourceConfigDef);
+ } finally {
+ if (comp != null)
+ comp.close();
+ }
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ AugeasComponent comp = null;
AugeasTree tree = null;
try {
- tree = parentComponent.getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = context.getResourceType()
- .getResourceConfigurationDefinition();
+ comp = parentComponent.getAugeas();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
-
+
AugeasNode directoryNode = getNode(parentComponent.getNode(tree));
mapping.updateAugeas(directoryNode, report.getConfiguration(), resourceConfigDef);
tree.save();
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
log.info("Apache configuration was updated");
-
+
context.getParentResourceComponent().finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null)
@@ -101,73 +103,30 @@ public class ApacheIfModuleComponent implements ResourceComponent<ApacheVirtualH
else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ } finally {
+ if (comp != null)
+ comp.close();
}
- }
+ }
+
public void deleteResource() throws Exception {
-
+
}
-
+
private AugeasNode getNode(AugeasNode virtualHost) {
AugeasNode directory = AugeasNodeSearch.findNodeById(virtualHost, context.getResourceKey());
return directory;
- }
-
- private void prepareNode(AugeasNode node,AugeasNode parentNode,AugeasTree tree,Configuration configuration){
- List<String> params = AugeasNodeSearch.getParams(node, parentNode);
-
- PropertyList list = (PropertyList)configuration.get(MappingPositionToConfiguration.LIST_PROPERTY_NAME);
- List<String> newParams = new ArrayList<String>();
- //get new list of params
- for (Property prop : list.getList()){
- if (prop instanceof PropertyMap)
- {
- PropertyMap propMap = (PropertyMap) prop;
- PropertySimple value = (PropertySimple) propMap.get(MappingPositionToConfiguration.SIMPLE_PROPERTY_NAME);
- newParams.add(value.getStringValue());
- }
- }
-
- int i = 0;
- int position = 0;
- AugeasNode tempNode = parentNode;
- boolean updated = true;
-
- while (updated){
- updated = false;
- List<AugeasNode> nodes = tempNode.getChildByLabel(IFMODULE_DIRECTIVE_NAME);
- for (AugeasNode nd : nodes){
- List<AugeasNode> paramNodes = nd.getChildByLabel("param");
- if (paramNodes.size()>0)
- {
- String value = paramNodes.get(0).getValue();
- if (value.equals(newParams.get(position)))
- {
- position = position + 1;
- tempNode = nd;
- updated = true;
- break;
- }
- }
- }
- }
-
- for(i=position;i<newParams.size();i++){
- int size = tempNode.getChildByLabel(IFMODULE_DIRECTIVE_NAME).size()+1;
- tempNode = tree.createNode(tempNode, IFMODULE_DIRECTIVE_NAME, null, size);
- tree.createNode(tempNode, "param", newParams.get(i), 1);
- }
}
-
- public void copy(AugeasNode a, AugeasNode b){
- for (AugeasNode nd : a.getChildNodes()){
+
+ public void copy(AugeasNode a, AugeasNode b) {
+ for (AugeasNode nd : a.getChildNodes()) {
AugeasNode tempNode = tree.createNode(b, nd.getLabel(), nd.getValue(), nd.getSeq());
- copy(nd,tempNode);
+ copy(nd, tempNode);
}
}
-
-
- public boolean isAugeasEnabled(){
- return parentComponent.isAugeasEnabled();
+
+ public boolean isAugeasEnabled() {
+ return parentComponent.isAugeasEnabled();
}
-
+
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java
index acb2572..dedcb3c 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java
@@ -24,6 +24,8 @@ package org.rhq.plugins.apache;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
@@ -38,51 +40,57 @@ import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.plugins.apache.mapping.ApacheAugeasMapping;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
-public class ApacheIfModuleDirectoryComponent implements ResourceComponent<ApacheDirectoryComponent>, ConfigurationFacet {
+public class ApacheIfModuleDirectoryComponent implements ResourceComponent<ApacheDirectoryComponent>,
+ ConfigurationFacet {
private ResourceContext<ApacheDirectoryComponent> context;
- private ApacheDirectoryComponent parentComponent;
+ private ApacheDirectoryComponent parentComponent;
private final Log log = LogFactory.getLog(this.getClass());
- private static final String IFMODULE_DIRECTIVE_NAME="<IfModule";
-
- public void start(ResourceContext<ApacheDirectoryComponent> context)
- throws InvalidPluginConfigurationException, Exception {
-
- this.context = context;
- parentComponent = context.getParentResourceComponent();
+ private static final String IFMODULE_DIRECTIVE_NAME = "<IfModule";
+
+ public void start(ResourceContext<ApacheDirectoryComponent> context) throws InvalidPluginConfigurationException,
+ Exception {
+ this.context = context;
+ parentComponent = context.getParentResourceComponent();
}
public void stop() {
}
public AvailabilityType getAvailability() {
- return parentComponent.getAvailability();
+ return parentComponent.getAvailability();
}
- public Configuration loadResourceConfiguration() throws Exception {
+ public Configuration loadResourceConfiguration() throws Exception {
ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
-
- AugeasNode directoryNode = parentComponent.getNode();
- AugeasTree tree = parentComponent.getServerConfigurationTree();
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- return mapping.updateConfiguration(getNode(directoryNode), resourceConfigDef);
+ AugeasComponent comp = parentComponent.getAugeas();
+ AugeasTree tree = null;
+ try {
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ AugeasNode directoryNode = parentComponent.getNode(tree);
+
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ return mapping.updateConfiguration(getNode(directoryNode), resourceConfigDef);
+ } finally {
+ comp.close();
+ }
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ AugeasComponent comp = parentComponent.getAugeas();
AugeasTree tree = null;
try {
- tree = parentComponent.getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = context.getResourceType()
- .getResourceConfigurationDefinition();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- AugeasNode directoryNode = getNode(parentComponent.getNode());
+ AugeasNode directoryNode = getNode(parentComponent.getNode(tree));
mapping.updateAugeas(directoryNode, report.getConfiguration(), resourceConfigDef);
tree.save();
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
log.info("Apache configuration was updated");
-
+
context.getParentResourceComponent().finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null)
@@ -90,16 +98,17 @@ public class ApacheIfModuleDirectoryComponent implements ResourceComponent<Apach
else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ } finally {
+ comp.close();
}
- }
-
+ }
+
private AugeasNode getNode(AugeasNode virtualHost) {
AugeasNode directory = AugeasNodeSearch.findNodeById(virtualHost, context.getResourceKey());
return directory;
- }
-
- public boolean isAugeasEnabled(){
- return parentComponent.isAugeasEnabled();
}
-}
+ public boolean isAugeasEnabled() {
+ return parentComponent.isAugeasEnabled();
+ }
+}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java
index 3d17f71..d3bbe15 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java
@@ -26,6 +26,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.resource.ResourceType;
@@ -36,39 +37,44 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
public class ApacheIfModuleDirectoryDiscoveryComponent implements ResourceDiscoveryComponent<ApacheDirectoryComponent> {
-
- private static final String [] parentRes = {"<IfModule"};
+
+ private static final String[] parentRes = { "<IfModule" };
private static final String IFMODULE_NODE_NAME = "<IfModule";
private AugeasTree tree;
private AugeasNode parentNode;
-
- public Set<DiscoveredResourceDetails> discoverResources(
- ResourceDiscoveryContext<ApacheDirectoryComponent> context)
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ApacheDirectoryComponent> context)
throws InvalidPluginConfigurationException, Exception {
-
- ApacheDirectoryComponent directory = context.getParentResourceComponent();
- Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
-
- if (!directory.isAugeasEnabled())
- return discoveredResources;
-
- parentNode = directory.getNode();
-
- List<AugeasNode> ifModuleNodes = AugeasNodeSearch.searchNode(parentRes, IFMODULE_NODE_NAME, parentNode);
-
- ResourceType resourceType = context.getResourceType();
+ ApacheDirectoryComponent directory = context.getParentResourceComponent();
+ Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
+
+ if (!directory.isAugeasEnabled())
+ return discoveredResources;
+
+ AugeasComponent comp = directory.getAugeas();
+ AugeasTree tree = null;
+ try {
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+
+ parentNode = directory.getNode(tree);
+
+ List<AugeasNode> ifModuleNodes = AugeasNodeSearch.searchNode(parentRes, IFMODULE_NODE_NAME, parentNode);
+
+ ResourceType resourceType = context.getResourceType();
+
+ for (AugeasNode node : ifModuleNodes) {
- for (AugeasNode node : ifModuleNodes) {
-
-
- String resourceKey = AugeasNodeSearch.getNodeKey(node,parentNode);
- String [] paramArray = resourceKey.split("\\|");
- String resourceName = paramArray[1];
+ String resourceKey = AugeasNodeSearch.getNodeKey(node, parentNode);
+ String[] paramArray = resourceKey.split("\\|");
+ String resourceName = paramArray[1];
- discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null, null,
- null, null));
+ discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null,
+ null, null, null));
+ }
+ return discoveredResources;
+ } finally {
+ comp.close();
}
- return discoveredResources;
- }
+ }
}
\ No newline at end of file
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java
index 708c198..e7165fd 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java
@@ -26,6 +26,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.resource.ResourceType;
@@ -35,41 +36,47 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
-public class ApacheIfModuleDiscoveryComponent implements ResourceDiscoveryComponent<ApacheVirtualHostServiceComponent> {
+public class ApacheIfModuleDiscoveryComponent implements ResourceDiscoveryComponent<ApacheVirtualHostServiceComponent> {
- private static final String [] parentRes = {"<IfModule"};
+ private static final String[] parentRes = { "<IfModule" };
private static final String IFMODULE_NODE_NAME = "<IfModule";
private AugeasTree tree;
private AugeasNode parentNode;
-
+
public Set<DiscoveredResourceDetails> discoverResources(
ResourceDiscoveryContext<ApacheVirtualHostServiceComponent> context)
throws InvalidPluginConfigurationException, Exception {
-
- Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
- ApacheVirtualHostServiceComponent virtualHost = context.getParentResourceComponent();
-
- if (!virtualHost.isAugeasEnabled()){
- return discoveredResources;
- }
-
- tree = virtualHost.getServerConfigurationTree();
- parentNode = virtualHost.getNode(tree);
-
- List<AugeasNode> ifModuleNodes = AugeasNodeSearch.searchNode(parentRes, IFMODULE_NODE_NAME, parentNode);
-
-
- ResourceType resourceType = context.getResourceType();
- for (AugeasNode node : ifModuleNodes) {
-
- String resourceKey = AugeasNodeSearch.getNodeKey(node,parentNode);
- String [] paramArray = resourceKey.split("\\|");
- String resourceName = paramArray[1];
+ Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
+ ApacheVirtualHostServiceComponent virtualHost = context.getParentResourceComponent();
- discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null, null,
- null, null));
+ if (!virtualHost.isAugeasEnabled()) {
+ return discoveredResources;
}
- return discoveredResources;
- }
+ AugeasComponent comp = virtualHost.getAugeas();
+ AugeasTree tree = null;
+ try {
+
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+
+ parentNode = virtualHost.getNode(tree);
+
+ List<AugeasNode> ifModuleNodes = AugeasNodeSearch.searchNode(parentRes, IFMODULE_NODE_NAME, parentNode);
+
+ ResourceType resourceType = context.getResourceType();
+
+ for (AugeasNode node : ifModuleNodes) {
+
+ String resourceKey = AugeasNodeSearch.getNodeKey(node, parentNode);
+ String[] paramArray = resourceKey.split("\\|");
+ String resourceName = paramArray[1];
+
+ discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null,
+ null, null, null));
+ }
+ return discoveredResources;
+ } finally {
+ comp.close();
+ }
+ }
}
\ No newline at end of file
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
index 92d51da..d180fe6 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
@@ -39,10 +39,13 @@ import org.apache.commons.logging.LogFactory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.rhq.augeas.AugeasProxy;
+import org.rhq.augeas.AugeasComponent;
+import org.rhq.augeas.config.AugeasConfiguration;
import org.rhq.augeas.config.AugeasModuleConfig;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
+import org.rhq.augeas.tree.AugeasTreeBuilder;
+import org.rhq.augeas.tree.AugeasTreeException;
import org.rhq.augeas.util.Glob;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
@@ -66,6 +69,7 @@ import org.rhq.core.pluginapi.event.log.LogFileEventPoller;
import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.pluginapi.operation.OperationFacet;
@@ -99,8 +103,8 @@ import org.rhq.rhqtransform.AugeasRHQComponent;
* @author Ian Springer
* @author Lukas Krejci
*/
-public class ApacheServerComponent implements AugeasRHQComponent<PlatformComponent>, MeasurementFacet, OperationFacet,
- ConfigurationFacet, CreateChildResourceFacet {
+public class ApacheServerComponent implements AugeasRHQComponent, ResourceComponent<PlatformComponent>,
+ MeasurementFacet, OperationFacet, ConfigurationFacet, CreateChildResourceFacet {
public static final String CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE = "Configuration is supported only for Apache version 2 and up using Augeas. You either have an old version of Apache or Augeas is not installed.";
@@ -111,6 +115,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
public static final String PLUGIN_CONFIG_PROP_CONTROL_SCRIPT_PATH = "controlScriptPath";
public static final String PLUGIN_CONFIG_PROP_URL = "url";
public static final String PLUGIN_CONFIG_PROP_HTTPD_CONF = "configFile";
+ public static final String AUGEAS_HTTP_MODULE_NAME = "Httpd";
public static final String PLUGIN_CONFIG_PROP_SNMP_AGENT_HOST = "snmpAgentHost";
public static final String PLUGIN_CONFIG_PROP_SNMP_AGENT_PORT = "snmpAgentPort";
@@ -122,9 +127,9 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
public static final String PLUGIN_CONFIG_PROP_ERROR_LOG_INCLUDES_PATTERN = "errorLogIncludesPattern";
public static final String PLUGIN_CONFIG_PROP_VHOST_FILES_MASK = "vhostFilesMask";
public static final String PLUGIN_CONFIG_PROP_VHOST_CREATION_POLICY = "vhostCreationPolicy";
-
+
public static final String PLUGIN_CONFIG_PROP_RESTART_AFTER_CONFIG_UPDATE = "restartAfterConfigurationUpdate";
-
+
public static final String PLUGIN_CONFIG_VHOST_IN_SINGLE_FILE_PROP_VALUE = "single-file";
public static final String PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE = "vhost-per-file";
@@ -148,7 +153,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
private static final String[] CONTROL_SCRIPT_PATHS = { "bin/apachectl", "sbin/apachectl", "bin/apachectl2",
"sbin/apachectl2" };
-
+
private ResourceContext<PlatformComponent> resourceContext;
private EventContext eventContext;
private SNMPClient snmpClient;
@@ -174,14 +179,13 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
SNMPSession snmpSession = getSNMPSession();
if (!snmpSession.ping()) {
- log
- .warn("Failed to connect to SNMP agent at "
- + snmpSession
- + "\n"
- + ". Make sure\n1) the managed Apache server has been instrumented with the JON SNMP module,\n"
- + "2) the Apache server is running, and\n"
- + "3) the SNMP agent host, port, and community are set correctly in this resource's connection properties.\n"
- + "The agent will not be able to record metrics from apache httpd without SNMP");
+ log.warn("Failed to connect to SNMP agent at "
+ + snmpSession
+ + "\n"
+ + ". Make sure\n1) the managed Apache server has been instrumented with the JON SNMP module,\n"
+ + "2) the Apache server is running, and\n"
+ + "3) the SNMP agent host, port, and community are set correctly in this resource's connection properties.\n"
+ + "The agent will not be able to record metrics from apache httpd without SNMP");
} else {
configured = true;
}
@@ -192,11 +196,10 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
try {
this.url = new URL(url);
if (this.url.getPort() == 0) {
- log
- .error("The 'url' connection property is invalid - 0 is not a valid port; please change the value to the "
- + "port the \"main\" Apache server is listening on. NOTE: If the 'url' property was set this way "
- + "after autodiscovery, you most likely did not include the port in the ServerName directive for "
- + "the \"main\" Apache server in httpd.conf.");
+ log.error("The 'url' connection property is invalid - 0 is not a valid port; please change the value to the "
+ + "port the \"main\" Apache server is listening on. NOTE: If the 'url' property was set this way "
+ + "after autodiscovery, you most likely did not include the port in the ServerName directive for "
+ + "the \"main\" Apache server in httpd.conf.");
} else {
configured = true;
}
@@ -213,15 +216,15 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
File executablePath = getExecutablePath();
try {
- this.binaryInfo = ApacheBinaryInfo.getInfo(executablePath.getPath(), this.resourceContext
- .getSystemInformation());
+ this.binaryInfo = ApacheBinaryInfo.getInfo(executablePath.getPath(),
+ this.resourceContext.getSystemInformation());
} catch (Exception e) {
throw new InvalidPluginConfigurationException("'" + executablePath
+ "' is not a valid Apache executable (" + e + ").");
}
- this.operationsDelegate = new ApacheServerOperationsDelegate(this, pluginConfig, this.resourceContext
- .getSystemInformation());
+ this.operationsDelegate = new ApacheServerOperationsDelegate(this, pluginConfig,
+ this.resourceContext.getSystemInformation());
//init the module names with the defaults
moduleNames = new HashMap<String, String>(ApacheServerDiscoveryComponent.getDefaultModuleNames(binaryInfo.getVersion()));
@@ -336,31 +339,38 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
}
public Configuration loadResourceConfiguration() throws Exception {
+
if (!isAugeasEnabled())
throw new RuntimeException(CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
+ AugeasComponent comp = getAugeas();
try {
ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
.getResourceConfigurationDefinition();
- AugeasTree tree = getAugeasTree();
+ AugeasTree tree = comp.getAugeasTree(AUGEAS_HTTP_MODULE_NAME);
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
return mapping.updateConfiguration(tree.getRootNode(), resourceConfigDef);
} catch (Exception e) {
log.error("Failed to load Apache configuration.", e);
throw e;
+ } finally {
+ comp.close();
}
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
- if (!isAugeasEnabled()){
+ if (!isAugeasEnabled()) {
report.setStatus(ConfigurationUpdateStatus.FAILURE);
return;
}
+
+ AugeasComponent comp = getAugeas();
+
Configuration originalConfig = report.getConfiguration().deepCopy(true);
AugeasTree tree = null;
try {
- tree = getAugeasTree();
+ tree = comp.getAugeasTree(AUGEAS_HTTP_MODULE_NAME);
ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
.getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
@@ -370,182 +380,198 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
log.info("Apache configuration was updated");
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
-
+
finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null) {
log.error("Augeas failed to save configuration " + tree.summarizeAugeasError());
e = new AugeasException("Failed to save configuration: " + tree.summarizeAugeasError() + " ", e);
- }
- else
+ } else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
report.setErrorMessageFromThrowable(e);
if (!originalConfig.equals(report.getConfiguration())) {
log.error("Configuration has changed");
- }
- else {
+ } else {
log.error("Configuratio has not changed");
}
+ } finally {
+ comp.close();
}
- }
-
- public AugeasProxy getAugeasProxy() throws AugeasException {
- File tempDir = resourceContext.getDataDirectory();
- if (!tempDir.exists())
- throw new RuntimeException("Loading of lens failed");
- AugeasConfigurationApache config = new AugeasConfigurationApache(tempDir.getAbsolutePath(),resourceContext.getPluginConfiguration());
- AugeasTreeBuilderApache builder = new AugeasTreeBuilderApache();
- AugeasProxy augeasProxy = new AugeasProxy(config, builder);
- augeasProxy.load();
- return augeasProxy;
- }
-
- public AugeasTree getAugeasTree() throws AugeasException {
- AugeasProxy proxy = getAugeasProxy();
- String module = ((AugeasConfigurationApache)proxy.getConfiguration()).getAugeasModuleName();
-
- return proxy.getAugeasTree(module, true);
}
-
+
+ public AugeasComponent getAugeas() throws AugeasTreeException {
+ return new AugeasComponent() {
+
+ public AugeasConfiguration initConfiguration() {
+ File tempDir = resourceContext.getDataDirectory();
+ if (!tempDir.exists())
+ throw new RuntimeException("Loading of lens failed");
+ AugeasConfigurationApache config = new AugeasConfigurationApache(tempDir.getAbsolutePath(),
+ resourceContext.getPluginConfiguration());
+ return config;
+ }
+
+ public AugeasTreeBuilder initTreeBuilder() {
+ AugeasTreeBuilderApache builder = new AugeasTreeBuilderApache();
+ return builder;
+ }
+
+ };
+ }
+
public CreateResourceReport createResource(CreateResourceReport report) {
- if (!isAugeasEnabled()){
+ if (!isAugeasEnabled()) {
report.setStatus(CreateResourceStatus.FAILURE);
report.setErrorMessage("Resources can be created only when augeas is enabled.");
return report;
}
if (ApacheVirtualHostServiceComponent.RESOURCE_TYPE_NAME.equals(report.getResourceType().getName())) {
Configuration vhostResourceConfig = report.getResourceConfiguration();
- ConfigurationDefinition vhostResourceConfigDef = report.getResourceType().getResourceConfigurationDefinition();
+ ConfigurationDefinition vhostResourceConfigDef = report.getResourceType()
+ .getResourceConfigurationDefinition();
Configuration vhostPluginConfig = report.getPluginConfiguration();
-
+
String vhostDef = report.getUserSpecifiedResourceName();
- String serverName = vhostResourceConfig.getSimpleValue(ApacheVirtualHostServiceComponent.SERVER_NAME_CONFIG_PROP, null);
-
+ String serverName = vhostResourceConfig.getSimpleValue(
+ ApacheVirtualHostServiceComponent.SERVER_NAME_CONFIG_PROP, null);
+
//determine the resource key
String resourceKey = vhostDef;
if (serverName != null) {
resourceKey = serverName + "|" + resourceKey;
}
-
- //determine the resource name
- AugeasProxy proxy = getAugeasProxy();
- AugeasTree tree = getAugeasTree();
+
String[] vhostDefs = vhostDef.split(" ");
- HttpdAddressUtility.Address addr;
- try{
+ HttpdAddressUtility.Address addr;
+ try {
ApacheDirectiveTree parserTree = new ApacheDirectiveTree();
- ApacheParser parser = new ApacheParserImpl(parserTree,getServerRoot().getAbsolutePath());
-
+ ApacheParser parser = new ApacheParserImpl(parserTree, getServerRoot().getAbsolutePath());
+
ApacheConfigReader.buildTree(getHttpdConfFile().getAbsolutePath(), parser);
+
Pattern virtualHostPattern = Pattern.compile(".+:([\\d]+|\\*)");
Matcher matcher = virtualHostPattern.matcher(vhostDefs[0]);
if (!matcher.matches())
- throw new Exception("Wrong format of virtual host resource name. The right format is Address:Port.");
-
+ throw new Exception("Wrong format of virtual host resource name. The right format is Address:Port.");
+
addr = getAddressUtility().getVirtualHostSampleAddress(parserTree, vhostDefs[0], serverName, false);
} catch (Exception e) {
- report.setStatus(CreateResourceStatus.FAILURE);
- report.setErrorMessage("Wrong format of virtual host resource name.");
- report.setException(e);
- return report;
- }
-
+ report.setStatus(CreateResourceStatus.FAILURE);
+ report.setErrorMessage("Wrong format of virtual host resource name.");
+ report.setException(e);
+ return report;
+ }
+
String resourceName;
if (serverName != null) {
resourceName = addr.host + ":" + addr.port;
} else {
resourceName = resourceKey;
}
-
+
report.setResourceKey(resourceKey);
report.setResourceName(resourceName);
- //fill in the plugin config
- String url = "http://" + addr.host + ":" + addr.port + "/";
- vhostPluginConfig.put(new PropertySimple(ApacheVirtualHostServiceComponent.URL_CONFIG_PROP, url));
-
- //determine the sequence number of the new vhost
- List<AugeasNode> existingVhosts = tree.matchRelative(tree.getRootNode(), "<VirtualHost");
- int seq = existingVhosts.size() + 1;
-
- Configuration pluginConfig = resourceContext.getPluginConfiguration();
- String creationType = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_VHOST_CREATION_POLICY,
- PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE);
+ AugeasComponent comp = getAugeas();
+ //determine the resource name
- AugeasNode vhost = null;
- String vhostFile = proxy.getConfiguration().getModules().get(0).getConfigFiles().get(0);
-
- if (PLUGIN_CONFIG_VHOST_IN_SINGLE_FILE_PROP_VALUE.equals(creationType)) {
- vhost = tree.createNode(tree.getRootNode(), "<VirtualHost", null, seq);
- } else if (PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE.equals(creationType)) {
- String mask = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_VHOST_FILES_MASK, null);
- if (mask == null) {
- report.setErrorMessage("No virtual host file mask configured.");
- } else {
- vhostFile = getNewVhostFileName(addr, mask);
- File vhostFileFile = new File(vhostFile);
-
- //we're creating a new file here, so we must ensure that Augeas does have this file
- //on its load path, otherwise it will refuse to create it.
- AugeasConfigurationApache config = (AugeasConfigurationApache) proxy.getConfiguration();
- AugeasModuleConfig moduleConfig = config.getModuleByName(config.getAugeasModuleName());
- boolean willPersist = false;
- for(String glob : moduleConfig.getIncludedGlobs()) {
- if (Glob.matches(getServerRoot(), glob, vhostFileFile)) {
- willPersist = true;
- break;
+ AugeasTree tree;
+ try {
+
+ tree = comp.getAugeasTree(AUGEAS_HTTP_MODULE_NAME);
+ //fill in the plugin config
+ String url = "http://" + addr.host + ":" + addr.port + "/";
+ vhostPluginConfig.put(new PropertySimple(ApacheVirtualHostServiceComponent.URL_CONFIG_PROP, url));
+
+ //determine the sequence number of the new vhost
+ List<AugeasNode> existingVhosts = tree.matchRelative(tree.getRootNode(), "<VirtualHost");
+ int seq = existingVhosts.size() + 1;
+
+ Configuration pluginConfig = resourceContext.getPluginConfiguration();
+ String creationType = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_VHOST_CREATION_POLICY,
+ PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE);
+
+ AugeasNode vhost = null;
+
+ String vhostFile = comp.getConfiguration().getModules().get(0).getConfigFiles().get(0);
+
+ if (PLUGIN_CONFIG_VHOST_IN_SINGLE_FILE_PROP_VALUE.equals(creationType)) {
+ vhost = tree.createNode(tree.getRootNode(), "<VirtualHost", null, seq);
+ } else if (PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE.equals(creationType)) {
+ String mask = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_VHOST_FILES_MASK, null);
+ if (mask == null) {
+ report.setErrorMessage("No virtual host file mask configured.");
+ } else {
+ vhostFile = getNewVhostFileName(addr, mask);
+ File vhostFileFile = new File(vhostFile);
+
+ //we're creating a new file here, so we must ensure that Augeas does have this file
+ //on its load path, otherwise it will refuse to create it.
+ AugeasConfigurationApache config = (AugeasConfigurationApache) comp.getConfiguration();
+ AugeasModuleConfig moduleConfig = config.getModuleByName(config.getAugeasModuleName());
+ boolean willPersist = false;
+ for (String glob : moduleConfig.getIncludedGlobs()) {
+ if (Glob.matches(getServerRoot(), glob, vhostFileFile)) {
+ willPersist = true;
+ break;
+ }
}
- }
-
- if (!willPersist) {
- //the file wouldn't be loaded by augeas
- moduleConfig.addIncludedGlob(vhostFile);
- }
-
- try {
- vhostFileFile.createNewFile();
- } catch (IOException e) {
- log.error("Failed to create a new vhost file: " + vhostFile, e);
- }
-
- proxy.load();
- tree = proxy.getAugeasTree(moduleConfig.getModuletName(), true);
-
- vhost = tree.createNode(AugeasTree.AUGEAS_DATA_PATH + vhostFile + "/<VirtualHost");
- ((ApacheAugeasNode)vhost).setParentNode(tree.getRootNode());
-
- if (!willPersist) {
- //this also means that there was no include
- //that would load the file, so we have to
- //add the include directive to the main conf.
- List<AugeasNode> includes = tree.matchRelative(tree.getRootNode(), "Include");
- AugeasNode include = tree.createNode(tree.getRootNode(), "Include", null, includes.size() + 1);
- tree.createNode(include, "param", vhostFile, 0);
+
+ if (!willPersist) {
+ //the file wouldn't be loaded by augeas
+ moduleConfig.addIncludedGlob(vhostFile);
+ //this also means that there was no include
+ //that would load the file, so we have to
+ //add the include directive to the main conf.
+ List<AugeasNode> includes = tree.matchRelative(tree.getRootNode(), "Include");
+ AugeasNode include = tree.createNode(tree.getRootNode(), "Include", null,
+ includes.size() + 1);
+ tree.createNode(include, "param", vhostFile, 0);
+ tree.save();
+ }
+
+ try {
+ vhostFileFile.createNewFile();
+ } catch (IOException e) {
+ log.error("Failed to create a new vhost file: " + vhostFile, e);
+ }
+
+ comp.close();
+ comp = getAugeas();
+ tree = comp.getAugeasTree(moduleConfig.getModuletName());
+
+ vhost = tree.createNode(AugeasTree.AUGEAS_DATA_PATH + vhostFile + "/<VirtualHost");
+ ((ApacheAugeasNode) vhost).setParentNode(tree.getRootNode());
+
}
}
- }
-
- if (vhost == null) {
- report.setStatus(CreateResourceStatus.FAILURE);
- } else {
- try {
- for(int i = 0; i < vhostDefs.length; ++i) {
- tree.createNode(vhost, "param", vhostDefs[i], i + 1);
- }
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- mapping.updateAugeas(vhost, vhostResourceConfig, vhostResourceConfigDef);
-
- tree.save();
- report.setStatus(CreateResourceStatus.SUCCESS);
-
- finishChildResourceCreate(report);
- } catch (Exception e) {
+
+ if (vhost == null) {
report.setStatus(CreateResourceStatus.FAILURE);
- report.setException(e);
+ } else {
+ try {
+ for (int i = 0; i < vhostDefs.length; ++i) {
+ tree.createNode(vhost, "param", vhostDefs[i], i + 1);
+ }
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ mapping.updateAugeas(vhost, vhostResourceConfig, vhostResourceConfigDef);
+
+ tree.save();
+ report.setStatus(CreateResourceStatus.SUCCESS);
+
+ finishChildResourceCreate(report);
+ } catch (Exception e) {
+ report.setStatus(CreateResourceStatus.FAILURE);
+ report.setException(e);
+ }
}
+ } finally {
+ if (comp != null)
+ comp.close();
}
}
+
return report;
}
@@ -604,14 +630,14 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
if (executablePath != null) {
executableFile = resolvePathRelativeToServerRoot(executablePath);
} else {
- String serverRoot=null;
-
- ApacheDirectiveTree tree = loadParser();
- List<ApacheDirective> directives = tree.search("/ServerRoot");
- if (!directives.isEmpty())
- if (!directives.get(0).getValues().isEmpty())
- serverRoot = directives.get(0).getValues().get(0);
-
+ String serverRoot = null;
+
+ ApacheDirectiveTree tree = loadParser();
+ List<ApacheDirective> directives = tree.search("/ServerRoot");
+ if (!directives.isEmpty())
+ if (!directives.get(0).getValues().isEmpty())
+ serverRoot = directives.get(0).getValues().get(0);
+
SystemInfo systemInfo = this.resourceContext.getSystemInformation();
if (systemInfo.getOperatingSystemType() != OperatingSystemType.WINDOWS) // UNIX
{
@@ -635,10 +661,11 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
/**
* @return The url the server is pinged for availability or null if the url is not set.
*/
- public @Nullable String getServerUrl() {
+ public @Nullable
+ String getServerUrl() {
return resourceContext.getPluginConfiguration().getSimpleValue(PLUGIN_CONFIG_PROP_URL, null);
}
-
+
/**
* Returns the httpd.conf file
* @return A File object that represents the httpd.conf file or null in case of error
@@ -691,19 +718,20 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
}
}
}
-
+
//only try harder on the control script path on OSes with UNIX file system layout
- if (!found && resourceContext.getSystemInformation().getOperatingSystemType() != OperatingSystemType.WINDOWS) {
+ if (!found
+ && resourceContext.getSystemInformation().getOperatingSystemType() != OperatingSystemType.WINDOWS) {
String executablePath = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_EXECUTABLE_PATH, null);
if (executablePath != null) {
// this is now something like /usr/sbin/httpd .. trim off the last 2 parts
int i = executablePath.lastIndexOf(File.separatorChar);
-
+
if (i >= 0) {
executablePath = executablePath.substring(0, i);
i = executablePath.lastIndexOf(File.separatorChar);
}
-
+
if (i >= 0) {
executablePath = executablePath.substring(0, i);
for (String path : CONTROL_SCRIPT_PATHS) {
@@ -713,10 +741,10 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
break;
}
}
- }
+ }
}
}
-
+
if (!found) {
controlScriptFile = getExecutablePath(); // fall back to the httpd binary
}
@@ -727,11 +755,11 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
@NotNull
public ConfigurationTimestamp getConfigurationTimestamp() {
- AugeasConfigurationApache config = new AugeasConfigurationApache(resourceContext.getTemporaryDirectory().getAbsolutePath(),
- resourceContext.getPluginConfiguration());
+ AugeasConfigurationApache config = new AugeasConfigurationApache(resourceContext.getTemporaryDirectory()
+ .getAbsolutePath(), resourceContext.getPluginConfiguration());
return new ConfigurationTimestamp(config.getAllConfigurationFiles());
}
-
+
/**
* This method is supposed to be called from {@link #updateResourceConfiguration(ConfigurationUpdateReport)}
* of this resource and any child resources.
@@ -748,7 +776,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
report.setErrorMessageFromThrowable(e);
}
}
-
+
/**
* This method is akin to {@link #finishConfigurationUpdate(ConfigurationUpdateReport)} but should
* be used in the {@link #createResource(CreateResourceReport)} method.
@@ -763,7 +791,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
report.setException(e);
}
}
-
+
/**
* Conditionally restarts the server based on the settings in the plugin configuration of the server.
*
@@ -776,7 +804,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
operationsDelegate.invokeOperation("graceful_restart", new Configuration());
}
}
-
+
/**
* This method checks whether the supplied node that has been deleted from the tree didn't leave
* the file it was contained in empty.
@@ -787,7 +815,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
public void deleteEmptyFile(AugeasTree tree, AugeasNode deletedNode) {
File file = tree.getFile(deletedNode);
List<AugeasNode> fileContents = tree.match(file.getAbsolutePath() + AugeasTree.PATH_SEPARATOR + "*");
-
+
if (fileContents.size() == 0) {
file.delete();
}
@@ -909,13 +937,13 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
String version = getVersion();
return HttpdAddressUtility.get(version);
}
-
+
private String getNewVhostFileName(HttpdAddressUtility.Address address, String mask) {
String filename = address.host + "_" + address.port;
String fullPath = mask.replace("*", filename);
-
+
File file = getFileRelativeToServerRoot(fullPath);
-
+
int i = 1;
while (file.exists()) {
filename = address.host + "_" + address.port + "-" + (i++);
@@ -924,40 +952,48 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
}
return file.getAbsolutePath();
}
-
+
private File getFileRelativeToServerRoot(String path) {
File f = new File(path);
if (f.isAbsolute()) {
return f;
} else {
return new File(getServerRoot(), path);
- }
+ }
}
-
- public ApacheDirectiveTree loadParser(){
+
+ public ApacheDirectiveTree loadParser() {
ApacheDirectiveTree tree = new ApacheDirectiveTree();
- ApacheParser parser = new ApacheParserImpl(tree,getServerRoot().getAbsolutePath());
+ ApacheParser parser = new ApacheParserImpl(tree, getServerRoot().getAbsolutePath());
ApacheConfigReader.buildTree(getHttpdConfFile().getAbsolutePath(), parser);
- return tree;
+ return tree;
}
-
+
public boolean isAugeasEnabled() {
-
+
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
PropertySimple prop = pluginConfig.getSimple(AUGEAS_ENABLED);
- if (prop == null || prop.getStringValue() == null)
- {
+ if (prop == null || prop.getStringValue() == null) {
return false;
- }
-
+ }
+
String val = prop.getStringValue();
-
- if (val.equals("yes")){
- try {
- Augeas ag = new Augeas();
- }catch(Exception e){
- log.error("Augeas is enabled in configuration but was not found on the system.");
- throw new RuntimeException(CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
+
+ if (val.equals("yes")) {
+ Augeas ag = null;
+ try {
+ ag = new Augeas();
+ } catch (Exception e) {
+ log.error("Augeas is enabled in configuration but was not found on the system.", e);
+ throw new RuntimeException(CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
+ } finally {
+ if (ag != null) {
+ try {
+ ag.close();
+ } catch (Exception e) {
+ }
+ ag = null;
+ }
}
String version = getVersion();
@@ -966,8 +1002,8 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
throw new RuntimeException(CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
}
return true;
- }else{
- return false;
+ } else {
+ return false;
}
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
index 922f943..c83c665 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
@@ -29,6 +29,7 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
@@ -93,7 +94,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
private int snmpWwwServiceIndex = -1;
public static final String RESOURCE_TYPE_NAME = "Apache Virtual Host";
-
+
public void start(ResourceContext<ApacheServerComponent> resourceContext) throws Exception {
this.resourceContext = resourceContext;
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
@@ -113,7 +114,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
+ "') is not a valid URL.");
}
}
-
+
ResponseTimeConfiguration responseTimeConfig = new ResponseTimeConfiguration(pluginConfig);
File logFile = responseTimeConfig.getLogFile();
if (logFile != null) {
@@ -155,20 +156,26 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
public Configuration loadResourceConfiguration() throws Exception {
ApacheServerComponent parent = resourceContext.getParentResourceComponent();
if (!parent.isAugeasEnabled())
- throw new Exception(ApacheServerComponent.CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
-
- AugeasTree tree = getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
- .getResourceConfigurationDefinition();
+ throw new Exception(ApacheServerComponent.CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
+
+ AugeasComponent comp = getAugeas();
+ try {
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- return mapping.updateConfiguration(getNode(tree), resourceConfigDef);
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ return mapping.updateConfiguration(getNode(tree), resourceConfigDef);
+ } finally {
+ comp.close();
+ }
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ AugeasComponent comp = getAugeas();
AugeasTree tree = null;
try {
- tree = getServerConfigurationTree();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
.getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
@@ -178,7 +185,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
log.info("Apache configuration was updated");
-
+
finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null)
@@ -186,31 +193,37 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ } finally {
+ comp.close();
}
}
public void deleteResource() throws Exception {
ApacheServerComponent parent = resourceContext.getParentResourceComponent();
if (!parent.isAugeasEnabled())
- throw new Exception(ApacheServerComponent.CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
-
+ throw new Exception(ApacheServerComponent.CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
+
if (MAIN_SERVER_RESOURCE_KEY.equals(resourceContext.getResourceKey())) {
- throw new IllegalArgumentException("Cannot delete the virtual host representing the main server configuration.");
+ throw new IllegalArgumentException(
+ "Cannot delete the virtual host representing the main server configuration.");
}
-
- AugeasTree tree = getServerConfigurationTree();
-
+
+ AugeasComponent comp = getAugeas();
+
try {
- AugeasNode myNode = getNode(getServerConfigurationTree());
-
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ AugeasNode myNode = getNode(tree);
+
tree.removeNode(myNode, true);
tree.save();
-
+
deleteEmptyFile(tree, myNode);
conditionalRestart();
} catch (IllegalStateException e) {
//this means we couldn't find the augeas node for this vhost.
//that error can be safely ignored in this situation.
+ } finally {
+ comp.close();
}
}
@@ -261,82 +274,106 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
}
public CreateResourceReport createResource(CreateResourceReport report) {
- if (!isAugeasEnabled()){
+ if (!isAugeasEnabled()) {
report.setStatus(CreateResourceStatus.FAILURE);
report.setErrorMessage("Resources can be created only when augeas is enabled.");
return report;
}
ResourceType resourceType = report.getResourceType();
-
- if (resourceType.equals(getDirectoryResourceType())) {
- Configuration resourceConfiguration = report.getResourceConfiguration();
- Configuration pluginConfiguration = report.getPluginConfiguration();
-
- String directoryName = report.getUserSpecifiedResourceName();
-
- //fill in the plugin configuration
-
- //get the directive index
- AugeasTree tree = getServerConfigurationTree();
- AugeasNode myNode = getNode(tree);
- List<AugeasNode> directories = myNode.getChildByLabel("<Directory");
- int seq = 1;
- /*
- * myNode will be parent node of the new Directory node.
- * We need to create a new node for directory node which will contain child nodes.
- * To create a node we can call method from AugeasTree which will create a node. In this method is
- * parameter sequence, if we will leave this parameter empty and there will be more nodes with
- * the same label, new node will be created but the method createNode will return node with index 0 resp 1.
- * If that will happen we can not update the node anymore because we are updating wrong node.
- * To avoid this situation we need to know what is the last sequence nr. of virtual host's child (directory) nodes.
- * We can not just count child nodes with the same label because some of the child nodes
- * could be stored in another file. So that in httpd configurationstructure they are child nodes of virtual host,
- * but in augeas configuration structure they can be child nodes of node Include[];.
- */
-
- for (AugeasNode n : directories) {
- String param = n.getFullPath();
- int end = param.lastIndexOf(File.separatorChar);
- if (end != -1)
- if (myNode.getFullPath().equals(param.substring(0,end)))
- seq++;
+ AugeasComponent comp = null;
+ try {
+ comp = getAugeas();
+ if (resourceType.equals(getDirectoryResourceType())) {
+ Configuration resourceConfiguration = report.getResourceConfiguration();
+ Configuration pluginConfiguration = report.getPluginConfiguration();
+
+ String directoryName = report.getUserSpecifiedResourceName();
+
+ //fill in the plugin configuration
+
+ //get the directive index
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ AugeasNode myNode = getNode(tree);
+ List<AugeasNode> directories = myNode.getChildByLabel("<Directory");
+ int seq = 1;
+ /*
+ * myNode will be parent node of the new Directory node.
+ * We need to create a new node for directory node which will contain child nodes.
+ * To create a node we can call method from AugeasTree which will create a node. In this method is
+ * parameter sequence, if we will leave this parameter empty and there will be more nodes with
+ * the same label, new node will be created but the method createNode will return node with index 0 resp 1.
+ * If that will happen we can not update the node anymore because we are updating wrong node.
+ * To avoid this situation we need to know what is the last sequence nr. of virtual host's child (directory) nodes.
+ * We can not just count child nodes with the same label because some of the child nodes
+ * could be stored in another file. So that in httpd configurationstructure they are child nodes of virtual host,
+ * but in augeas configuration structure they can be child nodes of node Include[];.
+ */
+
+ for (AugeasNode n : directories) {
+ String param = n.getFullPath();
+ int end = param.lastIndexOf(File.separatorChar);
+ if (end != -1)
+ if (myNode.getFullPath().equals(param.substring(0, end)))
+ seq++;
}
-
- //pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.DIRECTIVE_INDEX_PROP, seq));
- //we don't support this yet... need to figure out how...
- pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.REGEXP_PROP, false));
- String dirNameToSet = AugeasNodeValueUtil.escape(directoryName);
-
- //now actually create the data in augeas
- try {
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- AugeasNode directoryNode = tree.createNode(myNode, "<Directory", null, seq);
- tree.createNode(directoryNode, "param", dirNameToSet, 0);
- mapping.updateAugeas(directoryNode, resourceConfiguration, resourceType.getResourceConfigurationDefinition());
- tree.save();
-
-
- tree = getServerConfigurationTree();
- String key = AugeasNodeSearch.getNodeKey(myNode, directoryNode);
- report.setResourceKey(key);
- report.setResourceName(directoryName);
-
- report.setStatus(CreateResourceStatus.SUCCESS);
-
- resourceContext.getParentResourceComponent().finishChildResourceCreate(report);
- } catch (Exception e) {
- report.setException(e);
+
+ //pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.DIRECTIVE_INDEX_PROP, seq));
+ //we don't support this yet... need to figure out how...
+ pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.REGEXP_PROP, false));
+ String dirNameToSet = AugeasNodeValueUtil.escape(directoryName);
+
+ //now actually create the data in augeas
+ try {
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ AugeasNode directoryNode = tree.createNode(myNode, "<Directory", null, seq);
+ String myNodeKey = AugeasNodeSearch.getNodeKey(myNode, tree.getRootNode());
+ tree.createNode(directoryNode, "param", dirNameToSet, 0);
+ mapping.updateAugeas(directoryNode, resourceConfiguration,
+ resourceType.getResourceConfigurationDefinition());
+
+ tree.save();
+ comp.close();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+
+ AugeasNode parentNode;
+ if (myNodeKey.equals("")) {
+ parentNode = tree.getRootNode();
+ } else
+ parentNode = AugeasNodeSearch.findNodeById(tree.getRootNode(), myNodeKey);
+
+ List<AugeasNode> nodes = parentNode.getChildByLabel("<Directory");
+ if (nodes.size() < seq) {
+ report.setStatus(CreateResourceStatus.FAILURE);
+ report.setErrorMessage("Could not create directory node.");
+ }
+
+ AugeasNode nd = nodes.get(seq - 1);
+ String key = AugeasNodeSearch.getNodeKey(nd, parentNode);
+
+ report.setResourceKey(key);
+ report.setResourceName(directoryName);
+
+ report.setStatus(CreateResourceStatus.SUCCESS);
+
+ resourceContext.getParentResourceComponent().finishChildResourceCreate(report);
+ } catch (Exception e) {
+ log.error("Could not create httpd virtual host child resource.", e);
+ report.setException(e);
+ report.setStatus(CreateResourceStatus.FAILURE);
+ }
+ } else {
+ report.setErrorMessage("Unable to create resources of type " + resourceType.getName());
report.setStatus(CreateResourceStatus.FAILURE);
}
- } else {
- report.setErrorMessage("Unable to create resources of type " + resourceType.getName());
- report.setStatus(CreateResourceStatus.FAILURE);
+ } finally {
+ if (comp != null)
+ comp.close();
}
return report;
}
-
- public AugeasTree getServerConfigurationTree() {
- return resourceContext.getParentResourceComponent().getAugeasTree();
+
+ public AugeasComponent getAugeas() {
+ return resourceContext.getParentResourceComponent().getAugeas();
}
/**
@@ -398,7 +435,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
public void finishConfigurationUpdate(ConfigurationUpdateReport report) {
resourceContext.getParentResourceComponent().finishConfigurationUpdate(report);
}
-
+
/**
* @see ApacheServerComponent#conditionalRestart()
*
@@ -407,11 +444,11 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
public void conditionalRestart() throws Exception {
resourceContext.getParentResourceComponent().conditionalRestart();
}
-
+
public void deleteEmptyFile(AugeasTree tree, AugeasNode deletedNode) {
resourceContext.getParentResourceComponent().deleteEmptyFile(tree, deletedNode);
}
-
+
private void collectSnmpMetric(MeasurementReport report, int primaryIndex, SNMPSession snmpSession,
MeasurementScheduleRequest schedule) throws SNMPException {
SNMPValue snmpValue = null;
@@ -565,13 +602,13 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
private ResourceType getDirectoryResourceType() {
return resourceContext.getResourceType().getChildResourceTypes().iterator().next();
}
-
- public ApacheDirectiveTree loadParser() throws Exception{
+
+ public ApacheDirectiveTree loadParser() throws Exception {
return resourceContext.getParentResourceComponent().loadParser();
}
-
- public boolean isAugeasEnabled(){
+
+ public boolean isAugeasEnabled() {
ApacheServerComponent parent = resourceContext.getParentResourceComponent();
- return parent.isAugeasEnabled();
+ return parent.isAugeasEnabled();
}
}
\ No newline at end of file
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasComponent.java
new file mode 100644
index 0000000..d41490f
--- /dev/null
+++ b/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasComponent.java
@@ -0,0 +1,52 @@
+package org.rhq.augeas;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.augeas.config.AugeasConfiguration;
+import org.rhq.augeas.tree.AugeasTree;
+import org.rhq.augeas.tree.AugeasTreeBuilder;
+
+public abstract class AugeasComponent {
+
+ AugeasProxy augeasProxy;
+ boolean isClosed = true;
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public abstract AugeasConfiguration initConfiguration();
+
+ public abstract AugeasTreeBuilder initTreeBuilder();
+
+ protected void reloadAugeas() {
+ if (!isClosed)
+ close();
+
+ augeasProxy = new AugeasProxy(initConfiguration(), initTreeBuilder());
+ augeasProxy.load();
+ isClosed = false;
+ }
+
+ public AugeasTree getAugeasTree(String moduleName) {
+ reloadAugeas();
+ return augeasProxy.getAugeasTree(moduleName, true);
+ }
+
+ public void close() {
+ isClosed = true;
+ if (augeasProxy != null) {
+ try {
+ augeasProxy.close();
+ } catch (Exception e) {
+ log.error("Could not close augeas instance", e);
+ }
+ }
+ }
+
+ public AugeasConfiguration getConfiguration() {
+ if (augeasProxy == null)
+ throw new RuntimeException("Could not provide augeas configuration because augeas was not initialized yet.");
+
+ return augeasProxy.getConfiguration();
+ }
+
+}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java b/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java
index 262bf95..12403a5 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java
@@ -23,7 +23,6 @@
package org.rhq.augeas;
import java.io.File;
-import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@@ -32,13 +31,13 @@ import net.augeas.AugeasException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.rhq.augeas.config.AugeasConfiguration;
import org.rhq.augeas.config.AugeasModuleConfig;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.augeas.tree.AugeasTreeBuilder;
import org.rhq.augeas.tree.AugeasTreeException;
import org.rhq.augeas.tree.impl.DefaultAugeasTreeBuilder;
-import org.rhq.plugins.augeas.AugeasPluginLifecycleListener;
/**
* This is the main entry point for interfacing with Augeas.
@@ -53,13 +52,13 @@ import org.rhq.plugins.augeas.AugeasPluginLifecycleListener;
*
*/
public class AugeasProxy {
-
- private final Log log = LogFactory.getLog(this.getClass());
+
+ private final Log log = LogFactory.getLog(this.getClass());
private AugeasConfiguration config;
private Augeas augeas;
private List<String> modules;
private AugeasTreeBuilder augeasTreeBuilder;
-
+
/**
* Instantiates new proxy with supplied configuration and
* {@link DefaultAugeasTreeBuilder} as the tree builder.
@@ -99,13 +98,20 @@ public class AugeasProxy {
public void load() throws AugeasTreeException {
try {
config.loadFiles();
+ if (augeas != null) {
+ try {
+ augeas.close();
+ } catch (Exception e) {
+ log.error("Could not close augeas instance", e);
+ }
+ }
augeas = new Augeas(config.getRootPath(), config.getLoadPath(), config.getMode());
-
+
for (AugeasModuleConfig module : config.getModules()) {
-
+
modules.add(module.getModuletName());
augeas.set("/augeas/load/" + module.getModuletName() + "/lens", module.getLensPath());
-
+
int idx = 1;
for (String incl : module.getConfigFiles()) {
augeas.set("/augeas/load/" + module.getModuletName() + "/incl[" + (idx++) + "]", incl);
@@ -118,8 +124,6 @@ public class AugeasProxy {
throw new AugeasException(e);
}
}
-
-
/**
* Produces the Augeas tree by loading it from augeas (if {@link #load()} wasn't called already)
@@ -178,4 +182,24 @@ public class AugeasProxy {
public Augeas getAugeas() {
return augeas;
}
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#finalize()
+ */
+ @Override
+ protected void finalize() throws Throwable {
+ close();
+ super.finalize();
+ }
+
+ public void close() {
+ if (augeas != null) {
+ try {
+ augeas.close();
+ } catch (Exception e) {
+ log.error("Could not close augeas instance", e);
+ }
+ augeas = null;
+ }
+ }
}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
index 9cd2e50..ec0dee8 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
@@ -141,41 +141,45 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
public Configuration loadResourceConfiguration() throws Exception {
abortIfAugeasNotAvailable();
- // Load the config file from disk and build a tree representation of it.
- loadConfigurationFiles(this.augeas);
+ //augeas was initialized in abortIfAugeasNotAvailable();
+ try {
+ ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
+ Configuration resourceConfig = new Configuration();
+ resourceConfig.setNotes("Loaded from Augeas at " + new Date());
- ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
- .getResourceConfigurationDefinition();
- Configuration resourceConfig = new Configuration();
- resourceConfig.setNotes("Loaded from Augeas at " + new Date());
+ Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
- Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
+ for (PropertyDefinition propDef : propDefs) {
+ loadProperty(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
+ }
- for (PropertyDefinition propDef : propDefs) {
- loadProperty(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
+ // This will add error messages to any PropertySimples with invalid values, so they can be displayed by the GUI.
+ validateResourceConfiguration(new ConfigurationUpdateReport(resourceConfig));
+ return resourceConfig;
+ } finally {
+ close();
}
-
- // This will add error messages to any PropertySimples with invalid values, so they can be displayed by the GUI.
- validateResourceConfiguration(new ConfigurationUpdateReport(resourceConfig));
- return resourceConfig;
}
protected void updateStructuredConfiguration(Configuration config) throws Exception {
abortIfAugeasNotAvailable();
- // Load the config files from disk and build a tree representation of them in memory.
- loadConfigurationFiles(this.augeas);
+ //augeas was initialized in abortIfAugeasNotAvailable
+ try {
+ ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
- ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
- .getResourceConfigurationDefinition();
+ Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
+ for (PropertyDefinition propDef : propDefs) {
+ setNode(propDef, config, this.augeas, this.resourceConfigRootNode);
+ }
- Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
- for (PropertyDefinition propDef : propDefs) {
- setNode(propDef, config, this.augeas, this.resourceConfigRootNode);
+ // Write the updated tree out to the config file.
+ saveConfigurationFiles();
+ } finally {
+ close();
}
-
- // Write the updated tree out to the config file.
- saveConfigurationFiles();
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
@@ -190,26 +194,29 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
log.debug("Validation of updated Resource configuration for " + this.resourceDescription
+ " failed with the following errors: " + report.getErrorMessage());
report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ close();
return;
}
- // Load the config files from disk and build a tree representation of them in memory.
- loadConfigurationFiles(this.augeas);
-
- ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
- .getResourceConfigurationDefinition();
- Configuration resourceConfig = report.getConfiguration();
+ //augeas was initialized in abortIfAugeasNotAvailable();
+ try {
+ ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
+ Configuration resourceConfig = report.getConfiguration();
- Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
- for (PropertyDefinition propDef : propDefs) {
- setNode(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
- }
+ Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
+ for (PropertyDefinition propDef : propDefs) {
+ setNode(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
+ }
- // Write the updated tree out to the config file.
- saveConfigurationFiles();
+ // Write the updated tree out to the config file.
+ saveConfigurationFiles();
- // If we got this far, we've succeeded in our mission.
- report.setStatus(ConfigurationUpdateStatus.SUCCESS);
+ // If we got this far, we've succeeded in our mission.
+ report.setStatus(ConfigurationUpdateStatus.SUCCESS);
+ } finally {
+ close();
+ }
}
public CreateResourceReport createResource(CreateResourceReport report) {
@@ -217,37 +224,47 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
ConfigurationDefinition resourceConfigDef = report.getResourceType().getResourceConfigurationDefinition();
// First insert the root node corresponding to the new child Resource.
- String rootPath = getChildResourceConfigurationRootPath(report.getResourceType(), report
- .getResourceConfiguration());
- AugeasNode rootNode = new AugeasNode(rootPath);
- if (this.augeas.exists(rootNode.getPath())) {
- report.setStatus(CreateResourceStatus.FAILURE);
- report.setErrorMessage("An Augeas node already exists with path " + rootPath);
- return report;
- }
- String rootLabel = getChildResourceConfigurationRootLabel(report.getResourceType(), report
- .getResourceConfiguration());
- this.augeas.set(rootNode.getPath(), rootLabel);
-
- // Then set all its child nodes.
- Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
- for (PropertyDefinition propDef : propDefs) {
- setNode(propDef, resourceConfig, this.augeas, rootNode);
- }
+ String rootPath = getChildResourceConfigurationRootPath(report.getResourceType(),
+ report.getResourceConfiguration());
+ initAugeas();
+ try {
+ AugeasNode rootNode = new AugeasNode(rootPath);
+ if (this.augeas.exists(rootNode.getPath())) {
+ report.setStatus(CreateResourceStatus.FAILURE);
+ report.setErrorMessage("An Augeas node already exists with path " + rootPath);
+ return report;
+ }
+ String rootLabel = getChildResourceConfigurationRootLabel(report.getResourceType(),
+ report.getResourceConfiguration());
+ this.augeas.set(rootNode.getPath(), rootLabel);
+
+ // Then set all its child nodes.
+ Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
+ for (PropertyDefinition propDef : propDefs) {
+ setNode(propDef, resourceConfig, this.augeas, rootNode);
+ }
- // Write the updated tree out to the config file.
- saveConfigurationFiles();
+ // Write the updated tree out to the config file.
+ saveConfigurationFiles();
- // If we got this far, we've succeeded in our mission.
- report.setStatus(CreateResourceStatus.SUCCESS);
- return report;
+ // If we got this far, we've succeeded in our mission.
+ report.setStatus(CreateResourceStatus.SUCCESS);
+ return report;
+ } finally {
+ close();
+ }
}
public void deleteResource() throws Exception {
String rootPath = getResourceConfigurationRootPath();
- Augeas augeas = getAugeas();
- augeas.remove(rootPath);
- augeas.save();
+ initAugeas();
+ try {
+ Augeas augeas = getAugeas();
+ augeas.remove(rootPath);
+ augeas.save();
+ } finally {
+ close();
+ }
}
/**
@@ -328,7 +345,14 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
return files;
}
+ /**
+ * Returns initialized augeas instance. Augeas instance must be closed by calling method close on the Augeas instance
+ * or by calling method close on AugeasConfigurationComponent instance after use of augeas.
+ * @return
+ */
public Augeas getAugeas() {
+ if (this.augeas == null)
+ initAugeas();
return this.augeas;
}
@@ -354,7 +378,6 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
try {
augeas = new Augeas(this.augeasRootPath, augeasLoadPath, Augeas.NO_MODL_AUTOLOAD);
setupAugeasModules(augeas);
- loadConfigurationFiles(augeas);
checkModuleErrors(augeas);
} catch (RuntimeException e) {
augeas = null;
@@ -631,14 +654,6 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
return mapKeyNames.getSimpleValue(listName, null);
}
- private void loadConfigurationFiles(Augeas augeas) {
- try {
- augeas.load();
- } catch (AugeasException e) {
- throw new RuntimeException(summarizeAugeasError(augeas), e);
- }
- }
-
private void saveConfigurationFiles() {
// TODO: Backup original file.
try {
@@ -688,8 +703,8 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
List<String> nodePaths = augeas.match(errorNode.getPath() + "/*");
for (String path : nodePaths) {
String error = augeas.get(path);
- summary.append("File \"").append(path.substring(metadataNodePrefix.length(), path.length())).append(
- "\":\n").append(error).append("\n");
+ summary.append("File \"").append(path.substring(metadataNodePrefix.length(), path.length()))
+ .append("\":\n").append(error).append("\n");
}
}
@@ -697,7 +712,16 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
}
protected void initAugeas() {
+ if (this.augeas != null) {
+ try {
+ this.augeas.close();
+ } catch (Exception e) {
+ }
+ this.augeas = null;
+ }
this.augeas = createAugeas();
+ this.augeas.load();
+ checkModuleErrors(this.augeas);
String resourceConfigRootPath = getResourceConfigurationRootPath();
if (resourceConfigRootPath.indexOf(AugeasNode.SEPARATOR_CHAR) != 0) {
// root path is relative - make it absolute
@@ -707,6 +731,7 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
this.resourceConfigRootNode = new AugeasNode(resourceConfigRootPath);
}
log.debug("Resource Config Root Node = \"" + this.resourceConfigRootNode + "\"");
+
}
private void abortIfAugeasNotAvailable() throws Exception {
@@ -747,4 +772,23 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
throw new IllegalStateException("Augeas modules didn't load cleanly.\n" + errorMessage);
}
}
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#finalize()
+ */
+ @Override
+ protected void finalize() throws Throwable {
+ close();
+ super.finalize();
+ }
+
+ public void close() {
+ if (this.augeas != null) {
+ try {
+ this.augeas.close();
+ } catch (Exception e) {
+ }
+ this.augeas = null;
+ }
+ }
}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java
index 7660de2..05e7bc4 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java
@@ -23,11 +23,8 @@
package org.rhq.rhqtransform;
-import org.rhq.augeas.AugeasProxy;
-import org.rhq.augeas.tree.AugeasTree;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.tree.AugeasTreeException;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-
/**
* An interface the RHQ resource components can implement to provide access
@@ -36,20 +33,7 @@ import org.rhq.core.pluginapi.inventory.ResourceComponent;
* @author Filip Drabek
*
*/
-public interface AugeasRHQComponent<T extends ResourceComponent> extends ResourceComponent<T> {
-
- /**
- * @return the augeas tree for the component
- * @throws AugeasTreeException
- */
- public AugeasTree getAugeasTree() throws AugeasTreeException;
+public interface AugeasRHQComponent {
- /**
- * Provides access to the Augeas proxy configured in the way this component needs
- * so that users are able to perform non-trivial operations on it.
- *
- * @return
- * @throws AugeasTreeException
- */
- public AugeasProxy getAugeasProxy() throws AugeasTreeException;
+ public AugeasComponent getAugeas() throws AugeasTreeException;
}
diff --git a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
index a7cdba4..6c8a60b 100644
--- a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
+++ b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
@@ -25,6 +25,7 @@ import java.util.List;
import net.augeas.Augeas;
import net.augeas.AugeasException;
+import org.rhq.augeas.util.GlobFilter;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.Property;
@@ -41,7 +42,6 @@ import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.plugins.augeas.AugeasConfigurationComponent;
import org.rhq.plugins.augeas.AugeasConfigurationDiscoveryComponent;
import org.rhq.plugins.augeas.helper.AugeasNode;
-import org.rhq.augeas.util.GlobFilter;
import org.rhq.plugins.platform.PlatformComponent;
/**
@@ -53,7 +53,7 @@ import org.rhq.plugins.platform.PlatformComponent;
public class CronComponent extends AugeasConfigurationComponent<PlatformComponent> implements CreateChildResourceFacet {
private static final String HOURLY_JOBS_PROP = "hourlyJobs";
- private static final String HOURLY_JOBS_NODE = "entry[time/minute != \"*\" and time/hour = \"*\" and time/dayofmonth = \"*\" and time/month = \"*\" and time/dayofweek = \"*\"]";
+ private static final String HOURLY_JOBS_NODE = "entry[time/minute != \"*\" and time/hour = \"*\" and time/dayofmonth = \"*\" and time/month = \"*\" and time/dayofweek = \"*\"]";
private static final String DAILY_JOBS_PROP = "dailyJobs";
private static final String DAILY_JOBS_NODE = "entry[time/minute != \"*\" and time/hour != \"*\" and time/dayofmonth = \"*\" and time/month = \"*\" and time/dayofweek = \"*\"]";
private static final String WEEKLY_JOBS_PROP = "weeklyJobs";
@@ -67,7 +67,7 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
private static final String AUGEAS_FILES_PREFIX = "/files";
private static final int AUGEAS_FILES_PREFIX_LENGTH = AUGEAS_FILES_PREFIX.length();
private static final String CRONTAB_RESOURCE_TYPE_NAME = "Cron Tab";
-
+
@Override
protected String getResourceConfigurationRootPath() {
return "/files/"; //the trailing slash is intentional so that we can get the
@@ -77,7 +77,8 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
public CreateResourceReport createResource(CreateResourceReport report) {
if (CRONTAB_RESOURCE_TYPE_NAME.equals(report.getResourceType().getName())) {
try {
- String resourceKey = createCrontab(report.getUserSpecifiedResourceName(), report.getResourceType().getResourceConfigurationDefinition(), report.getResourceConfiguration());
+ String resourceKey = createCrontab(report.getUserSpecifiedResourceName(), report.getResourceType()
+ .getResourceConfigurationDefinition(), report.getResourceConfiguration());
report.setResourceName(resourceKey);
report.setResourceKey(resourceKey);
report.setStatus(CreateResourceStatus.SUCCESS);
@@ -130,7 +131,7 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
private String getEntryCrontabPath(AugeasNode crontabNode) {
//the node's path is /files/blah/blah/entry/..
//we want the /blah/blah part
- return crontabNode.getParent().getParent().getPath().substring(AUGEAS_FILES_PREFIX_LENGTH);
+ return crontabNode.getParent().getParent().getPath().substring(AUGEAS_FILES_PREFIX_LENGTH);
}
/**
@@ -139,65 +140,71 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
* @param resourceConfiguration
* @return the resource key of the crontab
*/
- private String createCrontab(String resourceName, ConfigurationDefinition configurationDefinition, Configuration resourceConfiguration) {
+ private String createCrontab(String resourceName, ConfigurationDefinition configurationDefinition,
+ Configuration resourceConfiguration) {
File crontabFile = new File(resourceName);
-
+
try {
if (!crontabFile.createNewFile()) {
- throw new RuntimeException("File " + resourceName + " already exists. Creating the crontab would overwrite it.");
+ throw new RuntimeException("File " + resourceName
+ + " already exists. Creating the crontab would overwrite it.");
}
} catch (IOException e) {
throw new RuntimeException("Failed to create the crontab file named: " + resourceName);
}
-
+
//check that the crontab's name passes the glob filters
Configuration pluginConfiguration = getResourceContext().getPluginConfiguration();
-
- List<String> includeGlobs = AugeasConfigurationDiscoveryComponent.getGlobList(pluginConfiguration.getSimple(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP));
- List<String> excludeGlobs = AugeasConfigurationDiscoveryComponent.getGlobList(pluginConfiguration.getSimple(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP));
+
+ List<String> includeGlobs = AugeasConfigurationDiscoveryComponent.getGlobList(pluginConfiguration
+ .getSimple(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP));
+ List<String> excludeGlobs = AugeasConfigurationDiscoveryComponent.getGlobList(pluginConfiguration
+ .getSimple(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP));
boolean isIncluded = false;
-
- for(String include : includeGlobs) {
+
+ for (String include : includeGlobs) {
if (new GlobFilter(include).accept(crontabFile)) {
isIncluded = true;
break;
}
}
-
- String errorText = "Given Cron tab file name would be created outside of mapped filters. See the Cron resource connection properties for the inclusion and exclusion filters set up.";
+
+ String errorText = "Given Cron tab file name would be created outside of mapped filters. See the Cron resource connection properties for the inclusion and exclusion filters set up.";
if (!isIncluded) {
throw new IllegalArgumentException(errorText);
}
-
- for(String exclude : excludeGlobs) {
+
+ for (String exclude : excludeGlobs) {
if (new GlobFilter(exclude).accept(crontabFile)) {
throw new IllegalArgumentException(errorText);
}
}
-
+
updateCrontab(resourceName, configurationDefinition, resourceConfiguration);
-
+
return resourceName;
}
-
- protected void updateCrontab(String crontabPath, ConfigurationDefinition crontabConfigurationDefinition, Configuration crontabConfiguration) {
- Augeas augeas = getAugeas();
+
+ protected void updateCrontab(String crontabPath, ConfigurationDefinition crontabConfigurationDefinition,
+ Configuration crontabConfiguration) {
+ Augeas augeas = null;
try {
- augeas.load();
-
+ augeas = getAugeas();
+
File crontabFile = new File(crontabPath);
String basePath = AUGEAS_FILES_PREFIX + crontabFile.getAbsolutePath();
AugeasNode baseNode = new AugeasNode(basePath);
-
+
PropertyList entries = crontabConfiguration.getList(CronTabComponent.ENTRIES_PROP);
- PropertyDefinitionList entriesDef = crontabConfigurationDefinition.getPropertyDefinitionList(CronTabComponent.ENTRIES_PROP);
+ PropertyDefinitionList entriesDef = crontabConfigurationDefinition
+ .getPropertyDefinitionList(CronTabComponent.ENTRIES_PROP);
setNodeFromPropertyList(entriesDef, entries, augeas, baseNode);
-
+
PropertyList settings = crontabConfiguration.getList(CronTabComponent.ENVIRONMENT_SETTINGS_PROP);
if (settings != null) {
- for(Property p : settings.getList()) {
- PropertyMap setting = (PropertyMap)p;
+ for (Property p : settings.getList()) {
+ PropertyMap setting = (PropertyMap) p;
String name = setting.getSimpleValue(CronTabComponent.NAME_PROP, null);
String value = setting.getSimpleValue(CronTabComponent.VALUE_PROP, "");
if (name != null) {
@@ -206,10 +213,15 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
}
}
}
-
+
augeas.save();
} catch (AugeasException e) {
- throw new RuntimeException(summarizeAugeasError(augeas), e);
+ if (augeas != null)
+ throw new RuntimeException(summarizeAugeasError(augeas), e);
+ else
+ throw new RuntimeException(e);
+ } finally {
+ close();
}
- }
+ }
}
diff --git a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
index dd29e6e..3f59718 100644
--- a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
+++ b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
@@ -78,7 +78,7 @@ public class HostsComponent extends AugeasConfigurationComponent {
@Override
public Configuration loadResourceConfiguration() throws Exception {
Configuration resourceConfig;
- if (getAugeas() != null) {
+ if (isAugeasAvailable()) {
resourceConfig = super.loadResourceConfiguration();
} else {
resourceConfig = new NonAugeasHostsConfigurationDelegate(this).loadResourceConfiguration();
@@ -90,7 +90,7 @@ public class HostsComponent extends AugeasConfigurationComponent {
@Override
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
- if (getAugeas() != null) {
+ if (isAugeasAvailable()) {
super.updateResourceConfiguration(report);
} else {
if (!validateResourceConfiguration(report)) {
diff --git a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java
index c123e86..7524a93 100644
--- a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java
+++ b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java
@@ -18,19 +18,18 @@ GNU General Public License for more details.
*/
package org.rhq.plugins.samba;
+import java.util.List;
+
import net.augeas.Augeas;
+
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.resource.CreateResourceHistory;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.plugins.augeas.AugeasConfigurationComponent;
import org.rhq.plugins.augeas.helper.AugeasNode;
-import java.util.List;
-
/**
* TODO
*/
@@ -52,7 +51,7 @@ public class SambaShareComponent extends AugeasConfigurationComponent<SambaServe
String targetPath = "/files/etc/samba/smb.conf/target[.='" + targetName + "']";
AugeasNode targetNode = new AugeasNode(targetPath);
Augeas augeas = getAugeas();
- augeas.load();
+
List<String> matches = augeas.match(targetNode.getPath());
return matches.get(0);
}
@@ -62,7 +61,7 @@ public class SambaShareComponent extends AugeasConfigurationComponent<SambaServe
}
public AvailabilityType getAvailability() {
- return super.getAvailability();
+ return super.getAvailability();
}
public Configuration loadResourceConfiguration() throws Exception {
@@ -78,7 +77,15 @@ public class SambaShareComponent extends AugeasConfigurationComponent<SambaServe
}
public void deleteResource() throws Exception {
- super.deleteResource();
+ initAugeas();
+ String rootPath = getResourceConfigurationRootPath();
+ try {
+ Augeas augeas = getAugeas();
+ augeas.remove(rootPath);
+ augeas.save();
+ } finally {
+ close();
+ }
}
}
diff --git a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java
index 67da318..34809b7 100644
--- a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java
+++ b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java
@@ -18,52 +18,47 @@
*/
package org.rhq.plugins.samba;
-import java.util.Set;
-import java.util.List;
import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import net.augeas.Augeas;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
public class SambaShareDiscoveryComponent implements ResourceDiscoveryComponent<SambaServerComponent> {
-
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<SambaServerComponent> discoveryContext)
- throws InvalidPluginConfigurationException, Exception {
+ public Set<DiscoveredResourceDetails> discoverResources(
+ ResourceDiscoveryContext<SambaServerComponent> discoveryContext) throws InvalidPluginConfigurationException,
+ Exception {
Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>();
SambaServerComponent serverComponent = discoveryContext.getParentResourceComponent();
- Augeas augeas = serverComponent.getAugeas();
- if (augeas==null) {
- return details; // No augeas no results
- }
- augeas.load();
+ Augeas augeas = null;
+ try {
+ augeas = serverComponent.getAugeas();
- List<String> matches = augeas.match("/files/etc/samba/smb.conf/target[. != 'global']");
- for (String match : matches) {
- String name = augeas.get(match);
- Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration();
- pluginConfig.put(new PropertySimple("targetName", name));
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- discoveryContext.getResourceType(),
- name,
- name + " share",
- null,
- "Samba Share [" + name + "]",
- pluginConfig,
- null
- );
- details.add(detail);
- }
+ List<String> matches = augeas.match("/files/etc/samba/smb.conf/target[. != 'global']");
+ for (String match : matches) {
+ String name = augeas.get(match);
+ Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration();
+ pluginConfig.put(new PropertySimple("targetName", name));
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(discoveryContext.getResourceType(),
+ name, name + " share", null, "Samba Share [" + name + "]", pluginConfig, null);
+ details.add(detail);
+ }
- return details;
+ return details;
+ } finally {
+ if (serverComponent != null)
+ serverComponent.close();
+ }
}
}
12 years, 10 months
[rhq] Branch 'drift' - modules/core
by John Sanda
modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSet.java | 79 +++++++++-
modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSetCategory.java | 25 +++
2 files changed, 101 insertions(+), 3 deletions(-)
New commits:
commit 27ae72b6db6a638bbf787df47cc962c11bf63257
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Aug 3 22:22:08 2011 -0400
adding javadocs
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSet.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSet.java
index b0cd61d..c6db79a 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSet.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSet.java
@@ -21,8 +21,18 @@ package org.rhq.core.domain.drift;
import java.util.Set;
/**
- * To support pluggable drift server implementations this Interface provides the contract required for
- * defining and persisting each DriftChangeSet reported from an Agent.
+ * A DriftChangeSet is somewhat similar to a commit in version control systems. It contains
+ * information about files being monitored or tracked for drift detection. A change set
+ * tells us about files that are added, modified, and deleted.
+ * <p/>
+ * Agents generate and send change set reports to the RHQ server. This interface provides
+ * the contract required for defining and persisting a DriftChangeSet. Drift server plugins
+ * are responsible for managing persistence.
+ * <p/>
+ * Each DriftChangeSet belongs to a particular {@link DriftConfiguration} which specifies
+ * the rules for how drift detection is performed (by the agent). A DriftConfiguration is
+ * in turn owned by a {@link org.rhq.core.domain.resource.Resource Resource} and a resource
+ * can have multiple drift configurations.
*
* @param <D> A server plugin's Drift implementation
*
@@ -30,27 +40,92 @@ import java.util.Set;
* @author John Sanda
*/
public interface DriftChangeSet<D extends Drift<?, ?>> {
+ /**
+ * Returns a string that uniquely identifies the change set. The format of the string
+ * is implementation dependent and as such there is no requirement that the id be
+ * stored as a string, only that it has a string representation.
+ *
+ * @return A unique id as a string
+ */
String getId();
+ /**
+ * Sets the change set id which should be unique. Implementations are free to store the
+ * id in any format.
+ *
+ * @param id The change set identifier that should be unique
+ */
void setId(String id);
+ /** @return The time that the change set was created */
Long getCtime();
+ /**
+ * Every change set must be assigned a version that is unique within the context of the
+ * owning {@link DriftConfiguration}. This is analgous to a revision number in a
+ * version control system like SVN.
+ *
+ * @return The change set version number that is unique within the context of its
+ * owning {@link DriftConfiguration}.
+ */
int getVersion();
+ /**
+ * Sets the change set version number. Note that change set version numbers
+ * <strong>must</strong> be unique within the context of the owning
+ * {@link DriftConfiguration}. Change sets should be assigned version numbers in
+ * increasing order. The first change set saved should have a version of N, the second
+ * should have a value of N + 1, etc.
+ *
+ * @param version The version number.
+ */
void setVersion(int version);
+ /**
+ * Retturns the category that identifies the change set type.
+ * @return The change set category
+ * @see DriftChangeSetCategory
+ */
DriftChangeSetCategory getCategory();
+ /**
+ * Sets the change set category.
+ *
+ * @param category The category that identifies the change set type
+ * @see DriftChangeSetCategory
+ */
void setCategory(DriftChangeSetCategory category);
+ /**
+ * Returns the id of the owning drift configuration. Note that while server plugins are
+ * responsible for managing the persistence of change sets, the RHQ server manages the
+ * persistence of the owning drift configuration.
+ *
+ * @return The {@link DriftConfiguration} id
+ */
int getDriftConfigurationId();
+ /**
+ * Sets the id of the owning drift configuration. Note that while server plugins are
+ * responsible for managing the persistence of change sets, the RHQ server manages the
+ * persistence of the drift configuration.
+ *
+ * @param id The {@link DriftConfiguration} id
+ */
void setDriftConfigurationId(int id);
+ /**
+ * Returns the id of the resource to which the drift configuration is assigned. Note
+ * that the RHQ server and not drift server plugins manage the persistence of the
+ * resource.
+ *
+ * @return The id of the resource to which the drift configuration belongs
+ */
int getResourceId();
+ /** @return The entries that comprise this change set */
Set<D> getDrifts();
+ /** @param drifts The entries that make up this change set */
void setDrifts(Set<D> drifts);
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSetCategory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSetCategory.java
index 5c3e436..2b938ad 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSetCategory.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSetCategory.java
@@ -23,12 +23,27 @@
package org.rhq.core.domain.drift;
/**
- * Type of change set report.
+ * Type of change set report. There are two types of change sets, coverage and drift. A
+ * coverage change set is in effect a snapshot of the files that are being monitored for
+ * drift detection. A drift change set on the hand, represents a delta between one or more
+ * files on disk and their versions in the previous change set.
+ * <p/>
+ * A DriftChangeSetCategory has a single representation which is suitable for persisting
+ * in a database.
*
* @author Jay Shaughnesssy
*/
public enum DriftChangeSetCategory {
+ /**
+ * A coverage change set is a snapshot of the files that are being monitored for drift
+ * detection.
+ */
COVERAGE("C"), // Reports only on files being covered by a drift configuration.
+
+ /**
+ * A drift change set represents a change between one or more files and their versions
+ * in the previous change set.
+ */
DRIFT("D"); // Reports on actual drift.
private final String code;
@@ -37,10 +52,18 @@ public enum DriftChangeSetCategory {
this.code = code;
}
+ /** @return The single character code */
public String code() {
return code;
}
+ /**
+ * Parses the single character code into a DriftChangeSetCategory object.
+ *
+ * @param code A single character code
+ * @return The corresponding DriftChangeSetCategory
+ * @throws IllegalArgumentException if the code is not recognized
+ */
public static DriftChangeSetCategory fromCode(String code) {
for (DriftChangeSetCategory type : DriftChangeSetCategory.values()) {
if (type.code.equals(code)) {
12 years, 10 months
[rhq] Branch 'as7plugin' - 2 commits - modules/integration-tests modules/plugins
by Heiko W. Rupp
modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/AbstractIntegrationTest.java | 4
modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/MiscTest.java | 25 +
modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/UploadAndDeployTest.java | 31 -
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java | 170 +++++-----
4 files changed, 129 insertions(+), 101 deletions(-)
New commits:
commit eb053bab84b136bc6c02d8e9e9210735ccf9de2f
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Aug 3 22:31:04 2011 +0200
Switch over to use of Address and add a test to simulate composite read-attribute operations for batching.
diff --git a/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/AbstractIntegrationTest.java b/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/AbstractIntegrationTest.java
index 929cef8..07fe592 100644
--- a/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/AbstractIntegrationTest.java
+++ b/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/AbstractIntegrationTest.java
@@ -31,6 +31,7 @@ import org.codehaus.jackson.JsonNode;
import org.rhq.modules.plugins.jbossas7.ASConnection;
import org.rhq.modules.plugins.jbossas7.ASUploadConnection;
+import org.rhq.modules.plugins.jbossas7.json.Address;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
@@ -82,8 +83,7 @@ public abstract class AbstractIntegrationTest {
Operation addDeployment(String deploymentName,String bytes_value)
{
- List<PROPERTY_VALUE> deploymentsAddress = new ArrayList<PROPERTY_VALUE>(1);
- deploymentsAddress.add(new PROPERTY_VALUE("deployment", deploymentName));
+ Address deploymentsAddress = new Address("deployment", deploymentName);
Operation op = new Operation("add",deploymentsAddress);
List<Object> content = new ArrayList<Object>(1);
Map<String,Object> contentValues = new HashMap<String,Object>();
diff --git a/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/MiscTest.java b/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/MiscTest.java
index 5f75be9..e96b935 100644
--- a/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/MiscTest.java
+++ b/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/MiscTest.java
@@ -1,11 +1,16 @@
package org.rhq.modules.integrationTests.jbossas7plugin;
import java.util.Collections;
+import java.util.Map;
import org.testng.annotations.Test;
+import org.rhq.modules.plugins.jbossas7.json.Address;
+import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
+import org.rhq.modules.plugins.jbossas7.json.CompositeOperation;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+import org.rhq.modules.plugins.jbossas7.json.ReadAttribute;
import org.rhq.modules.plugins.jbossas7.json.Result;
/**
@@ -17,7 +22,7 @@ public class MiscTest extends AbstractIntegrationTest {
public void testSetRollback() throws Exception {
- Operation op = new Operation("foo", Collections.<PROPERTY_VALUE>emptyList());
+ Operation op = new Operation("foo", new Address());
Result res = getASConnection().execute(op);
assert res != null;
assert !res.isSuccess();
@@ -25,4 +30,22 @@ public class MiscTest extends AbstractIntegrationTest {
assert res.getFailureDescription().endsWith("rolled-back=true");
}
+ public void testCompositeReadAttribute() throws Exception {
+
+ Address a = new Address("profile=default,subsystem=web,connector=http");
+ CompositeOperation cop = new CompositeOperation();
+ Operation step1 = new ReadAttribute(a,"maxTime");
+ cop.addStep(step1);
+ Operation step2 = new ReadAttribute(a,"processingTime");
+ cop.addStep(step2);
+
+ ComplexResult res = getASConnection().executeComplex(cop);
+ assert res!=null;
+ assert res.isSuccess();
+ Map<String,Object> resResult = res.getResult();
+ assert resResult !=null;
+ assert resResult.size()==2;
+
+
+ }
}
diff --git a/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/UploadAndDeployTest.java b/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/UploadAndDeployTest.java
index 2010640..9b35471 100644
--- a/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/UploadAndDeployTest.java
+++ b/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/UploadAndDeployTest.java
@@ -92,8 +92,7 @@ public class UploadAndDeployTest extends AbstractIntegrationTest {
System.out.println();
ASConnection connection = new ASConnection(DC_HOST, DC_HTTP_PORT);
- List<PROPERTY_VALUE> deploymentsAddress = new ArrayList<PROPERTY_VALUE>(1);
- deploymentsAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
+ Address deploymentsAddress = new Address("deployment", TEST_WAR);
Operation op = new Operation("add",deploymentsAddress);
List<Object> content = new ArrayList<Object>(1);
Map<String,Object> contentValues = new HashMap<String,Object>();
@@ -110,9 +109,9 @@ public class UploadAndDeployTest extends AbstractIntegrationTest {
assert ret.toString().contains("success") : ret;
- List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
- serverGroupAddress.add(new PROPERTY_VALUE("server-group", "main-server-group"));
- serverGroupAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
+ Address serverGroupAddress = new Address();
+ serverGroupAddress.add("server-group", "main-server-group");
+ serverGroupAddress.add("deployment", TEST_WAR);
Operation attach = new Operation("add",serverGroupAddress);//,"enabled","true");
// deploy.addAdditionalProperty("runtime-name", TEST_WAR);
@@ -193,11 +192,12 @@ public class UploadAndDeployTest extends AbstractIntegrationTest {
assert ret.toString().contains("success") : ret;
- List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
- serverGroupAddress.add(new PROPERTY_VALUE("server-group", "main-server-group"));
- serverGroupAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
+ Address serverGroupAddress = new Address();
+ serverGroupAddress.add("server-group", "main-server-group");
+ serverGroupAddress.add("deployment", TEST_WAR);
- Operation attach = new Operation("add",serverGroupAddress,"enabled",true);
+ Operation attach = new Operation("add",serverGroupAddress);
+ attach.addAdditionalProperty("enabled",true);
System.out.flush();
ret = connection.executeRaw(attach);
System.out.println("Add to server group done: " + ret);
@@ -246,8 +246,8 @@ public class UploadAndDeployTest extends AbstractIntegrationTest {
System.out.println("Prepare done");
System.out.flush();
- List<PROPERTY_VALUE> deploymentsAddress = new ArrayList<PROPERTY_VALUE>(1);
- deploymentsAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
+ Address deploymentsAddress = new Address();
+ deploymentsAddress.add("deployment", TEST_WAR);
Operation step1 = new Operation("add",deploymentsAddress);
List<Object> content = new ArrayList<Object>(1);
Map<String,Object> contentValues = new HashMap<String,Object>();
@@ -257,9 +257,9 @@ public class UploadAndDeployTest extends AbstractIntegrationTest {
step1.addAdditionalProperty("name", TEST_WAR); // this needs to be unique per upload
- List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
- serverGroupAddress.add(new PROPERTY_VALUE("server-group","main-server-group"));
- serverGroupAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
+ Address serverGroupAddress = new Address();
+ serverGroupAddress.add("server-group","main-server-group");
+ serverGroupAddress.add("deployment", TEST_WAR);
Operation step2 = new Operation("add",serverGroupAddress);// ,"enabled","true");
Operation step2a = new Operation("deploy",serverGroupAddress);
@@ -312,8 +312,7 @@ public class UploadAndDeployTest extends AbstractIntegrationTest {
System.out.println("Prepare done");
System.out.flush();
- List<PROPERTY_VALUE> deploymentsAddress = new ArrayList<PROPERTY_VALUE>(1);
- deploymentsAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
+ Address deploymentsAddress = new Address("deployment", TEST_WAR);
Operation step1 = new Operation("add",deploymentsAddress);
List<Object> content = new ArrayList<Object>(1);
Map<String,Object> contentValues = new HashMap<String,Object>();
commit 29f990c4c7aa3d28078e8663fcae21801beffbf2
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Aug 3 22:06:11 2011 +0200
Do some cleanup and fix a bug where more subsystems were discovered than available.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index bc7e341..7584a68 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -40,7 +40,18 @@ import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
/**
- * Discover subsystems
+ * Discover subsystems. We need to distinguish two cases denoted by the path
+ * plugin config:
+ * <ul>
+ * <li>Path is a single 'word': here the value denotes a key in the resource path
+ * of AS7, that identifies a child type see e.g. the Connectors below the JBossWeb
+ * service in the plugin descriptor. There can be multiple resources of the given
+ * type. In addition it is possible that a path entry in configuration shares multiple
+ * types that are separated by the pipe symbol.</li>
+ * <li>Path is a key-value pair (e.g. subsystem=web ). This denotes a singleton
+ * subsystem with a fixes path within AS7 (perhaps below another resource in the
+ * tree.</li>
+ * </ul>
*
* @author Heiko W. Rupp
*/
@@ -52,7 +63,7 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> context)
throws Exception {
- Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
+ Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>();
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
@@ -63,115 +74,110 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
Configuration config = context.getDefaultPluginConfiguration();
- String confPath = config.getSimpleValue("path", null);
- if (confPath==null) {
+ String confPath = config.getSimpleValue("path", "");
+ if (confPath==null || confPath.isEmpty()) {
log.error("Path plugin config is null for ResourceType [" + context.getResourceType().getName() +"].");
return details;
}
- List<String> subTypes = new ArrayList<String>();
- if (confPath.contains("|")) {
- subTypes.addAll(Arrays.asList(confPath.split("\\|")));
- }
- else
- subTypes.add(confPath);
-
+ boolean lookForChildren = false;
- for (String cpath : subTypes) {
+ if (!confPath.contains("=")) { // NO = -> no sub path, but a type
+ lookForChildren = true;
+ }
+ // Construct the full path including the parent
+ String path;
+ String parentPath = parentComponent.getPath();
+ if (parentPath==null || parentPath.isEmpty())
+ path = "";
+ else
+ path = parentPath;
- boolean recursive = false;
+ if (Boolean.getBoolean("as7plugin.verbose"))
+ log.info("total path: [" + path + "]");
- String parentPath = parentComponent.getPath();
- String path;
- String childType = null;
- if (!cpath.contains("=")) { // NO = -> no sub path, but a type
- recursive = true;
- childType = cpath;
+ if (lookForChildren) {
+ // Looking for multiple resource of type 'childType'
+ // check if there are multiple types are present
+ List<String> subTypes = new ArrayList<String>();
+ if (confPath.contains("|")) {
+ subTypes.addAll(Arrays.asList(confPath.split("\\|")));
}
-
- if (parentPath==null || parentPath.isEmpty())
- path = "";
else
- path = parentPath;
-
- if (cpath.contains("="))
- path += "," + cpath;
+ subTypes.add(confPath);
- if (Boolean.getBoolean("as7plugin.verbose"))
- log.info("total path: [" + path + "]");
+ for (String cpath : subTypes) {
- Result result ;
- if (!recursive)
- result = connection.execute(new ReadResource(parentComponent.getAddress()));
- else {
Address addr = new Address(parentPath);
- result = connection.execute(new ReadChildrenNames(addr, childType));
- }
- if (result.isSuccess()) {
- if (recursive) {
+ Result result = connection.execute(new ReadChildrenNames(addr, cpath));
+
+ if (result.isSuccess()) {
+ @SuppressWarnings("unchecked")
List<String> subsystems = (List<String>) result.getResult();
+ // There may be multiple children of the given type
for (String val : subsystems) {
- String newPath = cpath + "=" + val;
- Configuration config2 = context.getDefaultPluginConfiguration();
+ String newPath = cpath + "=" + val;
+ Configuration config2 = context.getDefaultPluginConfiguration();
+ String resKey;
- String resKey;
-
- if (path==null||path.isEmpty())
- resKey = newPath;
- else {
- if (path.startsWith(","))
- path = path.substring(1);
- resKey = path + "," +childType + "=" + val;
- }
-
- PropertySimple pathProp = new PropertySimple("path",resKey);
- config2.put(pathProp);
-
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- context.getResourceType(), // DataType
- resKey, // Key
- val, // Name
- null, // Version
- context.getResourceType().getDescription(), // subsystem.description
- config2,
- null);
- details.add(detail);
+ if (path==null||path.isEmpty())
+ resKey = newPath;
+ else {
+ if (path.startsWith(","))
+ path = path.substring(1);
+ resKey = path + "," +cpath + "=" + val;
}
+
+ PropertySimple pathProp = new PropertySimple("path",resKey);
+ config2.put(pathProp);
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ context.getResourceType(), // DataType
+ resKey, // Key
+ val, // Name
+ null, // Version
+ context.getResourceType().getDescription(), // subsystem.description
+ config2,
+ null);
+ details.add(detail);
}
- else {
- if (path.startsWith(","))
- path = path.substring(1);
-
- String resKey = path;
- String name = resKey.substring(resKey.lastIndexOf("=") + 1);
- Configuration config2 = context.getDefaultPluginConfiguration();
- PropertySimple pathProp = new PropertySimple("path",path);
- config2.put(pathProp);
-
-
-
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- context.getResourceType(), // DataType
- path, // Key
- name, // Name
- null, // Version
- context.getResourceType().getDescription(), // Description
- config2,
- null);
- details.add(detail);
}
-
}
+ }
+ else {
+ // Single subsystem
+ path += "," + confPath;
+ if (path.startsWith(","))
+ path = path.substring(1);
+ Result result = connection.execute(new ReadResource(new Address(path)));
+ if (result.isSuccess()) {
+ String resKey = path;
+ String name = resKey.substring(resKey.lastIndexOf("=") + 1);
+ Configuration config2 = context.getDefaultPluginConfiguration();
+ PropertySimple pathProp = new PropertySimple("path",path);
+ config2.put(pathProp);
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ context.getResourceType(), // DataType
+ path, // Key
+ name, // Name
+ null, // Version
+ context.getResourceType().getDescription(), // Description
+ config2,
+ null);
+ details.add(detail);
+ }
}
+
return details;
}
12 years, 10 months
[rhq] Branch 'stefan/dbreset' - modules/core
by snegrea
modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
New commits:
commit b4746083421af4d6a0ae4991dbcbf90272ff67a8
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Aug 3 12:23:44 2011 -0500
Forgot to replace three properties with the params after refactoring dbreset.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
index 9cd49e4..4736988 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/reset/DBReset.java
@@ -69,6 +69,7 @@ public class DBReset {
public void performDBReset(String dbTypeMapping, String dbUrl, String dbName, String user, String adminUser,
String adminPassword) throws Exception {
if (dbTypeMapping.equals("PostgreSQL")) {
+ System.out.println("PostgreSQL started!");
Connection connection = null;
Statement dropDB = null;
Statement createDB = null;
@@ -95,12 +96,12 @@ public class DBReset {
}
}
- } else if (DB_TYPE_MAPPING.equals("Oracle10g")) {
+ } else if (dbTypeMapping.equals("Oracle10g")) {
Connection connection = null;
PreparedStatement cleanUserStatement = null;
try {
- connection = DbUtil.getConnection(DB_URL, adminUser, ADMIN_PASSWORD);
+ connection = DbUtil.getConnection(dbUrl, adminUser, adminPassword);
connection.setAutoCommit(false);
String plsql = "declare cursor all_objects_to_drop is\n"
12 years, 10 months