modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresTableComponent.java
| 13 +++++++++-
modules/plugins/postgres/src/main/resources/META-INF/rhq-plugin.xml
| 4 +++
2 files changed, 16 insertions(+), 1 deletion(-)
New commits:
commit 94dfe93fe58e0929640f9e08220509b9d938a7c0
Merge: 6077f6c... 7b7bb8d...
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jan 4 22:32:04 2011 +0100
Merge branch 'master' of
ssh://git.fedorahosted.org/git/rhq/rhq
commit 6077f6c060e37499cb8fb999b63fb159f8f1fbcb
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jan 4 22:31:06 2011 +0100
Support vacuuming tables.
diff --git
a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresTableComponent.java
b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresTableComponent.java
index ff21e78..6fb651a 100644
---
a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresTableComponent.java
+++
b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresTableComponent.java
@@ -42,6 +42,8 @@ import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
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.database.DatabaseComponent;
import org.rhq.plugins.database.DatabaseQueryUtility;
@@ -51,7 +53,7 @@ import org.rhq.plugins.database.DatabaseQueryUtility;
* @author Greg Hinkle
*/
public class PostgresTableComponent implements
DatabaseComponent<PostgresDatabaseComponent>, MeasurementFacet,
- ConfigurationFacet, DeleteResourceFacet {
+ ConfigurationFacet, DeleteResourceFacet, OperationFacet {
private static final List<String> PG_STAT_USER_TABLE_STATS =
Arrays.asList("seq_scan", "seq_tup_read", "idx_scan",
"idx_tup_fetch", "n_tup_ins", "n_tup_upd",
"n_tup_del", "table_size", "total_size");
@@ -230,6 +232,15 @@ public class PostgresTableComponent implements
DatabaseComponent<PostgresDatabas
this.resourceContext.getParentResourceComponent().removeConnection();
}
+ public OperationResult invokeOperation(String name, Configuration parameters) throws
InterruptedException,
+ Exception {
+
+ if ("vacuum".equals(name)) {
+ DatabaseQueryUtility.executeUpdate(this,"vacuum " +
getTableName());
+ }
+ return null;
+ }
+
private static class ColumnDefinition {
String columnName;
String columnType;
diff --git a/modules/plugins/postgres/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/postgres/src/main/resources/META-INF/rhq-plugin.xml
index 450dcfe..88df960 100644
--- a/modules/plugins/postgres/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/postgres/src/main/resources/META-INF/rhq-plugin.xml
@@ -349,6 +349,10 @@
<c:simple-property name="tableName" readOnly="true"
/>
</plugin-configuration>
+ <operation name="vacuum" description="Vacuum the
table">
+ <!--TODO add options like analyze-->
+ </operation>
+
<metric displayName="Sequential Scans"
property="seq_scan" measurementType="trendsup"
description="Number of sequential scans done against this table
(when an index scan was not possible)"/>
<metric displayName="Sequential Rows Read"
property="seq_tup_read" measurementType="trendsup"