[rhq] modules/enterprise
by Heiko W. Rupp
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 +++++-----
2 files changed, 15 insertions(+), 11 deletions(-)
New commits:
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>
10 years, 10 months
[rhq] modules/plugins
by John Sanda
modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java | 23 +++++++++-
modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml | 6 ++
2 files changed, 26 insertions(+), 3 deletions(-)
New commits:
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"/>
10 years, 10 months
[rhq] modules/core
by John Sanda
modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/StorageNodeAddressUpgradeTask.java | 54 ++++++++++
1 file changed, 54 insertions(+)
New commits:
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);
+ }
+ }
+}
10 years, 10 months
[rhq] modules/common modules/core
by John Sanda
modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java | 5 +++--
modules/core/dbutils/pom.xml | 2 +-
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 5 +++++
3 files changed, 9 insertions(+), 3 deletions(-)
New commits:
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>
10 years, 10 months
[rhq] modules/common modules/enterprise modules/plugins pom.xml
by John Sanda
modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml | 77 +---------
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml | 2
modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java | 64 +++++---
modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ClusterBuilder.java | 7
modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml | 4
modules/enterprise/server/appserver/src/main/scripts/storage_setup.groovy | 1
modules/enterprise/server/itests-2/pom.xml | 4
modules/plugins/cassandra/pom.xml | 4
pom.xml | 2
9 files changed, 64 insertions(+), 101 deletions(-)
New commits:
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>
10 years, 10 months
[rhq] modules/enterprise
by Jiri Kremser
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 | 7 ++++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java | 14 ++++++----
3 files changed, 22 insertions(+), 7 deletions(-)
New commits:
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);
10 years, 10 months
[rhq] Changes to 'bug/923400'
by Thomas Segismont
New branch 'bug/923400' available with the following commits:
commit 3a65e09ac935bc75bb5a416a274273ef477f1a3c
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
10 years, 10 months
[rhq] Branch 'bug/923400' - modules/core
by Thomas Segismont
modules/core/native-system/src/main/java/org/rhq/core/system/SigarAccessHandler.java | 109 +++++-----
modules/core/native-system/src/test/java/org/rhq/core/system/SigarAccessHandlerTest.java | 49 +++-
2 files changed, 105 insertions(+), 53 deletions(-)
New commits:
commit a6e0c42c046095f05ddf364e5d4dad50e8d32d88
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Wed Jul 10 18:11:45 2013 +0200
Bug 923400 - Sigar creates high number of blocked threads (unbounded) if mount is gone
Add a parameter to switch on a limit of Sigar instances.
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
index 0fcacb7..a781641 100644
--- 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
@@ -29,7 +29,6 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import org.apache.commons.logging.Log;
@@ -42,16 +41,18 @@ import org.hyperic.sigar.Sigar;
* 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 'sigarInstancesThreshold' has not been exceeded. It it has, a
- * warning message will be logged, optionally with a thread dump.
+ * <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 a thread will wait for the shared Sigar lock
- * acquistion; defaults to 5</li>
- * <li><strong>sigarInstancesThreshold</strong>: threshold of currently living Sigar instances at which the
- * background task will print warning messages; defaults to 50</li>
- * <li><strong>threadDumpOnSigarInstancesThreshold</strong>: if set to true (case insensitive), the background task
- * will also log a thread dump when <strong>sigarInstancesThreshold</strong> is met</li>
+ * <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>
*
@@ -60,15 +61,20 @@ import org.hyperic.sigar.Sigar;
class SigarAccessHandler implements InvocationHandler {
private static final Log LOG = LogFactory.getLog(SigarAccessHandler.class);
- private static final int sharedSigarLockMaxWait = Integer.getInteger("sharedSigarLockMaxWait", 5);
- private static final int sigarInstancesThreshold = Integer.getInteger("sigarInstancesThreshold", 50);
- private static final boolean threadDumpOnSigarInstancesThreshold = Boolean
- .getBoolean("threadDumpOnSigarInstancesThreshold");
+ 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 AtomicInteger sigarInstancesCount;
+ private final ReentrantLock localSigarLock;
private final ScheduledExecutorService scheduledExecutorService;
+ private volatile int localSigarInstancesCount;
private Sigar sharedSigar;
SigarAccessHandler() {
@@ -76,11 +82,12 @@ class SigarAccessHandler implements InvocationHandler {
}
SigarAccessHandler(SigarFactory sigarFactory) {
+ this.sigarFactory = sigarFactory;
sharedSigarLock = new ReentrantLock();
- sigarInstancesCount = new AtomicInteger(0);
+ localSigarLock = new ReentrantLock();
scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
scheduledExecutorService.scheduleWithFixedDelay(new ThresholdChecker(), 1, 5, MINUTES);
- this.sigarFactory = sigarFactory;
+ localSigarInstancesCount = 0;
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
@@ -91,13 +98,10 @@ class SigarAccessHandler implements InvocationHandler {
}
// Acquire lock for shared Sigar instance. Wait 'sharedSigarLockMaxWait' seconds at most
- boolean acquiredLock = sharedSigarLock.tryLock(sharedSigarLockMaxWait, SECONDS);
+ boolean acquiredLock = sharedSigarLock.tryLock(SHARED_SIGAR_LOCK_MAX_WAIT, SECONDS);
if (acquiredLock) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Using shared Sigar instance for " + method);
- }
if (sharedSigar == null) {
- this.sharedSigar = createSigarInstance();
+ this.sharedSigar = sigarFactory.createSigarInstance();
}
try {
return method.invoke(sharedSigar, args);
@@ -107,36 +111,46 @@ class SigarAccessHandler implements InvocationHandler {
sharedSigarLock.unlock();
}
} else {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Using local Sigar instance for " + method);
- }
- Sigar localSigar = createSigarInstance();
+ Sigar localSigar = createLocalSigarInstance();
try {
return method.invoke(localSigar, args);
} catch (InvocationTargetException e) {
throw e.getTargetException();
} finally {
- closeSigarInstance(localSigar);
+ closeLocalSigarInstance(localSigar);
}
}
}
- private Sigar createSigarInstance() {
- Sigar sigar = sigarFactory.createSigarInstance();
- sigarInstancesCount.incrementAndGet();
- return sigar;
+ 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 closeSigarInstance(Sigar sigar) {
- sigar.close();
- sigarInstancesCount.decrementAndGet();
+ private void closeLocalSigarInstance(Sigar sigar) {
+ localSigarLock.lock();
+ try {
+ sigar.close();
+ localSigarInstancesCount--;
+ } finally {
+ localSigarLock.unlock();
+ }
}
void close() {
if (sharedSigar != null) {
sharedSigarLock.lock();
try {
- closeSigarInstance(sharedSigar);
+ sharedSigar.close();
sharedSigar = null;
} finally {
sharedSigarLock.unlock();
@@ -145,8 +159,8 @@ class SigarAccessHandler implements InvocationHandler {
scheduledExecutorService.shutdownNow();
}
- int currentSigarInstancesCount() {
- return sigarInstancesCount.get();
+ int localSigarInstancesCount() {
+ return localSigarInstancesCount;
}
interface SigarFactory {
@@ -163,24 +177,25 @@ class SigarAccessHandler implements InvocationHandler {
private class ThresholdChecker implements Runnable {
@Override
public void run() {
- int currentSigarInstancesCount = sigarInstancesCount.get();
- if (currentSigarInstancesCount > sigarInstancesThreshold) {
- LOG.warn("There are " + currentSigarInstancesCount + " Sigar instances currently active. "
- + "This may indicate that a call to the shared Sigar instance did not complete.");
- if (threadDumpOnSigarInstancesThreshold) {
- LOG.warn("threadDumpOnSigarInstancesThreshold is on." + System.getProperty("line.separator")
- + threadDump());
+ 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 String threadDump() {
- StringBuilder dump = new StringBuilder();
+ private void threadDump(StringBuilder sb) {
ThreadInfo[] threadInfos = ManagementFactory.getThreadMXBean().dumpAllThreads(true, true);
for (ThreadInfo threadInfo : threadInfos) {
- dump.append(threadInfo);
+ sb.append(threadInfo);
+ sb.append(LINE_SEPARATOR);
}
- return dump.toString();
}
}
}
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
index ef5f970..e993725 100644
--- 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
@@ -22,10 +22,15 @@ 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;
@@ -41,7 +46,7 @@ import org.testng.annotations.Test;
*/
@Test(singleThreaded = true)
public class SigarAccessHandlerTest {
- private static final int THREAD_POOL_SIZE = 10;
+ private static final int THREAD_POOL_SIZE = 100;
private Method getSwapMethod;
private Method getFileSystemMapMethod;
@@ -50,7 +55,7 @@ public class SigarAccessHandlerTest {
private SigarAccessHandler sigarAccessHandler;
@BeforeClass
- public void setMethodFields() throws Exception {
+ 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);
@@ -85,7 +90,7 @@ public class SigarAccessHandlerTest {
@Test(timeOut = 1000 * 30)
public void testOnDemandSigarInstanceCreation() throws Throwable {
// Start concurrent invocations of the long running getSwap method
- for (int i = 0; i < THREAD_POOL_SIZE; i++) {
+ for (int i = 0; i < 10; i++) {
executorService.submit(new Runnable() {
@Override
public void run() {
@@ -98,14 +103,14 @@ public class SigarAccessHandlerTest {
}
Thread.sleep(1000 * 8);
- assertEquals(sigarAccessHandler.currentSigarInstancesCount(), THREAD_POOL_SIZE);
+ 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 < THREAD_POOL_SIZE; i++) {
+ for (int i = 0; i < 10; i++) {
if (i == 0) {
executorService.submit(new Runnable() {
@Override
@@ -130,6 +135,38 @@ public class SigarAccessHandlerTest {
}
Thread.sleep(1000 * 8);
- assertEquals(sigarAccessHandler.currentSigarInstancesCount(), 1);
+ 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);
}
}
10 years, 10 months
[rhq] modules/enterprise
by Jiri Kremser
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java | 2 ++
1 file changed, 2 insertions(+)
New commits:
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 {
10 years, 10 months