Author: rareddy
Date: 2012-07-20 16:44:01 -0400 (Fri, 20 Jul 2012)
New Revision: 4254
Modified:
trunk/admin/src/main/java/org/teiid/adminapi/Admin.java
trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java
trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
trunk/engine/pom.xml
trunk/jboss-integration/src/main/java/org/teiid/jboss/Element.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/OperationsConstants.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java
trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
trunk/metadata/pom.xml
Log:
TEIID-1985: adding get-plan to admin method, and also adding "include-source"
paramter for request based methods to retrieve only user level requests
Modified: trunk/admin/src/main/java/org/teiid/adminapi/Admin.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/Admin.java 2012-07-20 20:11:06 UTC (rev
4253)
+++ trunk/admin/src/main/java/org/teiid/adminapi/Admin.java 2012-07-20 20:44:01 UTC (rev
4254)
@@ -307,4 +307,12 @@
* @param typeNamePattern RegEx pattern to filter to names of tables, procedures that
are being read. Null means no filter.
*/
String getSchema(String vdbName, int vdbVersion, String modelName,
EnumSet<SchemaObjectType> allowedTypes, String typeNamePattern) throws
AdminException;
+
+ /**
+ * Get the Query Plan for the given session with provided execution id.
+ * @param sessionId
+ * @param executionId
+ * @return
+ */
+ String getQueryPlan(String sessionId, int executionId) throws AdminException;
}
Modified: trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java 2012-07-20 20:11:06 UTC
(rev 4253)
+++ trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java 2012-07-20 20:44:01 UTC
(rev 4254)
@@ -1374,6 +1374,23 @@
} catch (Exception e) {
throw new AdminProcessingException(AdminPlugin.Event.TEIID70046, e);
}
+ }
+
+ @Override
+ public String getQueryPlan(String sessionId, int executionId) throws AdminException {
+ final ModelNode request = buildRequest("teiid", "get-plan",
"session", sessionId, "execution-id",
String.valueOf(executionId));//$NON-NLS-1$
+ if (request == null) {
+ return null;
+ }
+ try {
+ ModelNode outcome = this.connection.execute(request);
+ if (!Util.isSuccess(outcome)) {
+ throw new AdminProcessingException(AdminPlugin.Event.TEIID70021,
Util.getFailureDescription(outcome));
+ }
+ return outcome.get(RESULT).asString();
+ } catch (Exception e) {
+ throw new AdminProcessingException(AdminPlugin.Event.TEIID70022, e);
+ }
}
}
}
Modified: trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java 2012-07-20
20:11:06 UTC (rev 4253)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java 2012-07-20
20:44:01 UTC (rev 4254)
@@ -341,6 +341,14 @@
@Doc(text = "models") String... models)
throws AdminException {
getAdmin().restartVDB(vdbName, vdbVersion, models);
+ }
+
+ @Doc(text = "Get query execution plan for the given execution id")
+ public static String getQueryPlan(
+ @Doc(text = "Session Id") String sessionId,
+ @Doc(text = "Execution Id") int executionId)
+ throws AdminException {
+ return getAdmin().getQueryPlan(sessionId, executionId);
}
@Doc(text = "Get the current org.teiid.adminapi.Admin instance for direct use.
Note: Used for advanced usecases to bypass AdminShell methods")
Modified: trunk/engine/pom.xml
===================================================================
--- trunk/engine/pom.xml 2012-07-20 20:11:06 UTC (rev 4253)
+++ trunk/engine/pom.xml 2012-07-20 20:44:01 UTC (rev 4254)
@@ -98,13 +98,6 @@
<artifactId>xom</artifactId>
<version>1.2</version>
</dependency>
-
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging</artifactId>
- <scope>test</scope>
- </dependency>
-
</dependencies>
</project>
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/Element.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/Element.java 2012-07-20 20:11:06
UTC (rev 4253)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/Element.java 2012-07-20 20:44:01
UTC (rev 4254)
@@ -236,7 +236,10 @@
}
public boolean isDefined(ModelNode node) {
- return node.hasDefined(getModelName());
+ if ( node.hasDefined(getModelName())) {
+ return !asString(node).isEmpty();
+ }
+ return false;
}
public int asInt(ModelNode node) {
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/OperationsConstants.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/OperationsConstants.java 2012-07-20
20:11:06 UTC (rev 4253)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/OperationsConstants.java 2012-07-20
20:44:01 UTC (rev 4254)
@@ -47,4 +47,6 @@
public static final String ENTITY_TYPE = "entity-type"; //$NON-NLS-1$
public static final String ENTITY_PATTERN = "entity-pattern"; //$NON-NLS-1$
+
+ public static final String INCLUDE_SOURCE = "include-source"; //$NON-NLS-1$
}
Modified:
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java 2012-07-20
20:11:06 UTC (rev 4253)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java 2012-07-20
20:44:01 UTC (rev 4254)
@@ -229,10 +229,21 @@
if (!operation.hasDefined(OperationsConstants.SESSION)) {
throw new OperationFailedException(new
ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.SESSION+MISSING)));
}
+ boolean includeSourceQueries = true;
+ if (operation.hasDefined(OperationsConstants.INCLUDE_SOURCE)) {
+ includeSourceQueries = operation.get(OperationsConstants.INCLUDE_SOURCE).asBoolean();
+ }
ModelNode result = context.getResult();
List<RequestMetadata> requests =
engine.getRequestsForSession(operation.get(OperationsConstants.SESSION).asString());
for (RequestMetadata request:requests) {
- VDBMetadataMapper.RequestMetadataMapper.INSTANCE.wrap(request, result.add());
+ if (request.sourceRequest()) {
+ if (includeSourceQueries) {
+ VDBMetadataMapper.RequestMetadataMapper.INSTANCE.wrap(request, result.add());
+ }
+ }
+ else {
+ VDBMetadataMapper.RequestMetadataMapper.INSTANCE.wrap(request, result.add());
+ }
}
}
@@ -240,6 +251,10 @@
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION,
TYPE).set(ModelType.STRING);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION,
REQUIRED).set(true);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SESSION));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.INCLUDE_SOURCE,
TYPE).set(ModelType.BOOLEAN);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.INCLUDE_SOURCE,
REQUIRED).set(false);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.INCLUDE_SOURCE,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.INCLUDE_SOURCE));
ModelNode reply = operationNode.get(REPLY_PROPERTIES);
reply.get(TYPE).set(ModelType.LIST);
@@ -253,13 +268,30 @@
}
@Override
protected void executeOperation(OperationContext context, DQPCore engine, ModelNode
operation) throws OperationFailedException{
+ boolean includeSourceQueries = true;
+ if (operation.hasDefined(OperationsConstants.INCLUDE_SOURCE)) {
+ includeSourceQueries = operation.get(OperationsConstants.INCLUDE_SOURCE).asBoolean();
+ }
+
ModelNode result = context.getResult();
List<RequestMetadata> requests = engine.getRequests();
for (RequestMetadata request:requests) {
- VDBMetadataMapper.RequestMetadataMapper.INSTANCE.wrap(request, result.add());
+ if (request.sourceRequest()) {
+ if (includeSourceQueries) {
+ VDBMetadataMapper.RequestMetadataMapper.INSTANCE.wrap(request, result.add());
+ }
+ }
+ else {
+ VDBMetadataMapper.RequestMetadataMapper.INSTANCE.wrap(request, result.add());
+ }
}
}
protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.INCLUDE_SOURCE,
TYPE).set(ModelType.BOOLEAN);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.INCLUDE_SOURCE,
REQUIRED).set(false);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.INCLUDE_SOURCE,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.INCLUDE_SOURCE));
+
ModelNode reply = operationNode.get(REPLY_PROPERTIES);
reply.get(TYPE).set(ModelType.LIST);
VDBMetadataMapper.RequestMetadataMapper.INSTANCE.describe(reply.get(VALUE_TYPE));
@@ -279,13 +311,25 @@
throw new OperationFailedException(new
ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_VERSION+MISSING)));
}
+ boolean includeSourceQueries = true;
+ if (operation.hasDefined(OperationsConstants.INCLUDE_SOURCE)) {
+ includeSourceQueries = operation.get(OperationsConstants.INCLUDE_SOURCE).asBoolean();
+ }
+
ModelNode result = context.getResult();
String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
for (TransportService t: this.transports) {
List<RequestMetadata> requests = t.getRequestsUsingVDB(vdbName,vdbVersion);
for (RequestMetadata request:requests) {
- VDBMetadataMapper.RequestMetadataMapper.INSTANCE.wrap(request, result.add());
+ if (request.sourceRequest()) {
+ if (includeSourceQueries) {
+ VDBMetadataMapper.RequestMetadataMapper.INSTANCE.wrap(request, result.add());
+ }
+ }
+ else {
+ VDBMetadataMapper.RequestMetadataMapper.INSTANCE.wrap(request, result.add());
+ }
}
}
}
@@ -298,7 +342,12 @@
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
TYPE).set(ModelType.INT);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
REQUIRED).set(true);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.INCLUDE_SOURCE,
TYPE).set(ModelType.BOOLEAN);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.INCLUDE_SOURCE,
REQUIRED).set(false);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.INCLUDE_SOURCE,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.INCLUDE_SOURCE));
+
ModelNode reply = operationNode.get(REPLY_PROPERTIES);
reply.get(TYPE).set(ModelType.LIST);
VDBMetadataMapper.RequestMetadataMapper.INSTANCE.describe(reply.get(VALUE_TYPE));
@@ -383,7 +432,7 @@
class GetPlan extends TeiidOperationHandler{
protected GetPlan() {
- super("get-plan"); //$NON-NLS-1$
+ super("get-query-plan"); //$NON-NLS-1$
}
@Override
protected void executeOperation(OperationContext context, DQPCore engine, ModelNode
operation) throws OperationFailedException{
Modified: trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2012-07-20
20:11:06 UTC (rev 4253)
+++ trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2012-07-20
20:44:01 UTC (rev 4254)
@@ -254,10 +254,10 @@
cancel-request.execution-id.describe=The Execution Identifier of the query
cancel-request.reply=True if successful; false otherwise.
-get-plan.describe=Get the plan of the actively running query
-get-plan.session.describe=The session Identifier of the user
-get-plan.execution-id.describe=The Execution Identifier of the query
-get-plan.reply=the plan as xml if successful; null otherwise.
+get-query-plan.describe=Get the plan of the actively running query
+get-query-plan.session.describe=The session Identifier of the user
+get-query-plan.execution-id.describe=The Execution Identifier of the query
+get-query-plan.reply=the plan as xml if successful; null otherwise.
change-vdb-connection-type.describe=Change the default VDB version selection
change-vdb-connection-type.vdb-name.describe=VDB Name
@@ -306,6 +306,7 @@
get-schema.reply=schema in the form of DDL
list-requests.describe=List of active requests
+list-requests.include-source.describe=include source queries; defaults to true
list-requests.reply=list of requests
list-sessions.describe=List of all the current active sessions in the Teiid subsystem.
@@ -349,11 +350,13 @@
list-requests-per-session.describe=Current active requests in progress in the query
engine for a given session identifier
list-requests-per-session.session.describe=The session Identifier
+list-requests-per-session.include-source.describe=include source queries; defaults to
true
list-requests-per-session.reply=requests for given session
list-requests-per-vdb.describe=Current active requests in progress in the query engine
for a given VDB name and its version.
list-requests-per-vdb.vdb-name.describe=VDB Name
list-requests-per-vdb.vdb-version.describe=VDB Version
+list-requests-per-vdb.include-source.describe=include source queries; defaults to true
list-requests-per-vdb.reply=list of requests on the given vdb
terminate-session.describe=Terminate the session
Modified: trunk/metadata/pom.xml
===================================================================
--- trunk/metadata/pom.xml 2012-07-20 20:11:06 UTC (rev 4253)
+++ trunk/metadata/pom.xml 2012-07-20 20:44:01 UTC (rev 4254)
@@ -63,13 +63,6 @@
<artifactId>jboss-vfs</artifactId>
<scope>provided</scope>
</dependency>
-
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging</artifactId>
- <scope>test</scope>
- </dependency>
-
</dependencies>
</project>
\ No newline at end of file