[rhq] 3 commits - modules/enterprise pom.xml
by Simeon Pinder
modules/enterprise/server/appserver/pom.xml | 11 ++++++++++
modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml | 11 ++++++++++
pom.xml | 2 -
3 files changed, 23 insertions(+), 1 deletion(-)
New commits:
commit 4fa9f082b2e011b3bde9defe1021248148c4ad40
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Tue Jul 23 15:02:09 2013 -0400
[BZ 984649] fix module metadata.
diff --git a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
index 145e3af..82ff294 100644
--- a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
@@ -290,7 +290,7 @@
<delete file="${jboss.home}/modules/system/layers/base/org/jgroups/main/jgroups-${jgroups.initial.version}.jar.index" />
<!-- Update the module metadata to the patched version -->
<replace file="${jboss.home}/modules/system/layers/base/org/jgroups/main/module.xml"
- token="jgroups-${jgroups.initial.version}.jar" value="${jgroups.patch.version}"/>
+ token="jgroups-${jgroups.initial.version}.jar" value="jgroups-${jgroups.patch.version}.jar"/>
<!-- Copy in patched version -->
<copy file="${settings.localRepository}/org/jgroups/jgroups/${jgroups.patch.version}/jgroups-${jgroups.patch.version}.jar"
toDir="${jboss.home}/modules/system/layers/base/org/jgroups/main" verbose="true"/>
commit 8203c669b3b3ba5ed5c3ef27f051220da93ea868
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Tue Jul 23 13:37:32 2013 -0400
Upgrading richfaces to latest patched version.
diff --git a/pom.xml b/pom.xml
index 3662bc7..f909033 100644
--- a/pom.xml
+++ b/pom.xml
@@ -135,7 +135,7 @@
<postgresql.version>9.2-1002.jdbc4</postgresql.version>
<h2.version>1.2.139</h2.version>
<jtds.version>1.2.2</jtds.version>
- <richfaces.version>3.3.3.Final</richfaces.version>
+ <richfaces.version>3.3.4.Final</richfaces.version>
<jline.version>0.9.94</jline.version>
<sigar.version>1.6.5.132-5</sigar.version>
<sigar.zip.version>1.6.5</sigar.zip.version>
commit caeb7a5c832334b74f76a265c8028a5697152dda
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Tue Jul 23 12:28:52 2013 -0400
[BZ 984649] update jgroups usage to latest patched version.
diff --git a/modules/enterprise/server/appserver/pom.xml b/modules/enterprise/server/appserver/pom.xml
index 0a61138..f1a4c7b 100644
--- a/modules/enterprise/server/appserver/pom.xml
+++ b/modules/enterprise/server/appserver/pom.xml
@@ -19,6 +19,8 @@
<properties>
<rhq.dev.data.dir>${rhq.rootDir}/rhq-data</rhq.dev.data.dir>
+ <jgroups.initial.version>3.2.7.Final</jgroups.initial.version>
+ <jgroups.patch.version>3.2.10.Final</jgroups.patch.version>
</properties>
<dependencies>
@@ -72,6 +74,13 @@
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</dependency>
+
+ <!-- Pull down the patched version of JGroups. See CVE 2013-4112 and BZ 984365 -->
+ <dependency>
+ <groupId>org.jgroups</groupId>
+ <artifactId>jgroups</artifactId>
+ <version>${jgroups.patch.version}</version>
+ </dependency>
</dependencies>
<build>
@@ -157,6 +166,8 @@
<property name="rhq.server.http.port" value="${rhq.server.http.port}" />
<property name="rhq.server.https.port" value="${rhq.server.https.port}" />
<property name="rhq.sync.endpoint-address" value="${rhq.sync.endpoint-address}" />
+ <property name="jgroups.initial.version" value="${jgroups.initial.version}" />
+ <property name="jgroups.patch.version" value="${jgroups.patch.version}" />
</ant>
</target>
</configuration>
diff --git a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
index a81b6cd..145e3af 100644
--- a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
@@ -283,6 +283,17 @@
</resources>
</module>
]]></echo>
+
+ <echo>Updating JGroups module component for EAP to ${jgroups.patch.version}</echo>
+ <!-- Remove the unpatched version -->
+ <delete file="${jboss.home}/modules/system/layers/base/org/jgroups/main/jgroups-${jgroups.initial.version}.jar" />
+ <delete file="${jboss.home}/modules/system/layers/base/org/jgroups/main/jgroups-${jgroups.initial.version}.jar.index" />
+ <!-- Update the module metadata to the patched version -->
+ <replace file="${jboss.home}/modules/system/layers/base/org/jgroups/main/module.xml"
+ token="jgroups-${jgroups.initial.version}.jar" value="${jgroups.patch.version}"/>
+ <!-- Copy in patched version -->
+ <copy file="${settings.localRepository}/org/jgroups/jgroups/${jgroups.patch.version}/jgroups-${jgroups.patch.version}.jar"
+ toDir="${jboss.home}/modules/system/layers/base/org/jgroups/main" verbose="true"/>
<echo>Generate SSL key for RHQ server - 128-bit key that expires in 20 years</echo>
<property name="jboss.conf.dir" location="${jboss.home}/standalone/configuration" />
10 years, 9 months
[rhq] Branch 'release/jon3.1.x' - modules/enterprise
by Larry O'Leary
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java | 16 +++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java | 17 +---
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/ldap/FakeLdapContext.java | 37 ++++------
3 files changed, 39 insertions(+), 31 deletions(-)
New commits:
commit cb7bdca5eb624e5064dc0e4191e63b01e4877829
Author: Larry O'Leary <loleary(a)redhat.com>
Date: Wed Jul 17 16:32:05 2013 +0200
BZ 981015 - Ldap auth failed if DN contained a backslash
(cherry-picked from commit 01cd91b130f563ba62cd96a46f2cb3a2ac567a48)
BZ 981015: Fix test failures introduced by commit 01cd91b
- findLdapUserDetails was appending baseDN twice during fallback code
- FakeLdapContext contained some lazy escaping on the mock group entries
(cherry picked from commit 567aee7f81c6aa0f7680d4f394cccb1974705320)
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java
index 3de303c..38af750 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java
@@ -23,6 +23,7 @@ import java.util.Iterator;
import java.util.Properties;
import java.util.Map.Entry;
+import javax.naming.CompositeName;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.directory.SearchControls;
@@ -189,7 +190,18 @@ public class LdapLoginModule extends UsernamePasswordLoginModule {
SearchResult si = (SearchResult) answer.next();
// Construct the UserDN
- String userDN = si.getName() + "," + baseDNs[x];
+ String userDN = null;
+
+ try {
+ userDN = si.getNameInNamespace();
+ } catch (UnsupportedOperationException use) {
+ userDN = new CompositeName(si.getName()).get(0);
+ if (si.isRelative()) {
+ userDN += "," + baseDNs[x];
+ }
+ }
+
+ log.debug("Using LDAP userDN=" + userDN);
ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, userDN);
ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, inputPassword);
@@ -204,7 +216,7 @@ public class LdapLoginModule extends UsernamePasswordLoginModule {
// If we try all the BaseDN's and have not found a match, return false
return false;
} catch (Exception e) {
- log.info("Failed to validate password: " + e.getMessage());
+ log.info("Failed to validate password for [" + userName + "]: " + e.getMessage());
return false;
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
index eeeb4fc..f828950 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* 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.
+ * 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.server.resource.group;
@@ -31,6 +31,7 @@ import java.util.Set;
import javax.ejb.EJB;
import javax.ejb.Stateless;
+import javax.naming.CompositeName;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
@@ -322,14 +323,10 @@ public class LdapGroupManagerBean implements LdapGroupManagerLocal {
try {
userDN = si.getNameInNamespace();
} catch (UnsupportedOperationException use) {
- userDN = si.getName();
- if (userDN.startsWith("\"")) {
- userDN = userDN.substring(1, userDN.length());
+ userDN = new CompositeName(si.getName()).get(0);
+ if (si.isRelative()) {
+ userDN += "," + baseDNs[x];
}
- if (userDN.endsWith("\"")) {
- userDN = userDN.substring(0, userDN.length() - 1);
- }
- userDN = userDN + "," + baseDNs[x];
}
userDetails.put("dn", userDN);
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/ldap/FakeLdapContext.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/ldap/FakeLdapContext.java
index dad31ce..2ae6265 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/ldap/FakeLdapContext.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/ldap/FakeLdapContext.java
@@ -99,7 +99,6 @@ public class FakeLdapContext implements LdapContext {
try {
return new FakeNamingEnumeration<SearchResult>(ldapTestData.getSearchResults(attributes));
} catch (Exception e) {
- // TODO Auto-generated catch block
e.printStackTrace();
return null;
}
@@ -516,12 +515,12 @@ public class FakeLdapContext implements LdapContext {
attr = new BasicAttribute("member");
attr.add("cn=Robert Smith,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Cannon\\, Brett,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
- attr.add("cn=Charles H\\\\Samlin,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
+ attr.add("cn=Charles H\\Samlin,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Craig \\#1 Sellers,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Beverly \\+1 Balanger,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Bethany \\<Stuart\\> Wallace,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Zachory S\\; Balanger,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
- attr.add("cn=Allen \\\"The Hammer\\\" Callen,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
+ attr.add("cn=Allen \"The Hammer\" Callen,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Sam Not \\= Smitherson,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=\\ Billy The Kiddough\\ ,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=System/Integration API,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
@@ -557,12 +556,12 @@ public class FakeLdapContext implements LdapContext {
attr = new BasicAttribute("member");
attr.add("cn=John Smith,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Dr. Greg Hause\\, MD,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
- attr.add("cn=Cindy\\\\Cynthia Groober,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
+ attr.add("cn=Cindy\\Cynthia Groober,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Biff \\# Rogers,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Steven \\+2 Reed,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Lisa \\<The Great\\> Toller,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Homer J Simpsonite\\; III,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
- attr.add("cn=Jessica \\\"Crouching Tiger\\\" Mathers,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
+ attr.add("cn=Jessica \"Crouching Tiger\" Mathers,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Hope \\= Rein,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=\\ Sue Ferguson\\ ,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Phil/Susan Carlson,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
@@ -598,12 +597,12 @@ public class FakeLdapContext implements LdapContext {
attr = new BasicAttribute("member");
attr.add("cn=Sheri Smith,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Walsh\\, Brad,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
- attr.add("cn=Jim\\\\James Kirk,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
+ attr.add("cn=Jim\\James Kirk,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Sandra \\# Phillips,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=William Tell Overture \\+1,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Craig \\<Bison\\> Allen,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Walter T Fredrick\\; The Second,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
- attr.add("cn=Stanley \\\"Short\\\" Mein,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
+ attr.add("cn=Stanley \"Short\" Mein,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Noah \\= Sadler,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=\\ Stuart Smiley\\ ,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=System/Integration API 2,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
@@ -984,7 +983,7 @@ public class FakeLdapContext implements LdapContext {
attr.add("User with backslash (\\) in 'cn' in the RHQ Admin Group");
attrs.put(attr);
- sr = new SearchResult("cn=Charles H\\\\Samlin,ou=users", null, null, attrs, true);
+ sr = new SearchResult("cn=Charles H\\Samlin,ou=users", null, null, attrs, true);
this.add(sr);
// dn: cn=Cindy\\Cynthia Groober,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
@@ -1033,7 +1032,7 @@ public class FakeLdapContext implements LdapContext {
attr.add("User with backslash (\\) in 'cn' in the JBoss Admin Group");
attrs.put(attr);
- sr = new SearchResult("cn=Cindy\\\\Cynthia Groober,ou=users", null, null, attrs, true);
+ sr = new SearchResult("cn=Cindy\\Cynthia Groober,ou=users", null, null, attrs, true);
this.add(sr);
// dn: cn=Jim\\James Kirk,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
@@ -1082,7 +1081,7 @@ public class FakeLdapContext implements LdapContext {
attr.add("User with backslash (\\) in 'cn' in the JBoss Monitor Group");
attrs.put(attr);
- sr = new SearchResult("cn=Jim\\\\James Kirk,ou=users", null, null, attrs, true);
+ sr = new SearchResult("cn=Jim\\James Kirk,ou=users", null, null, attrs, true);
this.add(sr);
// dn: cn=Craig \#1 Sellers,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
@@ -1675,7 +1674,7 @@ public class FakeLdapContext implements LdapContext {
null, attrs, true);
this.add(sr);
- // dn: cn=Allen \"The Hammer\" Callen,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
+ // dn: cn=Allen "The Hammer" Callen,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
attrs = new BasicAttributes();
attr = new BasicAttribute("baseName");
@@ -1721,11 +1720,11 @@ public class FakeLdapContext implements LdapContext {
attr.add("User with quote (\") in 'cn' in the RHQ Admin Group");
attrs.put(attr);
- sr = new SearchResult("cn=Allen \\\"The Hammer\\\" Callen,ou=users", "javax.naming.directory.DirContext",
+ sr = new SearchResult("cn=Allen \"The Hammer\" Callen,ou=users", "javax.naming.directory.DirContext",
null, attrs, true);
this.add(sr);
- // dn: cn=Jessica \"Crouching Tiger\" Mathers,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
+ // dn: cn=Jessica "Crouching Tiger" Mathers,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
attrs = new BasicAttributes();
attr = new BasicAttribute("baseName");
@@ -1771,11 +1770,11 @@ public class FakeLdapContext implements LdapContext {
attr.add("User with quote (\") in 'cn' in the JBoss Admin Group");
attrs.put(attr);
- sr = new SearchResult("cn=Jessica \\\"Crouching Tiger\\\" Mathers,ou=users",
+ sr = new SearchResult("cn=Jessica \"Crouching Tiger\" Mathers,ou=users",
"javax.naming.directory.DirContext", null, attrs, true);
this.add(sr);
- // dn: cn=Stanley \"Short\" Mein,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
+ // dn: cn=Stanley "Short" Mein,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
attrs = new BasicAttributes();
attr = new BasicAttribute("baseName");
@@ -1821,7 +1820,7 @@ public class FakeLdapContext implements LdapContext {
attr.add("User with quote (\") in 'cn' in the JBoss Monitor Group");
attrs.put(attr);
- sr = new SearchResult("cn=Stanley \\\"Short\\\" Mein,ou=users", null, null, attrs, true);
+ sr = new SearchResult("cn=Stanley \"Short\" Mein,ou=users", null, null, attrs, true);
this.add(sr);
// dn: cn=Sam Not \= Smitherson,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
@@ -2160,7 +2159,7 @@ public class FakeLdapContext implements LdapContext {
attr.add("User with slash (/) in 'cn' in the RHQ Admin Group");
attrs.put(attr);
- sr = new SearchResult("cn=System/Integration API,ou=users", null, null, attrs, true);
+ sr = new SearchResult("cn=System\\/Integration API,ou=users", null, null, attrs, true);
this.add(sr);
// dn: cn=Phil/Susan Carlson,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
@@ -2209,7 +2208,7 @@ public class FakeLdapContext implements LdapContext {
attr.add("User with slash (/) in 'cn' in the JBoss Admin Group");
attrs.put(attr);
- sr = new SearchResult("cn=Phil/Susan Carlson,ou=users", null, null, attrs, true);
+ sr = new SearchResult("cn=Phil\\/Susan Carlson,ou=users", null, null, attrs, true);
this.add(sr);
// dn: cn=System/Integration API 2,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
@@ -2254,7 +2253,7 @@ public class FakeLdapContext implements LdapContext {
attr.add("User with slash (/) in 'cn' in the JBoss Monitor Group");
attrs.put(attr);
- sr = new SearchResult("cn=System/Integration API 2,ou=users", null, null, attrs, true);
+ sr = new SearchResult("cn=System\\/Integration API 2,ou=users", null, null, attrs, true);
this.add(sr);
// dn: cn=Lee -Fast- Croutche,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
10 years, 9 months
[rhq] 3 commits - modules/core modules/enterprise modules/plugins
by snegrea
modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeLoadComposite.java | 58 +++++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDatasource.java | 32 ++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeLoadComponent.java | 5
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java | 31 ++++-
modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml | 2
modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml | 3
6 files changed, 102 insertions(+), 29 deletions(-)
New commits:
commit cc64adde1d8835f8c000afe2de0746fda5bbd5c1
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 23 08:43:19 2013 -0500
One more place where the previous rebase removed code for the storage node configuration.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
index 31e3bf7..9416c67 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
@@ -643,6 +643,8 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
Configuration parameters = new Configuration();
parameters.setSimpleValue("jmxPort", storageNodeConfiguration.getJmxPort() + "");
parameters.setSimpleValue("heapSize", storageNodeConfiguration.getHeapSize() + "");
+ parameters.setSimpleValue("heapNewSize", storageNodeConfiguration.getHeapNewSize() + "");
+ parameters.setSimpleValue("threadStackSize", storageNodeConfiguration.getThreadStackSize() + "");
boolean updateConfigurationResult = runOperationAndWaitForResult(subject, storageNodeResource,
UPDATE_CONFIGURATION_OPERATION, parameters);
commit 373a931987b402479df3d02269cc00f4ac88a358
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 23 08:42:49 2013 -0500
Enable the new set of calculated metrics for disk space utilization in the UI and CLI.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeLoadComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeLoadComposite.java
index 80bfdd6..2c0b8f8 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeLoadComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeLoadComposite.java
@@ -41,9 +41,13 @@ public class StorageNodeLoadComposite implements Serializable {
private MeasurementAggregateWithUnits heapUsed;
private MeasurementAggregateWithUnits heapPercentageUsed;
private MeasurementAggregateWithUnits load;
- private MeasurementAggregateWithUnits partitionDiskUsedPercentage;
private MeasurementAggregateWithUnits dataDiskUsed;
private MeasurementAggregate tokens;
+
+ private MeasurementAggregateWithUnits dataDiskUsedPercentage;
+ private MeasurementAggregateWithUnits totalDiskUsedPercentage;
+ private MeasurementAggregate freeDiskToDataSizeRatio;
+
private MeasurementAggregateWithUnits actuallyOwns;
public StorageNodeLoadComposite() {
@@ -113,35 +117,59 @@ public class StorageNodeLoadComposite implements Serializable {
public void setHeapPercentageUsed(MeasurementAggregateWithUnits heapPercentageUsed) {
this.heapPercentageUsed = heapPercentageUsed;
}
-
+
/**
* @deprecated use {@link #getPartitionDiskUsedPercentage() getPartitionDiskUsedPercentage()} instead
- *
+ *
* @return partitionDiskUsedPercentage
*/
public MeasurementAggregateWithUnits getDiskSpacePercentageUsed() {
- return getPartitionDiskUsedPercentage();
+ return getDataDiskUsedPercentage();
}
-
+
/**
* @deprecated use {@link #setPartitionDiskUsedPercentage() setPartitionDiskUsedPercentage()} instead
- *
+ *
* @param partitionDiskUsedPercentage
*/
- public void setDiskSpacePercentageUsed(MeasurementAggregateWithUnits partitionDiskUsedPercentage) {
- setPartitionDiskUsedPercentage(partitionDiskUsedPercentage);
+ public void setDiskSpacePercentageUsed(MeasurementAggregateWithUnits diskUsedPercentage) {
+ setDataDiskUsedPercentage(diskUsedPercentage);
+ }
+
+ /**
+ * @return A computed metric for the percentage of disk space used by data file on the corresponding partitions.
+ * If multiple data locations are configured then the aggregate is calculated.
+ */
+ public MeasurementAggregateWithUnits getDataDiskUsedPercentage() {
+ return dataDiskUsedPercentage;
+ }
+
+ public void setDataDiskUsedPercentage(MeasurementAggregateWithUnits dataDiskUsedPercentage) {
+ this.dataDiskUsedPercentage = dataDiskUsedPercentage;
+ }
+
+ /**
+ * @return A computed metric for the percentage of total (system + Storage Node data file) disk space used the partitions where data files are stored.
+ * If multiple data locations are configured then the aggregate is calculated.
+ */
+ public MeasurementAggregateWithUnits getTotalDiskUsedPercentage() {
+ return totalDiskUsedPercentage;
+ }
+
+ public void setTotalDiskUsedPercentage(MeasurementAggregateWithUnits totalDiskUsedPercentage) {
+ this.totalDiskUsedPercentage = totalDiskUsedPercentage;
}
/**
- * @return A computed metric for the percentage of disk space used on the partition that contains the SSTables.
- * If multiple data locations are configured then the partition with the highest utilization will be reported.
+ * @return A computed metric for the percentage of total (system + Storage Node data file) disk space used the partitions where data files are stored.
+ * If multiple data locations are configured then the aggregate is calculated.
*/
- public MeasurementAggregateWithUnits getPartitionDiskUsedPercentage() {
- return partitionDiskUsedPercentage;
+ public MeasurementAggregate getFreeDiskToDataSizeRatio() {
+ return freeDiskToDataSizeRatio;
}
- public void setPartitionDiskUsedPercentage(MeasurementAggregateWithUnits partitionDiskUsedPercentage) {
- this.partitionDiskUsedPercentage = partitionDiskUsedPercentage;
+ public void setFreeDiskToDataSizeRatio(MeasurementAggregate freeDiskToDataSizeRatio) {
+ this.freeDiskToDataSizeRatio = freeDiskToDataSizeRatio;
}
/**
@@ -202,7 +230,7 @@ public class StorageNodeLoadComposite implements Serializable {
builder.append("heapUsed=").append(heapUsed).append(", ");
builder.append("heapPercentageUsed=").append(heapPercentageUsed).append(", ");
builder.append("load=").append(load).append(", ");
- builder.append("partitionDiskUsedPercentage=").append(partitionDiskUsedPercentage).append(", ");
+ builder.append("dataUsedPercentage=").append(dataDiskUsedPercentage).append(", ");
builder.append("dataDiskUsed=").append(dataDiskUsed).append(", ");
builder.append("tokens=").append(tokens).append(", ");
builder.append("actuallyOwns=").append(actuallyOwns);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDatasource.java
index 7d413fd..07064b7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDatasource.java
@@ -47,6 +47,7 @@ import org.rhq.core.domain.cloud.StorageNode.OperationMode;
import org.rhq.core.domain.cloud.StorageNodeLoadComposite;
import org.rhq.core.domain.cloud.StorageNodeLoadComposite.MeasurementAggregateWithUnits;
import org.rhq.core.domain.criteria.StorageNodeCriteria;
+import org.rhq.core.domain.measurement.MeasurementAggregate;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
@@ -200,7 +201,8 @@ public class StorageNodeDatasource extends RPCDataSource<StorageNode, StorageNod
public static class StorageNodeLoadCompositeDatasource extends RPCDataSource<StorageNodeLoadComposite, StorageNodeCriteria> {
public static final String HEAP_PERCENTAGE_KEY = "heapPercentage";
- public static final String DISK_SPACE_PERCENTAGE_KEY = "diskSpacePercentage";
+ public static final String DATA_DISK_SPACE_PERCENTAGE_KEY = "dataDiskSpacePercentage";
+ public static final String TOTAL_DISK_SPACE_PERCENTAGE_KEY = "totalDiskSpacePercentage";
private int id;
public static StorageNodeLoadCompositeDatasource getInstance(int id) {
@@ -296,10 +298,15 @@ public class StorageNodeDatasource extends RPCDataSource<StorageNode, StorageNod
"This value is calculated by dividing Heap Used by Heap Maximum.", HEAP_PERCENTAGE_KEY),
Arrays.<Object> asList(loadComposite.getLoad(), "Load", "Data stored on the node", "load"),
Arrays.<Object> asList(
- loadComposite.getPartitionDiskUsedPercentage(),
- "Disk Space Percent Used",
- "Percentage of total disk space used for the partition that contains the data files.If multiple data locations are specified then this will report the average utilization accross all the partitions.",
- DISK_SPACE_PERCENTAGE_KEY),
+ loadComposite.getDataDiskUsedPercentage(),
+ "Data Disk Space Percent Used",
+ "Percentage of disk space used by data files on the partitions that contain the data files. If multiple data locations are specified then the aggregate accross all the partitions that contain data files is reported.",
+ DATA_DISK_SPACE_PERCENTAGE_KEY),
+ Arrays.<Object> asList(
+ loadComposite.getTotalDiskUsedPercentage(),
+ "Total Disk Space Percent Used",
+ "Percentage of total disk space used (system and Storage Node) on the partitions that contain the data files. If multiple data locations are specified then the aggregate accross all the partitions that contain data files is reported.",
+ TOTAL_DISK_SPACE_PERCENTAGE_KEY),
Arrays.<Object> asList(
loadComposite.getDataDiskUsed(),
"Total Disk Space Used",
@@ -325,6 +332,21 @@ public class StorageNodeDatasource extends RPCDataSource<StorageNode, StorageNod
recordsList.add(tokens);
}
+
+ if (loadComposite.getFreeDiskToDataSizeRatio() != null){
+ MeasurementAggregate aggregate = loadComposite.getFreeDiskToDataSizeRatio();
+
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute("id", "freeDiskToDataSizeRatio");
+ record.setAttribute("name", "Free Disk To Data Size Ratio");
+ record.setAttribute("hover", "Ratio of (Free Disk)/(Data File Size). A value below 1 is not recommended since a compaction or repair process could double the amount of disk space used by data files. If multiple data locations are specified then the aggregate accross all the partitions that contain data files is reported.");
+ record.setAttribute("min", aggregate.getMin());
+ record.setAttribute("avg", aggregate.getAvg());
+ record.setAttribute("max", aggregate.getMax());
+
+ recordsList.add(record);
+ }
+
ListGridRecord[] records = recordsList.toArray(new ListGridRecord[recordsList.size()]);
return records;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeLoadComponent.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeLoadComponent.java
index e8dde9d..e044e4e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeLoadComponent.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeLoadComponent.java
@@ -51,8 +51,9 @@ public class StorageNodeLoadComponent extends EnhancedVLayout {
@Override
protected String getCellCSSText(ListGridRecord record, int rowNum, int colNum) {
if ("avg".equals(getFieldName(colNum))
- && (StorageNodeLoadCompositeDatasource.HEAP_PERCENTAGE_KEY.equals(record.getAttribute("id")) || StorageNodeLoadCompositeDatasource.DISK_SPACE_PERCENTAGE_KEY
- .equals(record.getAttribute("id")))) {
+ && (StorageNodeLoadCompositeDatasource.HEAP_PERCENTAGE_KEY.equals(record.getAttribute("id")) ||
+ StorageNodeLoadCompositeDatasource.DATA_DISK_SPACE_PERCENTAGE_KEY.equals(record.getAttribute("id")) ||
+ StorageNodeLoadCompositeDatasource.TOTAL_DISK_SPACE_PERCENTAGE_KEY.equals(record.getAttribute("id")))) {
if (record.getAttributeAsFloat("avgFloat") > .85) {
return "font-weight:bold; color:#d64949;";
} else if (record.getAttributeAsFloat("avgFloat") > .7) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
index fab803b..31e3bf7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
@@ -253,13 +253,16 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
Map<String, Integer> scheduleIdsMap = new HashMap<String, Integer>();
// get the schedule ids for Storage Service resource
- final String tokensMetric = "Tokens", ownershipMetric = "Ownership", diskUsedPercentageMetric = "Calculated.PartitionDiskUsedPercentage";
+ final String tokensMetric = "Tokens", ownershipMetric = "Ownership";
+ final String dataDiskUsedPercentageMetric = "Calculated.DataDiskUsedPercentage";
+ final String totalDiskUsedPercentageMetric = "Calculated.TotalDiskUsedPercentage";
+ final String freeDiskToDataRatioMetric = "Calculated.FreeDiskToDataSizeRatio";
final String loadMetric = "Load", keyCacheSize = "KeyCacheSize", rowCacheSize = "RowCacheSize", totalCommitLogSize = "TotalCommitlogSize";
TypedQuery<Object[]> query = entityManager.<Object[]> createNamedQuery(
StorageNode.QUERY_FIND_SCHEDULE_IDS_BY_PARENT_RESOURCE_ID_AND_MEASUREMENT_DEFINITION_NAMES, Object[].class);
query.setParameter("parrentId", resourceId).setParameter("metricNames",
- Arrays.asList(tokensMetric, ownershipMetric, diskUsedPercentageMetric, loadMetric, keyCacheSize,
- rowCacheSize, totalCommitLogSize));
+ Arrays.asList(tokensMetric, ownershipMetric, loadMetric, keyCacheSize, rowCacheSize, totalCommitLogSize,
+ dataDiskUsedPercentageMetric, totalDiskUsedPercentageMetric, freeDiskToDataRatioMetric));
for (Object[] pair : query.getResultList()) {
scheduleIdsMap.put((String) pair[0], (Integer) pair[1]);
}
@@ -292,10 +295,22 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
subject, scheduleId, MeasurementUnits.PERCENTAGE, beginTime, endTime);
result.setActuallyOwns(ownershipAggregateWithUnits);
}
- if ((scheduleId = scheduleIdsMap.get(diskUsedPercentageMetric)) != null) {
- StorageNodeLoadComposite.MeasurementAggregateWithUnits diskUsedPercentageAggregateWithUnits = getMeasurementAggregateWithUnits(
+
+ //calculated disk space related metrics
+ if ((scheduleId = scheduleIdsMap.get(dataDiskUsedPercentageMetric)) != null) {
+ StorageNodeLoadComposite.MeasurementAggregateWithUnits dataDiskUsedPercentageAggregateWithUnits = getMeasurementAggregateWithUnits(
+ subject, scheduleId, MeasurementUnits.PERCENTAGE, beginTime, endTime);
+ result.setDataDiskUsedPercentage(dataDiskUsedPercentageAggregateWithUnits);
+ }
+ if ((scheduleId = scheduleIdsMap.get(totalDiskUsedPercentageMetric)) != null) {
+ StorageNodeLoadComposite.MeasurementAggregateWithUnits totalDiskUsedPercentageAggregateWithUnits = getMeasurementAggregateWithUnits(
subject, scheduleId, MeasurementUnits.PERCENTAGE, beginTime, endTime);
- result.setPartitionDiskUsedPercentage(diskUsedPercentageAggregateWithUnits);
+ result.setDataDiskUsedPercentage(totalDiskUsedPercentageAggregateWithUnits);
+ }
+ if ((scheduleId = scheduleIdsMap.get(freeDiskToDataRatioMetric)) != null) {
+ MeasurementAggregate freeDiskToDataRatioAggregate = measurementManager.getAggregate(subject,
+ scheduleId, beginTime, endTime);
+ result.setFreeDiskToDataSizeRatio(freeDiskToDataRatioAggregate);
}
if ((scheduleId = scheduleIdsMap.get(loadMetric)) != null) {
diff --git a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
index 5bbebed..e95f995 100644
--- a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
@@ -188,7 +188,7 @@
<metric property="Calculated.DataDiskUsedPercentage" displayName="Data File Disk Used Percentage" dataType="measurement" units="percentage" displayType="summary" description="Percentage of disk space used by Cassandra data files. The aggregate accross all the partitions will be reported if multiple data locations are specified. This is a calculated metric derived from system and Cassandra runtime information."/>
<metric property="Calculated.TotalDiskUsedPercentage" displayName="Total Disk Used Percentage" dataType="measurement" units="percentage" displayType="summary" description="Percentage of total disk space used. The metric acounts overall disk usage (including system files), not just disk space used by Cassandra. The aggregate accross all the partitions will be reported if multiple data locations are specified. This is a calculated metric derived from system and Cassandra runtime information."/>
- <metric property="Calculated.FreeDiskToDataSizeRatio" displayName="Free Disk to Data Size Ratio" dataType="measurement" displayType="summary" description="Ratio of (Amount of Free Disk)/(Data File Size). A value below 1 is not recommended since a compaction or repair process could double the amount of disk space used by data files. The aggregate accross all the partitions will be reported if multiple data locations are specified. This is a calculated metric derived from system and Cassandra runtime information."/>
+ <metric property="Calculated.FreeDiskToDataSizeRatio" displayName="Free Disk to Data Size Ratio" dataType="measurement" displayType="summary" description="Ratio of (Free Disk)/(Data File Size). A value below 1 is not recommended since a compaction or repair process could double the amount of disk space used by data files. The aggregate accross all the partitions will be reported if multiple data locations are specified. This is a calculated metric derived from system and Cassandra runtime information."/>
<metric property="CurrentGenerationNumber" dataType="trait" displayType="summary" description="Current generation number"/>
<metric property="ExceptionCount" measurementType="trendsup" dataType="measurement" displayType="summary" description="Exception Count"/>
commit 6997631e56204db41c9f4902eef1c6210706be3f
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 22 15:14:22 2013 -0500
Add back code used to update storage node configuration tha was lost due to rebase. This code updates two additional storage node properties added.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
index b32ab5b..fab803b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
@@ -611,6 +611,8 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
storageNodeResource.getId());
configuration.setHeapSize(storageNodeConfiguration.getSimpleValue("maxHeapSize"));
+ configuration.setHeapNewSize(storageNodeConfiguration.getSimpleValue("heapNewSize"));
+ configuration.setThreadStackSize(storageNodeConfiguration.getSimpleValue("threadStackSize"));
configuration.setJmxPort(storageNode.getJmxPort());
}
diff --git a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
index 8156d02..1e39d6c 100644
--- a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
@@ -122,6 +122,9 @@
<operation name="updateConfiguration" description="Updates the node configuration. Will require a separate server restart for the settings to take effect.">
<parameters>
<c:simple-property name="heapSize" type="string" description="The heap size to be used for both -Xms and -Xmx JVM options."/>
+ <c:simple-property name="heapNewSize" type="string" description="The heap new size to be used be used with -Xmn JVM option."/>
+ <c:simple-property name="threadStackSize" type="integer" description="The thread stack size. This memory is allocated to each thread off heap. The
+ value should be an integer that will be interpreted in kilobytes."/>
<c:simple-property name="jmxPort" type="integer" description="JMX port JVM option."/>
</parameters>
<results>
10 years, 9 months
[rhq] 2 commits - modules/core pom.xml
by Heiko W. Rupp
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java | 44 ++
modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/ExtensionModelTest.java | 2
modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/NestedSubCategoriesMetadataParserTest.java | 159 ++++++++++
modules/core/client-api/src/test/resources/test-hibernate.xml | 8
modules/core/client-api/src/test/resources/test-jbossas.xml | 10
modules/core/client-api/src/test/resources/test-subcategories-nested.xml | 60 +++
pom.xml | 4
7 files changed, 279 insertions(+), 8 deletions(-)
New commits:
commit e85abcf495d6939d876b09bd1de1e71a29af17ec
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jul 23 10:42:17 2013 +0200
BZ 796480 (and others) add support for subCategory in embedded types (aka runs-inside)
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
index 88dd865..d5ff2ef 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
@@ -417,16 +417,56 @@ public class PluginMetadataParser {
return serviceResourceType;
}
- private static void setSubCategory(ResourceDescriptor resourceDescriptor, ResourceType resourceType)
+ /**
+ * Try to find the subCategory of the p/s/s descriptor in one of the parents
+ * <subcategories><subcategory>Foo</subcategory></subcategories> elements and
+ * set it on the resourceType if found.
+ *
+ * It is not enough to look at the direct parents, but we need to also look at the
+ * <runs-inside> types if our type is "embedded" in a different type.
+ * @param resourceDescriptor Descriptor to get the subCategory attribute from
+ * @param resourceType The type to attach the ResourceSubCategory to.
+ * @throws InvalidPluginDescriptorException If the descriptor.subCategory can not be found in any parent.
+ */
+ private void setSubCategory(ResourceDescriptor resourceDescriptor, ResourceType resourceType)
throws InvalidPluginDescriptorException {
String subCatName = resourceDescriptor.getSubCategory();
if (subCatName != null) {
ResourceSubCategory subCat = SubCategoriesMetadataParser.findSubCategoryOnResourceTypeAncestor(
resourceType, subCatName);
- if (subCat == null)
+
+ // We need to look at resourceDescriptor -> runsInside to see if one of those defines the
+ // subcategories that we are looking for.
+ if (subCat == null && resourceDescriptor.getRunsInside() != null) {
+ RunsInsideType rit = resourceDescriptor.getRunsInside();
+ List<ParentResourceType> parentResourceTypeList = rit.getParentResourceType();
+ for (ParentResourceType parentResourceType : parentResourceTypeList) {
+ ResourceType parentType = getResourceTypeFromPlugin(parentResourceType.getName(),parentResourceType.getPlugin());
+ // check on the parent
+ if (parentType.getChildSubCategories()!=null ) {
+ for (ResourceSubCategory parentSubcat : parentType.getChildSubCategories()) {
+ if (parentSubcat.getName().equals(subCatName)) {
+ subCat = parentSubcat;
+ break;
+ }
+ }
+ }
+
+ // Not found on runs-inside type look at the ancestor of those runs-inside types?
+ if (subCat==null) {
+ subCat = SubCategoriesMetadataParser.findSubCategoryOnResourceTypeAncestor(parentType,subCatName);
+ }
+ if (subCat!=null) {
+ break;
+ }
+ }
+ }
+
+ if (subCat == null) {
throw new InvalidPluginDescriptorException("Resource type [" + resourceType.getName()
+ "] specified a subcategory (" + subCatName
+ ") that is not defined as a child subcategory of one of its ancestor resource types.");
+ }
resourceType.setSubCategory(subCat);
}
}
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 20e1aa9..2a9595f 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
@@ -226,6 +226,7 @@ public class ExtensionModelTest {
assert jbossServer.getCategory().equals(ResourceCategory.SERVER);
assert jbossServer.getDescription().equals("JBoss Application Server Description");
assert jbossServer.getParentResourceTypes().size() == 0;
+ assert jbossServer.getChildSubCategories().size() == 2;
assert jbossServer.getChildResourceTypes().size() == 1;
ResourceType embeddedTomcatServer = jbossServer.getChildResourceTypes().iterator().next();
@@ -263,6 +264,7 @@ public class ExtensionModelTest {
assert hibernateService.getDescription().equals("Hibernate Service Description");
assert hibernateService.getChildResourceTypes().size() == 0;
assert hibernateService.getParentResourceTypes().size() == 3;
+ assert hibernateService.getSubCategory().getName().equals("Framework");
ResourceType tomcatServer = metadataManager.getType("TomcatServer", "Tomcat");
ResourceType jbossServer = metadataManager.getType("JBossASServer", "JBossAS");
diff --git a/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/NestedSubCategoriesMetadataParserTest.java b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/NestedSubCategoriesMetadataParserTest.java
new file mode 100644
index 0000000..1cba523
--- /dev/null
+++ b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/NestedSubCategoriesMetadataParserTest.java
@@ -0,0 +1,159 @@
+ /*
+ * 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.core.clientapi.agent.metadata.test;
+
+ import java.net.URL;
+ import java.util.List;
+ import java.util.Set;
+
+ import javax.xml.bind.JAXBContext;
+ import javax.xml.bind.Unmarshaller;
+ import javax.xml.bind.util.ValidationEventCollector;
+
+ import org.apache.commons.logging.Log;
+ import org.apache.commons.logging.LogFactory;
+ import org.testng.annotations.BeforeSuite;
+ import org.testng.annotations.Test;
+
+ import org.rhq.core.clientapi.agent.metadata.PluginMetadataManager;
+ import org.rhq.core.clientapi.agent.metadata.SubCategoriesMetadataParser;
+ import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil;
+ import org.rhq.core.clientapi.descriptor.DescriptorPackages;
+ import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
+ import org.rhq.core.clientapi.descriptor.plugin.ResourceDescriptor;
+ import org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor;
+ import org.rhq.core.clientapi.descriptor.plugin.ServiceDescriptor;
+ import org.rhq.core.clientapi.descriptor.plugin.SubCategoryDescriptor;
+ import org.rhq.core.domain.resource.ResourceCategory;
+ import org.rhq.core.domain.resource.ResourceSubCategory;
+ import org.rhq.core.domain.resource.ResourceType;
+
+ /**
+ * @author Charles Crouch
+ * @author Heiko W. Rupp
+ */
+public class NestedSubCategoriesMetadataParserTest {
+ private static final String DESCRIPTOR_FILENAME = "test-subcategories-nested.xml";
+ private final Log LOG = LogFactory.getLog(NestedSubCategoriesMetadataParserTest.class);
+
+ private PluginDescriptor pluginDescriptor;
+
+ @BeforeSuite
+ public void loadPluginDescriptor() throws Exception {
+ try {
+ URL descriptorUrl = this.getClass().getClassLoader().getResource(DESCRIPTOR_FILENAME);
+ LOG.info("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());
+ } catch (Throwable t) {
+ // Catch RuntimeExceptions and Errors and dump their stack trace, because Surefire will completely swallow them
+ // and throw a cryptic NPE (see http://jira.codehaus.org/browse/SUREFIRE-157)!
+ t.printStackTrace();
+ throw new RuntimeException(t);
+ }
+ }
+
+ @Test
+ public void parseSingleSubCategory() {
+ List<ServerDescriptor> servers = pluginDescriptor.getServers();
+ ServerDescriptor server0 = servers.get(0);
+ ResourceDescriptor.Subcategories subCategoriesDescriptor = server0.getSubcategories();
+ assert subCategoriesDescriptor != null : "No subcategories element: " + server0.getName();
+
+ List<SubCategoryDescriptor> subCategoryDescriptors = subCategoriesDescriptor.getSubcategory();
+
+ assert subCategoryDescriptors != null : "No subcategory elements: " + server0.getName();
+ assert !subCategoryDescriptors.isEmpty() : "No subcategory elements: " + server0.getName();
+
+ ResourceSubCategory subCat;
+
+ ResourceType resType = new ResourceType("testResType", "myplugin", ResourceCategory.SERVER, null);
+ subCat = SubCategoriesMetadataParser.getSubCategory(subCategoryDescriptors.get(0), resType);
+
+ assert subCat != null : "Null subcategory received from parser";
+ assert subCat.getName().equals("applications") : "Name not read correctly";
+ assert subCat.getDisplayName().equals("Apps") : "Display name not read correctly";
+ assert subCat.getDescription().equals("The apps.") : "Description not read correctly";
+ // getSubCategory is no longer responsible for setting resourcetype information, that is done in PluginMetadataParser
+ //assert subCat.getResourceType().equals(resType) : "ResourceType not set correctly";
+
+ }
+
+ @Test
+ public void parseNestedSubCategories() {
+ List<ServerDescriptor> servers = pluginDescriptor.getServers();
+ ServerDescriptor server2 = servers.get(1);
+ assert server2.getName().equals("testServer2");
+ ResourceDescriptor.Subcategories subCategoriesDescriptor = server2.getSubcategories();
+ assert subCategoriesDescriptor == null : "Unexpected subcategories element: " + server2.getName();
+ assert server2.getSubCategory().equals("applications");
+
+ List<ServiceDescriptor> services = pluginDescriptor.getServices();
+ ServiceDescriptor service1 = services.get(0);
+ assert service1.getName().equals("testService");
+ assert service1.getSubCategory().equals("applications");
+ }
+
+ @Test
+ public void testParseViaMetaDataManager() throws Exception {
+
+ PluginDescriptor pluginDescriptor;
+
+ URL descriptorUrl = this.getClass().getClassLoader().getResource(DESCRIPTOR_FILENAME);
+ System.out.println("Loading plugin descriptor at: " + descriptorUrl);
+
+ pluginDescriptor = (PluginDescriptor) AgentPluginDescriptorUtil.parsePluginDescriptor(descriptorUrl
+ .openStream());
+
+ PluginMetadataManager metadataManager = new PluginMetadataManager();
+ Set<ResourceType> typeSet = metadataManager.loadPlugin(pluginDescriptor);
+ assert typeSet != null : "Got no types!!";
+ assert typeSet.size()==5 : "Expected 5 types, but got " + typeSet.size();
+
+ ResourceType testService = findType(typeSet,"testService");
+ assert testService.getSubCategory().getName().equals("applications");
+
+ ResourceType testService2 = findType(typeSet,"testService2");
+ assert testService2.getSubCategory().getName().equals("applications");
+
+ ResourceType testService3 = findType(typeSet,"testService3");
+ assert testService3.getSubCategory().getName().equals("fooBar");
+
+
+ }
+
+ private ResourceType findType(Set<ResourceType> types, String name) {
+ for (ResourceType type : types ) {
+ if (type.getName().equals(name)) {
+ return type;
+ }
+ }
+ assert false : "Type with name " + name + " not found";
+ return null;
+ }
+ }
\ No newline at end of file
diff --git a/modules/core/client-api/src/test/resources/test-hibernate.xml b/modules/core/client-api/src/test/resources/test-hibernate.xml
index 37a2e03..9051ca2 100644
--- a/modules/core/client-api/src/test/resources/test-hibernate.xml
+++ b/modules/core/client-api/src/test/resources/test-hibernate.xml
@@ -3,7 +3,7 @@
package="org.rhq.plugins.test2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin">
-
+
<depends plugin="JMX" />
<depends plugin="Tomcat" />
<depends plugin="JBossAS" />
@@ -11,11 +11,13 @@
<service name="HibernateService"
discovery="HibernateDiscoveryComponent"
class="HibernateServiceComponent"
- description="Hibernate Service Description">
+ description="Hibernate Service Description"
+ subCategory="Framework"
+ >
<runs-inside>
<parent-resource-type name="TomcatServer" plugin="Tomcat"/>
<parent-resource-type name="JBossASServer" plugin="JBossAS"/>
<parent-resource-type name="EmbeddedTomcatServer" plugin="JBossAS"/>
</runs-inside>
- </service>
+ </service>
</plugin>
\ No newline at end of file
diff --git a/modules/core/client-api/src/test/resources/test-jbossas.xml b/modules/core/client-api/src/test/resources/test-jbossas.xml
index 4d2602b..8269343 100644
--- a/modules/core/client-api/src/test/resources/test-jbossas.xml
+++ b/modules/core/client-api/src/test/resources/test-jbossas.xml
@@ -12,7 +12,11 @@
discovery="JBossASDiscoveryComponent"
class="JBossASServerComponent"
description="JBoss Application Server Description">
-
+ <subcategories>
+ <subcategory name="Applications" />
+ <subcategory name="Framework" />
+ </subcategories>
+
<operation name="stop" displayName="Stop JBossAS Server" description="Kills the server" timeout="30">
<parameters>
<c:simple-property name="force"
@@ -29,7 +33,7 @@
required="true"
description="If true, the server is definitely down; otherwise, the shutdown was issued but it is unclear if it really died"/>
</results>
- </operation>
+ </operation>
<server name="EmbeddedTomcatServer"
description="Embedded Tomcat Web Server Description"
sourcePlugin="Tomcat"
@@ -37,6 +41,6 @@
discovery="JBossASTomcatDiscoveryComponent"
class="JBossASTomcatServerComponent">
</server>
-
+
</server>
</plugin>
\ No newline at end of file
diff --git a/modules/core/client-api/src/test/resources/test-subcategories-nested.xml b/modules/core/client-api/src/test/resources/test-subcategories-nested.xml
new file mode 100644
index 0000000..eb43af7
--- /dev/null
+++ b/modules/core/client-api/src/test/resources/test-subcategories-nested.xml
@@ -0,0 +1,60 @@
+<!--
+ ~ RHQ Management Platform
+ ~ Copyright (C) 2005-2013 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.,
+ ~ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ -->
+
+<plugin name="TestPlugin" displayName="Mock JBoss AS" package="org.rhq.plugins.mock.jboss"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:xmlns:rhq-plugin">
+
+ <server name="testServer1">
+ <subcategories>
+ <subcategory name="applications" displayName="Apps" description="The apps."/>
+ <subcategory name="fooBar"/>
+ </subcategories>
+ </server>
+
+ <!-- subCategory="applications" means that resources of this type go in the 'applications folder' of testServer1-->
+ <server name="testServer2" subCategory="applications">
+ <runs-inside>
+ <parent-resource-type name="testServer1" plugin="TestPlugin"/>
+ </runs-inside>
+ <metric property="testMetric"/>
+ </server>
+
+ <service name="testService" subCategory="applications">
+ <runs-inside>
+ <parent-resource-type name="testServer1" plugin="TestPlugin"/>
+ </runs-inside>
+
+ </service>
+
+ <service name="testService2" subCategory="applications">
+ <runs-inside>
+ <parent-resource-type name="testServer1" plugin="TestPlugin"/>
+ </runs-inside>
+
+ </service>
+
+ <service name="testService3" subCategory="fooBar">
+ <runs-inside>
+ <parent-resource-type name="testServer1" plugin="TestPlugin"/>
+ </runs-inside>
+
+ </service>
+
+</plugin>
commit 60329fcbda5a1961e0f9285c70eb56ea12fe2eb0
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jul 22 15:00:35 2013 +0200
Add Michael Burman as contributor
diff --git a/pom.xml b/pom.xml
index c5cf5a7..3662bc7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2353,6 +2353,10 @@
<timezone>+1</timezone>
</contributor>
<contributor>
+ <name>Michael Burman</name>
+ <timezone>+2</timezone>
+ </contributor>
+ <contributor>
<name>Torben Jäger</name>
<timezone>+1</timezone>
</contributor>
10 years, 9 months
[rhq] modules/plugins
by Thomas Segismont
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java | 7 ++++-
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java | 12 ++++------
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java | 7 ++++-
3 files changed, 15 insertions(+), 11 deletions(-)
New commits:
commit d7e9f5b9871824d1f02ae762b44cff85ff6c3d44
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Tue Jul 23 10:41:12 2013 +0200
Bug 969621 - EAP 6 managed plug-in is unable to discover EAP servers when more then one is running on a single host
Update expected resource keys in itests
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java
index 91ece92..269474b 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java
@@ -43,8 +43,11 @@ public class DomainServerComponentTest extends AbstractServerComponentTest {
public static final ResourceType RESOURCE_TYPE =
new ResourceType("JBossAS7 Host Controller", PLUGIN_NAME, ResourceCategory.SERVER, null);
- // The key is the server's base dir.
- public static final String RESOURCE_KEY = new File(JBOSS_HOME, "domain").getPath();
+ // The key is the server host config file
+ // hostConfig: /tmp/jboss-as-6.0.0/domain/configuration/host.xml
+ public static final String RESOURCE_KEY = "hostConfig: "
+ + new File(JBOSS_HOME, "domain" + File.separator + "configuration" + File.separator + "host.xml")
+ .getAbsolutePath();
@Override
protected ResourceType getServerResourceType() {
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java
index d128144..182ef36 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* 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.
+ * 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.modules.plugins.jbossas7.itest.domain;
@@ -488,10 +488,8 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
InventoryManager im = pluginContainer.getInventoryManager();
Resource platform = im.getPlatform();
//host controller
- ResourceType hostControllerType = new ResourceType("JBossAS7 Host Controller", PLUGIN_NAME,
- ResourceCategory.SERVER, null);
- Resource hostController = getResourceByTypeAndKey(platform, hostControllerType,
- "/tmp/jboss-as-6.0.0/domain");
+ Resource hostController = getResourceByTypeAndKey(platform, DomainServerComponentTest.RESOURCE_TYPE,
+ DomainServerComponentTest.RESOURCE_KEY);
//profile=full-ha
ResourceType profileType = new ResourceType("Profile", PLUGIN_NAME, ResourceCategory.SERVICE, null);
String key = PROFILE;
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java
index 8446345..32f92c7 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java
@@ -51,8 +51,11 @@ public class StandaloneServerComponentTest extends AbstractServerComponentTest {
public static final ResourceType RESOURCE_TYPE =
new ResourceType("JBossAS7 Standalone Server", PLUGIN_NAME, ResourceCategory.SERVER, null);
- // The key is the server's base dir.
- public static final String RESOURCE_KEY = new File(JBOSS_HOME, "standalone").getPath();
+ // The key is the server host config file
+ // hostConfig: /tmp/jboss-as-6.0.0/standalone/configuration/standalone-full-ha.xml
+ public static final String RESOURCE_KEY = "hostConfig: "
+ + new File(JBOSS_HOME, "standalone" + File.separator + "configuration" + File.separator
+ + "standalone-full-ha.xml").getAbsolutePath();
private static final String RELOAD_OPERATION_NAME = "reload";
private static final String RESTART_OPERATION_NAME = "restart";
10 years, 9 months
[rhq] Branch 'mtho11/consolidated-metrics' - 92 commits - .classpath etc/agent-versioning etc/dev-utils etc/rhq-ircBot etc/scripts modules/common modules/core modules/enterprise modules/helpers modules/plugins pom.xml
by mike thompson
.classpath | 1
etc/agent-versioning/build.xml | 2
etc/dev-utils/TestLdapSettings.java | 102 +
etc/rhq-ircBot/src/main/java/org/rhq/etc/ircbot/RhqIrcBotListener.java | 5
etc/scripts/rhq48-storage-patch/rhq48-storage-patch.bat | 104 +
etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh | 43
modules/common/cassandra-auth/pom.xml | 27
modules/common/cassandra-auth/src/main/java/org/rhq/cassandra/auth/RhqInternodeAuthenticator.java | 78 +
modules/common/cassandra-auth/src/main/java/org/rhq/cassandra/auth/RhqInternodeAuthenticatorMBean.java | 10
modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml | 87 -
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/bin/cassandra | 192 ++
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/cassandra-jvm.properties | 112 +
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra-env.sh | 247 ---
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml | 4
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/deploy.xml | 221 ---
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/cassandra/cli/dbsetup.script | 40
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/cassandra/cql/create_keyspace.cql | 1
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/cassandra/cql/dbsetup.cql | 42
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java | 39
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java | 83 +
modules/common/cassandra-ccm/cassandra-ccm-core/src/test/java/org/rhq/cassandra/DeployerITest.java | 4
modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-env.sh | 247 ---
modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-jvm.properties | 112 +
modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra.yaml | 4
modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java | 146 +-
modules/common/cassandra-installer/src/test/java/org/rhq/storage/installer/StorageInstallerTest.java | 204 ++
modules/common/cassandra-installer/src/test/resources/log4j.properties | 41
modules/common/cassandra-installer/src/test/resources/rhq48/storage/conf/cassandra-env.sh | 247 +++
modules/common/cassandra-installer/src/test/resources/rhq48/storage/conf/cassandra.yaml | 690 ++++++++++
modules/common/cassandra-installer/src/test/resources/rhq48/storage/conf/log4j-server.properties | 45
modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ClusterBuilder.java | 7
modules/common/pom.xml | 1
modules/core/dbutils/pom.xml | 2
modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/StorageNodeAddressUpgradeTask.java | 54
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 5
modules/core/domain/intentional-api-changes-since-4.8.0.xml | 8
modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java | 3
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDampening.java | 3
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java | 4
modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNode.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeConfigurationComposite.java | 130 +
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java | 247 +++
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java | 9
modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementUnits.java | 13
modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationBuilderTest.java | 237 +++
modules/core/native-system/src/main/java/org/rhq/core/system/SigarAccess.java | 44
modules/core/native-system/src/main/java/org/rhq/core/system/SigarAccessHandler.java | 201 ++
modules/core/native-system/src/test/java/org/rhq/core/system/SigarAccessHandlerTest.java | 172 ++
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java | 2
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java | 15
modules/enterprise/gui/coregui/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 20
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java | 42
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionEditor.java | 38
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/DashboardLinkUtility.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java | 204 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java | 99 -
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 7
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties | 5
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties | 4
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties | 5
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties | 5
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties | 5
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties | 5
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties | 5
modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml | 12
modules/enterprise/gui/rest-war/src/main/java/org/rhq/enterprise/rest/JsonPFilter.java | 23
modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.bat | 14
modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.sh | 14
modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml | 8
modules/enterprise/server/appserver/src/main/scripts/storage_setup.groovy | 5
modules/enterprise/server/client-api/src/test/java/org/rhq/enterprise/client/test/LocalClientTest.java | 22
modules/enterprise/server/ear/pom.xml | 4
modules/enterprise/server/ear/src/main/application/META-INF/jboss-deployment-structure.xml | 2
modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java | 2
modules/enterprise/server/itests-2/pom.xml | 4
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/client/security/test/JndiAccessTest.java | 86 -
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/test/GroupMemberCandidateResourcesTest.java | 190 ++
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java | 67
modules/enterprise/server/itests-2/src/test/resources/application.xml | 4
modules/enterprise/server/itests-2/src/test/resources/jboss-deployment-structure.xml | 2
modules/enterprise/server/jar/intentional-api-changes-since-4.8.0.xml | 18
modules/enterprise/server/jar/pom.xml | 21
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java | 215 +++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java | 26
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerRemote.java | 27
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java | 16
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/remote/RemoteSafeInvocationHandler.java | 10
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 8
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java | 20
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java | 29
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/StorageNodeMaintenanceJob.java | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java | 10
modules/enterprise/server/jar/src/main/resources/server-comm-configuration-overrides.properties | 2
modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpInfo.java | 10
modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml | 16
modules/enterprise/server/plugins/alert-snmp/src/test/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpInfoTest.java | 6
modules/enterprise/server/plugins/alert-snmp/src/test/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSenderTest.java | 5
modules/enterprise/server/plugins/alertdef-rhq/src/main/java/org/rhq/enterprise/server/plugins/alertdef/AlertDefinitionServerPluginComponent.java | 49
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/ControlCommand.java | 86 +
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/AbstractInstall.java | 55
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java | 2
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Start.java | 10
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Stop.java | 10
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Upgrade.java | 2
modules/enterprise/server/server-metrics/pom.xml | 12
modules/enterprise/server/startup-subsystem/pom.xml | 4
modules/helpers/metrics-simulator/pom.xml | 6
modules/helpers/pluginAnnotations/pom.xml | 4
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/ConfigProperty.java | 49
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Parameter.java | 5
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqType.java | 77 +
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java | 12
modules/helpers/pluginGen/pom.xml | 42
modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/AnnotationProcessor.java | 162 ++
modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/DirectoryClassLoader.java | 142 ++
modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Generator.java | 357 +++++
modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/PluginGen.java | 35
modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Prop.java | 135 +
modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java | 68
modules/helpers/pluginGen/src/main/resources/component.ftl | 9
modules/helpers/pluginGen/src/main/resources/descriptor.ftl | 9
modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl | 31
modules/helpers/pluginGen/src/main/resources/pom.ftl | 21
modules/helpers/pluginGen/src/test/java/org/rhq/helpers/pluginGen/test/FooBean.java | 64
modules/helpers/rest-docs-generator/pom.xml | 12
modules/plugins/cassandra/pom.xml | 4
modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java | 124 +
modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/StorageServiceComponent.java | 60
modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml | 14
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java | 64
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java | 55
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java | 25
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/helper/HostConfiguration.java | 24
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/InterruptibleOperationsTest.java | 13
modules/plugins/rhq-storage/pom.xml | 97 -
modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java | 130 +
modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java | 192 ++
modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml | 54
modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java | 191 ++
modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java | 41
pom.xml | 7
144 files changed, 6408 insertions(+), 1884 deletions(-)
New commits:
commit 4d3cd62b836415b00987b25d65a6ab38d732abc3
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Mon Jul 22 19:04:10 2013 -0700
Consolidated Metrics -Finish 'add to dashboard' button menu functionality. .
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/DashboardLinkUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/DashboardLinkUtility.java
index e7482fe..779f877 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/DashboardLinkUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/DashboardLinkUtility.java
@@ -65,13 +65,12 @@ import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
public class DashboardLinkUtility {
final static Messages MSG = CoreGUI.getMessages();
- public DashboardLinkUtility getInstance(){
- return new DashboardLinkUtility();
+ private DashboardLinkUtility() {
}
- private DashboardLinkUtility(){ }
- public static MenuItem buildMetricsMenu(final ResourceType type, final Resource resource) {
- MenuItem measurements = new MenuItem(MSG.view_tree_common_contextMenu_measurements());
+ public static MenuItem buildMetricsMenu(final ResourceType resourceType, final Resource resource, String label) {
+
+ MenuItem measurements = new MenuItem(label);
final Menu measurementsSubMenu = new Menu();
DashboardCriteria criteria = new DashboardCriteria();
@@ -87,7 +86,7 @@ public class DashboardLinkUtility {
//sort the display items alphabetically
TreeSet<String> ordered = new TreeSet<String>();
Map<String, MeasurementDefinition> definitionMap = new HashMap<String, MeasurementDefinition>();
- for (MeasurementDefinition m : type.getMetricDefinitions()) {
+ for (MeasurementDefinition m : resourceType.getMetricDefinitions()) {
ordered.add(m.getDisplayName());
definitionMap.put(m.getDisplayName(), m);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index e305039..a3990bb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -32,11 +32,6 @@ import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
-import com.google.gwt.http.client.Request;
-import com.google.gwt.http.client.RequestBuilder;
-import com.google.gwt.http.client.RequestCallback;
-import com.google.gwt.http.client.RequestException;
-import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSCallback;
@@ -60,17 +55,8 @@ import com.smartgwt.client.widgets.tree.events.DataArrivedHandler;
import com.smartgwt.client.widgets.tree.events.NodeContextClickEvent;
import com.smartgwt.client.widgets.tree.events.NodeContextClickHandler;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.criteria.DashboardCriteria;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
-import org.rhq.core.domain.criteria.SubjectCriteria;
-import org.rhq.core.domain.dashboard.Dashboard;
-import org.rhq.core.domain.dashboard.DashboardPortlet;
-import org.rhq.core.domain.measurement.DataType;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.measurement.MeasurementSchedule;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
@@ -82,11 +68,9 @@ 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.LinkManager;
-import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.ResourceD3GraphPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
@@ -101,8 +85,6 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTyp
import org.rhq.enterprise.gui.coregui.client.util.Log;
import org.rhq.enterprise.gui.coregui.client.util.enhanced.EnhancedVLayout;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import org.rhq.enterprise.gui.coregui.client.util.preferences.MeasurementUserPreferences;
-import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
/**
* @author Jay Shaughnessy
@@ -562,7 +544,7 @@ public class ResourceTreeView extends EnhancedVLayout {
resourceContextMenu.addItem(operations);
// Metric graph addition menu
- resourceContextMenu.addItem(buildMetricsMenu(resourceType, resource));
+ resourceContextMenu.addItem(DashboardLinkUtility.buildMetricsMenu(resourceType, resource, MSG.view_tree_common_contextMenu_measurements()));
// Create Child Menu and Manual Import Menu
final Set<ResourceType> creatableChildTypes = getCreatableChildTypes(resourceType);
@@ -725,190 +707,6 @@ public class ResourceTreeView extends EnhancedVLayout {
tree.reloadChildren(refreshNode);
}
- private MenuItem buildMetricsMenu(final ResourceType type, final Resource resource) {
- MenuItem measurements = new MenuItem(MSG.view_tree_common_contextMenu_measurements());
- final Menu measurementsSubMenu = new Menu();
-
- DashboardCriteria criteria = new DashboardCriteria();
- GWTServiceLookup.getDashboardService().findDashboardsByCriteria(criteria,
- new AsyncCallback<PageList<Dashboard>>() {
-
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_contextMenu_loadFailed_dashboard(),
- caught);
- }
-
- public void onSuccess(PageList<Dashboard> result) {
- //sort the display items alphabetically
- TreeSet<String> ordered = new TreeSet<String>();
- Map<String, MeasurementDefinition> definitionMap = new HashMap<String, MeasurementDefinition>();
- for (MeasurementDefinition m : type.getMetricDefinitions()) {
- ordered.add(m.getDisplayName());
- definitionMap.put(m.getDisplayName(), m);
- }
-
- for (String displayName : ordered) {
- final MeasurementDefinition def = definitionMap.get(displayName);
- //only add menu items for Measurement
- if (def.getDataType().equals(DataType.MEASUREMENT)) {
- MenuItem defItem = new MenuItem(def.getDisplayName());
- measurementsSubMenu.addItem(defItem);
- Menu defSubItem = new Menu();
- defItem.setSubmenu(defSubItem);
-
- for (final Dashboard d : result) {
- MenuItem addToDBItem = new MenuItem(MSG
- .view_tree_common_contextMenu_addChartToDashboard(d.getName()));
- defSubItem.addItem(addToDBItem);
-
- addToDBItem.addClickHandler(new ClickHandler() {
-
- public void onClick(MenuItemClickEvent menuItemClickEvent) {
- DashboardPortlet p = new DashboardPortlet(MSG
- .view_tree_common_contextMenu_resourceGraph(), ResourceD3GraphPortlet.KEY,
- 250);
- p.getConfiguration().put(
- new PropertySimple(ResourceD3GraphPortlet.CFG_RESOURCE_ID, resource.getId()));
- p.getConfiguration().put(
- new PropertySimple(ResourceD3GraphPortlet.CFG_DEFINITION_ID, def.getId()));
-
- d.addPortlet(p);
-
- GWTServiceLookup.getDashboardService().storeDashboard(d,
- new AsyncCallback<Dashboard>() {
-
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_tree_common_contextMenu_saveChartToDashboardFailure(),
- caught);
- }
-
- public void onSuccess(Dashboard result) {
- CoreGUI
- .getMessageCenter()
- .notify(
- new Message(
- MSG.view_tree_common_contextMenu_saveChartToDashboardSuccessful(result
- .getName()), Message.Severity.Info));
- }
- });
-
- }
-
- });
-
-
- }//end dashboard iteration
-
- //add new menu item for adding current graphable element to view if on Monitor/Graphs tab
- String currentViewPath = History.getToken();
- if (currentViewPath.contains("Monitoring/Metrics")) {
- MenuItem addGraphItem = new MenuItem(MSG.common_title_add_graph_to_view());
- defSubItem.addItem(addGraphItem);
-
- addGraphItem.addClickHandler(new ClickHandler() {
- public void onClick(MenuItemClickEvent menuItemClickEvent) {
- //generate javascript to call out to.
- //Ex. menuLayers.hide();addMetric('${metric.resourceId},${metric.scheduleId}')
- if (getScheduleDefinitionId(resource, def.getName()) > -1) {
- final String resourceGraphElements = resource.getId() + ","
- + getScheduleDefinitionId(resource, def.getName());
-
- //Once, the portal-war will be rewritten to GWT and operations performed
- //within the iframe + JSF will update the user preferences, the following
- //2 lines could be uncommented and the lines below them refactorized
- //MeasurementUserPreferences measurementPreferences = new MeasurementUserPreferences(UserSessionManager.getUserPreferences());
- //String selectedView = measurementPreferences.getSelectedView(String.valueOf(resource.getId()));
-
- final int sid = UserSessionManager.getSessionSubject().getId();
- SubjectCriteria c = new SubjectCriteria();
- c.addFilterId(sid);
-
- GWTServiceLookup.getSubjectService().findSubjectsByCriteria(c,
- new AsyncCallback<PageList<Subject>>() {
- public void onSuccess(PageList<Subject> result) {
- if (result.size() > 0) {
- UserPreferences uPreferences = new UserPreferences(result
- .get(0));
- MeasurementUserPreferences mPreferences = new MeasurementUserPreferences(
- uPreferences);
- String selectedView = mPreferences.getSelectedView(String
- .valueOf(resource.getId()));
-
- addNewMetric(String.valueOf(resource.getId()),
- selectedView, resourceGraphElements);
- } else {
- Log.trace("Error obtaining subject with id:" + sid);
- }
- }
-
- public void onFailure(Throwable caught) {
- Log.trace("Error obtaining subject with id:" + sid, caught);
- }
- });
- }
- }
- });
- } // end add the "add to view" menu item
- }//end trait exclusion
- }//end measurement def iteration
-
- }
- });
- measurements.setSubmenu(measurementsSubMenu);
- return measurements;
- }
-
- private void addNewMetric(String id, String selectedView, String resourceGraphElements) {
- //construct portal.war url to access
- String baseUrl = "/resource/common/monitor/visibility/IndicatorCharts.do";
- baseUrl += "?id=" + id;
- baseUrl += "&view=" + selectedView;
- baseUrl += "&action=addChart&metric=" + resourceGraphElements;
- final String url = baseUrl;
- //initiate HTTP request
- final RequestBuilder b = new RequestBuilder(RequestBuilder.GET, baseUrl);
-
- try {
- b.setCallback(new RequestCallback() {
- public void onResponseReceived(final Request request, final Response response) {
- Log.trace("Successfully submitted request to add graph to view:" + url);
-
- //kick off a page reload.
- String currentViewPath = History.getToken();
- CoreGUI.goToView(currentViewPath, true);
- }
-
- @Override
- public void onError(Request request, Throwable t) {
- Log.trace("Error adding Metric:" + url, t);
- }
- });
- b.send();
- } catch (RequestException e) {
- Log.trace("Error adding Metric:" + url, e);
- }
- }
-
- /** Locate the specific schedule definition using the definition identifier.
- */
- private int getScheduleDefinitionId(Resource resource, String definitionName) {
- int id = -1;
- if (resource.getSchedules() != null) {
- boolean located = false;
- MeasurementSchedule[] schedules = new MeasurementSchedule[resource.getSchedules().size()];
- resource.getSchedules().toArray(schedules);
- for (int i = 0; (!located && i < resource.getSchedules().size()); i++) {
- MeasurementSchedule schedule = schedules[i];
- MeasurementDefinition definition = schedule.getDefinition();
- if ((definition != null) && definition.getName().equals(definitionName)) {
- located = true;
- id = schedule.getId();
- }
- }
- }
- return id;
- }
private void setRootResource(Resource rootResource) {
this.rootResource = rootResource;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
index 31534ed..b837af1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
@@ -44,21 +44,18 @@ import com.smartgwt.client.widgets.grid.events.RecordCollapseEvent;
import com.smartgwt.client.widgets.grid.events.RecordCollapseHandler;
import com.smartgwt.client.widgets.grid.events.RecordExpandEvent;
import com.smartgwt.client.widgets.grid.events.RecordExpandHandler;
+import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
+import com.smartgwt.client.widgets.grid.events.SelectionEvent;
import com.smartgwt.client.widgets.grid.events.SortChangedHandler;
import com.smartgwt.client.widgets.grid.events.SortEvent;
import com.smartgwt.client.widgets.layout.VLayout;
-import com.smartgwt.client.widgets.menu.MenuItem;
-import com.smartgwt.client.widgets.menu.events.ClickHandler;
-import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
+import com.smartgwt.client.widgets.menu.Menu;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.criteria.SubjectCriteria;
import org.rhq.core.domain.measurement.MeasurementData;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.MeasurementUnits;
import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
@@ -68,12 +65,12 @@ import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractD3GraphLis
import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.MetricGraphData;
import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.RedrawGraphs;
import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.StackedBarMetricGraphImpl;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.DashboardLinkUtility;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.MetricD3Graph;
import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
import org.rhq.enterprise.gui.coregui.client.util.Log;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementConverterClient;
import org.rhq.enterprise.gui.coregui.client.util.preferences.MeasurementUserPreferences;
-import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
/**
* Views a resource's metrics in a tabular view with sparkline graph and optional detailed d3 graph.
@@ -86,13 +83,18 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
private final Resource resource;
private final AbstractD3GraphListView abstractD3GraphListView;
- private MeasurementUserPreferences measurementUserPrefs;
+ private final MeasurementUserPreferences measurementUserPrefs;
+ private final Menu addToDashboardMenu;
public MetricsTableView(Resource resource, AbstractD3GraphListView abstractD3GraphListView) {
super();
this.resource = resource;
this.abstractD3GraphListView = abstractD3GraphListView;
setDataSource(new MetricsViewDataSource(resource));
+ addToDashboardMenu = new Menu();
+ addToDashboardMenu.setWidth(200);
+ addToDashboardMenu.setItems(DashboardLinkUtility.buildMetricsMenu(resource.getResourceType(), resource,
+ MSG.view_metric_addToDashboard()));
measurementUserPrefs = new MeasurementUserPreferences(UserSessionManager.getUserPreferences());
}
@@ -104,7 +106,7 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
*/
@Override
protected ListGrid createListGrid() {
- return new MetricsTableListGrid(resource);
+ return new MetricsTableListGrid(resource, addToDashboardMenu);
}
protected void configureTable() {
@@ -112,7 +114,7 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
setListGridFields(fields.toArray(new ListGridField[0]));
addTableAction(MSG.view_measureTable_getLive(), new ShowLiveDataTableAction(this));
- addTableAction(MSG.view_measureTable_addToDashboard(), new AddToDashboardTableAction(this));
+ addExtraWidget(addToDashboardMenu, false);
}
@@ -230,76 +232,6 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
}
- private static class AddToDashboardTableAction implements TableAction {
- private MetricsTableView metricsTableView;
-
- public AddToDashboardTableAction(MetricsTableView metricsTableView) {
- this.metricsTableView = metricsTableView;
- }
-
- @Override
- public boolean isEnabled(ListGridRecord[] selection) {
- return selection != null && selection.length > 0;
- }
-
- @Override
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- //@todo: Add to Dashboard
- }
-
- public void abc(){
-
- MenuItem addGraphItem = new MenuItem(MSG.common_title_add_graph_to_view());
- defSubItem.addItem(addGraphItem);
-
- addGraphItem.addClickHandler(new ClickHandler() {
- public void onClick(MenuItemClickEvent menuItemClickEvent) {
- //generate javascript to call out to.
- //Ex. menuLayers.hide();addMetric('${metric.resourceId},${metric.scheduleId}')
- if (getScheduleDefinitionId(resource, def.getName()) > -1) {
- final String resourceGraphElements = resource.getId() + ","
- + getScheduleDefinitionId(resource, def.getName());
-
- //Once, the portal-war will be rewritten to GWT and operations performed
- //within the iframe + JSF will update the user preferences, the following
- //2 lines could be uncommented and the lines below them refactorized
- //MeasurementUserPreferences measurementPreferences = new MeasurementUserPreferences(UserSessionManager.getUserPreferences());
- //String selectedView = measurementPreferences.getSelectedView(String.valueOf(resource.getId()));
-
- final int sid = UserSessionManager.getSessionSubject().getId();
- SubjectCriteria c = new SubjectCriteria();
- c.addFilterId(sid);
-
- GWTServiceLookup.getSubjectService().findSubjectsByCriteria(c,
- new AsyncCallback<PageList<Subject>>() {
- public void onSuccess(PageList<Subject> result) {
- if (result.size() > 0) {
- UserPreferences uPreferences = new UserPreferences(result
- .get(0));
- MeasurementUserPreferences mPreferences = new MeasurementUserPreferences(
- uPreferences);
- String selectedView = mPreferences.getSelectedView(String
- .valueOf(resource.getId()));
-
- addNewMetric(String.valueOf(resource.getId()),
- selectedView, resourceGraphElements);
- } else {
- Log.trace("Error obtaining subject with id:" + sid);
- }
- }
-
- public void onFailure(Throwable caught) {
- Log.trace("Error obtaining subject with id:" + sid, caught);
- }
- });
- }
- }
- });
-
- }
-
- }
-
@Override
/**
* Redraw Graphs in this context means to refresh the table and redraw open graphs.
@@ -322,10 +254,13 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
private static final int TREEVIEW_DETAIL_CHART_HEIGHT = 205;
private static final int NUM_METRIC_POINTS = 60;
private Resource resource;
+ final private Menu addToDashboardMenu;
- public MetricsTableListGrid(Resource resource) {
+ public MetricsTableListGrid(final Resource resource, final Menu dashboardMenu) {
super();
this.resource = resource;
+ this.addToDashboardMenu = dashboardMenu;
+ this.addToDashboardMenu.disable();
setCanExpandRecords(true);
setCanExpandMultipleRecords(true);
setExpansionMode(ExpansionMode.DETAIL_FIELD);
@@ -345,10 +280,10 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
addSortChangedHandler(new SortChangedHandler() {
@Override
public void onSortChanged(SortEvent sortEvent) {
- Log.debug("SortChangeHandler");
redrawGraphs();
}
});
+
}
@Override
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 42e8e07..cf54939 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
@@ -1795,6 +1795,7 @@ view_messageCenter_messageTime = Time
view_messageCenter_messageTitle = Message Center
view_messageCenter_noRecentMessages = No Recent Messages
view_messageCenter_stackTraceFollows = --- STACK TRACE FOLLOWS ---
+view_metric_addToDashboard = Add to Dashboard
view_metric_traits = Traits
view_metric_viewTraitHistory = Value History for Trait [{0}]
view_operationHistoryDetails_dateCompleted = Date Completed
@@ -2114,7 +2115,7 @@ view_titleBar_common_updateTagsSuccessful = The tags for [{0}] have been updated
view_titleBar_group_failInfo = Failed to get general info on group [{0}] with ID [{1}]
view_titleBar_group_summary_collapsedTooltip = Click to show more details for this group
view_titleBar_group_summary_expandedTooltip = Click to hide details for this group
-view_tree_common_contextMenu_addChartToDashboard = Add chart to dashboard [{0}]
+view_tree_common_contextMenu_addChartToDashboard = Add Graph to Dashboard [{0}]
view_tree_common_contextMenu_editPluginConfiguration = Edit [{0}] Plugin Configuration
view_tree_common_contextMenu_editResourceConfiguration = Edit [{0}] Resource Configuration
view_tree_common_contextMenu_groupGraph = Group Metric Graph
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
index d26f4cb..ac8a91e 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
@@ -1807,6 +1807,7 @@ view_messageCenter_messageTime = Čas
view_messageCenter_messageTitle = Centrum zpráv
view_messageCenter_noRecentMessages = Žádné nové zprávy
view_messageCenter_stackTraceFollows = --- VÝPIS ZÁSOBNÍKU NÍŽE ---
+##view_metric_addToDashboard = Add to Dashboard
view_metric_traits = Vlastnosti
view_metric_viewTraitHistory = Historie hodnot pro vlastnost [{0}]
view_operationHistoryDetails_dateCompleted = Datum ukončení
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 5392198..a775ed1 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
@@ -1594,6 +1594,7 @@ view_messageCenter_messageTime = Zeitpukt
view_messageCenter_messageTitle = Nachrichtencenter
view_messageCenter_noRecentMessages = Keine aktuellen Nachrichten
view_messageCenter_stackTraceFollows = --- STACK TRACE FOLGT ---
+##view_metric_addToDashboard = Add to Dashboard
view_metric_traits = Traits
view_metric_viewTraitHistory = Werteverlauf für Trait [{0}]
##view_operationCreateWizard_error_scheduleOperationFailure = Failed to schedule operation execution.
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 3edf1b0..cf88ed6 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
@@ -1778,6 +1778,7 @@ view_messageCenter_messageTime = 時間
view_messageCenter_messageTitle = メッセージセンター
view_messageCenter_noRecentMessages = 最近のメッセージはありません
view_messageCenter_stackTraceFollows = --- スタックトレース ---
+##view_metric_addToDashboard = Add to Dashboard
view_metric_traits = トレイト
view_metric_viewTraitHistory = トレイト [{0}] のための値の履歴
view_operationHistoryDetails_dateCompleted = 完了日
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
index f8e27fc..1849bb7 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
@@ -1499,6 +1499,7 @@ view_messageCenter_messageTime = 시간
view_messageCenter_messageTitle = 메시지 센터
view_messageCenter_noRecentMessages = 최근 메시지는 없습니다
view_messageCenter_stackTraceFollows = --- 스택 추적 ---
+##view_metric_addToDashboard = Add to Dashboard
view_metric_traits = 특성
view_metric_viewTraitHistory = 특성 [{0}]에 대한 값 기록
view_operationHistoryDetails_dateCompleted = 완료일
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 8a6373d..517c787 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
@@ -1811,6 +1811,7 @@ view_messageCenter_messageTime = Tempo
view_messageCenter_messageTitle = Centro de Mensagens
view_messageCenter_noRecentMessages = N\u00E3o existem Mensagens Recentes
view_messageCenter_stackTraceFollows = --- STACK TRACE FOLLOWS ---
+##view_metric_addToDashboard = Add to Dashboard
view_metric_traits = Traits
view_metric_viewTraitHistory = Value History for Trait [{0}]
view_operationCreateWizard_button_execute = Execute
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
index ad560b4..6311cef 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
@@ -1731,6 +1731,7 @@
#view_messageCenter_messageTitle = Message Center
#view_messageCenter_noRecentMessages = No Recent Messages
#view_messageCenter_stackTraceFollows = --- STACK TRACE FOLLOWS ---
+##view_metric_addToDashboard = Add to Dashboard
#view_metric_traits = Traits
#view_metric_viewTraitHistory = Value History for Trait [{0}]
#view_operationHistoryDetails_dateCompleted = Date Completed
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 855cb73..67006d0 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
@@ -1779,6 +1779,7 @@ view_messageCenter_messageTime = \u65f6\u95f4
view_messageCenter_messageTitle = \u6d88\u606f\u4e2d\u5fc3
view_messageCenter_noRecentMessages = \u65e0\u8fd1\u671f\u6d88\u606f
view_messageCenter_stackTraceFollows = --- \u540e\u9762\u662f\u5f02\u5e38\u4fe1\u606f ---
+##view_metric_addToDashboard = Add to Dashboard
view_metric_traits = \u7279\u5f81
view_metric_viewTraitHistory = Value History for Trait [{0}]
view_operationHistoryDetails_dateCompleted = \u5b8c\u6210\u65e5\u671f
commit 221e5895acffdde2a44029a9ec5b9a7293f1bfdd
Merge: 061d403 e1461de
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Mon Jul 22 10:44:48 2013 -0700
Merge branch 'master' into mtho11/consolidated-metrics
commit e1461de493712c30e454fa51f946a72cadf2c257
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 22 07:47:00 2013 -0500
Fix merge rebase issue.
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
index 4744e96..3b0aa5b 100644
--- a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
+++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
@@ -41,8 +41,8 @@ import org.mc4j.ems.connection.bean.attribute.EmsAttribute;
import org.mc4j.ems.connection.bean.operation.EmsOperation;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.Property;
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;
@@ -116,7 +116,8 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
if (!configurationUpdate.getStatus().equals(ConfigurationUpdateStatus.SUCCESS)) {
result.setErrorMessage(configurationUpdate.getErrorMessage());
-
+ }
+
return result;
}
commit 642421966cbea990df8cf0593e1fb82a4c1a98a8
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 22 07:40:53 2013 -0500
Attempt to improve the operation trigger for updates on the storage node configuration.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
index c77e229..c2a7b46 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
@@ -64,6 +64,7 @@ import org.rhq.core.domain.measurement.MeasurementUnits;
import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.operation.ResourceOperationHistory;
import org.rhq.core.domain.operation.bean.GroupOperationSchedule;
+import org.rhq.core.domain.operation.bean.ResourceOperationSchedule;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
@@ -101,8 +102,8 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
private static final String RHQ_STORAGE_JMX_PORT_PROPERTY = "jmxPort";
private static final String RHQ_STORAGE_ADDRESS_PROPERTY = "host";
- private static final int OPERATION_QUERY_TIMEOUT = 1000;
- private static final int MAX_ITERATIONS = 5;
+ private static final int OPERATION_QUERY_TIMEOUT = 20000;
+ private static final int MAX_ITERATIONS = 6;
private static final String UPDATE_CONFIGURATION_OPERATION = "updateConfiguration";
private static final String RESTART_OPERATION = "restart";
@@ -636,8 +637,16 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
//scheduling the operation
long operationStartTime = System.currentTimeMillis();
- operationManager.scheduleResourceOperation(subject, storageNodeResource.getId(), operationToRun, 0, 0, 0, 0,
- parameters, "Run by StorageNodeManagerBean");
+
+ ResourceOperationSchedule newSchedule = new ResourceOperationSchedule();
+ newSchedule.setJobTrigger(JobTrigger.createNowTrigger());
+ newSchedule.setResource(storageNodeResource);
+ newSchedule.setOperationName(operationToRun);
+ newSchedule.setDescription("Run by StorageNodeManagerBean");
+ newSchedule.setParameters(parameters);
+
+ operationManager.scheduleResourceOperation(subject, newSchedule);
+ entityManager.flush();
//waiting for the operation result then return it
int iteration = 0;
commit a7e279884e1a7ee6c0782c1d5e79a27dcff26b76
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 22 07:39:55 2013 -0500
Implement the storage node operation for updating jvm options.
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
index 006dd26..4744e96 100644
--- a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
+++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
@@ -42,6 +42,7 @@ import org.mc4j.ems.connection.bean.operation.EmsOperation;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -102,7 +103,20 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
private OperationResult updateConfiguration(Configuration params) {
OperationResult result = new OperationResult("Configuration updated.");
- //TODO: implement updates to various sub-resources here
+
+ //update storage node jvm settings
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("minHeapSize", params.getSimpleValue("heapSize")));
+ config.put(new PropertySimple("maxHeapSize", params.getSimpleValue("heapSize")));
+ config.put(new PropertySimple("heapNewSize", params.getSimpleValue("heapNewSize")));
+ config.put(new PropertySimple("threadStackSize", params.getSimpleValue("threadStackSize")));
+
+ ConfigurationUpdateReport configurationUpdate = new ConfigurationUpdateReport(config);
+ this.updateResourceConfiguration(configurationUpdate);
+
+ if (!configurationUpdate.getStatus().equals(ConfigurationUpdateStatus.SUCCESS)) {
+ result.setErrorMessage(configurationUpdate.getErrorMessage());
+
return result;
}
commit 26a7f7f476e03367d52e9e229f2e583c789e7bec
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 22 07:38:15 2013 -0500
Add two more properties to the list of configurable properties for the storaga node. The new properties are heap new size and thread stack size.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeConfigurationComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeConfigurationComposite.java
index e2c64f9..32d8ab3 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeConfigurationComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeConfigurationComposite.java
@@ -33,6 +33,8 @@ public class StorageNodeConfigurationComposite implements Serializable {
private StorageNode storageNode;
private int jmxPort;
private String heapSize;
+ private String threadStackSize;
+ private String heapNewSize;
public StorageNodeConfigurationComposite() {
// GWT needs this
@@ -85,14 +87,44 @@ public class StorageNodeConfigurationComposite implements Serializable {
this.heapSize = heapSize;
}
+ /**
+ * @return the threadStackSize
+ */
+ public String getThreadStackSize() {
+ return threadStackSize;
+ }
+
+ /**
+ * @param threadStackSize the threadStackSize to set
+ */
+ public void setThreadStackSize(String threadStackSize) {
+ this.threadStackSize = threadStackSize;
+ }
+
+ /**
+ * @return the heapNewSize
+ */
+ public String getHeapNewSize() {
+ return heapNewSize;
+ }
+
+ /**
+ * @param heapNewSize the heapNewSize to set
+ */
+ public void setHeapNewSize(String heapNewSize) {
+ this.heapNewSize = heapNewSize;
+ }
+
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("storageNode.addresss=").append(storageNode.getAddress()).append(", ");
+ builder.append("jmxPort=").append(jmxPort).append(",");
builder.append("heapSize=").append(heapSize).append(", ");
- builder.append("jmxPort=").append(jmxPort).append("");
+ builder.append("heapNewSize=").append(heapSize).append(", ");
+ builder.append("threadStackSize=").append(threadStackSize).append("");
return builder.toString();
}
}
commit a0285ac83b5b673dab0582f9ff52baaa746fd8cd
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 22 07:37:10 2013 -0500
Update the set of calculated metrics for Cassandra to incorporate latest feedback. There are three metrics now: total system used space percentage, data file disk space used percentage, and free to data disk space ratio.
Also, update the alert definition for disk space to monitor all three metrics.
diff --git a/modules/enterprise/server/plugins/alertdef-rhq/src/main/java/org/rhq/enterprise/server/plugins/alertdef/AlertDefinitionServerPluginComponent.java b/modules/enterprise/server/plugins/alertdef-rhq/src/main/java/org/rhq/enterprise/server/plugins/alertdef/AlertDefinitionServerPluginComponent.java
index 8995ec0..37d10a8 100644
--- a/modules/enterprise/server/plugins/alertdef-rhq/src/main/java/org/rhq/enterprise/server/plugins/alertdef/AlertDefinitionServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/alertdef-rhq/src/main/java/org/rhq/enterprise/server/plugins/alertdef/AlertDefinitionServerPluginComponent.java
@@ -61,7 +61,9 @@ public class AlertDefinitionServerPluginComponent implements ServerPluginCompone
private final Log log = LogFactory.getLog(AlertDefinitionServerPluginComponent.class);
- private static final String PARTITION_DISK_USED_PERCENTAGE_METRIC_NAME = "Calculated.PartitionDiskUsedPercentage";
+ private static final String DATA_DISK_USED_PERCENTAGE_METRIC_NAME = "Calculated.DataDiskUsedPercentage";
+ private static final String TOTAL_DISK_USED_PERCENTAGE_METRIC_NAME = "Calculated.TotalDiskUsedPercentage";
+ private static final String FREE_DISK_TO_DATA_SIZE_RATIO_METRIC_NAME = "Calculated.FreeDiskToDataSizeRatio";
static private final List<InjectedTemplate> injectedTemplates;
static private final InjectedTemplate storageNodeHighHeapTemplate;
@@ -297,23 +299,42 @@ public class AlertDefinitionServerPluginComponent implements ServerPluginCompone
newTemplate.setRecoveryId(0);
newTemplate.setEnabled(true);
- AlertCondition ac = new AlertCondition();
- ac.setCategory(AlertConditionCategory.THRESHOLD);
- ac.setComparator(">");
- ac.setThreshold(0.5D);
+
+ AlertCondition dataDiskUsedAlertCondition = new AlertCondition();
+ dataDiskUsedAlertCondition.setCategory(AlertConditionCategory.THRESHOLD);
+ dataDiskUsedAlertCondition.setComparator(">");
+ dataDiskUsedAlertCondition.setThreshold(0.5D);
+
+ AlertCondition totalDiskUsedAlertCondition = new AlertCondition();
+ totalDiskUsedAlertCondition.setCategory(AlertConditionCategory.THRESHOLD);
+ totalDiskUsedAlertCondition.setComparator(">");
+ totalDiskUsedAlertCondition.setThreshold(0.75D);
+
+ AlertCondition freeSpaveDataRatioAlertCondition = new AlertCondition();
+ freeSpaveDataRatioAlertCondition.setCategory(AlertConditionCategory.THRESHOLD);
+ freeSpaveDataRatioAlertCondition.setComparator("<");
+ freeSpaveDataRatioAlertCondition.setThreshold(1.5D);
List<Integer> measurementDefinitionIds = new ArrayList<Integer>(1);
for (MeasurementDefinition d : resourceType.getMetricDefinitions()) {
- if (PARTITION_DISK_USED_PERCENTAGE_METRIC_NAME.equals(d.getName())) {
+ if (DATA_DISK_USED_PERCENTAGE_METRIC_NAME.equals(d.getName())) {
measurementDefinitionIds.add(d.getId());
- ac.setMeasurementDefinition(d);
- ac.setName(d.getDisplayName());
+ dataDiskUsedAlertCondition.setMeasurementDefinition(d);
+ dataDiskUsedAlertCondition.setName(d.getDisplayName());
+ } else if (TOTAL_DISK_USED_PERCENTAGE_METRIC_NAME.equals(d.getName())) {
+ measurementDefinitionIds.add(d.getId());
+ totalDiskUsedAlertCondition.setMeasurementDefinition(d);
+ totalDiskUsedAlertCondition.setName(d.getDisplayName());
+ } else if (FREE_DISK_TO_DATA_SIZE_RATIO_METRIC_NAME.equals(d.getName())) {
+ measurementDefinitionIds.add(d.getId());
+ freeSpaveDataRatioAlertCondition.setMeasurementDefinition(d);
+ freeSpaveDataRatioAlertCondition.setName(d.getDisplayName());
}
}
- assert null != ac.getMeasurementDefinition() : "Did not find expected measurement definition "
- + PARTITION_DISK_USED_PERCENTAGE_METRIC_NAME + " for "
- + resourceType;
- newTemplate.addCondition(ac);
+
+ newTemplate.addCondition(dataDiskUsedAlertCondition);
+ newTemplate.addCondition(totalDiskUsedAlertCondition);
+ newTemplate.addCondition(freeSpaveDataRatioAlertCondition);
AlertDampening dampener = new AlertDampening(AlertDampening.Category.PARTIAL_COUNT);
dampener.setPeriod(15);
diff --git a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/StorageServiceComponent.java b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/StorageServiceComponent.java
index e5a2283..76ce2b2 100644
--- a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/StorageServiceComponent.java
+++ b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/StorageServiceComponent.java
@@ -58,7 +58,9 @@ import org.rhq.plugins.jmx.JMXComponent;
public class StorageServiceComponent extends ComplexConfigurationResourceComponent {
private static final String OWNERSHIP_METRIC_NAME = "Ownership";
- private static final String PARTITION_DISK_USED_PERCENTAGE_METRIC_NAME = "Calculated.PartitionDiskUsedPercentage";
+ private static final String DATA_DISK_USED_PERCENTAGE_METRIC_NAME = "Calculated.DataDiskUsedPercentage";
+ private static final String TOTAL_DISK_USED_PERCENTAGE_METRIC_NAME = "Calculated.TotalDiskUsedPercentage";
+ private static final String FREE_DISK_TO_DATA_SIZE_RATIO_METRIC_NAME = "Calculated.FreeDiskToDataSizeRatio";
private static final String DATA_FILE_LOCATIONS_NAME = "AllDataFileLocations";
private static final String LOAD_NAME = "Load";
@@ -156,6 +158,22 @@ public class StorageServiceComponent extends ComplexConfigurationResourceCompone
@Override
protected void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests, EmsBean bean) {
super.getValues(report, requests, bean);
+
+ EmsAttribute loadAttribute = bean.getAttribute(LOAD_NAME);
+ Object loadValue = loadAttribute.refresh();
+
+ EmsAttribute dataFileLocationAttribute = bean.getAttribute(DATA_FILE_LOCATIONS_NAME);
+ Object dataFileLocationValue = dataFileLocationAttribute.refresh();
+
+ double load = 0;
+ if (loadValue != null && dataFileLocationValue != null && dataFileLocationValue instanceof String[]) {
+ //Please visit for details: https://issues.apache.org/jira/browse/CASSANDRA-2749
+ //The average usage of all partitions with the data will be reported.
+ //Cassandra selects the partition with most free space for SStable flush and compaction.
+ load = Double.parseDouble(loadValue.toString());
+ load = load / 1024d; //transform in MB
+ }
+
for (MeasurementScheduleRequest request : requests) {
if (OWNERSHIP_METRIC_NAME.equals(request.getName()) && host != null) {
EmsAttribute attribute = bean.getAttribute(OWNERSHIP_METRIC_NAME);
@@ -179,49 +197,53 @@ public class StorageServiceComponent extends ComplexConfigurationResourceCompone
report.addData(new MeasurementDataNumeric(request, value.doubleValue()));
}
break;
- } else if (PARTITION_DISK_USED_PERCENTAGE_METRIC_NAME.equals(request.getName())) {
-
-
- EmsAttribute loadAttribute = bean.getAttribute(LOAD_NAME);
- Object loadValue = loadAttribute.refresh();
-
- EmsAttribute dataFileLocationAttribute = bean.getAttribute(DATA_FILE_LOCATIONS_NAME);
- Object dataFileLocationValue = dataFileLocationAttribute.refresh();
-
- if (loadValue != null && dataFileLocationValue != null && dataFileLocationValue instanceof String[]) {
- //Please visit for details: https://issues.apache.org/jira/browse/CASSANDRA-2749
- //The average usage of all partitions with the data will be reported.
- //Cassandra selects the partition with most free space for SStable flush and compaction.
- double load = Double.parseDouble(loadValue.toString());
-
- report.addData(new MeasurementDataNumeric(request, getPartitionDiskUsedPercentage(load,
- (String[]) dataFileLocationValue)));
- }
+ } else if (DATA_DISK_USED_PERCENTAGE_METRIC_NAME.equals(request.getName())
+ || TOTAL_DISK_USED_PERCENTAGE_METRIC_NAME.equals(request.getName())
+ || FREE_DISK_TO_DATA_SIZE_RATIO_METRIC_NAME.equals(request.getName())) {
+ double metricValue = getDiskUsageMetric(request, load, (String[]) dataFileLocationValue);
+ report.addData(new MeasurementDataNumeric(request, metricValue));
}
}
}
- private double getPartitionDiskUsedPercentage(double dataSize, String[] paths) {
+ private double getDiskUsageMetric(MeasurementScheduleRequest request, double dataSize, String[] paths) {
List<String> visitedMountPoints = new ArrayList<String>();
long totalDiskSpace = 0;
+ long totalFreeDiskSpace = 0;
+ long totalUsedDiskSpace = 0;
for (String path : paths) {
try {
FileSystemInfo fileSystemInfo = this.getResourceContext().getSystemInformation().getFileSystem(path);
if (!visitedMountPoints.contains(fileSystemInfo.getMountPoint())) {
visitedMountPoints.add(fileSystemInfo.getMountPoint());
+
+ //contrary to Sigar documentation this values are reported in MB and not bytes
totalDiskSpace += fileSystemInfo.getFileSystemUsage().getTotal();
+ totalFreeDiskSpace += fileSystemInfo.getFileSystemUsage().getFree();
+ totalUsedDiskSpace += fileSystemInfo.getFileSystemUsage().getUsed();
}
} catch (Exception e) {
log.error("Unable to determine file system usage information for data file location " + path, e);
}
}
+ double metricValue = 0;
+
+
if (totalDiskSpace != 0) {
- double rawPercentage = dataSize / ((double) totalDiskSpace);
- return Math.round(rawPercentage * 100.0) / 100.0;
+ double rawPercentage = 0;
+ if (DATA_DISK_USED_PERCENTAGE_METRIC_NAME.equals(request.getName())) {
+ rawPercentage = dataSize / ((double) totalDiskSpace);
+ } else if (TOTAL_DISK_USED_PERCENTAGE_METRIC_NAME.equals(request.getName())) {
+ rawPercentage = ((double) totalUsedDiskSpace) / ((double) totalDiskSpace);
+ } else if (FREE_DISK_TO_DATA_SIZE_RATIO_METRIC_NAME.equals(request.getName())) {
+ rawPercentage = ((double) totalFreeDiskSpace) / (double) dataSize;
+ }
+
+ metricValue = Math.round(rawPercentage * 100d) / 100d;
}
- return 0;
+ return metricValue;
}
}
diff --git a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
index a1b3412..5bbebed 100644
--- a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
@@ -186,9 +186,11 @@
</parameters>
</operation>
+ <metric property="Calculated.DataDiskUsedPercentage" displayName="Data File Disk Used Percentage" dataType="measurement" units="percentage" displayType="summary" description="Percentage of disk space used by Cassandra data files. The aggregate accross all the partitions will be reported if multiple data locations are specified. This is a calculated metric derived from system and Cassandra runtime information."/>
+ <metric property="Calculated.TotalDiskUsedPercentage" displayName="Total Disk Used Percentage" dataType="measurement" units="percentage" displayType="summary" description="Percentage of total disk space used. The metric acounts overall disk usage (including system files), not just disk space used by Cassandra. The aggregate accross all the partitions will be reported if multiple data locations are specified. This is a calculated metric derived from system and Cassandra runtime information."/>
+ <metric property="Calculated.FreeDiskToDataSizeRatio" displayName="Free Disk to Data Size Ratio" dataType="measurement" displayType="summary" description="Ratio of (Amount of Free Disk)/(Data File Size). A value below 1 is not recommended since a compaction or repair process could double the amount of disk space used by data files. The aggregate accross all the partitions will be reported if multiple data locations are specified. This is a calculated metric derived from system and Cassandra runtime information."/>
+
<metric property="CurrentGenerationNumber" dataType="trait" displayType="summary" description="Current generation number"/>
- <metric property="Calculated.PartitionDiskUsedPercentage" displayName="Data File Disk Used Percentage" dataType="measurement" units="percentage" displayType="summary" description="Percentage of disk space used by the data files. If multiple data locations are specified then this will report
- the average utilization accross all the partitions that contain data files."/>
<metric property="ExceptionCount" measurementType="trendsup" dataType="measurement" displayType="summary" description="Exception Count"/>
<metric property="Initialized" dataType="trait" displayType="summary" description="Initialized"/>
<metric property="Joined" dataType="trait" displayType="summary" description="Joined"/>
commit 82d0075ed860dcc2f2aed57191e4fa64806caa97
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Mon Jul 22 14:39:39 2013 +0200
Entities < and > in the plugin descriptor were interpreted as HTML in the ConfigurationEditor and the content between them wasn't there.
diff --git a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
index e6bc1da..a1b3412 100644
--- a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
@@ -159,7 +159,7 @@
<operation name="takeSnapshot"
description="Takes a snapshot of all keyspaces. A snapshot first flushes all in-memory writes to disk and then creates a hard
link of each SSTable file for each keyspace. Note that a column family can have multiple
- SSTables on disk. By default snapshots are stored in the <cassandra_data_dir>/<keyspace_name>/<column_family_name>/snapshots
+ SSTables on disk. By default snapshots are stored in the [cassandra_data_dir]/[keyspace_name]/[column_family_name]/snapshots
directory. On Linux/UNIX systems cassandra_data_dir defaults to /var/lib/cassandra/data">
<parameters>
<c:simple-property name="snapshotName" required="false" type="string" displayName="Snapshot Name"
commit 1a520b6c33dd2bde09d58ea7e51d04c83622f481
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 22 07:17:20 2013 -0400
comment out exporting test ear
Might be nice to enable exporting test ear with a system property where the
location is also configurable.
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
index 2fd8624..8010c2b 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
@@ -413,7 +413,8 @@ public abstract class AbstractEJB3Test extends Arquillian {
//System.out.println("** The Deployment EAR: " + testEar.toString(true) + "\n");
// Save the test EAR to a zip file for inspection (set file explicitly)
- exportZip(testEar, new File("/Users/jsanda/tmp/test-ear.ear"));
+ //String tmpDir = System.getProperty("java.io.tmpdir");
+ //exportZip(testEar, new File(tmpDir, "test.ear"));
return testEar;
}
commit df8669222aa3146b71b3252166af6bdd387806cd
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jul 22 10:38:44 2013 +0200
Add more units.
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
index 0ae4011..150b9e0 100644
--- a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, and
+ * Copyright 2009-2013, Red Hat, Inc. and/or its affiliates, and
* individual contributors as indicated by the @author tags. See the
* copyright.txt file in the distribution for a full listing of
* individual contributors.
@@ -26,10 +26,18 @@ package org.rhq.helpers.pluginAnnotations.agent;
* Metric Units.
*
* @author Galder Zamarreño
+ * @author Heiko W. Rupp
+ * See also org.rhq.core.domain.measurement.MeasurementUnits
* @since 4.0
*/
+@SuppressWarnings("unused")
public enum Units {
- NONE, MILLISECONDS, SECONDS, PERCENTAGE;
+ NONE, PERCENTAGE,
+ BYTES, KILOBYTES, MEGABYTES, GIGABYTES, TERABYTES, PETABYTES,
+ BITS, KILOBITS, MEGABITS, GIGABITS, TERABITS, PETABITS,
+ EPOCH_MILLISECONDS, EPOCH_SECONDS,
+ JIFFYS, NANOSECONDS, MICROSECONDS, MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS,
+ CELSIUS, KELVIN, FAHRENHEIT;
@Override
public String toString() {
commit 14edae37060b25ebcfed621deef0281c72b1cea2
Author: John Sanda <jsanda(a)redhat.com>
Date: Sun Jul 21 21:22:43 2013 -0400
adding resource operation to update internode auth conf file
The operation updates the file on disk and then invokes the JMX operation to
have the authenticator reload the configuration so that the changes can be
picked up without having to restart the node.
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
index 380da65..006dd26 100644
--- a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
+++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
@@ -26,7 +26,12 @@
package org.rhq.plugins.storage;
import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -36,6 +41,7 @@ import org.mc4j.ems.connection.bean.attribute.EmsAttribute;
import org.mc4j.ems.connection.bean.operation.EmsOperation;
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.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -43,7 +49,10 @@ import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.core.util.StringUtil;
import org.rhq.core.util.exception.ThrowableUtil;
+import org.rhq.core.util.file.FileUtil;
+import org.rhq.core.util.stream.StreamUtil;
import org.rhq.plugins.cassandra.CassandraNodeComponent;
import org.rhq.plugins.cassandra.util.KeyspaceService;
@@ -84,6 +93,8 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
return readRepair();
} else if (name.equals("updateConfiguration")) {
return updateConfiguration(parameters);
+ } else if (name.equals("updateKnownNodes")) {
+ return updateKnownNodes(parameters);
} else {
return super.invokeOperation(name, parameters);
}
@@ -95,6 +106,73 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
return result;
}
+ private OperationResult updateKnownNodes(Configuration params) {
+ OperationResult result = new OperationResult();
+
+ PropertyList propertyList = params.getList("ipAddresses");
+ Set<String> ipAddresses = new HashSet<String>();
+
+ for (Property property : propertyList.getList()) {
+ PropertySimple propertySimple = (PropertySimple) property;
+ ipAddresses.add(propertySimple.getStringValue());
+ }
+
+ log.info("Updating known nodes to " + ipAddresses);
+
+ File confDir = new File(getBasedir(), "conf");
+ File authFile = new File(confDir, "rhq-storage-auth.conf");
+ File authBackupFile = new File(confDir, "." + authFile.getName() + ".bak");
+
+ if (authBackupFile.exists()) {
+ if (log.isDebugEnabled()) {
+ log.debug(authBackupFile + " already exists. Deleting it now in preparation of creating new backup " +
+ "for " + authFile.getName());
+ }
+ if (!authBackupFile.delete()) {
+ String msg = "Failed to delete backup file " + authBackupFile + ". The operation will abort " +
+ "since " + authFile + " cannot reliably be backed up before making changes. Please delete " +
+ authBackupFile + " manually and reschedule the operation once the file has been removed.";
+ log.error(msg);
+ result.setErrorMessage(msg);
+
+ return result;
+ }
+ }
+
+ try {
+ FileUtil.copyFile(authFile, authBackupFile);
+ } catch (IOException e) {
+ String msg = "Failed to backup " + authFile + " prior to making updates. The operation will abort due " +
+ "to unexpected error";
+ log.error(msg, e);
+ result.setErrorMessage(msg + ": " + ThrowableUtil.getRootMessage(e));
+ return result;
+ }
+
+ try {
+ StreamUtil.copy(new StringReader(StringUtil.collectionToString(ipAddresses, "\n")),
+ new FileWriter(authFile), true);
+ } catch (IOException e) {
+ log.error("An error occurred while updating " + authFile, e);
+ try {
+ FileUtil.copyFile(authBackupFile, authFile);
+ } catch (IOException e1) {
+ log.error("Failed to revert backup of " + authFile, e1);
+ }
+ result.setErrorMessage("There was an unexpected error while updating " + authFile + ". Make sure that " +
+ "it matches " + authBackupFile + " and then reschedule the operation.");
+ return result;
+ }
+
+ EmsBean authBean = getEmsConnection().getBean("org.rhq.cassandra.auth:type=RhqInternodeAuthenticator");
+ EmsOperation emsOperation = authBean.getOperation("reloadConfiguration");
+ emsOperation.invoke();
+
+ result.setSimpleResult("Successfully updated the set of known nodes.");
+
+ return result;
+ }
+
private OperationResult nodeAdded(Configuration params) {
boolean runRepair = params.getSimple("runRepair").getBooleanValue();
boolean updateSeedsList = params.getSimple("updateSeedsList").getBooleanValue();
diff --git a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
index 6ed31b7..8156d02 100644
--- a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
@@ -93,6 +93,14 @@
</results>
</operation>
+ <operation name="updateKnownNodes">
+ <parameters>
+ <c:list-property name="ipAddresses">
+ <c:simple-property name="ipAddress"/>
+ </c:list-property>
+ </parameters>
+ </operation>
+
<operation name="prepareForUpgrade" description="Prepares the storage node for upgrade (this operation consists of following steps: 1) turning off the RPC server, 2) turning off the gossiper, 3) taking the snapshot (backuping the data), 4) invoking the drain operation">
<parameters>
<c:simple-property name="snapshotName" required="false" type="string" displayName="Snapshot Name"
commit 38777a49e6b5c5f92c54c3f41511f5f691d2a548
Author: John Sanda <jsanda(a)redhat.com>
Date: Sun Jul 21 21:21:45 2013 -0400
update cassandra deployer itest
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-jvm.properties b/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-jvm.properties
index a90d23c..774a831 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-jvm.properties
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-jvm.properties
@@ -17,9 +17,9 @@ heap_dump_dir=""
thread_stack_size=-Xss180k
-java_agent=""
# Enable jamm when running on Java 6 patch version 23 or higher.
#java_agent="-javaagent:$CASSANDRA_HOME/lib/jamm-0.2.5.jar"
+java_agent=-javaagent:$CASSANDRA_HOME/lib/jamm-0.2.5.jar
# GC tuning options
#
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra.yaml b/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra.yaml
index 15d08f2..b9e490a 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra.yaml
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra.yaml
@@ -323,7 +323,7 @@ listen_address: localhost
# Internode authentication backend, implementing IInternodeAuthenticator;
# used to allow/disallow connections from peer nodes.
-# internode_authenticator: org.apache.cassandra.auth.AllowAllInternodeAuthenticator
+internode_authenticator: org.rhq.cassandra.auth.RhqInternodeAuthenticator
# Whether to start the native transport server.
# Currently, only the thrift server is started by default because the native
commit 1750170844f6a68b11256ba001fe6cffb53439f6
Author: John Sanda <jsanda(a)redhat.com>
Date: Sun Jul 21 21:14:48 2013 -0400
temporarily disable the quartz job that is kicked off when a new node is added
I need to disable the job while working on the internode authentication stuff.
If the maintenance operations run on the nodes, the cluster can actually get
into a bad state because the nodes' authentication conf files have not been
updated which means the new node is not actually part of the cluster.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
index 3f1ec69..c77e229 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
@@ -170,7 +170,7 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
entityManager.persist(storageNode);
- scheduleQuartzJob(storageNodes.size());
+// scheduleQuartzJob(storageNodes.size());
}
}
}
commit fe6da9b5511a3b4c97c2421079db04020c33c27f
Author: John Sanda <jsanda(a)redhat.com>
Date: Sun Jul 21 21:11:43 2013 -0400
pre-configure internode auth conf file
From testing I have done thus far it appears that a storage node should have
its own IP address included in the internode authentication config file. The
storage installer updates the auth file to include the node's address as well
as and seeds.
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
index edf1430..c8bb2ef 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
@@ -34,6 +34,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
+import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -109,6 +110,13 @@ public class CassandraClusterManager {
List<StorageNode> nodes = new ArrayList<StorageNode>(deploymentOptions.getNumNodes());
String seeds = collectionToString(calculateLocalIPAddresses(deploymentOptions.getNumNodes()));
+ Set<InetAddress> ipAddresses = null;
+
+ try {
+ ipAddresses = getClusterIPAddresses();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to get cluster IP addresses", e);
+ }
for (int i = 0; i < deploymentOptions.getNumNodes(); ++i) {
File basedir = new File(deploymentOptions.getClusterDir(), "node" + i);
@@ -141,7 +149,7 @@ public class CassandraClusterManager {
storageNode.setCqlPort(nodeOptions.getNativeTransportPort());
nodes.add(storageNode);
- updateStorageAuthConf(basedir);
+ deployer.updateStorageAuthConf(ipAddresses);
installedNodeDirs.add(basedir);
} catch (Exception e) {
@@ -193,6 +201,15 @@ public class CassandraClusterManager {
return i <= seedsArray.length ? seedsArray[i - 1] : ("127.0.0." + i);
}
+ private Set<InetAddress> getClusterIPAddresses() throws IOException {
+ Set<InetAddress> ipAddresses = new HashSet<InetAddress>();
+ for (String address : calculateLocalIPAddresses(deploymentOptions.getNumNodes())) {
+ ipAddresses.add(InetAddress.getByName(address));
+ }
+
+ return ipAddresses;
+ }
+
private List<StorageNode> calculateNodes() {
List<StorageNode> nodes = new ArrayList<StorageNode>(deploymentOptions.getNumNodes());
for (int i = 0; i < deploymentOptions.getNumNodes(); ++i) {
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
index b01ebe9..6547043 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
@@ -30,13 +30,18 @@ import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
+import java.io.StringReader;
+import java.net.InetAddress;
+import java.util.HashSet;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rhq.core.util.PropertiesFileUpdate;
+import org.rhq.core.util.StringUtil;
import org.rhq.core.util.TokenReplacingReader;
import org.rhq.core.util.ZipUtil;
import org.rhq.core.util.stream.StreamUtil;
@@ -171,4 +176,22 @@ public class Deployer {
}
}
+ public void updateStorageAuthConf(Set<InetAddress> ipAddresses) {
+ File confDir = new File(deploymentOptions.getBasedir(), "conf");
+ File authFile = new File(confDir, "rhq-storage-auth.conf");
+
+ Set<String> addresses = new HashSet<String>(ipAddresses.size());
+ for (InetAddress ipAddress : ipAddresses) {
+ addresses.add(ipAddress.getHostAddress());
+ }
+
+ try {
+ authFile.delete();
+ StreamUtil.copy(new StringReader(StringUtil.collectionToString(addresses, "\n")),
+ new FileWriter(authFile), true);
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to update " + authFile);
+ }
+ }
+
}
diff --git a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
index 5c5ac4e..113d66b 100644
--- a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
+++ b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
@@ -34,10 +34,12 @@ import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
@@ -386,6 +388,7 @@ public class StorageInstaller {
deployer.unzipDistro();
deployer.applyConfigChanges();
deployer.updateFilePerms();
+ deployer.updateStorageAuthConf(getAddresses(hostname, seeds));
log.info("Finished installing RHQ Storage Node.");
@@ -499,6 +502,19 @@ public class StorageInstaller {
return dir;
}
+ private Set<InetAddress> getAddresses(String hostname, String seeds) throws IOException {
+ Set<InetAddress> addresses = new HashSet<InetAddress>();
+ addresses.add(InetAddress.getByName(hostname));
+
+ if (!StringUtil.isEmpty(seeds)) {
+ for (String seed : seeds.split(",")) {
+ addresses.add(InetAddress.getByName(seed));
+ }
+ }
+
+ return addresses;
+ }
+
private PropertiesFileUpdate getServerProperties() {
String sysprop = System.getProperty("rhq.server.properties-file");
if (sysprop == null) {
commit b63c38cb0c19cd062d14c5e025164021f1e946cc
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat Jul 20 09:53:10 2013 -0400
turn on internode authentication
This enabled internode authentication in cassandra.yaml and the cassandra-auth
module is packaged with our Cassandra distro. The authentication config file is
automatically updated for integrated tests. There is still work to be done for
multi-node dev-container (and production) deployments.
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml b/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml
index 2bde394..c12c567 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml
@@ -113,6 +113,11 @@
<artifactId>snappy-java</artifactId>
<version>${cassandra.snappy.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-cassandra-auth</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<executions>
<execution>
@@ -166,12 +171,15 @@
<delete file="${cassandra.dir}/lib/snappy-java-1.0.4.1.jar"/>
<copy file="${settings.localRepository}/org/xerial/snappy/snappy-java/${cassandra.snappy.version}/snappy-java-${cassandra.snappy.version}.jar"
todir="${cassandra.dir}/lib"/>
+ <copy file="${settings.localRepository}/org/rhq/rhq-cassandra-auth/${project.version}/rhq-cassandra-auth-${project.version}.jar"
+ todir="${cassandra.dir}/lib"/>
<move file="${project.build.outputDirectory}/cassandra/conf" todir="${cassandra.dir}"/>
<delete file="${cassandra.dir}/bin/cassandra"/>
<move file="${project.build.outputDirectory}/cassandra/bin/cassandra" todir="${cassandra.dir}/bin"/>
<delete dir="${project.build.outputDirectory}/cassandra"/>
<delete dir="${cassandra.dir}/javadoc"/>
<delete file="${cassandra.dir}/conf/cassandra-env.sh"/>
+ <touch file="${cassandra.dir}/conf/rhq-storage-auth.conf"/>
<zip basedir="${cassandra.dir}" destfile="${cassandra.distro.zip}"/>
<delete dir="${cassandra.dir}"/>
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/cassandra-jvm.properties b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/cassandra-jvm.properties
index 612c65e..1faee9d 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/cassandra-jvm.properties
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/cassandra-jvm.properties
@@ -17,9 +17,9 @@ heap_dump_dir=""
thread_stack_size="-Xss180k"
-java_agent=""
# Enable jamm when running on Java 6 patch version 23 or higher.
#java_agent="-javaagent:$CASSANDRA_HOME/lib/jamm-0.2.5.jar"
+java_agent=
# GC tuning options
#
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml
index 298db9d..da09e92 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml
@@ -323,7 +323,7 @@ listen_address: ${rhq.cassandra.listen.address}
# Internode authentication backend, implementing IInternodeAuthenticator;
# used to allow/disallow connections from peer nodes.
-# internode_authenticator: org.apache.cassandra.auth.AllowAllInternodeAuthenticator
+internode_authenticator: org.rhq.cassandra.auth.RhqInternodeAuthenticator
# Whether to start the native transport server.
# Currently, only the thrift server is started by default because the native
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
index 338ef3a..edf1430 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
@@ -30,7 +30,9 @@ import static org.rhq.core.util.StringUtil.collectionToString;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileReader;
+import java.io.FileWriter;
import java.io.IOException;
+import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
@@ -50,6 +52,7 @@ import org.rhq.core.system.ProcessExecution;
import org.rhq.core.system.ProcessExecutionResults;
import org.rhq.core.system.SystemInfo;
import org.rhq.core.system.SystemInfoFactory;
+import org.rhq.core.util.StringUtil;
import org.rhq.core.util.file.FileUtil;
import org.rhq.core.util.stream.StreamUtil;
@@ -138,6 +141,8 @@ public class CassandraClusterManager {
storageNode.setCqlPort(nodeOptions.getNativeTransportPort());
nodes.add(storageNode);
+ updateStorageAuthConf(basedir);
+
installedNodeDirs.add(basedir);
} catch (Exception e) {
log.error("Failed to install node at " + basedir);
@@ -152,6 +157,21 @@ public class CassandraClusterManager {
return nodes;
}
+ private void updateStorageAuthConf(File basedir) {
+ File confDir = new File(basedir, "conf");
+ File authFile = new File(confDir, "rhq-storage-auth.conf");
+ authFile.delete();
+
+ Set<String> addresses = calculateLocalIPAddresses(deploymentOptions.getNumNodes());
+
+ try {
+ StreamUtil.copy(new StringReader(StringUtil.collectionToString(addresses, "\n")),
+ new FileWriter(authFile), true);
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to update " + authFile);
+ }
+ }
+
private Set<String> calculateLocalIPAddresses(int numNodes) {
Set<String> addresses = new HashSet<String>();
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
index b222c82..b01ebe9 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
@@ -160,11 +160,6 @@ public class Deployer {
return Integer.parseInt(javaVersion.substring(startIndex + 1, javaVersion.length()));
}
- private boolean isLaterThanJava1_6() {
- String javaVersion = System.getProperty("java.version");
- return javaVersion.compareTo("1.6.0") > 0;
- }
-
public void updateFilePerms() {
File deployDir = new File(deploymentOptions.getBasedir());
File binDir = new File(deployDir, "bin");
commit 890a378fc11b04f3e7af64babfbfd1a7e306b7cd
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat Jul 20 07:56:14 2013 -0400
initial commit for cassandra-auth module
This is the first cut at our IInternodeAuthenticator. It loads IP addresses
from a config file. There is a JMX operation to reload the config file that can
be used after the config file is updated.
diff --git a/modules/common/cassandra-auth/pom.xml b/modules/common/cassandra-auth/pom.xml
new file mode 100644
index 0000000..c53c752
--- /dev/null
+++ b/modules/common/cassandra-auth/pom.xml
@@ -0,0 +1,27 @@
+<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-common-parent</artifactId>
+ <version>4.9.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>rhq-cassandra-auth</artifactId>
+ <name>RHQ Cassandra Authentication</name>
+
+ <properties>
+ <moduleName>org.rhq.${project.artifactId}</moduleName>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cassandra</groupId>
+ <artifactId>cassandra-all</artifactId>
+ <version>${cassandra.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/modules/common/cassandra-auth/src/main/java/org/rhq/cassandra/auth/RhqInternodeAuthenticator.java b/modules/common/cassandra-auth/src/main/java/org/rhq/cassandra/auth/RhqInternodeAuthenticator.java
new file mode 100644
index 0000000..56980f1
--- /dev/null
+++ b/modules/common/cassandra-auth/src/main/java/org/rhq/cassandra/auth/RhqInternodeAuthenticator.java
@@ -0,0 +1,78 @@
+package org.rhq.cassandra.auth;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.net.InetAddress;
+import java.net.URISyntaxException;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.cassandra.auth.IInternodeAuthenticator;
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+/**
+ * @author John Sanda
+ */
+public class RhqInternodeAuthenticator implements IInternodeAuthenticator, RhqInternodeAuthenticatorMBean {
+
+ private final String MBEAN_NAME = "org.rhq.cassandra.auth:type=" + RhqInternodeAuthenticator.class.getSimpleName();
+
+ private final String CONF_FILE = "rhq-storage-auth.conf";
+
+ private File authConfFile;
+
+ private Set<InetAddress> addresses = new HashSet<InetAddress>();
+
+ public RhqInternodeAuthenticator() {
+ try {
+ authConfFile = new File(getClass().getResource("/" + CONF_FILE).toURI());
+ if (!authConfFile.exists()) {
+ throw new RuntimeException(authConfFile + " does not exist");
+ }
+
+ reloadConfiguration();
+ } catch (URISyntaxException e) {
+ throw new RuntimeException("Failed to load " + CONF_FILE, e);
+ }
+
+ try {
+ MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+ ObjectName nameObj = new ObjectName(MBEAN_NAME);
+ mbs.registerMBean(this, nameObj);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to register MBean " + MBEAN_NAME, e);
+ }
+ }
+
+ @Override
+ public boolean authenticate(InetAddress address, int port) {
+ return addresses.contains(address);
+ }
+
+ @Override
+ public void reloadConfiguration() {
+ try {
+ addresses.clear();
+
+ BufferedReader reader = new BufferedReader(new FileReader(authConfFile));
+ String line = reader.readLine();
+
+ while (line != null) {
+ addresses.add(InetAddress.getByName(line));
+ line = reader.readLine();
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load addresses from " + authConfFile, e);
+ }
+ }
+
+ @Override
+ public void validateConfiguration() throws ConfigurationException {
+ }
+}
diff --git a/modules/common/cassandra-auth/src/main/java/org/rhq/cassandra/auth/RhqInternodeAuthenticatorMBean.java b/modules/common/cassandra-auth/src/main/java/org/rhq/cassandra/auth/RhqInternodeAuthenticatorMBean.java
new file mode 100644
index 0000000..5e20389
--- /dev/null
+++ b/modules/common/cassandra-auth/src/main/java/org/rhq/cassandra/auth/RhqInternodeAuthenticatorMBean.java
@@ -0,0 +1,10 @@
+package org.rhq.cassandra.auth;
+
+/**
+ * @author John Sanda
+ */
+public interface RhqInternodeAuthenticatorMBean {
+
+ public void reloadConfiguration();
+
+}
diff --git a/modules/common/pom.xml b/modules/common/pom.xml
index bcbf862..7d12500 100644
--- a/modules/common/pom.xml
+++ b/modules/common/pom.xml
@@ -30,6 +30,7 @@
<module>ant-bundle</module>
<module>drift</module>
<module>jboss-as-dmr-client</module>
+ <module>cassandra-auth</module>
<module>cassandra-util</module>
<module>cassandra-jmx</module>
<module>cassandra-schema</module>
commit 8cf740355dfab9832b904984aaba4e52bf759951
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 19 22:18:23 2013 -0400
add logic to enable jamm java agent, which mirrors logic in cassandra-env.sh
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
index 1e31e14..b222c82 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
@@ -125,6 +125,13 @@ public class Deployer {
properties.setProperty("thread_stack_size", "-Xss" + deploymentOptions.getStackSize());
properties.setProperty("jmx_port", deploymentOptions.getJmxPort().toString());
+ String javaVersion = System.getProperty("java.version");
+ // The check here is taken right from cassandra-env.sh
+ if ((!isOpenJDK() || javaVersion.compareTo("1.6.0") > 0) ||
+ (javaVersion.equals("1.6.0") && getJavaPatchVersion() > 23)) {
+ properties.put("java_agent", "-javaagent:$CASSANDRA_HOME/lib/jamm-0.2.5.jar");
+ }
+
propertiesUpdater.update(properties);
} catch (IOException e) {
log.error("An error occurred while updating " + jvmPropsFile, e);
@@ -132,6 +139,32 @@ public class Deployer {
}
}
+ private boolean isOpenJDK() {
+ String javaVMName = System.getProperty("java.vm.name");
+ return javaVMName.startsWith("OpenJDK");
+ }
+
+ private boolean isJava1_6() {
+ String javaVersion = System.getProperty("java.version");
+ return javaVersion.startsWith("1.6.0");
+ }
+
+ private int getJavaPatchVersion() {
+ String javaVersion = System.getProperty("java.version");
+ int startIndex = javaVersion.indexOf('_');
+
+ if (startIndex == -1) {
+ return 0;
+ }
+
+ return Integer.parseInt(javaVersion.substring(startIndex + 1, javaVersion.length()));
+ }
+
+ private boolean isLaterThanJava1_6() {
+ String javaVersion = System.getProperty("java.version");
+ return javaVersion.compareTo("1.6.0") > 0;
+ }
+
public void updateFilePerms() {
File deployDir = new File(deploymentOptions.getBasedir());
File binDir = new File(deployDir, "bin");
commit 0517e453381aec1d30b6aaa62bec63a322dfa350
Author: Larry O'Leary <loleary(a)redhat.com>
Date: Fri Jul 19 19:05:25 2013 -0500
Updated TestLdapSettings to include changes/fixes introduced from the following BZs:
Bug 707047 - LDAP Group Member search doesn't escape special characters
Bug 981015 - LDAP auth fails if user's DN contains a backslash
Also includes a fix in where the user auth test would fail to switch back to the directory bind account and result in ACL failures on the following group lookup steps.
diff --git a/etc/dev-utils/TestLdapSettings.java b/etc/dev-utils/TestLdapSettings.java
index 4df79dc..2e29b3d 100644
--- a/etc/dev-utils/TestLdapSettings.java
+++ b/etc/dev-utils/TestLdapSettings.java
@@ -10,12 +10,14 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.PrintWriter;
import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import javax.naming.CompositeName;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.directory.Attribute;
@@ -257,7 +259,17 @@ public class TestLdapSettings extends JFrame {
SearchResult si = (SearchResult) answer.next();
// Construct the UserDN
- userDN = si.getName() + "," + baseDNs[x];
+ userDN = null;
+
+ try {
+ userDN = si.getNameInNamespace();
+ } catch (UnsupportedOperationException use) {
+ userDN = new CompositeName(si.getName()).get(0);
+ if (si.isRelative()) {
+ userDN += "," + baseDNs[x];
+ }
+ }
+
msg = "STEP-2:PASS: The test user '"
+ testUserName
+ "' was succesfully located, and the following userDN will be used in authorization check:\n";
@@ -288,6 +300,21 @@ public class TestLdapSettings extends JFrame {
log(msg);
proceed=false;
}
+ try {
+ ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, bindUserName);
+ ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, bindPassword);
+ ctx.addToEnvironment(Context.SECURITY_AUTHENTICATION, "simple");
+ ctx.reconnect(null);
+ } catch (Exception ex) {
+ msg = "STEP-2:WARN: There was an error when switching back to the bind user '"
+ + bindUserName + "'\n";
+ msg += ex.getMessage();
+ if(enableVerboseDebugging.isSelected()){
+ msg = appendStacktraceToMsg(msg, ex);
+ }
+ log(msg);
+ }
+
}
// with authentication completed, now check authorization.
// validate filter components to list all available groups
@@ -433,7 +460,7 @@ public class TestLdapSettings extends JFrame {
Set<Map<String, String>> ret = new HashSet<Map<String, String>>();
String filter = String.format("(&(%s)(%s=%s))",
groupSearchFilter, groupMemberFilter,
- userDN);
+ LDAPStringUtil.encodeForFilter(userDN));
msg = "STEP-4:TESTING: about to do ldap search with filter \n'"
+ filter
+ "'\n to locate groups that test user IS authorized to access.";
@@ -638,3 +665,74 @@ public class TestLdapSettings extends JFrame {
return constraints;
}
}
+
+class LDAPStringUtil {
+
+ /**
+ * <p>Encode a string so that it can be used in an LDAP search filter.</p>
+ *
+ * <p>The following table shows the characters that are encoded and their
+ * encoded version.</p>
+ *
+ * <table>
+ * <tr><th align="center">Character</th><th>Encoded As</th></tr>
+ * <tr><td align="center">*</td><td>\2a</td></tr>
+ * <tr><td align="center">(</td><td>\28</td></tr>
+ * <tr><td align="center">)</td><td>\29</td></tr>
+ * <tr><td align="center">\</td><td>\5c</td></tr>
+ * <tr><td align="center"><code>null</code></td><td>\00</td></tr>
+ * </table>
+ *
+ * <p>In addition to encoding the above characters, any non-ASCII character
+ * (any character with a hex value greater then <code>0x7f</code>) is also
+ * encoded and rewritten as a UTF-8 character or sequence of characters in
+ * hex notation.</p>
+ *
+ * @param filterString a string that is to be encoded
+ * @return the encoded version of <code>filterString</code> suitable for use
+ * in a LDAP search filter
+ * @see <a href="http://tools.ietf.org/html/rfc4515">RFC 4515</a>
+ */
+ public static String encodeForFilter(final String filterString) {
+ if (filterString != null && filterString.length() > 0) {
+ StringBuilder encString = new StringBuilder(filterString.length());
+ for (int i = 0; i < filterString.length(); i++) {
+ char ch = filterString.charAt(i);
+ switch (ch) {
+ case '*': // encode a wildcard * character
+ encString.append("\\2a");
+ break;
+ case '(': // encode a open parenthesis ( character
+ encString.append("\\28");
+ break;
+ case ')': // encode a close parenthesis ) character
+ encString.append("\\29");
+ break;
+ case '\\': // encode a backslash \ character
+ encString.append("\\5c");
+ break;
+ case '\u0000': // encode a null character
+ encString.append("\\00");
+ break;
+ default:
+ if (ch <= 0x7f) { // an ASCII character
+ encString.append(ch);
+ } else if (ch >= 0x80) { // encode to UTF-8
+ try {
+ byte[] utf8bytes = String.valueOf(ch).getBytes("UTF8");
+ for (byte b : utf8bytes) {
+ encString.append(String.format("\\%02x", b));
+ }
+ } catch (UnsupportedEncodingException e) {
+ // ignore
+ }
+ }
+ }
+ }
+ return encString.toString();
+ }
+ return filterString;
+ }
+
+}
+
commit 5d3b55ed04d5da4eab12704c8391872cd93421ad
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 19 15:35:34 2013 -0400
forgot to include new test resources in previous commit
diff --git a/modules/common/cassandra-installer/src/test/resources/rhq48/storage/conf/cassandra-env.sh b/modules/common/cassandra-installer/src/test/resources/rhq48/storage/conf/cassandra-env.sh
new file mode 100644
index 0000000..cd415b3
--- /dev/null
+++ b/modules/common/cassandra-installer/src/test/resources/rhq48/storage/conf/cassandra-env.sh
@@ -0,0 +1,247 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+calculate_heap_sizes()
+{
+ case "`uname`" in
+ Linux)
+ system_memory_in_mb=`free -m | awk '/Mem:/ {print $2}'`
+ system_cpu_cores=`egrep -c 'processor([[:space:]]+):.*' /proc/cpuinfo`
+ ;;
+ FreeBSD)
+ system_memory_in_bytes=`sysctl hw.physmem | awk '{print $2}'`
+ system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024`
+ system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'`
+ ;;
+ SunOS)
+ system_memory_in_mb=`prtconf | awk '/Memory size:/ {print $3}'`
+ system_cpu_cores=`psrinfo | wc -l`
+ ;;
+ Darwin)
+ system_memory_in_bytes=`sysctl hw.memsize | awk '{print $2}'`
+ system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024`
+ system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'`
+ ;;
+ *)
+ # assume reasonable defaults for e.g. a modern desktop or
+ # cheap server
+ system_memory_in_mb="2048"
+ system_cpu_cores="2"
+ ;;
+ esac
+
+ # some systems like the raspberry pi don't report cores, use at least 1
+ if [ "$system_cpu_cores" -lt "1" ]
+ then
+ system_cpu_cores="1"
+ fi
+
+ # set max heap size based on the following
+ # max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB))
+ # calculate 1/2 ram and cap to 1024MB
+ # calculate 1/4 ram and cap to 8192MB
+ # pick the max
+ half_system_memory_in_mb=`expr $system_memory_in_mb / 2`
+ quarter_system_memory_in_mb=`expr $half_system_memory_in_mb / 2`
+ if [ "$half_system_memory_in_mb" -gt "1024" ]
+ then
+ half_system_memory_in_mb="1024"
+ fi
+ if [ "$quarter_system_memory_in_mb" -gt "8192" ]
+ then
+ quarter_system_memory_in_mb="8192"
+ fi
+ if [ "$half_system_memory_in_mb" -gt "$quarter_system_memory_in_mb" ]
+ then
+ max_heap_size_in_mb="$half_system_memory_in_mb"
+ else
+ max_heap_size_in_mb="$quarter_system_memory_in_mb"
+ fi
+ MAX_HEAP_SIZE="${max_heap_size_in_mb}M"
+
+ # Young gen: min(max_sensible_per_modern_cpu_core * num_cores, 1/4 * heap size)
+ max_sensible_yg_per_core_in_mb="100"
+ max_sensible_yg_in_mb=`expr $max_sensible_yg_per_core_in_mb "*" $system_cpu_cores`
+
+ desired_yg_in_mb=`expr $max_heap_size_in_mb / 4`
+
+ if [ "$desired_yg_in_mb" -gt "$max_sensible_yg_in_mb" ]
+ then
+ HEAP_NEWSIZE="${max_sensible_yg_in_mb}M"
+ else
+ HEAP_NEWSIZE="${desired_yg_in_mb}M"
+ fi
+}
+
+# Determine the sort of JVM we'll be running on.
+
+java_ver_output=`"${JAVA:-java}" -version 2>&1`
+
+jvmver=`echo "$java_ver_output" | awk -F'"' 'NR==1 {print $2}'`
+JVM_VERSION=${jvmver%_*}
+JVM_PATCH_VERSION=${jvmver#*_}
+
+jvm=`echo "$java_ver_output" | awk 'NR==2 {print $1}'`
+case "$jvm" in
+ OpenJDK)
+ JVM_VENDOR=OpenJDK
+ # this will be "64-Bit" or "32-Bit"
+ JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $2}'`
+ ;;
+ "Java(TM)")
+ JVM_VENDOR=Oracle
+ # this will be "64-Bit" or "32-Bit"
+ JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $3}'`
+ ;;
+ *)
+ # Help fill in other JVM values
+ JVM_VENDOR=other
+ JVM_ARCH=unknown
+ ;;
+esac
+
+
+# Override these to set the amount of memory to allocate to the JVM at
+# start-up. For production use you may wish to adjust this for your
+# environment. MAX_HEAP_SIZE is the total amount of memory dedicated
+# to the Java heap; HEAP_NEWSIZE refers to the size of the young
+# generation. Both MAX_HEAP_SIZE and HEAP_NEWSIZE should be either set
+# or not (if you set one, set the other).
+#
+# The main trade-off for the young generation is that the larger it
+# is, the longer GC pause times will be. The shorter it is, the more
+# expensive GC will be (usually).
+#
+# The example HEAP_NEWSIZE assumes a modern 8-core+ machine for decent pause
+# times. If in doubt, and if you do not particularly want to tweak, go with
+# 100 MB per physical CPU core.
+
+#MAX_HEAP_SIZE="4G"
+#HEAP_NEWSIZE="800M"
+
+if [ "x$MAX_HEAP_SIZE" = "x" ] && [ "x$HEAP_NEWSIZE" = "x" ]; then
+ calculate_heap_sizes
+else
+ if [ "x$MAX_HEAP_SIZE" = "x" ] || [ "x$HEAP_NEWSIZE" = "x" ]; then
+ echo "please set or unset MAX_HEAP_SIZE and HEAP_NEWSIZE in pairs (see cassandra-env.sh)"
+ exit 1
+ fi
+fi
+
+# Specifies the default port over which Cassandra will be available for
+# JMX connections.
+JMX_PORT="7399"
+
+
+# Here we create the arguments that will get passed to the jvm when
+# starting cassandra.
+
+# enable assertions. disabling this in production will give a modest
+# performance benefit (around 5%).
+JVM_OPTS="$JVM_OPTS -ea"
+
+# add the jamm javaagent
+if [ "$JVM_VENDOR" != "OpenJDK" -o "$JVM_VERSION" \> "1.6.0" ] \
+ || [ "$JVM_VERSION" = "1.6.0" -a "$JVM_PATCH_VERSION" -ge 23 ]
+then
+ JVM_OPTS="$JVM_OPTS -javaagent:$CASSANDRA_HOME/lib/jamm-0.2.5.jar"
+fi
+
+# enable thread priorities, primarily so we can give periodic tasks
+# a lower priority to avoid interfering with client workload
+JVM_OPTS="$JVM_OPTS -XX:+UseThreadPriorities"
+# allows lowering thread priority without being root. see
+# http://tech.stolsvik.com/2010/01/linux-java-thread-priorities-workaround....
+JVM_OPTS="$JVM_OPTS -XX:ThreadPriorityPolicy=42"
+
+# min and max heap sizes should be set to the same value to avoid
+# stop-the-world GC pauses during resize, and so that we can lock the
+# heap in memory on startup to prevent any of it from being swapped
+# out.
+JVM_OPTS="$JVM_OPTS -Xms512M"
+JVM_OPTS="$JVM_OPTS -Xmx512M"
+JVM_OPTS="$JVM_OPTS -Xmn128M"
+JVM_OPTS="$JVM_OPTS -XX:+HeapDumpOnOutOfMemoryError"
+
+# set jvm HeapDumpPath with CASSANDRA_HEAPDUMP_DIR
+if [ "x$CASSANDRA_HEAPDUMP_DIR" != "x" ]; then
+ JVM_OPTS="$JVM_OPTS -XX:HeapDumpPath=$CASSANDRA_HEAPDUMP_DIR/cassandra-`date +%s`-pid$$.hprof"
+fi
+
+
+startswith() { [ "${1#$2}" != "$1" ]; }
+
+if [ "`uname`" = "Linux" ] ; then
+ # reduce the per-thread stack size to minimize the impact of Thrift
+ # thread-per-client. (Best practice is for client connections to
+ # be pooled anyway.) Only do so on Linux where it is known to be
+ # supported.
+ # u34 and greater need 180k
+ JVM_OPTS="$JVM_OPTS -Xss180k"
+fi
+echo "xss = $JVM_OPTS"
+
+# GC tuning options
+JVM_OPTS="$JVM_OPTS -XX:+UseParNewGC"
+JVM_OPTS="$JVM_OPTS -XX:+UseConcMarkSweepGC"
+JVM_OPTS="$JVM_OPTS -XX:+CMSParallelRemarkEnabled"
+JVM_OPTS="$JVM_OPTS -XX:SurvivorRatio=8"
+JVM_OPTS="$JVM_OPTS -XX:MaxTenuringThreshold=1"
+JVM_OPTS="$JVM_OPTS -XX:CMSInitiatingOccupancyFraction=75"
+JVM_OPTS="$JVM_OPTS -XX:+UseCMSInitiatingOccupancyOnly"
+JVM_OPTS="$JVM_OPTS -XX:+UseTLAB"
+# note: bash evals '1.7.x' as > '1.7' so this is really a >= 1.7 jvm check
+if [ "$JVM_VERSION" \> "1.7" ] ; then
+ JVM_OPTS="$JVM_OPTS -XX:+UseCondCardMark"
+fi
+
+# GC logging options -- uncomment to enable
+# JVM_OPTS="$JVM_OPTS -XX:+PrintGCDetails"
+# JVM_OPTS="$JVM_OPTS -XX:+PrintGCDateStamps"
+# JVM_OPTS="$JVM_OPTS -XX:+PrintHeapAtGC"
+# JVM_OPTS="$JVM_OPTS -XX:+PrintTenuringDistribution"
+# JVM_OPTS="$JVM_OPTS -XX:+PrintGCApplicationStoppedTime"
+# JVM_OPTS="$JVM_OPTS -XX:+PrintPromotionFailure"
+# JVM_OPTS="$JVM_OPTS -XX:PrintFLSStatistics=1"
+# JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/cassandra/gc-`date +%s`.log"
+# If you are using JDK 6u34 7u2 or later you can enable GC log rotation
+# don't stick the date in the log name if rotation is on.
+# JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/cassandra/gc.log"
+# JVM_OPTS="$JVM_OPTS -XX:+UseGCLogFileRotation"
+# JVM_OPTS="$JVM_OPTS -XX:NumberOfGCLogFiles=10"
+# JVM_OPTS="$JVM_OPTS -XX:GCLogFileSize=10M"
+
+# uncomment to have Cassandra JVM listen for remote debuggers/profilers on port 1414
+# JVM_OPTS="$JVM_OPTS -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1414"
+
+# Prefer binding to IPv4 network intefaces (when net.ipv6.bindv6only=1). See
+# http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6342561 (short version:
+# comment out this entry to enable IPv6 support).
+JVM_OPTS="$JVM_OPTS -Djava.net.preferIPv4Stack=true"
+
+# jmx: metrics and administration interface
+#
+# add this if you're having trouble connecting:
+# JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<public name>"
+#
+# see
+# https://blogs.oracle.com/jmxetc/entry/troubleshooting_connection_problems...
+# for more on configuring JMX through firewalls, etc. (Short version:
+# get it working with no firewall first.)
+JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT"
+JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false"
+JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
+JVM_OPTS="$JVM_OPTS $JVM_EXTRA_OPTS"
diff --git a/modules/common/cassandra-installer/src/test/resources/rhq48/storage/conf/cassandra.yaml b/modules/common/cassandra-installer/src/test/resources/rhq48/storage/conf/cassandra.yaml
new file mode 100644
index 0000000..8c9c68c
--- /dev/null
+++ b/modules/common/cassandra-installer/src/test/resources/rhq48/storage/conf/cassandra.yaml
@@ -0,0 +1,690 @@
+# Cassandra storage config YAML
+
+# NOTE:
+# See http://wiki.apache.org/cassandra/StorageConfiguration for
+# full explanations of configuration directives
+# /NOTE
+
+# The name of the cluster. This is mainly used to prevent machines in
+# one logical cluster from joining another.
+cluster_name: rhq
+
+# This defines the number of tokens randomly assigned to this node on the ring
+# The more tokens, relative to other nodes, the larger the proportion of data
+# that this node will store. You probably want all nodes to have the same number
+# of tokens assuming they have equal hardware capability.
+#
+# If you leave this unspecified, Cassandra will use the default of 1 token for legacy compatibility,
+# and will use the initial_token as described below.
+#
+# Specifying initial_token will override this setting.
+#
+# If you already have a cluster with 1 token per node, and wish to migrate to
+# multiple tokens per node, see http://wiki.apache.org/cassandra/Operations
+num_tokens: 256
+
+# If you haven't specified num_tokens, or have set it to the default of 1 then
+# you should always specify InitialToken when setting up a production
+# cluster for the first time, and often when adding capacity later.
+# The principle is that each node should be given an equal slice of
+# the token ring; see http://wiki.apache.org/cassandra/Operations
+# for more details.
+#
+# If blank, Cassandra will request a token bisecting the range of
+# the heaviest-loaded existing node. If there is no load information
+# available, such as is the case with a new cluster, it will pick
+# a random token, which will lead to hot spots.
+#initial_token:
+
+# See http://wiki.apache.org/cassandra/HintedHandoff
+hinted_handoff_enabled: true
+# this defines the maximum amount of time a dead host will have hints
+# generated. After it has been dead this long, new hints for it will not be
+# created until it has been seen alive and gone down again.
+max_hint_window_in_ms: 10800000 # 3 hours
+# throttle in KB's per second, per delivery thread
+hinted_handoff_throttle_in_kb: 1024
+# Number of threads with which to deliver hints;
+# Consider increasing this number when you have multi-dc deployments, since
+# cross-dc handoff tends to be slower
+max_hints_delivery_threads: 2
+
+# The following setting populates the page cache on memtable flush and compaction
+# WARNING: Enable this setting only when the whole node's data fits in memory.
+# Defaults to: false
+# populate_io_cache_on_flush: false
+
+# Authentication backend, implementing IAuthenticator; used to identify users
+# Out of the box, Cassandra provides org.apache.cassandra.auth.{AllowAllAuthenticator,
+# PasswordAuthenticator}.
+#
+# - AllowAllAuthenticator performs no checks - set it to disable authentication.
+# - PasswordAuthenticator relies on username/password pairs to authenticate
+# users. It keeps usernames and hashed passwords in system_auth.credentials table.
+# Please increase system_auth keyspace replication factor if you use this authenticator.
+authenticator: org.apache.cassandra.auth.PasswordAuthenticator
+
+# Authorization backend, implementing IAuthorizer; used to limit access/provide permissions
+# Out of the box, Cassandra provides org.apache.cassandra.auth.{AllowAllAuthorizer,
+# CassandraAuthorizer}.
+#
+# - AllowAllAuthorizer allows any action to any user - set it to disable authorization.
+# - CassandraAuthorizer stores permissions in system_auth.permissions table. Please
+# increase system_auth keyspace replication factor if you use this authorizer.
+authorizer: org.apache.cassandra.auth.CassandraAuthorizer
+
+# Validity period for permissions cache (fetching permissions can be an
+# expensive operation depending on the authorizer, CassandraAuthorizer is
+# one example). Defaults to 2000, set to 0 to disable.
+# Will be disabled automatically for AllowAllAuthorizer.
+permissions_validity_in_ms: 2000
+
+# The partitioner is responsible for distributing rows (by key) across
+# nodes in the cluster. Any IPartitioner may be used, including your
+# own as long as it is on the classpath. Out of the box, Cassandra
+# provides org.apache.cassandra.dht.{Murmur3Partitioner, RandomPartitioner
+# ByteOrderedPartitioner, OrderPreservingPartitioner (deprecated)}.
+#
+# - RandomPartitioner distributes rows across the cluster evenly by md5.
+# This is the default prior to 1.2 and is retained for compatibility.
+# - Murmur3Partitioner is similar to RandomPartioner but uses Murmur3_128
+# Hash Function instead of md5. When in doubt, this is the best option.
+# - ByteOrderedPartitioner orders rows lexically by key bytes. BOP allows
+# scanning rows in key order, but the ordering can generate hot spots
+# for sequential insertion workloads.
+# - OrderPreservingPartitioner is an obsolete form of BOP, that stores
+# - keys in a less-efficient format and only works with keys that are
+# UTF8-encoded Strings.
+# - CollatingOPP colates according to EN,US rules rather than lexical byte
+# ordering. Use this as an example if you need custom collation.
+#
+# See http://wiki.apache.org/cassandra/Operations for more on
+# partitioners and token selection.
+partitioner: org.apache.cassandra.dht.Murmur3Partitioner
+
+# directories where Cassandra should store data on disk.
+data_file_directories:
+ - target/rhq48/rhq-storage/data
+
+# commit log
+commitlog_directory: target/rhq48/rhq-storage/commit_log
+
+# policy for data disk failures:
+# stop: shut down gossip and Thrift, leaving the node effectively dead, but
+# still inspectable via JMX.
+# best_effort: stop using the failed disk and respond to requests based on
+# remaining available sstables. This means you WILL see obsolete
+# data at CL.ONE!
+# ignore: ignore fatal errors and let requests fail, as in pre-1.2 Cassandra
+disk_failure_policy: stop
+
+# Maximum size of the key cache in memory.
+#
+# Each key cache hit saves 1 seek and each row cache hit saves 2 seeks at the
+# minimum, sometimes more. The key cache is fairly tiny for the amount of
+# time it saves, so it's worthwhile to use it at large numbers.
+# The row cache saves even more time, but must store the whole values of
+# its rows, so it is extremely space-intensive. It's best to only use the
+# row cache if you have hot rows or static rows.
+#
+# NOTE: if you reduce the size, you may not get you hottest keys loaded on startup.
+#
+# Default value is empty to make it "auto" (min(5% of Heap (in MB), 100MB)). Set to 0 to disable key cache.
+key_cache_size_in_mb:
+
+# Duration in seconds after which Cassandra should
+# safe the keys cache. Caches are saved to saved_caches_directory as
+# specified in this configuration file.
+#
+# Saved caches greatly improve cold-start speeds, and is relatively cheap in
+# terms of I/O for the key cache. Row cache saving is much more expensive and
+# has limited use.
+#
+# Default is 14400 or 4 hours.
+key_cache_save_period: 14400
+
+# Number of keys from the key cache to save
+# Disabled by default, meaning all keys are going to be saved
+# key_cache_keys_to_save: 100
+
+# Maximum size of the row cache in memory.
+# NOTE: if you reduce the size, you may not get you hottest keys loaded on startup.
+#
+# Default value is 0, to disable row caching.
+row_cache_size_in_mb: 0
+
+# Duration in seconds after which Cassandra should
+# safe the row cache. Caches are saved to saved_caches_directory as specified
+# in this configuration file.
+#
+# Saved caches greatly improve cold-start speeds, and is relatively cheap in
+# terms of I/O for the key cache. Row cache saving is much more expensive and
+# has limited use.
+#
+# Default is 0 to disable saving the row cache.
+row_cache_save_period: 0
+
+# Number of keys from the row cache to save
+# Disabled by default, meaning all keys are going to be saved
+# row_cache_keys_to_save: 100
+
+# The provider for the row cache to use.
+#
+# Supported values are: ConcurrentLinkedHashCacheProvider, SerializingCacheProvider
+#
+# SerializingCacheProvider serialises the contents of the row and stores
+# it in native memory, i.e., off the JVM Heap. Serialized rows take
+# significantly less memory than "live" rows in the JVM, so you can cache
+# more rows in a given memory footprint. And storing the cache off-heap
+# means you can use smaller heap sizes, reducing the impact of GC pauses.
+#
+# It is also valid to specify the fully-qualified class name to a class
+# that implements org.apache.cassandra.cache.IRowCacheProvider.
+#
+# Defaults to SerializingCacheProvider
+row_cache_provider: SerializingCacheProvider
+
+# saved caches
+saved_caches_directory: target/rhq48/rhq-storage/saved_caches
+
+# commitlog_sync may be either "periodic" or "batch."
+# When in batch mode, Cassandra won't ack writes until the commit log
+# has been fsynced to disk. It will wait up to
+# commitlog_sync_batch_window_in_ms milliseconds for other writes, before
+# performing the sync.
+#
+# commitlog_sync: batch
+# commitlog_sync_batch_window_in_ms: 50
+#
+# the other option is "periodic" where writes may be acked immediately
+# and the CommitLog is simply synced every commitlog_sync_period_in_ms
+# milliseconds.
+commitlog_sync: periodic
+commitlog_sync_period_in_ms: 10000
+
+# The size of the individual commitlog file segments. A commitlog
+# segment may be archived, deleted, or recycled once all the data
+# in it (potentally from each columnfamily in the system) has been
+# flushed to sstables.
+#
+# The default size is 32, which is almost always fine, but if you are
+# archiving commitlog segments (see commitlog_archiving.properties),
+# then you probably want a finer granularity of archiving; 8 or 16 MB
+# is reasonable.
+commitlog_segment_size_in_mb: 32
+
+# any class that implements the SeedProvider interface and has a
+# constructor that takes a Map<String, String> of parameters will do.
+seed_provider:
+ # Addresses of hosts that are deemed contact points.
+ # Cassandra nodes use this list of hosts to find each other and learn
+ # the topology of the ring. You must change this if you are running
+ # multiple nodes!
+ - class_name: org.apache.cassandra.locator.SimpleSeedProvider
+ parameters:
+ # seeds is actually a comma-delimited list of addresses.
+ # Ex: "<ip1>,<ip2>,<ip3>"
+ - seeds: "127.0.0.1"
+
+# emergency pressure valve: each time heap usage after a full (CMS)
+# garbage collection is above this fraction of the max, Cassandra will
+# flush the largest memtables.
+#
+# Set to 1.0 to disable. Setting this lower than
+# CMSInitiatingOccupancyFraction is not likely to be useful.
+#
+# RELYING ON THIS AS YOUR PRIMARY TUNING MECHANISM WILL WORK POORLY:
+# it is most effective under light to moderate load, or read-heavy
+# workloads; under truly massive write load, it will often be too
+# little, too late.
+flush_largest_memtables_at: 0.75
+
+# emergency pressure valve #2: the first time heap usage after a full
+# (CMS) garbage collection is above this fraction of the max,
+# Cassandra will reduce cache maximum _capacity_ to the given fraction
+# of the current _size_. Should usually be set substantially above
+# flush_largest_memtables_at, since that will have less long-term
+# impact on the system.
+#
+# Set to 1.0 to disable. Setting this lower than
+# CMSInitiatingOccupancyFraction is not likely to be useful.
+reduce_cache_sizes_at: 0.85
+reduce_cache_capacity_to: 0.6
+
+# For workloads with more data than can fit in memory, Cassandra's
+# bottleneck will be reads that need to fetch data from
+# disk. "concurrent_reads" should be set to (16 * number_of_drives) in
+# order to allow the operations to enqueue low enough in the stack
+# that the OS and drives can reorder them.
+#
+# On the other hand, since writes are almost never IO bound, the ideal
+# number of "concurrent_writes" is dependent on the number of cores in
+# your system; (8 * number_of_cores) is a good rule of thumb.
+concurrent_reads: 32
+concurrent_writes: 32
+
+# Total memory to use for memtables. Cassandra will flush the largest
+# memtable when this much memory is used.
+# If omitted, Cassandra will set it to 1/3 of the heap.
+# memtable_total_space_in_mb: 2048
+
+# Total space to use for commitlogs. Since commitlog segments are
+# mmapped, and hence use up address space, the default size is 32
+# on 32-bit JVMs, and 1024 on 64-bit JVMs.
+#
+# If space gets above this value (it will round up to the next nearest
+# segment multiple), Cassandra will flush every dirty CF in the oldest
+# segment and remove it. So a small total commitlog space will tend
+# to cause more flush activity on less-active columnfamilies.
+# commitlog_total_space_in_mb: 4096
+
+# This sets the amount of memtable flush writer threads. These will
+# be blocked by disk io, and each one will hold a memtable in memory
+# while blocked. If you have a large heap and many data directories,
+# you can increase this value for better flush performance.
+# By default this will be set to the amount of data directories defined.
+#memtable_flush_writers: 1
+
+# the number of full memtables to allow pending flush, that is,
+# waiting for a writer thread. At a minimum, this should be set to
+# the maximum number of secondary indexes created on a single CF.
+memtable_flush_queue_size: 4
+
+# Whether to, when doing sequential writing, fsync() at intervals in
+# order to force the operating system to flush the dirty
+# buffers. Enable this to avoid sudden dirty buffer flushing from
+# impacting read latencies. Almost always a good idea on SSD:s; not
+# necessarily on platters.
+trickle_fsync: false
+trickle_fsync_interval_in_kb: 10240
+
+# TCP port, for commands and data
+storage_port: 7100
+
+# SSL port, for encrypted communication. Unused unless enabled in
+# encryption_options
+ssl_storage_port: 7101
+
+# Address to bind to and tell other Cassandra nodes to connect to. You
+# _must_ change this if you want multiple nodes to be able to
+# communicate!
+#
+# Leaving it blank leaves it up to InetAddress.getLocalHost(). This
+# will always do the Right Thing *if* the node is properly configured
+# (hostname, name resolution, etc), and the Right Thing is to use the
+# address associated with the hostname (it might not be).
+#
+# Setting this to 0.0.0.0 is always wrong.
+listen_address: 127.0.0.1
+
+# Address to broadcast to other Cassandra nodes
+# Leaving this blank will set it to the same value as listen_address
+# broadcast_address: 1.2.3.4
+
+# Internode authentication backend, implementing IInternodeAuthenticator;
+# used to allow/disallow connections from peer nodes.
+# internode_authenticator: org.apache.cassandra.auth.AllowAllInternodeAuthenticator
+
+# Whether to start the native transport server.
+# Currently, only the thrift server is started by default because the native
+# transport is considered beta.
+# Please note that the address on which the native transport is bound is the
+# same as the rpc_address. The port however is different and specified below.
+start_native_transport: true
+# port for the CQL native transport to listen for clients on
+native_transport_port: 9142
+# The minimum and maximum threads for handling requests when the native
+# transport is used. The meaning is those is similar to the one of
+# rpc_min_threads and rpc_max_threads, though the default differ slightly and
+# are the ones below:
+# native_transport_min_threads: 16
+native_transport_max_threads: 128
+
+
+# Whether to start the thrift rpc server.
+start_rpc: false
+# The address to bind the Thrift RPC service to -- clients connect
+# here. Unlike ListenAddress above, you *can* specify 0.0.0.0 here if
+# you want Thrift to listen on all interfaces.
+#
+# Leaving this blank has the same effect it does for ListenAddress,
+# (i.e. it will be based on the configured hostname of the node).
+rpc_address: 127.0.0.1
+# port for Thrift to listen for clients on
+rpc_port: 9160
+
+# enable or disable keepalive on rpc connections
+rpc_keepalive: true
+
+# Cassandra provides three out-of-the-box options for the RPC Server:
+#
+# sync -> One thread per thrift connection. For a very large number of clients, memory
+# will be your limiting factor. On a 64 bit JVM, 128KB is the minimum stack size
+# per thread, and that will correspond to your use of virtual memory (but physical memory
+# may be limited depending on use of stack space).
+#
+# hsha -> Stands for "half synchronous, half asynchronous." All thrift clients are handled
+# asynchronously using a small number of threads that does not vary with the amount
+# of thrift clients (and thus scales well to many clients). The rpc requests are still
+# synchronous (one thread per active request).
+#
+# The default is sync because on Windows hsha is about 30% slower. On Linux,
+# sync/hsha performance is about the same, with hsha of course using less memory.
+#
+# Alternatively, can provide your own RPC server by providing the fully-qualified class name
+# of an o.a.c.t.TServerFactory that can create an instance of it.
+rpc_server_type: sync
+
+# Uncomment rpc_min|max_thread to set request pool size limits.
+#
+# Regardless of your choice of RPC server (see above), the number of maximum requests in the
+# RPC thread pool dictates how many concurrent requests are possible (but if you are using the sync
+# RPC server, it also dictates the number of clients that can be connected at all).
+#
+# The default is unlimited and thus provide no protection against clients overwhelming the server. You are
+# encouraged to set a maximum that makes sense for you in production, but do keep in mind that
+# rpc_max_threads represents the maximum number of client requests this server may execute concurrently.
+#
+# rpc_min_threads: 16
+# rpc_max_threads: 2048
+
+# uncomment to set socket buffer sizes on rpc connections
+# rpc_send_buff_size_in_bytes:
+# rpc_recv_buff_size_in_bytes:
+
+# uncomment to set socket buffer size for internode communication
+# Note that when setting this, the buffer size is limited by net.core.wmem_max
+# and when not setting it it is defined by net.ipv4.tcp_wmem
+# See:
+# /proc/sys/net/core/wmem_max
+# /proc/sys/net/core/rmem_max
+# /proc/sys/net/ipv4/tcp_wmem
+# /proc/sys/net/ipv4/tcp_wmem
+# and: man tcp
+# internode_send_buff_size_in_bytes:
+# internode_recv_buff_size_in_bytes:
+
+# Frame size for thrift (maximum field length).
+thrift_framed_transport_size_in_mb: 15
+
+# The max length of a thrift message, including all fields and
+# internal thrift overhead.
+thrift_max_message_length_in_mb: 16
+
+# Set to true to have Cassandra create a hard link to each sstable
+# flushed or streamed locally in a backups/ subdirectory of the
+# Keyspace data. Removing these links is the operator's
+# responsibility.
+incremental_backups: false
+
+# Whether or not to take a snapshot before each compaction. Be
+# careful using this option, since Cassandra won't clean up the
+# snapshots for you. Mostly useful if you're paranoid when there
+# is a data format change.
+snapshot_before_compaction: false
+
+# Whether or not a snapshot is taken of the data before keyspace truncation
+# or dropping of column families. The STRONGLY advised default of true
+# should be used to provide data safety. If you set this flag to false, you will
+# lose data on truncation or drop.
+auto_snapshot: true
+
+# Add column indexes to a row after its contents reach this size.
+# Increase if your column values are large, or if you have a very large
+# number of columns. The competing causes are, Cassandra has to
+# deserialize this much of the row to read a single column, so you want
+# it to be small - at least if you do many partial-row reads - but all
+# the index data is read for each access, so you don't want to generate
+# that wastefully either.
+column_index_size_in_kb: 64
+
+# Size limit for rows being compacted in memory. Larger rows will spill
+# over to disk and use a slower two-pass compaction process. A message
+# will be logged specifying the row key.
+in_memory_compaction_limit_in_mb: 64
+
+# Number of simultaneous compactions to allow, NOT including
+# validation "compactions" for anti-entropy repair. Simultaneous
+# compactions can help preserve read performance in a mixed read/write
+# workload, by mitigating the tendency of small sstables to accumulate
+# during a single long running compactions. The default is usually
+# fine and if you experience problems with compaction running too
+# slowly or too fast, you should look at
+# compaction_throughput_mb_per_sec first.
+#
+# concurrent_compactors defaults to the number of cores.
+# Uncomment to make compaction mono-threaded, the pre-0.8 default.
+#concurrent_compactors: 1
+
+# Multi-threaded compaction. When enabled, each compaction will use
+# up to one thread per core, plus one thread per sstable being merged.
+# This is usually only useful for SSD-based hardware: otherwise,
+# your concern is usually to get compaction to do LESS i/o (see:
+# compaction_throughput_mb_per_sec), not more.
+multithreaded_compaction: false
+
+# Throttles compaction to the given total throughput across the entire
+# system. The faster you insert data, the faster you need to compact in
+# order to keep the sstable count down, but in general, setting this to
+# 16 to 32 times the rate you are inserting data is more than sufficient.
+# Setting this to 0 disables throttling. Note that this account for all types
+# of compaction, including validation compaction.
+compaction_throughput_mb_per_sec: 16
+
+# Track cached row keys during compaction, and re-cache their new
+# positions in the compacted sstable. Disable if you use really large
+# key caches.
+compaction_preheat_key_cache: true
+
+# Throttles all outbound streaming file transfers on this node to the
+# given total throughput in Mbps. This is necessary because Cassandra does
+# mostly sequential IO when streaming data during bootstrap or repair, which
+# can lead to saturating the network connection and degrading rpc performance.
+# When unset, the default is 200 Mbps or 25 MB/s.
+# stream_throughput_outbound_megabits_per_sec: 200
+
+# How long the coordinator should wait for read operations to complete
+read_request_timeout_in_ms: 20000
+# How long the coordinator should wait for seq or index scans to complete
+range_request_timeout_in_ms: 20000
+# How long the coordinator should wait for writes to complete
+write_request_timeout_in_ms: 20000
+# How long the coordinator should wait for truncates to complete
+# (This can be much longer, because we need to flush all CFs
+# to make sure we can clear out anythink in the commitlog that could
+# cause truncated data to reappear.)
+truncate_request_timeout_in_ms: 60000
+# The default timeout for other, miscellaneous operations
+request_timeout_in_ms: 20000
+
+# Enable operation timeout information exchange between nodes to accurately
+# measure request timeouts, If disabled cassandra will assuming the request
+# was forwarded to the replica instantly by the coordinator
+#
+# Warning: before enabling this property make sure to ntp is installed
+# and the times are synchronized between the nodes.
+cross_node_timeout: false
+
+# Enable socket timeout for streaming operation.
+# When a timeout occurs during streaming, streaming is retried from the start
+# of the current file. This *can* involve re-streaming an important amount of
+# data, so you should avoid setting the value too low.
+# Default value is 0, which never timeout streams.
+# streaming_socket_timeout_in_ms: 0
+
+# phi value that must be reached for a host to be marked down.
+# most users should never need to adjust this.
+# phi_convict_threshold: 8
+
+# endpoint_snitch -- Set this to a class that implements
+# IEndpointSnitch. The snitch has two functions:
+# - it teaches Cassandra enough about your network topology to route
+# requests efficiently
+# - it allows Cassandra to spread replicas around your cluster to avoid
+# correlated failures. It does this by grouping machines into
+# "datacenters" and "racks." Cassandra will do its best not to have
+# more than one replica on the same "rack" (which may not actually
+# be a physical location)
+#
+# IF YOU CHANGE THE SNITCH AFTER DATA IS INSERTED INTO THE CLUSTER,
+# YOU MUST RUN A FULL REPAIR, SINCE THE SNITCH AFFECTS WHERE REPLICAS
+# ARE PLACED.
+#
+# Out of the box, Cassandra provides
+# - SimpleSnitch:
+# Treats Strategy order as proximity. This improves cache locality
+# when disabling read repair, which can further improve throughput.
+# Only appropriate for single-datacenter deployments.
+# - PropertyFileSnitch:
+# Proximity is determined by rack and data center, which are
+# explicitly configured in cassandra-topology.properties.
+# - GossipingPropertyFileSnitch
+# The rack and datacenter for the local node are defined in
+# cassandra-rackdc.properties and propagated to other nodes via gossip. If
+# cassandra-topology.properties exists, it is used as a fallback, allowing
+# migration from the PropertyFileSnitch.
+# - RackInferringSnitch:
+# Proximity is determined by rack and data center, which are
+# assumed to correspond to the 3rd and 2nd octet of each node's
+# IP address, respectively. Unless this happens to match your
+# deployment conventions (as it did Facebook's), this is best used
+# as an example of writing a custom Snitch class.
+# - Ec2Snitch:
+# Appropriate for EC2 deployments in a single Region. Loads Region
+# and Availability Zone information from the EC2 API. The Region is
+# treated as the Datacenter, and the Availability Zone as the rack.
+# Only private IPs are used, so this will not work across multiple
+# Regions.
+# - Ec2MultiRegionSnitch:
+# Uses public IPs as broadcast_address to allow cross-region
+# connectivity. (Thus, you should set seed addresses to the public
+# IP as well.) You will need to open the storage_port or
+# ssl_storage_port on the public IP firewall. (For intra-Region
+# traffic, Cassandra will switch to the private IP after
+# establishing a connection.)
+#
+# You can use a custom Snitch by setting this to the full class name
+# of the snitch, which will be assumed to be on your classpath.
+endpoint_snitch: SimpleSnitch
+
+# controls how often to perform the more expensive part of host score
+# calculation
+dynamic_snitch_update_interval_in_ms: 100
+# controls how often to reset all host scores, allowing a bad host to
+# possibly recover
+dynamic_snitch_reset_interval_in_ms: 600000
+# if set greater than zero and read_repair_chance is < 1.0, this will allow
+# 'pinning' of replicas to hosts in order to increase cache capacity.
+# The badness threshold will control how much worse the pinned host has to be
+# before the dynamic snitch will prefer other replicas over it. This is
+# expressed as a double which represents a percentage. Thus, a value of
+# 0.2 means Cassandra would continue to prefer the static snitch values
+# until the pinned host was 20% worse than the fastest.
+dynamic_snitch_badness_threshold: 0.1
+
+# request_scheduler -- Set this to a class that implements
+# RequestScheduler, which will schedule incoming client requests
+# according to the specific policy. This is useful for multi-tenancy
+# with a single Cassandra cluster.
+# NOTE: This is specifically for requests from the client and does
+# not affect inter node communication.
+# org.apache.cassandra.scheduler.NoScheduler - No scheduling takes place
+# org.apache.cassandra.scheduler.RoundRobinScheduler - Round robin of
+# client requests to a node with a separate queue for each
+# request_scheduler_id. The scheduler is further customized by
+# request_scheduler_options as described below.
+request_scheduler: org.apache.cassandra.scheduler.NoScheduler
+
+# Scheduler Options vary based on the type of scheduler
+# NoScheduler - Has no options
+# RoundRobin
+# - throttle_limit -- The throttle_limit is the number of in-flight
+# requests per client. Requests beyond
+# that limit are queued up until
+# running requests can complete.
+# The value of 80 here is twice the number of
+# concurrent_reads + concurrent_writes.
+# - default_weight -- default_weight is optional and allows for
+# overriding the default which is 1.
+# - weights -- Weights are optional and will default to 1 or the
+# overridden default_weight. The weight translates into how
+# many requests are handled during each turn of the
+# RoundRobin, based on the scheduler id.
+#
+# request_scheduler_options:
+# throttle_limit: 80
+# default_weight: 5
+# weights:
+# Keyspace1: 1
+# Keyspace2: 5
+
+# request_scheduler_id -- An identifer based on which to perform
+# the request scheduling. Currently the only valid option is keyspace.
+# request_scheduler_id: keyspace
+
+# index_interval controls the sampling of entries from the primrary
+# row index in terms of space versus time. The larger the interval,
+# the smaller and less effective the sampling will be. In technicial
+# terms, the interval coresponds to the number of index entries that
+# are skipped between taking each sample. All the sampled entries
+# must fit in memory. Generally, a value between 128 and 512 here
+# coupled with a large key cache size on CFs results in the best trade
+# offs. This value is not often changed, however if you have many
+# very small rows (many to an OS page), then increasing this will
+# often lower memory usage without a impact on performance.
+index_interval: 128
+
+# Enable or disable inter-node encryption
+# Default settings are TLS v1, RSA 1024-bit keys (it is imperative that
+# users generate their own keys) TLS_RSA_WITH_AES_128_CBC_SHA as the cipher
+# suite for authentication, key exchange and encryption of the actual data transfers.
+# NOTE: No custom encryption options are enabled at the moment
+# The available internode options are : all, none, dc, rack
+#
+# If set to dc cassandra will encrypt the traffic between the DCs
+# If set to rack cassandra will encrypt the traffic between the racks
+#
+# The passwords used in these options must match the passwords used when generating
+# the keystore and truststore. For instructions on generating these files, see:
+# http://download.oracle.com/javase/6/docs/technotes/guides/security/jsse/J...
+#
+server_encryption_options:
+ internode_encryption: none
+ keystore: conf/.keystore
+ keystore_password: cassandra
+ truststore: conf/.truststore
+ truststore_password: cassandra
+ # More advanced defaults below:
+ # protocol: TLS
+ # algorithm: SunX509
+ # store_type: JKS
+ # cipher_suites: [TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA]
+ # require_client_auth: false
+
+# enable or disable client/server encryption.
+client_encryption_options:
+ enabled: false
+ keystore: conf/.keystore
+ keystore_password: cassandra
+ # require_client_auth: false
+ # Set trustore and truststore_password if require_client_auth is true
+ # truststore: conf/.truststore
+ # truststore_password: cassandra
+ # More advanced defaults below:
+ # protocol: TLS
+ # algorithm: SunX509
+ # store_type: JKS
+ # cipher_suites: [TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA]
+
+# internode_compression controls whether traffic between nodes is
+# compressed.
+# can be: all - all traffic is compressed
+# dc - traffic between different datacenters is compressed
+# none - nothing is compressed.
+internode_compression: all
+
+# Enable or disable tcp_nodelay for inter-dc communication.
+# Disabling it will result in larger (but fewer) network packets being sent,
+# reducing overhead from the TCP protocol itself, at the cost of increasing
+# latency if you block for cross-datacenter responses.
+inter_dc_tcp_nodelay: true
diff --git a/modules/common/cassandra-installer/src/test/resources/rhq48/storage/conf/log4j-server.properties b/modules/common/cassandra-installer/src/test/resources/rhq48/storage/conf/log4j-server.properties
new file mode 100644
index 0000000..c2e6dab
--- /dev/null
+++ b/modules/common/cassandra-installer/src/test/resources/rhq48/storage/conf/log4j-server.properties
@@ -0,0 +1,45 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# for production, you should probably set pattern to %c instead of %l.
+# (%l is slower.)
+
+# output messages into a rolling log file as well as stdout
+log4j.rootLogger=INFO,stdout,R
+
+# stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%5p %d{HH:mm:ss,SSS} %m%n
+
+# rolling log file
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.maxFileSize=20MB
+log4j.appender.R.maxBackupIndex=50
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern=%5p [%t] %d{ISO8601} %F (line %L) %m%n
+# Edit the next line to point to your logs directory
+log4j.appender.R.File=target/rhq48/rhq-storage/logs/rhq-storage.log
+log4j.appender.R.Threshold=INFO
+
+# Application logging options
+#log4j.logger.org.apache.cassandra=DEBUG
+#log4j.logger.org.apache.cassandra.db=DEBUG
+#log4j.logger.org.apache.cassandra.service.StorageProxy=DEBUG
+
+# Adding this to avoid thrift logging disconnect errors.
+log4j.logger.org.apache.thrift.server.TNonblockingServer=ERROR
+
commit 656cc6066250f46ff51e16230c0f7c8263f55435
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 19 13:43:46 2013 -0400
[BZ 983226] fixing upgrade regression introduced by use of cassandra-jvm.properties
This commit removes cassandra-env.sh from our Cassandra distro since we are no
longer using that script. The storage installer upgrade has been cleaned up
some so that it will get the jmx port from cassandra-env.sh for 4.8 installs
and then update cassandra-jvm.properties.
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml b/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml
index 42f6c8b..2bde394 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml
@@ -171,6 +171,7 @@
<move file="${project.build.outputDirectory}/cassandra/bin/cassandra" todir="${cassandra.dir}/bin"/>
<delete dir="${project.build.outputDirectory}/cassandra"/>
<delete dir="${cassandra.dir}/javadoc"/>
+ <delete file="${cassandra.dir}/conf/cassandra-env.sh"/>
<zip basedir="${cassandra.dir}" destfile="${cassandra.distro.zip}"/>
<delete dir="${cassandra.dir}"/>
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/bin/cassandra b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/bin/cassandra
index 742d9c0..ddbc099 100755
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/bin/cassandra
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/bin/cassandra
@@ -106,8 +106,7 @@ if [ -z "$CASSANDRA_CONF" -o -z "$CLASSPATH" ]; then
exit 1
fi
-if [ -f "$CASSANDRA_CONF/cassandra-env.sh" ]; then
- #. "$CASSANDRA_CONF/cassandra-env.sh"
+if [ -f "$CASSANDRA_CONF/cassandra-jvm.properties" ]; then
. "$CASSANDRA_CONF/cassandra-jvm.properties"
fi
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra-env.sh b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra-env.sh
deleted file mode 100644
index 99b3128..0000000
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra-env.sh
+++ /dev/null
@@ -1,247 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-calculate_heap_sizes()
-{
- case "`uname`" in
- Linux)
- system_memory_in_mb=`free -m | awk '/Mem:/ {print $2}'`
- system_cpu_cores=`egrep -c 'processor([[:space:]]+):.*' /proc/cpuinfo`
- ;;
- FreeBSD)
- system_memory_in_bytes=`sysctl hw.physmem | awk '{print $2}'`
- system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024`
- system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'`
- ;;
- SunOS)
- system_memory_in_mb=`prtconf | awk '/Memory size:/ {print $3}'`
- system_cpu_cores=`psrinfo | wc -l`
- ;;
- Darwin)
- system_memory_in_bytes=`sysctl hw.memsize | awk '{print $2}'`
- system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024`
- system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'`
- ;;
- *)
- # assume reasonable defaults for e.g. a modern desktop or
- # cheap server
- system_memory_in_mb="2048"
- system_cpu_cores="2"
- ;;
- esac
-
- # some systems like the raspberry pi don't report cores, use at least 1
- if [ "$system_cpu_cores" -lt "1" ]
- then
- system_cpu_cores="1"
- fi
-
- # set max heap size based on the following
- # max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB))
- # calculate 1/2 ram and cap to 1024MB
- # calculate 1/4 ram and cap to 8192MB
- # pick the max
- half_system_memory_in_mb=`expr $system_memory_in_mb / 2`
- quarter_system_memory_in_mb=`expr $half_system_memory_in_mb / 2`
- if [ "$half_system_memory_in_mb" -gt "1024" ]
- then
- half_system_memory_in_mb="1024"
- fi
- if [ "$quarter_system_memory_in_mb" -gt "8192" ]
- then
- quarter_system_memory_in_mb="8192"
- fi
- if [ "$half_system_memory_in_mb" -gt "$quarter_system_memory_in_mb" ]
- then
- max_heap_size_in_mb="$half_system_memory_in_mb"
- else
- max_heap_size_in_mb="$quarter_system_memory_in_mb"
- fi
- MAX_HEAP_SIZE="\${max_heap_size_in_mb}M"
-
- # Young gen: min(max_sensible_per_modern_cpu_core * num_cores, 1/4 * heap size)
- max_sensible_yg_per_core_in_mb="100"
- max_sensible_yg_in_mb=`expr $max_sensible_yg_per_core_in_mb "*" $system_cpu_cores`
-
- desired_yg_in_mb=`expr $max_heap_size_in_mb / 4`
-
- if [ "$desired_yg_in_mb" -gt "$max_sensible_yg_in_mb" ]
- then
- HEAP_NEWSIZE="\${max_sensible_yg_in_mb}M"
- else
- HEAP_NEWSIZE="\${desired_yg_in_mb}M"
- fi
-}
-
-# Determine the sort of JVM we'll be running on.
-
-java_ver_output=`"\${JAVA:-java}" -version 2>&1`
-
-jvmver=`echo "$java_ver_output" | awk -F'"' 'NR==1 {print $2}'`
-JVM_VERSION=\${jvmver%_*}
-JVM_PATCH_VERSION=\${jvmver#*_}
-
-jvm=`echo "$java_ver_output" | awk 'NR==2 {print $1}'`
-case "$jvm" in
- OpenJDK)
- JVM_VENDOR=OpenJDK
- # this will be "64-Bit" or "32-Bit"
- JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $2}'`
- ;;
- "Java(TM)")
- JVM_VENDOR=Oracle
- # this will be "64-Bit" or "32-Bit"
- JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $3}'`
- ;;
- *)
- # Help fill in other JVM values
- JVM_VENDOR=other
- JVM_ARCH=unknown
- ;;
-esac
-
-
-# Override these to set the amount of memory to allocate to the JVM at
-# start-up. For production use you may wish to adjust this for your
-# environment. MAX_HEAP_SIZE is the total amount of memory dedicated
-# to the Java heap; HEAP_NEWSIZE refers to the size of the young
-# generation. Both MAX_HEAP_SIZE and HEAP_NEWSIZE should be either set
-# or not (if you set one, set the other).
-#
-# The main trade-off for the young generation is that the larger it
-# is, the longer GC pause times will be. The shorter it is, the more
-# expensive GC will be (usually).
-#
-# The example HEAP_NEWSIZE assumes a modern 8-core+ machine for decent pause
-# times. If in doubt, and if you do not particularly want to tweak, go with
-# 100 MB per physical CPU core.
-
-#MAX_HEAP_SIZE="4G"
-#HEAP_NEWSIZE="800M"
-
-if [ "x$MAX_HEAP_SIZE" = "x" ] && [ "x$HEAP_NEWSIZE" = "x" ]; then
- calculate_heap_sizes
-else
- if [ "x$MAX_HEAP_SIZE" = "x" ] || [ "x$HEAP_NEWSIZE" = "x" ]; then
- echo "please set or unset MAX_HEAP_SIZE and HEAP_NEWSIZE in pairs (see cassandra-env.sh)"
- exit 1
- fi
-fi
-
-# Specifies the default port over which Cassandra will be available for
-# JMX connections.
-JMX_PORT="${rhq.cassandra.jmx.port}"
-
-
-# Here we create the arguments that will get passed to the jvm when
-# starting cassandra.
-
-# enable assertions. disabling this in production will give a modest
-# performance benefit (around 5%).
-JVM_OPTS="$JVM_OPTS -ea"
-
-# add the jamm javaagent
-if [ "$JVM_VENDOR" != "OpenJDK" -o "$JVM_VERSION" \\> "1.6.0" ] \\
- || [ "$JVM_VERSION" = "1.6.0" -a "$JVM_PATCH_VERSION" -ge 23 ]
-then
- JVM_OPTS="$JVM_OPTS -javaagent:$CASSANDRA_HOME/lib/jamm-0.2.5.jar"
-fi
-
-# enable thread priorities, primarily so we can give periodic tasks
-# a lower priority to avoid interfering with client workload
-JVM_OPTS="$JVM_OPTS -XX:+UseThreadPriorities"
-# allows lowering thread priority without being root. see
-# http://tech.stolsvik.com/2010/01/linux-java-thread-priorities-workaround....
-JVM_OPTS="$JVM_OPTS -XX:ThreadPriorityPolicy=42"
-
-# min and max heap sizes should be set to the same value to avoid
-# stop-the-world GC pauses during resize, and so that we can lock the
-# heap in memory on startup to prevent any of it from being swapped
-# out.
-JVM_OPTS="$JVM_OPTS -Xms${rhq.cassandra.max.heap.size}"
-JVM_OPTS="$JVM_OPTS -Xmx${rhq.cassandra.max.heap.size}"
-JVM_OPTS="$JVM_OPTS -Xmn${rhq.cassandra.heap.new.size}"
-JVM_OPTS="$JVM_OPTS -XX:+HeapDumpOnOutOfMemoryError"
-
-# set jvm HeapDumpPath with CASSANDRA_HEAPDUMP_DIR
-if [ "x$CASSANDRA_HEAPDUMP_DIR" != "x" ]; then
- JVM_OPTS="$JVM_OPTS -XX:HeapDumpPath=$CASSANDRA_HEAPDUMP_DIR/cassandra-`date +%s`-pid$$.hprof"
-fi
-
-
-startswith() { [ "\${1#$2}" != "$1" ]; }
-
-if [ "`uname`" = "Linux" ] ; then
- # reduce the per-thread stack size to minimize the impact of Thrift
- # thread-per-client. (Best practice is for client connections to
- # be pooled anyway.) Only do so on Linux where it is known to be
- # supported.
- # u34 and greater need 180k
- JVM_OPTS="$JVM_OPTS -Xss${rhq.cassandra.stack.size}"
-fi
-echo "xss = $JVM_OPTS"
-
-# GC tuning options
-JVM_OPTS="$JVM_OPTS -XX:+UseParNewGC"
-JVM_OPTS="$JVM_OPTS -XX:+UseConcMarkSweepGC"
-JVM_OPTS="$JVM_OPTS -XX:+CMSParallelRemarkEnabled"
-JVM_OPTS="$JVM_OPTS -XX:SurvivorRatio=8"
-JVM_OPTS="$JVM_OPTS -XX:MaxTenuringThreshold=1"
-JVM_OPTS="$JVM_OPTS -XX:CMSInitiatingOccupancyFraction=75"
-JVM_OPTS="$JVM_OPTS -XX:+UseCMSInitiatingOccupancyOnly"
-JVM_OPTS="$JVM_OPTS -XX:+UseTLAB"
-# note: bash evals '1.7.x' as > '1.7' so this is really a >= 1.7 jvm check
-if [ "$JVM_VERSION" \\> "1.7" ] ; then
- JVM_OPTS="$JVM_OPTS -XX:+UseCondCardMark"
-fi
-
-# GC logging options -- uncomment to enable
-# JVM_OPTS="$JVM_OPTS -XX:+PrintGCDetails"
-# JVM_OPTS="$JVM_OPTS -XX:+PrintGCDateStamps"
-# JVM_OPTS="$JVM_OPTS -XX:+PrintHeapAtGC"
-# JVM_OPTS="$JVM_OPTS -XX:+PrintTenuringDistribution"
-# JVM_OPTS="$JVM_OPTS -XX:+PrintGCApplicationStoppedTime"
-# JVM_OPTS="$JVM_OPTS -XX:+PrintPromotionFailure"
-# JVM_OPTS="$JVM_OPTS -XX:PrintFLSStatistics=1"
-# JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/cassandra/gc-`date +%s`.log"
-# If you are using JDK 6u34 7u2 or later you can enable GC log rotation
-# don't stick the date in the log name if rotation is on.
-# JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/cassandra/gc.log"
-# JVM_OPTS="$JVM_OPTS -XX:+UseGCLogFileRotation"
-# JVM_OPTS="$JVM_OPTS -XX:NumberOfGCLogFiles=10"
-# JVM_OPTS="$JVM_OPTS -XX:GCLogFileSize=10M"
-
-# uncomment to have Cassandra JVM listen for remote debuggers/profilers on port 1414
-# JVM_OPTS="$JVM_OPTS -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1414"
-
-# Prefer binding to IPv4 network intefaces (when net.ipv6.bindv6only=1). See
-# http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6342561 (short version:
-# comment out this entry to enable IPv6 support).
-JVM_OPTS="$JVM_OPTS -Djava.net.preferIPv4Stack=true"
-
-# jmx: metrics and administration interface
-#
-# add this if you're having trouble connecting:
-# JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<public name>"
-#
-# see
-# https://blogs.oracle.com/jmxetc/entry/troubleshooting_connection_problems...
-# for more on configuring JMX through firewalls, etc. (Short version:
-# get it working with no firewall first.)
-JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT"
-JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false"
-JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
-JVM_OPTS="$JVM_OPTS $JVM_EXTRA_OPTS"
diff --git a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
index 63282e4..5c5ac4e 100644
--- a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
+++ b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
@@ -25,8 +25,10 @@
package org.rhq.storage.installer;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileReader;
import java.io.IOException;
import java.net.InetAddress;
import java.util.ArrayList;
@@ -250,15 +252,32 @@ public class StorageInstaller {
File oldConfDir = new File(existingStorageDir, "conf");
File newConfDir = new File(storageBasedir, "conf");
+ File cassandraEnvFile = new File(oldConfDir, "cassandra-env.sh");
+
String cassandraYaml = "cassandra.yaml";
String cassandraJvmProps = "cassandra-jvm.properties";
File cassandraJvmPropsFile = new File(newConfDir, cassandraJvmProps);
String log4j = "log4j-server.properties";
replaceFile(new File(oldConfDir, cassandraYaml), new File(newConfDir, cassandraYaml));
- replaceFile(new File(oldConfDir, cassandraJvmProps), cassandraJvmPropsFile);
replaceFile(new File(oldConfDir, log4j), new File(newConfDir, log4j));
+ if (cassandraEnvFile.exists()) {
+ // Then this is an RHQ 4.8 install
+ jmxPort = parseJmxPortFromCassandrEnv(cassandraEnvFile);
+ Properties jvmProps = new Properties();
+ jvmProps.load(new FileInputStream(cassandraJvmPropsFile));
+ PropertiesFileUpdate propertiesUpdater = new PropertiesFileUpdate(
+ cassandraJvmPropsFile.getAbsolutePath());
+ jvmProps.setProperty("jmx_port", Integer.toString(jmxPort));
+
+ propertiesUpdater.update(jvmProps);
+
+ } else {
+ jmxPort = parseJmxPort(cassandraJvmPropsFile);
+ replaceFile(new File(oldConfDir, cassandraJvmProps), cassandraJvmPropsFile);
+ }
+
log.info("Finished installing RHQ Storage Node.");
log.info("Updating rhq-server.properties...");
@@ -268,8 +287,6 @@ public class StorageInstaller {
Map<String, Object> config = (Map<String, Object>) yaml.load(new FileInputStream(yamlFile));
hostname = (String) config.get("listen_address");
-
- jmxPort = parseJmxPort(cassandraJvmPropsFile);
} else {
if (cmdLine.hasOption("dir")) {
File basedir = new File(cmdLine.getOptionValue("dir"));
@@ -661,6 +678,60 @@ public class StorageInstaller {
}
}
+ private int parseJmxPortFromCassandrEnv(File cassandraEnvFile) {
+ Integer port = null;
+ if (isWindows()) {
+ // TODO
+ return defaultJmxPort;
+ } else {
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new FileReader(cassandraEnvFile));
+ String line = reader.readLine();
+
+ while (line != null) {
+ if (line.startsWith("JMX_PORT")) {
+ int startIndex = "JMX_PORT=\"".length();
+ int endIndex = line.lastIndexOf("\"");
+
+ if (startIndex == -1 || endIndex == -1) {
+ log.error("Failed to parse the JMX port. Make sure that you have the JMX port defined on its "
+ + "own line as follows, JMX_PORT=\"<jmx-port>\"");
+ throw new RuntimeException("Cannot determine JMX port");
+ }
+ try {
+ port = Integer.parseInt(line.substring(startIndex, endIndex));
+ } catch (NumberFormatException e) {
+ log.error("The JMX port must be an integer. [" + port + "] is an invalid value");
+ throw new RuntimeException("The JMX port has an invalid value");
+ }
+ return port;
+ }
+ line = reader.readLine();
+ }
+ log.error("Failed to parse the JMX port. Make sure that you have the JMX port defined on its "
+ + "own line as follows, JMX_PORT=\"<jmx-port>\"");
+ throw new RuntimeException("Cannot determine JMX port");
+ } catch (IOException e) {
+ log.error("Failed to parse JMX port. There was an unexpected IO error", e);
+ throw new RuntimeException("Failed to parse JMX port due to IO error: " + e.getMessage());
+ } finally {
+ try {
+ if (reader != null) {
+ reader.close();
+ }
+ } catch (IOException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("An error occurred closing the " + BufferedReader.class.getName() + " used to "
+ + "parse the JMX port", e);
+ } else {
+ log.warn("There was error closing the reader used to parse the JMX port: " + e.getMessage());
+ }
+ }
+ }
+ }
+ }
+
private int parseJmxPort(File cassandraJvmOptsFile) {
Integer port = null;
if (isWindows()) {
diff --git a/modules/common/cassandra-installer/src/test/java/org/rhq/storage/installer/StorageInstallerTest.java b/modules/common/cassandra-installer/src/test/java/org/rhq/storage/installer/StorageInstallerTest.java
index 3fd13c7..a7921c0 100644
--- a/modules/common/cassandra-installer/src/test/java/org/rhq/storage/installer/StorageInstallerTest.java
+++ b/modules/common/cassandra-installer/src/test/java/org/rhq/storage/installer/StorageInstallerTest.java
@@ -2,11 +2,13 @@ package org.rhq.storage.installer;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Properties;
@@ -20,41 +22,53 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.rhq.cassandra.CassandraClusterManager;
+import org.rhq.core.util.MessageDigestGenerator;
import org.rhq.core.util.file.FileUtil;
+import org.rhq.core.util.stream.StreamUtil;
/**
* @author John Sanda
*/
public class StorageInstallerTest {
+ private MessageDigestGenerator digestGenerator;
+
private File basedir;
+ private File serverDir;
+
private File storageDir;
private StorageInstaller installer;
@BeforeMethod
public void initDirs(Method test) throws Exception {
+ digestGenerator = new MessageDigestGenerator(MessageDigestGenerator.SHA_256);
+
File dir = new File(getClass().getResource(".").toURI());
basedir = new File(dir, getClass().getSimpleName() + "/" + test.getName());
FileUtil.purge(basedir, true);
basedir.mkdirs();
- System.setProperty("rhq.server.basedir", basedir.getAbsolutePath());
+ serverDir = new File(basedir, "rhq-server");
- File serverPropsFile = new File(basedir, "rhq-server.properties");
+ System.setProperty("rhq.server.basedir", serverDir.getAbsolutePath());
+
+ File serverPropsFile = new File(serverDir, "rhq-server.properties");
FileUtils.touch(serverPropsFile);
System.setProperty("rhq.server.properties-file", serverPropsFile.getAbsolutePath());
- storageDir = new File(basedir, "rhq-storage");
+ storageDir = new File(serverDir, "rhq-storage");
installer = new StorageInstaller();
}
@AfterMethod
public void shutdownStorageNode() throws Exception {
- CassandraClusterManager ccm = new CassandraClusterManager();
- ccm.killNode(storageDir);
+ if (FileUtils.getFile(storageDir, "bin", "cassandra.pid").exists()) {
+ CassandraClusterManager ccm = new CassandraClusterManager();
+ ccm.killNode(storageDir);
+ }
}
@Test
@@ -97,6 +111,65 @@ public class StorageInstallerTest {
assertTrue(savedCachesDir.exists(), "Expected to find saved_caches directory at " + savedCachesDir);
}
+ @Test
+ public void upgradeFromRHQ48Install() throws Exception {
+ File rhq48ServerDir = new File(basedir, "rhq48-server");
+ File rhq48StorageDir = new File(rhq48ServerDir, "rhq-storage");
+ File rhq48StorageConfDir = new File(rhq48StorageDir, "conf");
+
+ File oldCassandraYamlFile = new File(rhq48StorageConfDir, "cassandra.yaml");
+ File oldCassandraEnvFile = new File(rhq48StorageConfDir, "cassandra-env.sh");
+ File oldLog4JFile = new File(rhq48StorageConfDir, "log4j-server.properties");
+
+ rhq48StorageConfDir.mkdirs();
+ StreamUtil.copy(getClass().getResourceAsStream("/rhq48/storage/conf/cassandra.yaml"),
+ new FileOutputStream(oldCassandraYamlFile), true);
+ StreamUtil.copy(getClass().getResourceAsStream("/rhq48/storage/conf/cassandra-env.sh"),
+ new FileOutputStream(oldCassandraEnvFile));
+ StreamUtil.copy(getClass().getResourceAsStream("/rhq48/storage/conf/log4j-server.properties"),
+ new FileOutputStream(oldLog4JFile));
+
+ CommandLineParser parser = new PosixParser();
+
+ String[] args = {
+ "--upgrade", rhq48ServerDir.getAbsolutePath(),
+ "--dir", storageDir.getAbsolutePath()
+ };
+
+ CommandLine cmdLine = parser.parse(installer.getOptions(), args);
+ int status = installer.run(cmdLine);
+
+ assertEquals(status, 0, "Expected to get back a status code of 0 for a successful upgrade");
+ assertNodeIsRunning();
+
+ File binDir = new File(storageDir, "bin");
+ assertTrue(binDir.exists(), "Expected to find bin directory at " + binDir);
+
+ File libDir = new File(storageDir, "lib");
+ assertTrue(libDir.exists(), "Expected to find lib directory at " + libDir);
+
+ File confDir = new File(storageDir, "conf");
+ assertTrue(confDir.exists(), "Expected to find conf directory at " + confDir);
+
+ File newCassandraYamlFile = new File(confDir, "cassandra.yaml");
+ assertEquals(sha256(oldCassandraYamlFile), sha256(newCassandraYamlFile), newCassandraYamlFile +
+ " does not match the original version");
+
+ File newLog4JFile = new File(confDir, "log4j-server.properties");
+ assertEquals(sha256(oldLog4JFile), sha256(newLog4JFile), newLog4JFile + " does not match the original version");
+
+ assertFalse(new File(confDir, "cassandra-env.sh").exists(), "cassandra-env.sh should not be used after RHQ 4.8.0");
+
+ File cassandraJvmPropsFile = new File(confDir, "cassandra-jvm.properties");
+ Properties properties = new Properties();
+ properties.load(new FileInputStream(cassandraJvmPropsFile));
+
+ // If this check fails, make sure that the expected value matches the value in
+ // src/test/resources/rhq48/storage/conf/cassandra-env.sh
+ assertEquals(properties.getProperty("jmx_port"), "7399", "Failed to update the JMX port in " +
+ cassandraJvmPropsFile);
+ }
+
private void assertNodeIsRunning() {
try {
installer.verifyNodeIsUp("127.0.0.1", 7299, 3, 1000);
@@ -106,7 +179,7 @@ public class StorageInstallerTest {
}
private void assertRhqServerPropsUpdated() {
- File serverPropsFile = new File(basedir, "rhq-server.properties");
+ File serverPropsFile = new File(serverDir, "rhq-server.properties");
Properties properties = new Properties();
try {
@@ -120,4 +193,12 @@ public class StorageInstallerTest {
assertEquals(seeds, "127.0.0.1|7299|9142");
}
+ private String sha256(File file) {
+ try {
+ return digestGenerator.calcDigestString(file);
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to calculate SHA-256 hash for " + file.getPath(), e);
+ }
+ }
+
}
commit 8ad6e86b9ba704eb468646fd7fffcf5dd082e2c4
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Jul 19 18:13:31 2013 +0200
Add annotation and processing for configuration properties. Also shuffle some classes around.
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/ConfigProperty.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/ConfigProperty.java
new file mode 100644
index 0000000..4b5a3ab
--- /dev/null
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/ConfigProperty.java
@@ -0,0 +1,49 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.helpers.pluginAnnotations.agent;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * A configuration property for resource or plugin config.
+ * Currently only property simple are supported.
+ * @author Heiko W. Rupp
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.FIELD})
+public @interface ConfigProperty {
+
+ public Scope scope() default Scope.PLUGIN;
+ String property() default "";
+ String displayName() default "";
+ String description() default "";
+ boolean readOnly() default false;
+ String defaultValue() default "";
+ RhqType rhqType() default RhqType.VOID;
+
+
+ public enum Scope {
+ PLUGIN,
+ RESOURCE;
+ }
+}
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/AnnotationProcessor.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/AnnotationProcessor.java
index 3c90b7b..16ec437 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/AnnotationProcessor.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/AnnotationProcessor.java
@@ -19,15 +19,23 @@
package org.rhq.helpers.pluginGen;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
import java.util.List;
+import org.rhq.helpers.pluginAnnotations.agent.ConfigProperty;
+import org.rhq.helpers.pluginAnnotations.agent.Metric;
+import org.rhq.helpers.pluginAnnotations.agent.Operation;
+import org.rhq.helpers.pluginAnnotations.agent.Parameter;
+import org.rhq.helpers.pluginAnnotations.agent.RhqType;
+
/**
* Processor that scans a directory for annotated classes and generates metrics etc. from them.
* @author Heiko W. Rupp
*/
public class AnnotationProcessor {
- private List<Class> classList;
private final DirectoryClassLoader classLoader;
public AnnotationProcessor(String baseDirectory) {
@@ -36,9 +44,119 @@ public class AnnotationProcessor {
}
public void populate(Props props) {
- classList = classLoader.findClasses();
+ List<Class> classList = classLoader.findClasses();
+
+ populateMetrics(props, classList);
+ populateOperations(props, classList);
+ populateConfigurations(props, classList);
+ }
+
+ public void populateMetrics(Props props, List<Class> classes) {
+ for (Class<?> clazz : classes) {
+ for (Field field : clazz.getDeclaredFields()) {
+ Metric metricAnnot = field.getAnnotation(Metric.class);
+ addMetric(props, metricAnnot, field.getName());
+ }
+
+ for (Method method : clazz.getDeclaredMethods()) {
+ Metric metricAnnot = method.getAnnotation(Metric.class);
+ addMetric(props, metricAnnot, method.getName());
+ }
+ }
+ }
+
+ public void populateOperations(Props props, List<Class> classes) {
+ for (Class<?> clazz : classes) {
+ for (Method method : clazz.getDeclaredMethods()) {
+ Operation operationAnnot = method.getAnnotation(Operation.class);
+ if (operationAnnot != null) {
+ String property = operationAnnot.name();
+ if (property.isEmpty()) {
+ property = method.getName();
+ }
+ Props.OperationProps op = new Props.OperationProps(property);
+ op.setDisplayName(operationAnnot.displayName());
+ op.setDescription(operationAnnot.description());
+ RhqType type = RhqType.findType(method.getReturnType());
+ if (type != RhqType.VOID) {
+ Props.SimpleProperty simpleProperty = new Props.SimpleProperty(type.getRhqName());
+ op.setResult(simpleProperty);
+ }
- props.populateMetrics(classList);
- props.populateOperations(classList);
+ Class[] types = method.getParameterTypes();
+ int i=0;
+ for (Annotation[] annotations : method.getParameterAnnotations() ) {
+ for (Annotation annotation : annotations) {
+ if (annotation instanceof Parameter) {
+ Parameter parameter = (Parameter) annotation;
+ Props.SimpleProperty simpleProperty = new Props.SimpleProperty(parameter.name());
+ simpleProperty.setDescription(parameter.description());
+ Class typeClass = types[i];
+ RhqType rhqType = RhqType.findType(typeClass);
+ if (parameter.type()!=RhqType.VOID){
+ rhqType = parameter.type();
+ }
+ simpleProperty.setType(rhqType.getRhqName());
+ op.getParams().add(simpleProperty);
+ }
+ }
+ i++;
+ }
+ props.getOperations().add(op);
+ }
+
+ }
+ }
+ }
+
+ public void populateConfigurations(Props props, List<Class> classes) {
+ for (Class<?> clazz : classes) {
+ for (Field field : clazz.getDeclaredFields()) {
+ ConfigProperty configProperty = field.getAnnotation(ConfigProperty.class);
+ if (configProperty!=null) {
+ String name = configProperty.property();
+ if(name.isEmpty()) {
+ name = field.getName();
+ }
+ Props.SimpleProperty property = new Props.SimpleProperty(name);
+ property.setDescription(configProperty.description());
+ property.setDisplayName(configProperty.displayName());
+ Class type = field.getType();
+ RhqType rhqType = RhqType.findType(type);
+ if (configProperty.rhqType()!=RhqType.VOID) {
+ rhqType = configProperty.rhqType();
+ }
+ property.setType(rhqType.getRhqName());
+
+ switch (configProperty.scope()){
+ case PLUGIN:
+ props.getPluginConfig().add(property);
+ break;
+ case RESOURCE:
+ props.getResourceConfig().add(property);
+ break;
+ default:
+ throw new IllegalStateException("Unknown scope: " +configProperty.scope().name());
+ }
+ }
+ }
+ }
}
+
+ private void addMetric(Props props, Metric metricAnnot, String name) {
+ if (metricAnnot != null) {
+ String property = metricAnnot.property();
+ if (property.isEmpty()) {
+ property = name;
+ }
+ Props.MetricProps metric = new Props.MetricProps(property);
+ metric.setDisplayName(metricAnnot.displayName());
+ metric.setDisplayType(metricAnnot.displayType());
+ metric.setDataType(metricAnnot.dataType());
+ metric.setDescription(metricAnnot.description());
+ metric.setUnits(metricAnnot.units());
+ props.getMetrics().add(metric);
+ }
+ }
+
}
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
index 95be574..c88fbc0 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
@@ -18,20 +18,12 @@
*/
package org.rhq.helpers.pluginGen;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.LinkedHashSet;
-import java.util.List;
import java.util.Set;
import org.rhq.helpers.pluginAnnotations.agent.DataType;
import org.rhq.helpers.pluginAnnotations.agent.DisplayType;
-import org.rhq.helpers.pluginAnnotations.agent.Metric;
-import org.rhq.helpers.pluginAnnotations.agent.Operation;
-import org.rhq.helpers.pluginAnnotations.agent.Parameter;
-import org.rhq.helpers.pluginAnnotations.agent.RhqType;
import org.rhq.helpers.pluginAnnotations.agent.Units;
/**
@@ -94,7 +86,8 @@ public class Props {
/** Embedded children */
private Set<Props> children = new HashSet<Props>();
- private Set<SimpleProperty> simpleProps = new LinkedHashSet<SimpleProperty>();
+ private Set<SimpleProperty> pluginConfig = new LinkedHashSet<SimpleProperty>();
+ private Set<SimpleProperty> resourceConfig = new LinkedHashSet<SimpleProperty>();
private Set<Template> templates = new HashSet<Template>();
@@ -291,12 +284,12 @@ public class Props {
this.rhqVersion = rhqVersion;
}
- public Set<SimpleProperty> getSimpleProps() {
- return simpleProps;
+ public Set<SimpleProperty> getPluginConfig() {
+ return pluginConfig;
}
- public void setSimpleProps(Set<SimpleProperty> simpleProps) {
- this.simpleProps = simpleProps;
+ public void setPluginConfig(Set<SimpleProperty> pluginConfig) {
+ this.pluginConfig = pluginConfig;
}
public Set<Template> getTemplates() {
@@ -307,7 +300,15 @@ public class Props {
this.templates = templates;
}
- public Set<MetricProps> getMetrics() {
+ public Set<SimpleProperty> getResourceConfig() {
+ return resourceConfig;
+ }
+
+ public void setResourceConfig(Set<SimpleProperty> resourceConfig) {
+ this.resourceConfig = resourceConfig;
+ }
+
+ public Set<MetricProps> getMetrics() {
return metrics;
}
@@ -363,79 +364,6 @@ public class Props {
this.scanForAnnotations = scanForAnnotations;
}
- public void populateMetrics(List<Class> classes) {
- for (Class<?> clazz : classes) {
- for (Field field : clazz.getDeclaredFields()) {
- Metric metricAnnot = field.getAnnotation(Metric.class);
- addMetric(metricAnnot, field.getName());
- }
-
- for (Method method : clazz.getDeclaredMethods()) {
- Metric metricAnnot = method.getAnnotation(Metric.class);
- addMetric(metricAnnot, method.getName());
- }
- }
- }
-
- public void populateOperations(List<Class> classes) {
- for (Class<?> clazz : classes) {
- for (Method method : clazz.getDeclaredMethods()) {
- Operation operationAnnot = method.getAnnotation(Operation.class);
- if (operationAnnot != null) {
- String property = operationAnnot.name();
- if (property.isEmpty()) {
- property = method.getName();
- }
- OperationProps op = new OperationProps(property);
- op.setDisplayName(operationAnnot.displayName());
- op.setDescription(operationAnnot.description());
- RhqType type = RhqType.findType(method.getReturnType());
- if (type != RhqType.VOID) {
- SimpleProperty simpleProperty = new SimpleProperty(type.getRhqName());
- op.setResult(simpleProperty);
- }
-
- Class[] types = method.getParameterTypes();
- int i=0;
- for (Annotation[] annotations : method.getParameterAnnotations() ) {
- for (Annotation annotation : annotations) {
- if (annotation instanceof Parameter) {
- Parameter parameter = (Parameter) annotation;
- SimpleProperty simpleProperty = new SimpleProperty(parameter.name());
- simpleProperty.setDescription(parameter.description());
- Class typeClass = types[i];
- RhqType rhqType = RhqType.findType(typeClass);
- if (parameter.type()!=RhqType.VOID){
- rhqType = parameter.type();
- }
- simpleProperty.setType(rhqType.getRhqName());
- op.getParams().add(simpleProperty);
- }
- }
- i++;
- }
- operations.add(op);
- }
-
- }
- }
- }
-
- private void addMetric(Metric metricAnnot, String name) {
- if (metricAnnot != null) {
- String property = metricAnnot.property();
- if (property.isEmpty()) {
- property = name;
- }
- MetricProps metric = new MetricProps(property);
- metric.setDisplayName(metricAnnot.displayName());
- metric.setDisplayType(metricAnnot.displayType());
- metric.setDataType(metricAnnot.dataType());
- metric.setDescription(metricAnnot.description());
- metric.setUnits(metricAnnot.units());
- metrics.add(metric);
- }
- }
@Override
public String toString() {
@@ -466,7 +394,7 @@ public class Props {
sb.append(", dependsOnJmxPlugin=").append(dependsOnJmxPlugin);
sb.append(", rhqVersion='").append(rhqVersion).append('\'');
sb.append(", children=").append(children);
- sb.append(", simpleProps=").append(simpleProps);
+ sb.append(", simpleProps=").append(pluginConfig);
sb.append(", templates=").append(templates);
sb.append(", runsInsides=").append(runsInsides);
sb.append('}');
diff --git a/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl b/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
index 5579806..ce35ebe 100644
--- a/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
+++ b/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
@@ -45,9 +45,9 @@ name="${props.name}"
</runs-inside>
</#if>
- <#if props.simpleProps?has_content>
+ <#if props.pluginConfig?has_content>
<plugin-configuration>
- <#list props.simpleProps as simpleProps>
+ <#list props.pluginConfig as simpleProps>
<c:simple-property name="${simpleProps.name}" description="${simpleProps.description}" <#if simpleProps.type??>type="${simpleProps.type}"</#if> <#if simpleProps.readOnly>readOnly="true"</#if>/>
</#list>
<!-- The template section is only for manual resource additions, and default parameters and the ones presented to the user. -->
@@ -106,4 +106,12 @@ name="${props.name}"
<!-- TODO supply your configuration parameters -->
<c:simple-property name="dummy"/>
</resource-configuration>
- </#if>
\ No newline at end of file
+ </#if>
+
+<#if props.resourceConfig?has_content>
+ <resource-configuration>
+ <#list props.resourceConfig as simpleProps>
+ <c:simple-property name="${simpleProps.name}" description="${simpleProps.description}" <#if simpleProps.type??>type="${simpleProps.type}"</#if> <#if simpleProps.readOnly>readOnly="true"</#if>/>
+ </#list>
+ </resource-configuration>
+</#if>
diff --git a/modules/helpers/pluginGen/src/test/java/org/rhq/helpers/pluginGen/test/FooBean.java b/modules/helpers/pluginGen/src/test/java/org/rhq/helpers/pluginGen/test/FooBean.java
index fbc571b..5027dbb 100644
--- a/modules/helpers/pluginGen/src/test/java/org/rhq/helpers/pluginGen/test/FooBean.java
+++ b/modules/helpers/pluginGen/src/test/java/org/rhq/helpers/pluginGen/test/FooBean.java
@@ -19,6 +19,7 @@
package org.rhq.helpers.pluginGen.test;
+import org.rhq.helpers.pluginAnnotations.agent.ConfigProperty;
import org.rhq.helpers.pluginAnnotations.agent.DataType;
import org.rhq.helpers.pluginAnnotations.agent.DisplayType;
import org.rhq.helpers.pluginAnnotations.agent.MeasurementType;
@@ -26,6 +27,7 @@ import org.rhq.helpers.pluginAnnotations.agent.Metric;
import org.rhq.helpers.pluginAnnotations.agent.Operation;
import org.rhq.helpers.pluginAnnotations.agent.Parameter;
import org.rhq.helpers.pluginAnnotations.agent.RhqType;
+import org.rhq.helpers.pluginAnnotations.agent.Units;
/**
* Just a sample
@@ -34,7 +36,8 @@ import org.rhq.helpers.pluginAnnotations.agent.RhqType;
public class FooBean {
- @Metric(description = "How often was this bean invoked", displayType = DisplayType.SUMMARY, measurementType = MeasurementType.DYNAMIC)
+ @Metric(description = "How often was this bean invoked", displayType = DisplayType.SUMMARY, measurementType = MeasurementType.DYNAMIC,
+ units = Units.SECONDS)
int invocationCount;
@Metric(description = "Just a foo", dataType = DataType.TRAIT)
@@ -51,5 +54,11 @@ public class FooBean {
invocationCount -= by;
}
+ @ConfigProperty(scope = ConfigProperty.Scope.PLUGIN, displayName="The Password",
+ readOnly = false, property="thePassword",description = "A password", rhqType = RhqType.PASSWORD)
+ String password;
+
+ @ConfigProperty(scope = ConfigProperty.Scope.RESOURCE)
+ int defaultSteps;
}
commit 039a42a2e696bb1bb0b170bec87ed95fe13921e2
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Fri Jul 19 16:40:48 2013 +0200
API Checks - Changing StorageNode.QUERY_FIND_BY_ADDRESS. The constants for native queries shouldn't be part of the public API.
diff --git a/modules/core/domain/intentional-api-changes-since-4.8.0.xml b/modules/core/domain/intentional-api-changes-since-4.8.0.xml
index f21a45f..a8a77b4 100644
--- a/modules/core/domain/intentional-api-changes-since-4.8.0.xml
+++ b/modules/core/domain/intentional-api-changes-since-4.8.0.xml
@@ -1,3 +1,11 @@
<?xml version="1.0"?>
<differences>
+ <difference>
+ <className>org/rhq/core/domain/cloud/StorageNode</className>
+ <differenceType>6003</differenceType><!-- Value of compile-time constant has changed -->
+ <field>QUERY_FIND_BY_ADDRESS</field>
+ <justification>
+ Changing StorageNode.QUERY_FIND_BY_ADDRESS. The constants for native queries shouldn't be part of the public API.
+ </justification>
+ </difference>
</differences>
commit 78eb557ae8f799b628769d76ccece61b6cb452a4
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Fri Jul 19 16:17:53 2013 +0200
[BZ 959587] - Alert definition should display units when entering a value; e.g. 'seconds' or 'megabytes' - Adding "BaseUnits" field to the popup form. The tooltip displays all allowed units from the same MeasurementUnits.Family.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementUnits.java b/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementUnits.java
index 31811ab..d66f23b 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementUnits.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementUnits.java
@@ -22,6 +22,9 @@
*/
package org.rhq.core.domain.measurement;
+import java.util.ArrayList;
+import java.util.List;
+
import org.rhq.core.domain.measurement.util.MeasurementConversionException;
/**
@@ -117,6 +120,16 @@ public enum MeasurementUnits {
return null;
}
+
+ public List<MeasurementUnits> getFamilyUnits() {
+ List<MeasurementUnits> returnList = new ArrayList<MeasurementUnits>();
+ for (MeasurementUnits units : MeasurementUnits.values()) {
+ if (units.family == family) {
+ returnList.add(units);
+ }
+ }
+ return returnList;
+ }
public boolean isComparableTo(MeasurementUnits other) {
return family == other.family;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionEditor.java
index 870140d..f4fbcad 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionEditor.java
@@ -44,6 +44,8 @@ import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.SpacerItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.toolbar.ToolStrip;
@@ -613,6 +615,7 @@ public class ConditionEditor extends EnhancedVLayout {
}
absoluteValue.setShowIfCondition(ifFunc);
formItems.add(absoluteValue);
+ formItems.add(buildBaseUnitsItem(metricDropDownMenu, ifFunc, editMode));
} else {
String noMetricsStr = MSG.view_alert_definition_condition_editor_metric_nometrics();
StaticTextItem noMetrics = buildHelpTextItem(THRESHOLD_NO_METRICS_ITEMNAME, noMetricsStr, ifFunc);
@@ -663,6 +666,7 @@ public class ConditionEditor extends EnhancedVLayout {
formItems.add(absoluteLowValue);
formItems.add(absoluteHighValue);
+ formItems.add(buildBaseUnitsItem(metricDropDownMenu, ifFunc, editMode));
} else {
String noMetricsStr = MSG.view_alert_definition_condition_editor_metric_nometrics();
StaticTextItem noMetrics = buildHelpTextItem(RANGE_NO_METRICS_ITEMNAME, noMetricsStr, ifFunc);
@@ -1220,6 +1224,40 @@ public class ConditionEditor extends EnhancedVLayout {
return comparatorSelection;
}
+ private StaticTextItem buildBaseUnitsItem(final SelectItem metricDropDownMenu, FormItemIfFunction ifFunc,
+ boolean editMode) {
+ String baseUnits = MSG.view_alert_definition_condition_editor_common_baseUnits();
+ final StaticTextItem baseUnitsItem = new StaticTextItem("baseUnits", baseUnits);
+ baseUnitsItem.setHoverWidth(200);
+ baseUnitsItem.setShowIfCondition(ifFunc);
+
+ metricDropDownMenu.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ MeasurementDefinition measDef = getMeasurementDefinition(form.getValueAsString(metricDropDownMenu
+ .getName()));
+ baseUnitsItem.setValue(measDef.getUnits() == MeasurementUnits.NONE ? MSG
+ .view_alert_definition_condition_editor_common_baseUnits_none()
+ : measDef.getUnits() == MeasurementUnits.MILLISECONDS ? MeasurementUnits.SECONDS : measDef
+ .getUnits());
+ List<MeasurementUnits> availableUnits = measDef.getUnits().getFamilyUnits();
+ baseUnitsItem.setTooltip(MSG.view_alert_definition_condition_editor_common_baseUnits_availableUnits()
+ + (availableUnits.isEmpty() || availableUnits.get(0) == MeasurementUnits.NONE ? MSG
+ .view_alert_definition_condition_editor_common_baseUnits_none() : availableUnits));
+ }
+ });
+ // initialize the field with proper value
+ MeasurementUnits units = editMode ? existingCondition.getMeasurementDefinition().getUnits()
+ : ConditionEditor.this.resourceType.getMetricDefinitions().iterator().next().getUnits();
+ baseUnitsItem.setValue(units == MeasurementUnits.NONE ? MSG
+ .view_alert_definition_condition_editor_common_baseUnits_none()
+ : units == MeasurementUnits.MILLISECONDS ? MeasurementUnits.SECONDS : units);
+ List<MeasurementUnits> availableUnits = units.getFamilyUnits();
+ baseUnitsItem.setTooltip(MSG.view_alert_definition_condition_editor_common_baseUnits_availableUnits()
+ + (availableUnits.isEmpty() || availableUnits.get(0) == MeasurementUnits.NONE ? MSG
+ .view_alert_definition_condition_editor_common_baseUnits_none() : availableUnits));
+ return baseUnitsItem;
+ }
+
private StaticTextItem buildHelpTextItem(String itemName, String helpText, FormItemIfFunction ifFunc) {
StaticTextItem help = new StaticTextItem(itemName);
help.setShowTitle(false);
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 ed6b130..19d3fa5 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
@@ -919,6 +919,9 @@ view_alert_definition_condition_editor_availabilityDuration_tooltip_duration = T
view_alert_definition_condition_editor_availability_tooltip = Specify the availability state change that will trigger the condition.
view_alert_definition_condition_editor_availability_value = Availability
view_alert_definition_condition_editor_common_avg = Average
+view_alert_definition_condition_editor_common_baseUnits = Base Units
+view_alert_definition_condition_editor_common_baseUnits_availableUnits = Available units:
+view_alert_definition_condition_editor_common_baseUnits_none = None
view_alert_definition_condition_editor_common_max = Maximum
view_alert_definition_condition_editor_common_min = Minimum
view_alert_definition_condition_editor_common_regex = Regular Expression
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
index 1950003..f71f907 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
@@ -933,6 +933,9 @@ view_alert_definition_condition_editor_availabilityDuration_tooltip_duration = P
view_alert_definition_condition_editor_availability_tooltip = Specifikujte stav dostupnosti, který poté splní podmínku.
view_alert_definition_condition_editor_availability_value = Dostupnost
view_alert_definition_condition_editor_common_avg = Průměr
+view_alert_definition_condition_editor_common_baseUnits = Základní jednotky
+view_alert_definition_condition_editor_common_baseUnits_availableUnits = Dostupné jednotky:
+view_alert_definition_condition_editor_common_baseUnits_none = Źádné
view_alert_definition_condition_editor_common_max = Maximum
view_alert_definition_condition_editor_common_min = Minimum
view_alert_definition_condition_editor_common_regex = Regulární výraz
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 bd8e0b4..524dcc0 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
@@ -844,6 +844,9 @@ view_alert_definition_condition_editor_avilability_option_up = Wird verfügbar
view_alert_definition_condition_editor_avilability_tooltip = Geben Sie die Änderung der Verfügbarkeit an, die die Bedingung auslösen soll.
view_alert_definition_condition_editor_avilability_value = Verfügbarkeit
view_alert_definition_condition_editor_common_avg = Durchschnitt
+##view_alert_definition_condition_editor_common_baseUnits = Base Units
+##view_alert_definition_condition_editor_common_baseUnits_availableUnits = Available units:
+##view_alert_definition_condition_editor_common_baseUnits_none = None
view_alert_definition_condition_editor_common_max = Maximum
view_alert_definition_condition_editor_common_min = Minimum
view_alert_definition_condition_editor_common_regex = Regulärer Ausdruck
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 1c0005b..cb0c35f 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
@@ -908,6 +908,9 @@ view_alert_definition_condition_editor_availabilityDuration_tooltip_duration =
view_alert_definition_condition_editor_availability_tooltip = 条件のトリガーとなるアベイラビリティ状態の変化を指定します
view_alert_definition_condition_editor_availability_value = アベイラビリティ
view_alert_definition_condition_editor_common_avg = 平均
+##view_alert_definition_condition_editor_common_baseUnits = Base Units
+##view_alert_definition_condition_editor_common_baseUnits_availableUnits = Available units:
+##view_alert_definition_condition_editor_common_baseUnits_none = None
view_alert_definition_condition_editor_common_max = 最大
view_alert_definition_condition_editor_common_min = 最小
view_alert_definition_condition_editor_common_regex = 正規表現
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
index 5118a2d..32dc73d 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
@@ -797,6 +797,9 @@ view_alert_definition_condition_editor_availabilityDuration_tooltip_duration =
view_alert_definition_condition_editor_availability_tooltip = 조건 트리거하는 가용성 상태의 변화를 지정합니다.
view_alert_definition_condition_editor_availability_value = 가용성
view_alert_definition_condition_editor_common_avg = 평균
+##view_alert_definition_condition_editor_common_baseUnits = Base Units
+##view_alert_definition_condition_editor_common_baseUnits_availableUnits = Available units:
+##view_alert_definition_condition_editor_common_baseUnits_none = None
view_alert_definition_condition_editor_common_max = 최대
view_alert_definition_condition_editor_common_min = 최소
view_alert_definition_condition_editor_common_regex = 정규 표현식
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 bfd95e8..f4419e1 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
@@ -916,6 +916,9 @@ view_alert_common_tab_recovery = Recupera\u00E7\u00E3o
view_alert_definition_condition_editor_availability_tooltip = Especifica a mudan\u00E7a de estado na disponibilidade do recurso que ir\u00E1 disparar a condi\u00E7\u00E3o.
view_alert_definition_condition_editor_availability_value = Disponibilidade
view_alert_definition_condition_editor_common_avg = M\u00E9dio
+##view_alert_definition_condition_editor_common_baseUnits = Base Units
+##view_alert_definition_condition_editor_common_baseUnits_availableUnits = Available units:
+##view_alert_definition_condition_editor_common_baseUnits_none = None
view_alert_definition_condition_editor_common_max = M\u00E1ximo
view_alert_definition_condition_editor_common_min = M\u00EDnimo
view_alert_definition_condition_editor_common_regex = Express\u00E3o Regular
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
index e03e1a9..d75b76e 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
@@ -881,6 +881,9 @@
#view_alert_definition_condition_editor_availability_tooltip = Specify the availability state change that will trigger the condition.
#view_alert_definition_condition_editor_availability_value = Availability
#view_alert_definition_condition_editor_common_avg = Average
+##view_alert_definition_condition_editor_common_baseUnits = Base Units
+##view_alert_definition_condition_editor_common_baseUnits_availableUnits = Available units:
+##view_alert_definition_condition_editor_common_baseUnits_none = None
#view_alert_definition_condition_editor_common_max = Maximum
#view_alert_definition_condition_editor_common_min = Minimum
#view_alert_definition_condition_editor_delete_confirm = Delete the selected alert condition(s)?
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 82ddc2a..a9a24df 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
@@ -902,6 +902,9 @@ view_alert_common_tab_recovery = \u8fd8\u539f
view_alert_definition_condition_editor_availability_tooltip = Specify the availability state change that will trigger the condition.
view_alert_definition_condition_editor_availability_value = \u53ef\u7528\u6027
view_alert_definition_condition_editor_common_avg = \u5e73\u5747
+##view_alert_definition_condition_editor_common_baseUnits = Base Units
+##view_alert_definition_condition_editor_common_baseUnits_availableUnits = Available units:
+##view_alert_definition_condition_editor_common_baseUnits_none = None
view_alert_definition_condition_editor_common_max = \u6700\u5927
view_alert_definition_condition_editor_common_min = \u6700\u5c0f
view_alert_definition_condition_editor_common_regex = \u6b63\u5219\u8868\u8fbe\u5f0f
commit 1f6cf05d57599ded2d196241284b4b5167886c80
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Fri Jul 19 12:43:35 2013 +0200
[BZ 980091] - link in the alert to the parent on which the alert was created - Adding the link to AlertDetailsView if the alert is defined by parent definition. Parent definition could mean group alert definition, autogroup alert definition or template definition
diff --git a/modules/enterprise/gui/coregui/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/modules/enterprise/gui/coregui/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch
new file mode 100644
index 0000000..627021f
--- /dev/null
+++ b/modules/enterprise/gui/coregui/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="org.eclipse.wst.jsdt.core.javascriptValidator"/>
+<mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
+</launchConfiguration>
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
index 17dd6d6..d66baea 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
@@ -57,6 +57,7 @@ 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.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.admin.templates.AlertDefinitionTemplateTypeView;
import org.rhq.enterprise.gui.coregui.client.components.form.DateFilterItem;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.AlertGWTServiceAsync;
@@ -74,6 +75,8 @@ import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
* @author John Mazzitelli
*/
public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> {
+
+ private static final String FIELD_PARENT = "parent"; // may be template or group alert def parent
public static final String PRIORITY_ICON_HIGH = ImageManager.getAlertIcon(AlertPriority.HIGH);
public static final String PRIORITY_ICON_MEDIUM = ImageManager.getAlertIcon(AlertPriority.MEDIUM);
@@ -359,6 +362,7 @@ public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> {
}
criteria.addFilterEntityContext(entityContext);
criteria.fetchConditionLogs(true);
+// criteria.fetchGroupAlertDefinition(true);
return criteria;
}
@@ -410,6 +414,22 @@ public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> {
record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());
+ AlertDefinition groupAlertDefinition = alertDefinition.getGroupAlertDefinition();
+ Integer parentId = alertDefinition.getParentId();
+ if (groupAlertDefinition != null && groupAlertDefinition.getGroup() != null) {
+ boolean isAutogroup = groupAlertDefinition.getGroup().getAutoGroupParentResource() != null;
+ record.setAttribute(FIELD_PARENT, (isAutogroup ? "#Resource/AutoGroup/" : "#ResourceGroup/")
+ + groupAlertDefinition.getGroup().getId() + "/Alerts/Definitions/" + groupAlertDefinition.getId());
+ record.setLinkText(MSG.view_alert_definition_for_group());
+ } else if (parentId != null && parentId.intValue() != 0) {
+ record.setAttribute(
+ FIELD_PARENT,
+ LinkManager.getAdminTemplatesEditLink(AlertDefinitionTemplateTypeView.VIEW_ID.getName(), resource
+ .getResourceType().getId())
+ + "/" + parentId);
+ record.setLinkText(MSG.view_alert_definition_for_type());
+ }
+
Set<AlertConditionLog> conditionLogs = from.getConditionLogs();
String conditionText;
String conditionValue;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java
index 68a0953..ed98d94 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java
@@ -40,8 +40,12 @@ import com.smartgwt.client.widgets.tab.Tab;
import com.smartgwt.client.widgets.tab.TabSet;
import org.rhq.core.domain.alert.Alert;
+import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.notification.ResultState;
import org.rhq.core.domain.criteria.AlertCriteria;
+import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
+import org.rhq.core.domain.criteria.ResourceGroupCriteria;
+import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
@@ -83,7 +87,14 @@ public class AlertDetailsView extends EnhancedVLayout implements BookmarkableVie
@Override
public void onSuccess(PageList<Alert> result) {
Alert alert = result.get(0);
- show(alert);
+ Integer parentId = alert.getAlertDefinition().getParentId();
+ AlertDefinition groupAlertDefinition = alert.getAlertDefinition().getGroupAlertDefinition();
+ if (groupAlertDefinition != null || (parentId != null && parentId.intValue() != 0)) {
+ fetchDefinitionWithGroupAndTemplate(alert);
+ } else {
+ show(alert);
+ }
+
}
@Override
@@ -92,6 +103,24 @@ public class AlertDetailsView extends EnhancedVLayout implements BookmarkableVie
}
});
}
+
+ private void fetchDefinitionWithGroupAndTemplate(final Alert alert) {
+ AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
+ criteria.addFilterAlertId(alert.getId());
+ criteria.fetchGroupAlertDefinition(true);
+ criteria.fetchResourceType(true);
+ GWTServiceLookup.getAlertDefinitionService().findAlertDefinitionsByCriteria(criteria, new AsyncCallback<PageList<AlertDefinition>>() {
+ public void onSuccess(PageList<AlertDefinition> result) {
+ alert.getAlertDefinition().setGroupAlertDefinition(result.get(0).getGroupAlertDefinition());
+ alert.getAlertDefinition().setResourceType(result.get(0).getResourceType());
+ show(alert);
+ }
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_alert_details_loadFailed(), caught);
+ }
+ });
+ }
private void show(Alert alert) {
destroyMembers();
@@ -102,7 +131,7 @@ public class AlertDetailsView extends EnhancedVLayout implements BookmarkableVie
addMember(getDetailsTabSet(record));
}
- private TabSet getDetailsTabSet(Record record) {
+ private TabSet getDetailsTabSet(ListGridRecord record) {
TabSet tabset = new NamedTabSet();
Tab generalTab = new NamedTab(new ViewName("general", MSG.view_alert_common_tab_general()));
@@ -121,7 +150,7 @@ public class AlertDetailsView extends EnhancedVLayout implements BookmarkableVie
return tabset;
}
- private DynamicForm getDetailsTableForAlert(Record record) {
+ private DynamicForm getDetailsTableForAlert(ListGridRecord record) {
DynamicForm form = new DynamicForm();
form.setNumCols(4);
form.setHeight("15%");
@@ -189,6 +218,13 @@ public class AlertDetailsView extends EnhancedVLayout implements BookmarkableVie
MSG.view_alert_details_field_resource_ancestry());
resourceAncestryItem.setValue(record.getAttribute("resourceAncestry"));
items.add(resourceAncestryItem);
+
+ String parentUrl = record.getAttribute("parent");
+ if (parentUrl != null) {
+ StaticTextItem parentItem = new StaticTextItem("parent", "Parent Definition");
+ parentItem.setValue(LinkManager.getHref(parentUrl, record.getLinkText()));
+ items.add(parentItem);
+ }
form.setItems(items.toArray(new FormItem[items.size()]));
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 84e9c6e..ed6b130 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
@@ -1080,6 +1080,7 @@ view_alert_definitions_update_failure = Alert definition update failed
view_alert_definitions_update_success = Alert definition successfully updated
view_alert_details_field_ack_at = Acknowledged at
view_alert_details_field_ack_by = Acknowledged by
+view_alert_details_field_parent_definition = Parent definition
view_alert_details_field_recovery_info = Recovery Info
view_alert_details_field_resource_ancestry = Resource Ancestry
view_alert_details_field_watched_resource = Watched Resource
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
index d6a102b..1950003 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
@@ -1094,6 +1094,7 @@ view_alert_definitions_update_failure = Nepodařilo se změnit definici výstrah
view_alert_definitions_update_success = Úspěšně změněna definice výstrahy
view_alert_details_field_ack_at = Potvrzeno v
view_alert_details_field_ack_by = Potvrzeno kým
+view_alert_details_field_parent_definition = Definice rodiče
view_alert_details_field_recovery_info = Informace o obnově
view_alert_details_field_resource_ancestry = Původ zdroje
view_alert_details_field_watched_resource = Sledovaný zdroj
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 9237f76..1c0005b 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
@@ -1069,6 +1069,7 @@ view_alert_definitions_update_failure = アラート定義の更新に失敗し
view_alert_definitions_update_success = アラート定義の更新に成功しました
view_alert_details_field_ack_at = 次の場所で確認済みです
view_alert_details_field_ack_by = 次の人によって確認済みです
+##view_alert_details_field_parent_definition = Parent definition
view_alert_details_field_recovery_info = リカバリ情報
##view_alert_details_field_resource_ancestry = Resource Ancestry
##view_alert_details_field_watched_resource = Watched Resource
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
index bd34f9b..5118a2d 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
@@ -935,6 +935,7 @@ view_alert_definitions_table_title_group = 그룹 경고 정의
view_alert_definitions_table_title_resource = 리소스 경고 정의
view_alert_details_field_ack_at = 다음 위치에서 확인했습니다
view_alert_details_field_ack_by = 다음 사람에 의해 확인되었습니다
+##view_alert_details_field_parent_definition = Parent definition
view_alert_details_field_recovery_info = 복구 정보
view_alert_details_field_resource_ancestry = 리소스 조상
view_alert_details_field_watched_resource = 관심 리소스
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 1330eb7..bfd95e8 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
@@ -1078,6 +1078,7 @@ view_alert_definitions_update_success = Defini\u00E7\u00E3o do alerta atualizada
view_alert_details_breadcrumb = Detalhes
view_alert_details_field_ack_at = Verificado em
view_alert_details_field_ack_by = Verificado por
+##view_alert_details_field_parent_definition = Parent definition
view_alert_details_field_recovery_info = Informa\u00E7\u00E3o de Recupera\u00E7\u00E3o
##view_alert_details_field_resource_ancestry = Resource Ancestry
##view_alert_details_field_watched_resource = Watched Resource
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
index 72a287b..e03e1a9 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
@@ -1042,6 +1042,7 @@
#view_alert_definitions_update_success = Alert definition successfully updated
#view_alert_details_field_ack_at = Acknowledged at
#view_alert_details_field_ack_by = Acknowledged by
+##view_alert_details_field_parent_definition = Parent definition
#view_alert_details_field_recovery_info = Recovery Info
#view_alert_details_loadFailed = Failed to fetch alert details
#view_alerts_ack_confirm = Acknowledge the selected alert(s)?
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 10f9b0a..82ddc2a 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
@@ -1063,6 +1063,7 @@ view_alert_definitions_update_failure = \u544a\u8b66\u5b9a\u4e49\u66f4\u65b0\u59
view_alert_definitions_update_success = \u544a\u8b66\u5b9a\u4e49\u66f4\u65b0\u6210\u529f
view_alert_details_field_ack_at = \u786e\u8ba4\u4e8e
view_alert_details_field_ack_by = \u786e\u8ba4\u8005
+##view_alert_details_field_parent_definition = Parent definition
view_alert_details_field_recovery_info = \u8fd8\u539f\u4fe1\u606f
##view_alert_details_field_resource_ancestry = Resource Ancestry
##view_alert_details_field_watched_resource = Watched Resource
commit 67c442b7baa5db4cdd3715fd89db9ea01b9e2fa8
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Fri Jul 19 12:41:13 2013 +0200
Removing deprecated annotation, adding orphanRemoval=true attribute instead.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java
index 4742c17..44a8eac 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java
@@ -253,9 +253,8 @@ public class Alert implements Serializable {
@ManyToOne
private AlertDefinition alertDefinition;
- @OneToMany(mappedBy = "alert", cascade = CascadeType.ALL)
+ @OneToMany(mappedBy = "alert", cascade = CascadeType.ALL, orphanRemoval=true)
@OrderBy
- @org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
// primary key
private Set<AlertConditionLog> conditionLogs = new LinkedHashSet<AlertConditionLog>();
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDampening.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDampening.java
index 0f2d0b1..be98df5 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDampening.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDampening.java
@@ -86,8 +86,7 @@ public class AlertDampening implements java.io.Serializable {
// This is required for cascade behavior. We want to be able to cascade delete the AlertDampeningEvents when an
// AlertDefinition is removed from the db, due to deleting a Resource from inventory.
- @OneToMany(mappedBy = "alertDefinition", cascade = { CascadeType.REFRESH, CascadeType.REMOVE })
- @org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
+ @OneToMany(mappedBy = "alertDefinition", cascade = { CascadeType.REFRESH, CascadeType.REMOVE }, orphanRemoval = true)
private Set<AlertDampeningEvent> alertDampeningEvents = new HashSet<AlertDampeningEvent>();
protected AlertDampening() {
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
index 02362ce..3445d9e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
@@ -293,7 +293,6 @@ public class AlertDefinition implements Serializable {
// do not cascade remove - group removal will be detaching children alert defs from the group def,
// and then letting the children be deleted slowly by existing alert def removal mechanisms
- @SuppressWarnings("unused")
@OneToMany(mappedBy = "groupAlertDefinition", fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
@OrderBy
private Set<AlertDefinition> groupAlertDefinitionChildren = new LinkedHashSet<AlertDefinition>();
@@ -361,11 +360,10 @@ public class AlertDefinition implements Serializable {
// referencing AlertConditionLog records.
private Set<AlertCondition> conditions = new LinkedHashSet<AlertCondition>(1); // Most alerts will only have one condition.
- @OneToMany(mappedBy = "alertDefinition", cascade = CascadeType.ALL)
+ @OneToMany(mappedBy = "alertDefinition", cascade = CascadeType.ALL, orphanRemoval = true)
// Although similar to AlertCondition, we do use DELETE_ORPHAN here. The reason is because AlertNotificationLog
// does not refer back to the AlertNotification record and therefore the notification logs are not affected
// by the loss of the AlertNotification that spawned the notification.
- @org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
private List<AlertNotification> alertNotifications = new ArrayList<AlertNotification>();
/**
commit 92a286d611085d96ba1710c442035445dda5318a
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Thu Jul 18 18:37:48 2013 +0200
[BZ 980091] - link in the alert to the parent on which the alert was created - Adding a new filter on AlertDefinitionCriteria (filter by alert id).
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
index 854efaf..9d4e51d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
@@ -48,6 +48,7 @@ public class AlertDefinitionCriteria extends Criteria {
private String filterName;
private String filterDescription;
private AlertPriority filterPriority;
+ private Integer filterAlertId; // requires overrides
private NonBindingOverrideFilter filterAlertTemplateOnly; // requires overrides - finds only alert templates
private Integer filterAlertTemplateParentId; // requires overrides
private Integer filterAlertTemplateResourceTypeId; // requires overrides
@@ -75,6 +76,10 @@ public class AlertDefinitionCriteria extends Criteria {
private PageOrdering sortResourceName; // requires sort override
public AlertDefinitionCriteria() {
+ filterOverrides.put("alertId", ""
+ + "id IN ( SELECT alert.alertDefinition.id " //
+ + " FROM Alert alert " //
+ + " WHERE alert.id = ? )");
filterOverrides.put("alertTemplateOnly", "resourceType IS NOT NULL");
filterOverrides.put("alertTemplateParentId", "parentId = ?");
filterOverrides.put("alertTemplateResourceTypeId", "resourceType.id = ?");
@@ -113,6 +118,10 @@ public class AlertDefinitionCriteria extends Criteria {
public void addFilterAlertTemplateParentId(Integer filterAlertTemplateParentId) {
this.filterAlertTemplateParentId = filterAlertTemplateParentId;
}
+
+ public void addFilterAlertId(Integer filterAlertId) {
+ this.filterAlertId = filterAlertId;
+ }
public void addFilterAlertTemplateResourceTypeId(Integer filterAlertTemplateResourceTypeId) {
this.filterAlertTemplateResourceTypeId = filterAlertTemplateResourceTypeId;
commit b3aa6d8a54378fad077d2052e9f9620768723a4d
Author: Michael Burman <yak(a)iki.fi>
Date: Fri Jul 19 12:27:38 2013 +0200
BZ980076 Check if storage is really running after a crash
diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/ControlCommand.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/ControlCommand.java
index 8988d98..5528619 100644
--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/ControlCommand.java
+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/ControlCommand.java
@@ -1,7 +1,7 @@
/*
*
* * RHQ Management Platform
- * * Copyright (C) 2005-2012 Red Hat, Inc.
+ * * Copyright (C) 2005-2013 Red Hat, Inc.
* * All rights reserved.
* *
* * This program is free software; you can redistribute it and/or modify
@@ -41,6 +41,10 @@ import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.ExecuteException;
+import org.apache.commons.exec.Executor;
+import org.apache.commons.exec.PumpStreamHandler;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -171,10 +175,15 @@ public abstract class ControlCommand {
return getStorageBasedir().exists();
}
- protected String getStoragePid() throws IOException {
+ protected File getStoragePidFile() {
File storageBasedir = getStorageBasedir();
File storageBinDir = new File(storageBasedir, "bin");
File pidFile = new File(storageBinDir, "cassandra.pid");
+ return pidFile;
+ }
+
+ protected String getStoragePid() throws IOException {
+ File pidFile = getStoragePidFile();
if (pidFile.exists()) {
return StreamUtil.slurp(new FileReader(pidFile));
@@ -282,4 +291,77 @@ public abstract class ControlCommand {
return inUse;
}
+
+ protected void waitForProcessToStop(String pid) throws Exception {
+
+ if (isWindows() || pid==null) {
+ // For the moment we have no better way to just wait some time
+ Thread.sleep(10*1000L);
+ } else {
+ int tries = 5;
+ while (tries > 0) {
+ log.debug(".");
+ if (!isUnixPidRunning(pid)) {
+ break;
+ }
+ Thread.sleep(2*1000L);
+ tries--;
+ }
+ if (tries==0) {
+ throw new RHQControlException("Process [" + pid + "] did not finish yet. Terminate it manually and retry.");
+ }
+ }
+
+ }
+
+ protected void killPid(String pid) throws IOException {
+ Executor executor = new DefaultExecutor();
+ executor.setWorkingDirectory(getBinDir());
+ executor.setStreamHandler(new PumpStreamHandler());
+ org.apache.commons.exec.CommandLine commandLine;
+
+ commandLine = new org.apache.commons.exec.CommandLine("kill").addArgument(pid);
+ executor.execute(commandLine);
+ }
+
+ protected boolean isUnixPidRunning(String pid) {
+
+ Executor executor = new DefaultExecutor();
+ executor.setWorkingDirectory(getBinDir());
+ executor.setStreamHandler(new PumpStreamHandler());
+ org.apache.commons.exec.CommandLine commandLine = new org.apache.commons.exec.CommandLine("/bin/kill")
+ .addArgument("-0")
+ .addArgument(pid);
+
+ try {
+ int code = executor.execute(commandLine);
+ if (code!=0) {
+ return false;
+ }
+ } catch (ExecuteException ee ) {
+ if (ee.getExitValue()==1) {
+ // return code 1 means process does not exist
+ return false;
+ }
+ } catch (IOException e) {
+ log.error("Checking for running process failed: " + e.getMessage());
+ }
+ return true;
+ }
+
+ protected boolean isStorageRunning() throws IOException {
+ String pid = getStoragePid();
+ if(pid == null) {
+ return false;
+ } else if(pid != null && !isUnixPidRunning(pid)) {
+ // There is a phantom pidfile
+ File pidFile = getStoragePidFile();
+ if(!pidFile.delete()) {
+ throw new RHQControlException("Could not delete storage pidfile " + pidFile.getAbsolutePath());
+ }
+ return false;
+ } else {
+ return true;
+ }
+ }
}
diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/AbstractInstall.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/AbstractInstall.java
index fe7cdd4..8c885b0 100644
--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/AbstractInstall.java
+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/AbstractInstall.java
@@ -1,7 +1,7 @@
/*
*
* * RHQ Management Platform
- * * Copyright (C) 2005-2012 Red Hat, Inc.
+ * * Copyright (C) 2005-2013 Red Hat, Inc.
* * All rights reserved.
* *
* * This program is free software; you can redistribute it and/or modify
@@ -36,16 +36,12 @@ import java.util.Properties;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.exec.DefaultExecuteResultHandler;
import org.apache.commons.exec.DefaultExecutor;
-import org.apache.commons.exec.ExecuteException;
import org.apache.commons.exec.Executor;
import org.apache.commons.exec.PumpStreamHandler;
-
import org.jboss.as.controller.client.ModelControllerClient;
-
import org.rhq.common.jbossas.client.controller.DeploymentJBossASClient;
import org.rhq.common.jbossas.client.controller.MCCHelper;
import org.rhq.server.control.ControlCommand;
-import org.rhq.server.control.RHQControlException;
/**
* Common code for commands that perform installs. Basically shared code for Install and Upgrade commands.
@@ -104,55 +100,6 @@ public abstract class AbstractInstall extends ControlCommand {
}
}
- protected void waitForProcessToStop(String pid) throws Exception {
-
- if (isWindows() || pid==null) {
- // For the moment we have no better way to just wait some time
- Thread.sleep(10*1000L);
- } else {
- int tries = 5;
- while (tries > 0) {
- log.debug(".");
- if (!isUnixPidRunning(pid)) {
- break;
- }
- Thread.sleep(2*1000L);
- tries--;
- }
- if (tries==0) {
- throw new RHQControlException("Process [" + pid + "] did not finish yet. Terminate it manually and retry.");
- }
- }
-
- }
-
- protected boolean isUnixPidRunning(String pid) {
-
- Executor executor = new DefaultExecutor();
- executor.setWorkingDirectory(getBinDir());
- executor.setStreamHandler(new PumpStreamHandler());
- org.apache.commons.exec.CommandLine commandLine;
-
- commandLine = new org.apache.commons.exec.CommandLine("/bin/kill")
- .addArgument("-0")
- .addArgument(pid);
-
- try {
- int code = executor.execute(commandLine);
- if (code!=0) {
- return false;
- }
- } catch (ExecuteException ee ) {
- if (ee.getExitValue()==1) {
- // return code 1 means process does not exist
- return false;
- }
- } catch (IOException e) {
- log.error("Checking for running process failed: " + e.getMessage());
- }
- return true;
- }
-
protected void waitForRHQServerToInitialize() throws Exception {
try {
final long messageInterval = 30000L;
diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Start.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Start.java
index 7e83c9e..f15b13e 100644
--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Start.java
+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Start.java
@@ -1,7 +1,7 @@
/*
*
* * RHQ Management Platform
- * * Copyright (C) 2005-2012 Red Hat, Inc.
+ * * Copyright (C) 2005-2013 Red Hat, Inc.
* * All rights reserved.
* *
* * This program is free software; you can redistribute it and/or modify
@@ -26,7 +26,6 @@
package org.rhq.server.control.command;
import java.io.File;
-import java.io.FileReader;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
@@ -137,14 +136,13 @@ public class Start extends ControlCommand {
log.debug("Failed to start storage service", e);
}
} else {
-
File storageBinDir = new File(getStorageBasedir(), "bin");
- File pidFile = new File(storageBinDir, "cassandra.pid");
+ File pidFile = getStoragePidFile();
// For now we are duplicating logic in the status command. This code will be
// replaced when we implement a rhq-storage.sh script.
- if (pidFile.exists()) {
- String pid = StreamUtil.slurp(new FileReader(pidFile));
+ if (isStorageRunning()) {
+ String pid = getStoragePid();
System.out.println("RHQ storage node (pid " + pid + ") is running");
} else {
commandLine = getCommandLine(false, "cassandra", "-p", pidFile.getAbsolutePath());
diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Stop.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Stop.java
index 53d0374..908aa8e 100644
--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Stop.java
+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Stop.java
@@ -1,7 +1,7 @@
/*
*
* * RHQ Management Platform
- * * Copyright (C) 2005-2012 Red Hat, Inc.
+ * * Copyright (C) 2005-2013 Red Hat, Inc.
* * All rights reserved.
* *
* * This program is free software; you can redistribute it and/or modify
@@ -126,13 +126,13 @@ public class Stop extends AbstractInstall {
log.debug("Failed to stop storage service", e);
}
} else {
- String pid = getStoragePid();
- if (pid != null) {
+ if(isStorageRunning()) {
+ String pid = getStoragePid();
+
System.out.println("Stopping RHQ storage node...");
System.out.println("RHQ storage node (pid=" + pid + ") is stopping...");
- commandLine = new org.apache.commons.exec.CommandLine("kill").addArgument(pid);
- executor.execute(commandLine);
+ killPid(pid);
waitForProcessToStop(pid);
commit bf8587569567d261791f272a672f5722d7dca8c0
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Thu Jul 18 23:37:57 2013 +0200
[as7] Fix domain api version discovery
Look for the first node of type element instead of simply calling getFirstChild
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/helper/HostConfiguration.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/helper/HostConfiguration.java
index 329246e..3c71135 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/helper/HostConfiguration.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/helper/HostConfiguration.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,11 +13,14 @@
* 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.
+ * 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.modules.plugins.jbossas7.helper;
+import static org.rhq.core.util.StringUtil.EMPTY_STRING;
+import static org.w3c.dom.Node.ELEMENT_NODE;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
@@ -33,6 +36,7 @@ import javax.xml.xpath.XPathFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
+import org.w3c.dom.Node;
import org.rhq.core.pluginapi.util.CommandLineOption;
import org.rhq.modules.plugins.jbossas7.AS7CommandLine;
@@ -234,11 +238,15 @@ public class HostConfiguration {
}
public String getDomainApiVersion() {
-
- String version = document.getFirstChild().getAttributes().getNamedItem("xmlns").getTextContent();
-
- version = version.substring(version.lastIndexOf(':')+1);
- return version;
+ // Look for the first child node of type element (<host> in domain mode or <server> in standalone mode)
+ // We can't just call getFirstChild because first child could be a node of type comment
+ for (Node childNode = document.getFirstChild(); childNode != null; childNode = childNode.getNextSibling()) {
+ if (childNode.getNodeType() == ELEMENT_NODE) {
+ String xmlns = childNode.getAttributes().getNamedItem("xmlns").getTextContent();
+ return xmlns.substring(xmlns.lastIndexOf(':') + 1);
+ }
+ }
+ return EMPTY_STRING;
}
/**
commit 5283e5356d2ca4bda6e3aeea9d323c186030baa9
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Thu Jul 18 09:41:39 2013 +0200
Bug 969621 - EAP 6 managed plug-in is unable to discover EAP servers when more then one is running on a single host
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 cc13406..cd9f276 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
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* 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.
+ * 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.modules.plugins.jbossas7;
@@ -42,6 +42,7 @@ import org.rhq.core.domain.configuration.Configuration;
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.resource.ResourceUpgradeReport;
import org.rhq.core.pluginapi.event.log.LogFileEventResourceComponentHelper;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
@@ -49,6 +50,8 @@ 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;
+import org.rhq.core.pluginapi.upgrade.ResourceUpgradeContext;
+import org.rhq.core.pluginapi.upgrade.ResourceUpgradeFacet;
import org.rhq.core.pluginapi.util.CommandLineOption;
import org.rhq.core.pluginapi.util.FileUtils;
import org.rhq.core.pluginapi.util.JavaCommandLine;
@@ -66,12 +69,15 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
* Abstract base discovery component for the two server types - "JBossAS7 Host Controller" and
* "JBossAS7 Standalone Server".
*/
-public abstract class BaseProcessDiscovery implements ResourceDiscoveryComponent, ManualAddFacet {
+public abstract class BaseProcessDiscovery implements ResourceDiscoveryComponent, ManualAddFacet, ResourceUpgradeFacet {
private static final String JBOSS_AS_PREFIX = "jboss-as-";
private static final String JBOSS_EAP_PREFIX = "jboss-eap-";
private static final String WILDFLY_PREFIX = "wildfly-";
+ private static final String LOCAL_RESOURCE_KEY_PREFIX = "hostConfig: ";
+ private static final String REMOTE_RESOURCE_KEY_PREFIX = "hostPort: ";
+
private static final String HOME_DIR_SYSPROP = "jboss.home.dir";
private static final String RHQADMIN = "rhqadmin";
@@ -202,7 +208,7 @@ public abstract class BaseProcessDiscovery implements ResourceDiscoveryComponent
setStartScriptPluginConfigProps(process, commandLine, pluginConfig, agentProcess);
setUserAndPasswordPluginConfigProps(serverPluginConfig, hostConfig, baseDir);
- String key = baseDir.getPath();
+ String key = createKeyForLocalResource(serverPluginConfig);
HostPort hostPort = hostConfig.getDomainControllerHostPort(commandLine);
String name = buildDefaultResourceName(hostPort, managementHostPort, productType);
String description = buildDefaultResourceDescription(hostPort, productType);
@@ -455,7 +461,7 @@ public abstract class BaseProcessDiscovery implements ResourceDiscoveryComponent
HostPort managementHostPort = new HostPort(false);
managementHostPort.host = hostname;
managementHostPort.port = port;
- String key = hostname + ":" + port;
+ String key = createKeyForRemoteResource(hostname + ":" + port);
String name = buildDefaultResourceName(hostPort, managementHostPort, productType);
String version = productInfo.getProductVersion();
String description = buildDefaultResourceDescription(hostPort, productType);
@@ -469,6 +475,43 @@ public abstract class BaseProcessDiscovery implements ResourceDiscoveryComponent
return detail;
}
+ @Override
+ public ResourceUpgradeReport upgrade(ResourceUpgradeContext inventoriedResource) {
+ String currentResourceKey = inventoriedResource.getResourceKey();
+ Configuration pluginConfiguration = inventoriedResource.getPluginConfiguration();
+ ServerPluginConfiguration serverPluginConfiguration = new ServerPluginConfiguration(pluginConfiguration);
+
+ if (currentResourceKey.startsWith(LOCAL_RESOURCE_KEY_PREFIX)
+ || currentResourceKey.startsWith(REMOTE_RESOURCE_KEY_PREFIX)) {
+ // Resource key already in right format
+ return null;
+ }
+
+ ResourceUpgradeReport report = new ResourceUpgradeReport();
+
+ if (new File(currentResourceKey).isDirectory()) {
+ // Old key format for a local resource (key is base dir)
+ report.setNewResourceKey(createKeyForLocalResource(serverPluginConfiguration));
+ } else if (currentResourceKey.contains(":")) {
+ // Old key format for a remote (manually added) resource (key is base dir)
+ report.setNewResourceKey(createKeyForRemoteResource(currentResourceKey));
+ } else {
+ log.warn("Unknown format, cannot upgrade resource key [" + currentResourceKey + "]");
+ return null;
+ }
+
+ return report;
+ }
+
+ private String createKeyForRemoteResource(String hostPort) {
+ return REMOTE_RESOURCE_KEY_PREFIX + hostPort;
+ }
+
+ private String createKeyForLocalResource(ServerPluginConfiguration serverPluginConfiguration) {
+ return LOCAL_RESOURCE_KEY_PREFIX
+ + serverPluginConfiguration.getHostConfigFile().getAbsolutePath();
+ }
+
private <T>T getServerAttribute(ASConnection connection, String attributeName) {
Operation op = new ReadAttribute(null, attributeName);
Result res = connection.execute(op);
commit e6fa8c734c2bfee9ad46a2b7683d4c86b4897e5c
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 18 07:23:34 2013 -0400
take 2 at dependency clean up
JNA libraries were getting pulled into the ear as transitive dependencies. JNA
is used by the cassandra-ccm-core module to shutdown Cassandra. This
functionality though is only used in test code.
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index c648685..f418afc 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -77,6 +77,14 @@
<groupId>org.rhq</groupId>
<artifactId>rhq-core-plugin-api</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>net.java.dev.jna</groupId>
+ <artifactId>jna</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>net.java.dev.jna</groupId>
+ <artifactId>platform</artifactId>
+ </exclusion>
</exclusions>
</dependency>
diff --git a/modules/enterprise/server/server-metrics/pom.xml b/modules/enterprise/server/server-metrics/pom.xml
index 2245978..97496f7 100644
--- a/modules/enterprise/server/server-metrics/pom.xml
+++ b/modules/enterprise/server/server-metrics/pom.xml
@@ -47,18 +47,6 @@
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>rhq-cassandra-ccm-core</artifactId>
- <version>${project.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.cassandra</groupId>
- <artifactId>cassandra-clientutil</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
<artifactId>rhq-cassandra-ccm-testng</artifactId>
<version>${project.version}</version>
<scope>test</scope>
commit 375f6f66fcc9214cc3d13605c17859ac11e3fd45
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 18 05:04:00 2013 -0500
Temporary fix for the server jar name for dev profile (it was still using the old name).
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index 7c236c7..c648685 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -776,7 +776,7 @@
<properties>
<rhq.rootDir>../../../..</rhq.rootDir>
<rhq.containerDir>${rhq.rootDir}/${rhq.devContainerServerPath}</rhq.containerDir>
- <rhq.deploymentName>${project.build.finalName}-ejb3.jar</rhq.deploymentName>
+ <rhq.deploymentName>rhq-server.jar</rhq.deploymentName>
<rhq.deploymentDir>${rhq.containerDir}/${rhq.earDeployDir}/${rhq.deploymentName}</rhq.deploymentDir>
</properties>
commit b59d1684eb12c4e1c5a78309b4ec40eeb461b7d5
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 17 20:17:14 2013 -0400
fix test ear deployment error that resulted from renaming server jar
The ear deployment was failing because classes were not getting added to the
rhq-server.jar in the test ear.
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
index 4dfbd46..2fd8624 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
@@ -341,7 +341,7 @@ public abstract class AbstractEJB3Test extends Arquillian {
// merge rhq.ear into testEar but include only the EJB jars and the supporting libraries. Note that we
// don't include the services sar because tests are responsible for prepare/unprepare of all required services,
// we don't want the production services performing any unexpected work.
- testEar = testEar.merge(rhqEar, Filters.include("/lib.*|/rhq.*ejb3\\.jar.*"));
+ testEar = testEar.merge(rhqEar, Filters.include("/lib.*|/rhq.*ejb3\\.jar.*|/rhq-server.jar.*"));
// remove startup beans and shutdown listeners, we don't want this to be a full server deployment. The tests
// start/stop what they need, typically with test services or mocks.
testEar.delete(ArchivePaths
@@ -413,7 +413,7 @@ public abstract class AbstractEJB3Test extends Arquillian {
//System.out.println("** The Deployment EAR: " + testEar.toString(true) + "\n");
// Save the test EAR to a zip file for inspection (set file explicitly)
- //exportZip(testEar, new File("c:/temp/test-ear.ear"));
+ exportZip(testEar, new File("/Users/jsanda/tmp/test-ear.ear"));
return testEar;
}
commit c855df20b787a6db0a7b9aed7b1fb5597eb0e2d6
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Jul 17 17:09:55 2013 -0400
Work on the windows rhq48 cassandra upgrade patch
diff --git a/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.bat b/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.bat
index e0312dc..c190503 100644
--- a/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.bat
+++ b/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.bat
@@ -1,14 +1,54 @@
@echo off
+
+rem ===========================================================================
+rem RHQ Storage Node (Cassandra) Windows 4.8.0 upgrade patch script
+rem
+rem WHO NEEDS TO RUN THE PATCH?
+rem
+rem Run this patch script if you are:
+rem - Running RHQ 4.8.0 on Windows
+rem - Planning to upgrade and maintain your Storage node data
+rem
+rem PREQUISITES:
+rem
+rem This patch requires the installation of Python. Download Python 2.7.5 from:
+rem
+rem http://www.python.org/download/releases/2.7.5/
+rem
+rem Install as directed. Note that Python will need to be on your PATH to run this patch. Also,
+rem this patch will not work with Python3.
+rem
+rem Edit <rhq-install-dir>\rhq-storage\conf\cassandra.yaml to ensure the following is true:
+rem
+rem start_rpc: true
+rem
+rem Note the setting of rpc_port. By default it is 9160, which is fine.
+rem
+rem RUNNING THE PATCH:
+rem
+rem > cd <patch-dir>
+rem > rhq48-storage-patch.bat <rhq-480-server-dir> <storage-node-ip-address> <thrift-rpc-port> <jmx-port>
+rem
+rem For example:
+rem > rhq48-storage-patch.bat c:\rhq-server-4.8.0 127.0.0.1 9160 7299
+rem
+rem Review the output carefully. There should be no errors (be careful, the script may still have completed).
+rem If errors are encountered fix the issue and rerun the patch.
+rem
+rem When done, you can again edit cassandra.yaml and reset start_rpc: false
+rem
+rem ===========================================================================
+
setlocal
if /i "%4" == "" (
- echo Usage: rhq48-storage-patch.bat ^<rhq-server-dir^> ^<storage-ip-address^> ^<cql-port^> ^<jmx-port^>
+ echo Usage: rhq48-storage-patch.bat ^<rhq-server-dir^> ^<storage-ip-address^> ^<thrift-rpc-port^> ^<jmx-port^>
exit /B 1
)
set RHQ_SERVER_DIR=%1
-set CQL_HOSTNAME=%2
-set CQL_PORT=%3
+set CQLSH_HOST=%2
+set CQLSH_PORT=%3
set JMX_PORT=%4
set USERNAME="rhqadmin"
set PASSWORD="rhqadmin"
@@ -29,7 +69,7 @@ echo Waiting for RHQ Storage Node to start up..
rem Sleep is not implemented in all Windows prompts, this one won't work in Vista
choice /n /c y /d y /t 3
-set RHQ_STORAGE_BIN=%RHQ_SERVER_DIR%\rhq-storage\bin\
+set RHQ_STORAGE_BIN=%RHQ_SERVER_DIR%\rhq-storage\bin
set CQLSH_PATH=%RHQ_STORAGE_BIN%\cqlsh
set NODETOOL_PATH=%RHQ_STORAGE_BIN%\nodetool.bat
commit 11b8ae9cff9ca5085bfe317a01653cc8b81d8bb7
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Jul 17 14:14:02 2013 -0500
Initial implementation for the Storage Node configuration composite. The final resource operation still needs to be implemented but the rest of the functionality is implemented.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNode.java b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNode.java
index 14043db..575edc74 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNode.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNode.java
@@ -90,7 +90,7 @@ public class StorageNode implements Serializable {
public static final long serialVersionUID = 1L;
public static final String QUERY_FIND_ALL = "StorageNode.findAll";
- public static final String QUERY_FIND_BY_ADDRESS = "StorageNode.findByName";
+ public static final String QUERY_FIND_BY_ADDRESS = "StorageNode.findByAddress";
public static final String QUERY_FIND_ALL_NOT_INSTALLED = "StorageNode.findAllCloudMembers";
public static final String QUERY_DELETE_BY_ID = "StorageNode.deleteById";
public static final String QUERY_FIND_ALL_NORMAL = "StorageNode.findAllNormalCloudMembers";
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeConfigurationComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeConfigurationComposite.java
new file mode 100644
index 0000000..e2c64f9
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeConfigurationComposite.java
@@ -0,0 +1,98 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.cloud;
+
+import java.io.Serializable;
+
+/**
+ * @author Stefan Negrea
+ */
+public class StorageNodeConfigurationComposite implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private StorageNode storageNode;
+ private int jmxPort;
+ private String heapSize;
+
+ public StorageNodeConfigurationComposite() {
+ // GWT needs this
+ }
+
+ public StorageNodeConfigurationComposite(StorageNode storageNode) {
+ this.storageNode = storageNode;
+ }
+
+ /**
+ * @return associated storage node
+ */
+ public StorageNode getStorageNode() {
+ return storageNode;
+ }
+
+ /**
+ * @param storageNode storage node
+ */
+ protected void setStorageNode(StorageNode storageNode) {
+ this.storageNode = storageNode;
+ }
+
+
+ /**
+ * @return the JMX port
+ */
+ public int getJmxPort() {
+ return jmxPort;
+ }
+
+ /**
+ * @param jmxPort JMX port to set
+ */
+ public void setJmxPort(int jmxPort) {
+ this.jmxPort = jmxPort;
+ }
+
+ /**
+ * @return the heap size
+ */
+ public String getHeapSize() {
+ return heapSize;
+ }
+
+ /**
+ * @param heapSize heap size to set
+ */
+ public void setHeapSize(String heapSize) {
+ this.heapSize = heapSize;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("storageNode.addresss=").append(storageNode.getAddress()).append(", ");
+ builder.append("heapSize=").append(heapSize).append(", ");
+ builder.append("jmxPort=").append(jmxPort).append("");
+ return builder.toString();
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
index fa51fe1..3f1ec69 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
@@ -51,14 +51,18 @@ import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.cloud.Server;
import org.rhq.core.domain.cloud.StorageNode;
import org.rhq.core.domain.cloud.StorageNode.OperationMode;
+import org.rhq.core.domain.cloud.StorageNodeConfigurationComposite;
import org.rhq.core.domain.cloud.StorageNodeLoadComposite;
import org.rhq.core.domain.common.JobTrigger;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.AlertCriteria;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
+import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
import org.rhq.core.domain.criteria.StorageNodeCriteria;
import org.rhq.core.domain.measurement.MeasurementAggregate;
import org.rhq.core.domain.measurement.MeasurementUnits;
+import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.core.domain.operation.ResourceOperationHistory;
import org.rhq.core.domain.operation.bean.GroupOperationSchedule;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
@@ -72,6 +76,7 @@ import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.RequiredPermission;
import org.rhq.enterprise.server.authz.RequiredPermissions;
import org.rhq.enterprise.server.cloud.instance.ServerManagerLocal;
+import org.rhq.enterprise.server.configuration.ConfigurationManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementDataManagerLocal;
import org.rhq.enterprise.server.operation.OperationManagerLocal;
import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
@@ -96,6 +101,11 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
private static final String RHQ_STORAGE_JMX_PORT_PROPERTY = "jmxPort";
private static final String RHQ_STORAGE_ADDRESS_PROPERTY = "host";
+ private static final int OPERATION_QUERY_TIMEOUT = 1000;
+ private static final int MAX_ITERATIONS = 5;
+ private static final String UPDATE_CONFIGURATION_OPERATION = "updateConfiguration";
+ private static final String RESTART_OPERATION = "restart";
+
@PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
private EntityManager entityManager;
@@ -120,6 +130,9 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
@EJB
private AlertManagerLocal alertManager;
+ @EJB
+ private ConfigurationManagerLocal configurationManager;
+
@Override
public void linkResource(Resource resource) {
List<StorageNode> storageNodes = this.getStorageNodes();
@@ -438,6 +451,19 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
entityManager.flush();
}
+ private StorageNode findStorageNodeByAddress(String address) {
+ TypedQuery<StorageNode> query = entityManager.<StorageNode> createNamedQuery(StorageNode.QUERY_FIND_BY_ADDRESS,
+ StorageNode.class);
+ query.setParameter("address", address);
+ List<StorageNode> result = query.getResultList();
+
+ if (result != null && result.size() > 0) {
+ return result.get(0);
+ }
+
+ return null;
+ }
+
private StorageNodeLoadComposite.MeasurementAggregateWithUnits getMeasurementAggregateWithUnits(Subject subject,
int schedId, MeasurementUnits units, long beginTime, long endTime) {
MeasurementAggregate measurementAggregate = measurementManager.getAggregate(subject, schedId, beginTime,
@@ -559,4 +585,91 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
return resourceIdsWithAlertDefinitions.toArray(new Integer[resourceIdsWithAlertDefinitions.size()]);
}
+
+ @Override
+ public StorageNodeConfigurationComposite retrieveConfiguration(Subject subject, StorageNode storageNode) {
+ StorageNodeConfigurationComposite configuration = new StorageNodeConfigurationComposite(storageNode);
+
+ if (storageNode != null && storageNode.getResource() != null) {
+ Resource storageNodeResource = storageNode.getResource();
+ Configuration storageNodeConfiguration = configurationManager.getResourceConfiguration(subject,
+ storageNodeResource.getId());
+
+ configuration.setHeapSize(storageNodeConfiguration.getSimpleValue("maxHeapSize"));
+ configuration.setJmxPort(storageNode.getJmxPort());
+ }
+
+ return configuration;
+ }
+
+ @Override
+ public boolean updateConfiguration(Subject subject, StorageNodeConfigurationComposite storageNodeConfiguration) {
+ StorageNode storageNode = findStorageNodeByAddress(storageNodeConfiguration.getStorageNode().getAddress());
+
+ if (storageNode != null && storageNode.getResource() != null) {
+ Resource storageNodeResource = storageNode.getResource();
+ Configuration parameters = new Configuration();
+ parameters.setSimpleValue("jmxPort", storageNodeConfiguration.getJmxPort() + "");
+ parameters.setSimpleValue("heapSize", storageNodeConfiguration.getHeapSize() + "");
+
+ boolean updateConfigurationResult = runOperationAndWaitForResult(subject, storageNodeResource,
+ UPDATE_CONFIGURATION_OPERATION, parameters);
+
+ if (updateConfigurationResult) {
+ boolean restartResult = runOperationAndWaitForResult(subject, storageNodeResource, RESTART_OPERATION,
+ null);
+
+ if (restartResult) {
+ storageNode.setJmxPort(storageNodeConfiguration.getJmxPort());
+ entityManager.persist(storageNode);
+
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private boolean runOperationAndWaitForResult(Subject subject, Resource storageNodeResource, String operationToRun,
+ Configuration parameters) {
+
+ //scheduling the operation
+ long operationStartTime = System.currentTimeMillis();
+ operationManager.scheduleResourceOperation(subject, storageNodeResource.getId(), operationToRun, 0, 0, 0, 0,
+ parameters, "Run by StorageNodeManagerBean");
+
+ //waiting for the operation result then return it
+ int iteration = 0;
+ boolean successResultFound = false;
+ while (iteration < MAX_ITERATIONS && !successResultFound) {
+ ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
+ criteria.addFilterResourceIds(storageNodeResource.getId());
+ criteria.addFilterStartTime(operationStartTime);
+ criteria.addFilterOperationName(operationToRun);
+ criteria.addFilterStatus(OperationRequestStatus.SUCCESS);
+ criteria.setPageControl(PageControl.getUnlimitedInstance());
+
+ PageList<ResourceOperationHistory> results = operationManager.findResourceOperationHistoriesByCriteria(
+ subject, criteria);
+
+ if (results != null && results.size() > 0) {
+ successResultFound = true;
+ }
+
+ if (successResultFound) {
+ break;
+ } else {
+ try {
+ Thread.sleep(OPERATION_QUERY_TIMEOUT);
+ } catch (Exception e) {
+ log.error(e);
+ }
+ }
+
+ iteration++;
+ }
+
+ return successResultFound;
+ }
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
index a9b2514..6fca820 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
@@ -25,6 +25,7 @@ import javax.ejb.Local;
import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.cloud.StorageNode;
+import org.rhq.core.domain.cloud.StorageNodeConfigurationComposite;
import org.rhq.core.domain.cloud.StorageNodeLoadComposite;
import org.rhq.core.domain.criteria.StorageNodeCriteria;
import org.rhq.core.domain.resource.Resource;
@@ -56,6 +57,10 @@ public interface StorageNodeManagerLocal {
*/
StorageNodeLoadComposite getLoad(Subject subject, StorageNode node, long beginTime, long endTime);
+ StorageNodeConfigurationComposite retrieveConfiguration(Subject subject, StorageNode storageNode);
+
+ boolean updateConfiguration(Subject subject, StorageNodeConfigurationComposite storageNodeConfiguration);
+
/**
* Fetches the list of StorageNode entities based on provided criteria.
*
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerRemote.java
index 72432db..7be1b07 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerRemote.java
@@ -23,6 +23,7 @@ import javax.ejb.Remote;
import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.cloud.StorageNode;
+import org.rhq.core.domain.cloud.StorageNodeConfigurationComposite;
import org.rhq.core.domain.cloud.StorageNodeLoadComposite;
import org.rhq.core.domain.criteria.StorageNodeCriteria;
import org.rhq.core.domain.util.PageList;
@@ -48,6 +49,10 @@ public interface StorageNodeManagerRemote {
*/
StorageNodeLoadComposite getLoad(Subject subject, StorageNode node, long beginTime, long endTime);
+ StorageNodeConfigurationComposite retrieveConfiguration(Subject subject, StorageNode storageNode);
+
+ boolean updateConfiguration(Subject subject, StorageNodeConfigurationComposite storageNodeConfiguration);
+
/**
* <p>Fetches the list of {@link StorageNode} entities based on provided criteria.</p>
*
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/StorageNodeMaintenanceJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/StorageNodeMaintenanceJob.java
index 6b1940d..54ca4c2 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/StorageNodeMaintenanceJob.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/StorageNodeMaintenanceJob.java
@@ -71,7 +71,6 @@ public class StorageNodeMaintenanceJob extends AbstractStatefulJob {
private final static String RUN_REPAIR_PROPERTY = "runRepair";
private final static String UPDATE_SEEDS_LIST = "updateSeedsList";
private final static String SEEDS_LIST = "seedsList";
- private final static String SUCCEED_PROPERTY = "succeed";
private static final String USERNAME_PROP = "rhq.cassandra.username";
private static final String PASSWORD_PROP = "rhq.cassandra.password";
@@ -169,8 +168,6 @@ public class StorageNodeMaintenanceJob extends AbstractStatefulJob {
List<Resource> childResources = LookupUtil.getResourceManager().findResourcesByCriteria(
LookupUtil.getSubjectManager().getOverlord(), c);
-
-
for (Resource childResource : childResources) {
if (STORAGE_SERVICE.equals(childResource.getName())) {
try {
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
index 6194146..380da65 100644
--- a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
+++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
@@ -82,11 +82,19 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
return prepareForUpgrade(parameters);
} else if (name.equals("readRepair")) {
return readRepair();
+ } else if (name.equals("updateConfiguration")) {
+ return updateConfiguration(parameters);
} else {
return super.invokeOperation(name, parameters);
}
}
+ private OperationResult updateConfiguration(Configuration params) {
+ OperationResult result = new OperationResult("Configuration updated.");
+ //TODO: implement updates to various sub-resources here
+ return result;
+ }
+
private OperationResult nodeAdded(Configuration params) {
boolean runRepair = params.getSimple("runRepair").getBooleanValue();
boolean updateSeedsList = params.getSimple("updateSeedsList").getBooleanValue();
@@ -222,12 +230,12 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
}
return result;
}
-
+
private OperationResult prepareForUpgrade(Configuration parameters) throws Exception {
EmsConnection emsConnection = getEmsConnection();
EmsBean storageService = emsConnection.getBean("org.apache.cassandra.db:type=StorageService");
Class<?>[] emptyParams = new Class<?>[0];
-
+
if (log.isDebugEnabled()) {
log.debug("Disabling native transport...");
}
@@ -249,7 +257,7 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
snapshotName = System.currentTimeMillis() + "";
}
operation.invoke(snapshotName, new String[] {});
-
+
// max 2 sec
waitForTaskToComplete(500, 10, 150);
@@ -261,7 +269,7 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
return new OperationResult();
}
-
+
private void waitForTaskToComplete(int initialWaiting, int maxTries, int sleepMillis) {
// initial waiting
try {
diff --git a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
index 5a60d19..6ed31b7 100644
--- a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
@@ -73,7 +73,7 @@
</c:list-property>
</results>
</operation>
-
+
<operation name="addNodeMaintenance">
<parameters>
<c:simple-property name="runRepair" type="boolean" default="true"/>
@@ -111,6 +111,16 @@
</parameters>
</operation>
+ <operation name="updateConfiguration" description="Updates the node configuration. Will require a separate server restart for the settings to take effect.">
+ <parameters>
+ <c:simple-property name="heapSize" type="string" description="The heap size to be used for both -Xms and -Xmx JVM options."/>
+ <c:simple-property name="jmxPort" type="integer" description="JMX port JVM option."/>
+ </parameters>
+ <results>
+ <c:simple-property name="operationResult" description="Outcome of updating the configuration."/>
+ </results>
+ </operation>
+
<resource-configuration>
<c:group name="MemorySettings">
<c:simple-property name="minHeapSize"
@@ -195,3 +205,4 @@
<service name="Keyspace" sourcePlugin="Cassandra" sourceType="Keyspace"/>
</server>
</plugin>
+
commit b268d00034cb7af8d929006e8ac4688eeae58549
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 17 13:10:58 2013 -0400
Revert "cleaning up dependencies"
This reverts commit e798901b83e37cd267a2d11489664569918ef90d.
diff --git a/modules/common/cassandra-schema/pom.xml b/modules/common/cassandra-schema/pom.xml
index 55dedb8..8e3b44a 100644
--- a/modules/common/cassandra-schema/pom.xml
+++ b/modules/common/cassandra-schema/pom.xml
@@ -15,6 +15,12 @@
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>rhq-cassandra-ccm-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>rhq-cassandra-util</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/modules/enterprise/server/server-metrics/pom.xml b/modules/enterprise/server/server-metrics/pom.xml
index 97496f7..2245978 100644
--- a/modules/enterprise/server/server-metrics/pom.xml
+++ b/modules/enterprise/server/server-metrics/pom.xml
@@ -47,6 +47,18 @@
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>rhq-cassandra-ccm-core</artifactId>
+ <version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.cassandra</groupId>
+ <artifactId>cassandra-clientutil</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>rhq-cassandra-ccm-testng</artifactId>
<version>${project.version}</version>
<scope>test</scope>
commit a05f561f5fcac94b3308937b07d3b1e1e3f84d58
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Wed Jul 17 16:59:03 2013 +0200
Print simpler log message when component invocation is interrupted and log level is higher than debug
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 a9fe1c2..3669947 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
@@ -671,8 +671,19 @@ public class ResourceContainer implements Serializable {
public void markContextInterrupted() {
localContext.markInterrupted();
- LOG.warn("Invocation has been marked interrupted for method [" + method + "] on resource ["
- + resourceContainer.getResource() + "]");
+ LOG.warn(getContextInterruptedWarningMessage(LOG.isDebugEnabled()));
+ }
+
+ private String getContextInterruptedWarningMessage(boolean detailed) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Invocation has been marked interrupted for method [");
+ if (detailed) {
+ sb.append(method.toGenericString());
+ } else {
+ sb.append(method.getDeclaringClass().getSimpleName()).append(".").append(method.getName());
+ }
+ sb.append("] on resource [").append(resourceContainer.getResource()).append("]");
+ return sb.toString();
}
}
}
commit 01cd91b130f563ba62cd96a46f2cb3a2ac567a48
Author: Larry O'Leary <loleary(a)redhat.com>
Date: Wed Jul 17 16:32:05 2013 +0200
BZ 981015 - Ldap auth failed if DN contained a backslash
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java
index 6b7add6..0db28f7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java
@@ -23,6 +23,7 @@ import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Properties;
+import javax.naming.CompositeName;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.directory.SearchControls;
@@ -194,7 +195,18 @@ public class LdapLoginModule extends UsernamePasswordLoginModule {
SearchResult si = (SearchResult) answer.next();
// Construct the UserDN
- String userDN = si.getName() + "," + baseDNs[x];
+ String userDN = null;
+
+ try {
+ userDN = si.getNameInNamespace();
+ } catch (UnsupportedOperationException use) {
+ userDN = new CompositeName(si.getName()).get(0);
+ if (si.isRelative()) {
+ userDN += "," + baseDNs[x];
+ }
+ }
+
+ log.debug("Using LDAP userDN=" + userDN);
ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, userDN);
ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, inputPassword);
@@ -209,7 +221,7 @@ public class LdapLoginModule extends UsernamePasswordLoginModule {
// If we try all the BaseDN's and have not found a match, return false
return false;
} catch (Exception e) {
- log.info("Failed to validate password: " + e.getMessage());
+ log.info("Failed to validate password for [" + userName + "]: " + e.getMessage());
return false;
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
index 532a944..a28c709 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* 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.
+ * 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.server.resource.group;
@@ -33,6 +33,7 @@ import java.util.Set;
import javax.ejb.EJB;
import javax.ejb.Stateless;
+import javax.naming.CompositeName;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
@@ -345,12 +346,9 @@ public class LdapGroupManagerBean implements LdapGroupManagerLocal {
try {
userDN = si.getNameInNamespace();
} catch (UnsupportedOperationException use) {
- userDN = si.getName();
- if (userDN.startsWith("\"")) {
- userDN = userDN.substring(1, userDN.length());
- }
- if (userDN.endsWith("\"")) {
- userDN = userDN.substring(0, userDN.length() - 1);
+ userDN = new CompositeName(si.getName()).get(0);
+ if (si.isRelative()) {
+ userDN += "," + baseDNs[x];
}
userDN = userDN + "," + baseDNs[x];
}
@@ -507,7 +505,7 @@ public class LdapGroupManagerBean implements LdapGroupManagerLocal {
/** Translate SystemSettings to familiar Properties instance since we're
* passing not one but multiple values.
- *
+ *
* @param systemSettings
* @return
*/
@@ -532,7 +530,7 @@ public class LdapGroupManagerBean implements LdapGroupManagerLocal {
/** Executes the LDAP group query using the filters, context and search controls, etc. parameters passed in.
* The matching groups located during processing this pages of results are added as new entries to the
* groupDetailsMap passed in.
- *
+ *
* @param filter
* @param groupDetailsMap
* @param ctx
commit 165c9c9f8da7251c0000444f04161171a7d5794f
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 17 07:37:12 2013 -0400
need to make cassandra-ccm-core a direct dependency now
diff --git a/modules/helpers/metrics-simulator/pom.xml b/modules/helpers/metrics-simulator/pom.xml
index a55afa5..0a06610 100644
--- a/modules/helpers/metrics-simulator/pom.xml
+++ b/modules/helpers/metrics-simulator/pom.xml
@@ -13,6 +13,12 @@
<dependencies>
<dependency>
<groupId>org.rhq</groupId>
+ <artifactId>rhq-cassandra-ccm-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
<artifactId>rhq-cassandra-schema</artifactId>
<version>${project.version}</version>
</dependency>
commit fb59ea4fb09414875afcaa9543788e3cfc1b14f1
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 17 07:35:22 2013 -0400
initial commit for StorageInstallerTest
This commit provides some initial test coverage for the storage installer. More
tests will be added to cover various error handling situations and upgrade
scenarios.
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
index 7496d08..338ef3a 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
@@ -303,7 +303,7 @@ public class CassandraClusterManager {
return nodeIds;
}
- private void killNode(File nodeDir) throws Exception {
+ public void killNode(File nodeDir) throws Exception {
long pid = getPid(nodeDir);
CLibrary.kill((int) pid, 9);
}
diff --git a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
index 2fec2dc..63282e4 100644
--- a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
+++ b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
@@ -485,7 +485,7 @@ public class StorageInstaller {
private PropertiesFileUpdate getServerProperties() {
String sysprop = System.getProperty("rhq.server.properties-file");
if (sysprop == null) {
- throw new RuntimeException("The required system property [rhq.server.properties] is not defined.");
+ throw new RuntimeException("The required system property [rhq.server.properties-file] is not defined.");
}
File file = new File(sysprop);
@@ -605,7 +605,7 @@ public class StorageInstaller {
return new File(binDir, "cassandra.pid").exists();
}
- private boolean verifyNodeIsUp(String address, int jmxPort, int retries, long timeout) throws Exception {
+ boolean verifyNodeIsUp(String address, int jmxPort, int retries, long timeout) throws Exception {
String url = "service:jmx:rmi:///jndi/rmi://" + address + ":" + jmxPort + "/jmxrmi";
JMXServiceURL serviceURL = new JMXServiceURL(url);
JMXConnector connector = null;
diff --git a/modules/common/cassandra-installer/src/test/java/org/rhq/storage/installer/StorageInstallerTest.java b/modules/common/cassandra-installer/src/test/java/org/rhq/storage/installer/StorageInstallerTest.java
new file mode 100644
index 0000000..3fd13c7
--- /dev/null
+++ b/modules/common/cassandra-installer/src/test/java/org/rhq/storage/installer/StorageInstallerTest.java
@@ -0,0 +1,123 @@
+package org.rhq.storage.installer;
+
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.Properties;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.PosixParser;
+import org.apache.commons.io.FileUtils;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import org.rhq.cassandra.CassandraClusterManager;
+import org.rhq.core.util.file.FileUtil;
+
+/**
+ * @author John Sanda
+ */
+public class StorageInstallerTest {
+
+ private File basedir;
+
+ private File storageDir;
+
+ private StorageInstaller installer;
+
+ @BeforeMethod
+ public void initDirs(Method test) throws Exception {
+ File dir = new File(getClass().getResource(".").toURI());
+ basedir = new File(dir, getClass().getSimpleName() + "/" + test.getName());
+ FileUtil.purge(basedir, true);
+ basedir.mkdirs();
+
+ System.setProperty("rhq.server.basedir", basedir.getAbsolutePath());
+
+ File serverPropsFile = new File(basedir, "rhq-server.properties");
+ FileUtils.touch(serverPropsFile);
+ System.setProperty("rhq.server.properties-file", serverPropsFile.getAbsolutePath());
+
+ storageDir = new File(basedir, "rhq-storage");
+
+ installer = new StorageInstaller();
+ }
+
+ @AfterMethod
+ public void shutdownStorageNode() throws Exception {
+ CassandraClusterManager ccm = new CassandraClusterManager();
+ ccm.killNode(storageDir);
+ }
+
+ @Test
+ public void performValidInstall() throws Exception {
+ CommandLineParser parser = new PosixParser();
+
+ String[] args = {
+ "--dir", storageDir.getAbsolutePath(),
+ "--commitlog", new File(storageDir, "commit_log").getAbsolutePath(),
+ "--data", new File(storageDir, "data").getAbsolutePath(),
+ "--saved-caches", new File(storageDir, "saved_caches").getAbsolutePath(),
+ "--heap-size", "256M",
+ "--heap-new-size", "64M",
+ "--hostname", "127.0.0.1"
+ };
+
+ CommandLine cmdLine = parser.parse(installer.getOptions(), args);
+ int status = installer.run(cmdLine);
+
+ assertEquals(status, 0, "Expected to get back a status code of 0 for a successful install");
+ assertNodeIsRunning();
+ assertRhqServerPropsUpdated();
+
+ File binDir = new File(storageDir, "bin");
+ assertTrue(binDir.exists(), "Expected to find bin directory at " + binDir);
+
+ File confDir = new File(storageDir, "conf");
+ assertTrue(confDir.exists(), "Expected to find conf directory at " + confDir);
+
+ File libDir = new File(storageDir, "lib");
+ assertTrue(libDir.exists(), "Expected to find lib directory at " + libDir);
+
+ File commitLogDir = new File(storageDir, "commit_log");
+ assertTrue(commitLogDir.exists(), "Expected to find commit_log directory at " + commitLogDir);
+
+ File dataDir = new File(storageDir, "data");
+ assertTrue(dataDir.exists(), "Expected to find data directory at " + dataDir);
+
+ File savedCachesDir = new File(storageDir, "saved_caches");
+ assertTrue(savedCachesDir.exists(), "Expected to find saved_caches directory at " + savedCachesDir);
+ }
+
+ private void assertNodeIsRunning() {
+ try {
+ installer.verifyNodeIsUp("127.0.0.1", 7299, 3, 1000);
+ } catch (Exception e) {
+ fail("Failed to verify that node is up", e);
+ }
+ }
+
+ private void assertRhqServerPropsUpdated() {
+ File serverPropsFile = new File(basedir, "rhq-server.properties");
+ Properties properties = new Properties();
+
+ try {
+ properties.load(new FileInputStream(serverPropsFile));
+ } catch (IOException e) {
+ fail("Failed to verify that " + serverPropsFile + " was updated", e);
+ }
+
+ String seeds = properties.getProperty("rhq.cassandra.seeds");
+
+ assertEquals(seeds, "127.0.0.1|7299|9142");
+ }
+
+}
diff --git a/modules/common/cassandra-installer/src/test/resources/log4j.properties b/modules/common/cassandra-installer/src/test/resources/log4j.properties
new file mode 100644
index 0000000..d56cc88
--- /dev/null
+++ b/modules/common/cassandra-installer/src/test/resources/log4j.properties
@@ -0,0 +1,41 @@
+#
+# /*
+# * RHQ Management Platform
+# * Copyright (C) 2005-2012 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.
+# */
+#
+
+log4j.rootCategory=WARN, FILE, CONSOLE
+
+log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.FILE.DatePattern='.'yyyy-MM-dd
+log4j.appender.FILE.File=./target/test.log
+log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.FILE.layout.ConversionPattern=%d{ABSOLUTE} %-5p %c %m%n
+#log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
+log4j.appender.FILE.Append=false
+
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+#log4j.appender.CONSOLE.layout.ConversionPattern=%5p %d{HH:mm:ss,SSS} %m%n
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p %c %m%n
+
+log4j.logger.org.rhq=DEBUG
commit e798901b83e37cd267a2d11489664569918ef90d
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 16 16:16:01 2013 -0400
cleaning up dependencies
diff --git a/modules/common/cassandra-schema/pom.xml b/modules/common/cassandra-schema/pom.xml
index 8e3b44a..55dedb8 100644
--- a/modules/common/cassandra-schema/pom.xml
+++ b/modules/common/cassandra-schema/pom.xml
@@ -15,12 +15,6 @@
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>rhq-cassandra-ccm-core</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
<artifactId>rhq-cassandra-util</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/modules/enterprise/server/server-metrics/pom.xml b/modules/enterprise/server/server-metrics/pom.xml
index 2245978..97496f7 100644
--- a/modules/enterprise/server/server-metrics/pom.xml
+++ b/modules/enterprise/server/server-metrics/pom.xml
@@ -47,18 +47,6 @@
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>rhq-cassandra-ccm-core</artifactId>
- <version>${project.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.cassandra</groupId>
- <artifactId>cassandra-clientutil</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
<artifactId>rhq-cassandra-ccm-testng</artifactId>
<version>${project.version}</version>
<scope>test</scope>
commit ae96f1c0ad6e797e889923dc47a1f3c55c8eb394
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jul 17 11:06:21 2013 +0200
Allow to specify a directory with classes to scan for plugin annotations and to auto-create metrics+operations from them.
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Parameter.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Parameter.java
index 4b82a13..29dcc1e 100644
--- a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Parameter.java
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Parameter.java
@@ -29,13 +29,14 @@ import java.lang.annotation.Target;
/**
* Parameter.
- *
+ *
* @author Galder Zamarreño
* @since 4.0
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface Parameter {
- String name() default "";
+ String name() ;
String description() default "";
+ RhqType type() default RhqType.VOID;
}
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqType.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqType.java
new file mode 100644
index 0000000..1487a51
--- /dev/null
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqType.java
@@ -0,0 +1,77 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.helpers.pluginAnnotations.agent;
+
+import java.io.File;
+
+
+/**
+ * Base data types from RHQ for properties
+ * @author Heiko W. Rupp
+ */
+public enum RhqType {
+ INTEGER(new Class<?>[]{Integer.class,int.class},Boolean.class),
+ LONG(new Class<?>[]{Long.class,long.class},Long.class),
+ DOUBLE(new Class<?>[]{Double.class,double.class},Double.class),
+ STRING(new Class<?>[]{String.class},String.class),
+ LONG_STRING(new Class<?>[]{},String.class),
+ PASSWORD(new Class<?>[]{},String.class),
+ BOOLEAN(new Class<?>[]{Boolean.class, boolean.class},Boolean.class),
+ FLOAT(new Class<?>[]{Float.class, float.class},Float.class),
+ FILE(new Class<?>[]{File.class},File.class),
+ DIRECTORY(new Class<?>[]{},File.class),
+ VOID(new Class<?>[]{Void.class,void.class},Void.class)
+ ;
+ private Class<?>[] fromClasses;
+ private Class<?> toClass;
+
+ private RhqType(Class<?>[] fromClasses,Class<?> toClass) {
+
+ this.fromClasses = fromClasses;
+ this.toClass = toClass;
+ }
+
+ public Class<?>[] getFromClasses() {
+ return fromClasses;
+ }
+
+ public Class<?> getToClass() {
+ return toClass;
+ }
+
+ public static RhqType findType(Class<?> clazz) {
+ for (RhqType type : RhqType.values()) {
+ for (Class from : type.getFromClasses()) {
+ if (clazz.equals(from)) {
+ return type;
+ }
+ }
+ }
+ return null;
+ }
+
+ public String getRhqName() {
+ String name = name().toLowerCase();
+ if (name.equals("long_string")) {
+ name = "longString";
+ }
+ return name;
+ }
+}
diff --git a/modules/helpers/pluginGen/pom.xml b/modules/helpers/pluginGen/pom.xml
index 5aa512c..e7744e4 100644
--- a/modules/helpers/pluginGen/pom.xml
+++ b/modules/helpers/pluginGen/pom.xml
@@ -19,6 +19,11 @@
<name>RHQ plugin generator</name>
<description>Helper to generate plugin skeletons</description>
+ <properties>
+ <!-- we are using JDK 1.7 here, as JavaFX needs this and the generator is standalone anyway -->
+ <animal.sniffer.java.signature.artifactId>java17</animal.sniffer.java.signature.artifactId>
+ </properties>
+
<build>
<plugins>
@@ -104,7 +109,7 @@
<dependency>
<groupId>org.rhq.helpers</groupId>
<artifactId>rhq-pluginAnnotations</artifactId>
- <version>4.8.0-SNAPSHOT</version>
+ <version>4.9.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/AnnotationProcessor.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/AnnotationProcessor.java
new file mode 100644
index 0000000..3c90b7b
--- /dev/null
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/AnnotationProcessor.java
@@ -0,0 +1,44 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.helpers.pluginGen;
+
+import java.util.List;
+
+/**
+ * Processor that scans a directory for annotated classes and generates metrics etc. from them.
+ * @author Heiko W. Rupp
+ */
+public class AnnotationProcessor {
+
+ private List<Class> classList;
+ private final DirectoryClassLoader classLoader;
+
+ public AnnotationProcessor(String baseDirectory) {
+ classLoader = new DirectoryClassLoader();
+ classLoader.setBaseDir(baseDirectory);
+ }
+
+ public void populate(Props props) {
+ classList = classLoader.findClasses();
+
+ props.populateMetrics(classList);
+ props.populateOperations(classList);
+ }
+}
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/DirectoryClassLoader.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/DirectoryClassLoader.java
new file mode 100644
index 0000000..b4a729f
--- /dev/null
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/DirectoryClassLoader.java
@@ -0,0 +1,142 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.helpers.pluginGen;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.nio.file.FileVisitor;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
+/**
+ * Classloader to load from a given directory
+ * @author Heiko W. Rupp
+ */
+public class DirectoryClassLoader extends ClassLoader {
+ private Hashtable classes = new Hashtable(); //used to cache already defined classes
+ private String baseDir;
+
+ @Override
+ protected Class<?> findClass(String pathName) throws ClassNotFoundException {
+
+
+ if (baseDir==null) {
+ throw new IllegalStateException("Must set baseDir first");
+ }
+
+ byte classByte[];
+ Class result = null;
+
+ String className = pathName.substring(baseDir.length()+1); // remove base dir
+ className = className.substring(0,className.length()-6); // remove .class
+ className = className.replaceAll(File.separator,"."); // change / -> .
+
+ result = (Class) classes.get(className); //checks in cached classes
+ if (result != null) {
+ return result;
+ }
+ try {
+ File classFile = new File(pathName);
+ FileInputStream fis = new FileInputStream(classFile);
+
+ ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+ int nextValue = fis.read();
+ while (-1 != nextValue) {
+ byteStream.write(nextValue);
+ nextValue = fis.read();
+ }
+
+ classByte = byteStream.toByteArray();
+ result = defineClass(className, classByte, 0, classByte.length, null);
+ classes.put(className, result);
+ return result;
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ public void setBaseDir(String baseDir) {
+ this.baseDir = baseDir;
+ }
+
+ public List<Class> findClasses() {
+ if (baseDir==null) {
+ throw new IllegalStateException("Must set baseDir first");
+ }
+
+ File baseFile = new File(baseDir);
+ if(!baseFile.isDirectory()) {
+ throw new IllegalStateException("BaseDir is no directory");
+ }
+ if (!baseFile.canRead()) {
+ throw new IllegalStateException("BaseDir is not readable");
+ }
+
+ List<File> files = walk(baseFile);
+
+ List<Class> classes = new ArrayList<>();
+ for (File file : files) {
+ String fileName = file.getAbsolutePath();
+
+ Class clazz = null;
+ try {
+ clazz = findClass(fileName);
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace(); // TODO: Customise this generated block
+ }
+ classes.add(clazz);
+
+ }
+
+ return classes;
+ }
+
+ private List<File> walk(File path) {
+
+ List<File> files = new ArrayList<>();
+
+ File[] list = path.listFiles();
+
+ if (list == null) {
+ return files;
+ }
+
+ for ( File f : list ) {
+ if ( f.isDirectory() ) {
+ List<File> newFiles = walk( f );
+ System.out.println( "Dir:" + f.getAbsoluteFile() );
+ files.addAll(newFiles);
+ }
+ else {
+ System.out.println( "File:" + f.getAbsoluteFile() );
+ if (f.getName().endsWith(".class") && !f.getName().contains("$")) {
+ files.add(f);
+ }
+
+ }
+ }
+ return files;
+ }
+}
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Generator.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Generator.java
index e7da952..21d0d4d 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Generator.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Generator.java
@@ -149,9 +149,12 @@ public class Generator extends Application{
Label label = new Label("Messages:");
msgBox.getChildren().add(label);
errorMessage = new Text();
- errorMessage.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12));
+ errorMessage.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 15));
errorMessage.setId("errorMessage");
msgBox.getChildren().add(errorMessage);
+ msgBox.setPadding(new Insets(5));
+ msgBox.setSpacing(3);
+ msgBox.setAlignment(Pos.BASELINE_LEFT);
return msgBox;
}
@@ -172,94 +175,14 @@ public class Generator extends Application{
// Now add the field itself
final Class propType = prop.getType();
if (propType.equals(String.class)) {
- final Pattern pattern = Pattern.compile(prop.getValidationRegex());
-
- final TextField input = new TextField();
- // Add field leave event to fill in the props with the result
- input.focusedProperty().addListener(new ChangeListener<Boolean>() {
- @Override
- public void changed(ObservableValue<? extends Boolean> observableValue, Boolean oldState,
- Boolean newState) {
- if (newState) { // User entered input field
- descriptionField.setText(prop.getDescription());
- }
- else { // User left input field
- descriptionField.setText("");
- setPropsValue(prop.getVariableName(),input.getText(), propType); // TODO right place?
- }
- }
- });
- // Add validation of the input
- input.textProperty().addListener(new ChangeListener<String>() {
- @Override
- public void changed(ObservableValue<? extends String> observableValue, String s, String newText) {
- Matcher m = pattern.matcher(newText);
- if (!m.matches()) {
- setErrorMessage("Input does not match " + prop.getValidationRegex());
- } else {
- clearErrorMessage();
- }
-
- }
- });
- root.add(input, 1, row);
+ addStringField(root, descriptionField, row, prop);
} else if (propType.equals(Boolean.class) || propType.equals(boolean.class)) {
- final ChoiceBox choiceBox = new ChoiceBox();
- choiceBox.getItems().addAll("Yes", "No");
- choiceBox.getSelectionModel().selectLast(); // NO is default
- choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
- @Override
- public void changed(ObservableValue<? extends String> observableValue, String s, String newValue) {
- setPropsValue(prop.getVariableName(), newValue.equals("Yes"), propType);
- }
- });
- Tooltip tooltip = new Tooltip(prop.getDescription()); // TODO make this a hover listener
- choiceBox.setTooltip(tooltip);
-
- root.add(choiceBox, 1, row);
+ addBooleanField(root, row, prop);
} else if (propType.equals(ResourceCategory.class)) {
- final ChoiceBox choiceBox = new ChoiceBox();
- for (ResourceCategory cat : ResourceCategory.values()) {
- choiceBox.getItems().add(cat.getLowerName());
- }
- choiceBox.getSelectionModel().selectLast(); // service is default
- choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
- @Override
- public void changed(ObservableValue<? extends String> observableValue, String s, String newValue) {
- ResourceCategory newCategory = ResourceCategory.valueOf(newValue.toUpperCase());
- setPropsValue(prop.getVariableName(),newCategory,propType);
- }
- });
- Tooltip tooltip = new Tooltip(prop.getDescription()); // TODO make this a hover listener
- choiceBox.setTooltip(tooltip);
- root.add(choiceBox,1,row);
+ addResourceTypeChooser(root, row, prop);
} else if (propType.equals(File.class)) {
- // Can not add this directly, so add a button to trigger it
- final Text text = new Text();
- text.setText("Pick a directory");
- root.add(text,1,row);
- Tooltip tooltip = new Tooltip("Pick the (parent) directory where the plugin will be put in.");
- Button pickButton = new Button("Pick");
- pickButton.setTooltip(tooltip);
- pickButton.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle(ActionEvent actionEvent) {
- DirectoryChooser chooser = new DirectoryChooser();
- chooser.setTitle("Pick a directory where the plugin will be put in.");
- File dir = chooser.showDialog(primaryStage);
- if (dir != null) {
- String dirName = dir.getAbsolutePath();
- props.setFileSystemRoot(dirName);
- clearErrorMessage();
- text.setText(dirName);
- } else {
- setErrorMessage("No directory selected");
- text.setText("Pick a directory");
- }
- }
- });
-
- root.add(pickButton,2,row);
+ addDirectoryChooserField(root, row, prop, descriptionField);
+
}
row++;
@@ -269,6 +192,115 @@ public class Generator extends Application{
return row;
}
+ private void addDirectoryChooserField(GridPane root, int row, final Prop prop, final Text descriptionField) {
+ // Can not add this directly, so add a button to trigger it
+ final TextField input = new TextField();
+ root.add(input,1,row);
+ Tooltip tooltip = new Tooltip(prop.getDescription());
+ Button pickButton = new Button("Pick");
+ input.setTooltip(tooltip);
+ pickButton.setTooltip(tooltip);
+ pickButton.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent actionEvent) {
+ DirectoryChooser chooser = new DirectoryChooser();
+ chooser.setTitle(prop.getDescription());
+ File dir = chooser.showDialog(primaryStage);
+ if (dir != null) {
+ String dirName = dir.getAbsolutePath();
+ setPropsValue(prop.getVariableName(), dirName, String.class);
+ clearErrorMessage();
+ input.setText(dirName);
+ } else {
+ setErrorMessage("No directory selected");
+ input.setText("Pick a directory");
+ }
+ }
+ });
+ input.focusedProperty().addListener(new ShowFieldDescriptionHandler(prop,descriptionField,input));
+ // Add validation of the input
+ input.textProperty().addListener(new ChangeListener<String>() {
+ @Override
+ public void changed(ObservableValue<? extends String> observableValue, String s, String newText) {
+ File file = new File(newText);
+ if (!file.isDirectory()) {
+ setErrorMessage(newText + " is no directory");
+ } else if (prop.isDirectoryWriteable() && !file.canWrite()) {
+ setErrorMessage(newText + " is not writable");
+ } else if (!prop.isDirectoryWriteable() && !file.canRead()) {
+ setErrorMessage(newText + " is not readable");
+ } else {
+ clearErrorMessage();
+ }
+
+ }
+ });
+
+
+
+ root.add(pickButton,2,row);
+ }
+
+ private void addResourceTypeChooser(GridPane root, int row, final Prop prop) {
+ final ChoiceBox choiceBox = new ChoiceBox();
+ for (ResourceCategory cat : ResourceCategory.values()) {
+ choiceBox.getItems().add(cat.getLowerName());
+ }
+ choiceBox.getSelectionModel().selectLast(); // service is default
+ choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
+ @Override
+ public void changed(ObservableValue<? extends String> observableValue, String s, String newValue) {
+ ResourceCategory newCategory = ResourceCategory.valueOf(newValue.toUpperCase());
+ setPropsValue(prop.getVariableName(),newCategory,prop.getType());
+ }
+ });
+ Tooltip tooltip = new Tooltip(prop.getDescription()); // TODO make this a hover listener
+ choiceBox.setTooltip(tooltip);
+ root.add(choiceBox,1,row);
+ }
+
+ private void addBooleanField(GridPane root, int row, final Prop prop) {
+ final ChoiceBox choiceBox = new ChoiceBox();
+ choiceBox.getItems().addAll("Yes", "No");
+ choiceBox.getSelectionModel().selectLast(); // NO is default
+ choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
+ @Override
+ public void changed(ObservableValue<? extends String> observableValue, String s, String newValue) {
+ setPropsValue(prop.getVariableName(), newValue.equals("Yes"), prop.getType());
+ }
+ });
+ Tooltip tooltip = new Tooltip(prop.getDescription()); // TODO make this a hover listener
+ choiceBox.setTooltip(tooltip);
+
+ root.add(choiceBox, 1, row);
+ }
+
+ private void addStringField(GridPane root, final Text descriptionField, int row, final Prop prop) {
+ final Pattern pattern = Pattern.compile(prop.getValidationRegex());
+
+ final TextField input = new TextField();
+ if (prop.getDefaultValue()!=null && !prop.getDefaultValue().isEmpty()) {
+ input.setText(prop.getDefaultValue());
+ setPropsValue(prop.getVariableName(),prop.getDefaultValue(),prop.getType());
+ }
+ // Add field leave event to fill in the props with the result
+ input.focusedProperty().addListener(new ShowFieldDescriptionHandler(prop,descriptionField,input));
+ // Add validation of the input
+ input.textProperty().addListener(new ChangeListener<String>() {
+ @Override
+ public void changed(ObservableValue<? extends String> observableValue, String s, String newText) {
+ Matcher m = pattern.matcher(newText);
+ if (!m.matches()) {
+ setErrorMessage("Input does not match " + prop.getValidationRegex());
+ } else {
+ clearErrorMessage();
+ }
+
+ }
+ });
+ root.add(input, 1, row);
+ }
+
private void setInfoMessage(String message) {
errorMessage.setText(message);
errorMessage.setFill(Color.DARKGREEN);
@@ -297,4 +329,29 @@ public class Generator extends Application{
}
}
+
+ private class ShowFieldDescriptionHandler implements ChangeListener<Boolean> {
+
+ private Prop prop;
+ private Text descriptionField;
+ private TextField input;
+
+ private ShowFieldDescriptionHandler(Prop prop,Text descriptionField, TextField input) {
+ this.prop = prop;
+ this.descriptionField = descriptionField;
+ this.input = input;
+ }
+
+ @Override
+ public void changed(ObservableValue<? extends Boolean> observableValue, Boolean oldState,
+ Boolean newState) {
+ if (newState) { // User entered input field
+ descriptionField.setText(prop.getDescription());
+ }
+ else { // User left input field
+ descriptionField.setText("");
+ setPropsValue(prop.getVariableName(),input.getText(), String.class); // TODO right place?
+ }
+ }
+ }
}
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/PluginGen.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/PluginGen.java
index 64b5509..8722446 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/PluginGen.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/PluginGen.java
@@ -51,6 +51,19 @@ public class PluginGen {
private final Log log = LogFactory.getLog(PluginGen.class);
public static void main(String[] arg) throws Exception {
+
+ if (arg.length>0) {
+ if (arg[0].equals("-ui")) {
+ Generator.main(arg);
+
+ }
+ else {
+ System.out.println("use option -ui to start the UI version");
+ }
+ System.exit(0);
+ }
+
+
PluginGen pg = new PluginGen();
pg.run();
@@ -121,10 +134,24 @@ public class PluginGen {
String pkg = props.getPackagePrefix() + "." + props.getName();
props.setPkg(pkg);
+ String name = props.getName(); // Type name
+
+ if (props.getComponentClass().contains("{name}")) {
+ props.setComponentClass(props.getComponentClass().replace("{name}",name));
+ }
+
+ if (props.getDiscoveryClass().contains("{name}")) {
+ props.setDiscoveryClass(props.getDiscoveryClass().replace("{name}",name));
+ }
+
for (Props cProp : props.getChildren()) {
cProp.setPkg(pkg);
}
+ if (props.getScanForAnnotations()!=null) {
+ AnnotationProcessor ap = new AnnotationProcessor(props.getScanForAnnotations());
+ ap.populate(props);
+ }
}
/**
@@ -247,7 +274,7 @@ public class PluginGen {
}
boolean success;
- File activeDirectory = new File(props.getFileSystemRoot(), props.getName());
+ File activeDirectory = new File(props.getFileSystemRoot(), props.getPluginName());
if (!activeDirectory.exists()) {
success = activeDirectory.mkdir();
@@ -260,7 +287,7 @@ public class PluginGen {
// write pom.xml
createFile(props, "pom", "pom.xml", activeDirectory.getAbsolutePath());
- // Create java directory hierarchie
+ // Create java directory hierarchy
String path = activeDirectory.getAbsolutePath() + File.separator + "src" + File.separator + "main"
+ File.separator;
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Prop.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Prop.java
index 4ed019a..40e729c 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Prop.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Prop.java
@@ -30,48 +30,62 @@ public enum Prop {
PLUGIN_NAME("pluginName", String.class,"Name of the plugin", "\\w+" , true ),
PLUGIN_DESCRIPTION("pluginDescription", String.class,"Description of the plugin",".*" , true ),
PACKAGE("packagePrefix", String.class,"Default Package","[a-zA-Z\\.]+",true ),
- FILE_ROOT("fileSystemRoot", File.class,"Root directory to put the plugin",".*",true ),
+ FILE_ROOT("fileSystemRoot", File.class,"Root directory to put the plugin into",".*",true , true,null),
RHQ_VERSION("rhqVersion",String.class,"RHQ version to use","[0-9][0-9\\.]+",true),
CATEGORY("category", ResourceCategory.class, "Category of the resource type (platform = host level)",null),
TYPE_NAME("name", String.class, "Name of the resource type", "\\w+"),
DESCRIPTION("description", String.class, "Description of the type", ".*"),
- DISCOVERY_CLASS("discoveryClass", String.class, "Discovery class", "[A-Z][a-zA-Z0-9]*"),
- COMPONENT_CLASS("componentClass", String.class, "Discovery class", "[A-Z][a-zA-Z0-9]*"),
+ DISCOVERY_CLASS("discoveryClass", String.class, "Name of the Discovery class. '{name}' will be replaced with the type name", "[A-Z][a-zA-Z0-9]*",false,false,"{name}Discovery"),
+ COMPONENT_CLASS("componentClass", String.class, "Name of the Discovery class. '{name}' will be replaced with the type name", "[A-Z][a-zA-Z0-9]*",false,false,"{name}Component"),
IS_SINGLETON("singleton",boolean.class,"Is this type a singleton, which means that" +
- " there can only be one resource of that type for the given parent?",null),
- HAS_METRICS("hasMetrics",boolean.class,"Does this type support taking metrics?",null),
- HAS_OPERATIONS("hasOperations",boolean.class,"Does this type support operations?",null),
- HAS_EVENTS("events",boolean.class,"Does this type support events?",null),
- HAS_SUPPORT_FACET("supportFacet",boolean.class,"Does this type support the support facet?",null),
+ " there can only be one resource of that type for the given parent?"),
+ HAS_METRICS("hasMetrics",boolean.class,"Does this type support taking metrics?"),
+ HAS_OPERATIONS("hasOperations",boolean.class,"Does this type support operations?"),
+ HAS_EVENTS("events",boolean.class,"Does this type support events?"),
+ HAS_SUPPORT_FACET("supportFacet",boolean.class,"Does this type support the support facet?"),
RESOURCE_CONFIGURATION("resourceConfiguration",boolean.class,"Does this type support " +
- "configuring the resource?",".*"),
- CAN_CREATE_CHILDREN("createChildren",boolean.class,"Can the type create child resources?",null),
- CAN_DELETE_CHILDREN("deleteChildren",boolean.class,"Can the type delete child resources?",null),
-
- // TODO add the remaining properties from Prop.class
-
+ "configuring the resource?"),
+ CAN_CREATE_CHILDREN("createChildren",boolean.class,"Can the type create child resources?"),
+ CAN_DELETE_CHILDREN("deleteChildren",boolean.class,"Can the type delete child resources?"),
+ USE_EXTENAL_JARS("usesExternalJarsInPlugin",boolean.class,"Will the plugin use external jars in the plugin jar?"),
+ ALLOW_MANUAL_ADD("manualAddOfResourceType",boolean.class,"Should manually adding resource be supported?"),
+ USE_LIFECYLE_API("usePluginLifecycleListenerApi",boolean.class,"Should the plugin lifecycle api be supported?"),
+ DEPENDS_ON_JMX_PLUGIN("dependsOnJmxPlugin",boolean.class,"Does the plugin use JMX and extend the JMX Plugin?"),
+ DEPENDS_ON_AS7_PLUGIN("dependsOnAs7Plugin",boolean.class,"Does the plugin use DMR and extend the AS7 Plugin?"),
+ USE_SUPPORT_FACET("supportFacet",boolean.class,"Will the support facet be used?"),
+
+ SCAN_FOR_ANNOTATIONS("scanForAnnotations",File.class,"Directory to scan for plugin annotations to include in type",null, false,false, null)
;
private String variableName;
private Class type;
private String description;
private boolean pluginLevel;
+ private boolean directoryWriteable;
+ private String defaultValue;
private String validationRegex;
- private Prop(String variableName, Class type, String description, String validationRegex, boolean pluginLevel) {
+ private Prop(String variableName, Class type, String description, String validationRegex, boolean pluginLevel, boolean directoryWriteable, String defaultValue) {
this.variableName = variableName;
this.type = type;
this.description = description;
this.validationRegex = validationRegex;
this.pluginLevel = pluginLevel;
+ this.directoryWriteable = directoryWriteable;
+ this.defaultValue = defaultValue;
+ }
+
+ private Prop(String variableName, Class type, String description, String validationRegex, boolean pluginLevel) {
+ this(variableName,type,description,validationRegex,pluginLevel,false,null);
}
private Prop(String variableName, Class type, String description, String validationRegex) {
- this.variableName = variableName;
- this.type = type;
- this.description = description;
- this.validationRegex = validationRegex;
+ this(variableName,type,description,validationRegex,false,false,null);
+ }
+
+ private Prop(String variableName, Class type, String description) {
+ this(variableName,type,description,null,false,false,null);
}
public String getVariableName() {
@@ -111,4 +125,11 @@ public enum Prop {
return builder.toString();
}
+ public boolean isDirectoryWriteable() {
+ return directoryWriteable;
+ }
+
+ public String getDefaultValue() {
+ return defaultValue;
+ }
}
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
index 237f5ad..95be574 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
@@ -18,6 +18,9 @@
*/
package org.rhq.helpers.pluginGen;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
@@ -26,6 +29,9 @@ import java.util.Set;
import org.rhq.helpers.pluginAnnotations.agent.DataType;
import org.rhq.helpers.pluginAnnotations.agent.DisplayType;
import org.rhq.helpers.pluginAnnotations.agent.Metric;
+import org.rhq.helpers.pluginAnnotations.agent.Operation;
+import org.rhq.helpers.pluginAnnotations.agent.Parameter;
+import org.rhq.helpers.pluginAnnotations.agent.RhqType;
import org.rhq.helpers.pluginAnnotations.agent.Units;
/**
@@ -33,6 +39,7 @@ import org.rhq.helpers.pluginAnnotations.agent.Units;
*
* @author Heiko W. Rupp
*/
+@SuppressWarnings("unused")
public class Props {
/** What category is this ? */
@@ -69,7 +76,7 @@ public class Props {
private boolean createChildren;
/** Can the service delete children ? */
private boolean deleteChildren;
- /** Use externals chars in the plugin jar ? */
+ /** Use externals jars in the plugin jar ? */
private boolean usesExternalJarsInPlugin;
/** Does it support manual add of children ? */
private boolean manualAddOfResourceType;
@@ -77,8 +84,12 @@ public class Props {
private boolean usePluginLifecycleListenerApi;
/** Depends on JMX plugin ? */
private boolean dependsOnJmxPlugin;
+ /** Depends on AS7 plugin ? */
+ private boolean dependsOnAs7Plugin;
+ /** Directory with java files to scan for plugin annotations */
+ private String scanForAnnotations;
/** What version of RHQ should this plugin's pom use ? */
- private String rhqVersion = "3.0.0";
+ private String rhqVersion = "4.8.0";
/** Embedded children */
private Set<Props> children = new HashSet<Props>();
@@ -336,22 +347,97 @@ public class Props {
this.runsInsides = runsInsides;
}
+ public boolean isDependsOnAs7Plugin() {
+ return dependsOnAs7Plugin;
+ }
+
+ public void setDependsOnAs7Plugin(boolean dependsOnAs7Plugin) {
+ this.dependsOnAs7Plugin = dependsOnAs7Plugin;
+ }
+
+ public String getScanForAnnotations() {
+ return scanForAnnotations;
+ }
+
+ public void setScanForAnnotations(String scanForAnnotations) {
+ this.scanForAnnotations = scanForAnnotations;
+ }
+
public void populateMetrics(List<Class> classes) {
- for (Class<?> clazz : classes) {
- Metric metricAnnot = clazz.getAnnotation(Metric.class);
- if (metricAnnot != null) {
- MetricProps metric = new MetricProps(metricAnnot.property());
+ for (Class<?> clazz : classes) {
+ for (Field field : clazz.getDeclaredFields()) {
+ Metric metricAnnot = field.getAnnotation(Metric.class);
+ addMetric(metricAnnot, field.getName());
+ }
+
+ for (Method method : clazz.getDeclaredMethods()) {
+ Metric metricAnnot = method.getAnnotation(Metric.class);
+ addMetric(metricAnnot, method.getName());
+ }
+ }
+ }
+
+ public void populateOperations(List<Class> classes) {
+ for (Class<?> clazz : classes) {
+ for (Method method : clazz.getDeclaredMethods()) {
+ Operation operationAnnot = method.getAnnotation(Operation.class);
+ if (operationAnnot != null) {
+ String property = operationAnnot.name();
+ if (property.isEmpty()) {
+ property = method.getName();
+ }
+ OperationProps op = new OperationProps(property);
+ op.setDisplayName(operationAnnot.displayName());
+ op.setDescription(operationAnnot.description());
+ RhqType type = RhqType.findType(method.getReturnType());
+ if (type != RhqType.VOID) {
+ SimpleProperty simpleProperty = new SimpleProperty(type.getRhqName());
+ op.setResult(simpleProperty);
+ }
+
+ Class[] types = method.getParameterTypes();
+ int i=0;
+ for (Annotation[] annotations : method.getParameterAnnotations() ) {
+ for (Annotation annotation : annotations) {
+ if (annotation instanceof Parameter) {
+ Parameter parameter = (Parameter) annotation;
+ SimpleProperty simpleProperty = new SimpleProperty(parameter.name());
+ simpleProperty.setDescription(parameter.description());
+ Class typeClass = types[i];
+ RhqType rhqType = RhqType.findType(typeClass);
+ if (parameter.type()!=RhqType.VOID){
+ rhqType = parameter.type();
+ }
+ simpleProperty.setType(rhqType.getRhqName());
+ op.getParams().add(simpleProperty);
+ }
+ }
+ i++;
+ }
+ operations.add(op);
+ }
+
+ }
+ }
+ }
+
+ private void addMetric(Metric metricAnnot, String name) {
+ if (metricAnnot != null) {
+ String property = metricAnnot.property();
+ if (property.isEmpty()) {
+ property = name;
+ }
+ MetricProps metric = new MetricProps(property);
metric.setDisplayName(metricAnnot.displayName());
metric.setDisplayType(metricAnnot.displayType());
metric.setDataType(metricAnnot.dataType());
metric.setDescription(metricAnnot.description());
+ metric.setUnits(metricAnnot.units());
metrics.add(metric);
- }
-
- }
- }
+ }
+ }
- @Override
+ @Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("Props");
@@ -387,7 +473,7 @@ public class Props {
return sb.toString();
}
- public static class TypeKey {
+ public static class TypeKey {
private String name;
private String pluginName;
diff --git a/modules/helpers/pluginGen/src/main/resources/component.ftl b/modules/helpers/pluginGen/src/main/resources/component.ftl
index 1b3dda1..b445008 100644
--- a/modules/helpers/pluginGen/src/main/resources/component.ftl
+++ b/modules/helpers/pluginGen/src/main/resources/component.ftl
@@ -187,7 +187,6 @@ public class ${props.componentClass} implements ResourceComponent<#if props.pare
<#if props.operations??>
-
public void startOperationFacet(OperationContext context) {
}
@@ -203,6 +202,13 @@ public class ${props.componentClass} implements ResourceComponent<#if props.pare
public OperationResult invokeOperation(String name, Configuration params) throws Exception {
OperationResult res = new OperationResult();
+<#if props.operations?has_content>
+ <#list props.operations as operation>
+ if (name.equals("${operation.name}") {
+ // TODO implement me
+ }
+ </#list>
+<#else>
if ("dummyOperation".equals(name)) {
// TODO implement me
@@ -210,6 +216,7 @@ public class ${props.componentClass} implements ResourceComponent<#if props.pare
return res;
}
</#if>
+</#if>
<#if props.resourceConfiguration>
diff --git a/modules/helpers/pluginGen/src/main/resources/descriptor.ftl b/modules/helpers/pluginGen/src/main/resources/descriptor.ftl
index 85195e8..1fe2a6b 100644
--- a/modules/helpers/pluginGen/src/main/resources/descriptor.ftl
+++ b/modules/helpers/pluginGen/src/main/resources/descriptor.ftl
@@ -1,7 +1,7 @@
<#--
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -38,6 +38,9 @@
<#if props.dependsOnJmxPlugin>
<depends plugin="JMX" useClasses="true"/>
</#if>
+<#if props.dependsOnAs7Plugin>
+ <depends plugin="JBossAS7" useClasses="true"/>
+</#if>
<${props.category.lowerName} <#include "descriptorMain.ftl"/>
diff --git a/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl b/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
index b650f7a..5579806 100644
--- a/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
+++ b/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
@@ -1,7 +1,7 @@
<#--
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -39,6 +39,11 @@ name="${props.name}"
</#list>
</runs-inside>
</#if>
+ <#if props.dependsOnAs7Plugin>
+ <runs-inside> <!-- TODO adjust type -->
+ <parent-resource-type name="JBossAS7 Standalone Server" plugin="JBossAS7"/>
+ </runs-inside>
+ </#if>
<#if props.simpleProps?has_content>
<plugin-configuration>
@@ -57,14 +62,14 @@ name="${props.name}"
</plugin-configuration>
</#if>
- <#if props.hasOperations>
+ <#if props.hasOperations || props.operations?has_content>
<#if props.operations?has_content>
<#list props.operations as operation>
- <operation name="${operation.name}" displayName="${operation.displayName}" description="${operation.description}">
+ <operation name="${operation.name}" <#if operation.displayName?has_content>displayName="${operation.displayName}"</#if> description="${operation.description}">
<#if operation.params?has_content>
<parameters>
<#list operation.params as param>
- <c:simple-property name="${param.name}" <#if param.description??>description="${param.description}"</#if>/>
+ <c:simple-property name="${param.name}" <#if param.description??>description="${param.description}"</#if> type="${param.type}"/>
</#list>
</parameters>
</#if>
@@ -82,10 +87,10 @@ name="${props.name}"
</#if>
</#if>
- <#if props.hasMetrics>
+ <#if props.hasMetrics || props.metrics?has_content>
<#if props.metrics?has_content>
<#list props.metrics as metric>
- <metric property="${metric.property}" displayName="${metric.displayName}" displayType="${metric.displayType}" units="${metric.units}" dataType="${metric.dataType}"
+ <metric property="${metric.property}" <#if metric.displayName?has_content>displayName="${metric.displayName}"</#if> displayType="${metric.displayType}" units="${metric.units}" dataType="${metric.dataType}"
description="${metric.description}" />
</#list>
<#else>
diff --git a/modules/helpers/pluginGen/src/main/resources/pom.ftl b/modules/helpers/pluginGen/src/main/resources/pom.ftl
index 01daca1..7c799b8 100644
--- a/modules/helpers/pluginGen/src/main/resources/pom.ftl
+++ b/modules/helpers/pluginGen/src/main/resources/pom.ftl
@@ -2,7 +2,7 @@
<#--
/*
* RHQ Management Platform
- * Copyright (C) 2005-20012 Red Hat, Inc.
+ * Copyright (C) 2005-20013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -35,10 +35,10 @@
</parent>
<groupId>org.rhq</groupId>
- <artifactId>${props.name}-plugin</artifactId>
+ <artifactId>${props.pluginName}-plugin</artifactId>
<packaging>jar</packaging>
- <name>RHQ ${props.name} Plugin</name>
+ <name>RHQ ${props.pluginName} Plugin</name>
<#if props.description??>
<description>${props.description}</description>
</#if>
@@ -86,7 +86,6 @@
</executions>
</plugin>
</#if>
-
</plugins>
</build>
@@ -232,6 +231,14 @@
<scope>provided</scope>
</dependency>
</#if>
+<#if props.dependsOnAs7Plugin>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-jboss-as-7-plugin</artifactId>
+ <version>${r"${project.version}"}</version>
+ <scope>provided</scope>
+ </dependency>
+</#if>
<!-- TODO add your dependencies here -->
diff --git a/modules/helpers/pluginGen/src/test/java/org/rhq/helpers/pluginGen/test/FooBean.java b/modules/helpers/pluginGen/src/test/java/org/rhq/helpers/pluginGen/test/FooBean.java
new file mode 100644
index 0000000..fbc571b
--- /dev/null
+++ b/modules/helpers/pluginGen/src/test/java/org/rhq/helpers/pluginGen/test/FooBean.java
@@ -0,0 +1,55 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.helpers.pluginGen.test;
+
+import org.rhq.helpers.pluginAnnotations.agent.DataType;
+import org.rhq.helpers.pluginAnnotations.agent.DisplayType;
+import org.rhq.helpers.pluginAnnotations.agent.MeasurementType;
+import org.rhq.helpers.pluginAnnotations.agent.Metric;
+import org.rhq.helpers.pluginAnnotations.agent.Operation;
+import org.rhq.helpers.pluginAnnotations.agent.Parameter;
+import org.rhq.helpers.pluginAnnotations.agent.RhqType;
+
+/**
+ * Just a sample
+ * @author Heiko W. Rupp
+ */
+
+public class FooBean {
+
+ @Metric(description = "How often was this bean invoked", displayType = DisplayType.SUMMARY, measurementType = MeasurementType.DYNAMIC)
+ int invocationCount;
+
+ @Metric(description = "Just a foo", dataType = DataType.TRAIT)
+ String lastCommand;
+
+ @Operation(description = "Increase the invocation count")
+ public int increaseCounter() {
+ invocationCount++;
+ return invocationCount;
+ }
+
+ @Operation(description = "Decrease the counter")
+ public void decreaseCounter(@Parameter(description = "How much to decrease?", name = "by") int by) {
+ invocationCount -= by;
+ }
+
+
+}
commit 2ee2ef305dd71c1f2869a5a8c4e8ebe9f9bae243
Author: Michael Burman <yak(a)iki.fi>
Date: Tue Jul 16 15:58:05 2013 -0400
committing windows version of RHQ 4.8 storage patch script
diff --git a/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.bat b/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.bat
new file mode 100644
index 0000000..e0312dc
--- /dev/null
+++ b/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.bat
@@ -0,0 +1,64 @@
+@echo off
+setlocal
+
+if /i "%4" == "" (
+ echo Usage: rhq48-storage-patch.bat ^<rhq-server-dir^> ^<storage-ip-address^> ^<cql-port^> ^<jmx-port^>
+ exit /B 1
+)
+
+set RHQ_SERVER_DIR=%1
+set CQL_HOSTNAME=%2
+set CQL_PORT=%3
+set JMX_PORT=%4
+set USERNAME="rhqadmin"
+set PASSWORD="rhqadmin"
+
+set PATCH="apache-cassandra-1.2.4-patch-1.jar"
+
+rem swap out the Cassandra jar file with the patched version
+echo Copying patch file to %RHQ_SERVER_DIR%\rhq-storage\lib
+move %RHQ_SERVER_DIR%\rhq-storage\lib\apache-cassandra-1.2.4.jar .
+copy %PATCH% %RHQ_SERVER_DIR%\rhq-storage\lib
+
+rem restart the storage node
+echo Starting RHQ Storage node
+call %RHQ_SERVER_DIR%\bin\rhqctl.bat start --storage
+
+rem sleep for a few seconds while Cassandra starts up
+echo Waiting for RHQ Storage Node to start up..
+rem Sleep is not implemented in all Windows prompts, this one won't work in Vista
+choice /n /c y /d y /t 3
+
+set RHQ_STORAGE_BIN=%RHQ_SERVER_DIR%\rhq-storage\bin\
+set CQLSH_PATH=%RHQ_STORAGE_BIN%\cqlsh
+set NODETOOL_PATH=%RHQ_STORAGE_BIN%\nodetool.bat
+
+rem run the CQL script
+echo Running CQL script to disable table compression
+python %CQLSH_PATH% -u %USERNAME% -p %PASSWORD% -f ./disable_compression.cql
+
+rem rewrite all sstables
+echo Rebuilding data files for system keyspace
+call %NODETOOL_PATH% -u rhqadmin -pw rhqadmin -p %JMX_PORT% upgradesstables --include-all-sstables system
+
+echo Rebuilding data files for system_traces keyspace
+call %NODETOOL_PATH% -u rhqadmin -pw rhqadmin -p %JMX_PORT% upgradesstables --include-all-sstables system_traces
+
+echo Rebuilding data files for system_auth keyspace
+call %NODETOOL_PATH% -u rhqadmin -pw rhqadmin -p %JMX_PORT% upgradesstables --include-all-sstables system_auth
+
+echo Rebuilding data files for rhq keyspace
+call %NODETOOL_PATH% -u rhqadmin -pw rhqadmin -p %JMX_PORT% upgradesstables --include-all-sstables rhq
+
+rem flush memtables and commit log to ensure no data loss prior to upgrade
+call %NODETOOL_PATH% -u rhqadmin -pw rhqadmin -p %JMX_PORT% drain
+
+echo Shutting down the RHQ Storage node
+call %RHQ_SERVER_DIR%\bin\rhqctl.bat stop --storage
+
+echo Removing patch file
+del %RHQ_SERVER_DIR%\rhq-storage\lib\%PATCH%
+move apache-cassandra-1.2.4.jar %RHQ_SERVER_DIR%\rhq-storage\lib
+
+echo Table compression has been disabled for all keyspaces. You are now ready to upgrade your RHQ installation.
+endlocal
commit 9983f60ec49f72b5bb0afcfb452afde616c622a6
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Tue Jul 16 17:51:59 2013 +0200
Fix InterruptibleOperationsTest. Mock resource context needs a ComponentInvocationContext instance.
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/InterruptibleOperationsTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/InterruptibleOperationsTest.java
index 192117c..b0acf4d 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/InterruptibleOperationsTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/InterruptibleOperationsTest.java
@@ -47,6 +47,7 @@ import org.eclipse.jetty.servlet.ServletHolder;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
+import org.rhq.core.pluginapi.component.ComponentInvocationContext;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -95,6 +96,7 @@ public class InterruptibleOperationsTest {
int httpPort = setupJettyServer();
setupResourceContext(httpPort);
executorService = Executors.newSingleThreadExecutor();
+ when(resourceContext.getComponentInvocationContext()).thenReturn(new MockComponentInvocationContext());
serverComponent.start(resourceContext);
}
@@ -160,6 +162,17 @@ public class InterruptibleOperationsTest {
assertEquals(operationResult.getSimpleResult(), "Success");
}
+ private static class MockComponentInvocationContext implements ComponentInvocationContext {
+ @Override
+ public boolean isInterrupted() {
+ return false;
+ }
+
+ @Override
+ public void markInterrupted() {
+ }
+ }
+
private class RestartJetty implements Runnable {
@Override
public void run() {
commit fb809005b42f358d3a2090993431769649ade732
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Jul 16 15:54:07 2013 +0200
Updating the list of the devs in the IRC bot
diff --git a/etc/rhq-ircBot/src/main/java/org/rhq/etc/ircbot/RhqIrcBotListener.java b/etc/rhq-ircBot/src/main/java/org/rhq/etc/ircbot/RhqIrcBotListener.java
index dd22dbf..cc10d2d 100644
--- a/etc/rhq-ircBot/src/main/java/org/rhq/etc/ircbot/RhqIrcBotListener.java
+++ b/etc/rhq-ircBot/src/main/java/org/rhq/etc/ircbot/RhqIrcBotListener.java
@@ -77,8 +77,7 @@ public class RhqIrcBotListener extends ListenerAdapter<RhqIrcBot> {
private static final Set<String> JON_DEVS = new HashSet<String>();
static {
- JON_DEVS.add("ccrouch");
- JON_DEVS.add("ips");
+ JON_DEVS.add("theute");
JON_DEVS.add("jkremser");
JON_DEVS.add("jsanda");
JON_DEVS.add("jshaughn");
@@ -377,4 +376,4 @@ public class RhqIrcBotListener extends ListenerAdapter<RhqIrcBot> {
this.docspacePassword = docspacePassword;
}
-}
\ No newline at end of file
+}
commit 98258686d712608aef7a21108f6a5505ffb820b7
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 16 08:16:57 2013 -0500
Add justification for the api changes to the Storage Node Manager bean.
diff --git a/modules/enterprise/server/jar/intentional-api-changes-since-4.8.0.xml b/modules/enterprise/server/jar/intentional-api-changes-since-4.8.0.xml
new file mode 100644
index 0000000..a9ce322
--- /dev/null
+++ b/modules/enterprise/server/jar/intentional-api-changes-since-4.8.0.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<differences>
+
+ <difference>
+ <className>org/rhq/enterprise/server/cloud/StorageNodeManagerRemote</className>
+ <differenceType>7012</differenceType> <!-- method added to an interface -->
+ <method>org.rhq.core.domain.util.PageList findNotAcknowledgedStorageNodeAlerts(org.rhq.core.domain.auth.Subject)</method>
+ <justification>Adding a method to a remote API interface is safe. This is newly implemented functionality.</justification>
+ </difference>
+
+ <difference>
+ <className>org/rhq/enterprise/server/cloud/StorageNodeManagerRemote</className>
+ <differenceType>7012</differenceType> <!-- method added to an interface -->
+ <method>org.rhq.core.domain.util.PageList findAllStorageNodeAlerts(org.rhq.core.domain.auth.Subject)</method>
+ <justification>Adding a method to a remote API interface is safe. This is newly implemented functionality.</justification>
+ </difference>
+
+</differences>
commit 6ad3c87c08631a00cb960a4ffa4c4929329aa6d8
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Tue Jul 16 13:42:50 2013 +0200
Bug 982804 - AS7 reload behavior includes hardcoded timeout of 20 seconds
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java
index 8c708db..41a1c41 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java
@@ -173,6 +173,8 @@ public class ResourceContext<T extends ResourceComponent<?>> {
* @param availabilityContext a {@link AvailabilityContext} the plugin can use to interoperate with the
* plugin container inventory manager
* @param pluginContainerDeployment indicates where the plugin container is running
+ * @param componentInvocationContext a {@link ComponentInvocationContext} the plugin can use to determine if the
+ * current component invocation has been canceled or timed out.
*/
public ResourceContext(Resource resource, T parentResourceComponent, ResourceContext<?> parentResourceContext,
ResourceDiscoveryComponent<T> resourceDiscoveryComponent, SystemInfo systemInfo, File temporaryDirectory,
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 4cb2cff..a9fe1c2 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
@@ -609,6 +609,8 @@ public class ResourceContainer implements Serializable {
}
private static class ComponentInvocation implements Callable {
+ private static final Log LOG = LogFactory.getLog(ComponentInvocation.class);
+
private final ResourceContainer resourceContainer;
private final Method method;
private final Object[] args;
@@ -669,6 +671,8 @@ public class ResourceContainer implements Serializable {
public void markContextInterrupted() {
localContext.markInterrupted();
+ LOG.warn("Invocation has been marked interrupted for method [" + method + "] on resource ["
+ + resourceContainer.getResource() + "]");
}
}
}
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 d399d1b..ccb8ce0 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
@@ -18,6 +18,8 @@
*/
package org.rhq.modules.plugins.jbossas7;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
import java.io.File;
import java.util.HashSet;
import java.util.Map;
@@ -184,39 +186,28 @@ public class StandaloneASComponent<T extends ResourceComponent<?>> extends BaseS
return operationResult;
}
- private boolean waitUntilReloaded() {
+ private boolean waitUntilReloaded() throws InterruptedException {
boolean reloaded = false;
- int count = 0;
-
while (!reloaded) {
Operation op = new ReadAttribute(new Address(), "release-version");
- try{
+ try {
Result res = getASConnection().execute(op);
if (res.isSuccess() && !res.isReloadRequired()) {
reloaded = true;
- } else if (count > 20) {
- break;
}
} catch (Exception e) {
//do absolutely nothing
//if an exception is thrown that means the server is still reloading, so consider this
//a single failed attempt, equivalent to res.isSuccess == false
}
-
if (!reloaded) {
- try {
- Thread.sleep(1000); // Wait 1s
- } catch (InterruptedException e) {
- // ignore
+ if (context.getComponentInvocationContext().isInterrupted()) {
+ // Operation canceled or timed out
+ throw new InterruptedException();
}
+ Thread.sleep(SECONDS.toMillis(1));
}
- count++;
}
-
- if (log.isDebugEnabled()) {
- log.debug("waitUntilReloaded: Used " + count + " delay round(s) to reload. Reload=" + reloaded);
- }
-
return reloaded;
}
commit 56f845bec82369f3032b565a8caeed751d1a4093
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jul 16 10:13:13 2013 +0200
Fix test fallout that got introduced by my changes.
diff --git a/modules/enterprise/server/plugins/alert-snmp/src/test/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpInfoTest.java b/modules/enterprise/server/plugins/alert-snmp/src/test/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpInfoTest.java
index 97b9a05..ecc995d 100644
--- a/modules/enterprise/server/plugins/alert-snmp/src/test/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpInfoTest.java
+++ b/modules/enterprise/server/plugins/alert-snmp/src/test/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpInfoTest.java
@@ -116,11 +116,11 @@ public class SnmpInfoTest {
// String representation is constrained (even not strongly).
Configuration configuration = new Configuration();
assertEquals(SnmpInfo.load(configuration).toString(), "UnknownHost:" + DEFAULT_PORT
- + " (UnknownOID) (DefaultTrapOID)");
+ + " (Unknown Binding Prefix) (DefaultTrapOID)");
configuration.setSimpleValue(PARAM_HOST, "pipo");
- assertEquals(SnmpInfo.load(configuration).toString(), "pipo:" + DEFAULT_PORT + " (UnknownOID) (DefaultTrapOID)");
+ assertEquals(SnmpInfo.load(configuration).toString(), "pipo:" + DEFAULT_PORT + " (Unknown Binding Prefix) (DefaultTrapOID)");
configuration.setSimpleValue(PARAM_PORT, "35162");
- assertEquals(SnmpInfo.load(configuration).toString(), "pipo:35162 (UnknownOID) (DefaultTrapOID)");
+ assertEquals(SnmpInfo.load(configuration).toString(), "pipo:35162 (Unknown Binding Prefix) (DefaultTrapOID)");
configuration.setSimpleValue(PARAM_VARIABLE_BINDING_PREFIX, "molo");
assertEquals(SnmpInfo.load(configuration).toString(), "pipo:35162 (molo) (DefaultTrapOID)");
configuration.setSimpleValue(PARAM_TRAP_OID, "logo");
diff --git a/modules/enterprise/server/plugins/alert-snmp/src/test/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSenderTest.java b/modules/enterprise/server/plugins/alert-snmp/src/test/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSenderTest.java
index 38b36d7..9583a07 100644
--- a/modules/enterprise/server/plugins/alert-snmp/src/test/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSenderTest.java
+++ b/modules/enterprise/server/plugins/alert-snmp/src/test/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpSenderTest.java
@@ -95,6 +95,7 @@ public class SnmpSenderTest {
private AlertManagerLocal alertManager;
private TestSnmpSender snmpSender;
+ private Configuration pluginConfiguration;
@BeforeMethod
public void setUp() throws Exception {
@@ -114,7 +115,7 @@ public class SnmpSenderTest {
MockitoAnnotations.initMocks(this);
- Configuration pluginConfiguration = new Configuration();
+ pluginConfiguration = new Configuration();
pluginConfiguration.setSimpleValue("snmpVersion", "2c");
pluginConfiguration.setSimpleValue("trapOid", TEST_TRAP_OID_PLUGIN_CONFIG);
pluginConfiguration.setSimpleValue("community", "public");
@@ -153,7 +154,7 @@ public class SnmpSenderTest {
assertNotNull(result);
assertEquals(result.getState(), FAILURE);
assertEquals(result.getFailureMessages().size(), 1);
- String expectedError = SnmpInfo.load(alertParameters).error;
+ String expectedError = SnmpInfo.load(alertParameters,pluginConfiguration).error;
assertNotNull(expectedError);
assertEquals(result.getFailureMessages().get(0), expectedError);
}
commit 609c93f0d219afd19db976d55c565c95bb96d1ab
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jul 15 11:03:05 2013 +0200
Display tool tips, for pick button and choice boxes
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Generator.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Generator.java
index 06f3fec..e7da952 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Generator.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Generator.java
@@ -210,11 +210,13 @@ public class Generator extends Application{
choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observableValue, String s, String newValue) {
- setPropsValue(prop.getVariableName(),newValue.equals("Yes"),propType);
+ setPropsValue(prop.getVariableName(), newValue.equals("Yes"), propType);
}
});
+ Tooltip tooltip = new Tooltip(prop.getDescription()); // TODO make this a hover listener
+ choiceBox.setTooltip(tooltip);
- root.add(choiceBox,1,row);
+ root.add(choiceBox, 1, row);
} else if (propType.equals(ResourceCategory.class)) {
final ChoiceBox choiceBox = new ChoiceBox();
for (ResourceCategory cat : ResourceCategory.values()) {
@@ -228,14 +230,17 @@ public class Generator extends Application{
setPropsValue(prop.getVariableName(),newCategory,propType);
}
});
-
+ Tooltip tooltip = new Tooltip(prop.getDescription()); // TODO make this a hover listener
+ choiceBox.setTooltip(tooltip);
root.add(choiceBox,1,row);
} else if (propType.equals(File.class)) {
// Can not add this directly, so add a button to trigger it
final Text text = new Text();
text.setText("Pick a directory");
root.add(text,1,row);
+ Tooltip tooltip = new Tooltip("Pick the (parent) directory where the plugin will be put in.");
Button pickButton = new Button("Pick");
+ pickButton.setTooltip(tooltip);
pickButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Prop.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Prop.java
index 73c4cd9..4ed019a 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Prop.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Prop.java
@@ -38,7 +38,7 @@ public enum Prop {
DESCRIPTION("description", String.class, "Description of the type", ".*"),
DISCOVERY_CLASS("discoveryClass", String.class, "Discovery class", "[A-Z][a-zA-Z0-9]*"),
COMPONENT_CLASS("componentClass", String.class, "Discovery class", "[A-Z][a-zA-Z0-9]*"),
- IS_SINGLETON("singleton",Boolean.class,"Is this type a singleton, which means that" +
+ IS_SINGLETON("singleton",boolean.class,"Is this type a singleton, which means that" +
" there can only be one resource of that type for the given parent?",null),
HAS_METRICS("hasMetrics",boolean.class,"Does this type support taking metrics?",null),
HAS_OPERATIONS("hasOperations",boolean.class,"Does this type support operations?",null),
commit f24eb1cfcb98ce8c1c4a9edb00453aef60c7e7dd
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 15 22:06:57 2013 -0400
copy cassandra-jvm.properties on upgrade. we're no longer using cassandra-env.sh.
diff --git a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
index 9a6a1c0..2fec2dc 100644
--- a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
+++ b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
@@ -25,10 +25,8 @@
package org.rhq.storage.installer;
-import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileReader;
import java.io.IOException;
import java.net.InetAddress;
import java.util.ArrayList;
@@ -37,6 +35,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Properties;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
@@ -65,6 +64,7 @@ import org.rhq.cassandra.DeploymentOptions;
import org.rhq.cassandra.DeploymentOptionsFactory;
import org.rhq.cassandra.installer.RMIContextFactory;
import org.rhq.core.util.PropertiesFileUpdate;
+import org.rhq.core.util.StringUtil;
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.core.util.file.FileUtil;
@@ -244,24 +244,19 @@ public class StorageInstaller {
deployer.updateFilePerms();
// For upgrades we will copy the existing cassandra.yaml,
- // log4j-server.properties, and cassandra-env.sh file from the existing
+ // log4j-server.properties, and cassandra-jvm.properties from the existing
// storage node installation. Going forward though we need to add support
- // for merging in the existing cassandra.yaml with the new one. We also
- // need to do something about cassandra-env.sh. There is no easy to parse
- // it and merge in changes which is problematic since that is where heap
- // settings and JMX port and other JMV options are specified. Maybe we can
- // replace it with a cassandra-in.sh that is essentially a properties file
- // which we can easily parse and update.
+ // for merging in the existing cassandra.yaml with the new one.
File oldConfDir = new File(existingStorageDir, "conf");
File newConfDir = new File(storageBasedir, "conf");
String cassandraYaml = "cassandra.yaml";
- String cassandraEnv = "cassandra-env.sh";
- File cassandraEnvFile = new File(newConfDir, cassandraEnv);
+ String cassandraJvmProps = "cassandra-jvm.properties";
+ File cassandraJvmPropsFile = new File(newConfDir, cassandraJvmProps);
String log4j = "log4j-server.properties";
replaceFile(new File(oldConfDir, cassandraYaml), new File(newConfDir, cassandraYaml));
- replaceFile(new File(oldConfDir, cassandraEnv), cassandraEnvFile);
+ replaceFile(new File(oldConfDir, cassandraJvmProps), cassandraJvmPropsFile);
replaceFile(new File(oldConfDir, log4j), new File(newConfDir, log4j));
log.info("Finished installing RHQ Storage Node.");
@@ -274,7 +269,7 @@ public class StorageInstaller {
hostname = (String) config.get("listen_address");
- jmxPort = parseJmxPort(cassandraEnvFile);
+ jmxPort = parseJmxPort(cassandraJvmPropsFile);
} else {
if (cmdLine.hasOption("dir")) {
File basedir = new File(cmdLine.getOptionValue("dir"));
@@ -666,56 +661,26 @@ public class StorageInstaller {
}
}
- private int parseJmxPort(File cassandraEnvFile) {
+ private int parseJmxPort(File cassandraJvmOptsFile) {
Integer port = null;
if (isWindows()) {
// TODO
return defaultJmxPort;
} else {
- BufferedReader reader = null;
try {
- reader = new BufferedReader(new FileReader(cassandraEnvFile));
- String line = reader.readLine();
-
- while (line != null) {
- if (line.startsWith("JMX_PORT")) {
- int startIndex = line.indexOf("JMX_PORT=\"") + 1;
- int endIndex = line.lastIndexOf("\"");
-
- if (startIndex == -1 || endIndex == -1) {
- log.error("Failed to parse the JMX port. Make sure that you have the JMX port defined on its "
- + "own line as follows, JMX_PORT=\"<jmx-port>\"");
- throw new RuntimeException("Cannot determine JMX port");
- }
- try {
- port = Integer.parseInt(line.substring(startIndex, endIndex));
- } catch (NumberFormatException e) {
- log.error("The JMX port must be an integer. [" + port + "] is an invalid value");
- throw new RuntimeException("The JMX port has an invalid value");
- }
- return port;
- }
- line = reader.readLine();
+ Properties properties = new Properties();
+ properties.load(new FileInputStream(cassandraJvmOptsFile));
+
+ String jmxPort = properties.getProperty("jmx_port");
+ if (StringUtil.isEmpty(jmxPort)) {
+ log.error("The property [jmx_port] is undefined.");
+ throw new RuntimeException("Cannot determine JMX port");
}
- log.error("Failed to parse the JMX port. Make sure that you have the JMX port defined on its "
- + "own line as follows, JMX_PORT=\"<jmx-port>\"");
- throw new RuntimeException("Cannot determine JMX port");
+
+ return Integer.parseInt(jmxPort);
} catch (IOException e) {
log.error("Failed to parse JMX port. There was an unexpected IO error", e);
throw new RuntimeException("Failed to parse JMX port due to IO error: " + e.getMessage());
- } finally {
- try {
- if (reader != null) {
- reader.close();
- }
- } catch (IOException e) {
- if (log.isDebugEnabled()) {
- log.debug("An error occurred closing the " + BufferedReader.class.getName() + " used to "
- + "parse the JMX port", e);
- } else {
- log.warn("There was error closing the reader used to parse the JMX port: " + e.getMessage());
- }
- }
}
}
}
commit 27138835d3ac9fb10fe18519fbe441fc1979387e
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 15 21:47:34 2013 -0400
fixing bug in script
diff --git a/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh b/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh
index 7c0b88a..33984d1 100755
--- a/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh
+++ b/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh
@@ -19,6 +19,9 @@ CQL_HOSTNAME=$2
CQL_PORT=$3
JMX_PORT=$4
+export CQLSH_HOST=$2
+export CQL_PORT=$3
+
PATCH="apache-cassandra-1.2.4-patch-1.jar"
# swap out the Cassandra jar file with the patched version
@@ -36,8 +39,6 @@ sleep 3
# run the CQL script
echo "Running CQL script to disable table compression"
-export CQLSH_HOST=$CQLSH_HOST
-export CQL_PORT=$CQL_PORT
$RHQ_SERVER_DIR/rhq-storage/bin/cqlsh -u rhqadmin -p rhqadmin -f ./disable_compression.cql
# rewrite all sstables
commit 34514a874e079e19736bbc0fd71db099a1b9b25a
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 15 16:23:06 2013 -0400
make parsing of heap options more robust
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
index a0220ba..8d1771d 100644
--- a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
+++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
@@ -32,18 +32,13 @@ public class StorageNodeConfigDelegate implements ConfigurationFacet {
Configuration config = new Configuration();
- String heapMinProp = properties.getProperty("heap_min");
- String heapMaxProp = properties.getProperty("heap_max");
- String heapNewProp = properties.getProperty("heap_new");
- String threadStackSizeProp = properties.getProperty("thread_stack_size");
String heapDumpOnOOMError = properties.getProperty("heap_dump_on_OOMError");
String heapDumpDir = properties.getProperty("heap_dump_dir");
- config.put(new PropertySimple("minHeapSize", heapMinProp.substring(4)));
- config.put(new PropertySimple("maxHeapSize", heapMaxProp.substring(4)));
- config.put(new PropertySimple("heapNewSize", heapNewProp.substring(4)));
- config.put(new PropertySimple("threadStackSize", threadStackSizeProp.substring(4,
- threadStackSizeProp.length() - 1)));
+ config.put(new PropertySimple("minHeapSize", getHeapMinProp(properties)));
+ config.put(new PropertySimple("maxHeapSize", getHeapMaxProp(properties)));
+ config.put(new PropertySimple("heapNewSize", getHeapNewProp(properties)));
+ config.put(new PropertySimple("threadStackSize", getStackSizeProp(properties)));
if (!StringUtil.isEmpty(heapDumpOnOOMError)) {
config.put(new PropertySimple("heapDumpOnOOMError", true));
@@ -61,6 +56,62 @@ public class StorageNodeConfigDelegate implements ConfigurationFacet {
return config;
}
+ private String getHeapMinProp(Properties properties) {
+ String value = properties.getProperty("heap_min");
+
+ if (StringUtil.isEmpty(value)) {
+ return "";
+ }
+
+ if (!value.startsWith("-Xms")) {
+ return value;
+ }
+
+ return value.substring(4);
+ }
+
+ private String getHeapMaxProp(Properties properties) {
+ String value = properties.getProperty("heap_max");
+
+ if (StringUtil.isEmpty(value)) {
+ return "";
+ }
+
+ if (!value.startsWith("-Xmx")) {
+ return value;
+ }
+
+ return value.substring(4);
+ }
+
+ private String getHeapNewProp(Properties properties) {
+ String value = properties.getProperty("heap_new");
+
+ if (StringUtil.isEmpty(value)) {
+ return "";
+ }
+
+ if (!value.startsWith("-Xmn")) {
+ return value;
+ }
+
+ return value.substring(4);
+ }
+
+ private String getStackSizeProp(Properties properties) {
+ String value = properties.getProperty("thread_stack_size");
+
+ if (StringUtil.isEmpty(value)) {
+ return "";
+ }
+
+ if (!(value.startsWith("-Xss") || value.endsWith("k") || value.length() > 5)) {
+ return value;
+ }
+
+ return value.substring(4, value.length() - 1);
+ }
+
@Override
public void updateResourceConfiguration(ConfigurationUpdateReport configurationUpdateReport) {
try {
commit 632eb18cc8984f12c794678c6d13a455048a2096
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 15 15:35:48 2013 -0400
adding validation checks for heap and thread args
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
index c87d2ac..a0220ba 100644
--- a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
+++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
@@ -42,7 +42,8 @@ public class StorageNodeConfigDelegate implements ConfigurationFacet {
config.put(new PropertySimple("minHeapSize", heapMinProp.substring(4)));
config.put(new PropertySimple("maxHeapSize", heapMaxProp.substring(4)));
config.put(new PropertySimple("heapNewSize", heapNewProp.substring(4)));
- config.put(new PropertySimple("threadStackSize", threadStackSizeProp.substring(4)));
+ config.put(new PropertySimple("threadStackSize", threadStackSizeProp.substring(4,
+ threadStackSizeProp.length() - 1)));
if (!StringUtil.isEmpty(heapDumpOnOOMError)) {
config.put(new PropertySimple("heapDumpOnOOMError", true));
@@ -70,6 +71,7 @@ public class StorageNodeConfigDelegate implements ConfigurationFacet {
String maxHeapSize = config.getSimpleValue("maxHeapSize");
if (!StringUtil.isEmpty(maxHeapSize)) {
+ validateHeapArg("maxHeapSize", maxHeapSize);
// We want min and max heap to be the same
properties.setProperty("heap_min", "-Xms" + maxHeapSize);
properties.setProperty("heap_max", "-Xmx" + maxHeapSize);
@@ -77,12 +79,14 @@ public class StorageNodeConfigDelegate implements ConfigurationFacet {
String heapNewSize = config.getSimpleValue("heapNewSize");
if (!StringUtil.isEmpty(heapNewSize)) {
+ validateHeapArg("heapNewSize", heapNewSize);
properties.setProperty("heap_new", "-Xmn" + heapNewSize);
}
String threadStackSize = config.getSimpleValue("threadStackSize");
if (!StringUtil.isEmpty(threadStackSize)) {
- properties.setProperty("thread_stack_size", "-Xss" + threadStackSize);
+ validateStackArg(threadStackSize);
+ properties.setProperty("thread_stack_size", "-Xss" + threadStackSize + "k");
}
PropertySimple heapDumpOnOMMError = config.getSimple("heapDumpOnOOMError");
@@ -102,9 +106,36 @@ public class StorageNodeConfigDelegate implements ConfigurationFacet {
propertiesUpdater.update(properties);
configurationUpdateReport.setStatus(ConfigurationUpdateStatus.SUCCESS);
+ } catch (IllegalArgumentException e) {
+ configurationUpdateReport.setErrorMessage("No configuration update was applied: " + e.getMessage());
} catch (IOException e) {
configurationUpdateReport.setErrorMessageFromThrowable(e);
}
+ }
+
+ private void validateHeapArg(String name, String value) {
+ if (value.length() < 2) {
+ throw new IllegalArgumentException(value + " is not a legal value for the property [" + name + "]");
+ }
+
+ char[] chars = value.toCharArray();
+ for (int i = 0; i < chars.length - 1; ++i) {
+ if (!Character.isDigit(chars[i])) {
+ throw new IllegalArgumentException(value + " is not a legal value for the property [" + name + "]");
+ }
+ }
+ char lastChar = Character.toUpperCase(chars[chars.length - 1]);
+ if (!(lastChar == 'M' || lastChar == 'G')) {
+ throw new IllegalArgumentException(value + " is not a legal value for the property [" + name + "]");
+ }
+ }
+
+ private void validateStackArg(String value) {
+ try {
+ Integer.parseInt(value);
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException(value + " is not a legal value for the property [threadStackSize]");
+ }
}
}
diff --git a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
index c700257..5a60d19 100644
--- a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
@@ -118,12 +118,24 @@
description="The minimum heap size. This value will be used with the -Xms JVM option. This
is read only because it is automatically set to the same value as Max Heap Size."/>
<c:simple-property name="maxHeapSize"
- description="The maximum heap size. This value will be used with the -Xmx JVM option."/>
+ description="The maximum heap size. This value will be used with the -Xmx JVM option. The
+ value should be an integer with a suffix of M or G to indicate megabytes or gigabytes.">
+ <c:constraint>
+ <c:regex-constraint expression="\d+[mMgG]"/>
+ </c:constraint>
+ </c:simple-property>
<c:simple-property name="heapNewSize"
description="The size of the new generation portion of the heap. This value will be used with
- the -Xmn JVM option."/>
+ the -Xmn JVM option. The value should be an integer with a suffix of M or G to indicate
+ megabytes or gigabytes.">
+ <c:constraint>
+ <c:regex-constraint expression="\d+[mMgG]"/>
+ </c:constraint>
+ </c:simple-property>
<c:simple-property name="threadStackSize"
- description="The thread stack size. This memory is allocated to each thread off heap."/>
+ type="integer"
+ description="The thread stack size. This memory is allocated to each thread off heap. The
+ value should be an integer that will be interpreted in kilobytes."/>
<c:simple-property name="heapDumpOnOOMError" displayName="Heap Dump on OutOfMemoryError" type="boolean"
default="true"
description="Generate a heap dump when an OutOfMemoryError occurs"/>
diff --git a/modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java b/modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java
index ee34f43..64d14b2 100644
--- a/modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java
+++ b/modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java
@@ -13,8 +13,10 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.util.file.FileUtil;
/**
* @author John Sanda
@@ -29,6 +31,7 @@ public class StorageNodeConfigDelegateTest {
public void initDirs(Method test) throws Exception {
File dir = new File(getClass().getResource(".").toURI());
basedir = new File(dir, getClass().getSimpleName() + "/" + test.getName());
+ FileUtil.purge(basedir, true);
configDelegate = new StorageNodeConfigDelegate(basedir);
}
@@ -42,7 +45,7 @@ public class StorageNodeConfigDelegateTest {
assertEquals(config.getSimpleValue("minHeapSize"), "512M", "Failed to load property [minHeapSize]");
assertEquals(config.getSimpleValue("maxHeapSize"), "512M", "Failed to load property [maxHepSize]");
assertEquals(config.getSimpleValue("heapNewSize"), "128M", "Failed to load property [heapNewSize]");
- assertEquals(config.getSimpleValue("threadStackSize"), "180k", "Failed to load property [threadStackSize]");
+ assertEquals(config.getSimpleValue("threadStackSize"), "180", "Failed to load property [threadStackSize]");
assertEquals(config.getSimple("heapDumpOnOOMError").getBooleanValue(), (Boolean) true,
"Failed to load property [heapDumpOnOOMError]");
assertEquals(new File(config.getSimpleValue("heapDumpDir")), binDir(), "Failed to load property [heapDumpDir]");
@@ -56,7 +59,7 @@ public class StorageNodeConfigDelegateTest {
config.put(new PropertySimple("minHeapSize", "1024M"));
config.put(new PropertySimple("maxHeapSize", "1024M"));
config.put(new PropertySimple("heapNewSize", "256M"));
- config.put(new PropertySimple("threadStackSize", "240k"));
+ config.put(new PropertySimple("threadStackSize", "240"));
config.put(new PropertySimple("heapDumpOnOOMError", true));
config.put(new PropertySimple("heapDumpDir", confDir()));
@@ -96,6 +99,60 @@ public class StorageNodeConfigDelegateTest {
"should be the same as [maxHeapSize].");
}
+ @Test
+ public void disableHeapDumps() throws Exception {
+ createDefaultConfig();
+
+ ConfigurationUpdateReport report = new ConfigurationUpdateReport(Configuration.builder()
+ .addSimple("heapDumpOnOOMError", false).build());
+
+ configDelegate.updateResourceConfiguration(report);
+
+ Properties properties = loadCassandraJvmProps();
+
+ assertEquals(properties.getProperty("heap_dump_on_OOMError"), "", "Failed to disable property " +
+ "[heapDumpOnOOMError]");
+ }
+
+ @Test
+ public void updateShouldFailWhenMaxHeapSizeIsInvalid() throws Exception {
+ createDefaultConfig();
+
+ ConfigurationUpdateReport report = new ConfigurationUpdateReport(Configuration.builder()
+ .addSimple("maxHeapSize", "256GB").build());
+
+ configDelegate.updateResourceConfiguration(report);
+
+ assertEquals(report.getStatus(), ConfigurationUpdateStatus.FAILURE, "The configuration update should fail " +
+ "when [maxHeapSize] has an invalid value.");
+ }
+
+ @Test
+ public void updateShouldFailWhenHeapNewSizeIsInvalid() throws Exception {
+ createDefaultConfig();
+
+ ConfigurationUpdateReport report = new ConfigurationUpdateReport(Configuration.builder()
+ .addSimple("heapNewSize", "25^G").build());
+
+ configDelegate.updateResourceConfiguration(report);
+
+ assertEquals(report.getStatus(), ConfigurationUpdateStatus.FAILURE, "The configuration update should fail " +
+ "when [heapNewSize] has an invalid value.");
+ }
+
+ @Test
+ public void updateShouldFailWhenThreadStackSizeIsInvalid() throws Exception {
+ createDefaultConfig();
+
+ ConfigurationUpdateReport report = new ConfigurationUpdateReport(Configuration.builder()
+ .addSimple("threadStackSize", "128M").build());
+
+ configDelegate.updateResourceConfiguration(report);
+
+ assertEquals(report.getStatus(), ConfigurationUpdateStatus.FAILURE, "The configuration update should fail " +
+ "when [threadStackSize] has an invalid value.");
+ }
+
private void createDefaultConfig() throws IOException {
Properties properties = new Properties();
properties.setProperty("heap_min", "-Xms512M");
commit fe38a28bd0ba7df967ec8b6a7f5f2b4a6bb839d6
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Wed Jul 3 12:27:55 2013 +0200
Bug 923400 - Sigar creates high number of blocked threads (unbounded) if mount is gone
diff --git a/modules/core/native-system/src/main/java/org/rhq/core/system/SigarAccess.java b/modules/core/native-system/src/main/java/org/rhq/core/system/SigarAccess.java
index 4319f9a..8c7cea9 100644
--- a/modules/core/native-system/src/main/java/org/rhq/core/system/SigarAccess.java
+++ b/modules/core/native-system/src/main/java/org/rhq/core/system/SigarAccess.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,17 +13,13 @@
* 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.
+ * 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.system;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarProxy;
/**
@@ -34,7 +30,6 @@ import org.hyperic.sigar.SigarProxy;
* @author John Mazzitelli
*/
public class SigarAccess {
-
private static SigarAccessHandler invocationHandler;
private static SigarProxy sigarProxy;
@@ -83,35 +78,4 @@ public class SigarAccess {
}
- private static class SigarAccessHandler implements InvocationHandler {
- private Sigar sigar;
-
- public Object invoke(Object proxy, Method meth, Object[] args) throws Throwable {
- // its possible in the time between this handler's creation and now, someone disabled the native layer.
- // throw a runtime exception if the native system was disabled
- if (SystemInfoFactory.isNativeSystemInfoDisabled()) {
- throw new SystemInfoException("Native system has been disabled");
- }
-
- try {
- synchronized (this) {
- if (sigar == null) {
- this.sigar = new Sigar();
- }
-
- return meth.invoke(sigar, args);
- }
- } catch (InvocationTargetException e) {
- throw e.getTargetException();
- }
- }
-
- public synchronized void close() {
- if (this.sigar != null) {
- this.sigar.close();
- this.sigar = null;
- }
- }
- }
-
-}
\ No newline at end of file
+}
diff --git a/modules/core/native-system/src/main/java/org/rhq/core/system/SigarAccessHandler.java b/modules/core/native-system/src/main/java/org/rhq/core/system/SigarAccessHandler.java
new file mode 100644
index 0000000..a781641
--- /dev/null
+++ b/modules/core/native-system/src/main/java/org/rhq/core/system/SigarAccessHandler.java
@@ -0,0 +1,201 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.core.system;
+
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.ThreadInfo;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hyperic.sigar.Sigar;
+
+/**
+ * An {@link InvocationHandler} for a {@link org.hyperic.sigar.SigarProxy}.
+ * <p>A single instance of this class will be created by the {@link SigarAccess} class.</p>
+ * This class holds a shared {@link Sigar} instance and serializes calls. If a thread waits more than
+ * 'sharedSigarLockMaxWait' seconds, it will be given a new Sigar instance, which will be destroyed at the end of the
+ * call.
+ * <p>Every 5 minutes, a background task checks that 'localSigarInstancesWarningThreshold' has not been exceeded. It it
+ * has, a warning message will be logged, optionally with a thread dump.
+ * <p>This class is configurable with System properties:
+ * <ul>
+ * <li><strong>sharedSigarLockMaxWait</strong>: maximum time in seconds a thread will wait for the shared Sigar lock
+ * acquistion; defaults to 2 seconds</li>
+ * <li><strong>localSigarInstancesWarningThreshold</strong>: threshold of currently living Sigar instances at which
+ * the background task will print warning messages; defaults to 50</li>
+ * <li><strong>maxLocalSigarInstances</strong>: maximum number of local Sigar instances which can be created, zero
+ * and negative values being interpreted as 'no limit'; defaults to 50</li>
+ * <li><strong>threadDumpOnlocalSigarInstancesWarningThreshold</strong>: if set to true (case insensitive), the
+ * background task will also log a thread dump when <strong>localSigarInstancesWarningThreshold</strong> is met</li>
+ * </ul>
+ * </p>
+ *
+ * @author Thomas Segismont
+ */
+class SigarAccessHandler implements InvocationHandler {
+ private static final Log LOG = LogFactory.getLog(SigarAccessHandler.class);
+
+ private static final String LINE_SEPARATOR = System.getProperty("line.separator");
+ private static final int SHARED_SIGAR_LOCK_MAX_WAIT = Integer.getInteger("sharedSigarLockMaxWait", 2);
+ private static final int LOCAL_SIGAR_INSTANCES_WARNING_THRESHOLD = Integer.getInteger(
+ "localSigarInstancesWarningThreshold", 50);
+ private static final int MAX_LOCAL_SIGAR_INSTANCES = Integer.getInteger("maxLocalSigarInstances", 50);
+ private static final boolean LIMIT_LOCAL_SIGAR_INSTANCES = MAX_LOCAL_SIGAR_INSTANCES > 0;
+ private static final boolean THREAD_DUMP_ON_SIGAR_INSTANCES_THRESHOLD = Boolean
+ .getBoolean("threadDumpOnlocalSigarInstancesWarningThreshold");
+
+ private final SigarFactory sigarFactory;
+ private final ReentrantLock sharedSigarLock;
+ private final ReentrantLock localSigarLock;
+ private final ScheduledExecutorService scheduledExecutorService;
+ private volatile int localSigarInstancesCount;
+ private Sigar sharedSigar;
+
+ SigarAccessHandler() {
+ this(new DefaultSigarFactory());
+ }
+
+ SigarAccessHandler(SigarFactory sigarFactory) {
+ this.sigarFactory = sigarFactory;
+ sharedSigarLock = new ReentrantLock();
+ localSigarLock = new ReentrantLock();
+ scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
+ scheduledExecutorService.scheduleWithFixedDelay(new ThresholdChecker(), 1, 5, MINUTES);
+ localSigarInstancesCount = 0;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ // its possible in the time between this handler's creation and now, someone disabled the native layer.
+ // throw a runtime exception if the native system was disabled
+ if (SystemInfoFactory.isNativeSystemInfoDisabled()) {
+ throw new SystemInfoException("Native system has been disabled");
+ }
+
+ // Acquire lock for shared Sigar instance. Wait 'sharedSigarLockMaxWait' seconds at most
+ boolean acquiredLock = sharedSigarLock.tryLock(SHARED_SIGAR_LOCK_MAX_WAIT, SECONDS);
+ if (acquiredLock) {
+ if (sharedSigar == null) {
+ this.sharedSigar = sigarFactory.createSigarInstance();
+ }
+ try {
+ return method.invoke(sharedSigar, args);
+ } catch (InvocationTargetException e) {
+ throw e.getTargetException();
+ } finally {
+ sharedSigarLock.unlock();
+ }
+ } else {
+ Sigar localSigar = createLocalSigarInstance();
+ try {
+ return method.invoke(localSigar, args);
+ } catch (InvocationTargetException e) {
+ throw e.getTargetException();
+ } finally {
+ closeLocalSigarInstance(localSigar);
+ }
+ }
+ }
+
+ private Sigar createLocalSigarInstance() {
+ localSigarLock.lock();
+ try {
+ if (LIMIT_LOCAL_SIGAR_INSTANCES && localSigarInstancesCount >= MAX_LOCAL_SIGAR_INSTANCES) {
+ throw new RuntimeException("Too many Sigar instances created");
+ }
+ Sigar sigarInstance = sigarFactory.createSigarInstance();
+ localSigarInstancesCount++;
+ return sigarInstance;
+ } finally {
+ localSigarLock.unlock();
+ }
+ }
+
+ private void closeLocalSigarInstance(Sigar sigar) {
+ localSigarLock.lock();
+ try {
+ sigar.close();
+ localSigarInstancesCount--;
+ } finally {
+ localSigarLock.unlock();
+ }
+ }
+
+ void close() {
+ if (sharedSigar != null) {
+ sharedSigarLock.lock();
+ try {
+ sharedSigar.close();
+ sharedSigar = null;
+ } finally {
+ sharedSigarLock.unlock();
+ }
+ }
+ scheduledExecutorService.shutdownNow();
+ }
+
+ int localSigarInstancesCount() {
+ return localSigarInstancesCount;
+ }
+
+ interface SigarFactory {
+ Sigar createSigarInstance();
+ }
+
+ private static class DefaultSigarFactory implements SigarFactory {
+ @Override
+ public Sigar createSigarInstance() {
+ return new Sigar();
+ }
+ }
+
+ private class ThresholdChecker implements Runnable {
+ @Override
+ public void run() {
+ int currentCount = localSigarInstancesCount;
+ if (currentCount > LOCAL_SIGAR_INSTANCES_WARNING_THRESHOLD) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("There are ").append(currentCount).append(" local Sigar instances currently active. ")
+ .append("This may indicate that a call to the shared Sigar instance did not complete.");
+ if (THREAD_DUMP_ON_SIGAR_INSTANCES_THRESHOLD) {
+ sb.append(LINE_SEPARATOR);
+ threadDump(sb);
+ }
+ LOG.warn(sb.toString());
+ }
+ }
+
+ private void threadDump(StringBuilder sb) {
+ ThreadInfo[] threadInfos = ManagementFactory.getThreadMXBean().dumpAllThreads(true, true);
+ for (ThreadInfo threadInfo : threadInfos) {
+ sb.append(threadInfo);
+ sb.append(LINE_SEPARATOR);
+ }
+ }
+ }
+}
diff --git a/modules/core/native-system/src/test/java/org/rhq/core/system/SigarAccessHandlerTest.java b/modules/core/native-system/src/test/java/org/rhq/core/system/SigarAccessHandlerTest.java
new file mode 100644
index 0000000..e993725
--- /dev/null
+++ b/modules/core/native-system/src/test/java/org/rhq/core/system/SigarAccessHandlerTest.java
@@ -0,0 +1,172 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.core.system;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.lang.reflect.Method;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import org.hyperic.sigar.Sigar;
+import org.hyperic.sigar.SigarProxy;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * @author Thomas Segismont
+ */
+@Test(singleThreaded = true)
+public class SigarAccessHandlerTest {
+ private static final int THREAD_POOL_SIZE = 100;
+
+ private Method getSwapMethod;
+ private Method getFileSystemMapMethod;
+ private Sigar sigarMock;
+ private ExecutorService executorService;
+ private SigarAccessHandler sigarAccessHandler;
+
+ @BeforeClass
+ private void setFields() throws Exception {
+ getSwapMethod = SigarProxy.class.getMethod("getSwap", new Class[0]);
+ getFileSystemMapMethod = SigarProxy.class.getMethod("getFileSystemMap", new Class[0]);
+ sigarMock = mock(Sigar.class);
+ // Wait 15 seconds on call to getSwap
+ when(sigarMock.getSwap()).then(new Answer<Object>() {
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ Thread.sleep(1000 * 15);
+ return null;
+ }
+ });
+ }
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ sigarAccessHandler = new SigarAccessHandler(new SigarAccessHandler.SigarFactory() {
+ @Override
+ public Sigar createSigarInstance() {
+ return sigarMock;
+ }
+ });
+ executorService = Executors.newFixedThreadPool(THREAD_POOL_SIZE);
+ }
+
+ @AfterMethod
+ public void tearDown() throws Exception {
+ sigarAccessHandler.close();
+ executorService.shutdownNow();
+
+ }
+
+ @Test(timeOut = 1000 * 30)
+ public void testOnDemandSigarInstanceCreation() throws Throwable {
+ // Start concurrent invocations of the long running getSwap method
+ for (int i = 0; i < 10; i++) {
+ executorService.submit(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ sigarAccessHandler.invoke(null, getSwapMethod, new Object[0]);
+ } catch (Throwable ignore) {
+ }
+ }
+ });
+ }
+ Thread.sleep(1000 * 8);
+
+ assertEquals(sigarAccessHandler.localSigarInstancesCount(), 9);
+ }
+
+ @Test(timeOut = 1000 * 30)
+ public void testSigarInstanceDestruction() throws Throwable {
+ // Start concurrent invocations of the short running getFileSystemMapMethod method and an invocation of the long
+ // running getSwap method
+ for (int i = 0; i < 10; i++) {
+ if (i == 0) {
+ executorService.submit(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ sigarAccessHandler.invoke(null, getSwapMethod, new Object[0]);
+ } catch (Throwable ignore) {
+ }
+ }
+ });
+ } else {
+ executorService.submit(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ sigarAccessHandler.invoke(null, getFileSystemMapMethod, new Object[0]);
+ } catch (Throwable ignore) {
+ }
+ }
+ });
+ }
+ }
+ Thread.sleep(1000 * 8);
+
+ assertEquals(sigarAccessHandler.localSigarInstancesCount(), 0);
+ }
+
+ @Test(timeOut = 1000 * 30)
+ public void testMaxSigarInstanceCreation() throws Throwable {
+ // Start concurrent invocations of the long running getSwap method
+ List<Future<Throwable>> futures = new LinkedList<Future<Throwable>>();
+ for (int i = 0; i < 60; i++) {
+ futures.add(executorService.submit(new Callable<Throwable>() {
+ @Override
+ public Throwable call() throws Exception {
+ try {
+ sigarAccessHandler.invoke(null, getSwapMethod, new Object[0]);
+ } catch (Throwable throwable) {
+ return throwable;
+ }
+ return null;
+ }
+ }));
+ }
+ Thread.sleep(1000 * 8);
+
+ assertEquals(sigarAccessHandler.localSigarInstancesCount(), 50);
+ int failedCallsCount = 0;
+ for (Future<Throwable> future : futures) {
+ Throwable throwable = future.get();
+ if (throwable != null) {
+ failedCallsCount++;
+ assertTrue(throwable instanceof RuntimeException);
+ assertEquals(throwable.getMessage(), "Too many Sigar instances created");
+ }
+ }
+ assertEquals(failedCallsCount, 9);
+ }
+}
commit 05ff27a9dec1422f46c91f69d524a3b388b3e421
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Mon Jul 15 19:57:08 2013 +0200
Bug 885655 - Datasource - Security Deployment Type is by default set to "Domain and application" instead of "None" as stated in description
Set default value in #createResource if needed
Update resource after creation as Security deployment type value is ignored by EAP servers
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
index 0d45594..e0699b0 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
@@ -19,12 +19,15 @@
package org.rhq.plugins.jbossas5;
+import static org.rhq.core.domain.resource.CreateResourceStatus.SUCCESS;
+
import java.io.File;
import java.io.InputStream;
import java.io.Serializable;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -47,13 +50,17 @@ import org.jboss.deployers.spi.management.deploy.ProgressEvent;
import org.jboss.deployers.spi.management.deploy.ProgressListener;
import org.jboss.managed.api.ComponentType;
import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.on.common.jbossas.JBPMWorkflowManager;
import org.jboss.on.common.jbossas.JBossASPaths;
import org.jboss.on.common.jbossas.JmxConnectionHelper;
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.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.content.PackageType;
import org.rhq.core.domain.content.transfer.DeployPackageStep;
import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
@@ -81,6 +88,8 @@ 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.jbossas5.adapter.api.PropertyAdapter;
+import org.rhq.plugins.jbossas5.adapter.api.PropertyAdapterFactory;
import org.rhq.plugins.jbossas5.connection.LocalProfileServiceConnectionProvider;
import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.rhq.plugins.jbossas5.connection.ProfileServiceConnectionProvider;
@@ -88,6 +97,7 @@ import org.rhq.plugins.jbossas5.connection.RemoteProfileServiceConnectionProvide
import org.rhq.plugins.jbossas5.helper.CreateChildResourceFacetDelegate;
import org.rhq.plugins.jbossas5.helper.InPluginControlActionFacade;
import org.rhq.plugins.jbossas5.helper.JBossAS5ConnectionTypeDescriptor;
+import org.rhq.plugins.jbossas5.util.ConversionUtils;
import org.rhq.plugins.jbossas5.util.ManagedComponentUtils;
/**
@@ -300,8 +310,58 @@ public class ApplicationServerComponent<T extends ResourceComponent<?>> implemen
// CreateChildResourceFacet --------------------------------------------
- public CreateResourceReport createResource(CreateResourceReport createResourceReport) {
- return this.createChildResourceDelegate.createResource(createResourceReport);
+ public CreateResourceReport createResource(CreateResourceReport report) {
+ if (creatingDatasourceOrConnectionFactory(report)) {
+ report = preCreateDatasourceOrConnectionFactory(report);
+ }
+ report = this.createChildResourceDelegate.createResource(report);
+ if (report.getStatus() != SUCCESS) {
+ return report;
+ }
+ if (creatingDatasourceOrConnectionFactory(report)) {
+ report = postCreateDatasourceOrConnectionFactory(report);
+ }
+ return report;
+ }
+
+ private CreateResourceReport preCreateDatasourceOrConnectionFactory(CreateResourceReport report) {
+ Configuration resourceConfiguration = report.getResourceConfiguration();
+ PropertyMap securityDomainPropertyMap = (PropertyMap) resourceConfiguration.get("security-domain");
+ PropertySimple securityDeploymentType = securityDomainPropertyMap.getSimple("securityDeploymentType");
+ if (securityDeploymentType.getStringValue() == null) {
+ securityDeploymentType.setValue("NONE");
+ }
+ return report;
+ }
+
+ private CreateResourceReport postCreateDatasourceOrConnectionFactory(CreateResourceReport report) {
+ Configuration resourceConfiguration = report.getResourceConfiguration();
+ ConfigurationDefinition resourceConfigurationDefinition = report.getResourceType()
+ .getResourceConfigurationDefinition();
+ ComponentType componentType = ConversionUtils.getComponentType(report.getResourceType());
+ String componentName = report.getResourceKey();
+ try {
+ ManagementView managementView = getConnection().getManagementView();
+ ManagedComponent managedComponent = managementView.getComponent(componentName, componentType);
+ Map<String, ManagedProperty> managedProperties = managedComponent.getProperties();
+ ManagedProperty managedProperty = managedProperties.get("security-domain");
+ MetaValue metaValue = managedProperty.getValue();
+ PropertyAdapter propertyAdapter = PropertyAdapterFactory.getPropertyAdapter(metaValue);
+ propertyAdapter.populateMetaValueFromProperty(resourceConfiguration.get("security-domain"), metaValue,
+ resourceConfigurationDefinition.get("security-domain"));
+ managementView.updateComponent(managedComponent);
+ managementView.load();
+ } catch (Exception e) {
+ report.setErrorMessage("Resource was created but an error occured while updating security-domain property");
+ report.setException(e);
+ }
+ return report;
+ }
+
+ private boolean creatingDatasourceOrConnectionFactory(CreateResourceReport report) {
+ String resourceTypeName = report.getResourceType().getName();
+ return Arrays.asList("No Tx Datasource", "Local Tx Datasource", "XA Datasource", "No Tx ConnectionFactory",
+ "Tx ConnectionFactory").contains(resourceTypeName);
}
// ProgressListener --------------------------------------------
commit 68d4c3d2c3c5eb67c09cde41ac78f77f6b32ec33
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 15 10:34:28 2013 -0400
[BZ 984433] revert changes for empty directory check
diff --git a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
index 386cda7..9a6a1c0 100644
--- a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
+++ b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
@@ -55,7 +55,6 @@ import org.apache.commons.cli.PosixParser;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.Executor;
import org.apache.commons.exec.PumpStreamHandler;
-import org.apache.commons.io.FileUtils;
import org.apache.commons.io.output.NullOutputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -450,7 +449,13 @@ public class StorageInstaller {
}
private boolean isDirectoryEmpty(File dir) {
- return FileUtils.sizeOf(dir) == 0;
+ // TODO need to check subdirectories
+ if (dir.isDirectory()) {
+ File[] files = dir.listFiles();
+ return (files == null || files.length == 0);
+ } else {
+ return true;
+ }
}
private int getPort(CommandLine cmdLine, String option, int defaultValue) {
commit 0bc81e9df0976365252b5ca11795b25d78172ec4
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 15 10:13:35 2013 -0400
check that properties are set before trying to update them
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
index e82f290..c87d2ac 100644
--- a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
+++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
@@ -68,19 +68,36 @@ public class StorageNodeConfigDelegate implements ConfigurationFacet {
Configuration config = configurationUpdateReport.getConfiguration();
- // We want min and max heap to be the same
- properties.setProperty("heap_min", "-Xms" + config.getSimpleValue("maxHeapSize"));
- properties.setProperty("heap_max", "-Xmx" + config.getSimpleValue("maxHeapSize"));
- properties.setProperty("heap_new", "-Xmn" + config.getSimpleValue("heapNewSize"));
- properties.setProperty("thread_stack_size", "-Xss" + config.getSimpleValue("threadStackSize"));
-
- if (config.getSimple("heapDumpOnOOMError").getBooleanValue()) {
- properties.setProperty("heap_dump_on_OOMError", "-XX:+HeapDumpOnOutOfMemoryError");
- } else {
- properties.setProperty("heap_dump_on_OOMError", "");
+ String maxHeapSize = config.getSimpleValue("maxHeapSize");
+ if (!StringUtil.isEmpty(maxHeapSize)) {
+ // We want min and max heap to be the same
+ properties.setProperty("heap_min", "-Xms" + maxHeapSize);
+ properties.setProperty("heap_max", "-Xmx" + maxHeapSize);
}
- properties.setProperty("heap_dump_dir", config.getSimpleValue("heapDumpDir"));
+ String heapNewSize = config.getSimpleValue("heapNewSize");
+ if (!StringUtil.isEmpty(heapNewSize)) {
+ properties.setProperty("heap_new", "-Xmn" + heapNewSize);
+ }
+
+ String threadStackSize = config.getSimpleValue("threadStackSize");
+ if (!StringUtil.isEmpty(threadStackSize)) {
+ properties.setProperty("thread_stack_size", "-Xss" + threadStackSize);
+ }
+
+ PropertySimple heapDumpOnOMMError = config.getSimple("heapDumpOnOOMError");
+ if (heapDumpOnOMMError != null) {
+ if (heapDumpOnOMMError.getBooleanValue()) {
+ properties.setProperty("heap_dump_on_OOMError", "-XX:+HeapDumpOnOutOfMemoryError");
+ } else {
+ properties.setProperty("heap_dump_on_OOMError", "");
+ }
+ }
+
+ String heapDumpDir = config.getSimpleValue("heapDumpDir");
+ if (!StringUtil.isEmpty(heapDumpDir)) {
+ properties.setProperty("heap_dump_dir", heapDumpDir);
+ }
propertiesUpdater.update(properties);
diff --git a/modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java b/modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java
index 5c5f089..ee34f43 100644
--- a/modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java
+++ b/modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java
@@ -23,10 +23,13 @@ public class StorageNodeConfigDelegateTest {
private File basedir;
+ private StorageNodeConfigDelegate configDelegate;
+
@BeforeMethod
public void initDirs(Method test) throws Exception {
File dir = new File(getClass().getResource(".").toURI());
basedir = new File(dir, getClass().getSimpleName() + "/" + test.getName());
+ configDelegate = new StorageNodeConfigDelegate(basedir);
}
@@ -34,7 +37,6 @@ public class StorageNodeConfigDelegateTest {
public void loadValidConfig() throws Exception {
createDefaultConfig();
- StorageNodeConfigDelegate configDelegate = new StorageNodeConfigDelegate(basedir);
Configuration config = configDelegate.loadResourceConfiguration();
assertEquals(config.getSimpleValue("minHeapSize"), "512M", "Failed to load property [minHeapSize]");
@@ -60,11 +62,9 @@ public class StorageNodeConfigDelegateTest {
ConfigurationUpdateReport report = new ConfigurationUpdateReport(config);
- StorageNodeConfigDelegate configDelegate = new StorageNodeConfigDelegate(basedir);
configDelegate.updateResourceConfiguration(report);
- Properties properties = new Properties();
- properties.load(new FileInputStream(new File(confDir(), "cassandra-jvm.properties")));
+ Properties properties = loadCassandraJvmProps();
assertEquals(properties.getProperty("heap_min"), "-Xms1024M", "Failed to update property [minHeapSize]");
assertEquals(properties.getProperty("heap_max"), "-Xmx1024M", "Failed to update property [maxHeapSize]");
@@ -77,6 +77,25 @@ public class StorageNodeConfigDelegateTest {
"Failed to update property [heap_dump_dir]");
}
+ @Test
+ public void minHeapSizeShouldBeTheSameAsMaxHeapSize() throws Exception {
+ createDefaultConfig();
+
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("minHeapSize", "512M"));
+ config.put(new PropertySimple("maxHeapSize", "768M"));
+
+ ConfigurationUpdateReport report = new ConfigurationUpdateReport(config);
+
+ configDelegate.updateResourceConfiguration(report);
+
+ Properties properties = loadCassandraJvmProps();
+
+ assertEquals(properties.getProperty("heap_max"), "-Xmx768M", "Failed to update property [maxHeapSize]");
+ assertEquals(properties.getProperty("heap_min"), "-Xms768M", "Failed to update property [maxHeapSize]. It " +
+ "should be the same as [maxHeapSize].");
+ }
+
private void createDefaultConfig() throws IOException {
Properties properties = new Properties();
properties.setProperty("heap_min", "-Xms512M");
@@ -84,10 +103,18 @@ public class StorageNodeConfigDelegateTest {
properties.setProperty("heap_new", "-Xmn128M");
properties.setProperty("thread_stack_size", "-Xss180k");
properties.setProperty("heap_dump_on_OOMError", "-XX:+HeapDumpOnOutOfMemoryError");
+ properties.setProperty("heap_dump_dir", binDir().getAbsolutePath());
properties.store(new FileOutputStream(new File(confDir(), "cassandra-jvm.properties")), "");
}
+ private Properties loadCassandraJvmProps() throws Exception {
+ Properties properties = new Properties();
+ properties.load(new FileInputStream(new File(confDir(), "cassandra-jvm.properties")));
+
+ return properties;
+ }
+
private File confDir() {
return mkdirIfNecessary(basedir, "conf");
}
commit 46ae96d60f17d0215185c0f79b8e004bdbc9c1ee
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu May 23 11:03:31 2013 +0200
Trivial: javadoc clean up.
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 13b1e32..4dae88a 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
@@ -850,10 +850,9 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM
*
* @return a clone of this configuration
*
- * @throws CloneNotSupportedException
- *
* @see #deepCopy()
*/
+ @SuppressWarnings("override")
//@Override //GWT trips over this, WTH!
public Configuration clone() {
return deepCopy();
@@ -1002,7 +1001,7 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM
/**
* Getter for the properties reference.
*
- * @return Map<String, Property>
+ * @return {@code Map<String, Property>}
*/
public Map<String, Property> getAllProperties() {
return this.properties;
commit b415c386059131057d91060a3bebef41699fcb3d
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu May 23 10:46:16 2013 +0200
Added missing generic type decls.
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 b006425..13b1e32 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
@@ -271,7 +271,7 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM
}
}
- public static class MapInList<Parent extends AbstractPropertyListBuilder> extends AbstractPropertyMapBuilder<PropertyMap, MapInList<Parent>> {
+ public static class MapInList<Parent extends AbstractPropertyListBuilder<?>> extends AbstractPropertyMapBuilder<PropertyMap, MapInList<Parent>> {
private Parent parent;
public MapInList(Parent parent, String name) {
@@ -307,7 +307,7 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM
}
}
- public static class ListInList<Parent extends AbstractPropertyListBuilder> extends AbstractPropertyListBuilder<ListInList<Parent>> {
+ public static class ListInList<Parent extends AbstractPropertyListBuilder<?>> extends AbstractPropertyListBuilder<ListInList<Parent>> {
private Parent parent;
private ListInList(Parent parent, String name, String memberName) {
commit abbbf13986af10b65cf812ce9b0a2a49c297934a
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed May 22 19:24:00 2013 +0200
A configuration instance builder.
This should greatly simplify the process of creating complex configuration
objects.
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 b1e6e22..b006425 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
@@ -143,6 +143,244 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM
public static final String QUERY_DELETE_RAW_CONFIGURATIONS_CONFIGURATION_IDS = "Configuration.deleteRawByConfigurationIds";
public static final String QUERY_DELETE_CONFIGURATIONS_BY_CONFIGURATION_IDs = "Configuration.deleteByConfigurationIdS";
+ private static abstract class AbstractPropertyMapBuilder<T extends AbstractPropertyMap, This extends AbstractPropertyMapBuilder<T, This>> {
+ private T map;
+
+ protected AbstractPropertyMapBuilder(T map) {
+ this.map = map;
+ }
+
+ /**
+ * Adds a simple property.
+ * @param name the name of the simple property
+ * @param value the value of the simple property
+ * @return continue with the definition
+ */
+ public This addSimple(String name, Object value) {
+ getMap().put(new PropertySimple(name, value));
+ return castThis();
+ }
+
+ /**
+ * Starts defining a new sub list.
+ * @param name the name of the sub list
+ * @param memberName the names of the member properties of the sub list
+ * @return the builder of the list
+ */
+ public Builder.ListInMap<This> openList(String name, String memberName) {
+ return new Builder.ListInMap<This>(castThis(), name, memberName);
+ }
+
+ /**
+ * Starts defining a new sub map.
+ * @param name the name of the sub map
+ * @return the builder of the map
+ */
+ public Builder.MapInMap<This> openMap(String name) {
+ return new Builder.MapInMap<This>(castThis(), name);
+ }
+
+ protected T getMap() {
+ return map;
+ }
+
+ @SuppressWarnings("unchecked")
+ private This castThis() {
+ return (This) this;
+ }
+ }
+
+ private static abstract class AbstractPropertyListBuilder<This extends AbstractPropertyListBuilder<This>> {
+ private PropertyList list;
+
+ private AbstractPropertyListBuilder(String name, String memberName) {
+ this.list = new PropertyList(name);
+ this.list.memberPropertyName = memberName;
+ }
+
+ /**
+ * Adds a simple property. The name of the property is the member name defined by this list.
+ * @param value the value of the simple property
+ * @return continue with the definition
+ */
+ public This addSimple(Object value) {
+ list.add(new PropertySimple(list.memberPropertyName, value));
+ return castThis();
+ }
+
+ /**
+ * Adds a number of simple properties. The names of the properties are the member name defined by this list.
+ * @param values the values of the simple properties
+ * @return continue with the definition
+ */
+ public This addSimples(Object... values) {
+ for(Object v : values) {
+ list.add(new PropertySimple(list.memberPropertyName, v));
+ }
+
+ return castThis();
+ }
+
+ /**
+ * Starts defining a new sub map.
+ * @return the builder of the map
+ */
+ public Builder.MapInList<This> openMap() {
+ return new Builder.MapInList<This>(castThis(), list.memberPropertyName);
+ }
+
+ /**
+ * Starts defining a new sub list.
+ * @param memberName the names of the member properties of the sub list
+ * @return the builder of the list
+ */
+ public Builder.ListInList<This> openList(String memberName) {
+ return new Builder.ListInList<This>(castThis(), list.memberPropertyName, memberName);
+ }
+
+ protected PropertyList getList() {
+ return list;
+ }
+
+ @SuppressWarnings("unchecked")
+ private This castThis() {
+ return (This) this;
+ }
+ }
+
+ /**
+ * A builder to easily build Configuration instances using a fluent API.
+ */
+ public static class Builder extends AbstractPropertyMapBuilder<Configuration, Builder> {
+
+ public static class MapInMap<Parent extends AbstractPropertyMapBuilder<?, ?>> extends AbstractPropertyMapBuilder<PropertyMap, MapInMap<Parent>> {
+ private Parent parent;
+
+ private MapInMap(Parent parent, String name) {
+ super(new PropertyMap(name));
+ this.parent = parent;
+ }
+
+ /**
+ * Closes the definition of the current map and returns to the parent context.
+ * @return the parent context
+ */
+ public Parent closeMap() {
+ parent.getMap().put(getMap());
+ return parent;
+ }
+ }
+
+ public static class MapInList<Parent extends AbstractPropertyListBuilder> extends AbstractPropertyMapBuilder<PropertyMap, MapInList<Parent>> {
+ private Parent parent;
+
+ public MapInList(Parent parent, String name) {
+ super(new PropertyMap(name));
+ this.parent = parent;
+ }
+
+ /**
+ * Closes the definition of the current map and returns to the parent context.
+ * @return the parent context
+ */
+ public Parent closeMap() {
+ parent.getList().add(getMap());
+ return parent;
+ }
+ }
+
+ public static class ListInMap<Parent extends AbstractPropertyMapBuilder<?, ?>> extends AbstractPropertyListBuilder<ListInMap<Parent>> {
+ private Parent parent;
+
+ private ListInMap(Parent parent, String name, String memberName) {
+ super(name, memberName);
+ this.parent = parent;
+ }
+
+ /**
+ * Closes the definition of the current list and returns to the parent context.
+ * @return the parent context
+ */
+ public Parent closeList() {
+ parent.getMap().put(getList());
+ return parent;
+ }
+ }
+
+ public static class ListInList<Parent extends AbstractPropertyListBuilder> extends AbstractPropertyListBuilder<ListInList<Parent>> {
+ private Parent parent;
+
+ private ListInList(Parent parent, String name, String memberName) {
+ super(name, memberName);
+ this.parent = parent;
+ }
+
+ /**
+ * Closes the definition of the current list and returns to the parent context.
+ * @return the parent context
+ */
+ public Parent closeList() {
+ parent.getList().add(getList());
+ return parent;
+ }
+ }
+
+ public class RawConfigurationBuilder {
+
+ private RawConfiguration rawConfig;
+
+ public RawConfigurationBuilder() {
+ rawConfig = new RawConfiguration();
+ rawConfig.setConfiguration(getMap());
+ }
+
+ public RawConfigurationBuilder withPath(String path) {
+ rawConfig.setPath(path);
+ return this;
+ }
+
+ public RawConfigurationBuilder withContents(String content, String sha256) {
+ rawConfig.setContents(content, sha256);
+ return this;
+ }
+
+ /**
+ * Closes the definition of the current raw configuration and returns to the parent context.
+ * @return the parent context
+ */
+ public Builder closeRawConfiguration() {
+ getMap().getRawConfigurations().add(rawConfig);
+ return Builder.this;
+ }
+ }
+
+ public Builder() {
+ super(new Configuration());
+ }
+
+ public Builder withNotes(String notes) {
+ getMap().setNotes(notes);
+ return this;
+ }
+
+ public Builder withVersion(long version) {
+ getMap().setVersion(version);
+ return this;
+ }
+
+ /**
+ * Starts defining a new raw configuration that will become part of this configuration.
+ * @return the builder of the raw configuration
+ */
+ public RawConfigurationBuilder openRawConfiguration() {
+ return new RawConfigurationBuilder();
+ }
+
+ public Configuration build() {
+ return getMap();
+ }
+ }
+
@GeneratedValue(generator = "RHQ_CONFIG_ID_SEQ", strategy = GenerationType.AUTO)
@Id
private int id;
@@ -283,6 +521,10 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM
@Column(name = "MTIME")
private long mtime = System.currentTimeMillis();
+ public static Builder builder() {
+ return new Builder();
+ }
+
public Configuration() {
}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationBuilderTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationBuilderTest.java
new file mode 100644
index 0000000..ad071ee
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationBuilderTest.java
@@ -0,0 +1,237 @@
+package org.rhq.core.domain.configuration;
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertSame;
+
+/**
+ * @author Lukas Krejci
+ */
+@Test
+public class ConfigurationBuilderTest {
+
+ public void testConfigurationProperties() {
+ Configuration config = Configuration.builder().withNotes("notes").withVersion(2).build();
+ assert "notes".equals(config.getNotes()) : "Unexpected notes";
+ assert 2 == config.getVersion() : "Unexpected version";
+ }
+
+ public void testSimples() {
+ Configuration config = Configuration.builder().addSimple("1", 1).addSimple("2", 2).build();
+
+ assert config.getSimpleValue("1").equals("1") : "1 != 1";
+ assert config.getSimpleValue("2").equals("2") : "2 != 2";
+
+ assert config.getSimple("1").getConfiguration() == config : "Configuration not set on property";
+ }
+
+ public void testListOfSimples() {
+ Configuration config = Configuration.builder().openList("l1", "m").addSimple(1).addSimple(2).closeList()
+ .openList("l2", "m").addSimples(1, 2).closeList().build();
+
+ PropertyList l1 = config.getList("l1");
+ PropertyList l2 = config.getList("l2");
+
+ assert l1 != null : "Could not find l1";
+ assert l2 != null : "Could not find l2";
+
+ assert l1.getConfiguration() == config : "Configuration on l1 not set";
+ assert l2.getConfiguration() == config : "Configuration on l2 not set";
+
+ assert l1.getList().size() == 2 : "Unexpected number of props in the list 1";
+ assert l2.getList().size() == 2 : "Unexpected number of props in the list 2";
+
+ testSimple((PropertySimple) l1.getList().get(0), null, l1, "1");
+ testSimple((PropertySimple) l1.getList().get(1), null, l1, "2");
+ testSimple((PropertySimple) l2.getList().get(0), null, l2, "1");
+ testSimple((PropertySimple) l2.getList().get(1), null, l2, "2");
+ }
+
+ public void testMapOfSimples() {
+ Configuration config = Configuration.builder().openMap("m").addSimple("1", 1).addSimple("2", 2).closeMap()
+ .build();
+
+ PropertyMap m = config.getMap("m");
+
+ assert m != null : "Cound not find map";
+
+ assert m.getConfiguration() == config : "Configuration on the map not set";
+
+ testSimple(m.getSimple("1"), m, null, "1");
+ testSimple(m.getSimple("2"), m, null, "2");
+ }
+
+ public void testListOfLists() {
+ Configuration config = new Configuration.Builder().openList("l", "m").openList("ml1").addSimples(1, 2)
+ .closeList().openList("ml2").addSimple(1).addSimple(2).closeList().closeList().build();
+
+ PropertyList l = config.getList("l");
+
+ assert l != null : "Could not find top-level list";
+
+ assert l.getList().size() == 2 : "Unexpected number of props in the top level list";
+
+ PropertyList m1 = (PropertyList) l.getList().get(0);
+ PropertyList m2 = (PropertyList) l.getList().get(1);
+
+ assert m1.getParentList() == l : "Parent list on m1 not set";
+ assert m1.getParentMap() == null : "Unexpected parent map on m1";
+ assert m2.getParentList() == l : "Parent list on m2 not set";
+ assert m1.getParentMap() == null : "Unexpected parent map on m2";
+
+ assert m1.getList().size() == 2 : "Unexpected number of props in the list 1";
+ assert m2.getList().size() == 2 : "Unexpected number of props in the list 2";
+
+ testSimple((PropertySimple) m1.getList().get(0), null, m1, "1");
+ testSimple((PropertySimple) m1.getList().get(1), null, m1, "2");
+ testSimple((PropertySimple) m2.getList().get(0), null, m2, "1");
+ testSimple((PropertySimple) m2.getList().get(1), null, m2, "2");
+ }
+
+ public void testListOfMaps() {
+ Configuration config = Configuration.builder().openList("l", "m").openMap().addSimple("c1", 1)
+ .addSimple("c2", 2).closeMap()
+ .openMap().addSimple("c1", 3).addSimple("c2", 4).closeMap().closeList().build();
+
+ PropertyList l = config.getList("l");
+
+ assert l != null : "Could not find top-level list";
+
+ assert l.getList().size() == 2 : "Unexpected number of props in the top level list";
+
+ PropertyMap m1 = (PropertyMap) l.getList().get(0);
+ PropertyMap m2 = (PropertyMap) l.getList().get(1);
+
+ assert m1.getParentList() == l : "Parent list on m1 not set";
+ assert m1.getParentMap() == null : "Unexpected parent map on m1";
+ assert m2.getParentList() == l : "Parent list on m2 not set";
+ assert m1.getParentMap() == null : "Unexpected parent map on m2";
+
+ assert m1.getMap().size() == 2 : "Unexpected number of props in the list 1";
+ assert m2.getMap().size() == 2 : "Unexpected number of props in the list 2";
+
+ testSimple(m1.getSimple("c1"), m1, null, "1");
+ testSimple(m1.getSimple("c2"), m1, null, "2");
+ testSimple(m2.getSimple("c1"), m2, null, "3");
+ testSimple(m2.getSimple("c2"), m2, null, "4");
+ }
+
+ public void testMapOfMaps() {
+ Configuration config = Configuration.builder().openMap("m").openMap("im1").addSimple("c1", 1).addSimple("c2", 2)
+ .closeMap().openMap("im2").addSimple("c1", 3).addSimple("c2", 4).closeMap().closeMap().build();
+
+ PropertyMap m = config.getMap("m");
+
+ assert m != null : "Could not find the top level map";
+
+ assert m.getMap().size() == 2 : "Unexpected number of props in the top level map";
+
+ PropertyMap m1 = m.getMap("im1");
+ PropertyMap m2 = m.getMap("im2");
+
+ assert m1 != null : "Could not find im1";
+ assert m2 != null : "Could not find im2";
+
+ assert m1.getParentList() == null : "Unexpected parent list on m1";
+ assert m1.getParentMap() == m : "Unexpected parent map on m1";
+ assert m2.getParentList() == null : "Unexpected parent list on m2";
+ assert m1.getParentMap() == m : "Unexpected parent map on m2";
+
+ testSimple(m1.getSimple("c1"), m1, null, "1");
+ testSimple(m1.getSimple("c2"), m1, null, "2");
+ testSimple(m2.getSimple("c1"), m2, null, "3");
+ testSimple(m2.getSimple("c2"), m2, null, "4");
+ }
+
+ public void testMapOfLists() {
+ Configuration config = Configuration.builder().openMap("m").openList("il1", "m").addSimples(1, 2)
+ .closeList().openList("il2", "m").addSimples(3, 4).closeList().closeMap().build();
+
+ PropertyMap m = config.getMap("m");
+
+ assert m != null : "Could not find the top level map";
+
+ assert m.getMap().size() == 2 : "Unexpected number of props in the top level map";
+
+ PropertyList l1 = m.getList("il1");
+ PropertyList l2 = m.getList("il2");
+
+ assert l1 != null : "Could not find il1";
+ assert l2 != null : "Could not find il2";
+
+ assert l1.getParentList() == null : "Unexpected parent list on l1";
+ assert l1.getParentMap() == m : "Unexpected parent map on l1";
+ assert l2.getParentList() == null : "Unexpected parent list on l2";
+ assert l2.getParentMap() == m : "Unexpected parent map on l2";
+
+ testSimple((PropertySimple) l1.getList().get(0), null, l1, "1");
+ testSimple((PropertySimple) l1.getList().get(1), null, l1, "2");
+ testSimple((PropertySimple) l2.getList().get(0), null, l2, "3");
+ testSimple((PropertySimple) l2.getList().get(1), null, l2, "4");
+ }
+
+ public void testUtterMess() {
+ Configuration config = Configuration.builder()
+ .openList("l", "m") //
+ /**/.openMap() //
+ /**//**/.openMap("innerMap") //
+ /**//**//**/.addSimple("c1", 1) //
+ /**//**//**/.openList("c2", "m") //
+ /**//**//**/.closeList() //
+ /**//**/.closeMap() //
+ /**//**/.addSimple("simple", 2) //
+ /**//**/.openList("innerList", "m") //
+ /**//**/.closeList() //
+ /**/.closeMap() //
+ /**/.addSimple(3) //
+ /**/.openList("im") //
+ /**//**/.openList("iim") //
+ /**//**/.closeList() //
+ /**//**/.openMap() //
+ /**//**/.closeMap() //
+ /**/.closeList() //
+ .closeList().build();
+
+ PropertyList l = config.getList("l");
+ PropertyMap lm = (PropertyMap) l.getList().get(0);
+ PropertyMap innerMap = lm.getMap("innerMap");
+ PropertySimple c1 = innerMap.getSimple("c1");
+ PropertyList c2 = innerMap.getList("c2");
+ PropertySimple simple = lm.getSimple("simple");
+ PropertyList innerList = lm.getList("innerList");
+ PropertySimple ls = (PropertySimple) l.getList().get(1);
+ PropertyList ll = (PropertyList) l.getList().get(2);
+ PropertyList lll = (PropertyList) ll.getList().get(0);
+ PropertyMap llm = (PropertyMap) ll.getList().get(1);
+
+ //all the aspects of the above mess have been tested in the previous tests
+ //this just really is here to prove the point of how messy our configs can be
+
+ assert c1 != null;
+ assert c2 != null;
+ assert simple != null;
+ assert innerList != null;
+ assert ls != null;
+ assert lll != null;
+ assert llm != null;
+ }
+
+ public void testRawConfigs() {
+ Configuration config = Configuration.builder().openRawConfiguration().withPath("a/b")
+ .withContents("asdf", "123").closeRawConfiguration().build();
+
+ RawConfiguration r = config.getRawConfigurations().iterator().next();
+ assert r.getPath().equals("a/b") : "Unexpected path";
+ assert r.getContents().equals("asdf") : "Unexpected contents";
+ assert r.getSha256().equals("123") : "Unexpected sha256";
+ assert r.getConfiguration() == config : "Unexpected raw config owning configuration";
+ }
+
+ private void testSimple(PropertySimple p, PropertyMap expectedParentMap, PropertyList expectedParentList,
+ String expectedValue) {
+ assertSame(p.getParentMap(), expectedParentMap, "Unexpected parent map");
+ assertSame(p.getParentList(), expectedParentList, "Unexpected parent list");
+ assertEquals(p.getStringValue(), expectedValue, "Unexpected value");
+ }
+}
commit eb3c52f1ba91a70fa7bdb45405849a1af4aa524a
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jul 15 10:18:15 2013 +0200
Add a JavaFX frontend to the PluginGenerator.
diff --git a/modules/helpers/pluginGen/pom.xml b/modules/helpers/pluginGen/pom.xml
index e9a5e29..5aa512c 100644
--- a/modules/helpers/pluginGen/pom.xml
+++ b/modules/helpers/pluginGen/pom.xml
@@ -22,6 +22,14 @@
<build>
<plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.7</source>
+ <target>1.7</target>
+ </configuration>
+ </plugin>
+
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
@@ -98,6 +106,13 @@
<artifactId>rhq-pluginAnnotations</artifactId>
<version>4.8.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>javafx</artifactId>
+ <version>2.0</version>
+ <systemPath>${java.home}/lib/jfxrt.jar</systemPath>
+ <scope>system</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Generator.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Generator.java
new file mode 100644
index 0000000..06f3fec
--- /dev/null
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Generator.java
@@ -0,0 +1,295 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.helpers.pluginGen;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javafx.application.Application;
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
+import javafx.collections.ObservableList;
+import javafx.event.ActionEvent;
+import javafx.event.EventHandler;
+import javafx.geometry.Insets;
+import javafx.geometry.Pos;
+import javafx.scene.Node;
+import javafx.scene.Scene;
+import javafx.scene.control.*;
+import javafx.scene.layout.BorderPane;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.VBox;
+import javafx.scene.paint.Color;
+import javafx.scene.text.Font;
+import javafx.scene.text.FontPosture;
+import javafx.scene.text.FontWeight;
+import javafx.scene.text.Text;
+import javafx.scene.text.TextAlignment;
+import javafx.stage.DirectoryChooser;
+import javafx.stage.Stage;
+
+/**
+ * JavaFX version of the plugin generator
+ * @author Heiko W. Rupp
+ */
+public class Generator extends Application{
+
+ Props props = new Props();
+ private Text errorMessage;
+ private Stage primaryStage;
+
+ public static void main(String[] args) {
+ launch(args);
+ }
+
+
+ @Override
+ public void start(Stage stage) throws Exception {
+ primaryStage = stage;
+
+ Button createButton = new Button();
+ createButton.setText("Create!");
+ createButton.setAlignment(Pos.BOTTOM_RIGHT);
+ createButton.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent actionEvent) {
+
+ PluginGen pluginGen = new PluginGen();
+ pluginGen.postprocess(props);
+ try {
+ pluginGen.generate(props);
+ setInfoMessage("Generated!");
+
+ }
+ catch (Exception e) {
+ setErrorMessage("Error during generation: " + e.getMessage());
+ }
+ }
+ });
+
+ GridPane pluginLevelPane = new GridPane();
+ pluginLevelPane.setPadding(new Insets(10));
+ Text pluginLevelDescription = new Text("Plugin level properties");
+ pluginLevelDescription.setTextAlignment(TextAlignment.CENTER);
+ pluginLevelDescription.setFont(Font.font("Arial", FontWeight.BOLD, 14));
+
+ Text resourceLevelDescription = new Text("ResourceType level properties");
+ resourceLevelDescription.setTextAlignment(TextAlignment.CENTER);
+ resourceLevelDescription.setFont(Font.font("Arial", FontWeight.BOLD, 14));
+
+ Text descriptionDescription = new Text("Field description");
+ descriptionDescription.setTextAlignment(TextAlignment.CENTER);
+ descriptionDescription.setFont(Font.font("Arial", FontWeight.BOLD, 14));
+
+ HBox msgBox = getMessagesBox();
+
+ GridPane resourceLevelPane = new GridPane();
+ resourceLevelPane.setPadding(new Insets(10));
+ Text descriptionText = new Text();
+ descriptionText.setFont(Font.font("Arial", FontPosture.ITALIC,12));
+
+ VBox innerBox = new VBox();
+ innerBox.setAlignment(Pos.CENTER_LEFT);
+ innerBox.setPadding(new Insets(25, 25, 25, 25));
+ innerBox.setSpacing(8);
+
+ addFields(pluginLevelPane, true, descriptionText);
+ addFields(resourceLevelPane, false, descriptionText);
+
+ ObservableList<Node> children = innerBox.getChildren();
+ children.add(pluginLevelDescription);
+ children.add(pluginLevelPane);
+ children.add(resourceLevelDescription);
+ children.add(resourceLevelPane);
+
+
+ ScrollPane scrollPane = new ScrollPane();
+ scrollPane.setContent(innerBox);
+
+ BorderPane outerBox = new BorderPane();
+ outerBox.setTop(msgBox);
+ outerBox.setPadding(new Insets(5));
+ outerBox.setCenter(scrollPane);
+
+ VBox descriptionBox = new VBox();
+ descriptionBox.getChildren().add(descriptionDescription);
+ descriptionBox.getChildren().add(descriptionText);
+ outerBox.setBottom(descriptionBox);
+
+ outerBox.setRight(createButton);
+
+
+ stage.setScene(new Scene(outerBox, 600, 550));
+ stage.show();
+ }
+
+ private HBox getMessagesBox() {
+ HBox msgBox = new HBox();
+ Label label = new Label("Messages:");
+ msgBox.getChildren().add(label);
+ errorMessage = new Text();
+ errorMessage.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12));
+ errorMessage.setId("errorMessage");
+ msgBox.getChildren().add(errorMessage);
+ return msgBox;
+ }
+
+ private int addFields(final GridPane root, boolean pluginLevel, final Text descriptionField) {
+
+ int row = 0;
+ for (final Prop prop : Prop.values()) {
+
+ if (!prop.isPluginLevel()==pluginLevel) {
+ continue;
+ }
+
+ // Add the label
+ String name = prop.readableName();
+ Label fieldName = new Label(name);
+ root.add(fieldName,0,row);
+
+ // Now add the field itself
+ final Class propType = prop.getType();
+ if (propType.equals(String.class)) {
+ final Pattern pattern = Pattern.compile(prop.getValidationRegex());
+
+ final TextField input = new TextField();
+ // Add field leave event to fill in the props with the result
+ input.focusedProperty().addListener(new ChangeListener<Boolean>() {
+ @Override
+ public void changed(ObservableValue<? extends Boolean> observableValue, Boolean oldState,
+ Boolean newState) {
+ if (newState) { // User entered input field
+ descriptionField.setText(prop.getDescription());
+ }
+ else { // User left input field
+ descriptionField.setText("");
+ setPropsValue(prop.getVariableName(),input.getText(), propType); // TODO right place?
+ }
+ }
+ });
+ // Add validation of the input
+ input.textProperty().addListener(new ChangeListener<String>() {
+ @Override
+ public void changed(ObservableValue<? extends String> observableValue, String s, String newText) {
+ Matcher m = pattern.matcher(newText);
+ if (!m.matches()) {
+ setErrorMessage("Input does not match " + prop.getValidationRegex());
+ } else {
+ clearErrorMessage();
+ }
+
+ }
+ });
+ root.add(input, 1, row);
+ } else if (propType.equals(Boolean.class) || propType.equals(boolean.class)) {
+ final ChoiceBox choiceBox = new ChoiceBox();
+ choiceBox.getItems().addAll("Yes", "No");
+ choiceBox.getSelectionModel().selectLast(); // NO is default
+ choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
+ @Override
+ public void changed(ObservableValue<? extends String> observableValue, String s, String newValue) {
+ setPropsValue(prop.getVariableName(),newValue.equals("Yes"),propType);
+ }
+ });
+
+ root.add(choiceBox,1,row);
+ } else if (propType.equals(ResourceCategory.class)) {
+ final ChoiceBox choiceBox = new ChoiceBox();
+ for (ResourceCategory cat : ResourceCategory.values()) {
+ choiceBox.getItems().add(cat.getLowerName());
+ }
+ choiceBox.getSelectionModel().selectLast(); // service is default
+ choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
+ @Override
+ public void changed(ObservableValue<? extends String> observableValue, String s, String newValue) {
+ ResourceCategory newCategory = ResourceCategory.valueOf(newValue.toUpperCase());
+ setPropsValue(prop.getVariableName(),newCategory,propType);
+ }
+ });
+
+ root.add(choiceBox,1,row);
+ } else if (propType.equals(File.class)) {
+ // Can not add this directly, so add a button to trigger it
+ final Text text = new Text();
+ text.setText("Pick a directory");
+ root.add(text,1,row);
+ Button pickButton = new Button("Pick");
+ pickButton.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent actionEvent) {
+ DirectoryChooser chooser = new DirectoryChooser();
+ chooser.setTitle("Pick a directory where the plugin will be put in.");
+ File dir = chooser.showDialog(primaryStage);
+ if (dir != null) {
+ String dirName = dir.getAbsolutePath();
+ props.setFileSystemRoot(dirName);
+ clearErrorMessage();
+ text.setText(dirName);
+ } else {
+ setErrorMessage("No directory selected");
+ text.setText("Pick a directory");
+ }
+ }
+ });
+
+ root.add(pickButton,2,row);
+ }
+
+ row++;
+
+ }
+
+ return row;
+ }
+
+ private void setInfoMessage(String message) {
+ errorMessage.setText(message);
+ errorMessage.setFill(Color.DARKGREEN);
+ }
+ private void setErrorMessage(String message) {
+ errorMessage.setText(message);
+ errorMessage.setFill(Color.RED);
+ }
+
+ private void clearErrorMessage() {
+ errorMessage.setText("");
+ errorMessage.setFill(Color.WHITE);
+ }
+
+ private void setPropsValue(String variableName, Object value, Class type) {
+
+ String var = variableName.substring(0,1).toUpperCase() + variableName.substring(1);
+ String setterName = "set"+ var;
+
+ try {
+ Method setter = Props.class.getDeclaredMethod(setterName,type);
+ setter.invoke(props,value);
+ } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
+ e.printStackTrace(); // TODO: Customise this generated block
+ setErrorMessage(e.getMessage());
+ }
+ }
+
+}
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/PluginGen.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/PluginGen.java
index 223a57f..64b5509 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/PluginGen.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/PluginGen.java
@@ -115,7 +115,7 @@ public class PluginGen {
* Do some post processing over the input received.
* @param props The properties just recorded from the user input
*/
- private void postprocess(Props props) {
+ protected void postprocess(Props props) {
// Set the package
String pkg = props.getPackagePrefix() + "." + props.getName();
@@ -231,7 +231,7 @@ public class PluginGen {
* Trigger the generation of the directory hierarchy.
* @param props Parameters to take into account
*/
- private void generate(Props props) {
+ protected void generate(Props props) {
log.info("Generating...");
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Prop.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Prop.java
new file mode 100644
index 0000000..73c4cd9
--- /dev/null
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Prop.java
@@ -0,0 +1,114 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.helpers.pluginGen;
+
+import java.io.File;
+
+/**
+ * All the properties that can be configured along with type, description and simple validation rules
+ * @author Heiko W. Rupp
+ */
+public enum Prop {
+
+ PLUGIN_NAME("pluginName", String.class,"Name of the plugin", "\\w+" , true ),
+ PLUGIN_DESCRIPTION("pluginDescription", String.class,"Description of the plugin",".*" , true ),
+ PACKAGE("packagePrefix", String.class,"Default Package","[a-zA-Z\\.]+",true ),
+ FILE_ROOT("fileSystemRoot", File.class,"Root directory to put the plugin",".*",true ),
+ RHQ_VERSION("rhqVersion",String.class,"RHQ version to use","[0-9][0-9\\.]+",true),
+
+ CATEGORY("category", ResourceCategory.class, "Category of the resource type (platform = host level)",null),
+ TYPE_NAME("name", String.class, "Name of the resource type", "\\w+"),
+ DESCRIPTION("description", String.class, "Description of the type", ".*"),
+ DISCOVERY_CLASS("discoveryClass", String.class, "Discovery class", "[A-Z][a-zA-Z0-9]*"),
+ COMPONENT_CLASS("componentClass", String.class, "Discovery class", "[A-Z][a-zA-Z0-9]*"),
+ IS_SINGLETON("singleton",Boolean.class,"Is this type a singleton, which means that" +
+ " there can only be one resource of that type for the given parent?",null),
+ HAS_METRICS("hasMetrics",boolean.class,"Does this type support taking metrics?",null),
+ HAS_OPERATIONS("hasOperations",boolean.class,"Does this type support operations?",null),
+ HAS_EVENTS("events",boolean.class,"Does this type support events?",null),
+ HAS_SUPPORT_FACET("supportFacet",boolean.class,"Does this type support the support facet?",null),
+ RESOURCE_CONFIGURATION("resourceConfiguration",boolean.class,"Does this type support " +
+ "configuring the resource?",".*"),
+ CAN_CREATE_CHILDREN("createChildren",boolean.class,"Can the type create child resources?",null),
+ CAN_DELETE_CHILDREN("deleteChildren",boolean.class,"Can the type delete child resources?",null),
+
+ // TODO add the remaining properties from Prop.class
+
+ ;
+
+ private String variableName;
+ private Class type;
+ private String description;
+ private boolean pluginLevel;
+ private String validationRegex;
+
+ private Prop(String variableName, Class type, String description, String validationRegex, boolean pluginLevel) {
+ this.variableName = variableName;
+ this.type = type;
+ this.description = description;
+ this.validationRegex = validationRegex;
+ this.pluginLevel = pluginLevel;
+ }
+
+ private Prop(String variableName, Class type, String description, String validationRegex) {
+ this.variableName = variableName;
+ this.type = type;
+ this.description = description;
+ this.validationRegex = validationRegex;
+ }
+
+ public String getVariableName() {
+ return variableName;
+ }
+
+ public Class getType() {
+ return type;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public boolean isPluginLevel() {
+ return pluginLevel;
+ }
+
+ public String getValidationRegex() {
+ return validationRegex;
+ }
+
+ public String readableName() {
+
+ String name = name();
+ name = name.replaceAll("_", " ");
+ String[] parts = name.split(" ");
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0; i < parts.length; i++) {
+ String part = parts[i];
+ part = part.substring(0,1).toUpperCase() + part.substring(1).toLowerCase();
+ builder.append(part);
+ if (i < parts.length-1) {
+ builder.append(" ");
+ }
+ }
+ return builder.toString();
+ }
+
+}
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
index 484d591..237f5ad 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
@@ -36,7 +36,7 @@ import org.rhq.helpers.pluginAnnotations.agent.Units;
public class Props {
/** What category is this ? */
- private ResourceCategory category;
+ private ResourceCategory category = ResourceCategory.SERVICE;
/** The name of this item */
private String name;
/** A description of the plugin */
commit 18c42dafe1e9e51a16a5ceba068a1e27cb8788c0
Author: John Sanda <jsanda(a)redhat.com>
Date: Sun Jul 14 22:36:40 2013 -0400
adding heap dump properties to resource configuration
The heap dump directory defaults to <rhq-storage-basedir>/bin and we are
generating heap dumps by default. Also refactoring and updating tests some.
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
index 99ba48b..e82f290 100644
--- a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
+++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
@@ -11,6 +11,7 @@ import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.util.PropertiesFileUpdate;
+import org.rhq.core.util.StringUtil;
/**
* @author John Sanda
@@ -35,12 +36,27 @@ public class StorageNodeConfigDelegate implements ConfigurationFacet {
String heapMaxProp = properties.getProperty("heap_max");
String heapNewProp = properties.getProperty("heap_new");
String threadStackSizeProp = properties.getProperty("thread_stack_size");
+ String heapDumpOnOOMError = properties.getProperty("heap_dump_on_OOMError");
+ String heapDumpDir = properties.getProperty("heap_dump_dir");
config.put(new PropertySimple("minHeapSize", heapMinProp.substring(4)));
config.put(new PropertySimple("maxHeapSize", heapMaxProp.substring(4)));
config.put(new PropertySimple("heapNewSize", heapNewProp.substring(4)));
config.put(new PropertySimple("threadStackSize", threadStackSizeProp.substring(4)));
+ if (!StringUtil.isEmpty(heapDumpOnOOMError)) {
+ config.put(new PropertySimple("heapDumpOnOOMError", true));
+ } else {
+ config.put(new PropertySimple("heapDumpOnOOMError", false));
+ }
+
+ if (!StringUtil.isEmpty(heapDumpDir)) {
+ config.put(new PropertySimple("heapDumpDir", heapDumpDir));
+ } else {
+ File basedir = jvmOptsFile.getParentFile().getParentFile();
+ config.put(new PropertySimple("heapDumpDir", new File(basedir, "bin").getAbsolutePath()));
+ }
+
return config;
}
@@ -58,6 +74,14 @@ public class StorageNodeConfigDelegate implements ConfigurationFacet {
properties.setProperty("heap_new", "-Xmn" + config.getSimpleValue("heapNewSize"));
properties.setProperty("thread_stack_size", "-Xss" + config.getSimpleValue("threadStackSize"));
+ if (config.getSimple("heapDumpOnOOMError").getBooleanValue()) {
+ properties.setProperty("heap_dump_on_OOMError", "-XX:+HeapDumpOnOutOfMemoryError");
+ } else {
+ properties.setProperty("heap_dump_on_OOMError", "");
+ }
+
+ properties.setProperty("heap_dump_dir", config.getSimpleValue("heapDumpDir"));
+
propertiesUpdater.update(properties);
configurationUpdateReport.setStatus(ConfigurationUpdateStatus.SUCCESS);
diff --git a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
index 5713288..c700257 100644
--- a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
@@ -124,6 +124,11 @@
the -Xmn JVM option."/>
<c:simple-property name="threadStackSize"
description="The thread stack size. This memory is allocated to each thread off heap."/>
+ <c:simple-property name="heapDumpOnOOMError" displayName="Heap Dump on OutOfMemoryError" type="boolean"
+ default="true"
+ description="Generate a heap dump when an OutOfMemoryError occurs"/>
+ <c:simple-property name="heapDumpDir" displayName="Heap Dump Directory" required="false"
+ description="The directory in which heap dumps will be written."/>
</c:group>
</resource-configuration>
diff --git a/modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java b/modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java
index f8d7bdc..5c5f089 100644
--- a/modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java
+++ b/modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java
@@ -6,8 +6,10 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.lang.reflect.Method;
import java.util.Properties;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.rhq.core.domain.configuration.Configuration;
@@ -19,16 +21,18 @@ import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
*/
public class StorageNodeConfigDelegateTest {
+ private File basedir;
+
+ @BeforeMethod
+ public void initDirs(Method test) throws Exception {
+ File dir = new File(getClass().getResource(".").toURI());
+ basedir = new File(dir, getClass().getSimpleName() + "/" + test.getName());
+ }
@Test
public void loadValidConfig() throws Exception {
- File dir = new File(getClass().getResource(".").toURI());
- File basedir = new File(dir, getClass().getSimpleName() + "/loadValidConfig");
- File confDir = new File(basedir, "conf");
-
- confDir.mkdirs();
- createDefaultConfig(confDir);
+ createDefaultConfig();
StorageNodeConfigDelegate configDelegate = new StorageNodeConfigDelegate(basedir);
Configuration config = configDelegate.loadResourceConfiguration();
@@ -37,22 +41,22 @@ public class StorageNodeConfigDelegateTest {
assertEquals(config.getSimpleValue("maxHeapSize"), "512M", "Failed to load property [maxHepSize]");
assertEquals(config.getSimpleValue("heapNewSize"), "128M", "Failed to load property [heapNewSize]");
assertEquals(config.getSimpleValue("threadStackSize"), "180k", "Failed to load property [threadStackSize]");
+ assertEquals(config.getSimple("heapDumpOnOOMError").getBooleanValue(), (Boolean) true,
+ "Failed to load property [heapDumpOnOOMError]");
+ assertEquals(new File(config.getSimpleValue("heapDumpDir")), binDir(), "Failed to load property [heapDumpDir]");
}
@Test
public void updateValidConfig() throws Exception {
- File dir = new File(getClass().getResource(".").toURI());
- File basedir = new File(dir, getClass().getSimpleName() + "/updateValidConfig");
- File confDir = new File(basedir, "conf");
-
- confDir.mkdirs();
- createDefaultConfig(confDir);
+ createDefaultConfig();
Configuration config = new Configuration();
config.put(new PropertySimple("minHeapSize", "1024M"));
config.put(new PropertySimple("maxHeapSize", "1024M"));
config.put(new PropertySimple("heapNewSize", "256M"));
config.put(new PropertySimple("threadStackSize", "240k"));
+ config.put(new PropertySimple("heapDumpOnOOMError", true));
+ config.put(new PropertySimple("heapDumpDir", confDir()));
ConfigurationUpdateReport report = new ConfigurationUpdateReport(config);
@@ -60,23 +64,44 @@ public class StorageNodeConfigDelegateTest {
configDelegate.updateResourceConfiguration(report);
Properties properties = new Properties();
- properties.load(new FileInputStream(new File(confDir, "cassandra-jvm.properties")));
+ properties.load(new FileInputStream(new File(confDir(), "cassandra-jvm.properties")));
assertEquals(properties.getProperty("heap_min"), "-Xms1024M", "Failed to update property [minHeapSize]");
assertEquals(properties.getProperty("heap_max"), "-Xmx1024M", "Failed to update property [maxHeapSize]");
assertEquals(properties.getProperty("heap_new"), "-Xmn256M", "Failed to update property [heapNewSize]");
assertEquals(properties.getProperty("thread_stack_size"), "-Xss240k",
"Failed to update property [threadStackSize]");
+ assertEquals(properties.getProperty("heap_dump_on_OOMError"), "-XX:+HeapDumpOnOutOfMemoryError",
+ "Failed to update property [heap_dump_on_OOMError]");
+ assertEquals(properties.getProperty("heap_dump_dir"), confDir().getAbsolutePath(),
+ "Failed to update property [heap_dump_dir]");
}
- private void createDefaultConfig(File confDir) throws IOException {
+ private void createDefaultConfig() throws IOException {
Properties properties = new Properties();
properties.setProperty("heap_min", "-Xms512M");
properties.setProperty("heap_max", "-Xmx512M");
properties.setProperty("heap_new", "-Xmn128M");
properties.setProperty("thread_stack_size", "-Xss180k");
+ properties.setProperty("heap_dump_on_OOMError", "-XX:+HeapDumpOnOutOfMemoryError");
+
+ properties.store(new FileOutputStream(new File(confDir(), "cassandra-jvm.properties")), "");
+ }
+
+ private File confDir() {
+ return mkdirIfNecessary(basedir, "conf");
+ }
+
+ private File binDir() {
+ return mkdirIfNecessary(basedir, "bin");
+ }
- properties.store(new FileOutputStream(new File(confDir, "cassandra-jvm.properties")), "");
+ private File mkdirIfNecessary(File parent, String path) {
+ File dir = new File(parent, path);
+ if (!dir.exists()) {
+ dir.mkdirs();
+ }
+ return dir;
}
}
commit 1130a8be9a9a44c6e4670053bd7347aed4e01f30
Author: John Sanda <jsanda(a)redhat.com>
Date: Sun Jul 14 09:44:04 2013 -0400
adding initial support for resource config updates of StorageNodeComponent
Also making minHeapSize read only as we also want it the same as maxHeapSize.
diff --git a/modules/plugins/rhq-storage/pom.xml b/modules/plugins/rhq-storage/pom.xml
index ea3b9ea..a88f56e 100644
--- a/modules/plugins/rhq-storage/pom.xml
+++ b/modules/plugins/rhq-storage/pom.xml
@@ -39,103 +39,6 @@
<profiles>
<profile>
- <id>integration-tests</id>
- <activation>
- <property>
- <name>maven.test.skip</name>
- <value>!true</value>
- </property>
- </activation>
-
- <build>
- <plugins>
-
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <phase>pre-integration-test</phase>
- <configuration>
- <target>
- <echo>Setting up plugin dependencies...</echo>
- <property name="settings.localRepository" location="${user.home}/.m2/repository" />
- <mkdir dir="target/itest" />
- <mkdir dir="target/itest/plugins" />
- <mkdir dir="target/itest/lib" />
- <copy toDir="target/itest/plugins" flatten="true">
- <!-- Plugin dependencies on other plugins -->
- <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/rhq/rhq-jboss-as-7-jmx-plugin/${project.version}/rhq-jboss-as-7-jmx-plugin-${project.version}.jar" />
- </fileset>
- <fileset dir="${project.build.directory}">
- <include name="rhq-rhqserver-plugin-${project.version}.jar" />
- </fileset>
- </copy>
- <unzip dest="target/itest/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/itest/lib" flatten="true">
- <fileset dir="target/itest/lib">
- <include name="**/lib/*" />
- </fileset>
- </move>
- <delete dir="target/itest/lib/hyperic-sigar-${sigar.version}" />
- </target>
- </configuration>
- <goals>
- <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>${jacoco.integration-test.args} -Dorg.hyperic.sigar.path=${basedir}/target/itest/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>
-
- <profile>
<id>dev</id>
<properties>
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
index 737dded..6194146 100644
--- a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
+++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
@@ -26,9 +26,7 @@
package org.rhq.plugins.storage;
import java.io.File;
-import java.io.FileInputStream;
import java.util.List;
-import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -62,25 +60,13 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
@Override
public Configuration loadResourceConfiguration() throws Exception {
- File confDir = new File(getBasedir(), "conf");
- File jvmOptsFile = new File(confDir, "cassandra-jvm.properties");
-
- Properties properties = new Properties();
- properties.load(new FileInputStream(jvmOptsFile));
-
- Configuration config = new Configuration();
-
- String heapMinProp = properties.getProperty("heap_min");
- String heapMaxProp = properties.getProperty("heap_max");
- String heapNewProp = properties.getProperty("heap_new");
- String threadStackSizeProp = properties.getProperty("thread_stack_size");
-
- config.put(new PropertySimple("minHeapSize", heapMinProp.substring(4)));
- config.put(new PropertySimple("maxHeapSize", heapMaxProp.substring(4)));
- config.put(new PropertySimple("heapNewSize", heapNewProp.substring(4)));
- config.put(new PropertySimple("threadStackSize", threadStackSizeProp.substring(4)));
+ return new StorageNodeConfigDelegate(getBasedir()).loadResourceConfiguration();
+ }
- return config;
+ @Override
+ public void updateResourceConfiguration(ConfigurationUpdateReport configurationUpdateReport) {
+ StorageNodeConfigDelegate configDelegate = new StorageNodeConfigDelegate(getBasedir());
+ configDelegate.updateResourceConfiguration(configurationUpdateReport);
}
private File getBasedir() {
@@ -89,10 +75,6 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
}
@Override
- public void updateResourceConfiguration(ConfigurationUpdateReport configurationUpdateReport) {
- }
-
- @Override
public OperationResult invokeOperation(String name, Configuration parameters) throws Exception {
if (name.equals("addNodeMaintenance")) {
return nodeAdded(parameters);
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
new file mode 100644
index 0000000..99ba48b
--- /dev/null
+++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
@@ -0,0 +1,69 @@
+package org.rhq.plugins.storage;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.util.PropertiesFileUpdate;
+
+/**
+ * @author John Sanda
+ */
+public class StorageNodeConfigDelegate implements ConfigurationFacet {
+
+ private File jvmOptsFile;
+
+ public StorageNodeConfigDelegate(File basedir) {
+ File confDir = new File(basedir, "conf");
+ jvmOptsFile = new File(confDir, "cassandra-jvm.properties");
+ }
+
+ @Override
+ public Configuration loadResourceConfiguration() throws Exception {
+ Properties properties = new Properties();
+ properties.load(new FileInputStream(jvmOptsFile));
+
+ Configuration config = new Configuration();
+
+ String heapMinProp = properties.getProperty("heap_min");
+ String heapMaxProp = properties.getProperty("heap_max");
+ String heapNewProp = properties.getProperty("heap_new");
+ String threadStackSizeProp = properties.getProperty("thread_stack_size");
+
+ config.put(new PropertySimple("minHeapSize", heapMinProp.substring(4)));
+ config.put(new PropertySimple("maxHeapSize", heapMaxProp.substring(4)));
+ config.put(new PropertySimple("heapNewSize", heapNewProp.substring(4)));
+ config.put(new PropertySimple("threadStackSize", threadStackSizeProp.substring(4)));
+
+ return config;
+ }
+
+ @Override
+ public void updateResourceConfiguration(ConfigurationUpdateReport configurationUpdateReport) {
+ try {
+ PropertiesFileUpdate propertiesUpdater = new PropertiesFileUpdate(jvmOptsFile.getAbsolutePath());
+ Properties properties = propertiesUpdater.loadExistingProperties();
+
+ Configuration config = configurationUpdateReport.getConfiguration();
+
+ // We want min and max heap to be the same
+ properties.setProperty("heap_min", "-Xms" + config.getSimpleValue("maxHeapSize"));
+ properties.setProperty("heap_max", "-Xmx" + config.getSimpleValue("maxHeapSize"));
+ properties.setProperty("heap_new", "-Xmn" + config.getSimpleValue("heapNewSize"));
+ properties.setProperty("thread_stack_size", "-Xss" + config.getSimpleValue("threadStackSize"));
+
+ propertiesUpdater.update(properties);
+
+ configurationUpdateReport.setStatus(ConfigurationUpdateStatus.SUCCESS);
+ } catch (IOException e) {
+ configurationUpdateReport.setErrorMessageFromThrowable(e);
+ }
+
+ }
+}
diff --git a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
index b012f1c..5713288 100644
--- a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
@@ -114,8 +114,9 @@
<resource-configuration>
<c:group name="MemorySettings">
<c:simple-property name="minHeapSize"
+ readOnly="true"
description="The minimum heap size. This value will be used with the -Xms JVM option. This
- should always be the same as Max Heap Size."/>
+ is read only because it is automatically set to the same value as Max Heap Size."/>
<c:simple-property name="maxHeapSize"
description="The maximum heap size. This value will be used with the -Xmx JVM option."/>
<c:simple-property name="heapNewSize"
diff --git a/modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java b/modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java
new file mode 100644
index 0000000..f8d7bdc
--- /dev/null
+++ b/modules/plugins/rhq-storage/src/test/java/org/rhq/plugins/storage/StorageNodeConfigDelegateTest.java
@@ -0,0 +1,82 @@
+package org.rhq.plugins.storage;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+
+/**
+ * @author John Sanda
+ */
+public class StorageNodeConfigDelegateTest {
+
+
+
+ @Test
+ public void loadValidConfig() throws Exception {
+ File dir = new File(getClass().getResource(".").toURI());
+ File basedir = new File(dir, getClass().getSimpleName() + "/loadValidConfig");
+ File confDir = new File(basedir, "conf");
+
+ confDir.mkdirs();
+ createDefaultConfig(confDir);
+
+ StorageNodeConfigDelegate configDelegate = new StorageNodeConfigDelegate(basedir);
+ Configuration config = configDelegate.loadResourceConfiguration();
+
+ assertEquals(config.getSimpleValue("minHeapSize"), "512M", "Failed to load property [minHeapSize]");
+ assertEquals(config.getSimpleValue("maxHeapSize"), "512M", "Failed to load property [maxHepSize]");
+ assertEquals(config.getSimpleValue("heapNewSize"), "128M", "Failed to load property [heapNewSize]");
+ assertEquals(config.getSimpleValue("threadStackSize"), "180k", "Failed to load property [threadStackSize]");
+ }
+
+ @Test
+ public void updateValidConfig() throws Exception {
+ File dir = new File(getClass().getResource(".").toURI());
+ File basedir = new File(dir, getClass().getSimpleName() + "/updateValidConfig");
+ File confDir = new File(basedir, "conf");
+
+ confDir.mkdirs();
+ createDefaultConfig(confDir);
+
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("minHeapSize", "1024M"));
+ config.put(new PropertySimple("maxHeapSize", "1024M"));
+ config.put(new PropertySimple("heapNewSize", "256M"));
+ config.put(new PropertySimple("threadStackSize", "240k"));
+
+ ConfigurationUpdateReport report = new ConfigurationUpdateReport(config);
+
+ StorageNodeConfigDelegate configDelegate = new StorageNodeConfigDelegate(basedir);
+ configDelegate.updateResourceConfiguration(report);
+
+ Properties properties = new Properties();
+ properties.load(new FileInputStream(new File(confDir, "cassandra-jvm.properties")));
+
+ assertEquals(properties.getProperty("heap_min"), "-Xms1024M", "Failed to update property [minHeapSize]");
+ assertEquals(properties.getProperty("heap_max"), "-Xmx1024M", "Failed to update property [maxHeapSize]");
+ assertEquals(properties.getProperty("heap_new"), "-Xmn256M", "Failed to update property [heapNewSize]");
+ assertEquals(properties.getProperty("thread_stack_size"), "-Xss240k",
+ "Failed to update property [threadStackSize]");
+ }
+
+ private void createDefaultConfig(File confDir) throws IOException {
+ Properties properties = new Properties();
+ properties.setProperty("heap_min", "-Xms512M");
+ properties.setProperty("heap_max", "-Xmx512M");
+ properties.setProperty("heap_new", "-Xmn128M");
+ properties.setProperty("thread_stack_size", "-Xss180k");
+
+ properties.store(new FileOutputStream(new File(confDir, "cassandra-jvm.properties")), "");
+ }
+
+}
commit cabe99fea2aa6ecbd2e26f2040ed70951c451dc2
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat Jul 13 16:30:19 2013 -0400
initial support for resource configuration with StorageNodeComponent
This commit introduces initial support for reading JVM options.
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
index cc34fe3..737dded 100644
--- a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
+++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
@@ -25,7 +25,10 @@
package org.rhq.plugins.storage;
+import java.io.File;
+import java.io.FileInputStream;
import java.util.List;
+import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -38,6 +41,8 @@ import org.rhq.core.domain.configuration.Configuration;
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.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.core.util.exception.ThrowableUtil;
@@ -47,7 +52,7 @@ import org.rhq.plugins.cassandra.util.KeyspaceService;
/**
* @author John Sanda
*/
-public class StorageNodeComponent extends CassandraNodeComponent implements OperationFacet {
+public class StorageNodeComponent extends CassandraNodeComponent implements OperationFacet, ConfigurationFacet {
private Log log = LogFactory.getLog(StorageNodeComponent.class);
@@ -56,6 +61,38 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
private static final String RHQ_KEYSPACE = "rhq";
@Override
+ public Configuration loadResourceConfiguration() throws Exception {
+ File confDir = new File(getBasedir(), "conf");
+ File jvmOptsFile = new File(confDir, "cassandra-jvm.properties");
+
+ Properties properties = new Properties();
+ properties.load(new FileInputStream(jvmOptsFile));
+
+ Configuration config = new Configuration();
+
+ String heapMinProp = properties.getProperty("heap_min");
+ String heapMaxProp = properties.getProperty("heap_max");
+ String heapNewProp = properties.getProperty("heap_new");
+ String threadStackSizeProp = properties.getProperty("thread_stack_size");
+
+ config.put(new PropertySimple("minHeapSize", heapMinProp.substring(4)));
+ config.put(new PropertySimple("maxHeapSize", heapMaxProp.substring(4)));
+ config.put(new PropertySimple("heapNewSize", heapNewProp.substring(4)));
+ config.put(new PropertySimple("threadStackSize", threadStackSizeProp.substring(4)));
+
+ return config;
+ }
+
+ private File getBasedir() {
+ Configuration pluginConfig = getResourceContext().getPluginConfiguration();
+ return new File(pluginConfig.getSimpleValue("baseDir"));
+ }
+
+ @Override
+ public void updateResourceConfiguration(ConfigurationUpdateReport configurationUpdateReport) {
+ }
+
+ @Override
public OperationResult invokeOperation(String name, Configuration parameters) throws Exception {
if (name.equals("addNodeMaintenance")) {
return nodeAdded(parameters);
diff --git a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
index f02c8e6..b012f1c 100644
--- a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
@@ -111,6 +111,21 @@
</parameters>
</operation>
+ <resource-configuration>
+ <c:group name="MemorySettings">
+ <c:simple-property name="minHeapSize"
+ description="The minimum heap size. This value will be used with the -Xms JVM option. This
+ should always be the same as Max Heap Size."/>
+ <c:simple-property name="maxHeapSize"
+ description="The maximum heap size. This value will be used with the -Xmx JVM option."/>
+ <c:simple-property name="heapNewSize"
+ description="The size of the new generation portion of the heap. This value will be used with
+ the -Xmn JVM option."/>
+ <c:simple-property name="threadStackSize"
+ description="The thread stack size. This memory is allocated to each thread off heap."/>
+ </c:group>
+ </resource-configuration>
+
<server name="Cassandra Server JVM"
sourcePlugin="JMX" sourceType="JMX Server"
discovery="org.rhq.plugins.jmx.EmbeddedJMXServerDiscoveryComponent"
commit 5d1cb191a0ea22dd4f24379597645aeff3934df7
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat Jul 13 13:09:41 2013 -0400
updating/fixing integration test failure
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/java/org/rhq/cassandra/DeployerITest.java b/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/java/org/rhq/cassandra/DeployerITest.java
index 91a5459..76ff090 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/java/org/rhq/cassandra/DeployerITest.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/java/org/rhq/cassandra/DeployerITest.java
@@ -103,8 +103,8 @@ public class DeployerITest {
}
@Test(dependsOnMethods = "applyConfigChanges")
- public void verifyConfigChangesToCassandraEnv() throws Exception {
- assertFileDeployedAndUpdated("cassandra-env.sh");
+ public void verifyConfigChangesToCassandraJvmOpts() throws Exception {
+ assertFileDeployedAndUpdated("cassandra-jvm.properties");
}
private void assertFileDeployedAndUpdated(String fileName) throws Exception {
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-env.sh b/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-env.sh
deleted file mode 100644
index 62dc0f2..0000000
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-env.sh
+++ /dev/null
@@ -1,247 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-calculate_heap_sizes()
-{
- case "`uname`" in
- Linux)
- system_memory_in_mb=`free -m | awk '/Mem:/ {print $2}'`
- system_cpu_cores=`egrep -c 'processor([[:space:]]+):.*' /proc/cpuinfo`
- ;;
- FreeBSD)
- system_memory_in_bytes=`sysctl hw.physmem | awk '{print $2}'`
- system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024`
- system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'`
- ;;
- SunOS)
- system_memory_in_mb=`prtconf | awk '/Memory size:/ {print $3}'`
- system_cpu_cores=`psrinfo | wc -l`
- ;;
- Darwin)
- system_memory_in_bytes=`sysctl hw.memsize | awk '{print $2}'`
- system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024`
- system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'`
- ;;
- *)
- # assume reasonable defaults for e.g. a modern desktop or
- # cheap server
- system_memory_in_mb="2048"
- system_cpu_cores="2"
- ;;
- esac
-
- # some systems like the raspberry pi don't report cores, use at least 1
- if [ "$system_cpu_cores" -lt "1" ]
- then
- system_cpu_cores="1"
- fi
-
- # set max heap size based on the following
- # max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB))
- # calculate 1/2 ram and cap to 1024MB
- # calculate 1/4 ram and cap to 8192MB
- # pick the max
- half_system_memory_in_mb=`expr $system_memory_in_mb / 2`
- quarter_system_memory_in_mb=`expr $half_system_memory_in_mb / 2`
- if [ "$half_system_memory_in_mb" -gt "1024" ]
- then
- half_system_memory_in_mb="1024"
- fi
- if [ "$quarter_system_memory_in_mb" -gt "8192" ]
- then
- quarter_system_memory_in_mb="8192"
- fi
- if [ "$half_system_memory_in_mb" -gt "$quarter_system_memory_in_mb" ]
- then
- max_heap_size_in_mb="$half_system_memory_in_mb"
- else
- max_heap_size_in_mb="$quarter_system_memory_in_mb"
- fi
- MAX_HEAP_SIZE="${max_heap_size_in_mb}M"
-
- # Young gen: min(max_sensible_per_modern_cpu_core * num_cores, 1/4 * heap size)
- max_sensible_yg_per_core_in_mb="100"
- max_sensible_yg_in_mb=`expr $max_sensible_yg_per_core_in_mb "*" $system_cpu_cores`
-
- desired_yg_in_mb=`expr $max_heap_size_in_mb / 4`
-
- if [ "$desired_yg_in_mb" -gt "$max_sensible_yg_in_mb" ]
- then
- HEAP_NEWSIZE="${max_sensible_yg_in_mb}M"
- else
- HEAP_NEWSIZE="${desired_yg_in_mb}M"
- fi
-}
-
-# Determine the sort of JVM we'll be running on.
-
-java_ver_output=`"${JAVA:-java}" -version 2>&1`
-
-jvmver=`echo "$java_ver_output" | awk -F'"' 'NR==1 {print $2}'`
-JVM_VERSION=${jvmver%_*}
-JVM_PATCH_VERSION=${jvmver#*_}
-
-jvm=`echo "$java_ver_output" | awk 'NR==2 {print $1}'`
-case "$jvm" in
- OpenJDK)
- JVM_VENDOR=OpenJDK
- # this will be "64-Bit" or "32-Bit"
- JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $2}'`
- ;;
- "Java(TM)")
- JVM_VENDOR=Oracle
- # this will be "64-Bit" or "32-Bit"
- JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $3}'`
- ;;
- *)
- # Help fill in other JVM values
- JVM_VENDOR=other
- JVM_ARCH=unknown
- ;;
-esac
-
-
-# Override these to set the amount of memory to allocate to the JVM at
-# start-up. For production use you may wish to adjust this for your
-# environment. MAX_HEAP_SIZE is the total amount of memory dedicated
-# to the Java heap; HEAP_NEWSIZE refers to the size of the young
-# generation. Both MAX_HEAP_SIZE and HEAP_NEWSIZE should be either set
-# or not (if you set one, set the other).
-#
-# The main trade-off for the young generation is that the larger it
-# is, the longer GC pause times will be. The shorter it is, the more
-# expensive GC will be (usually).
-#
-# The example HEAP_NEWSIZE assumes a modern 8-core+ machine for decent pause
-# times. If in doubt, and if you do not particularly want to tweak, go with
-# 100 MB per physical CPU core.
-
-#MAX_HEAP_SIZE="4G"
-#HEAP_NEWSIZE="800M"
-
-if [ "x$MAX_HEAP_SIZE" = "x" ] && [ "x$HEAP_NEWSIZE" = "x" ]; then
- calculate_heap_sizes
-else
- if [ "x$MAX_HEAP_SIZE" = "x" ] || [ "x$HEAP_NEWSIZE" = "x" ]; then
- echo "please set or unset MAX_HEAP_SIZE and HEAP_NEWSIZE in pairs (see cassandra-env.sh)"
- exit 1
- fi
-fi
-
-# Specifies the default port over which Cassandra will be available for
-# JMX connections.
-JMX_PORT="7200"
-
-
-# Here we create the arguments that will get passed to the jvm when
-# starting cassandra.
-
-# enable assertions. disabling this in production will give a modest
-# performance benefit (around 5%).
-JVM_OPTS="$JVM_OPTS -ea"
-
-# add the jamm javaagent
-if [ "$JVM_VENDOR" != "OpenJDK" -o "$JVM_VERSION" \> "1.6.0" ] \
- || [ "$JVM_VERSION" = "1.6.0" -a "$JVM_PATCH_VERSION" -ge 23 ]
-then
- JVM_OPTS="$JVM_OPTS -javaagent:$CASSANDRA_HOME/lib/jamm-0.2.5.jar"
-fi
-
-# enable thread priorities, primarily so we can give periodic tasks
-# a lower priority to avoid interfering with client workload
-JVM_OPTS="$JVM_OPTS -XX:+UseThreadPriorities"
-# allows lowering thread priority without being root. see
-# http://tech.stolsvik.com/2010/01/linux-java-thread-priorities-workaround....
-JVM_OPTS="$JVM_OPTS -XX:ThreadPriorityPolicy=42"
-
-# min and max heap sizes should be set to the same value to avoid
-# stop-the-world GC pauses during resize, and so that we can lock the
-# heap in memory on startup to prevent any of it from being swapped
-# out.
-JVM_OPTS="$JVM_OPTS -Xms${MAX_HEAP_SIZE}"
-JVM_OPTS="$JVM_OPTS -Xmx${MAX_HEAP_SIZE}"
-JVM_OPTS="$JVM_OPTS -Xmn${HEAP_NEWSIZE}"
-JVM_OPTS="$JVM_OPTS -XX:+HeapDumpOnOutOfMemoryError"
-
-# set jvm HeapDumpPath with CASSANDRA_HEAPDUMP_DIR
-if [ "x$CASSANDRA_HEAPDUMP_DIR" != "x" ]; then
- JVM_OPTS="$JVM_OPTS -XX:HeapDumpPath=$CASSANDRA_HEAPDUMP_DIR/cassandra-`date +%s`-pid$$.hprof"
-fi
-
-
-startswith() { [ "${1#$2}" != "$1" ]; }
-
-if [ "`uname`" = "Linux" ] ; then
- # reduce the per-thread stack size to minimize the impact of Thrift
- # thread-per-client. (Best practice is for client connections to
- # be pooled anyway.) Only do so on Linux where it is known to be
- # supported.
- # u34 and greater need 180k
- JVM_OPTS="$JVM_OPTS -Xss180k"
-fi
-echo "xss = $JVM_OPTS"
-
-# GC tuning options
-JVM_OPTS="$JVM_OPTS -XX:+UseParNewGC"
-JVM_OPTS="$JVM_OPTS -XX:+UseConcMarkSweepGC"
-JVM_OPTS="$JVM_OPTS -XX:+CMSParallelRemarkEnabled"
-JVM_OPTS="$JVM_OPTS -XX:SurvivorRatio=8"
-JVM_OPTS="$JVM_OPTS -XX:MaxTenuringThreshold=1"
-JVM_OPTS="$JVM_OPTS -XX:CMSInitiatingOccupancyFraction=75"
-JVM_OPTS="$JVM_OPTS -XX:+UseCMSInitiatingOccupancyOnly"
-JVM_OPTS="$JVM_OPTS -XX:+UseTLAB"
-# note: bash evals '1.7.x' as > '1.7' so this is really a >= 1.7 jvm check
-if [ "$JVM_VERSION" \> "1.7" ] ; then
- JVM_OPTS="$JVM_OPTS -XX:+UseCondCardMark"
-fi
-
-# GC logging options -- uncomment to enable
-# JVM_OPTS="$JVM_OPTS -XX:+PrintGCDetails"
-# JVM_OPTS="$JVM_OPTS -XX:+PrintGCDateStamps"
-# JVM_OPTS="$JVM_OPTS -XX:+PrintHeapAtGC"
-# JVM_OPTS="$JVM_OPTS -XX:+PrintTenuringDistribution"
-# JVM_OPTS="$JVM_OPTS -XX:+PrintGCApplicationStoppedTime"
-# JVM_OPTS="$JVM_OPTS -XX:+PrintPromotionFailure"
-# JVM_OPTS="$JVM_OPTS -XX:PrintFLSStatistics=1"
-# JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/cassandra/gc-`date +%s`.log"
-# If you are using JDK 6u34 7u2 or later you can enable GC log rotation
-# don't stick the date in the log name if rotation is on.
-# JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/cassandra/gc.log"
-# JVM_OPTS="$JVM_OPTS -XX:+UseGCLogFileRotation"
-# JVM_OPTS="$JVM_OPTS -XX:NumberOfGCLogFiles=10"
-# JVM_OPTS="$JVM_OPTS -XX:GCLogFileSize=10M"
-
-# uncomment to have Cassandra JVM listen for remote debuggers/profilers on port 1414
-# JVM_OPTS="$JVM_OPTS -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1414"
-
-# Prefer binding to IPv4 network intefaces (when net.ipv6.bindv6only=1). See
-# http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6342561 (short version:
-# comment out this entry to enable IPv6 support).
-JVM_OPTS="$JVM_OPTS -Djava.net.preferIPv4Stack=true"
-
-# jmx: metrics and administration interface
-#
-# add this if you're having trouble connecting:
-# JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<public name>"
-#
-# see
-# https://blogs.oracle.com/jmxetc/entry/troubleshooting_connection_problems...
-# for more on configuring JMX through firewalls, etc. (Short version:
-# get it working with no firewall first.)
-JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT"
-JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false"
-JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
-JVM_OPTS="$JVM_OPTS $JVM_EXTRA_OPTS"
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-jvm.properties b/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-jvm.properties
new file mode 100644
index 0000000..a90d23c
--- /dev/null
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-jvm.properties
@@ -0,0 +1,112 @@
+enable_assertions="-ea"
+
+# JMX settings
+jmx_port=7200
+
+use_thread_priorities="-XX:+UseThreadPriorities"
+
+thread_priority_policy="-XX:ThreadPriorityPolicy=42"
+
+heap_min=-Xms${MAX_HEAP_SIZE}
+heap_max=-Xmx${MAX_HEAP_SIZE}
+heap_new=-Xmn${HEAP_NEWSIZE}
+
+heap_dump_on_OOMError="-XX:+HeapDumpOnOutOfMemoryError"
+
+heap_dump_dir=""
+
+thread_stack_size=-Xss180k
+
+java_agent=""
+# Enable jamm when running on Java 6 patch version 23 or higher.
+#java_agent="-javaagent:$CASSANDRA_HOME/lib/jamm-0.2.5.jar"
+
+# GC tuning options
+#
+# Uses a parallel version of the young generation copying collector alongside
+# the default collector. This minimizes pauses by using all available CPUs in
+# parallel. The collector is compatible with both the default collector and the
+# Concurrent Mark and Sweep (CMS) collector.
+# This is a parallel collector option.
+use_par_new_gc="-XX:+UseParNewGC"
+
+# Whether parallel remark enabled (only if ParNewGC)
+# This is a parallel collector option.
+cms_parallel_remark_enabled="-XX:+CMSParallelRemarkEnabled"
+
+# Uses the Concurrent Mark and Sweep collector. It is a mostly concurrent
+# collector with a low pause time. It is a good match for multi-core systems.
+use_concur_mark_sweep_gc="-XX:+UseConcMarkSweepGC"
+
+# Ratio of eden/survivor space size. The default value is 8.
+# This is a Garbage First (G1) garbage collector option.
+survivor_ratio="-XX:SurvivorRatio=8"
+
+# Maximum value for tenuring threshold.
+# Young collection tuning option.
+max_tenuring_threshold="-XX:MaxTenuringThreshold=1"
+
+# Percentage CMS generation occupancy to start a CMS collection cycle (A
+# negative value means that CMSTirggerRatio is used).
+# This is a CMS tuning option.
+cms_initiating_occupancy_fraction="-XX:CMSInitiatingOccupancyFraction=75"
+
+# Only use occupancy as a criterion for starting a CMS collection.
+# This is a CMS tuning option.
+use_cms_initiating_occupancy_only="-XX:+UseCMSInitiatingOccupancyOnly"
+
+# Use thread local allocation blocks in young space. Enabled by default.
+# This is a young collection tuning option.
+use_tlab="-XX:+UseTLAB"
+
+#####################
+# GC logging options
+#####################
+# Print more details at garbage collection
+#print_gc_details="-XX:+PrintGCDetails"
+print_gc_details=""
+
+# Prefix logging statements with wall clock time.
+#print_gc_datestamps="XX:+PrintGCDateStamps"
+print_gc_datestamps=""
+
+# Print heap layout before and after each garbage collection.
+#print_heap_at_gc="-XX:+PrintHeapAtGC"
+print_heap_at_gc=""
+
+# Print tenuring age information.
+#print_tenuring_distribution="-XX:+PrintTenuringDistribution"
+print_tenuring_distribution=""
+
+# Print the time the application has been stopped.
+#print_gc_application_stopped_time="-XX:+PrintGCApplicationStoppedTime"
+print_gc_application_stopped_time=""
+
+# Print more details about promotion failures.
+#print_promotion_failure="-XX:+PrintPromotionFailure"
+print_promotion_failure=""
+
+# Print statistics for CMS' FreeListSpace.
+#print_flss_stats="-XX:PrintFLSStatistics=1"
+print_flss_stats=""
+
+# Redirects GC output to file instead of console.
+#gc_log_file="-Xloggc:/var/log/cassandra/gc-`date +%s`.log"
+gc_log_file=""
+
+###############################################################################
+# THE FOLLOWING IS READ ONLY
+# Now build the JVM_OPTS variable. The following variables should NOT be
+# directly modified. Instead update the preceding variables. The following
+# variables build up the JVM_OPTS variable that is read by the cassandra and
+# cassandra.bat scripts.
+###############################################################################
+HEAP_OPTS="${heap_min} ${heap_max} ${heap_new} ${heap_dump_on_OOMError} ${thread_stack_size}"
+
+GC_TUNING_OPTS="${use_par_new_gc} ${use_concur_mark_sweep_gc} ${cms_parallel_remark_enabled} ${survivor_ratio} ${max_tenuring_threshold} ${cms_initiating_occupancy_fraction} ${use_cms_initiating_occupancy_only} ${use_tlab}"
+
+GC_LOGGING_OPTS="${print_gc_details} ${print_gc_datestamps} ${print_heap_at_gc} ${print_tenuring_distribution} ${print_gc_application_stopped_time} ${print_promotion_failure} ${print_flss_stats} ${gc_log_file}"
+
+JMX_OPTS="-Dcom.sun.management.jmxremote.port=${jmx_port} -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
+
+JVM_OPTS="${enable_assertions} ${java_agent} ${use_thread_priorities} ${thread_priority_policy} ${HEAP_OPTS} ${GC_TUNING_OPTS} ${GC_LOGGING_OPTS} ${JMX_OPTS}"
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra.yaml b/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra.yaml
index 82778c9..15d08f2 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra.yaml
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra.yaml
@@ -681,7 +681,7 @@ client_encryption_options:
# can be: all - all traffic is compressed
# dc - traffic between different datacenters is compressed
# none - nothing is compressed.
-internode_compression: all
+internode_compression: none
# Enable or disable tcp_nodelay for inter-dc communication.
# Disabling it will result in larger (but fewer) network packets being sent,
commit bf78527f20bfeb95fe6040ae5f744bf633d08140
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat Jul 13 12:46:07 2013 -0400
remove usage of cassandra-env.sh for cassandra start up
We want to manage C* heap settings and other options/arguments passed to the
C* JVM command line. On linux, the JVM options are set using the JVM_OPTS
shell script variable which is done in cassandra-env.sh. The cassandra-env.sh
script however does not lend itself well to our structured, resource
configuration. The JVM_OPTS variable is now built up in
cassandra-jvm.properties which is a java properties file that also uses legal
shell syntax. The file is sourced from the cassandra start script. This paves
the way for resource configuration of the Cassandra JVM options.
I am also hoping that we can do something similar for Windows where we can use
cassandra-jvm.properties. This would substantially reduce the need for platform
specific code in the storage plugin.
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml b/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml
index 0b015b4..42f6c8b 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml
@@ -167,6 +167,9 @@
<copy file="${settings.localRepository}/org/xerial/snappy/snappy-java/${cassandra.snappy.version}/snappy-java-${cassandra.snappy.version}.jar"
todir="${cassandra.dir}/lib"/>
<move file="${project.build.outputDirectory}/cassandra/conf" todir="${cassandra.dir}"/>
+ <delete file="${cassandra.dir}/bin/cassandra"/>
+ <move file="${project.build.outputDirectory}/cassandra/bin/cassandra" todir="${cassandra.dir}/bin"/>
+ <delete dir="${project.build.outputDirectory}/cassandra"/>
<delete dir="${cassandra.dir}/javadoc"/>
<zip basedir="${cassandra.dir}" destfile="${cassandra.distro.zip}"/>
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/bin/cassandra b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/bin/cassandra
new file mode 100755
index 0000000..742d9c0
--- /dev/null
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/bin/cassandra
@@ -0,0 +1,193 @@
+#!/bin/sh
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# OPTIONS:
+# -f: start in foreground
+# -p <filename>: log the pid to a file (useful to kill it later)
+# -v: print version string and exit
+
+# CONTROLLING STARTUP:
+#
+# This script relies on few environment variables to determine startup
+# behavior, those variables are:
+#
+# CLASSPATH -- A Java classpath containing everything necessary to run.
+# JVM_OPTS -- Additional arguments to the JVM for heap size, etc
+# CASSANDRA_CONF -- Directory containing Cassandra configuration files.
+#
+# As a convenience, a fragment of shell is sourced in order to set one or
+# more of these variables. This so-called `include' can be placed in a
+# number of locations and will be searched for in order. The lowest
+# priority search path is the same directory as the startup script, and
+# since this is the location of the sample in the project tree, it should
+# almost work Out Of The Box.
+#
+# Any serious use-case though will likely require customization of the
+# include. For production installations, it is recommended that you copy
+# the sample to one of /usr/share/cassandra/cassandra.in.sh,
+# /usr/local/share/cassandra/cassandra.in.sh, or
+# /opt/cassandra/cassandra.in.sh and make your modifications there.
+#
+# Another option is to specify the full path to the include file in the
+# environment. For example:
+#
+# $ CASSANDRA_INCLUDE=/path/to/in.sh cassandra -p /var/run/cass.pid
+#
+# Note: This is particularly handy for running multiple instances on a
+# single installation, or for quick tests.
+#
+# Finally, developers and enthusiasts who frequently run from an SVN
+# checkout, and do not want to locally modify bin/cassandra.in.sh, can put
+# a customized include file at ~/.cassandra.in.sh.
+#
+# If you would rather configure startup entirely from the environment, you
+# can disable the include by exporting an empty CASSANDRA_INCLUDE, or by
+# ensuring that no include files exist in the aforementioned search list.
+# Be aware that you will be entirely responsible for populating the needed
+# environment variables.
+
+# NB: Developers should be aware that this script should remain compatible with
+# POSIX sh and Solaris sh. This means, in particular, no $(( )) and no $( ).
+
+# If an include wasn't specified in the environment, then search for one...
+if [ "x$CASSANDRA_INCLUDE" = "x" ]; then
+ # Locations (in order) to use when searching for an include file.
+ for include in /usr/share/cassandra/cassandra.in.sh \
+ /usr/local/share/cassandra/cassandra.in.sh \
+ /opt/cassandra/cassandra.in.sh \
+ "$HOME/.cassandra.in.sh" \
+ "`dirname $0`/cassandra.in.sh"; do
+ if [ -r "$include" ]; then
+ . "$include"
+ break
+ fi
+ done
+# ...otherwise, source the specified include.
+elif [ -r "$CASSANDRA_INCLUDE" ]; then
+ . "$CASSANDRA_INCLUDE"
+fi
+
+# Use JAVA_HOME if set, otherwise look for java in PATH
+if [ -n "$JAVA_HOME" ]; then
+ JAVA="$JAVA_HOME/bin/java"
+else
+ JAVA=java
+fi
+
+# If numactl is available, use it. For Cassandra, the priority is to
+# avoid disk I/O. Even for the purpose of CPU efficiency, we don't
+# really have CPU<->data affinity anyway. Also, empirically test that numactl
+# works before trying to use it (CASSANDRA-3245).
+NUMACTL_ARGS="--interleave=all"
+if which numactl >/dev/null 2>/dev/null && numactl $NUMACTL_ARGS ls / >/dev/null 2>/dev/null
+then
+ NUMACTL="numactl $NUMACTL_ARGS"
+else
+ NUMACTL=""
+fi
+
+if [ -z "$CASSANDRA_CONF" -o -z "$CLASSPATH" ]; then
+ echo "You must set the CASSANDRA_CONF and CLASSPATH vars" >&2
+ exit 1
+fi
+
+if [ -f "$CASSANDRA_CONF/cassandra-env.sh" ]; then
+ #. "$CASSANDRA_CONF/cassandra-env.sh"
+ . "$CASSANDRA_CONF/cassandra-jvm.properties"
+fi
+
+# Special-case path variables.
+case "`uname`" in
+ CYGWIN*)
+ CLASSPATH=`cygpath -p -w "$CLASSPATH"`
+ CASSANDRA_CONF=`cygpath -p -w "$CASSANDRA_CONF"`
+ ;;
+esac
+
+launch_service()
+{
+ pidpath=$1
+ foreground=$2
+ props=$3
+ class=$4
+ cassandra_parms="-Dlog4j.configuration=log4j-server.properties -Dlog4j.defaultInitOverride=true"
+
+ if [ "x$pidpath" != "x" ]; then
+ cassandra_parms="$cassandra_parms -Dcassandra-pidfile=$pidpath"
+ fi
+
+ # The cassandra-foreground option will tell CassandraDaemon not
+ # to close stdout/stderr, but it's up to us not to background.
+ if [ "x$foreground" != "x" ]; then
+ cassandra_parms="$cassandra_parms -Dcassandra-foreground=yes"
+ exec $NUMACTL "$JAVA" $JVM_OPTS $cassandra_parms -cp "$CLASSPATH" $props "$class"
+ # Startup CassandraDaemon, background it, and write the pid.
+ else
+ exec $NUMACTL "$JAVA" $JVM_OPTS $cassandra_parms -cp "$CLASSPATH" $props "$class" <&- &
+ [ ! -z "$pidpath" ] && printf "%d" $! > "$pidpath"
+ true
+ fi
+
+ return $?
+}
+
+# Parse any command line options.
+args=`getopt vfhp:bD: "$@"`
+eval set -- "$args"
+
+classname="org.apache.cassandra.service.CassandraDaemon"
+
+while true; do
+ case "$1" in
+ -p)
+ pidfile="$2"
+ shift 2
+ ;;
+ -f)
+ foreground="yes"
+ shift
+ ;;
+ -h)
+ echo "Usage: $0 [-f] [-h] [-p pidfile]"
+ exit 0
+ ;;
+ -v)
+ "$JAVA" -cp "$CLASSPATH" org.apache.cassandra.tools.GetVersion
+ exit 0
+ ;;
+ -D)
+ properties="$properties -D$2"
+ shift 2
+ ;;
+ --)
+ shift
+ break
+ ;;
+ *)
+ echo "Error parsing arguments!" >&2
+ exit 1
+ ;;
+ esac
+done
+
+# Start up the service
+launch_service "$pidfile" "$foreground" "$properties" "$classname"
+
+exit $?
+
+# vi:ai sw=4 ts=4 tw=0 et
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/cassandra-jvm.properties b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/cassandra-jvm.properties
new file mode 100644
index 0000000..612c65e
--- /dev/null
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/cassandra-jvm.properties
@@ -0,0 +1,112 @@
+enable_assertions="-ea"
+
+# JMX settings
+jmx_port="7299"
+
+use_thread_priorities="-XX:+UseThreadPriorities"
+
+thread_priority_policy="-XX:ThreadPriorityPolicy=42"
+
+heap_min="-Xms256M"
+heap_max="-Xms256M"
+heap_new="-Xmn64M"
+
+heap_dump_on_OOMError="-XX:+HeapDumpOnOutOfMemoryError"
+
+heap_dump_dir=""
+
+thread_stack_size="-Xss180k"
+
+java_agent=""
+# Enable jamm when running on Java 6 patch version 23 or higher.
+#java_agent="-javaagent:$CASSANDRA_HOME/lib/jamm-0.2.5.jar"
+
+# GC tuning options
+#
+# Uses a parallel version of the young generation copying collector alongside
+# the default collector. This minimizes pauses by using all available CPUs in
+# parallel. The collector is compatible with both the default collector and the
+# Concurrent Mark and Sweep (CMS) collector.
+# This is a parallel collector option.
+use_par_new_gc="-XX:+UseParNewGC"
+
+# Whether parallel remark enabled (only if ParNewGC)
+# This is a parallel collector option.
+cms_parallel_remark_enabled="-XX:+CMSParallelRemarkEnabled"
+
+# Uses the Concurrent Mark and Sweep collector. It is a mostly concurrent
+# collector with a low pause time. It is a good match for multi-core systems.
+use_concur_mark_sweep_gc="-XX:+UseConcMarkSweepGC"
+
+# Ratio of eden/survivor space size. The default value is 8.
+# This is a Garbage First (G1) garbage collector option.
+survivor_ratio="-XX:SurvivorRatio=8"
+
+# Maximum value for tenuring threshold.
+# Young collection tuning option.
+max_tenuring_threshold="-XX:MaxTenuringThreshold=1"
+
+# Percentage CMS generation occupancy to start a CMS collection cycle (A
+# negative value means that CMSTirggerRatio is used).
+# This is a CMS tuning option.
+cms_initiating_occupancy_fraction="-XX:CMSInitiatingOccupancyFraction=75"
+
+# Only use occupancy as a criterion for starting a CMS collection.
+# This is a CMS tuning option.
+use_cms_initiating_occupancy_only="-XX:+UseCMSInitiatingOccupancyOnly"
+
+# Use thread local allocation blocks in young space. Enabled by default.
+# This is a young collection tuning option.
+use_tlab="-XX:+UseTLAB"
+
+#####################
+# GC logging options
+#####################
+# Print more details at garbage collection
+#print_gc_details="-XX:+PrintGCDetails"
+print_gc_details=""
+
+# Prefix logging statements with wall clock time.
+#print_gc_datestamps="XX:+PrintGCDateStamps"
+print_gc_datestamps=""
+
+# Print heap layout before and after each garbage collection.
+#print_heap_at_gc="-XX:+PrintHeapAtGC"
+print_heap_at_gc=""
+
+# Print tenuring age information.
+#print_tenuring_distribution="-XX:+PrintTenuringDistribution"
+print_tenuring_distribution=""
+
+# Print the time the application has been stopped.
+#print_gc_application_stopped_time="-XX:+PrintGCApplicationStoppedTime"
+print_gc_application_stopped_time=""
+
+# Print more details about promotion failures.
+#print_promotion_failure="-XX:+PrintPromotionFailure"
+print_promotion_failure=""
+
+# Print statistics for CMS' FreeListSpace.
+#print_flss_stats="-XX:PrintFLSStatistics=1"
+print_flss_stats=""
+
+# Redirects GC output to file instead of console.
+#gc_log_file="-Xloggc:/var/log/cassandra/gc-`date +%s`.log"
+gc_log_file=""
+
+###############################################################################
+# THE FOLLOWING IS READ ONLY
+# Now build the JVM_OPTS variable. The following variables should NOT be
+# directly modified. Instead update the preceding variables. The following
+# variables build up the JVM_OPTS variable that is read by the cassandra and
+# cassandra.bat scripts.
+###############################################################################
+HEAP_OPTS="${heap_min} ${heap_max} ${heap_new} ${heap_dump_on_OOMError} ${thread_stack_size}"
+
+GC_TUNING_OPTS="${use_par_new_gc} ${use_concur_mark_sweep_gc} ${cms_parallel_remark_enabled} ${survivor_ratio} ${max_tenuring_threshold} ${cms_initiating_occupancy_fraction} ${use_cms_initiating_occupancy_only} ${use_tlab}"
+
+GC_LOGGING_OPTS="${print_gc_details} ${print_gc_datestamps} ${print_heap_at_gc} ${print_tenuring_distribution} ${print_gc_application_stopped_time} ${print_promotion_failure} ${print_flss_stats} ${gc_log_file}"
+
+JMX_OPTS="-Dcom.sun.management.jmxremote.port=${jmx_port} -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
+
+JVM_OPTS="${enable_assertions} ${java_agent} ${use_thread_priorities} ${thread_priority_policy} ${HEAP_OPTS} ${GC_TUNING_OPTS} ${GC_LOGGING_OPTS} ${JMX_OPTS}"
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
index e85813d..1e31e14 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
@@ -31,10 +31,12 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
+import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.core.util.PropertiesFileUpdate;
import org.rhq.core.util.TokenReplacingReader;
import org.rhq.core.util.ZipUtil;
import org.rhq.core.util.stream.StreamUtil;
@@ -83,10 +85,13 @@ public class Deployer {
applyConfigChanges(confDir, "cassandra.yaml", tokens);
applyConfigChanges(confDir, "log4j-server.properties", tokens);
- applyConfigChanges(confDir, "cassandra-env.sh", tokens);
+ applyChangesToCassandraJvmProps(confDir, deploymentOptions);
+// applyConfigChanges(confDir, "cassandra-env.sh", tokens);
}
- private void applyConfigChanges(File confDir, String fileName, Map<String, String> tokens) throws DeploymentException {
+ private void applyConfigChanges(File confDir, String fileName, Map<String, String> tokens)
+ throws DeploymentException {
+
File filteredFile = new File(confDir, fileName);
try {
if (log.isInfoEnabled()) {
@@ -104,6 +109,29 @@ public class Deployer {
}
}
+ private void applyChangesToCassandraJvmProps(File confDir, DeploymentOptions deploymentOptions)
+ throws DeploymentException {
+
+ File jvmPropsFile = new File(confDir, "cassandra-jvm.properties");
+ try {
+ log.info("Applying configuration changes to " + jvmPropsFile);
+
+ PropertiesFileUpdate propertiesUpdater = new PropertiesFileUpdate(jvmPropsFile.getAbsolutePath());
+ Properties properties = propertiesUpdater.loadExistingProperties();
+
+ properties.setProperty("heap_min", "-Xms" + deploymentOptions.getHeapSize());
+ properties.setProperty("heap_max", "-Xmx" + deploymentOptions.getHeapSize());
+ properties.setProperty("heap_new", "-Xmn" + deploymentOptions.getHeapNewSize());
+ properties.setProperty("thread_stack_size", "-Xss" + deploymentOptions.getStackSize());
+ properties.setProperty("jmx_port", deploymentOptions.getJmxPort().toString());
+
+ propertiesUpdater.update(properties);
+ } catch (IOException e) {
+ log.error("An error occurred while updating " + jvmPropsFile, e);
+ throw new DeploymentException("An error occurred while updating " + jvmPropsFile, e);
+ }
+ }
+
public void updateFilePerms() {
File deployDir = new File(deploymentOptions.getBasedir());
File binDir = new File(deployDir, "bin");
commit 7185fb3fbaf98dde194872657c7362134d342c10
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat Jul 13 10:08:22 2013 -0400
remove obsolete files that are no longer used
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/deploy.xml b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/deploy.xml
deleted file mode 100644
index 19d5647..0000000
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/deploy.xml
+++ /dev/null
@@ -1,221 +0,0 @@
-<project name="rhq_cassandra_bundle"
- default="main"
- xmlns:rhq="antlib:org.rhq.bundle">
- <rhq:bundle name="${rhq.cassandra.bundle.name}"
- version="${rhq.cassandra.bundle.version}"
- description="A bundle for deploying RHQ Cassandra nodes.">
-
- <!--
- NOTE: the name attribute of an rhq:input-property does not support using a dash.
- There is a convention where dashes are used in property names in rhq properties files
- in the trailing part of a property name. If an rhq:input-property has a corresponding
- property in cassandra.properties and contains a dash, the dash will be changed to an
- underscore in this file.
- -->
-
- <rhq:input-property name="cluster.name"
- description="The name of the cluster. This is used to prevent machines in one logical cluster from joining another"
- required="true"
- defaultValue="rhqdev"
- type="string"/>
-
- <rhq:input-property name="cluster.dir"
- description="The directory in which Cassandra nodes will be installed"
- required="true"
- defaultValue=""
- type="string"/>
-
- <rhq:input-property name="data.dir"
- description="The directory where Cassandra should store data files."
- required="true"
- defaultValue="data"
- type="string"/>
-
- <rhq:input-property name="commitlog.dir"
- description="The directory where Cassandra stores its commit logs."
- required="true"
- defaultValue="commit_log"
- type="string"/>
-
- <rhq:input-property name="saved.caches.dir"
- description="The directory where Cassandra stores saved caches."
- required="true"
- defaultValue="saved_caches"
- type="string"/>
-
- <rhq:input-property name="log.dir"
- description="The directory where Cassandra stores log files."
- required="true"
- defaultValue="logs"
- type="string"/>
-
- <rhq:input-property name="rhq.cassandra.log.file.name"
- description="The name of the log file to which Cassandra writes."
- required="true"
- defaultValue="rhq-storage-node.log"
- type="string"/>
-
- <rhq:input-property name="logging.level"
- description="The log4j logging level to use."
- required="false"
- defaultValue="DEBUG"
- type="string"/>
-
- <rhq:input-property name="seeds"
- description="A comma-delimited list of IP addresses/host names that are deemed contact points. Cassandra nodes use this list of hosts to find each other and learn the topology of the ring. If you are running a local development cluster, be sure to have aliases set up for localhost."
- required="false"
- defaultValue="127.0.0.1"
- type="string"/>
-
- <rhq:input-property name="rhq.cassandra.num_tokens"
- description="Defines the number of tokens randomly assigned to a node on the ring. The more tokens, relative to other nodes, the larger the proportion of data that this node will store. You probably want all nodes to have the same number of tokens assuming they have equal hardware capability."
- required="false"
- defaultValue="256"
- type="string"/>
-
- <rhq:input-property name="jmx.port"
- description="The port over which Cassandra listens for JMX connections. Each node should be assigned a unique port."
- required="false"
- defaultValue="7200"
- type="string"/>
-
- <rhq:input-property name="rhq.cassandra.storage.port"
- description="The port used for inter-node communication."
- required="false"
- defaultValue="7000"
- type="string"/>
-
- <rhq:input-property name="rhq.cassandra.ssl.storage.port"
- description="The port used for encrypted inter-node communication."
- required="false"
- defaultValue="7001"
- type="string"/>
-
- <rhq:input-property name="listen.address"
- description="Address used for inter-node communication. Defaults to value of hostname property."
- required="true"
- defaultValue=""
- type="string"/>
-
- <rhq:input-property name="rpc.address"
- description="Address used for Thrift RPC client communication. Defaults to value of hostname property."
- required="true"
- defaultValue=""
- type="string"/>
-
- <rhq:input-property name="cassandra.ring.delay.property"
- required="false"
- defaultValue=""
- type="string"/>
-
- <rhq:input-property name="cassandra.ring.delay"
- description="When a node initializes it contacts a seed and then sleeps for RING_DELAY (milliseconds) to learn about other nodes in the cluster. Cassandra uses a default value of 30 seconds."
- required="false"
- defaultValue=""
- type="string"/>
-
- <rhq:input-property name="rhq.cassandra.native_transport_max_threads"
- description="The maximum number of threads handling native CQL requests."
- required="false"
- defaultValue="64"
- type="integer"/>
-
- <rhq:input-property name="rhq.cassandra.native_transport_port"
- description="The port for the CQL native transport to listen for clients on."
- required="false"
- defaultValue="9042"
- type="integer"/>
-
- <rhq:input-property name="rhq.cassandra.rpc_port"
- description="The port to listen for Thrift clients on."
- required="false"
- defaultValue="9160"
- type="integer"/>
-
- <rhq:input-property name="rhq.cassandra.authenticator"
- description="A class that performs authentication. The value should be a fully qualified class name and implement IAuthenticator."
- required="false"
- defaultValue="org.rhq.cassandra.auth.SimpleAuthenticator"
- type="string"/>
-
- <rhq:input-property name="rhq.cassandra.authorizer"
- description="A class that performs authorization. Used to limit/provide permissions. The value should be a fully qualified class name and implement IAuthorizer."
- required="false"
- defaultValue="org.rhq.cassandra.auth.SimpleAuthorizer"
- type="string"/>
-
- <rhq:input-property name="rhq.cassandra.password.properties.file"
- description="The location of the password properties file used by SimpleAuthenticator. If a relative path is specified, its location is resolved relative to Cassandra's bin directory."
- required="false"
- defaultValue="./../conf/passwd.properties"
- type="file"/>
-
- <rhq:input-property name="rhq.cassandra.access.properties.file"
- description="The location of the authorization properties file used by SimpleAuthority. If a relative path is specified, its location is resolved relative to Cassandra's bin directory."
- required="false"
- defaultValue="./../conf/access.properties"
- type="file"/>
-
- <rhq:input-property name="rhq.cassandra.username"
- description="The username with which to authenticate requests to Cassandra."
- required="true"
- type="string"/>
-
- <rhq:input-property name="rhq.cassandra.password"
- description="The password with which to authenticate requests to Cassandra."
- required="true"
- type="string"/>
-
- <rhq:input-property name="rhq.cassandra.max.heap.size"
- required="true"
- defaultValue="${MAX_HEAP_SIZE}"/>
-
- <rhq:input-property name="rhq.cassandra.heap.new.size"
- required="true"
- defaultValue="${HEAP_NEWSIZE}"/>
-
- <rhq:deployment-unit name="cassandra" preinstallTarget="pre-install" postinstallTarget="post-install">
-<!--
- <rhq:file name="dbsetup.script" destinationFile="scripts/dbsetup.script" replace="true"/>
--->
- <rhq:archive name="cassandra.zip">
- <rhq:replace>
- <rhq:fileset dir="conf">
- <include name="cassandra.yaml"/>
- </rhq:fileset>
- <rhq:fileset dir="conf">
- <include name="cassandra-env.sh"/>
- </rhq:fileset>
- <rhq:fileset dir="conf">
- <include name="log4j-server.properties"/>
- </rhq:fileset>
- <rhq:fileset dir="conf">
- <include name="passwd.properties"/>
- </rhq:fileset>
-<!--
- <rhq:fileset dir="scripts">
- <include name="dbsetup.script"/>
- </rhq:fileset>
--->
- </rhq:replace>
- </rhq:archive>
- </rhq:deployment-unit>
- </rhq:bundle>
-
- <target name="main"/>
-
- <target name="pre-install">
- <mkdir dir="${cluster.dir}"/>
-
- </target>
-
- <target name="post-install">
- <property name="bin.dir" value="${rhq.deploy.dir}/bin"/>
-
- <chmod file="${bin.dir}/cassandra" perm="+x"/>
- <chmod file="${bin.dir}/cqlsh" perm="+x"/>
- <chmod file="${bin.dir}/cassandra-cli" perm="+x"/>
- <chmod file="${bin.dir}/nodetool" perm="+x"/>
- </target>
-
-</project>
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/cassandra/cli/dbsetup.script b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/cassandra/cli/dbsetup.script
deleted file mode 100644
index 73bc2a7..0000000
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/cassandra/cli/dbsetup.script
+++ /dev/null
@@ -1,40 +0,0 @@
-create keyspace rhq
- with placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy' and
- strategy_options = {replication_factor:1};
-
-use rhq;
-
-create column family raw_metrics
- with comparator = DateType and
- default_validation_class = DoubleType and
- key_validation_class = Int32Type;
-
-create column family one_hour_metric_data
- with comparator = 'CompositeType(DateType, Int32Type)' and
- default_validation_class = DoubleType and
- key_validation_class = Int32Type;
-
-create column family six_hour_metric_data
- with comparator = 'CompositeType(DateType, Int32Type)' and
- default_validation_class = DoubleType and
- key_validation_class = Int32Type;
-
-create column family twenty_four_hour_metric_data
- with comparator = 'CompositeType(DateType, Int32Type)' and
- default_validation_class = DoubleType and
- key_validation_class = Int32Type;
-
-create column family metrics_work_queue
- with comparator = 'CompositeType(DateType, Int32Type)' and
- default_validation_class = Int32Type and
- key_validation_class = UTF8Type;
-
-create column family resource_traits
- with comparator = 'CompositeType(DateType, Int32Type, Int32Type, UTF8Type, UTF8Type)' and
- default_validation_class = UTF8Type and
- key_validation_class = Int32Type;
-
-create column family traits
- with comparator = DateType and
- default_validation_class = UTF8Type and
- key_validation_class = Int32Type;
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/cassandra/cql/create_keyspace.cql b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/cassandra/cql/create_keyspace.cql
deleted file mode 100644
index 9df13a0..0000000
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/cassandra/cql/create_keyspace.cql
+++ /dev/null
@@ -1 +0,0 @@
-CREATE KEYSPACE rhq WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/cassandra/cql/dbsetup.cql b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/cassandra/cql/dbsetup.cql
deleted file mode 100644
index 189b35b..0000000
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/cassandra/cql/dbsetup.cql
+++ /dev/null
@@ -1,42 +0,0 @@
-CREATE KEYSPACE rhq WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
-
-USE rhq;
-
-CREATE TABLE raw_metrics (
- schedule_id int,
- time timestamp,
- value double,
- PRIMARY KEY (schedule_id, time)
-);
-
-CREATE TABLE one_hour_metrics (
- schedule_id int,
- time timestamp,
- type int,
- value double,
- PRIMARY KEY (schedule_id, time, type)
-);
-
-CREATE TABLE six_hour_metrics (
- schedule_id int,
- time timestamp,
- type int,
- value double,
- PRIMARY KEY (schedule_id, time, type)
-);
-
-CREATE TABLE twenty_four_hour_metrics (
- schedule_id int,
- time timestamp,
- type int,
- value double,
- PRIMARY KEY (schedule_id, time, type)
-);
-
-CREATE TABLE metrics_index (
- bucket varchar,
- time timestamp,
- schedule_id int,
- null_col boolean,
- PRIMARY KEY (bucket, time, schedule_id)
-);
commit f9f3f712f702058e0d6ef5f1b99dcbe2162e63a9
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Jul 12 11:09:16 2013 +0200
Downgrade to 1.2.3, as the jboss nexus repo does not find 1.2.5. It is more recent than 1.1.1 anyway
diff --git a/pom.xml b/pom.xml
index 6b1d75f..c5cf5a7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -151,7 +151,7 @@
<augeas.zip.mask>*-${augeas.classifier}.zip</augeas.zip.mask>
<ant.contrib.version>1.0b3</ant.contrib.version>
<freemarker.version>2.3.18</freemarker.version>
- <swagger-annotations.version>1.2.5</swagger-annotations.version>
+ <swagger-annotations.version>1.2.3</swagger-annotations.version>
<powermock.version>1.4.12</powermock.version>
<arquillian.version>1.0.3.Final</arquillian.version>
<arquillian.jboss.container.version>7.2.0.Final</arquillian.jboss.container.version>
commit c33f3226056333a1aaaa303306d1ce6dadcefe47
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Jul 12 10:35:44 2013 +0200
Bump swagger annotations version to a stable version and remove the snapshot repo. Thanks gaYak for reminding me.
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index 2127930..7c236c7 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -439,7 +439,7 @@
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-annotations_2.9.1</artifactId>
- <version>1.1.1-SNAPSHOT</version>
+ <version>${swagger-annotations.version}</version>
<scope>provided</scope>
</dependency>
@@ -686,15 +686,6 @@
</build>
- <repositories>
- <repository>
- <!-- TODO change when the annotations are published. This is temporary for the swagger annotations for REST-docu -->
- <id>sonatype-oss-snapshot</id>
- <name>Sonatype OSS Snapshot repository</name>
- <url>https://oss.sonatype.org/content/repositories/snapshots</url>
- </repository>
-
- </repositories>
<profiles>
diff --git a/modules/helpers/rest-docs-generator/pom.xml b/modules/helpers/rest-docs-generator/pom.xml
index 9cc4fa1..c672abf 100644
--- a/modules/helpers/rest-docs-generator/pom.xml
+++ b/modules/helpers/rest-docs-generator/pom.xml
@@ -122,16 +122,6 @@
</plugins>
</build>
- <repositories>
- <repository>
- <!-- TODO temporary for the swagger annotations -->
- <id>sonatype-oss-snapshot</id>
- <name>Sonatype OSS Snapshot repository</name>
- <url>https://oss.sonatype.org/content/repositories/snapshots</url>
- </repository>
-
- </repositories>
-
<dependencies>
<dependency>
@@ -149,7 +139,7 @@
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-annotations_2.9.1</artifactId>
- <version>1.1.1-SNAPSHOT</version>
+ <version>${swagger-annotations.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
diff --git a/pom.xml b/pom.xml
index 26703d1..6b1d75f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -151,6 +151,7 @@
<augeas.zip.mask>*-${augeas.classifier}.zip</augeas.zip.mask>
<ant.contrib.version>1.0b3</ant.contrib.version>
<freemarker.version>2.3.18</freemarker.version>
+ <swagger-annotations.version>1.2.5</swagger-annotations.version>
<powermock.version>1.4.12</powermock.version>
<arquillian.version>1.0.3.Final</arquillian.version>
<arquillian.jboss.container.version>7.2.0.Final</arquillian.jboss.container.version>
@@ -901,7 +902,7 @@
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
-
+
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
commit 524d1b66879fa6d20788505e1c43c0e046e06e48
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Jul 12 00:58:48 2013 -0500
Initial implementation for fetching all the alerts triggered for Storage Nodes resource and sub-sources.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
index 9d073ee..fa51fe1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
@@ -28,8 +28,10 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Queue;
import javax.ejb.EJB;
import javax.ejb.Stateless;
@@ -43,6 +45,7 @@ import org.quartz.JobDataMap;
import org.quartz.SimpleTrigger;
import org.quartz.Trigger;
+import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.cloud.Server;
@@ -51,6 +54,7 @@ import org.rhq.core.domain.cloud.StorageNode.OperationMode;
import org.rhq.core.domain.cloud.StorageNodeLoadComposite;
import org.rhq.core.domain.common.JobTrigger;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.criteria.AlertCriteria;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.criteria.StorageNodeCriteria;
import org.rhq.core.domain.measurement.MeasurementAggregate;
@@ -59,8 +63,11 @@ import org.rhq.core.domain.operation.bean.GroupOperationSchedule;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.server.RHQConstants;
+import org.rhq.enterprise.server.alert.AlertManagerLocal;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.RequiredPermission;
import org.rhq.enterprise.server.authz.RequiredPermissions;
@@ -110,6 +117,9 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
@EJB
private OperationManagerLocal operationManager;
+ @EJB
+ private AlertManagerLocal alertManager;
+
@Override
public void linkResource(Resource resource) {
List<StorageNode> storageNodes = this.getStorageNodes();
@@ -427,7 +437,7 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
}
entityManager.flush();
}
-
+
private StorageNodeLoadComposite.MeasurementAggregateWithUnits getMeasurementAggregateWithUnits(Subject subject,
int schedId, MeasurementUnits units, long beginTime, long endTime) {
MeasurementAggregate measurementAggregate = measurementManager.getAggregate(subject, schedId, beginTime,
@@ -472,4 +482,81 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
operationManager.scheduleGroupOperation(subjectManager.getOverlord(), schedule);
}
-}
+
+ @Override
+ public PageList<Alert> findNotAcknowledgedStorageNodeAlerts(Subject subject) {
+ return findStorageNodeAlerts(subject, false);
+ }
+
+ @Override
+ public PageList<Alert> findAllStorageNodeAlerts(Subject subject) {
+ return findStorageNodeAlerts(subject, true);
+ }
+
+ /**
+ * Find the set of alerts related to Storage Node resources and sub-resources.
+ *
+ * @param subject subject
+ * @param allAlerts if [true] then return all alerts; if [false] then return only alerts that are not acknowledged
+ * @return alerts
+ */
+ private PageList<Alert> findStorageNodeAlerts(Subject subject, boolean allAlerts) {
+ Integer[] resouceIdsWithAlertDefinitions = findResourcesWithAlertDefinitions();
+ PageList<Alert> alerts = new PageList<Alert>();
+
+ if( resouceIdsWithAlertDefinitions != null && resouceIdsWithAlertDefinitions.length != 0 ){
+ AlertCriteria criteria = new AlertCriteria();
+ criteria.setPageControl(PageControl.getUnlimitedInstance());
+ criteria.addFilterResourceIds(resouceIdsWithAlertDefinitions);
+ criteria.addSortCtime(PageOrdering.DESC);
+
+ alerts = alertManager.findAlertsByCriteria(subject, criteria);
+
+ if (!allAlerts) {
+ //select on alerts that are not acknowledge
+ PageList<Alert> trimmedAlerts = new PageList<Alert>();
+ for (Alert alert : alerts) {
+ if (alert.getAcknowledgeTime() == null || alert.getAcknowledgeTime() <= 0) {
+ trimmedAlerts.add(alert);
+ }
+ }
+
+ alerts = trimmedAlerts;
+ }
+ }
+
+ return alerts;
+ }
+
+ /**
+ * Return resource Ids for all resources and sub-resources of Storage Nodes that
+ * have alert definitions. This will be used by the resource criteria to find
+ * all alerts triggered for storage nodes.
+ *
+ * @return
+ */
+ private Integer[] findResourcesWithAlertDefinitions() {
+ List<Integer> resourceIdsWithAlertDefinitions = new ArrayList<Integer>();
+ List<StorageNode> test2 = getStorageNodes();
+
+ Queue<Resource> unvisitedResources = new LinkedList<Resource>();
+ for (StorageNode node : test2) {
+ if (node.getResource() != null) {
+ unvisitedResources.add(node.getResource());
+ }
+ }
+
+ while(!unvisitedResources.isEmpty()){
+ Resource resource = unvisitedResources.poll();
+ if (resource.getAlertDefinitions() != null) {
+ resourceIdsWithAlertDefinitions.add(resource.getId());
+ }
+
+ for(Resource child: resource.getChildResources()){
+ unvisitedResources.add(child);
+ }
+ }
+
+ return resourceIdsWithAlertDefinitions.toArray(new Integer[resourceIdsWithAlertDefinitions.size()]);
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
index 5c3f092..a9b2514 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
@@ -22,6 +22,7 @@ import java.util.List;
import javax.ejb.Local;
+import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.cloud.StorageNode;
import org.rhq.core.domain.cloud.StorageNodeLoadComposite;
@@ -65,13 +66,29 @@ public interface StorageNodeManagerLocal {
* @return list of nodes
*/
PageList<StorageNode> findStorageNodesByCriteria(Subject subject, StorageNodeCriteria criteria);
-
+
+ /**
+ * Fetches the list of Storage Node related alerts that have not yet been acknowledged.
+ *
+ * @param subject subject
+ * @return storage nodes alerts not acknowledged
+ */
+ PageList<Alert> findNotAcknowledgedStorageNodeAlerts(Subject subject);
+
+ /**
+ * Fetches all the Storage Node related alerts.
+ *
+ * @param subject subject
+ * @return all storage nodes alerts
+ */
+ PageList<Alert> findAllStorageNodeAlerts(Subject subject);
+
/**
* <p>Prepares the node for subsequent upgrade.</p>
* <p> CAUTION: this method will set the RHQ server to maintenance mode, RHQ storage flushes all the data to disk
* and backup of all the keyspaces is created</p>
* <p>the subject needs to have <code>MANAGE_SETTINGS</code> and <code>MANAGE_INVENTORY</code> permissions.</p>
- *
+ *
* @param subject caller
* @param storageNode storage node on which the prepareForUpgrade operation should be run
*/
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerRemote.java
index d4c9f78..72432db 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerRemote.java
@@ -20,6 +20,7 @@ package org.rhq.enterprise.server.cloud;
import javax.ejb.Remote;
+import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.cloud.StorageNode;
import org.rhq.core.domain.cloud.StorageNodeLoadComposite;
@@ -28,7 +29,7 @@ import org.rhq.core.domain.util.PageList;
/**
* Remote interface to the manager responsible for creating and managing storage nodes.
- *
+ *
* @author Jirka Kremser
*/
@Remote
@@ -36,9 +37,9 @@ public interface StorageNodeManagerRemote {
/**
* <p>Returns the summary of load of the storage node.</p>
- *
+ *
* <p>the subject needs to have <code>MANAGE_SETTINGS</code> permissions.</p>
- *
+ *
* @param subject user that must have proper permissions
* @param node storage node entity (it can be a new object, but the id should be set properly)
* @param beginTime the start time
@@ -58,4 +59,19 @@ public interface StorageNodeManagerRemote {
*/
PageList<StorageNode> findStorageNodesByCriteria(Subject subject, StorageNodeCriteria criteria);
+ /**
+ * Fetches the list of Storage Node related alerts that have not yet been acknowledged.
+ *
+ * @param subject subject
+ * @return storage nodes alerts not acknowledged
+ */
+ PageList<Alert> findNotAcknowledgedStorageNodeAlerts(Subject subject);
+
+ /**
+ * Fetches all the Storage Node related alerts.
+ *
+ * @param subject subject
+ * @return all storage nodes alerts
+ */
+ PageList<Alert> findAllStorageNodeAlerts(Subject subject);
}
commit 4674c9c66fef570a0abb3961205056fed3e75097
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 11 14:58:52 2013 -0500
Update the calculation for the percentage of disk space used. The percentage now represents the amount of disk used by the Cassandra data files.
diff --git a/modules/enterprise/server/plugins/alertdef-rhq/src/main/java/org/rhq/enterprise/server/plugins/alertdef/AlertDefinitionServerPluginComponent.java b/modules/enterprise/server/plugins/alertdef-rhq/src/main/java/org/rhq/enterprise/server/plugins/alertdef/AlertDefinitionServerPluginComponent.java
index dcfdc37..8995ec0 100644
--- a/modules/enterprise/server/plugins/alertdef-rhq/src/main/java/org/rhq/enterprise/server/plugins/alertdef/AlertDefinitionServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/alertdef-rhq/src/main/java/org/rhq/enterprise/server/plugins/alertdef/AlertDefinitionServerPluginComponent.java
@@ -300,7 +300,7 @@ public class AlertDefinitionServerPluginComponent implements ServerPluginCompone
AlertCondition ac = new AlertCondition();
ac.setCategory(AlertConditionCategory.THRESHOLD);
ac.setComparator(">");
- ac.setThreshold(0.75D);
+ ac.setThreshold(0.5D);
List<Integer> measurementDefinitionIds = new ArrayList<Integer>(1);
for (MeasurementDefinition d : resourceType.getMetricDefinitions()) {
diff --git a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/StorageServiceComponent.java b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/StorageServiceComponent.java
index 7281f9b..e5a2283 100644
--- a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/StorageServiceComponent.java
+++ b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/StorageServiceComponent.java
@@ -60,6 +60,8 @@ public class StorageServiceComponent extends ComplexConfigurationResourceCompone
private static final String OWNERSHIP_METRIC_NAME = "Ownership";
private static final String PARTITION_DISK_USED_PERCENTAGE_METRIC_NAME = "Calculated.PartitionDiskUsedPercentage";
private static final String DATA_FILE_LOCATIONS_NAME = "AllDataFileLocations";
+ private static final String LOAD_NAME = "Load";
+
private Log log = LogFactory.getLog(StorageServiceComponent.class);
private InetAddress host;
@@ -178,23 +180,30 @@ public class StorageServiceComponent extends ComplexConfigurationResourceCompone
}
break;
} else if (PARTITION_DISK_USED_PERCENTAGE_METRIC_NAME.equals(request.getName())) {
- EmsAttribute attribute = bean.getAttribute(DATA_FILE_LOCATIONS_NAME);
- Object valueObject = attribute.refresh();
- if (valueObject instanceof String[]) {
+
+
+ EmsAttribute loadAttribute = bean.getAttribute(LOAD_NAME);
+ Object loadValue = loadAttribute.refresh();
+
+ EmsAttribute dataFileLocationAttribute = bean.getAttribute(DATA_FILE_LOCATIONS_NAME);
+ Object dataFileLocationValue = dataFileLocationAttribute.refresh();
+
+ if (loadValue != null && dataFileLocationValue != null && dataFileLocationValue instanceof String[]) {
//Please visit for details: https://issues.apache.org/jira/browse/CASSANDRA-2749
//The average usage of all partitions with the data will be reported.
//Cassandra selects the partition with most free space for SStable flush and compaction.
- report.addData(new MeasurementDataNumeric(request,
- getPartitionDiskUsedPercentage((String[]) valueObject)));
+ double load = Double.parseDouble(loadValue.toString());
+
+ report.addData(new MeasurementDataNumeric(request, getPartitionDiskUsedPercentage(load,
+ (String[]) dataFileLocationValue)));
}
}
}
}
- private double getPartitionDiskUsedPercentage(String[] paths) {
+ private double getPartitionDiskUsedPercentage(double dataSize, String[] paths) {
List<String> visitedMountPoints = new ArrayList<String>();
long totalDiskSpace = 0;
- long totalUsedDiskSpace = 0;
for (String path : paths) {
try {
@@ -202,7 +211,6 @@ public class StorageServiceComponent extends ComplexConfigurationResourceCompone
if (!visitedMountPoints.contains(fileSystemInfo.getMountPoint())) {
visitedMountPoints.add(fileSystemInfo.getMountPoint());
totalDiskSpace += fileSystemInfo.getFileSystemUsage().getTotal();
- totalUsedDiskSpace += fileSystemInfo.getFileSystemUsage().getUsed();
}
} catch (Exception e) {
log.error("Unable to determine file system usage information for data file location " + path, e);
@@ -210,7 +218,7 @@ public class StorageServiceComponent extends ComplexConfigurationResourceCompone
}
if (totalDiskSpace != 0) {
- double rawPercentage = ((double) totalUsedDiskSpace) / ((double) totalDiskSpace);
+ double rawPercentage = dataSize / ((double) totalDiskSpace);
return Math.round(rawPercentage * 100.0) / 100.0;
}
diff --git a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
index 3aa701b..e6bc1da 100644
--- a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
@@ -187,8 +187,8 @@
</operation>
<metric property="CurrentGenerationNumber" dataType="trait" displayType="summary" description="Current generation number"/>
- <metric property="Calculated.PartitionDiskUsedPercentage" dataType="measurement" units="percentage" displayType="summary" description="Percentage of total disk space used for the partition that contains the data files.
- If multiple data locations are specified then this will report the average utilization accross all the partitions."/>
+ <metric property="Calculated.PartitionDiskUsedPercentage" displayName="Data File Disk Used Percentage" dataType="measurement" units="percentage" displayType="summary" description="Percentage of disk space used by the data files. If multiple data locations are specified then this will report
+ the average utilization accross all the partitions that contain data files."/>
<metric property="ExceptionCount" measurementType="trendsup" dataType="measurement" displayType="summary" description="Exception Count"/>
<metric property="Initialized" dataType="trait" displayType="summary" description="Initialized"/>
<metric property="Joined" dataType="trait" displayType="summary" description="Joined"/>
commit a1c2dcac50a7a0df8ab17898952e7fa6270dfc3b
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 11 21:41:34 2013 -0400
use upgradesstables and not scrub command to regenerate sstables
Also execute a drain operation at the end to flush all memtables and commit log
to ensure no data loss prior to upgrade.
diff --git a/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh b/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh
index 8a83320..7c0b88a 100755
--- a/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh
+++ b/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh
@@ -30,24 +30,31 @@ cp $PATCH $RHQ_SERVER_DIR/rhq-storage/lib
echo "Starting RHQ Storage node"
$RHQ_SERVER_DIR/bin/rhqctl start --storage
+# sleep for a few seconds while Cassandra starts up
+echo "Waiting for RHQ Storage Node to start up..."
+sleep 3
+
# run the CQL script
echo "Running CQL script to disable table compression"
export CQLSH_HOST=$CQLSH_HOST
export CQL_PORT=$CQL_PORT
$RHQ_SERVER_DIR/rhq-storage/bin/cqlsh -u rhqadmin -p rhqadmin -f ./disable_compression.cql
-# scrub all keyspaces
+# rewrite all sstables
echo "Rebuilding data files for system keyspace"
-$RHQ_SERVER_DIR/rhq-storage/bin/nodetool -u rhqadmin -pw rhqadmin -p $JMX_PORT scrub system
+$RHQ_SERVER_DIR/rhq-storage/bin/nodetool -u rhqadmin -pw rhqadmin -p $JMX_PORT upgradesstables --include-all-sstables system
echo "Rebuilding data files for system_traces keyspace"
-$RHQ_SERVER_DIR/rhq-storage/bin/nodetool -u rhqadmin -pw rhqadmin -p $JMX_PORT scrub system_traces
+$RHQ_SERVER_DIR/rhq-storage/bin/nodetool -u rhqadmin -pw rhqadmin -p $JMX_PORT upgradesstables --include-all-sstables system_traces
echo "Rebuilding data files for system_auth keyspace"
-$RHQ_SERVER_DIR/rhq-storage/bin/nodetool -u rhqadmin -pw rhqadmin -p $JMX_PORT scrub system_auth
+$RHQ_SERVER_DIR/rhq-storage/bin/nodetool -u rhqadmin -pw rhqadmin -p $JMX_PORT upgradesstables --include-all-sstables system_auth
echo "Rebuilding data files for rhq keyspace"
-$RHQ_SERVER_DIR/rhq-storage/bin/nodetool -u rhqadmin -pw rhqadmin -p $JMX_PORT scrub rhq
+$RHQ_SERVER_DIR/rhq-storage/bin/nodetool -u rhqadmin -pw rhqadmin -p $JMX_PORT upgradesstables --include-all-sstables rhq
+
+# flush memtables and commit log to ensure no data loss prior to upgrade
+$RHQ_SERVER_DIR/rhq-storage/bin/nodetool -u rhqadmin -pw rhqadmin -p $JMX_PORT drain
echo "Shutting down the RHQ Storage node"
$RHQ_SERVER_DIR/bin/rhqctl stop
commit 957781e62543ff5023c4b59567ee76c6ab2a9d9a
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 11 17:14:48 2013 -0400
BZ 983552 shorten the deployment names of the ejb3 jar and the startup subsystem
diff --git a/etc/agent-versioning/build.xml b/etc/agent-versioning/build.xml
index d6c18a1..7a60e51 100644
--- a/etc/agent-versioning/build.xml
+++ b/etc/agent-versioning/build.xml
@@ -112,7 +112,7 @@ ant -Dserver.home.dir=/my/server/rhq-agent -Dnew.version=0.0.0.GA -Dnew.build=0
<target name="init-server">
<property name="env.RHQ_SERVER_HOME" location="dev-container"/>
<property name="server.home.dir" location="${env.RHQ_SERVER_HOME}"/>
- <property name="server.download.dir" location="${server.home.dir}/modules/org/rhq/rhq-enterprise-server-startup-subsystem/main/deployments/rhq.ear/rhq-downloads/rhq-agent"/>
+ <property name="server.download.dir" location="${server.home.dir}/modules/org/rhq/server-startup/main/deployments/rhq.ear/rhq-downloads/rhq-agent"/>
<available property="_server.download.dir.exists" file="${server.download.dir}"/>
<fail unless="_server.download.dir.exists" message="Cannot find the server download directory at ${server.download.dir}"/>
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
index 6d17177..481073e 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
+++ b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-
+
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
@@ -9,7 +9,7 @@
<context-param>
<param-name>resteasy.jndi.resources</param-name>
- <param-value>java:app/rhq-enterprise-server-ejb3/InventorySummaryHandler,java:app/rhq-enterprise-server-ejb3/AlertDefinitionHandler,java:app/rhq-enterprise-server-ejb3/ConfigurationHistoryHandler,java:app/rhq-enterprise-server-ejb3/RecentAlertHandler,java:app/rhq-enterprise-server-ejb3/SuspectMetricHandler,java:app/rhq-enterprise-server-ejb3/DriftComplianceHandler,java:app/rhq-enterprise-server-ejb3/RecentOperationsHandler,java:app/rhq-enterprise-server-ejb3/RecentDriftHandler,java:app/rhq-enterprise-server-ejb3/PlatformUtilizationHandler</param-value>
+ <param-value>java:app/rhq-server/InventorySummaryHandler,java:app/rhq-server/AlertDefinitionHandler,java:app/rhq-server/ConfigurationHistoryHandler,java:app/rhq-server/RecentAlertHandler,java:app/rhq-server/SuspectMetricHandler,java:app/rhq-server/DriftComplianceHandler,java:app/rhq-server/RecentOperationsHandler,java:app/rhq-server/RecentDriftHandler,java:app/rhq-server/PlatformUtilizationHandler</param-value>
<!--<description>List of jndi names of EJBs local interfaces that define REST stuff</description>-->
</context-param>
<context-param>
@@ -192,7 +192,7 @@
<servlet>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI DriftGWTService</servlet-name>
<servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.DriftGWTServiceImpl</servlet-class>
- </servlet>
+ </servlet>
<servlet>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI PlatformUtilizationGWTService</servlet-name>
<servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.PlatformUtilizationGWTServiceImpl</servlet-class>
@@ -205,7 +205,7 @@
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI TopologyGWTService</servlet-name>
<servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.TopologyGWTServiceImpl</servlet-class>
</servlet>
-
+
<servlet>
<servlet-name>Resteasy</servlet-name>
@@ -373,7 +373,7 @@
<servlet-mapping>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI DriftGWTService</servlet-name>
<url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/DriftGWTService</url-pattern>
- </servlet-mapping>
+ </servlet-mapping>
<servlet-mapping>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI PlatformUtilizationGWTService</servlet-name>
<url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/PlatformUtilizationGWTService</url-pattern>
@@ -398,7 +398,7 @@
</welcome-file-list>
- <!-- Uncomment the below to automatically redirect all HTTP requests to the
+ <!-- Uncomment the below to automatically redirect all HTTP requests to the
corresponding HTTPS URLs. -->
<!--
<security-constraint>
diff --git a/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.bat b/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.bat
index 2f197478..68e8706 100644
--- a/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.bat
+++ b/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.bat
@@ -1,16 +1,16 @@
rem This script should consume all the wsdls and compile the JAXB types all
rem into one directory.
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-enterprise-server-ejb3/RoleManagerBean?wsdl -p org.rhq.enterprise.server.ws
+call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-server/RoleManagerBean?wsdl -p org.rhq.enterprise.server.ws
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-enterprise-server-ejb3/ContentManagerBean?wsdl -p org.rhq.enterprise.server.ws
+call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-server/ContentManagerBean?wsdl -p org.rhq.enterprise.server.ws
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-enterprise-server-ejb3/SubjectManagerBean?wsdl -p org.rhq.enterprise.server.ws
+call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-server/SubjectManagerBean?wsdl -p org.rhq.enterprise.server.ws
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-enterprise-server-ejb3/OperationManagerBean... -p org.rhq.enterprise.server.ws
+call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-server/OperationManagerBean?wsdl -p org.rhq.enterprise.server.ws
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-enterprise-server-ejb3/RepoManagerBean?wsdl -p org.rhq.enterprise.server.ws
+call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-server/RepoManagerBean?wsdl -p org.rhq.enterprise.server.ws
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-enterprise-server-ejb3/ConfigurationManager... -p org.rhq.enterprise.server.ws
+call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-server/ConfigurationManagerBean?wsdl -p org.rhq.enterprise.server.ws
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-enterprise-server-ejb3/ResourceManagerBean?... -p org.rhq.enterprise.server.ws
\ No newline at end of file
+call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-server/ResourceManagerBean?wsdl -p org.rhq.enterprise.server.ws
\ No newline at end of file
diff --git a/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.sh b/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.sh
index e229fb4..f83293b 100644
--- a/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.sh
+++ b/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.sh
@@ -3,16 +3,16 @@
# This script should consume all the wsdls and compile the JAXB types all
# into one directory.
-../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-enterprise-server-ejb3/RoleManagerBean?wsdl -p org.rhq.enterprise.server.ws
+../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-server/RoleManagerBean?wsdl -p org.rhq.enterprise.server.ws
-../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-enterprise-server-ejb3/ContentManagerBean?wsdl -p org.rhq.enterprise.server.ws
+../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-server/ContentManagerBean?wsdl -p org.rhq.enterprise.server.ws
-../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-enterprise-server-ejb3/SubjectManagerBean?wsdl -p org.rhq.enterprise.server.ws
+../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-server/SubjectManagerBean?wsdl -p org.rhq.enterprise.server.ws
-../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-enterprise-server-ejb3/OperationManagerBean... -p org.rhq.enterprise.server.ws
+../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-server/OperationManagerBean?wsdl -p org.rhq.enterprise.server.ws
-../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-enterprise-server-ejb3/RepoManagerBean?wsdl -p org.rhq.enterprise.server.ws
+../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-server/RepoManagerBean?wsdl -p org.rhq.enterprise.server.ws
-../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-enterprise-server-ejb3/ConfigurationManager... -p org.rhq.enterprise.server.ws
+../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-server/ConfigurationManagerBean?wsdl -p org.rhq.enterprise.server.ws
-../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-enterprise-server-ejb3/ResourceManagerBean?... -p org.rhq.enterprise.server.ws
\ No newline at end of file
+../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-server/ResourceManagerBean?wsdl -p org.rhq.enterprise.server.ws
\ No newline at end of file
diff --git a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
index bf06886..a81b6cd 100644
--- a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
@@ -80,7 +80,7 @@
<property name="jboss.modules.dir" location="${project.build.outputDirectory}/modules" />
<mkdir dir="${jboss.modules.dir}" />
- <property name="rhq.ear.dir" location="${jboss.modules.dir}/org/rhq/rhq-enterprise-server-startup-subsystem/main/deployments/${rhq.earName}" />
+ <property name="rhq.ear.dir" location="${jboss.modules.dir}/org/rhq/server-startup/main/deployments/${rhq.earName}" />
<condition property="use-postgres" value="true">
<contains string="${rhq.server.database.type-mapping}" substring="postgres" casesensitive="false" />
@@ -164,7 +164,7 @@
<fail unless="jboss.home.is.valid" message="${jboss.home} does not contain a valid JBossAS installation - aborting!" />
<echo>Adding main EAR app module to ${jboss.modules.dir} ...</echo>
- <unzip src="${settings.localRepository}/org/rhq/rhq-enterprise-server-startup-subsystem/${project.version}/rhq-enterprise-server-startup-subsystem-${project.version}.zip"
+ <unzip src="${settings.localRepository}/org/rhq/server-startup/${project.version}/server-startup-${project.version}.zip"
dest="${jboss.modules.dir}" />
<echo>Adding installer module to ${jboss.modules.dir} ...</echo>
diff --git a/modules/enterprise/server/appserver/src/main/scripts/storage_setup.groovy b/modules/enterprise/server/appserver/src/main/scripts/storage_setup.groovy
index ccb90b9..857c268 100644
--- a/modules/enterprise/server/appserver/src/main/scripts/storage_setup.groovy
+++ b/modules/enterprise/server/appserver/src/main/scripts/storage_setup.groovy
@@ -168,11 +168,11 @@ def prepareModulesDir(basedir) {
)
ant.symlink(link: "$modulesDir/org/rhq/rhq-server-control", resource: "$defaultModulesDir/org/rhq/rhq-server-control")
- def downloadsDir = "$modulesDir/org/rhq/rhq-enterprise-server-startup-subsystem/main/deployments/rhq.ear/rhq-downloads"
+ def downloadsDir = "$modulesDir/org/rhq/server-startup/main/deployments/rhq.ear/rhq-downloads"
ant.mkdir(dir: downloadsDir)
ant.symlink(
link: "$downloadsDir/rhq-agent",
- resource: "$defaultModulesDir/org/rhq/rhq-enterprise-server-startup-subsystem/main/deployments/rhq.ear/rhq-downloads/rhq-agent"
+ resource: "$defaultModulesDir/org/rhq/server-startup/main/deployments/rhq.ear/rhq-downloads/rhq-agent"
)
}
diff --git a/modules/enterprise/server/client-api/src/test/java/org/rhq/enterprise/client/test/LocalClientTest.java b/modules/enterprise/server/client-api/src/test/java/org/rhq/enterprise/client/test/LocalClientTest.java
index 6e2fcf6..f350843 100644
--- a/modules/enterprise/server/client-api/src/test/java/org/rhq/enterprise/client/test/LocalClientTest.java
+++ b/modules/enterprise/server/client-api/src/test/java/org/rhq/enterprise/client/test/LocalClientTest.java
@@ -47,7 +47,7 @@ import org.rhq.enterprise.client.LocalClient;
import org.rhq.test.JMockTest;
/**
- *
+ *
*
* @author Lukas Krejci
*/
@@ -59,29 +59,29 @@ public class LocalClientTest extends JMockTest {
return CONTEXT_MOCK_FOR_TEST;
}
}
-
+
public static Context CONTEXT_MOCK_FOR_TEST = null;
-
+
@BeforeClass
public void setUpNaming() {
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FakeContextFactory.class.getName());
}
-
+
/**
* Needs to be called from within a test method so that the "context" variable is available.
- *
+ *
* @throws NamingException
*/
private void setupFakeJndiLookup() throws NamingException {
CONTEXT_MOCK_FOR_TEST = context.mock(Context.class);
-
+
context.checking(new Expectations() {{
allowing(CONTEXT_MOCK_FOR_TEST).lookup(with(any(String.class)));
will(new CustomAction("Fake JNDI lookup") {
@Override
public Object invoke(Invocation invocation) throws Throwable {
- // JNDI name format like: java:global/rhq/rhq-enterprise-server-ejb3/SystemManagerBean!org.rhq.enterprise.server.system.SystemManagerLocal
+ // JNDI name format like: java:global/rhq/rhq-server/SystemManagerBean!org.rhq.enterprise.server.system.SystemManagerLocal
String jndiName = (String) invocation.getParameter(0);
String beanName = jndiName.substring(0,jndiName.indexOf('!'));
beanName = beanName.substring(beanName.lastIndexOf('/') + 1);
@@ -105,7 +105,7 @@ public class LocalClientTest extends JMockTest {
});
}
});
-
+
allowing(CONTEXT_MOCK_FOR_TEST).close();
}});
}
@@ -130,15 +130,15 @@ public class LocalClientTest extends JMockTest {
@Test
public void testResilienceAgainstContextClassloaders() throws Exception {
setupFakeJndiLookup();
-
+
ClassLoader origCl = Thread.currentThread().getContextClassLoader();
try {
ClassLoader differentCl = new URLClassLoader(new URL[0], getClass().getClassLoader());
-
+
Thread.currentThread().setContextClassLoader(differentCl);
LocalClient lc = new LocalClient(null);
-
+
//this call creates the proxy and is theoretically prone to the context classloader
Object am = lc.getScriptingAPI().get(RhqManager.AlertManager);
diff --git a/modules/enterprise/server/ear/pom.xml b/modules/enterprise/server/ear/pom.xml
index 0e4bc83..e2a4cdb 100644
--- a/modules/enterprise/server/ear/pom.xml
+++ b/modules/enterprise/server/ear/pom.xml
@@ -238,7 +238,7 @@
<ejbModule>
<groupId>${project.groupId}</groupId>
<artifactId>rhq-enterprise-server</artifactId>
- <bundleFileName>rhq-enterprise-server-ejb3.jar</bundleFileName>
+ <bundleFileName>rhq-server.jar</bundleFileName>
</ejbModule>
<ejbClientModule>
@@ -832,7 +832,7 @@
<rhq.rootDir>../../../..</rhq.rootDir>
<rhq.containerDir>${rhq.rootDir}/${rhq.devContainerServerPath}</rhq.containerDir>
<rhq.deploymentName>${project.build.finalName}.ear</rhq.deploymentName>
- <rhq.deploymentDir>${rhq.containerDir}/modules/org/rhq/rhq-enterprise-server-startup-subsystem/main/deployments/${rhq.deploymentName}</rhq.deploymentDir>
+ <rhq.deploymentDir>${rhq.containerDir}/modules/org/rhq/server-startup/main/deployments/${rhq.deploymentName}</rhq.deploymentDir>
</properties>
<build>
diff --git a/modules/enterprise/server/ear/src/main/application/META-INF/jboss-deployment-structure.xml b/modules/enterprise/server/ear/src/main/application/META-INF/jboss-deployment-structure.xml
index d0a665d..80a648f 100644
--- a/modules/enterprise/server/ear/src/main/application/META-INF/jboss-deployment-structure.xml
+++ b/modules/enterprise/server/ear/src/main/application/META-INF/jboss-deployment-structure.xml
@@ -33,7 +33,7 @@
</sub-deployment>
<!-- This corresponds to the Server EJB3 JAR -->
- <sub-deployment name="rhq-enterprise-server-ejb3.jar">
+ <sub-deployment name="rhq-server.jar">
<dependencies>
<module name="org.jboss.msc" export="true" />
<module name="org.jboss.as.controller" export="true" />
diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
index 284ddbd..160b5dd 100644
--- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
+++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
@@ -49,7 +49,7 @@ import org.rhq.enterprise.server.installer.ServerInstallUtil.SupportedDatabaseTy
*/
public class InstallerServiceImpl implements InstallerService {
- private static final String RHQ_EXTENSION_NAME = "org.rhq.rhq-enterprise-server-startup-subsystem";
+ private static final String RHQ_EXTENSION_NAME = "org.rhq.server-startup";
private static final String RHQ_SUBSYSTEM_NAME = "rhq-startup";
private static final String EAR_NAME = "rhq.ear";
private static final String SYSPROP_PROPFILE = "rhq.server.properties-file";
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/client/security/test/JndiAccessTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/client/security/test/JndiAccessTest.java
index 334e768..1cdc1d5 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/client/security/test/JndiAccessTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/client/security/test/JndiAccessTest.java
@@ -34,7 +34,7 @@ import org.rhq.enterprise.server.system.SystemManagerBean;
import org.rhq.enterprise.server.util.LookupUtil;
/**
- *
+ *
*
* @author Lukas Krejci
*/
@@ -59,21 +59,21 @@ public class JndiAccessTest extends ScriptableAbstractEJB3Test {
public void testEjbsAccessibleThroughPrivilegedCode() {
LookupUtil.getSubjectManager().getOverlord();
}
-
+
public void testEjbsAccessibleThroughLocalClient() throws ScriptException, IOException {
Subject overlord = LookupUtil.getSubjectManager().getOverlord();
-
+
ScriptEngine engine = getEngine(overlord);
-
+
engine.eval("SubjectManager.getSubjectByName('rhqadmin');");
}
-
+
public void testLocalEjbsInaccessibleThroughJndiLookup() throws ScriptException, IOException {
Subject overlord = LookupUtil.getSubjectManager().getOverlord();
-
+
ScriptEngine engine = getEngine(overlord);
-
- String jndiName = "java:global/rhq/rhq-enterprise-server-ejb3/"
+
+ String jndiName = "java:global/rhq/rhq-server/"
+ SystemManagerBean.class.getSimpleName()
+ "!"
+ SystemManagerBean.class.getName().replace("Bean", "Local");
@@ -85,19 +85,19 @@ public class JndiAccessTest extends ScriptableAbstractEJB3Test {
+ jndiName
+ "');\n"
+ "systemManager.isDebugModeEnabled();");
-
+
Assert.fail("The script shouldn't have been able to call local SLSB method.");
} catch (ScriptException e) {
checkIsDesiredSecurityException(e);
}
}
-
+
public void testLocalEjbsInaccessibleThroughJndiLookupWithCustomUrlPackages() throws ScriptException, IOException {
Subject overlord = LookupUtil.getSubjectManager().getOverlord();
ScriptEngine engine = getEngine(overlord);
- String jndiName = "java:global/rhq/rhq-enterprise-server-ejb3/"
+ String jndiName = "java:global/rhq/rhq-server/"
+ SystemManagerBean.class.getSimpleName()
+ "!"
+ SystemManagerBean.class.getName().replace("Bean", "Local");
@@ -122,10 +122,10 @@ public class JndiAccessTest extends ScriptableAbstractEJB3Test {
public void testRemoteEjbsInaccessibleThroughJndiLookup() throws ScriptException, IOException {
Subject overlord = LookupUtil.getSubjectManager().getOverlord();
-
+
ScriptEngine engine = getEngine(overlord);
- String jndiName = "java:global/rhq/rhq-enterprise-server-ejb3/"
+ String jndiName = "java:global/rhq/rhq-server/"
+ SystemManagerBean.class.getSimpleName()
+ "!"
+ SystemManagerBean.class.getName().replace("Bean", "Remote");
@@ -137,28 +137,28 @@ public class JndiAccessTest extends ScriptableAbstractEJB3Test {
+ jndiName
+ "');\n"
+ "systemManager.getSystemSettings(subject);");
-
+
Assert.fail("The script shouldn't have been able to call remote SLSB method directly.");
} catch (ScriptException e) {
checkIsDesiredSecurityException(e);
}
}
-
+
public void testScriptCantUseSessionManagerMethods() throws Exception {
- Subject overlord = LookupUtil.getSubjectManager().getOverlord();
-
+ Subject overlord = LookupUtil.getSubjectManager().getOverlord();
+
final ScriptEngine engine = getEngine(overlord);
-
+
class G {
private String sessionManager = ""
+ "org.rhq.enterprise.server.auth.SessionManager.getInstance().";
-
+
public void testInvoke(String methodCall) throws ScriptException {
String code = sessionManager + methodCall;
try {
- engine.eval(code);
+ engine.eval(code);
Assert.fail("The script shouldn't have been able to call a method on a SessionManager: " + methodCall);
} catch (ScriptException e) {
checkIsDesiredSecurityException(e);
@@ -166,7 +166,7 @@ public class JndiAccessTest extends ScriptableAbstractEJB3Test {
}
};
G manager = new G();
-
+
manager.testInvoke("getLastAccess(0);");
manager.testInvoke("getOverlord()");
manager.testInvoke("getSubject(2);");
@@ -175,27 +175,27 @@ public class JndiAccessTest extends ScriptableAbstractEJB3Test {
manager.testInvoke("put(new org.rhq.core.domain.auth.Subject());");
manager.testInvoke("put(new org.rhq.core.domain.auth.Subject(), 0);");
}
-
+
public void testScriptCantObtainRawJDBCConnectionsWithoutCredentials() throws Exception {
Subject overlord = LookupUtil.getSubjectManager().getOverlord();
-
+
ScriptEngine engine = getEngine(overlord);
-
+
try {
engine.eval(""
+ "var ctx = new javax.naming.InitialContext();\n"
+ "var datasource = ctx.lookup('" + RHQConstants.DATASOURCE_JNDI_NAME + "');\n"
+ "con = datasource.getConnection();");
-
+
Assert.fail("The script shouldn't have been able to obtain the datasource from the JNDI.");
} catch (ScriptException e) {
checkIsDesiredSecurityException(e);
}
}
-
+
public void testScriptCantUseEntityManager() throws Exception {
- Subject overlord = LookupUtil.getSubjectManager().getOverlord();
-
+ Subject overlord = LookupUtil.getSubjectManager().getOverlord();
+
ScriptEngine engine = getEngine(overlord);
try {
@@ -204,12 +204,12 @@ public class JndiAccessTest extends ScriptableAbstractEJB3Test {
+ "var entityManagerFactory = ctx.lookup('" + RHQConstants.ENTITY_MANAGER_JNDI_NAME + "');\n"
+ "var entityManager = entityManagerFactory.createEntityManager();\n"
+ "entityManager.find(java.lang.Class.forName('org.rhq.core.domain.resource.Resource'), java.lang.Integer.valueOf('10001'));");
-
+
Assert.fail("The script shouldn't have been able to use the EntityManager.");
} catch (ScriptException e) {
checkIsDesiredSecurityException(e);
- }
-
+ }
+
//try harder with manually specifying the initial context factory
try {
engine.eval(""
@@ -220,20 +220,20 @@ public class JndiAccessTest extends ScriptableAbstractEJB3Test {
+ "var entityManagerFactory = ctx.lookup('" + RHQConstants.ENTITY_MANAGER_JNDI_NAME + "');\n"
+ "var entityManager = entityManagerFactory.createEntityManager();\n"
+ "entityManager.find(java.lang.Class.forName('org.rhq.core.domain.resource.Resource'), java.lang.Integer.valueOf('10001'));");
-
+
Assert.fail("The script shouldn't have been able to use the EntityManager even using custom initial context factory.");
} catch (ScriptException e) {
checkIsDesiredSecurityException(e);
- }
+ }
}
public void testProxyFactoryWorksWithSecuredScriptEngine() throws Exception {
- Subject overlord = LookupUtil.getSubjectManager().getOverlord();
-
+ Subject overlord = LookupUtil.getSubjectManager().getOverlord();
+
ScriptEngine engine = getEngine(overlord);
-
+
try {
- engine.eval("var resource = ProxyFactory.getResource(10001);");
+ engine.eval("var resource = ProxyFactory.getResource(10001);");
} catch (ScriptException e) {
//if the script fails (there is no resource with ID 10001)
//it should not be because of an access control exception
@@ -243,10 +243,10 @@ public class JndiAccessTest extends ScriptableAbstractEJB3Test {
//THIS IS A NEW REQUIREMENT THAT DOESN'T CURRENTLY WORK...
// public void testInitialContextFactoryBuilderNotReplaceableUsingScripts() throws Exception {
- // Subject overlord = LookupUtil.getSubjectManager().getOverlord();
- //
+ // Subject overlord = LookupUtil.getSubjectManager().getOverlord();
+ //
// ScriptEngine engine = getEngine(overlord);
- //
+ //
// try {
// engine.eval(""
// + "var mgrCls = java.lang.Class.forName('javax.naming.spi.NamingManager');\n"
@@ -262,11 +262,11 @@ public class JndiAccessTest extends ScriptableAbstractEJB3Test {
// NamingHack.bruteForceInitialContextFactoryBuilder();
// }
// }
-
+
private static void checkIsDesiredSecurityException(ScriptException e) {
String message = e.getMessage();
String permissionTrace = "org.rhq.allow.server.internals.access";
-
+
if (!message.contains(permissionTrace)) {
Assert
.fail(
@@ -278,7 +278,7 @@ public class JndiAccessTest extends ScriptableAbstractEJB3Test {
private static void checkIsNotASecurityException(ScriptException e) {
String message = e.getMessage();
String permissionTrace = "org.rhq.allow.server.internals.access";
-
+
if (message.contains(permissionTrace)) {
Assert
.fail(
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
index 9ddba97..4dfbd46 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
@@ -124,20 +124,20 @@ public abstract class AbstractEJB3Test extends Arquillian {
// we need a way to deploy dependent ears needed to support the server/jar classes. But
// building this jar up (as is done in core/domain) was too difficult due to the huge number
// of dependencies. It was easier, and made sense, to use the already built rhq.ear
- // and run as true integration tests. We do thin rhq.ear by removing all of the WAR files, and
+ // and run as true integration tests. We do thin rhq.ear by removing all of the WAR files, and
// deploy only the EJB jars, and the services, which are really the objects under test.
@Deployment
protected static EnterpriseArchive getBaseDeployment() {
- // Ensure the test working dir exists
+ // Ensure the test working dir exists
tmpdirRoot.mkdirs();
// deploy the test classes in their own jar, under /lib
JavaArchive testClassesJar = ShrinkWrap.create(JavaArchive.class, "test-classes.jar");
testClassesJar = addClasses(testClassesJar, new File("target/test-classes/org"), null);
- // add non itests-2 RHQ classes used by the test classes, as well as needed resources
+ // add non itests-2 RHQ classes used by the test classes, as well as needed resources
testClassesJar.addClass(ThrowableUtil.class);
testClassesJar.addClass(MessageDigestGenerator.class);
testClassesJar.addClass(StreamUtil.class);
@@ -340,22 +340,22 @@ public abstract class AbstractEJB3Test extends Arquillian {
.withoutTransitivity().asSingle(EnterpriseArchive.class);
// merge rhq.ear into testEar but include only the EJB jars and the supporting libraries. Note that we
// don't include the services sar because tests are responsible for prepare/unprepare of all required services,
- // we don't want the production services performing any unexpected work.
+ // we don't want the production services performing any unexpected work.
testEar = testEar.merge(rhqEar, Filters.include("/lib.*|/rhq.*ejb3\\.jar.*"));
// remove startup beans and shutdown listeners, we don't want this to be a full server deployment. The tests
// start/stop what they need, typically with test services or mocks.
testEar.delete(ArchivePaths
- .create("/rhq-enterprise-server-ejb3.jar/org/rhq/enterprise/server/core/StartupBean.class"));
+ .create("/rhq-server.jar/org/rhq/enterprise/server/core/StartupBean.class"));
testEar.delete(ArchivePaths
- .create("/rhq-enterprise-server-ejb3.jar/org/rhq/enterprise/server/core/StartupBean$1.class"));
+ .create("/rhq-server.jar/org/rhq/enterprise/server/core/StartupBean$1.class"));
testEar.delete(ArchivePaths
- .create("/rhq-enterprise-server-ejb3.jar/org/rhq/enterprise/server/core/ShutdownListener.class"));
+ .create("/rhq-server.jar/org/rhq/enterprise/server/core/ShutdownListener.class"));
//replace the above startup beans with stripped down versions
testEar.add(new ClassAsset(StrippedDownStartupBean.class), ArchivePaths
- .create("/rhq-enterprise-server-ejb3.jar/org/rhq/enterprise/server/test/StrippedDownStartupBean.class"));
+ .create("/rhq-server.jar/org/rhq/enterprise/server/test/StrippedDownStartupBean.class"));
testEar.add(new ClassAsset(StrippedDownStartupBeanPreparation.class), ArchivePaths
- .create("/rhq-enterprise-server-ejb3.jar/org/rhq/enterprise/server/test/"
+ .create("/rhq-server.jar/org/rhq/enterprise/server/test/"
+ "StrippedDownStartupBeanPreparation.class"));
testEar.addAsManifestResource(new ByteArrayAsset("<beans/>".getBytes()), ArchivePaths.create("beans.xml"));
@@ -368,7 +368,7 @@ public abstract class AbstractEJB3Test extends Arquillian {
// add the application xml declaring the ejb jars
testEar.setApplicationXML("application.xml");
- // add additional 3rd party dependent jars needed to support test classes
+ // add additional 3rd party dependent jars needed to support test classes
Collection thirdPartyDeps = new ArrayList();
thirdPartyDeps.add("joda-time:joda-time");
thirdPartyDeps.add("org.jboss.shrinkwrap:shrinkwrap-impl-base");
@@ -496,15 +496,15 @@ public abstract class AbstractEJB3Test extends Arquillian {
/**
* <p>DO NOT OVERRIDE.</p>
* <p>DO NOT DEFINE AN @BeforeMethod</p>
- *
+ *
* Instead, override {@link #beforeMethod()}. If you must override, for example, if you
* need to use special attributes on your annotation, then ensure you protect the code with
* and {@link #inContainer()} call.
*/
@BeforeMethod
protected void __beforeMethod(Method method) throws Throwable {
- // Note that Arquillian calls the testng BeforeMethod twice (as of 1.0.2.Final, once
- // out of container and once in container. In general the expectation is to execute it
+ // Note that Arquillian calls the testng BeforeMethod twice (as of 1.0.2.Final, once
+ // out of container and once in container. In general the expectation is to execute it
// one time, and doing it in container allows for the expected injections and context.
if (inContainer()) {
try {
@@ -539,7 +539,7 @@ public abstract class AbstractEJB3Test extends Arquillian {
/**
* <p>DO NOT OVERRIDE.</p>
* <p>DO NOT DEFINE AN @AfterMethod</p>
- *
+ *
* Instead, override {@link #afterMethod()}.
*/
@AfterMethod(alwaysRun = true)
@@ -559,33 +559,33 @@ public abstract class AbstractEJB3Test extends Arquillian {
}
protected boolean inContainer() {
- // If the injection is done we're running in the container.
+ // If the injection is done we're running in the container.
return (null != initialContext);
}
/**
- * Override Point! Do not implement a @BeforeMethod, instead override this method.
+ * Override Point! Do not implement a @BeforeMethod, instead override this method.
*/
protected void beforeMethod() throws Exception {
// do nothing if we're not overridden
}
/**
- * Override Point! Do not implement a @BeforeMethod, instead override this method.
+ * Override Point! Do not implement a @BeforeMethod, instead override this method.
*/
protected void beforeMethod(Method method) throws Exception {
// do nothing if we're not overridden
}
/**
- * Override Point! Do not implement an @AfterMethod, instead override this method. note: alwaysRun=true
+ * Override Point! Do not implement an @AfterMethod, instead override this method. note: alwaysRun=true
*/
protected void afterMethod() throws Exception {
// do nothing if we're not overridden
}
/**
- * Override Point! Do not implement an @AfterMethod, instead override this method. note: alwaysRun=true
+ * Override Point! Do not implement an @AfterMethod, instead override this method. note: alwaysRun=true
*/
protected void afterMethod(ITestResult result, Method meth) throws Exception {
// do nothing if we're not overridden
@@ -706,7 +706,7 @@ public abstract class AbstractEJB3Test extends Arquillian {
}
/* The old AbstractEJB3Test impl extended AssertJUnit. Continue to support the used methods
- * with various call-thru methods.
+ * with various call-thru methods.
*/
protected void assertNotNull(Object o) {
@@ -1020,7 +1020,7 @@ public abstract class AbstractEJB3Test extends Arquillian {
scanner.setAgentPluginDir(pluginDirPath); // we don't want to scan for these
scanner.setServerPluginDir("ignore no plugins here"); // we don't want to scan for these
scanner.setUserPluginDir("ignore no plugins here"); // we don't want to scan for these
- scanner.setScanPeriod("9999999"); // we want to manually scan - don't allow for auto-scan to happen
+ scanner.setScanPeriod("9999999"); // we want to manually scan - don't allow for auto-scan to happen
return preparePluginScannerService(scanner);
}
@@ -1028,7 +1028,7 @@ public abstract class AbstractEJB3Test extends Arquillian {
/**
* Note that the standard plugin scanner service is deployed automatically with the test rhq ear,
* this is only necessary if you want a custom service.
- *
+ *
* @param scannerService
*/
public PluginDeploymentScannerMBean preparePluginScannerService(PluginDeploymentScannerMBean scannerService) {
@@ -1072,7 +1072,7 @@ public abstract class AbstractEJB3Test extends Arquillian {
* annotations by creating sessions for different users with different permissions.
*
* @param subject a JON subject
- * @return the session activated subject, a copy of the subject passed in.
+ * @return the session activated subject, a copy of the subject passed in.
*/
public Subject createSession(Subject subject) {
return SessionManager.getInstance().put(subject);
@@ -1086,9 +1086,9 @@ public abstract class AbstractEJB3Test extends Arquillian {
* A utility for writing out various objects that need to be persisted for use between
* tests. Arquillian (1.0.2) basically "new"s the testng test class on each test, so instance
* variables can not be used between tests. Instead, the db or this mechanism needs to be used.
- *
+ *
* The file will be placed in the standard temp dir. If it already exists it will be replaced.
- *
+ *
* @param filename Do not include the directory. The value will be prepended with the class name.
* @param objects
* @throws Exception
@@ -1106,9 +1106,9 @@ public abstract class AbstractEJB3Test extends Arquillian {
/**
* A utility for reading in objects written with {@link #writeObjects(String, Object...). They are
* placed in the result List in the same order they were written.
- *
+ *
* @param filename The same filename used in the write. Do not include the directory.
- * @param numObjects the number of objects to read out. Can be less than total written, not greater.
+ * @param numObjects the number of objects to read out. Can be less than total written, not greater.
* @throws Exception
*/
protected List<Object> readObjects(String filename, int numObjects) throws Exception {
@@ -1130,16 +1130,16 @@ public abstract class AbstractEJB3Test extends Arquillian {
/**
* A utility for cleaning up files created with {@link #writeObjects(String, Object...).
- *
- * @param filename The same filename used in the write. Do not include the directory.
- * @return true if deleted, false otherwise.
+ *
+ * @param filename The same filename used in the write. Do not include the directory.
+ * @return true if deleted, false otherwise.
*/
protected boolean deleteObjects(String filename) {
File file = new File(getTempDir(), filename);
return file.delete();
}
- /**
+ /**
* @return a temp directory for testing that is specific to this test class. Specifically tmpdirRoot/this.getClass().getSimpleName().
*/
public File getTempDir() {
diff --git a/modules/enterprise/server/itests-2/src/test/resources/application.xml b/modules/enterprise/server/itests-2/src/test/resources/application.xml
index 06b81e6..e28f755 100644
--- a/modules/enterprise/server/itests-2/src/test/resources/application.xml
+++ b/modules/enterprise/server/itests-2/src/test/resources/application.xml
@@ -6,6 +6,6 @@
<ejb>rhq-core-domain-ejb3.jar</ejb>
</module>
<module>
- <ejb>rhq-enterprise-server-ejb3.jar</ejb>
- </module>
+ <ejb>rhq-server.jar</ejb>
+ </module>
</application>
\ No newline at end of file
diff --git a/modules/enterprise/server/itests-2/src/test/resources/jboss-deployment-structure.xml b/modules/enterprise/server/itests-2/src/test/resources/jboss-deployment-structure.xml
index 48a80f2..1b5ceb9 100644
--- a/modules/enterprise/server/itests-2/src/test/resources/jboss-deployment-structure.xml
+++ b/modules/enterprise/server/itests-2/src/test/resources/jboss-deployment-structure.xml
@@ -20,7 +20,7 @@
</deployment>
<!-- This corresponds to the Server EJB3 JAR -->
- <sub-deployment name="rhq-enterprise-server-ejb3.jar">
+ <sub-deployment name="rhq-server.jar">
<dependencies>
<module name="org.jboss.msc" export="true" />
<module name="org.jboss.as.controller" export="true" />
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/remote/RemoteSafeInvocationHandler.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/remote/RemoteSafeInvocationHandler.java
index 3a435ef..2602cf8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/remote/RemoteSafeInvocationHandler.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/remote/RemoteSafeInvocationHandler.java
@@ -44,8 +44,8 @@ import org.rhq.enterprise.server.safeinvoker.HibernateDetachUtility;
* Although, we execute only locals to bypass the serialization performed by a remote invocation. Even
* though this handler is co-located, for remotes, remoting will serialize the return data immediately.
* This is bad for us because since we return domain objects we ned to scrub the data, removing
- * hibernate proxies (see {@link HibernateDetachUtility}.
- *
+ * hibernate proxies (see {@link HibernateDetachUtility}.
+ *
* @author Greg Hinkle
* @autor Jay Shaughnessy
*/
@@ -103,7 +103,7 @@ public class RemoteSafeInvocationHandler implements ServerInvocationHandler {
Object target = ic.lookup(jndiName);
Method m = target.getClass().getMethod(methodInfo[1], sig);
- // switch to the local
+ // switch to the local
jndiName = getLocalJNDIName(remoteClass);
target = ic.lookup(jndiName);
@@ -146,12 +146,12 @@ public class RemoteSafeInvocationHandler implements ServerInvocationHandler {
}
private static <T> String getLocalJNDIName(Class<?> remoteClass) {
- return ("java:global/rhq/rhq-enterprise-server-ejb3/" + remoteClass.getSimpleName().replace("Remote", "Bean")
+ return ("java:global/rhq/rhq-server/" + remoteClass.getSimpleName().replace("Remote", "Bean")
+ "!" + remoteClass.getName().replace("Remote", "Local"));
}
private static <T> String getRemoteJNDIName(Class<?> remoteClass) {
- return ("java:global/rhq/rhq-enterprise-server-ejb3/" + remoteClass.getSimpleName().replace("Remote", "Bean")
+ return ("java:global/rhq/rhq-server/" + remoteClass.getSimpleName().replace("Remote", "Bean")
+ "!" + remoteClass.getName());
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index 7b60e13..d597363 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -482,7 +482,7 @@ public final class LookupUtil {
public static TopologyManagerLocal getTopologyManager() {
return lookupLocal(TopologyManagerBean.class);
}
-
+
public static StorageNodeManagerLocal getStorageNodeManager() {
return lookupLocal(StorageNodeManagerBean.class);
}
@@ -636,10 +636,10 @@ public final class LookupUtil {
/**
* Generic method to lookup an Ejb bean by name and the interface name
- *
+ *
* @param beanName the name of the EJB bean
* @param interfaceName the full class name of either the remote or local interface
- *
+ *
* @return the bean accessed through specified interface
*/
public static Object getEjb(String beanName, String interfaceName) {
@@ -656,7 +656,7 @@ public final class LookupUtil {
// Private Methods
private static String getLocalJNDIName(String beanName, String interfaceName) {
- return "java:global/rhq/rhq-enterprise-server-ejb3/" + beanName + "!" + interfaceName;
+ return "java:global/rhq/rhq-server/" + beanName + "!" + interfaceName;
}
private static <T> String getLocalJNDIName(@NotNull
@@ -673,7 +673,7 @@ public final class LookupUtil {
*/
private static <T> String getRemoteJNDIName(@NotNull
Class<? extends T> beanClass) {
- return ("java:global/rhq/rhq-enterprise-server-ejb3/" + beanClass.getSimpleName() + "!" + beanClass.getName()
+ return ("java:global/rhq/rhq-server/" + beanClass.getSimpleName() + "!" + beanClass.getName()
.replace("Bean", "Remote"));
}
diff --git a/modules/enterprise/server/jar/src/main/resources/server-comm-configuration-overrides.properties b/modules/enterprise/server/jar/src/main/resources/server-comm-configuration-overrides.properties
index 91ccc85..f529be9 100644
--- a/modules/enterprise/server/jar/src/main/resources/server-comm-configuration-overrides.properties
+++ b/modules/enterprise/server/jar/src/main/resources/server-comm-configuration-overrides.properties
@@ -1,5 +1,5 @@
# location of the plugin jars and other files agents can download directly from sever
-rhq.server.agent-files-directory=${rhq.server.home}/modules/org/rhq/rhq-enterprise-server-startup-subsystem/main/deployments/rhq.ear/rhq-downloads
+rhq.server.agent-files-directory=${rhq.server.home}/modules/org/rhq/server-startup/main/deployments/rhq.ear/rhq-downloads
# location where data files can be stored
rhq.communications.data-directory=${jboss.server.data.dir}
# global limit on number of concurrent incoming messages allowed
diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java
index df07b5a..bb6aa40 100644
--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java
+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java
@@ -354,7 +354,7 @@ public class Install extends AbstractInstall {
private File getAgentInstaller() {
File agentDownloadDir = new File(getBaseDir(),
- "modules/org/rhq/rhq-enterprise-server-startup-subsystem/main/deployments/rhq.ear/rhq-downloads/rhq-agent");
+ "modules/org/rhq/server-startup/main/deployments/rhq.ear/rhq-downloads/rhq-agent");
return agentDownloadDir.listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Upgrade.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Upgrade.java
index 37667c6..9245baf 100644
--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Upgrade.java
+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Upgrade.java
@@ -571,7 +571,7 @@ public class Upgrade extends AbstractInstall {
private File getFileDownload(String directory, final String fileMatch) {
File downloadDir = new File(getBaseDir(),
- "modules/org/rhq/rhq-enterprise-server-startup-subsystem/main/deployments/rhq.ear/rhq-downloads/"
+ "modules/org/rhq/server-startup/main/deployments/rhq.ear/rhq-downloads/"
+ directory);
return downloadDir.listFiles(new FileFilter() {
@Override
diff --git a/modules/enterprise/server/startup-subsystem/pom.xml b/modules/enterprise/server/startup-subsystem/pom.xml
index 3b5b2ba..e69df2e 100644
--- a/modules/enterprise/server/startup-subsystem/pom.xml
+++ b/modules/enterprise/server/startup-subsystem/pom.xml
@@ -13,7 +13,7 @@
<relativePath>../../../../pom.xml</relativePath>
</parent>
- <artifactId>rhq-enterprise-server-startup-subsystem</artifactId>
+ <artifactId>server-startup</artifactId>
<name>RHQ Server Startup AS7 Subsystem</name>
@@ -106,7 +106,7 @@
<artifactId>jboss-as-ee</artifactId>
<scope>provided</scope>
</dependency>
-
+
<!-- our startup subsystem will be deploying this -->
<dependency>
<groupId>org.rhq</groupId>
diff --git a/pom.xml b/pom.xml
index d52dcc7..26703d1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,7 +42,7 @@
<rhq.defaultDevContainerPath>dev-container</rhq.defaultDevContainerPath>
<rhq.devContainerServerPath>${rhq.defaultDevContainerPath}/rhq-server</rhq.devContainerServerPath>
<!-- path relative to under dev container path where the EAR is deployed -->
- <rhq.earDeployDir>modules/org/rhq/rhq-enterprise-server-startup-subsystem/main/deployments/${rhq.earName}</rhq.earDeployDir>
+ <rhq.earDeployDir>modules/org/rhq/server-startup/main/deployments/${rhq.earName}</rhq.earDeployDir>
<!-- path relative to under dev container path where other things are stored -->
<rhq.agentPluginDir>${rhq.earDeployDir}/rhq-downloads/rhq-plugins</rhq.agentPluginDir>
<rhq.serverPluginDir>${rhq.earDeployDir}/rhq-serverplugins</rhq.serverPluginDir>
commit d3336fcd24c36f257a0702b13114b95146d44d83
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jul 11 14:04:39 2013 -0400
cassandra-installer uses a commons-io 2.1 API, we need to put this up front in classpath in eclipse
diff --git a/.classpath b/.classpath
index f09f8ed..e5e7a21 100644
--- a/.classpath
+++ b/.classpath
@@ -217,6 +217,7 @@
<classpathentry kind="src" path="modules/enterprise/server/data-migration/src/test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/httpcomponents/httpclient/4.2.3/httpclient-4.2.3.jar" sourcepath="M2_REPO/org/apache/httpcomponents/httpclient/4.2.3/httpclient-4.2.3-sources.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/commons-io/commons-io/2.1/commons-io-2.1.jar" sourcepath="M2_REPO/commons-io/commons-io/2.1/commons-io-2.1-sources.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/httpcomponents/httpcore/4.2.2/httpcore-4.2.2.jar" sourcepath="M2_REPO/org/apache/httpcomponents/httpcore/4.2.2/httpcore-4.2.2-sources.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/httpcomponents/httpmime/4.2.3/httpmime-4.2.3.jar" sourcepath="M2_REPO/org/apache/httpcomponents/httpmime/4.2.3/httpmime-4.2.3-sources.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/integration/jboss-profileservice-spi/5.1.0.SP1/jboss-profileservice-spi-5.1.0.SP1.jar"/>
commit 794d564b16b697870ca92040f27acbcdcad63522
Author: Rémy Maucherat <rmaucher(a)redhat.com>
Date: Thu Jul 11 15:33:55 2013 +0200
BZ863502: Fix OOM connecting to Tomcat instance. Patch by Thomas Segismont.
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java
index f1e2c51..1b595db 100644
--- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java
+++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java
@@ -1,24 +1,20 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2013 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.jboss.on.plugins.tomcat;
@@ -195,10 +191,9 @@ public class TomcatServerComponent<T extends ResourceComponent<?>> implements JM
// to have a version compatible local install and set the install path to the local path, even though
// the server url was remote.
String catalinaHome = pluginConfig.getSimpleValue(PLUGIN_CONFIG_CATALINA_HOME_PATH, null);
- boolean hasLocalJars = new File(catalinaHome).isDirectory();
-
- if (hasLocalJars) {
- connectionSettings.setLibraryURI(catalinaHome);
+ File libDir = getLibDir(catalinaHome);
+ if (libDir != null) {
+ connectionSettings.setLibraryURI(libDir.getAbsolutePath());
connectionFactory.discoverServerClasses(connectionSettings);
// Tell EMS to make copies of jar files so that the ems classloader doesn't lock
@@ -276,6 +271,22 @@ public class TomcatServerComponent<T extends ResourceComponent<?>> implements JM
return connection;
}
+ private File getLibDir(String catalinaHome) {
+ if (catalinaHome != null) {
+ // Tomcat 6 and Tomcat 7 have Catalina JARS in CATALINA_HOME/lib
+ File libDir = new File(catalinaHome, "lib");
+ if (libDir.isDirectory()) {
+ return libDir;
+ }
+ // Tomcat 5.5 has Catalina JARS in CATALINA_HOME/server/lib
+ libDir = new File(catalinaHome, "server" + File.separator + "lib");
+ if (libDir.isDirectory()) {
+ return libDir;
+ }
+ }
+ return null;
+ }
+
public Configuration getPluginConfiguration() {
return resourceContext.getPluginConfiguration();
}
@@ -485,4 +496,4 @@ public class TomcatServerComponent<T extends ResourceComponent<?>> implements JM
operationParameters.put(shutdownScriptEnv);
}
}
-}
\ No newline at end of file
+}
commit 6b054aa471107a3894fc45ea2ed97c7f8615562f
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Thu Jul 11 15:29:55 2013 +0200
Improve CassandraNodeComponent availability check performance.
Keep a reference of the ProcessInfo instance and get a new one only if needed.
diff --git a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
index 90afafb..0037bfe 100644
--- a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
+++ b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
@@ -1,30 +1,25 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.plugins.cassandra;
-import static org.rhq.core.domain.measurement.AvailabilityType.DOWN;
-import static org.rhq.core.domain.measurement.AvailabilityType.UNKNOWN;
-import static org.rhq.core.domain.measurement.AvailabilityType.UP;
+import static java.util.concurrent.TimeUnit.NANOSECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.rhq.core.system.OperatingSystemType.WINDOWS;
import java.io.File;
@@ -65,6 +60,7 @@ import org.rhq.core.pluginapi.util.ProcessExecutionUtility;
import org.rhq.core.system.ProcessExecution;
import org.rhq.core.system.ProcessExecutionResults;
import org.rhq.core.system.ProcessInfo;
+import org.rhq.core.system.ProcessInfo.ProcessInfoSnapshot;
import org.rhq.core.system.SystemInfo;
import org.rhq.core.util.StringUtil;
import org.rhq.core.util.exception.ThrowableUtil;
@@ -75,17 +71,19 @@ import org.rhq.plugins.jmx.JMXServerComponent;
* @author John Sanda
*/
public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent<?>> implements OperationFacet {
-
- private Log log = LogFactory.getLog(CassandraNodeComponent.class);
+ private static final Log LOG = LogFactory.getLog(CassandraNodeComponent.class);
private Session cassandraSession;
private String host;
+ private ProcessInfo processInfo;
@SuppressWarnings("rawtypes")
@Override
public void start(ResourceContext context) throws Exception {
super.start(context);
+ processInfo = context.getNativeProcess();
+
host = context.getPluginConfiguration().getSimpleValue("host", "localhost");
String clusterName = context.getPluginConfiguration().getSimpleValue("clusterName", "unknown");
String username = context.getPluginConfiguration().getSimpleValue("username", "cassandra");
@@ -98,7 +96,7 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
nativePort = Integer.parseInt(context.getPluginConfiguration()
.getSimpleValue("nativeTransportPort", "9042"));
} catch (Exception e) {
- log.debug("Native transport port parsing failed...", e);
+ LOG.debug("Native transport port parsing failed...", e);
}
@@ -115,42 +113,39 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
this.cassandraSession = clusterBuilder.build().connect(clusterName);
} catch (Exception e) {
- log.error("Connect to Cassandra " + host + ":" + nativePort, e);
+ LOG.error("Connect to Cassandra " + host + ":" + nativePort, e);
throw e;
}
};
@Override
public void stop() {
- log.info("Shutting down Cassandra client");
+ processInfo = null;
+ LOG.info("Shutting down Cassandra client");
cassandraSession.getCluster().shutdown();
- log.info("Shutdown is complete");
+ LOG.info("Shutdown is complete");
}
@Override
public AvailabilityType getAvailability() {
- long start = System.currentTimeMillis();
+ long start = System.nanoTime();
try {
- ResourceContext<?> context = getResourceContext();
- ProcessInfo processInfo = context.getNativeProcess();
-
- if (processInfo == null) {
- return UNKNOWN;
- } else {
- // It is safe to read prior snapshot as getNativeProcess always return a fresh instance
- // ProcessInfoSnapshot processInfoSnaphot = processInfo.freshSnapshot();
- if (processInfo.priorSnaphot().isRunning()) {
- return UP;
- } else {
- return DOWN;
- }
+ // Get a fresh snapshot of the process
+ ProcessInfoSnapshot processInfoSnapshot = (processInfo == null) ? null : processInfo.freshSnapshot();
+ if (processInfoSnapshot == null || !processInfoSnapshot.isRunning()) {
+ processInfo = getResourceContext().getNativeProcess();
+ // Safe to get prior snapshot here, we've just recreated the process info instance
+ processInfoSnapshot = (processInfo == null) ? null : processInfo.priorSnaphot();
}
+ return (processInfoSnapshot != null && processInfoSnapshot.isRunning()) ? AvailabilityType.UP
+ : AvailabilityType.DOWN;
} finally {
- long end = System.currentTimeMillis();
- long totalTime = end - start;
- log.debug("Finished availability check in " + totalTime + " ms");
- if (totalTime > (1000 * 5)) {
- log.warn("Availability check exceeded five seconds. Total time was " + totalTime + " ms");
+ long totalTimeMillis = NANOSECONDS.toMillis(System.nanoTime() - start);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Finished availability check in " + totalTimeMillis + " ms");
+ }
+ if (totalTimeMillis > SECONDS.toMillis(5)) {
+ LOG.warn("Availability check exceeded five seconds. Total time was " + totalTimeMillis + " ms");
}
}
}
@@ -175,28 +170,28 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
protected OperationResult shutdownNode() {
ResourceContext<?> context = getResourceContext();
- if (log.isInfoEnabled()) {
- log.info("Starting shutdown operation on " + CassandraNodeComponent.class.getName() +
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Starting shutdown operation on " + CassandraNodeComponent.class.getName() +
" with resource key " + context.getResourceKey());
}
EmsConnection emsConnection = getEmsConnection();
EmsBean storageService = emsConnection.getBean("org.apache.cassandra.db:type=StorageService");
Class[] emptyParams = new Class[0];
- if (log.isDebugEnabled()) {
- log.debug("Disabling thrift...");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Disabling thrift...");
}
EmsOperation operation = storageService.getOperation("stopRPCServer", emptyParams);
operation.invoke((Object[]) emptyParams);
- if (log.isDebugEnabled()) {
- log.debug("Disabling gossip...");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Disabling gossip...");
}
operation = storageService.getOperation("stopGossiping", emptyParams);
operation.invoke((Object[]) emptyParams);
- if (log.isDebugEnabled()) {
- log.debug("Initiating drain...");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Initiating drain...");
}
operation = storageService.getOperation("drain", emptyParams);
operation.invoke((Object[]) emptyParams);
@@ -207,7 +202,7 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
process.kill("KILL");
return new OperationResult("Successfully shut down Cassandra daemon with pid " + pid);
} catch (SigarException e) {
- log.warn("Failed to shut down Cassandra node with pid " + pid, e);
+ LOG.warn("Failed to shut down Cassandra node with pid " + pid, e);
OperationResult failure = new OperationResult("Failed to shut down Cassandra node with pid " + pid);
failure.setErrorMessage(ThrowableUtil.getAllMessages(e));
return failure;
@@ -256,7 +251,7 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
try {
updateSeedsList(addresses);
} catch (Exception e) {
- log.error("An error occurred while updating the seeds list property", e);
+ LOG.error("An error occurred while updating the seeds list property", e);
Throwable rootCause = ThrowableUtil.getRootCause(e);
result.setErrorMessage(ThrowableUtil.getStackAsString(rootCause));
}
@@ -277,7 +272,7 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
try {
addresses = convertToIPAddresses(seeds);
} catch (UnknownHostException e) {
- log.error("Failed to update seeds list", e);
+ LOG.error("Failed to update seeds list", e);
throw new IOException("Failed to update seeds list. Make sure that " + seeds + " is a list of valid " +
"hostnames or IP addresses that can be resolved.", e);
}
@@ -329,7 +324,7 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
if (!yamlFile.delete()) {
String msg = "Failed to delete [" + yamlFile + "] in preparation of writing updated configuration. The " +
"changes will be aborted.";
- log.error(msg);
+ LOG.error(msg);
deleteYamlBackupFile(yamlFileBackup);
throw new IOException(msg);
}
@@ -339,8 +334,8 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
yaml.dump(cassandraConfig, writer);
deleteYamlBackupFile(yamlFileBackup);
} catch (Exception e) {
- log.error("An error occurred while trying to write the updated configuration back to " + yamlFile, e);
- log.error("Reverting changes to " + yamlFile);
+ LOG.error("An error occurred while trying to write the updated configuration back to " + yamlFile, e);
+ LOG.error("Reverting changes to " + yamlFile);
if (yamlFile.delete()) {
StreamUtil.copy(new FileInputStream(yamlFileBackup), new FileOutputStream(yamlFile));
@@ -348,7 +343,7 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
} else {
String msg = "Failed updates to " + yamlFile.getName() + " cannot be rolled back. The file cannot be " +
"deleted. " + yamlFile + " should be replaced by " + yamlFileBackup;
- log.error(msg);
+ LOG.error(msg);
throw new IOException(msg);
}
} finally {
@@ -367,8 +362,8 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
private void deleteYamlBackupFile(File yamlBackup) {
if (!yamlBackup.delete()) {
- log.warn("Failed to delete Cassandra configuration backup file [" + yamlBackup + "]. This file " +
- "should be deleted.");
+ LOG.warn("Failed to delete Cassandra configuration backup file [" + yamlBackup + "]. This file " +
+ "should be deleted.");
}
}
commit 3f21a52f2eeef0e5b46f9002980e158ff26f21d9
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 11 09:18:02 2013 -0400
don't use $TMPDIR since it might not be defined on all platforms
diff --git a/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh b/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh
index 947155f..8a83320 100755
--- a/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh
+++ b/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh
@@ -23,7 +23,7 @@ PATCH="apache-cassandra-1.2.4-patch-1.jar"
# swap out the Cassandra jar file with the patched version
echo "Copying patch file to $RHQ_SERVER_DIR/rhq-storage/lib"
-mv $RHQ_SERVER_DIR/rhq-storage/lib/apache-cassandra-1.2.4.jar $TMPDIR
+mv $RHQ_SERVER_DIR/rhq-storage/lib/apache-cassandra-1.2.4.jar .
cp $PATCH $RHQ_SERVER_DIR/rhq-storage/lib
# restart the storage node
@@ -54,6 +54,6 @@ $RHQ_SERVER_DIR/bin/rhqctl stop
echo "Removing patch file"
rm $RHQ_SERVER_DIR/rhq-storage/lib/$PATCH
-mv $TMPDIR/apache-cassandra-1.2.4.jar $RHQ_SERVER_DIR/rhq-storage/lib
+mv ./apache-cassandra-1.2.4.jar $RHQ_SERVER_DIR/rhq-storage/lib
echo "Table compression has been disabled for all keyspaces. You are now ready to upgrade your RHQ installation."
commit 9356e5fe02c664fc758376166a95ed4b85a603cb
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Jul 11 11:19:45 2013 +0200
BZ 966294 Further improvements. Also work around BZ 983275
diff --git a/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpInfo.java b/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpInfo.java
index 7b174cc..296696c 100644
--- a/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpInfo.java
+++ b/modules/enterprise/server/plugins/alert-snmp/src/main/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpInfo.java
@@ -37,6 +37,7 @@ public class SnmpInfo {
// Default remote port for SNMP trap
static final String DEFAULT_PORT = "162";
+ private static final String DEFAULT_RHQ_BINDING = "1.3.6.1.4.1.18016.2.1";
final public String host;
final public String port;
@@ -84,8 +85,11 @@ public class SnmpInfo {
if (host==null || host.isEmpty()) {
host = preferences.getSimpleValue("defaultTargetHost",null);
}
- String port = configuration.getSimpleValue(PARAM_PORT, DEFAULT_PORT);
- String oid = configuration.getSimpleValue(PARAM_VARIABLE_BINDING_PREFIX, null); // required
+ String port = configuration.getSimpleValue(PARAM_PORT, null);
+ if (port==null||port.isEmpty()) {
+ port = preferences.getSimpleValue("defaultPort",DEFAULT_PORT);
+ }
+ String oid = configuration.getSimpleValue(PARAM_VARIABLE_BINDING_PREFIX, DEFAULT_RHQ_BINDING); // required
String trapOid = configuration.getSimpleValue(PARAM_TRAP_OID, null);
return new SnmpInfo(host, port, oid, trapOid);
@@ -94,7 +98,7 @@ public class SnmpInfo {
@Override
public String toString() {
String hostString = (host == null ? "UnknownHost" : host);
- String oidString = (oid == null ? "UnknownOID" : oid);
+ String oidString = (oid == null ? "Unknown Binding Prefix" : oid);
String trapOidString = (trapOid == null ? "DefaultTrapOID" : trapOid);
return hostString + ":" + port + " (" + oidString + ") (" + trapOidString + ")";
}
diff --git a/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml
index 3f7a35c..8e2a4cc 100644
--- a/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -25,7 +25,7 @@
</c:property-options>
</c:simple-property>
- <c:simple-property name="defaultTargetHost" displayName="Default trap target host" required="false"/>
+ <c:simple-property name="defaultTargetHost" displayName="Default trap target host" required="false" default="localhost"/>
<c:simple-property name="defaultPort" displayName="Default trap target port" required="false" type="integer"
default="162" defaultValue="162"/>
<c:simple-property name="transport" defaultValue="UDP">
@@ -35,7 +35,7 @@
</c:property-options>
</c:simple-property>
- <c:simple-property name="trapOid" displayName="Trap OID" description="OID for the trap sent" type="string"
+ <c:simple-property name="trapOid" displayName="Trap OID" description="OID of the trap sent" type="string"
default="1.3.6.1.4.1.18016.2.1.2.0.1"/>
<c:simple-property name="community" type="string" default="public" description="Community - v1 and v2c only" required="false"/>
@@ -43,10 +43,10 @@
<c:simple-property name="genericId" required="false" default="6" type="integer"
description="Set the generic trap type. Default is 6 (=Enterprise specific)."/>
- <c:simple-property name="enterpriseOid" required="false" default="1.3.6.1.4.1.18016.2.3"
+ <c:simple-property name="specificId" required="false" default="0" type="integer"
+ description="Enterprise-specific ID of the trap. If this is set, the generic ID must be set to 6."/>
+ <c:simple-property name="enterpriseOid" required="false" default="1.3.6.1.4.1.18016.2.3"
description="OID of the sender, identifies the type of managed object generating the trap. Default is enterprise.jboss.rhq.rhqServer"/>
- <c:simple-property name="specificId" required="false" default="0" type="integer"
- description="Enterprise-specific ID of the trap. If this is set, the generic ID must be set to 6."/>
<c:simple-property name="agentAddress" description="Address of our SNMP agent (=the RHQ server)" required="false"/>
</c:group>
<!--
@@ -91,7 +91,7 @@
sender-wide preferences"/>
<c:simple-property name="port" type="integer" required="false" default="162" description="Trap target port"/>
<c:simple-property name="oid" displayName="Variable bindings prefix" type="string" required="true"
- defaultValue="1.3.6.1.4.1.18016.2.1">
+ defaultValue="1.3.6.1.4.1.18016.2.1" default="1.3.6.1.4.1.18016.2.1">
<c:description>
<![CDATA[
<p>RHQ will send alert notification details as a list of variable bindings in the
@@ -103,11 +103,11 @@
<c:simple-property name="trapOid" required="false">
<c:description>
<![CDATA[
- <p>If set, the value of this paramater will override the value of the Trap Oid parameter defined globally
+ <p>If set, the value of this parameter will override the value of the Trap Oid parameter defined globally
in the server plugin configuration. The Trap OID is sent as the second variable binding in the SNMP trap
PDU.</p>
<p><strong>Only applicable to v2c and v3 traps.</strong></p>
- <p><strong>Do not confuse this paramater with 'Variable bindings prefix'.</strong></p>
+ <p><strong>Do not confuse this parameter with 'Variable bindings prefix'.</strong></p>
]]>
</c:description>
</c:simple-property>
commit 9320e9df35f7dfeba8c6ddcf0dc16df11b2f162b
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 10 22:10:35 2013 -0400
add verification to updateSeedsList resource operation
The updateSeedsList operation will convert each seed to an InetAddress to
1) make sure it is a valid hostname/IP address and 2) convert it to an IP
address to ensure the seeds property in cassandra.yaml uses IP addresses.
diff --git a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
index 5e7692b..90afafb 100644
--- a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
+++ b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
@@ -32,6 +32,8 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -63,7 +65,6 @@ import org.rhq.core.pluginapi.util.ProcessExecutionUtility;
import org.rhq.core.system.ProcessExecution;
import org.rhq.core.system.ProcessExecutionResults;
import org.rhq.core.system.ProcessInfo;
-import org.rhq.core.system.ProcessInfo.ProcessInfoSnapshot;
import org.rhq.core.system.SystemInfo;
import org.rhq.core.util.StringUtil;
import org.rhq.core.util.exception.ThrowableUtil;
@@ -271,7 +272,16 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
return addresses;
}
- protected void updateSeedsList(List<String> addresses) throws IOException {
+ protected void updateSeedsList(List<String> seeds) throws IOException {
+ List<String> addresses = null;
+ try {
+ addresses = convertToIPAddresses(seeds);
+ } catch (UnknownHostException e) {
+ log.error("Failed to update seeds list", e);
+ throw new IOException("Failed to update seeds list. Make sure that " + seeds + " is a list of valid " +
+ "hostnames or IP addresses that can be resolved.", e);
+ }
+
ResourceContext<?> context = getResourceContext();
Configuration pluginConfig = context.getPluginConfiguration();
@@ -346,6 +356,15 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
}
}
+ private List<String> convertToIPAddresses(List<String> seeds) throws UnknownHostException {
+ List<String> ipAddresses = new ArrayList<String>(seeds.size());
+ for (String seed : seeds) {
+ InetAddress address = InetAddress.getByName(seed);
+ ipAddresses.add(address.getHostAddress());
+ }
+ return ipAddresses;
+ }
+
private void deleteYamlBackupFile(File yamlBackup) {
if (!yamlBackup.delete()) {
log.warn("Failed to delete Cassandra configuration backup file [" + yamlBackup + "]. This file " +
diff --git a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
index cac0a8d..3aa701b 100644
--- a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
@@ -75,7 +75,11 @@
</results>
</operation>
- <operation name="updateSeedsList" description="Updatess the node's seeds property in cassandra.yaml">
+ <operation name="updateSeedsList"
+ description="Updates the node's seeds property in cassandra.yaml. seedsList must be a list of valid
+ hostnames or IP addresses that are reachable from the agent machine. Note that if hostnames are
+ specified they will be converted to IP addresses so that the seeds property will consist solely of IP
+ addresses.">
<parameters>
<c:list-property name="seedsList">
<c:simple-property name="seed" type="string"/>
commit 6430ccb39805a3b1de2fe7a57d303a6b640ce059
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 10 21:32:43 2013 -0400
adding custom java dbupgrade task for updating storage node addresss
Forgot to include this file in my previous commit.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/StorageNodeAddressUpgradeTask.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/StorageNodeAddressUpgradeTask.java
new file mode 100644
index 0000000..9fc90ed
--- /dev/null
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/StorageNodeAddressUpgradeTask.java
@@ -0,0 +1,54 @@
+package org.rhq.core.db.upgrade;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.List;
+
+import org.rhq.core.db.DatabaseType;
+import org.rhq.core.db.DbUtilsI18NFactory;
+import org.rhq.core.db.DbUtilsI18NResourceKeys;
+
+import mazz.i18n.Logger;
+
+/**
+ * Updates the address field of storage node entities to ensure we are storing IP addresses and not hostnames. We want
+ * to store the IP address since that is what Cassandra uses for inter-node communication. JMX operations that return
+ * nodes will return the node IP addresses and not hostnames.
+ *
+ * @author John Sanda
+ */
+public class StorageNodeAddressUpgradeTask implements DatabaseUpgradeTask {
+
+ private final Logger log = DbUtilsI18NFactory.getLogger(StorageNodeAddressUpgradeTask.class);
+
+ @Override
+ public void execute(DatabaseType databaseType, Connection connection) throws SQLException {
+ String sql = "SELECT id, address FROM rhq_storage_node";
+
+ log.debug(DbUtilsI18NResourceKeys.EXECUTING_SQL, sql);
+ List<Object[]> results = databaseType.executeSelectSql(connection, sql);
+
+ Integer id = null;
+ String storageNodeAddress = null;
+ try {
+ for (Object[] row : results) {
+ id = (Integer) row[0];
+ storageNodeAddress = (String) row[1];
+ InetAddress address = InetAddress.getByName(storageNodeAddress);
+ if (!storageNodeAddress.equals(address.getHostAddress())) {
+ log.debug(DbUtilsI18NResourceKeys.MESSAGE, "Updating address for StorageNode[id= " + id + ", ]" +
+ "address= " + storageNodeAddress + "]");
+ String update = "UPDATE rhq_storage_node SET address = '" + address.getHostAddress() + "' " +
+ "WHERE id = " + id;
+ log.debug(DbUtilsI18NResourceKeys.EXECUTING_SQL, update);
+ databaseType.executeSql(connection, update);
+ }
+ }
+ } catch (UnknownHostException e) {
+ throw new RuntimeException("Failed to look up IP address for StorageNode[id =" + id + ", address=" +
+ storageNodeAddress + "]", e);
+ }
+ }
+}
commit b1c1f6de18af6c1e598268944e2b41100cbb1a3d
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 10 21:23:06 2013 -0400
make sure that we store the IP address of storage nodes and not hostnames
When doing cluster maintenance on the server, we make calls to get C* node
addresses. C* returns IP addresses since it uses IP addresses for gossip;
consequently, we want to make sure we store the IP address to avoid having to
perform any hostname/IP address mapping.
diff --git a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
index d919ee3..386cda7 100644
--- a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
+++ b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
@@ -132,7 +132,8 @@ public class StorageInstaller {
Option hostname = new Option("n", "hostname", true,
"The hostname or IP address on which the node will listen for "
- + "requests. If not specified, defaults to the hostname for localhost.");
+ + "requests. Note that if a hostname is specified, the IP address is used. Defaults to the IP " +
+ "address of the local host (which depending on hostname configuration may not be localhost).");
hostname.setArgName("HOSTNAME");
Option seeds = new Option("s", "seeds", true, "A comma-delimited list of hostnames or IP addresses that "
@@ -282,7 +283,7 @@ public class StorageInstaller {
}
if (cmdLine.hasOption("n")) {
- hostname = cmdLine.getOptionValue("n");
+ hostname = InetAddress.getByName(cmdLine.getOptionValue("n")).getHostAddress();
} else {
hostname = InetAddress.getLocalHost().getHostAddress();
}
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 356ff48..483688f 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -17,7 +17,7 @@
<description>Database schema setup, upgrade and other utilities</description>
<properties>
- <db.schema.version>2.133</db.schema.version>
+ <db.schema.version>2.134</db.schema.version>
<rhq.ds.type-mapping>${rhq.test.ds.type-mapping}</rhq.ds.type-mapping>
<rhq.ds.server-name>${rhq.test.ds.server-name}</rhq.ds.server-name>
<rhq.ds.db-name>${rhq.test.ds.db-name}</rhq.ds.db-name>
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 0e1afd3..bb5fa50 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2074,6 +2074,11 @@
</schema-directSQL>
</schemaSpec>
+ <schemaSpec version="2.134">
+ <!-- Make sure existing storage nodes are storing IP addresses and not hostnames -->
+ <schema-javaTask className="StorageNodeAddressUpgradeTask" />
+ </schemaSpec>
+
</dbupgrade>
</target>
</project>
commit d124d4589120090628c53c04c6767b948c7a270a
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 10 14:59:57 2013 -0400
remove C* native library dependencies
JNA and lz4-java have been removed from our C* distro. The distro now includes a
version of snappy-java that excludes the native components. We still have to
include snappy-java because C* still has a runtime dependency on snappy-java
classes.
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml b/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml
index 0f6eaca..0b015b4 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml
@@ -97,9 +97,6 @@
<exclude>src/main/resources/cassandra/conf/cassandra-env.sh</exclude>
</excludes>
</resource>
- <!--<resource>-->
- <!--<directory>src/main/cassandra/cql</directory>-->
- <!--</resource>-->
</resources>
<delimiters>
<delimiter>${*}</delimiter>
@@ -110,6 +107,13 @@
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.xerial.snappy</groupId>
+ <artifactId>snappy-java</artifactId>
+ <version>${cassandra.snappy.version}</version>
+ </dependency>
+ </dependencies>
<executions>
<execution>
<!--
@@ -158,12 +162,13 @@
<property name="cassandra.distro.filename" value="cassandra.zip"/>
<property name="cassandra.distro.zip"
value="${project.build.outputDirectory}/${cassandra.distro.filename}"/>
- <copy file="${settings.localRepository}/net/java/dev/jna/platform/${cassandra.jna.version}/platform-${cassandra.jna.version}.jar"
- todir="${cassandra.dir}/lib"/>
- <copy file="${settings.localRepository}/net/java/dev/jna/jna/${cassandra.jna.version}/jna-${cassandra.jna.version}.jar"
+ <delete file="${cassandra.dir}/lib/lz4-1.1.0.jar"/>
+ <delete file="${cassandra.dir}/lib/snappy-java-1.0.4.1.jar"/>
+ <copy file="${settings.localRepository}/org/xerial/snappy/snappy-java/${cassandra.snappy.version}/snappy-java-${cassandra.snappy.version}.jar"
todir="${cassandra.dir}/lib"/>
<move file="${project.build.outputDirectory}/cassandra/conf" todir="${cassandra.dir}"/>
<delete dir="${cassandra.dir}/javadoc"/>
+
<zip basedir="${cassandra.dir}" destfile="${cassandra.distro.zip}"/>
<delete dir="${cassandra.dir}"/>
<delete file="${project.build.outputDirectory}/deploy.xml"/>
@@ -262,65 +267,5 @@
</plugins>
</build>
</profile>
-
- <!--
- Cassandra uses the snappy-java compression library, and it uses a native library that
- is packaged in the snappy-java JAR. Running on Mac OS X with Java 7 will result in,
-
- NoClassDefFoundError Could not initialize class org.xerial.snappy.Snappy
-
- due to the file name extension that the Java 7 JVM looks for on Mac OS X. This issue
- was logged and fixed under https://github.com/xerial/snappy-java/issues/6. Cassandra
- however does not yet bundle a newer version of snappy-java. This profile is activated
- when running on Mac OS X and replaces the packaged version of snappy-java with a newer
- version so that snappy compression can still be used during development. Note that
- this is **not** an issue when running on Java 6.
-
- - jsanda 10/03/2012
- -->
- <profile>
- <id>snappy-mac-workaround</id>
- <activation>
- <os>
- <family>Mac</family>
- </os>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <inherited>false</inherited>
- <dependencies>
- <dependency>
- <groupId>org.xerial.snappy</groupId>
- <artifactId>snappy-java</artifactId>
- <version>1.1.0-M3</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <id>setup-pkg-mac</id>
- <phase>process-resources</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <target>
- <property name="cassandra.dir"
- value="${project.build.outputDirectory}/cassandra-${cassandra.version}"/>
- <property name="cassandra.lib.dir" value="${cassandra.dir}/lib"/>
- <property name="snappy.jar.original" value="${cassandra.lib.dir}/snappy-java-1.0.4.1.jar"/>
- <property name="snappy.jar.updated"
- value="${local.repo}/org/xerial/snappy/snappy-java/${cassandra.driver.snappy.version}/snappy-java-${cassandra.driver.snappy.version}.jar"/>
- <delete file="${snappy.jar.original}"/>
- <copy file="${snappy.jar.updated}" todir="${cassandra.lib.dir}"/>
- </target>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
</profiles>
</project>
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml
index bae3ecc..298db9d 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml
@@ -681,7 +681,7 @@ client_encryption_options:
# can be: all - all traffic is compressed
# dc - traffic between different datacenters is compressed
# none - nothing is compressed.
-internode_compression: all
+internode_compression: none
# Enable or disable tcp_nodelay for inter-dc communication.
# Disabling it will result in larger (but fewer) network packets being sent,
diff --git a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
index 8062d6a..d919ee3 100644
--- a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
+++ b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
@@ -32,6 +32,7 @@ import java.io.FileReader;
import java.io.IOException;
import java.net.InetAddress;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@@ -54,6 +55,7 @@ import org.apache.commons.cli.PosixParser;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.Executor;
import org.apache.commons.exec.PumpStreamHandler;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.io.output.NullOutputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -90,6 +92,8 @@ public class StorageInstaller {
private final Log log = LogFactory.getLog(StorageInstaller.class);
+ private final String VERIFY_DATA_DIRS_EMPTY = "verify-data-dirs-empty";
+
private Options options;
private File serverBasedir;
@@ -191,12 +195,15 @@ public class StorageInstaller {
+ "where the existing RHQ server is installed.");
upgradeOption.setArgName("RHQ_SERVER_DIR");
+ Option verifyDataDirsEmptyOption = new Option(null, VERIFY_DATA_DIRS_EMPTY, true, "Will cause the installer " +
+ "to abort if any of the data directories is not empty. Defaults to true.");
+
options = new Options().addOption(new Option("h", "help", false, "Show this message.")).addOption(hostname)
.addOption(seeds).addOption(jmxPortOption).addOption(startOption).addOption(checkStatus)
.addOption(commitLogOption).addOption(dataDirOption).addOption(savedCachesDirOption)
.addOption(nativeTransportPortOption).addOption(storagePortOption).addOption(sslStoragePortOption)
.addOption(basedirOption).addOption(heapSizeOption).addOption(heapNewSizeOption).addOption(stackSizeOption)
- .addOption(upgradeOption);
+ .addOption(upgradeOption).addOption(verifyDataDirsEmptyOption);
}
public int run(CommandLine cmdLine) throws Exception {
@@ -296,21 +303,25 @@ public class StorageInstaller {
File dataDirFile = new File(dataDir);
File savedCachesDirFile = new File(savedCachesDir);
- // validate the three data directories are empty - if they are not, we are probably stepping on another storage node
- if (!isDirectoryEmpty(commitLogDirFile)) {
- log.error("Commitlog directory is not empty. It should not exist for a new Storage Node ["
- + commitLogDirFile.getAbsolutePath() + "]");
- return STATUS_DATA_DIR_NOT_EMPTY;
- }
- if (!isDirectoryEmpty(dataDirFile)) {
- log.error("Data directory is not empty. It should not exist for a new Storage Node ["
- + dataDirFile.getAbsolutePath() + "]");
- return STATUS_DATA_DIR_NOT_EMPTY;
- }
- if (!isDirectoryEmpty(savedCachesDirFile)) {
- log.error("Saved caches directory is not empty. It should not exist for a new Storage Node ["
- + savedCachesDirFile.getAbsolutePath() + "]");
- return STATUS_DATA_DIR_NOT_EMPTY;
+ boolean verifyDataDirsEmpty = Boolean.valueOf(cmdLine.getOptionValue(VERIFY_DATA_DIRS_EMPTY, "true"));
+ if (verifyDataDirsEmpty) {
+ // validate the three data directories are empty - if they are not, we are probably stepping on
+ // another storage node
+ if (!isDirectoryEmpty(commitLogDirFile)) {
+ log.error("Commitlog directory is not empty. It should not exist for a new Storage Node ["
+ + commitLogDirFile.getAbsolutePath() + "]");
+ return STATUS_DATA_DIR_NOT_EMPTY;
+ }
+ if (!isDirectoryEmpty(dataDirFile)) {
+ log.error("Data directory is not empty. It should not exist for a new Storage Node ["
+ + dataDirFile.getAbsolutePath() + "]");
+ return STATUS_DATA_DIR_NOT_EMPTY;
+ }
+ if (!isDirectoryEmpty(savedCachesDirFile)) {
+ log.error("Saved caches directory is not empty. It should not exist for a new Storage Node ["
+ + savedCachesDirFile.getAbsolutePath() + "]");
+ return STATUS_DATA_DIR_NOT_EMPTY;
+ }
}
jmxPort = getPort(cmdLine, "jmx-port", defaultJmxPort);
@@ -438,12 +449,7 @@ public class StorageInstaller {
}
private boolean isDirectoryEmpty(File dir) {
- if (dir.isDirectory()) {
- File[] files = dir.listFiles();
- return (files == null || files.length == 0);
- } else {
- return true;
- }
+ return FileUtils.sizeOf(dir) == 0;
}
private int getPort(CommandLine cmdLine, String option, int defaultValue) {
@@ -709,12 +715,22 @@ public class StorageInstaller {
}
public void printUsage() {
- Options options = getOptions();
HelpFormatter helpFormatter = new HelpFormatter();
String syntax = "rhq-storage-installer.sh|bat [options]";
String header = "";
- helpFormatter.printHelp(syntax, header, options, null);
+ helpFormatter.printHelp(syntax, header, getHelpOptions(), null);
+ }
+
+ public Options getHelpOptions() {
+ Options helpOptions = new Options();
+ for (Option option : (Collection<Option>)options.getOptions()) {
+ if (option.getLongOpt().equals(VERIFY_DATA_DIRS_EMPTY)) {
+ continue;
+ }
+ helpOptions.addOption(option);
+ }
+ return helpOptions;
}
public Options getOptions() {
diff --git a/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ClusterBuilder.java b/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ClusterBuilder.java
index 4687b4b..14f12e1 100644
--- a/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ClusterBuilder.java
+++ b/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ClusterBuilder.java
@@ -94,9 +94,10 @@ public class ClusterBuilder {
* @see com.datastax.driver.core.Cluster.Builder#build()
*/
public Cluster build() {
- if (compression == null && !isIBMJRE()) {
- builder.withCompression(ProtocolOptions.Compression.SNAPPY);
- }
+// if (compression == null && !isIBMJRE()) {
+// builder.withCompression(ProtocolOptions.Compression.SNAPPY);
+// }
+ builder.withCompression(ProtocolOptions.Compression.NONE);
return builder.build();
}
diff --git a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
index cfe13be..bf06886 100644
--- a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
@@ -243,7 +243,7 @@
toDir="${jboss.modules.dir}/com/datastax/cassandra/cassandra-driver-core/main" verbose="true"/>
<copy file="${settings.localRepository}/org/slf4j/slf4j-log4j12/1.7.2/slf4j-log4j12-1.7.2.jar"
toDir="${jboss.modules.dir}/com/datastax/cassandra/cassandra-driver-core/main" verbose="true"/>
- <copy file="${settings.localRepository}/org/xerial/snappy/snappy-java/1.0.5-M3-p1/snappy-java-1.0.5-M3-p1.jar"
+ <copy file="${settings.localRepository}/org/xerial/snappy/snappy-java/${cassandra.snappy.version}/snappy-java-${cassandra.snappy.version}.jar"
toDir="${jboss.modules.dir}/com/datastax/cassandra/cassandra-driver-core/main" verbose="true"/>
<echo file="${jboss.modules.dir}/com/datastax/cassandra/cassandra-driver-core/main/module.xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
@@ -258,7 +258,7 @@
<resource-root path="metrics-core-2.2.0.jar"/>
<resource-root path="slf4j-api-1.7.2.jar"/>
<resource-root path="slf4j-log4j12-1.7.2.jar"/>
- <resource-root path="snappy-java-1.0.5-M3-p1.jar"/>
+ <resource-root path="snappy-java-${cassandra.snappy.version}.jar"/>
<resource-root path="avro-1.4.0-cassandra-1.jar"/>
</resources>
diff --git a/modules/enterprise/server/appserver/src/main/scripts/storage_setup.groovy b/modules/enterprise/server/appserver/src/main/scripts/storage_setup.groovy
index f8fae7d..ccb90b9 100644
--- a/modules/enterprise/server/appserver/src/main/scripts/storage_setup.groovy
+++ b/modules/enterprise/server/appserver/src/main/scripts/storage_setup.groovy
@@ -97,6 +97,7 @@ heap-new-size=${heapNewSize}
hostname=127.0.0.$nodeId
jmx-port=${defaultJmxPort + (nodeId - 1)}
seeds=${seeds}
+verify-data-dirs-empty=false
"""
)
}
diff --git a/modules/enterprise/server/itests-2/pom.xml b/modules/enterprise/server/itests-2/pom.xml
index 1819f02..a3e9c7b 100644
--- a/modules/enterprise/server/itests-2/pom.xml
+++ b/modules/enterprise/server/itests-2/pom.xml
@@ -326,7 +326,7 @@
toDir="${jboss.modules.dir}/com/datastax/cassandra/cassandra-driver-core/main" verbose="true"/>
<copy file="${settings.localRepository}/org/slf4j/slf4j-log4j12/1.7.2/slf4j-log4j12-1.7.2.jar"
toDir="${jboss.modules.dir}/com/datastax/cassandra/cassandra-driver-core/main" verbose="true"/>
- <copy file="${settings.localRepository}/org/xerial/snappy/snappy-java/1.0.5-M3-p1/snappy-java-1.0.5-M3-p1.jar"
+ <copy file="${settings.localRepository}/org/xerial/snappy/snappy-java/${cassandra.snappy.version}/snappy-java-${cassandra.snappy.version}.jar"
toDir="${jboss.modules.dir}/com/datastax/cassandra/cassandra-driver-core/main" verbose="true"/>
<echo file="${jboss.modules.dir}/com/datastax/cassandra/cassandra-driver-core/main/module.xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
@@ -341,7 +341,7 @@
<resource-root path="metrics-core-2.2.0.jar"/>
<resource-root path="slf4j-api-1.7.2.jar"/>
<resource-root path="slf4j-log4j12-1.7.2.jar"/>
- <resource-root path="snappy-java-1.0.5-M3-p1.jar"/>
+ <resource-root path="snappy-java-${cassandra.snappy.version}.jar"/>
<resource-root path="avro-1.4.0-cassandra-1.jar"/>
</resources>
diff --git a/modules/plugins/cassandra/pom.xml b/modules/plugins/cassandra/pom.xml
index 76a781d..da90f09 100644
--- a/modules/plugins/cassandra/pom.xml
+++ b/modules/plugins/cassandra/pom.xml
@@ -27,7 +27,7 @@
<dependency>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
- <version>1.0.5-M3-p1</version>
+ <version>${cassandra.snappy.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cassandra</groupId>
@@ -141,7 +141,7 @@
<artifactItem>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
- <version>1.0.5-M3-p1</version>
+ <version>${cassandra.snappy.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.codehaus.jackson</groupId>
diff --git a/pom.xml b/pom.xml
index 99c1bdc..d52dcc7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -179,7 +179,7 @@
<cassandra.thrift.version>0.7.0</cassandra.thrift.version>
<cassandra.driver.version>1.0.0-rhq-1.2.4</cassandra.driver.version>
<cassandra.driver.netty.version>3.6.3.Final</cassandra.driver.netty.version>
- <cassandra.driver.snappy.version>1.0.5-M3-p1</cassandra.driver.snappy.version>
+ <cassandra.snappy.version>1.0.4.1-rhq-p1</cassandra.snappy.version>
<cassandra.snakeyaml.version>1.6</cassandra.snakeyaml.version>
<rhq.db.admin.username>rhqadmin</rhq.db.admin.username>
commit 3783018826b0ebbe069751842cde15e75bc29bb2
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Wed Jul 10 18:44:17 2013 +0200
[BZ 966293] - Add validation for expression when creating Dynagroup Definition - adding a check to GroupDefinitionManagerBean.validate() method. Also making sure, the right message is correctly propagated to the web UI.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
index 74484dd..fed6e32 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java
@@ -130,7 +130,13 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition, Re
@Override
public void onFailure(Throwable caught) {
Map<String, String> errors = new HashMap<String, String>();
- errors.put("name", MSG.view_dynagroup_definitionAlreadyExists());
+ String msg = caught.getMessage();
+ String cannotParse = "Cannot parse the expression: ";
+ if (msg != null && msg.contains(cannotParse)) {
+ errors.put("expression", msg.substring(msg.indexOf(cannotParse) + cannotParse.length()));
+ } else {
+ errors.put("name", MSG.view_dynagroup_definitionAlreadyExists());
+ }
response.setErrors(errors);
response.setStatus(RPCResponse.STATUS_VALIDATION_ERROR);
processResponse(request.getRequestId(), response);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
index 1afa30d..7b36717 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
@@ -199,6 +199,7 @@ public class SingleGroupDefinitionView extends EnhancedVLayout implements Bookma
@Override
public void execute(DSResponse response, Object rawData, DSRequest request) {
boolean hasDuplicateNameError = false;
+ boolean hasParseExpressionError = false;
if (form.isNewRecord()) {
Record[] results = response.getData();
if (results.length != 1) {
@@ -212,10 +213,14 @@ public class SingleGroupDefinitionView extends EnhancedVLayout implements Bookma
String errorValue = (String) thisEntry.getValue();
CoreGUI.getErrorHandler().handleError(errorValue);
hasDuplicateNameError = true;
+ } else if (fieldKey.equals("expression")) {
+ String errorValue = (String) thisEntry.getValue();
+ CoreGUI.getErrorHandler().handleError(errorValue);
+ hasParseExpressionError = true;
}
}
- if (!hasDuplicateNameError) {
+ if (!hasDuplicateNameError && !hasParseExpressionError) {
CoreGUI.getErrorHandler().handleError(
MSG.view_dynagroup_singleSaveFailure(String.valueOf(results.length)));
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
index a276efb..373368c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
@@ -175,11 +175,6 @@ public class GroupDefinitionManagerBean implements GroupDefinitionManagerLocal,
throw new GroupDefinitionUpdateException(gde.getMessage());
}
- ExpressionEvaluator evaluator = new ExpressionEvaluator();
- for (String expression : groupDefinition.getExpressionAsList()) {
- evaluator.addExpression(expression);
- }
-
RecursivityChangeType changeType = RecursivityChangeType.None;
GroupDefinition attachedGroupDefinition = null;
try {
@@ -251,6 +246,15 @@ public class GroupDefinitionManagerBean implements GroupDefinitionManagerLocal,
if (definition.getExpression() == null || definition.getExpression().isEmpty()) {
throw new GroupDefinitionException("Expression is empty");
}
+
+ try {
+ ExpressionEvaluator evaluator = new ExpressionEvaluator();
+ for (String expression : definition.getExpressionAsList()) {
+ evaluator.addExpression(expression);
+ }
+ } catch (InvalidExpressionException e) {
+ throw new GroupDefinitionException("Cannot parse the expression: " + e.getMessage());
+ }
Query query = entityManager.createNamedQuery(GroupDefinition.QUERY_FIND_BY_NAME);
query.setParameter("name", name);
commit 0d1662bbbec85dbbb820cc8e778963015027caa2
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Wed Jul 10 17:33:48 2013 +0200
[BZ 976265] - Unable to remove one dynagroup definition - Anotating method GroupDefinitionManagerBean.updateGroupDefinition() with @TransactionAttribute.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
index bb425f6..a276efb 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
@@ -162,6 +162,8 @@ public class GroupDefinitionManagerBean implements GroupDefinitionManagerLocal,
}
@RequiredPermission(Permission.MANAGE_INVENTORY)
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ // required for the recalculation thread (same like calculateGroupMembership) this fixes BZ 976265
public GroupDefinition updateGroupDefinition(Subject subject, GroupDefinition groupDefinition)
throws GroupDefinitionAlreadyExistsException, GroupDefinitionUpdateException, InvalidExpressionException,
ResourceGroupUpdateException {
commit 627c48a7a18a03d9a91032a32c1833d4fcbae86a
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Wed Jul 10 17:10:04 2013 +0200
[BZ 974501] - Its possible to create a dynaGroup definition without expression via CLI - check whether expression is null of an empty string
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
index bb2587f..bb425f6 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
@@ -230,27 +230,25 @@ public class GroupDefinitionManagerBean implements GroupDefinitionManagerLocal,
if (name.equals("")) {
throw new GroupDefinitionException("Name is a required property");
}
-
if (name.length() > 100) {
throw new GroupDefinitionException("Name is limited to 100 characters");
}
-
if (description.length() > 100) {
throw new GroupDefinitionException("Description is limited to 100 characters");
}
-
if (name.contains("<") || name.contains("$") || name.contains("'") || name.contains("{") || name.contains("[")) {
throw new GroupDefinitionException("Name must not contain <,$,',[,{ characters");
}
-
if (definition.getRecalculationInterval() < 0) {
throw new GroupDefinitionException("Recalculation interval cannot be negative");
}
-
if (definition.getRecalculationInterval() > 0 && definition.getRecalculationInterval() < 60 * 1000) {
throw new GroupDefinitionException(
"Recalculation interval cannot be a positive number lower than 1 minute (60000ms)");
}
+ if (definition.getExpression() == null || definition.getExpression().isEmpty()) {
+ throw new GroupDefinitionException("Expression is empty");
+ }
Query query = entityManager.createNamedQuery(GroupDefinition.QUERY_FIND_BY_NAME);
query.setParameter("name", name);
commit d1f030ca0033ce7d7a7ea4ab223214789118de99
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 10 10:48:16 2013 -0400
add some basic argument validation
The script now takes as arguments the rhq server directory, the ip address of
the storage node, the cql port, and the jmx port.
diff --git a/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh b/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh
index 756ba20..947155f 100755
--- a/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh
+++ b/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh
@@ -1,14 +1,23 @@
#!/bin/bash
-if [ "x$1" = "x" ]; then
- echo "Usage: $0 <rhq-server-dir>"
+function usage() {
+ echo "Usage: $0 <rhq-server-dir> <storage-ip-address> <cql-port> <jmx-port>"
+}
+
+if [ $# -ne 4 ]; then
+ usage
+ exit 1
+fi
+
+if [[ "x$1" = "x" ]] || [[ "x$2" = "x" ]] || [[ "x$3" = "x" ]] || [[ "x$4" = "x" ]]; then
+ usage
exit 1
fi
RHQ_SERVER_DIR=$1
CQL_HOSTNAME=$2
-CQL_PORT=9142
-JMX_PORT=7299
+CQL_PORT=$3
+JMX_PORT=$4
PATCH="apache-cassandra-1.2.4-patch-1.jar"
commit 08f7934eecde748578f075d26018fcc348693fae
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Wed Jul 10 16:44:00 2013 +0200
[BZ 977782] - Incorrect error message is shown when creating a new dynaGroup definition with incorrect name - added regexp validator to the coregui.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
index 99e0192..1afa30d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
@@ -56,6 +56,8 @@ import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import com.smartgwt.client.widgets.form.fields.events.FormItemClickHandler;
import com.smartgwt.client.widgets.form.fields.events.FormItemIconClickEvent;
+import com.smartgwt.client.widgets.form.validator.RegExpValidator;
+import com.smartgwt.client.widgets.form.validator.Validator;
import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.HoverCustomizer;
import com.smartgwt.client.widgets.grid.ListGrid;
@@ -82,10 +84,10 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions.GroupDefinitionExpressionBuilder.AddExpressionHandler;
import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
-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.enhanced.EnhancedIButton;
import org.rhq.enterprise.gui.coregui.client.util.enhanced.EnhancedVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
/**
* @author Joseph Marques
@@ -136,6 +138,10 @@ public class SingleGroupDefinitionView extends EnhancedVLayout implements Bookma
description.setValue(groupDefinition.getDescription());
recalculationInterval.setValue(groupDefinition.getRecalculationInterval() / (60 * 1000));
expression.setValue(groupDefinition.getExpression());
+
+ Validator nameValidator = new RegExpValidator("^[^\\<\\$\\'\\{\\[]{1,100}$");
+ nameValidator.setErrorMessage("Name must not contain following characters: < $ ' [ {");
+ name.setValidators(nameValidator);
final DynamicForm form = new DynamicForm();
form.setFields(id, name, description, templateSelectorTitleSpacer, templateSelector, expression, recursive,
commit fa8e8225c6777c5d7e57c25aae3b80a180cbc58b
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Wed Jul 10 14:54:21 2013 +0200
[BZ 975502] - Its possible to create a dynaGroup definition with recalculation Interval < 1 minute via CLI - added simple checks to the GroupDefinitionManagerBean.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
index 8713928..bb2587f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
@@ -242,6 +242,15 @@ public class GroupDefinitionManagerBean implements GroupDefinitionManagerLocal,
if (name.contains("<") || name.contains("$") || name.contains("'") || name.contains("{") || name.contains("[")) {
throw new GroupDefinitionException("Name must not contain <,$,',[,{ characters");
}
+
+ if (definition.getRecalculationInterval() < 0) {
+ throw new GroupDefinitionException("Recalculation interval cannot be negative");
+ }
+
+ if (definition.getRecalculationInterval() > 0 && definition.getRecalculationInterval() < 60 * 1000) {
+ throw new GroupDefinitionException(
+ "Recalculation interval cannot be a positive number lower than 1 minute (60000ms)");
+ }
Query query = entityManager.createNamedQuery(GroupDefinition.QUERY_FIND_BY_NAME);
query.setParameter("name", name);
commit d61c77462f80bf1f8164341e58783ab75d3ff5f0
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Jul 10 09:17:57 2013 -0500
AllDataFileLocations is not a metric and thus no need to change the collection interval.
diff --git a/modules/enterprise/server/plugins/alertdef-rhq/src/main/java/org/rhq/enterprise/server/plugins/alertdef/AlertDefinitionServerPluginComponent.java b/modules/enterprise/server/plugins/alertdef-rhq/src/main/java/org/rhq/enterprise/server/plugins/alertdef/AlertDefinitionServerPluginComponent.java
index 1cff654..dcfdc37 100644
--- a/modules/enterprise/server/plugins/alertdef-rhq/src/main/java/org/rhq/enterprise/server/plugins/alertdef/AlertDefinitionServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/alertdef-rhq/src/main/java/org/rhq/enterprise/server/plugins/alertdef/AlertDefinitionServerPluginComponent.java
@@ -62,7 +62,6 @@ public class AlertDefinitionServerPluginComponent implements ServerPluginCompone
private final Log log = LogFactory.getLog(AlertDefinitionServerPluginComponent.class);
private static final String PARTITION_DISK_USED_PERCENTAGE_METRIC_NAME = "Calculated.PartitionDiskUsedPercentage";
- private static final String DATA_FILE_LOCATIONS_NAME = "AllDataFileLocations";
static private final List<InjectedTemplate> injectedTemplates;
static private final InjectedTemplate storageNodeHighHeapTemplate;
@@ -309,8 +308,6 @@ public class AlertDefinitionServerPluginComponent implements ServerPluginCompone
measurementDefinitionIds.add(d.getId());
ac.setMeasurementDefinition(d);
ac.setName(d.getDisplayName());
- } else if (DATA_FILE_LOCATIONS_NAME.equals(d.getName())) {
- measurementDefinitionIds.add(d.getId());
}
}
assert null != ac.getMeasurementDefinition() : "Did not find expected measurement definition "
@@ -331,7 +328,8 @@ public class AlertDefinitionServerPluginComponent implements ServerPluginCompone
// is set by default.
MeasurementScheduleManagerLocal measurementManager = LookupUtil.getMeasurementScheduleManager();
measurementManager.updateDefaultCollectionIntervalAndEnablementForMeasurementDefinitions(
- subjectManager.getOverlord(), ArrayUtils.toPrimitive(measurementDefinitionIds.toArray(new Integer[2])),
+ subjectManager.getOverlord(),
+ ArrayUtils.toPrimitive(measurementDefinitionIds.toArray(new Integer[measurementDefinitionIds.size()])),
60000L, true, true);
return newTemplateId;
commit 5b0415a3703ce56bbc27fd348c9808e446207fed
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Wed Jul 10 15:52:07 2013 +0200
Bug 910646 - Unable to add more than 100 resources to a Compatible Group
Add integration test and throw UnsupportedOperationException if criteria has unlimited PageControl
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/test/GroupMemberCandidateResourcesTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/test/GroupMemberCandidateResourcesTest.java
new file mode 100644
index 0000000..3447799
--- /dev/null
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/test/GroupMemberCandidateResourcesTest.java
@@ -0,0 +1,190 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.enterprise.server.resource.test;
+
+import static org.rhq.core.domain.util.PageOrdering.ASC;
+
+import java.util.Arrays;
+
+import javax.ejb.EJBException;
+
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
+import org.rhq.enterprise.server.resource.ResourceManagerLocal;
+import org.rhq.enterprise.server.test.AbstractEJB3Test;
+import org.rhq.enterprise.server.test.TransactionCallback;
+import org.rhq.enterprise.server.util.LookupUtil;
+import org.rhq.enterprise.server.util.SessionTestHelper;
+
+/**
+ * @author Thomas Segismont
+ */
+public class GroupMemberCandidateResourcesTest extends AbstractEJB3Test {
+
+ private static final String GROUP_MEMBER_CANDIDATE_NAME_PREFIX = GroupMemberCandidateResourcesTest.class
+ .getSimpleName() + "-";
+
+ private Subject overlord;
+
+ private ResourceManagerLocal resourceManager;
+
+ @Override
+ protected void beforeMethod() throws Exception {
+ SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
+ overlord = subjectManager.getOverlord();
+ resourceManager = LookupUtil.getResourceManager();
+ }
+
+ @Test
+ public void testNoCandidates() {
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.setCaseSensitive(false);
+ criteria.addFilterName(GROUP_MEMBER_CANDIDATE_NAME_PREFIX);
+
+ PageList<Resource> groupMemberCandidateResources = resourceManager.findGroupMemberCandidateResources(
+ overlord, criteria, new int[0]);
+
+ assertEquals(0, groupMemberCandidateResources.getTotalSize());
+ assertEquals(0, groupMemberCandidateResources.size());
+ }
+ });
+ }
+
+ @Test
+ public void testNoCandidatesWithExclusions() {
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.setCaseSensitive(false);
+ criteria.addFilterName(GROUP_MEMBER_CANDIDATE_NAME_PREFIX);
+ int[] alreadySelectedResourceIds = new int[100];
+ for (int i = 0; i < alreadySelectedResourceIds.length; i++) {
+ alreadySelectedResourceIds[i] = i;
+ }
+
+ PageList<Resource> groupMemberCandidateResources = resourceManager.findGroupMemberCandidateResources(
+ overlord, criteria, alreadySelectedResourceIds);
+
+ assertEquals(0, groupMemberCandidateResources.getTotalSize());
+ assertEquals(0, groupMemberCandidateResources.size());
+ }
+ });
+ }
+
+ @Test
+ public void testUnlimitedPageControl() {
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.setPageControl(PageControl.getUnlimitedInstance());
+
+ try {
+ PageList<Resource> groupMemberCandidateResources = resourceManager
+ .findGroupMemberCandidateResources(overlord, criteria, new int[0]);
+ fail("findGroupMemberCandidateResources should throw UnsupportedOperationException");
+ } catch (EJBException e) {
+ assertTrue(e.getCausedByException() instanceof UnsupportedOperationException);
+ }
+ }
+ });
+ }
+
+ @Test
+ public void testPageControl() {
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ int resourcesCount = 100;
+ createTestResources(resourcesCount);
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.setCaseSensitive(false);
+ criteria.addFilterName(GROUP_MEMBER_CANDIDATE_NAME_PREFIX);
+ criteria.addSortName(ASC);
+ int pageNumber = 5;
+ int pageSize = 7;
+ criteria.setPaging(pageNumber, pageSize);
+
+ PageList<Resource> groupMemberCandidateResources = resourceManager.findGroupMemberCandidateResources(
+ overlord, criteria, new int[0]);
+
+ assertEquals(resourcesCount, groupMemberCandidateResources.getTotalSize());
+ assertEquals(pageSize, groupMemberCandidateResources.size());
+ for (Resource groupMemberCandidateResource : groupMemberCandidateResources) {
+ assertTrue(groupMemberCandidateResource.getName().startsWith(GROUP_MEMBER_CANDIDATE_NAME_PREFIX));
+ }
+ assertEquals(pageNumber, groupMemberCandidateResources.getPageControl().getPageNumber());
+ assertEquals(pageSize, groupMemberCandidateResources.getPageControl().getPageSize());
+ }
+ });
+ }
+
+ @Test
+ public void testPageControlWithExclusions() {
+ executeInTransaction(new TransactionCallback() {
+ @Override
+ public void execute() throws Exception {
+ int resourcesCount = 100;
+ int[] resourcesIds = createTestResources(resourcesCount);
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.setCaseSensitive(false);
+ criteria.addFilterName(GROUP_MEMBER_CANDIDATE_NAME_PREFIX);
+ criteria.addSortName(ASC);
+ int pageNumber = 5;
+ int pageSize = 7;
+ criteria.setPaging(pageNumber, pageSize);
+ int[] alreadySelectedResourceIds = Arrays.copyOfRange(resourcesIds, 13, 59);
+
+ PageList<Resource> groupMemberCandidateResources = resourceManager.findGroupMemberCandidateResources(
+ overlord, criteria, alreadySelectedResourceIds);
+
+ assertEquals(resourcesCount, groupMemberCandidateResources.getTotalSize());
+ assertEquals(pageSize, groupMemberCandidateResources.size());
+ for (Resource groupMemberCandidateResource : groupMemberCandidateResources) {
+ assertTrue(groupMemberCandidateResource.getName().startsWith(GROUP_MEMBER_CANDIDATE_NAME_PREFIX));
+ }
+ assertEquals(pageNumber, groupMemberCandidateResources.getPageControl().getPageNumber());
+ assertEquals(pageSize, groupMemberCandidateResources.getPageControl().getPageSize());
+ }
+ });
+ }
+
+ private int[] createTestResources(int resourcesCount) {
+ int[] resourcesIds = new int[resourcesCount];
+ ResourceType testResourceType = SessionTestHelper.createNewResourceType(em);
+ for (int i = 0; i < resourcesCount; i++) {
+ resourcesIds[i] = SessionTestHelper.createNewResource(em, GROUP_MEMBER_CANDIDATE_NAME_PREFIX + i,
+ testResourceType).getId();
+ }
+ return resourcesIds;
+ }
+
+}
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 0c8594d..0aa09a4 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
@@ -2930,10 +2930,14 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
public PageList<Resource> findGroupMemberCandidateResources(Subject subject, ResourceCriteria criteria,
int[] alreadySelectedResourceIds) {
+ PageControl originalPageControl = getPageControl(criteria);
+ if (originalPageControl.isUnlimited()) {
+ throw new UnsupportedOperationException("Supplied criteria has an unlimited PageControl");
+ }
+
Set<Integer> alreadySelectedResourceIdSet = new HashSet<Integer>(
- ArrayUtils.wrapInList(alreadySelectedResourceIds));
+ ArrayUtils.wrapInList(alreadySelectedResourceIds == null ? new int[0] : alreadySelectedResourceIds));
- PageControl originalPageControl = getPageControl(criteria);
PageControl pageControl = (PageControl) originalPageControl.clone();
criteria.setPageControl(pageControl);
commit 07e921660b7336a96593c71b3bb57624f7645396
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jul 10 09:05:05 2013 +0200
Don't bail out on empty plugin description. Bump default pom version
diff --git a/modules/helpers/pluginGen/src/main/resources/descriptor.ftl b/modules/helpers/pluginGen/src/main/resources/descriptor.ftl
index a62af11..85195e8 100644
--- a/modules/helpers/pluginGen/src/main/resources/descriptor.ftl
+++ b/modules/helpers/pluginGen/src/main/resources/descriptor.ftl
@@ -22,7 +22,11 @@
<?xml version="1.0"?>
<plugin name="${props.pluginName}"
displayName="${props.pluginName}Plugin"
+<#if props.pluginDescription??>
description="${props.pluginDescription}"
+<#else>
+ description="TODO provide a description for the plugin"
+</#if>
<#if props.usePluginLifecycleListenerApi>
pluginLifecycleListener="${props.componentClass}"
</#if>
diff --git a/modules/helpers/pluginGen/src/main/resources/pom.ftl b/modules/helpers/pluginGen/src/main/resources/pom.ftl
index 2434ddd..01daca1 100644
--- a/modules/helpers/pluginGen/src/main/resources/pom.ftl
+++ b/modules/helpers/pluginGen/src/main/resources/pom.ftl
@@ -31,7 +31,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version><#if props.rhqVersion??>${props.rhqVersion}<#else >4.5.0-SNAPSHOT</#if></version><!-- TODO adjust RHQ version -->
+ <version><#if props.rhqVersion??>${props.rhqVersion}<#else >4.9.0-SNAPSHOT</#if></version><!-- TODO adjust RHQ version -->
</parent>
<groupId>org.rhq</groupId>
@@ -49,8 +49,8 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
- <source>1.5</source>
- <target>1.5</target>
+ <source>1.6</source>
+ <target>1.6</target>
</configuration>
</plugin>
commit 206bc37502ef973145cf689b3a077722bb8bf2e9
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jul 10 08:49:08 2013 +0200
BZ 981809 Disable compression when wrapping. Also some cleanup in the file.
diff --git a/modules/enterprise/gui/rest-war/src/main/java/org/rhq/enterprise/rest/JsonPFilter.java b/modules/enterprise/gui/rest-war/src/main/java/org/rhq/enterprise/rest/JsonPFilter.java
index 3a785fd..8d43f03 100644
--- a/modules/enterprise/gui/rest-war/src/main/java/org/rhq/enterprise/rest/JsonPFilter.java
+++ b/modules/enterprise/gui/rest-war/src/main/java/org/rhq/enterprise/rest/JsonPFilter.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* 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.
+ * 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.rest;
@@ -45,6 +45,9 @@ import javax.servlet.http.HttpServletResponseWrapper;
/**
* A filter to wrap json answers as jsonp
+ * For this to happen, the user has to pass ?<filter.jsonp.callback>=<name> in the url like
+ * <pre>http://localhost:7080/rest/metric/data/10001/raw.json?jsonp=foo</pre>
+ * The <filter.jsonp.callback> is defined in web.xml and defaults to 'jsonp'.
* @author Heiko W. Rupp
*/
public class JsonPFilter implements Filter {
@@ -132,7 +135,6 @@ public class JsonPFilter implements Filter {
private static class JsonPRequestWrapper extends HttpServletRequestWrapper {
int contentLength;
BufferedReader reader;
- String method;
ByteArrayInputStream bais;
Map<String, String> headers = new HashMap<String, String>();
@@ -147,6 +149,11 @@ public class JsonPFilter implements Filter {
Enumeration headers = request.getHeaderNames();
while (headers.hasMoreElements()) {
String key = (String) headers.nextElement();
+ if (key.equalsIgnoreCase("Accept-Encoding")) {
+ // Filter Content codings like compression, as we would end up
+ // with compressed inner data and uncompressed wrapper
+ continue;
+ }
String value = request.getHeader(key);
this.headers.put(key, value);
}
@@ -157,14 +164,6 @@ public class JsonPFilter implements Filter {
}
-/*
- public void setBody(String body) {
- bais = new ByteArrayInputStream(body.getBytes());
- contentLength = body.length();
- headers.put("content-length", Integer.toString(contentLength));
- }
-*/
-
@Override
public BufferedReader getReader() throws IOException {
reader = new BufferedReader(new InputStreamReader(bais));
commit 1d75e54e136107c19d0b1163feb69e64993f7944
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jul 9 17:46:46 2013 +0200
Bump pom versions. Allow to start the generator via mvn exec:java
diff --git a/modules/helpers/pluginAnnotations/pom.xml b/modules/helpers/pluginAnnotations/pom.xml
index be5e976..7ce1859 100644
--- a/modules/helpers/pluginAnnotations/pom.xml
+++ b/modules/helpers/pluginAnnotations/pom.xml
@@ -7,14 +7,14 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.8.0-SNAPSHOT</version>
+ <version>4.9.0-SNAPSHOT</version>
<relativePath>../../../pom.xml</relativePath>
</parent>
<groupId>org.rhq.helpers</groupId>
<artifactId>rhq-pluginAnnotations</artifactId>
<packaging>jar</packaging>
- <version>4.8.0-SNAPSHOT</version>
+ <version>4.9.0-SNAPSHOT</version>
<name>RHQ plugin annotations</name>
<description>Annotations to help generate plugin descriptors</description>
diff --git a/modules/helpers/pluginGen/pom.xml b/modules/helpers/pluginGen/pom.xml
index fb2cce6..e9a5e29 100644
--- a/modules/helpers/pluginGen/pom.xml
+++ b/modules/helpers/pluginGen/pom.xml
@@ -7,14 +7,14 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
- <version>4.8.0-SNAPSHOT</version>
+ <version>4.9.0-SNAPSHOT</version>
<relativePath>../../../pom.xml</relativePath>
</parent>
<groupId>org.rhq.helpers</groupId>
<artifactId>rhq-pluginGen</artifactId>
<packaging>jar</packaging>
- <version>4.8.0-SNAPSHOT</version>
+ <version>4.9.0-SNAPSHOT</version>
<name>RHQ plugin generator</name>
<description>Helper to generate plugin skeletons</description>
@@ -62,6 +62,22 @@
<version>2.1</version>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2.1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <mainClass>org.rhq.helpers.pluginGen.PluginGen</mainClass>
+ </configuration>
+ </plugin>
+
</plugins>
</build>
10 years, 9 months
[rhq] modules/enterprise
by Larry O'Leary
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/ldap/FakeLdapContext.java | 37 ++++------
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java | 1
2 files changed, 18 insertions(+), 20 deletions(-)
New commits:
commit 567aee7f81c6aa0f7680d4f394cccb1974705320
Author: Larry O'Leary <loleary(a)redhat.com>
Date: Mon Jul 22 16:10:09 2013 -0500
BZ 981015: Fix test failures introduced by commit 01cd91b
- findLdapUserDetails was appending baseDN twice during fallback code
- FakeLdapContext contained some lazy escaping on the mock group entries
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/ldap/FakeLdapContext.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/ldap/FakeLdapContext.java
index dad31ce..2ae6265 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/ldap/FakeLdapContext.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/ldap/FakeLdapContext.java
@@ -99,7 +99,6 @@ public class FakeLdapContext implements LdapContext {
try {
return new FakeNamingEnumeration<SearchResult>(ldapTestData.getSearchResults(attributes));
} catch (Exception e) {
- // TODO Auto-generated catch block
e.printStackTrace();
return null;
}
@@ -516,12 +515,12 @@ public class FakeLdapContext implements LdapContext {
attr = new BasicAttribute("member");
attr.add("cn=Robert Smith,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Cannon\\, Brett,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
- attr.add("cn=Charles H\\\\Samlin,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
+ attr.add("cn=Charles H\\Samlin,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Craig \\#1 Sellers,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Beverly \\+1 Balanger,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Bethany \\<Stuart\\> Wallace,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Zachory S\\; Balanger,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
- attr.add("cn=Allen \\\"The Hammer\\\" Callen,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
+ attr.add("cn=Allen \"The Hammer\" Callen,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Sam Not \\= Smitherson,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=\\ Billy The Kiddough\\ ,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=System/Integration API,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
@@ -557,12 +556,12 @@ public class FakeLdapContext implements LdapContext {
attr = new BasicAttribute("member");
attr.add("cn=John Smith,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Dr. Greg Hause\\, MD,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
- attr.add("cn=Cindy\\\\Cynthia Groober,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
+ attr.add("cn=Cindy\\Cynthia Groober,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Biff \\# Rogers,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Steven \\+2 Reed,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Lisa \\<The Great\\> Toller,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Homer J Simpsonite\\; III,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
- attr.add("cn=Jessica \\\"Crouching Tiger\\\" Mathers,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
+ attr.add("cn=Jessica \"Crouching Tiger\" Mathers,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Hope \\= Rein,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=\\ Sue Ferguson\\ ,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Phil/Susan Carlson,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
@@ -598,12 +597,12 @@ public class FakeLdapContext implements LdapContext {
attr = new BasicAttribute("member");
attr.add("cn=Sheri Smith,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Walsh\\, Brad,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
- attr.add("cn=Jim\\\\James Kirk,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
+ attr.add("cn=Jim\\James Kirk,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Sandra \\# Phillips,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=William Tell Overture \\+1,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Craig \\<Bison\\> Allen,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Walter T Fredrick\\; The Second,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
- attr.add("cn=Stanley \\\"Short\\\" Mein,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
+ attr.add("cn=Stanley \"Short\" Mein,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=Noah \\= Sadler,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=\\ Stuart Smiley\\ ,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
attr.add("cn=System/Integration API 2,ou=users,dc=test,dc=rhq,dc=redhat,dc=com");
@@ -984,7 +983,7 @@ public class FakeLdapContext implements LdapContext {
attr.add("User with backslash (\\) in 'cn' in the RHQ Admin Group");
attrs.put(attr);
- sr = new SearchResult("cn=Charles H\\\\Samlin,ou=users", null, null, attrs, true);
+ sr = new SearchResult("cn=Charles H\\Samlin,ou=users", null, null, attrs, true);
this.add(sr);
// dn: cn=Cindy\\Cynthia Groober,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
@@ -1033,7 +1032,7 @@ public class FakeLdapContext implements LdapContext {
attr.add("User with backslash (\\) in 'cn' in the JBoss Admin Group");
attrs.put(attr);
- sr = new SearchResult("cn=Cindy\\\\Cynthia Groober,ou=users", null, null, attrs, true);
+ sr = new SearchResult("cn=Cindy\\Cynthia Groober,ou=users", null, null, attrs, true);
this.add(sr);
// dn: cn=Jim\\James Kirk,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
@@ -1082,7 +1081,7 @@ public class FakeLdapContext implements LdapContext {
attr.add("User with backslash (\\) in 'cn' in the JBoss Monitor Group");
attrs.put(attr);
- sr = new SearchResult("cn=Jim\\\\James Kirk,ou=users", null, null, attrs, true);
+ sr = new SearchResult("cn=Jim\\James Kirk,ou=users", null, null, attrs, true);
this.add(sr);
// dn: cn=Craig \#1 Sellers,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
@@ -1675,7 +1674,7 @@ public class FakeLdapContext implements LdapContext {
null, attrs, true);
this.add(sr);
- // dn: cn=Allen \"The Hammer\" Callen,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
+ // dn: cn=Allen "The Hammer" Callen,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
attrs = new BasicAttributes();
attr = new BasicAttribute("baseName");
@@ -1721,11 +1720,11 @@ public class FakeLdapContext implements LdapContext {
attr.add("User with quote (\") in 'cn' in the RHQ Admin Group");
attrs.put(attr);
- sr = new SearchResult("cn=Allen \\\"The Hammer\\\" Callen,ou=users", "javax.naming.directory.DirContext",
+ sr = new SearchResult("cn=Allen \"The Hammer\" Callen,ou=users", "javax.naming.directory.DirContext",
null, attrs, true);
this.add(sr);
- // dn: cn=Jessica \"Crouching Tiger\" Mathers,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
+ // dn: cn=Jessica "Crouching Tiger" Mathers,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
attrs = new BasicAttributes();
attr = new BasicAttribute("baseName");
@@ -1771,11 +1770,11 @@ public class FakeLdapContext implements LdapContext {
attr.add("User with quote (\") in 'cn' in the JBoss Admin Group");
attrs.put(attr);
- sr = new SearchResult("cn=Jessica \\\"Crouching Tiger\\\" Mathers,ou=users",
+ sr = new SearchResult("cn=Jessica \"Crouching Tiger\" Mathers,ou=users",
"javax.naming.directory.DirContext", null, attrs, true);
this.add(sr);
- // dn: cn=Stanley \"Short\" Mein,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
+ // dn: cn=Stanley "Short" Mein,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
attrs = new BasicAttributes();
attr = new BasicAttribute("baseName");
@@ -1821,7 +1820,7 @@ public class FakeLdapContext implements LdapContext {
attr.add("User with quote (\") in 'cn' in the JBoss Monitor Group");
attrs.put(attr);
- sr = new SearchResult("cn=Stanley \\\"Short\\\" Mein,ou=users", null, null, attrs, true);
+ sr = new SearchResult("cn=Stanley \"Short\" Mein,ou=users", null, null, attrs, true);
this.add(sr);
// dn: cn=Sam Not \= Smitherson,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
@@ -2160,7 +2159,7 @@ public class FakeLdapContext implements LdapContext {
attr.add("User with slash (/) in 'cn' in the RHQ Admin Group");
attrs.put(attr);
- sr = new SearchResult("cn=System/Integration API,ou=users", null, null, attrs, true);
+ sr = new SearchResult("cn=System\\/Integration API,ou=users", null, null, attrs, true);
this.add(sr);
// dn: cn=Phil/Susan Carlson,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
@@ -2209,7 +2208,7 @@ public class FakeLdapContext implements LdapContext {
attr.add("User with slash (/) in 'cn' in the JBoss Admin Group");
attrs.put(attr);
- sr = new SearchResult("cn=Phil/Susan Carlson,ou=users", null, null, attrs, true);
+ sr = new SearchResult("cn=Phil\\/Susan Carlson,ou=users", null, null, attrs, true);
this.add(sr);
// dn: cn=System/Integration API 2,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
@@ -2254,7 +2253,7 @@ public class FakeLdapContext implements LdapContext {
attr.add("User with slash (/) in 'cn' in the JBoss Monitor Group");
attrs.put(attr);
- sr = new SearchResult("cn=System/Integration API 2,ou=users", null, null, attrs, true);
+ sr = new SearchResult("cn=System\\/Integration API 2,ou=users", null, null, attrs, true);
this.add(sr);
// dn: cn=Lee -Fast- Croutche,ou=users,dc=test,dc=rhq,dc=redhat,dc=com
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
index a28c709..7473321 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManagerBean.java
@@ -350,7 +350,6 @@ public class LdapGroupManagerBean implements LdapGroupManagerLocal {
if (si.isRelative()) {
userDN += "," + baseDNs[x];
}
- userDN = userDN + "," + baseDNs[x];
}
userDetails.put("dn", userDN);
10 years, 9 months
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/AbstractInstall.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
New commits:
commit 8c693ee685d538a28a3c42ce813b10b49997f871
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Jul 22 16:36:23 2013 -0400
get rid of the upgrade wording, it's confusing when performing an initial install.
diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/AbstractInstall.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/AbstractInstall.java
index 61c8a9c..fb9bceb 100644
--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/AbstractInstall.java
+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/AbstractInstall.java
@@ -363,14 +363,14 @@ public abstract class AbstractInstall extends ControlCommand {
protected void startRHQServerForInstallation() throws IOException {
try {
- log.info("The RHQ Server must be started to complete its upgrade. Starting the RHQ server in preparation of running the server installer...");
+ log.info("The RHQ Server must be started to complete its installation. Starting the RHQ server in preparation of running the server installer...");
// when you unzip the distro, you are getting a fresh, unadulterated, out-of-box EAP installation, which by default listens
// to port 9999 for its native management subsystem. Make sure some other independent EAP server (or anything for that matter)
// isn't already listening to that port.
if (isPortInUse("127.0.0.1", 9999)) {
throw new IOException(
- "Something is already listening to port 9999 - shut it down before upgrading the server.");
+ "Something is already listening to port 9999 - shut it down before installing the server.");
}
Executor executor = new DefaultExecutor();
@@ -400,7 +400,7 @@ public abstract class AbstractInstall extends ControlCommand {
}
// Wait for the server to complete it's startup
- log.info("Waiting for the RHQ Server to start in preparation of running the server installer for upgrade...");
+ log.info("Waiting for the RHQ Server to start in preparation of running the server installer...");
commandLine = getCommandLine("rhq-installer", "--test");
Executor installerExecutor = new DefaultExecutor();
10 years, 9 months
[rhq] etc/scripts
by John Sanda
etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh | 42 +++++++++++++++--
1 file changed, 39 insertions(+), 3 deletions(-)
New commits:
commit 2409ed2dcd705c58e5024182e95445431b25acf5
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 22 15:16:49 2013 -0400
document the 4.8 storage patch script
diff --git a/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh b/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh
index 33984d1..ae78240 100755
--- a/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh
+++ b/etc/scripts/rhq48-storage-patch/rhq48-storage-patch.sh
@@ -1,7 +1,43 @@
#!/bin/bash
+#
+# BACKGROUND:
+# This patch script needs to be run against RHQ 4.8.0 installations prior to
+# script. You do not need to run this script if upgrading from a version
+# earlier than 4.8.0.
+#
+# PREREQUISITES:
+# 1) Shut down the RHQ storage node and server.
+#
+# 2) Edit <rhq-install-dir>/rhq-storage/conf/cassandra.yaml and set the
+# following property,
+#
+# start_rpc: true
+#
+# 3) Note the value of rpc_port in cassandra.yaml. By default it is 9160 which
+# is fine.
+#
+# RUNNING THE PATCH:
+# 1) cd <patch-dir>
+#
+# 2) ./rhq48-storage-patch.sh <rhq-480-server-dir> <storage-ip-address> <thrift-port> <jmx-port>
+#
+# 3) Carefully reivew the script output for any errors.
+#
+# 4) Edit cassandra.yaml against and reset start_rpc: false
+#
+# ADDITIONAL NOTES:
+# The <jmx-port> defaults to 7299. If you are uncertain of what value to use,
+# you can find it in the UI. Log into RHQ and go to Administration --> Storage Nodes.
+#
+# If you are uncertain of the value to use for the storage node IP address, you
+# find the correct valu in the storage nodes admin UI as well.
+#
+# EXAMPLE:
+# ./rhq48-storage-patch.sh /opt/rhq-4.8.0 127.0.0.1 9160 7299
+# Usage: ./rhq48-storage-patch.sh <rhq-480-server-dir> <storage-ip-address> <thrift-port> <jmx-port>
function usage() {
- echo "Usage: $0 <rhq-server-dir> <storage-ip-address> <cql-port> <jmx-port>"
+ echo "Usage: $0 <rhq-480-server-dir> <storage-ip-address> <thrift-port> <jmx-port>"
}
if [ $# -ne 4 ]; then
@@ -16,11 +52,11 @@ fi
RHQ_SERVER_DIR=$1
CQL_HOSTNAME=$2
-CQL_PORT=$3
+THRIFT_PORT=$3
JMX_PORT=$4
export CQLSH_HOST=$2
-export CQL_PORT=$3
+export CQLSH_PORT=$3
PATCH="apache-cassandra-1.2.4-patch-1.jar"
10 years, 10 months
[rhq] modules/enterprise
by snegrea
modules/enterprise/server/jar/intentional-api-changes-since-4.8.0.xml | 14 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java | 52 ++++++----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java | 42 ++++++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerRemote.java | 17 +++
4 files changed, 106 insertions(+), 19 deletions(-)
New commits:
commit c91c8f23416db836308b2bf3871fdda87559297e
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 22 14:12:08 2013 -0500
Update the storage node manager API for alerts to support UI functionality.
diff --git a/modules/enterprise/server/jar/intentional-api-changes-since-4.8.0.xml b/modules/enterprise/server/jar/intentional-api-changes-since-4.8.0.xml
index a9ce322..58c4eda 100644
--- a/modules/enterprise/server/jar/intentional-api-changes-since-4.8.0.xml
+++ b/modules/enterprise/server/jar/intentional-api-changes-since-4.8.0.xml
@@ -11,8 +11,22 @@
<difference>
<className>org/rhq/enterprise/server/cloud/StorageNodeManagerRemote</className>
<differenceType>7012</differenceType> <!-- method added to an interface -->
+ <method>org.rhq.core.domain.util.PageList findNotAcknowledgedStorageNodeAlerts(org.rhq.core.domain.auth.Subject, org.rhq.core.domain.cloud.StorageNode)</method>
+ <justification>Adding a method to a remote API interface is safe. This is newly implemented functionality.</justification>
+ </difference>
+
+ <difference>
+ <className>org/rhq/enterprise/server/cloud/StorageNodeManagerRemote</className>
+ <differenceType>7012</differenceType> <!-- method added to an interface -->
<method>org.rhq.core.domain.util.PageList findAllStorageNodeAlerts(org.rhq.core.domain.auth.Subject)</method>
<justification>Adding a method to a remote API interface is safe. This is newly implemented functionality.</justification>
</difference>
+ <difference>
+ <className>org/rhq/enterprise/server/cloud/StorageNodeManagerRemote</className>
+ <differenceType>7012</differenceType> <!-- method added to an interface -->
+ <method>org.rhq.core.domain.util.PageList findAllStorageNodeAlerts(org.rhq.core.domain.auth.Subject, org.rhq.core.domain.cloud.StorageNode)</method>
+ <justification>Adding a method to a remote API interface is safe. This is newly implemented functionality.</justification>
+ </difference>
+
</differences>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
index c2a7b46..b32ab5b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
@@ -512,12 +512,22 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
@Override
public PageList<Alert> findNotAcknowledgedStorageNodeAlerts(Subject subject) {
- return findStorageNodeAlerts(subject, false);
+ return findStorageNodeAlerts(subject, false, null);
+ }
+
+ @Override
+ public PageList<Alert> findNotAcknowledgedStorageNodeAlerts(Subject subject, StorageNode storageNode) {
+ return findStorageNodeAlerts(subject, false, storageNode);
}
@Override
public PageList<Alert> findAllStorageNodeAlerts(Subject subject) {
- return findStorageNodeAlerts(subject, true);
+ return findStorageNodeAlerts(subject, true, null);
+ }
+
+ @Override
+ public PageList<Alert> findAllStorageNodeAlerts(Subject subject, StorageNode storageNode) {
+ return findStorageNodeAlerts(subject, true, storageNode);
}
/**
@@ -527,8 +537,8 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
* @param allAlerts if [true] then return all alerts; if [false] then return only alerts that are not acknowledged
* @return alerts
*/
- private PageList<Alert> findStorageNodeAlerts(Subject subject, boolean allAlerts) {
- Integer[] resouceIdsWithAlertDefinitions = findResourcesWithAlertDefinitions();
+ private PageList<Alert> findStorageNodeAlerts(Subject subject, boolean allAlerts, StorageNode storageNode) {
+ Integer[] resouceIdsWithAlertDefinitions = findResourcesWithAlertDefinitions(storageNode);
PageList<Alert> alerts = new PageList<Alert>();
if( resouceIdsWithAlertDefinitions != null && resouceIdsWithAlertDefinitions.length != 0 ){
@@ -555,31 +565,35 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
return alerts;
}
- /**
- * Return resource Ids for all resources and sub-resources of Storage Nodes that
- * have alert definitions. This will be used by the resource criteria to find
- * all alerts triggered for storage nodes.
- *
- * @return
- */
- private Integer[] findResourcesWithAlertDefinitions() {
- List<Integer> resourceIdsWithAlertDefinitions = new ArrayList<Integer>();
- List<StorageNode> test2 = getStorageNodes();
+ @Override
+ public Integer[] findResourcesWithAlertDefinitions() {
+ return this.findResourcesWithAlertDefinitions(null);
+ }
+
+ @Override
+ public Integer[] findResourcesWithAlertDefinitions(StorageNode storageNode) {
+ List<StorageNode> initialStorageNodes;
+ if (storageNode == null) {
+ initialStorageNodes = getStorageNodes();
+ } else {
+ initialStorageNodes = Arrays.asList(storageNode);
+ }
Queue<Resource> unvisitedResources = new LinkedList<Resource>();
- for (StorageNode node : test2) {
- if (node.getResource() != null) {
- unvisitedResources.add(node.getResource());
+ for (StorageNode initialStorageNode : initialStorageNodes) {
+ if (initialStorageNode.getResource() != null) {
+ unvisitedResources.add(initialStorageNode.getResource());
}
}
- while(!unvisitedResources.isEmpty()){
+ List<Integer> resourceIdsWithAlertDefinitions = new ArrayList<Integer>();
+ while (!unvisitedResources.isEmpty()) {
Resource resource = unvisitedResources.poll();
if (resource.getAlertDefinitions() != null) {
resourceIdsWithAlertDefinitions.add(resource.getId());
}
- for(Resource child: resource.getChildResources()){
+ for (Resource child : resource.getChildResources()) {
unvisitedResources.add(child);
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
index 6fca820..69b16c4 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
@@ -81,6 +81,15 @@ public interface StorageNodeManagerLocal {
PageList<Alert> findNotAcknowledgedStorageNodeAlerts(Subject subject);
/**
+ * Fetches the list of Storage Node related alerts that have not yet been acknowledged for the
+ * specified storage node.
+ *
+ * @param subject subject
+ * @return storage nodes alerts not acknowledged
+ */
+ PageList<Alert> findNotAcknowledgedStorageNodeAlerts(Subject subject, StorageNode storageNode);
+
+ /**
* Fetches all the Storage Node related alerts.
*
* @param subject subject
@@ -89,6 +98,39 @@ public interface StorageNodeManagerLocal {
PageList<Alert> findAllStorageNodeAlerts(Subject subject);
/**
+ * Fetches all the Storage Node related alerts for the specified storage node.
+ *
+ * @param subject subject
+ * @return all storage nodes alerts
+ */
+ PageList<Alert> findAllStorageNodeAlerts(Subject subject, StorageNode storageNode);
+
+
+ /**
+ * Find ids for all resources and sub-resources of Storage Nodes that
+ * have alert definitions. This can be used by the resource criteria queries to find
+ * all alerts triggered for storage nodes resources.
+ *
+ * @return resource ids
+ */
+ Integer[] findResourcesWithAlertDefinitions();
+
+ /**
+ * Find ids for all resources and sub-resources, of the specified storage node, that
+ * have alert definitions. This can be used by the resource criteria queries to find
+ * all alerts triggered for storage nodes resources.
+ *
+ * If storage node is null it find ids for all resources and sub-resources of Storage Nodes that
+ * have alert definitions. Please see {@link #findResourcesWithAlertDefinitions()} for more details.
+ *
+ * @param storageNode storage node
+ *
+ * @return resource ids
+ */
+ Integer[] findResourcesWithAlertDefinitions(StorageNode storageNode);
+
+
+ /**
* <p>Prepares the node for subsequent upgrade.</p>
* <p> CAUTION: this method will set the RHQ server to maintenance mode, RHQ storage flushes all the data to disk
* and backup of all the keyspaces is created</p>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerRemote.java
index 7be1b07..75ac02b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerRemote.java
@@ -73,10 +73,27 @@ public interface StorageNodeManagerRemote {
PageList<Alert> findNotAcknowledgedStorageNodeAlerts(Subject subject);
/**
+ * Fetches the list of Storage Node related alerts that have not yet been acknowledged for the
+ * specified storage node.
+ *
+ * @param subject subject
+ * @return storage nodes alerts not acknowledged
+ */
+ PageList<Alert> findNotAcknowledgedStorageNodeAlerts(Subject subject, StorageNode storageNode);
+
+ /**
* Fetches all the Storage Node related alerts.
*
* @param subject subject
* @return all storage nodes alerts
*/
PageList<Alert> findAllStorageNodeAlerts(Subject subject);
+
+ /**
+ * Fetches all the Storage Node related alerts for the specified storage node.
+ *
+ * @param subject subject
+ * @return all storage nodes alerts
+ */
+ PageList<Alert> findAllStorageNodeAlerts(Subject subject, StorageNode storageNode);
}
10 years, 10 months