Author: tejones
Date: 2010-10-07 18:34:28 -0400 (Thu, 07 Oct 2010)
New Revision: 2636
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/util/PluginConstants.java
branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml
Log:
TEIID-982: Added Get 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-07
18:42:05 UTC (rev 2635)
+++
branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-10-07
22:34:28 UTC (rev 2636)
@@ -64,9 +64,11 @@
public class DQPManagementView implements PluginConstants {
private static ManagedComponent mc = null;
- private static final Log LOG =
LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
- private static final MetaValueFactory metaValueFactory =
MetaValueFactory.getInstance();
-
+ private static final Log LOG = LogFactory
+ .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+ private static final MetaValueFactory metaValueFactory = MetaValueFactory
+ .getInstance();
+
private static final String VDB_EXT = ".vdb";
public DQPManagementView() {
@@ -75,52 +77,67 @@
/*
* Metric methods
*/
- public Object getMetric(ProfileServiceConnection connection, String componentType,
String identifier, String metric, Map<String, Object> valueMap) {
+ public Object getMetric(ProfileServiceConnection connection,
+ String componentType, String identifier, String metric,
+ Map<String, Object> valueMap) {
Object resultObject = new Object();
if (componentType.equals(PluginConstants.ComponentType.Platform.NAME)) {
- resultObject = getPlatformMetric(connection, componentType, metric, valueMap);
+ resultObject = getPlatformMetric(connection, componentType, metric,
+ valueMap);
} else if (componentType.equals(PluginConstants.ComponentType.VDB.NAME)) {
- resultObject = getVdbMetric(connection, componentType, identifier,metric, valueMap);
+ resultObject = getVdbMetric(connection, componentType, identifier,
+ metric, valueMap);
}
return resultObject;
}
- private Object getPlatformMetric(ProfileServiceConnection connection, String
componentType, String metric,
- Map<String, Object> valueMap) {
+ private Object getPlatformMetric(ProfileServiceConnection connection,
+ String componentType, String metric, Map<String, Object> valueMap) {
Object resultObject = new Object();
- if (metric .equals(PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
+ if (metric
+ .equals(PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
resultObject = new Double(getQueryCount(connection).doubleValue());
- } else if
(metric .equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
+ } else if (metric
+ .equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
resultObject = new Double(getSessionCount(connection).doubleValue());
- } else if
(metric .equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
- Collection<Request> longRunningQueries = new ArrayList<Request>();
- getRequestCollectionValue(getLongRunningQueries(connection), longRunningQueries);
- resultObject = new Double(longRunningQueries.size());
- } else if (metric.equals(PluginConstants.ComponentType.Platform.Metrics.BUFFER_USAGE))
{
+ } else if (metric
+ .equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
+ Collection<Request> longRunningQueries = new ArrayList<Request>();
+ getRequestCollectionValue(getLongRunningQueries(connection),
+ longRunningQueries);
+ resultObject = new Double(longRunningQueries.size());
+ } else if (metric
+ .equals(PluginConstants.ComponentType.Platform.Metrics.BUFFER_USAGE)) {
try {
- resultObject = ProfileServiceUtil.doubleValue(getUsedBufferSpace(connection));
+ resultObject = ProfileServiceUtil
+ .doubleValue(getUsedBufferSpace(connection));
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.GET_BUFFER_USAGE; //$NON-NLS-1$
LOG.error(msg, e);
}
- } else if (metric.startsWith(Admin.Cache.PREPARED_PLAN_CACHE.toString()+".")
//$NON-NLS-1$
- ||
metric.startsWith(Admin.Cache.QUERY_SERVICE_RESULT_SET_CACHE.toString()+".")) {
//$NON-NLS-1$
+ } else if (metric.startsWith(Admin.Cache.PREPARED_PLAN_CACHE.toString()
+ + ".") //$NON-NLS-1$
+ || metric.startsWith(Admin.Cache.QUERY_SERVICE_RESULT_SET_CACHE
+ .toString()
+ + ".")) { //$NON-NLS-1$
return getCacheProperty(connection, metric);
}
return resultObject;
}
-
- private Object getCacheProperty(ProfileServiceConnection connection, String metric) {
+
+ private Object getCacheProperty(ProfileServiceConnection connection,
+ String metric) {
int dotIndex = metric.indexOf('.');
String cacheType = metric.substring(0, dotIndex);
- String property = metric.substring(dotIndex+1);
- CompositeValueSupport mv = (CompositeValueSupport)getCacheStats(connection, cacheType);
- MetaValue v = mv.get(property);
- return ((SimpleValue)v).getValue();
+ String property = metric.substring(dotIndex + 1);
+ CompositeValueSupport mv = (CompositeValueSupport) getCacheStats(
+ connection, cacheType);
+ MetaValue v = mv.get(property);
+ return ((SimpleValue) v).getValue();
}
private Object getVdbMetric(ProfileServiceConnection connection,
@@ -129,19 +146,27 @@
Object resultObject = new Object();
- if (metric .equals(PluginConstants.ComponentType.VDB.Metrics.ERROR_COUNT)) {
+ if (metric
+ .equals(PluginConstants.ComponentType.VDB.Metrics.ERROR_COUNT)) {
// TODO remove version parameter after AdminAPI is changed
- resultObject = getErrorCount(connection, (String) valueMap.get(VDB.NAME));
- } else if (metric.equals(PluginConstants.ComponentType.VDB.Metrics.STATUS)) {
+ resultObject = getErrorCount(connection, (String) valueMap
+ .get(VDB.NAME));
+ } else if (metric
+ .equals(PluginConstants.ComponentType.VDB.Metrics.STATUS)) {
// TODO remove version parameter after AdminAPI is changed
- resultObject = getVDBStatus(connection, (String) valueMap.get(VDB.NAME));
- } else if (metric.equals(PluginConstants.ComponentType.VDB.Metrics.QUERY_COUNT)) {
+ resultObject = getVDBStatus(connection, (String) valueMap
+ .get(VDB.NAME));
+ } else if (metric
+ .equals(PluginConstants.ComponentType.VDB.Metrics.QUERY_COUNT)) {
resultObject = new Double(getQueryCount(connection).doubleValue());
- } else if (metric.equals(PluginConstants.ComponentType.VDB.Metrics.SESSION_COUNT)) {
+ } else if (metric
+ .equals(PluginConstants.ComponentType.VDB.Metrics.SESSION_COUNT)) {
resultObject = new Double(getSessionCount(connection).doubleValue());
- } else if
(metric.equals(PluginConstants.ComponentType.VDB.Metrics.LONG_RUNNING_QUERIES)) {
+ } else if (metric
+ .equals(PluginConstants.ComponentType.VDB.Metrics.LONG_RUNNING_QUERIES)) {
Collection<Request> longRunningQueries = new ArrayList<Request>();
- getRequestCollectionValue(getLongRunningQueries(connection), longRunningQueries);
+ getRequestCollectionValue(getLongRunningQueries(connection),
+ longRunningQueries);
resultObject = new Double(longRunningQueries.size());
}
return resultObject;
@@ -151,12 +176,17 @@
* Operation methods
*/
- public void executeOperation(ProfileServiceConnection connection, ExecutedResult
operationResult, final Map<String, Object> valueMap) {
+ public void executeOperation(ProfileServiceConnection connection,
+ ExecutedResult operationResult, final Map<String, Object> valueMap) {
- if
(operationResult.getComponentType().equals(PluginConstants.ComponentType.Platform.NAME))
{
- executePlatformOperation(connection,
operationResult, operationResult.getOperationName(), valueMap);
- } else if
(operationResult.getComponentType().equals( PluginConstants.ComponentType.VDB.NAME)) {
- executeVdbOperation(connection, operationResult, operationResult .getOperationName(),
valueMap);
+ if (operationResult.getComponentType().equals(
+ PluginConstants.ComponentType.Platform.NAME)) {
+ executePlatformOperation(connection, operationResult,
+ operationResult.getOperationName(), valueMap);
+ } else if (operationResult.getComponentType().equals(
+ PluginConstants.ComponentType.VDB.NAME)) {
+ executeVdbOperation(connection, operationResult, operationResult
+ .getOperationName(), valueMap);
}
}
@@ -199,8 +229,9 @@
MetaValue[] args = new MetaValue[] { metaValueFactory
.create(sessionID) };
try {
- executeManagedOperation(connection, getRuntimeEngineDeployer(connection, mc),
- Platform.Operations.KILL_TRANSACTION, args);
+ executeManagedOperation(connection, getRuntimeEngineDeployer(
+ connection, mc), Platform.Operations.KILL_TRANSACTION,
+ args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.KILL_TRANSACTION; //$NON-NLS-1$
LOG.error(msg, e);
@@ -210,8 +241,8 @@
MetaValue[] args = new MetaValue[] { metaValueFactory
.create(sessionID) };
try {
- executeManagedOperation(connection, getRuntimeEngineDeployer(connection, mc),
- Platform.Operations.KILL_SESSION, args);
+ executeManagedOperation(connection, getRuntimeEngineDeployer(
+ connection, mc), Platform.Operations.KILL_SESSION, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.KILL_SESSION; //$NON-NLS-1$
LOG.error(msg, e);
@@ -223,31 +254,35 @@
metaValueFactory.create(requestID),
metaValueFactory.create(sessionID) };
try {
- executeManagedOperation(connection, getRuntimeEngineDeployer(connection, mc),
- Platform.Operations.KILL_REQUEST, args);
+ executeManagedOperation(connection, getRuntimeEngineDeployer(
+ connection, mc), Platform.Operations.KILL_REQUEST, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.KILL_REQUEST; //$NON-NLS-1$
LOG.error(msg, e);
}
} else if (operationName.equals(Platform.Operations.DEPLOY_VDB_BY_URL)) {
String vdbUrl = (String) valueMap.get(Operation.Value.VDB_URL);
- String deployName = (String) valueMap.get(Operation.Value.VDB_DEPLOY_NAME);
+ String deployName = (String) valueMap
+ .get(Operation.Value.VDB_DEPLOY_NAME);
Object vdbVersion = valueMap.get(Operation.Value.VDB_VERSION);
- //strip off vdb extension if user added it
- if (deployName.endsWith(VDB_EXT)){
- deployName = deployName.substring(0, deployName.lastIndexOf(VDB_EXT));
+ // strip off vdb extension if user added it
+ if (deployName.endsWith(VDB_EXT)) {
+ deployName = deployName.substring(0, deployName
+ .lastIndexOf(VDB_EXT));
}
- if (vdbVersion!=null){
- deployName = deployName + "." + ((Integer)vdbVersion).toString() + VDB_EXT;
//$NON-NLS-1$
+ if (vdbVersion != null) {
+ deployName = deployName
+ + "." + ((Integer) vdbVersion).toString() + VDB_EXT; //$NON-NLS-1$
}
- //add vdb extension if there was no version
- if (!deployName.endsWith(VDB_EXT)){
- deployName = deployName + VDB_EXT;
+ // add vdb extension if there was no version
+ if (!deployName.endsWith(VDB_EXT)) {
+ deployName = deployName + VDB_EXT;
}
-
+
try {
URL url = new URL(vdbUrl);
- DeploymentUtils.deployArchive(deployName, connection.getDeploymentManager(), url,
false);
+ DeploymentUtils.deployArchive(deployName, connection
+ .getDeploymentManager(), url, false);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.DEPLOY_VDB_BY_URL; //$NON-NLS-1$
LOG.error(msg, e);
@@ -259,6 +294,7 @@
private void executeVdbOperation(ProfileServiceConnection connection,
ExecutedResult operationResult, final String operationName,
final Map<String, Object> valueMap) {
+ Collection<ArrayList<String>> sqlResultsObject = new
ArrayList<ArrayList<String>>();
Collection<Request> resultObject = new ArrayList<Request>();
Collection<Session> activeSessionsCollection = new ArrayList<Session>();
String vdbName = (String) valueMap
@@ -285,6 +321,14 @@
getRequestCollectionValue(requestMetaValue, resultObject);
operationResult.setContent(createReportResultList(fieldNameList,
resultObject.iterator()));
+ } else if (operationName.equals(VDB.Operations.GET_MATVIEWS)) {
+ List<String> fieldNameList = operationResult.getFieldNameList();
+ MetaValue resultsMetaValue = executeMaterializedViewQuery(
+ connection, formatVdbName(vdbName), Integer
+ .parseInt(vdbVersion));
+ getResultsCollectionValue(resultsMetaValue, sqlResultsObject);
+ operationResult.setContent(createReportResultListForMatViewQuery(fieldNameList,
+ sqlResultsObject.iterator()));
}
}
@@ -293,6 +337,11 @@
* Helper methods
*/
+ private String formatVdbName(String vdbName) {
+
+ return vdbName.substring(0, vdbName.indexOf(".")); //$NON-NLS-1$
+ }
+
public MetaValue getProperties(ProfileServiceConnection connection,
final String component) {
@@ -300,7 +349,8 @@
MetaValue args = null;
try {
- propertyValue = executeManagedOperation(connection,
getRuntimeEngineDeployer(connection, mc),
+ propertyValue = executeManagedOperation(connection,
+ getRuntimeEngineDeployer(connection, mc),
PluginConstants.Operation.GET_PROPERTIES, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.GET_PROPERTIES; //$NON-NLS-1$
@@ -317,9 +367,10 @@
MetaValue args = null;
try {
- requestsCollection = executeManagedOperation(connection,
getRuntimeEngineDeployer(connection, mc),
+ requestsCollection = executeManagedOperation(connection,
+ getRuntimeEngineDeployer(connection, mc),
- PluginConstants.Operation.GET_REQUESTS, args);
+ PluginConstants.Operation.GET_REQUESTS, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.GET_REQUESTS; //$NON-NLS-1$
LOG.error(msg, e);
@@ -329,6 +380,31 @@
}
+ protected MetaValue executeMaterializedViewQuery(
+ ProfileServiceConnection connection, String vdbName, int vdbVersion) {
+
+ MetaValue resultsCollection = null;
+ MetaValue[] args = new MetaValue[] {
+ MetaValueFactory.getInstance().create(vdbName),
+ MetaValueFactory.getInstance().create(vdbVersion),
+ MetaValueFactory.getInstance().create(
+ Operation.Value.MAT_VIEW_QUERY),
+ MetaValueFactory.getInstance()
+ .create(Long.parseLong("9999999")) };
+
+ try {
+ resultsCollection = executeManagedOperation(connection,
+ getRuntimeEngineDeployer(connection, mc),
+ VDB.Operations.EXECUTE_QUERIES, args);
+ } catch (Exception e) {
+ final String msg = "Exception executing operation: " +
VDB.Operations.EXECUTE_QUERIES; //$NON-NLS-1$
+ LOG.error(msg, e);
+ }
+
+ return resultsCollection;
+
+ }
+
protected MetaValue getRequestsForVDB(ProfileServiceConnection connection,
String vdbName, int vdbVersion) {
@@ -338,7 +414,8 @@
MetaValueFactory.getInstance().create(vdbVersion) };
try {
- requestsCollection = executeManagedOperation(connection,
getRuntimeEngineDeployer(connection, mc),
+ requestsCollection = executeManagedOperation(connection,
+ getRuntimeEngineDeployer(connection, mc),
PluginConstants.ComponentType.VDB.Operations.GET_REQUESTS,
args);
} catch (Exception e) {
@@ -356,7 +433,8 @@
MetaValue args = null;
try {
- transactionsCollection = executeManagedOperation(connection,
getRuntimeEngineDeployer(connection, mc),
+ transactionsCollection = executeManagedOperation(connection,
+ getRuntimeEngineDeployer(connection, mc),
Platform.Operations.GET_TRANSACTIONS, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.GET_TRANSACTIONS; //$NON-NLS-1$
@@ -373,7 +451,8 @@
MetaValue args = null;
try {
- sessionCollection = executeManagedOperation(connection,
getRuntimeEngineDeployer(connection, mc),
+ sessionCollection = executeManagedOperation(connection,
+ getRuntimeEngineDeployer(connection, mc),
PluginConstants.Operation.GET_SESSIONS, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.GET_SESSIONS; //$NON-NLS-1$
@@ -401,7 +480,7 @@
final String msg = "Exception in getVDBStatus(): " + e.getMessage();
//$NON-NLS-1$
LOG.error(msg, e);
}
-
+
if (mcVdb == null) {
return Status.INACTIVE.toString();
}
@@ -432,7 +511,6 @@
}
-
/**
* @param mc
* @return
@@ -468,7 +546,7 @@
}
return mc;
}
-
+
public static MetaValue getManagedProperty(
ProfileServiceConnection connection, ManagedComponent mc,
String property) throws Exception {
@@ -481,10 +559,10 @@
LOG.error(msg, e);
}
- if (managedProperty!=null){
- return managedProperty.getValue();
+ if (managedProperty != null) {
+ return managedProperty.getValue();
}
-
+
throw new Exception("No property found with given name =" + property);
//$NON-NLS-1$
}
@@ -560,13 +638,18 @@
}
return count;
}
-
- protected MetaValue getCacheStats(ProfileServiceConnection connection, String type) {
+
+ protected MetaValue getCacheStats(ProfileServiceConnection connection,
+ String type) {
try {
- return executeManagedOperation(connection, getRuntimeEngineDeployer(connection, mc),
- Platform.Operations.GET_CACHE_STATS, SimpleValueSupport.wrap(type));
+ return executeManagedOperation(connection,
+ getRuntimeEngineDeployer(connection, mc),
+ Platform.Operations.GET_CACHE_STATS, SimpleValueSupport
+ .wrap(type));
} catch (Exception e) {
- LOG.error("Exception executing operation: " +
Platform.Operations.GET_CACHE_STATS, e); //$NON-NLS-1$
+ LOG
+ .error(
+ "Exception executing operation: " + Platform.Operations.GET_CACHE_STATS,
e); //$NON-NLS-1$
}
return null;
}
@@ -578,7 +661,8 @@
MetaValue args = null;
try {
- requestsCollection = executeManagedOperation(connection,
getRuntimeEngineDeployer(connection, mc),
+ requestsCollection = executeManagedOperation(connection,
+ getRuntimeEngineDeployer(connection, mc),
Platform.Operations.GET_LONGRUNNINGQUERIES, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.GET_LONGRUNNINGQUERIES; //$NON-NLS-1$
@@ -588,14 +672,13 @@
return requestsCollection;
}
- protected MetaValue getUsedBufferSpace(
- ProfileServiceConnection connection) {
+ protected MetaValue getUsedBufferSpace(ProfileServiceConnection connection) {
MetaValue usedBufferSpace = null;
try {
- usedBufferSpace = getManagedProperty(connection, getBufferService(connection, mc),
- Platform.Operations.GET_BUFFER_USAGE);
+ usedBufferSpace = getManagedProperty(connection, getBufferService(
+ connection, mc), Platform.Operations.GET_BUFFER_USAGE);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.GET_BUFFER_USAGE; //$NON-NLS-1$
LOG.error(msg, e);
@@ -603,32 +686,52 @@
return usedBufferSpace;
}
-
- private void getRequestCollectionValue(MetaValue pValue,Collection<Request> list)
{
+
+ private void getRequestCollectionValue(MetaValue pValue,
+ Collection<Request> list) {
MetaType metaType = pValue.getMetaType();
if (metaType.isCollection()) {
- for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
+ for (MetaValue value : ((CollectionValueSupport) pValue)
+ .getElements()) {
if (value.getMetaType().isComposite()) {
RequestMetadataMapper rmm = new RequestMetadataMapper();
RequestMetadata request = rmm.unwrapMetaValue(value);
list.add(request);
} else {
- throw new IllegalStateException(pValue + " is not a Composite type");
//$NON-NLS-1$
+ throw new IllegalStateException(pValue
+ + " is not a Composite type"); //$NON-NLS-1$
}
}
}
}
+ private void getResultsCollectionValue(MetaValue pValue,
+ Collection<ArrayList<String>> list) {
+ MetaType metaType = pValue.getMetaType();
+ if (metaType.isCollection()) {
+ 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();
if (metaType.isCollection()) {
- for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
+ for (MetaValue value : ((CollectionValueSupport) pValue)
+ .getElements()) {
if (value.getMetaType().isComposite()) {
- Transaction transaction = (Transaction)
MetaValueFactory.getInstance().unwrap(value);
+ Transaction transaction = (Transaction) MetaValueFactory
+ .getInstance().unwrap(value);
list.add(transaction);
} else {
- throw new IllegalStateException(pValue + " is not a Composite type");
//$NON-NLS-1$
+ throw new IllegalStateException(pValue
+ + " is not a Composite type"); //$NON-NLS-1$
}
}
}
@@ -638,12 +741,15 @@
Collection<Session> list) {
MetaType metaType = pValue.getMetaType();
if (metaType.isCollection()) {
- for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
+ for (MetaValue value : ((CollectionValueSupport) pValue)
+ .getElements()) {
if (value.getMetaType().isComposite()) {
- Session Session = (Session) MetaValueFactory.getInstance().unwrap(value);
+ Session Session = (Session) MetaValueFactory.getInstance()
+ .unwrap(value);
list.add(Session);
} else {
- throw new IllegalStateException(pValue + " is not a Composite type");
//$NON-NLS-1$
+ throw new IllegalStateException(pValue
+ + " is not a Composite type"); //$NON-NLS-1$
}
}
}
@@ -653,14 +759,17 @@
Collection<Session> list, String vdbName) {
MetaType metaType = pValue.getMetaType();
if (metaType.isCollection()) {
- for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
+ for (MetaValue value : ((CollectionValueSupport) pValue)
+ .getElements()) {
if (value.getMetaType().isComposite()) {
- Session session = (Session) MetaValueFactory.getInstance().unwrap(value);
+ Session session = (Session) MetaValueFactory.getInstance()
+ .unwrap(value);
if (session.getVDBName().equals(vdbName)) {
list.add(session);
}
} else {
- throw new IllegalStateException(pValue + " is not a Composite type");
//$NON-NLS-1$
+ throw new IllegalStateException(pValue
+ + " is not a Composite type"); //$NON-NLS-1$
}
}
}
@@ -692,5 +801,30 @@
}
return reportResultList;
}
+
+ private Collection createReportResultListForMatViewQuery(List fieldNameList,
+ Iterator objectIter) {
+ Collection reportResultList = new ArrayList();
+ //Iterate throught rows
+ while (objectIter.hasNext()) {
+ 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) {
+ String fieldName = (String) fieldIter.next();
+ reportValueMap.put(fieldName, columnValue);
+ }
+ reportResultList.add(reportValueMap);
+ } catch (Throwable e) {
+ System.err.println(e);
+ }
+ }
+ return reportResultList;
+ }
+
}
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-07
18:42:05 UTC (rev 2635)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-10-07
22:34:28 UTC (rev 2636)
@@ -82,7 +82,8 @@
*
*/
public class VDBComponent extends Facet {
- private final Log LOG = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+ private final Log LOG = LogFactory
+ .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
/*
* (non-Javadoc)
@@ -122,7 +123,7 @@
} else if (name.equals(Platform.Operations.KILL_SESSION)) {
valueMap.put(Operation.Value.SESSION_ID, configuration.getSimple(
Operation.Value.SESSION_ID).getLongValue());
- }
+ }
}
@@ -134,9 +135,10 @@
@Override
public AvailabilityType getAvailability() {
// TODO Remove vdb version after no longer viable in Teiid
- String version = this.resourceConfiguration.getSimpleValue(
- "version", null);
- String status = DQPManagementView.getVDBStatus(getConnection(), this.name);
+ String version = this.resourceConfiguration.getSimpleValue("version",
+ null);
+ String status = DQPManagementView.getVDBStatus(getConnection(),
+ this.name);
if (status.equals("ACTIVE")) {
return AvailabilityType.UP;
}
@@ -165,8 +167,9 @@
String name = request.getName();
LOG.debug("Measurement name = " + name); //$NON-NLS-1$
- Object metricReturnObject = view.getMetric(getConnection(), getComponentType(), this
- .getComponentIdentifier(), name, valueMap);
+ Object metricReturnObject = view.getMetric(getConnection(),
+ getComponentType(), this.getComponentIdentifier(), name,
+ valueMap);
try {
if (request.getName().equals(
@@ -200,10 +203,11 @@
.getName()
.equals(
PluginConstants.ComponentType.VDB.Metrics.STATUS)) {
- if (((String) metricReturnObject).equals("ACTIVE")) {
+ if (((String) metricReturnObject)
+ .equals("ACTIVE")) {
report.addData(new MeasurementDataTrait(
request, "UP"));
- }else{
+ } else {
report.addData(new MeasurementDataTrait(
request, "DOWN"));
}
@@ -350,7 +354,7 @@
ManagedComponent mcVdb = null;
try {
- mcVdb = ProfileServiceUtil.getManagedComponent( getConnection(),
+ mcVdb = ProfileServiceUtil.getManagedComponent(getConnection(),
new org.jboss.managed.api.ComponentType(
PluginConstants.ComponentType.VDB.TYPE,
PluginConstants.ComponentType.VDB.SUBTYPE),
@@ -371,8 +375,8 @@
"description", String.class);
String vdbStatus = ProfileServiceUtil.getSimpleValue(mcVdb, "status",
String.class);
- String connectionType = ProfileServiceUtil.getSimpleValue(mcVdb,
"connectionType",
- String.class);
+ String connectionType = ProfileServiceUtil.getSimpleValue(mcVdb,
+ "connectionType", String.class);
String vdbURL = ProfileServiceUtil.getSimpleValue(mcVdb, "url",
String.class);
@@ -614,7 +618,8 @@
new PropertySimple("type", translatorType),
new PropertySimple("propertyName", propertyName),
new PropertySimple("propertyValue", propertyValue));
- // Only want translator name and value to show up for the first row,
+ // Only want translator name and value to show up for the
+ // first row,
// so we will blank them out here.
translatorName = "";
translatorType = "";
@@ -655,10 +660,10 @@
@Override
public ProfileServiceConnection getConnection() {
- return
((PlatformComponent)this.resourceContext.getParentResourceComponent()).getConnection();
+ return ((PlatformComponent) this.resourceContext
+ .getParentResourceComponent()).getConnection();
}
-
@Override
public EmsConnection getEmsConnection() {
// TODO Auto-generated method stub
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-07
18:42:05 UTC (rev 2635)
+++
branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-10-07
22:34:28 UTC (rev 2636)
@@ -97,13 +97,15 @@
public static interface Operations {
- public final static String GET_QUERIES = "listQueries"; //$NON-NLS-1$
+ public final static String GET_QUERIES = "listQueries"; //$NON-NLS-1$
+ public final static String EXECUTE_QUERIES = "executeQuery"; //$NON-NLS-1$
public final static String GET_LONGRUNNINGQUERIES =
"getLongRunningRequests"; //$NON-NLS-1$
public final static String KILL_REQUEST = "cancelRequest"; //$NON-NLS-1$
public final static String KILL_SESSION = "terminateSession";
//$NON-NLS-1$
public final static String GET_PROPERTIES = "getProperties"; //$NON-NLS-1$
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$
}
@@ -227,7 +229,9 @@
* @since 1.0
*/
public static interface Value {
- public final static String STOP_NOW = "stopNow"; //$NON-NLS-1$
+ 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 WAIT_UNTIL_FINISHED = "waitUntilFinished";
//$NON-NLS-1$
public final static String INCLUDE_SOURCE_QUERIES = "includeSourceQueries";
//$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-07 18:42:05
UTC (rev 2635)
+++ branches/7.1.x/console/src/main/resources/META-INF/rhq-plugin.xml 2010-10-07 22:34:28
UTC (rev 2636)
@@ -469,6 +469,35 @@
</results>
</operation>
+ <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"
+ description="Get information related to Materialized Views, if any, for this
VDB"
+ required="false">
+ <c:map-property name="map">
+ <c:simple-property displayName="Schema Name"
+ name="schemaName" type="string" description="Name of the
schema that is materialized" />
+ <c:simple-property displayName="Name" name="name"
+ type="string" description="Name of the materialized table"
/>
+ <c:simple-property displayName="Target Schema Name"
+ name="targetSchemaName" type="string" description="Name
of the materialized schema" />
+ <c:simple-property displayName="Target Name"
+ name="targetName" type="string" description="Name of
target table" />
+ <c:simple-property displayName="Created Time"
+ name="valid" type="string" description="Indicates if
data in table is valid for use" />
+ <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" />
+ <c:simple-property displayName="Cardinality"
+ name="cardinality" type="string" description="Row
count" />
+ </c:map-property>
+ </c:list-property>
+ </results>
+ </operation>
+
<metric displayName="Status" defaultOn="true"
dataType="trait"
displayType="summary" category="availability"
property="status"
description="The status of this VDB" />
@@ -611,9 +640,8 @@
description="Indicates if the role is mapped to any authenticated user"
readOnly="false" required="false" />
<c:simple-property name="description"
- displayName="Description" type="string"
- description="Description of this data role"
- readOnly="true" required="false" />
+ displayName="Description" type="string"
description="Description of this data role"
+ readOnly="true" required="false" />
<c:list-property name="mappedRoleNameList"
readOnly="false" required="false" displayName="Mapped Role
Names"
description="Mapped role names for this data role">
@@ -633,9 +661,11 @@
createDeletePolicy="both" creationDataType="configuration">
<resource-configuration>
- <c:simple-property name="name" displayName="Name"
description="Name of the translator" readOnly="true"
required="false" />
- <c:simple-property name="description"
displayName="Description" description="Description the translator"
readOnly="true" required="false" />
-
+ <c:simple-property name="name" displayName="Name"
+ description="Name of the translator" readOnly="true"
required="false" />
+ <c:simple-property name="description"
displayName="Description"
+ description="Description the translator" readOnly="true"
required="false" />
+
<c:list-property name="translatorList" readOnly="true"
required="false" displayName="Properties"
description="Translator properties">
<c:map-property name="properties" readOnly="true">