[teiid-commits] teiid SVN: r2639 - in branches/7.1.x/console/src/main: java/org/teiid/rhq/plugin and 3 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Sun Oct 10 22:02:08 EDT 2010
Author: tejones
Date: 2010-10-10 22:02:07 -0400 (Sun, 10 Oct 2010)
New Revision: 2639
Modified:
branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml
Log:
TEIID-982: Added Refresh Materialized Views operation at the VDB level
Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-10-08 02:24:14 UTC (rev 2638)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-10-11 02:02:07 UTC (rev 2639)
@@ -327,8 +327,20 @@
connection, formatVdbName(vdbName), Integer
.parseInt(vdbVersion));
getResultsCollectionValue(resultsMetaValue, sqlResultsObject);
- operationResult.setContent(createReportResultListForMatViewQuery(fieldNameList,
- sqlResultsObject.iterator()));
+ operationResult.setContent(createReportResultListForMatViewQuery(
+ fieldNameList, sqlResultsObject.iterator()));
+ } else if (operationName.equals(VDB.Operations.RELOAD_MATVIEW)) {
+ List<String> fieldNameList = operationResult.getFieldNameList();
+ MetaValue resultsMetaValue = reloadMaterializedView(connection,
+ formatVdbName(vdbName), Integer.parseInt(vdbVersion),
+ (String) valueMap.get(Operation.Value.MATVIEW_SCHEMA),
+ (String) valueMap.get(Operation.Value.MATVIEW_TABLE),
+ (Boolean) valueMap.get(Operation.Value.INVALIDATE_MATVIEW));
+ if (resultsMetaValue==null) {
+ operationResult.setContent("failure - see log for details"); //$NON-NLS-1$
+ } else {
+ operationResult.setContent("data successfully refreshed!"); //$NON-NLS-1$
+ }
}
}
@@ -390,7 +402,7 @@
MetaValueFactory.getInstance().create(
Operation.Value.MAT_VIEW_QUERY),
MetaValueFactory.getInstance()
- .create(Long.parseLong("9999999")) };
+ .create(Long.parseLong("9999999")) }; //$NON-NLS-1$
try {
resultsCollection = executeManagedOperation(connection,
@@ -405,6 +417,36 @@
}
+ protected MetaValue reloadMaterializedView(
+ ProfileServiceConnection connection, String vdbName,
+ int vdbVersion, String schema, String table, Boolean invalidate) {
+
+ MetaValue result = null;
+ String matView = schema + "." + table; //$NON-NLS-1$
+ String query = PluginConstants.Operation.Value.MAT_VIEW_REFRESH;
+ query = query.replace("param1", matView); //$NON-NLS-1$
+ query = query.replace("param2", invalidate.toString()); //$NON-NLS-1$
+ MetaValue[] args = new MetaValue[] {
+ MetaValueFactory.getInstance().create(vdbName),
+ MetaValueFactory.getInstance().create(vdbVersion),
+ MetaValueFactory.getInstance().create(query),
+ MetaValueFactory.getInstance()
+ .create(Long.parseLong("9999999")) }; //$NON-NLS-1$
+
+ try {
+ result = executeManagedOperation(connection,
+ getRuntimeEngineDeployer(connection, mc),
+ VDB.Operations.EXECUTE_QUERIES, args);
+ } catch (Exception e) {
+ final String msg = "Exception executing operation: " + VDB.Operations.RELOAD_MATVIEW; //$NON-NLS-1$
+ LOG.error(msg, e);
+
+ }
+
+ return result;
+
+ }
+
protected MetaValue getRequestsForVDB(ProfileServiceConnection connection,
String vdbName, int vdbVersion) {
@@ -504,10 +546,11 @@
} catch (Exception e) {
final String msg = "Exception getting the AdminApi in " + operation; //$NON-NLS-1$
LOG.error(msg, e);
+ throw new RuntimeException(e);
}
}
}
- throw new Exception("No operation found with given name =" + operation); //$NON-NLS-1$
+ throw new Exception("No operation found with given name = " + operation); //$NON-NLS-1$
}
@@ -712,13 +755,27 @@
for (MetaValue value : ((CollectionValueSupport) pValue)
.getElements()) {
if (value.getMetaType().isCollection()) {
- ArrayList<String> row = (ArrayList<String>)MetaValueFactory.getInstance().unwrap(value);
- list.add(row);
+ ArrayList<String> row = (ArrayList<String>) MetaValueFactory
+ .getInstance().unwrap(value);
+ list.add(row);
}
}
}
}
+ private void getResultsCollectionValueForMatViewRefresh(MetaValue pValue,
+ Collection<ArrayList<String>> list) {
+ MetaType metaType = pValue.getMetaType();
+ for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
+ if (value.getMetaType().isCollection()) {
+ ArrayList<String> row = (ArrayList<String>) MetaValueFactory
+ .getInstance().unwrap(value);
+ list.add(row);
+ }
+ }
+
+ }
+
public static <T> void getTransactionCollectionValue(MetaValue pValue,
Collection<Transaction> list) {
MetaType metaType = pValue.getMetaType();
@@ -801,21 +858,22 @@
}
return reportResultList;
}
-
- private Collection createReportResultListForMatViewQuery(List fieldNameList,
- Iterator objectIter) {
+
+ private Collection createReportResultListForMatViewQuery(
+ List fieldNameList, Iterator objectIter) {
Collection reportResultList = new ArrayList();
- //Iterate throught rows
+ // Iterate through rows
while (objectIter.hasNext()) {
- ArrayList<String> columnValues = (ArrayList<String>)objectIter.next();
+ ArrayList<String> columnValues = (ArrayList<String>) objectIter
+ .next();
Class cls = null;
try {
Iterator fieldIter = fieldNameList.iterator();
- Map reportValueMap = new HashMap<String, String>();
- //Iterate through columns with a row
- for (String columnValue: columnValues) {
+ Map reportValueMap = new HashMap<String, Object>();
+ // Iterate through columns with a row
+ for (Object columnValue : columnValues) {
String fieldName = (String) fieldIter.next();
reportValueMap.put(fieldName, columnValue);
}
Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-10-08 02:24:14 UTC (rev 2638)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-10-11 02:02:07 UTC (rev 2639)
@@ -123,8 +123,14 @@
} else if (name.equals(Platform.Operations.KILL_SESSION)) {
valueMap.put(Operation.Value.SESSION_ID, configuration.getSimple(
Operation.Value.SESSION_ID).getLongValue());
- }
-
+ } else if (name.equals(VDB.Operations.RELOAD_MATVIEW)) {
+ valueMap.put(Operation.Value.MATVIEW_SCHEMA, configuration.getSimple(
+ Operation.Value.MATVIEW_SCHEMA).getStringValue());
+ valueMap.put(Operation.Value.MATVIEW_TABLE, configuration.getSimple(
+ Operation.Value.MATVIEW_TABLE).getStringValue());
+ valueMap.put(Operation.Value.INVALIDATE_MATVIEW, configuration.getSimple(
+ Operation.Value.INVALIDATE_MATVIEW).getBooleanValue());
+ }
}
/*
Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java 2010-10-08 02:24:14 UTC (rev 2638)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java 2010-10-11 02:02:07 UTC (rev 2639)
@@ -134,6 +134,10 @@
.getPropertyDefinitions();
PropertyDefinition listPropDefinition = (PropertyDefinition) propDefs
.get(LISTNAME);
+
+ if (listPropDefinition == null) {
+ continue;
+ }
PropertyDefinition propertyDefinitionMap = ((PropertyDefinitionList) listPropDefinition)
.getMemberDefinition();
Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-10-08 02:24:14 UTC (rev 2638)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-10-11 02:02:07 UTC (rev 2639)
@@ -106,6 +106,7 @@
public final static String GET_REQUESTS = "getRequestsUsingVDB"; //$NON-NLS-1$
public final static String GET_SESSIONS = "getSessions"; //$NON-NLS-1$
public final static String GET_MATVIEWS = "getMaterializedViews"; //$NON-NLS-1$
+ public final static String RELOAD_MATVIEW = "reloadMaterializedView"; //$NON-NLS-1$
}
@@ -232,6 +233,7 @@
public final static String STOP_NOW = "stopNow"; //$NON-NLS-1$
public final static String MAT_VIEW_QUERY = "select SchemaName, Name, TargetSchemaName, TargetName, " + //$NON-NLS-1$
"Valid, LoadState, Updated, Cardinality from SYSADMIN.MATVIEWS"; //$NON-NLS-1$
+ public final static String MAT_VIEW_REFRESH = "exec SYSADMIN.refreshMatView('param1','param2');"; //$NON-NLS-1$
public final static String WAIT_UNTIL_FINISHED = "waitUntilFinished"; //$NON-NLS-1$
public final static String INCLUDE_SOURCE_QUERIES = "includeSourceQueries"; //$NON-NLS-1$
@@ -247,6 +249,9 @@
public final static String VDB_VERSION = "vdbVersion"; //$NON-NLS-1$
public final static String NAME = "Name"; //$NON-NLS-1$
public final static String VALUE = "Value"; //$NON-NLS-1$
+ public final static String MATVIEW_SCHEMA = "schema"; //$NON-NLS-1$
+ public final static String MATVIEW_TABLE = "table"; //$NON-NLS-1$
+ public final static String INVALIDATE_MATVIEW = "invalidate"; //$NON-NLS-1$
}
Modified: branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml 2010-10-08 02:24:14 UTC (rev 2638)
+++ branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml 2010-10-11 02:02:07 UTC (rev 2639)
@@ -471,6 +471,7 @@
<operation name="getMaterializedViews" displayName="Get Materialized View Info"
description="Get any Materialized Views for this VDB">
+
<results>
<c:list-property name="list" displayName=" Materialized Views"
@@ -490,14 +491,34 @@
<c:simple-property displayName="Current State"
name="loadState" type="string" description="Processing time for the request" />
<c:simple-property displayName="Last Updated"
- name="updated" type="string" description="Last time of data refresh" />
+ name="updated" type="integer" description="Last time of data refresh" />
<c:simple-property displayName="Cardinality"
- name="cardinality" type="string" description="Row count" />
+ name="cardinality" type="integer" description="Row count" />
</c:map-property>
</c:list-property>
</results>
</operation>
+ <operation name="reloadMaterializedView" displayName="Refresh a Materialized View"
+ description="Refresh a given any Materialized View for this VDB">
+ <parameters>
+ <c:simple-property displayName="Materialized View Schema"
+ name="schema" type="string" required="true"
+ description="The schema name of the Materialized View to refresh" />
+ <c:simple-property displayName="Materialized View Table"
+ name="table" type="string" required="true"
+ description="The table name of the Materialized View to refresh" />
+ <c:simple-property displayName="Invalidate Current Materialized View"
+ name="invalidate" type="boolean" required="true"
+ description="If true, will invalidate the current Materialized View" />
+ </parameters>
+
+ <results>
+ <c:simple-property displayName="Result" name="operationResult"
+ type="string" description="Result of refresh" />
+ </results>
+ </operation>
+
<metric displayName="Status" defaultOn="true" dataType="trait"
displayType="summary" category="availability" property="status"
description="The status of this VDB" />
More information about the teiid-commits
mailing list